diff --git a/Program.cs b/Program.cs index f1a5355..4a0d8fa 100644 --- a/Program.cs +++ b/Program.cs @@ -112,45 +112,10 @@ namespace dy.net services.AddResponseCompression(); // JWT认证 - ConfigureJwtAuthentication(services); + services.ConfigureJwtAuthentication(); } - /// - /// 配置JWT认证 - /// - private static void ConfigureJwtAuthentication(IServiceCollection services) - { - var key = Encoding.ASCII.GetBytes(Md5Util.JWT_TOKEN_KEY); - - services.AddAuthentication(options => - { - options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; - options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; - }) - .AddJwtBearer(options => - { - options.Events = new JwtBearerEvents - { - OnMessageReceived = context => - { - context.Token = context.Request.Headers["Authorization"] - .FirstOrDefault()?.Split(" ").Last(); - return Task.CompletedTask; - } - }; - options.RequireHttpsMetadata = false; - options.SaveToken = true; - options.TokenValidationParameters = new TokenValidationParameters - { - ValidateIssuerSigningKey = true, - IssuerSigningKey = new SymmetricSecurityKey(key), - ValidateIssuer = false, - ValidateAudience = false, - ValidateLifetime = true, - ClockSkew = TimeSpan.FromSeconds(60) - }; - }); - } + /// /// 配置中间件 @@ -187,28 +152,6 @@ namespace dy.net } } - /// - /// 配置上传路径 - /// - private static void ConfigureUploadPath(WebApplication app, bool isDevelopment) - { - var uploadPath = isDevelopment - ? Md5Util.UPLOAD_PATH_DEV - : Md5Util.UPLOAD_PATH_PRO; - - if (!Directory.Exists(uploadPath)) - { - Directory.CreateDirectory(uploadPath); - } - - // 如需启用文件上传访问可取消注释 - // app.UseStaticFiles(new StaticFileOptions - // { - // FileProvider = new PhysicalFileProvider(uploadPath), - // RequestPath = "/upload" - // }); - } - /// /// 初始化应用服务数据 /// @@ -221,46 +164,25 @@ namespace dy.net { // 初始化用户 var userService = services.GetRequiredService(); - userService.InitUser(new LoginUserInfo - { - UserName = "douyin", - Password = "douyin2025", - CreateTime = DateTime.Now - }); + userService.InitUser(); // 初始化Cookie var cookieService = services.GetRequiredService(); - cookieService.Init(new DyUserCookies - { - UserName = "douyin", - Cookies = "--", - Id = "2026", - SavePath = "/app/collect", - Status = 0, - SecUserId = "--", - FavSavePath = "/app/favorite", - UpSavePath = "/app/uper", - }); - - + cookieService.Init(); // 初始化配置 var commonService = services.GetRequiredService(); - var config = commonService.InitConfig(new AppConfig - { - Id = IdGener.GetLong().ToString(), - Cron = "30", - BatchCount = 10 - }); + var config = commonService.InitConfig(); // 更新收藏视频类型--兼容老版本-原来的旧数据没有这个类型字段 commonService.UpdateCollectViedoType(); - + // 重置博主作品同步状态为未同步 commonService.UpdateAllCookieSyncedToZero(); - Serilog.Log.Debug("系统初始化,会默认将-博主作品同步功能-同步全部作品重置为关闭(若要开启,可以到抖音授权菜单中更改)"); // 启动定时任务 var quartzJobService = services.GetRequiredService(); quartzJobService.StartJob(config?.Cron ?? "30"); + + Serilog.Log.Debug("系统初始化完成,会默认将-博主作品同步功能-同步全部作品重置为关闭(若要开启,可以到抖音授权菜单中更改)"); } catch (Exception ex) { @@ -269,63 +191,8 @@ namespace dy.net } } - /// - /// 创建SQLite数据库连接字符串 - /// - private static string CreateSqliteDBConn() - { - var dbFolder = Path.Combine(Environment.CurrentDirectory, "db"); - Directory.CreateDirectory(dbFolder); // 不存在则创建,无需判断 + - var dbPath = Path.Combine(dbFolder, "dy.sqlite"); - if (!File.Exists(dbPath)) - { - using (File.Create(dbPath)) { } // 使用using确保文件流关闭 - } - - return $"DataSource={dbPath}"; - } - - /// - /// 初始化数据库 - /// - private static ISqlSugarClient InitDataBase(DbType dbType, string connString) - { - // 处理SQLite连接字符串 - if (dbType == DbType.Sqlite) - { - connString = CreateSqliteDBConn(); - } - - if (string.IsNullOrWhiteSpace(connString)) - { - return null; - } - - return new SqlSugarClient(new ConnectionConfig - { - ConnectionString = connString, - InitKeyType = InitKeyType.Attribute, - DbType = dbType, - IsAutoCloseConnection = true - }, db => - { - // 日志配置 - db.Aop.OnLogExecuting = (sql, pars) => Serilog.Log.Debug(sql); - db.Aop.OnError = e => - { - Serilog.Log.Error(e.Message); - Serilog.Log.Error(e.Sql); - }; - - // 创建数据库和表 - db.DbMaintenance.CreateDatabase(); - var modelTypes = Assembly.GetExecutingAssembly() - .GetTypes() - .Where(t => t.Namespace?.StartsWith("dy.net.model") ?? false) - .ToArray(); - db.CodeFirst.InitTables(modelTypes); - }); - } + } } \ No newline at end of file diff --git a/Properties/PublishProfiles/FolderProfile.pubxml.user b/Properties/PublishProfiles/FolderProfile.pubxml.user index 0131b15..98ebba2 100644 --- a/Properties/PublishProfiles/FolderProfile.pubxml.user +++ b/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. <_PublishTargetUrl>F:\work\code\me\dysync.net\bin\Release\net6.0\publish\ - True|2025-10-21T10:35:28.8392541Z||;True|2025-10-20T10:31:05.5865212+08:00||;True|2025-10-20T10:20:41.5717101+08:00||;True|2025-10-19T10:08:33.6669332+08:00||;False|2025-10-19T10:07:22.3337545+08:00||;False|2025-10-19T10:05:22.9484805+08:00||;True|2025-10-10T16:54:27.1472888+08:00||;False|2025-10-10T16:53:44.1700030+08:00||;False|2025-10-10T16:52:48.1740453+08:00||;False|2025-10-10T16:51:21.5067253+08:00||;False|2025-10-10T16:50:19.2140597+08:00||;False|2025-10-10T16:49:21.2213290+08:00||;False|2025-10-10T16:48:47.7229948+08:00||;False|2025-10-10T16:48:15.1258700+08:00||;True|2025-09-30T13:29:42.2354235+08:00||;True|2025-09-25T11:44:52.6858389+08:00||;True|2025-09-25T11:08:27.8810109+08:00||;True|2025-09-25T09:28:50.2563374+08:00||;True|2025-09-24T16:14:02.3072184+08:00||;True|2025-09-23T22:38:52.4414757+08:00||;True|2025-09-23T22:19:07.1006356+08:00||;True|2025-09-23T22:18:01.5945225+08:00||;True|2025-09-23T22:06:15.6293613+08:00||;True|2025-09-23T21:53:14.2977444+08:00||;True|2025-09-23T21:46:55.2322411+08:00||;False|2025-09-23T21:45:23.7858854+08:00||;False|2025-09-23T21:03:51.8325689+08:00||;True|2025-09-23T10:03:32.2251920+08:00||;False|2025-09-23T09:38:08.2372201+08:00||;False|2025-09-23T09:37:49.9390545+08:00||;True|2024-03-11T21:31:45.8102398+08:00||;True|2024-03-11T07:26:24.7660541+08:00||;True|2024-03-08T22:08:40.0154831+08:00||;True|2024-03-03T10:14:36.8109114+08:00||;True|2024-03-02T18:44:57.3288537+08:00||;True|2024-01-24T17:51:37.9164415+08:00||;True|2024-01-24T16:36:50.5612157+08:00||;True|2024-01-24T15:51:35.7556653+08:00||;True|2024-01-17T23:40:40.7526618+08:00||;True|2024-01-17T23:36:10.3692844+08:00||;True|2024-01-17T23:22:03.2378834+08:00||;True|2024-01-03T11:35:44.7118292+08:00||;True|2024-01-03T11:11:23.4270453+08:00||;True|2024-01-03T11:04:35.2081526+08:00||;True|2024-01-03T10:57:03.7053107+08:00||;True|2024-01-03T10:51:50.7463989+08:00||;False|2024-01-03T10:50:24.9775312+08:00||;True|2024-01-03T10:47:30.1128183+08:00||;True|2024-01-03T10:42:55.8640657+08:00||;True|2024-01-03T09:24:24.3436056+08:00||;True|2024-01-02T23:40:38.2001198+08:00||;True|2024-01-02T23:08:36.7230444+08:00||;True|2024-01-02T22:53:43.9658255+08:00||;True|2024-01-02T22:25:38.5545279+08:00||;False|2024-01-02T22:24:42.6577609+08:00||;True|2024-01-02T22:04:33.4708889+08:00||;True|2024-01-02T21:49:57.9249898+08:00||;True|2023-12-28T22:42:58.5976180+08:00||;True|2023-12-28T22:24:09.2051205+08:00||;True|2023-12-28T22:05:48.4865497+08:00||;True|2023-12-28T21:50:57.4549336+08:00||;True|2023-12-28T21:45:30.4557939+08:00||;True|2023-12-28T21:19:59.3614594+08:00||;False|2023-12-28T21:17:04.3069097+08:00||;False|2023-12-28T21:15:56.7788810+08:00||;False|2023-12-28T21:14:57.3617402+08:00||;False|2023-12-28T21:10:45.4382469+08:00||;True|2023-12-28T19:45:33.1431914+08:00||;True|2023-12-26T11:30:36.6418716+08:00||;True|2023-12-26T11:17:40.6433651+08:00||;True|2023-12-26T09:13:56.0741559+08:00||;True|2023-12-26T09:10:55.5358737+08:00||;True|2023-12-25T23:15:34.6534359+08:00||;True|2023-12-25T23:09:47.1566176+08:00||;False|2023-12-25T23:07:32.1118803+08:00||;True|2023-12-25T22:59:50.4643459+08:00||;True|2023-12-25T22:50:14.3584798+08:00||;False|2023-12-25T22:49:20.0279513+08:00||;True|2023-12-25T22:44:07.4183973+08:00||;True|2023-12-25T22:35:27.3847085+08:00||;True|2023-12-25T22:23:21.3542658+08:00||;True|2023-12-25T22:12:00.5219522+08:00||;True|2023-12-25T16:52:12.5089621+08:00||;True|2023-12-25T16:43:30.8348193+08:00||;True|2023-12-25T16:35:08.2421925+08:00||;True|2023-12-25T16:25:21.3233455+08:00||;False|2023-12-25T16:24:39.1703901+08:00||;True|2023-12-25T16:24:01.4340091+08:00||;True|2023-12-25T16:10:06.5213850+08:00||;True|2023-12-25T15:42:17.1376331+08:00||;True|2023-12-25T15:29:47.8537015+08:00||;True|2023-12-25T14:04:54.3750643+08:00||;False|2023-12-25T14:04:07.9330700+08:00||;True|2023-12-25T13:51:58.1949269+08:00||;True|2023-12-25T13:41:42.4832670+08:00||;True|2023-12-25T13:00:25.3861450+08:00||;True|2023-12-25T12:48:45.3851245+08:00||;True|2023-12-25T12:46:54.1266013+08:00||;True|2023-12-25T12:37:03.2615780+08:00||;False|2023-12-25T12:36:06.2657224+08:00||; + True|2025-10-22T07:01:04.1668366Z||;True|2025-10-22T14:49:43.6340569+08:00||;True|2025-10-22T14:38:39.4685603+08:00||;True|2025-10-21T18:35:28.8392541+08:00||;True|2025-10-20T10:31:05.5865212+08:00||;True|2025-10-20T10:20:41.5717101+08:00||;True|2025-10-19T10:08:33.6669332+08:00||;False|2025-10-19T10:07:22.3337545+08:00||;False|2025-10-19T10:05:22.9484805+08:00||;True|2025-10-10T16:54:27.1472888+08:00||;False|2025-10-10T16:53:44.1700030+08:00||;False|2025-10-10T16:52:48.1740453+08:00||;False|2025-10-10T16:51:21.5067253+08:00||;False|2025-10-10T16:50:19.2140597+08:00||;False|2025-10-10T16:49:21.2213290+08:00||;False|2025-10-10T16:48:47.7229948+08:00||;False|2025-10-10T16:48:15.1258700+08:00||;True|2025-09-30T13:29:42.2354235+08:00||;True|2025-09-25T11:44:52.6858389+08:00||;True|2025-09-25T11:08:27.8810109+08:00||;True|2025-09-25T09:28:50.2563374+08:00||;True|2025-09-24T16:14:02.3072184+08:00||;True|2025-09-23T22:38:52.4414757+08:00||;True|2025-09-23T22:19:07.1006356+08:00||;True|2025-09-23T22:18:01.5945225+08:00||;True|2025-09-23T22:06:15.6293613+08:00||;True|2025-09-23T21:53:14.2977444+08:00||;True|2025-09-23T21:46:55.2322411+08:00||;False|2025-09-23T21:45:23.7858854+08:00||;False|2025-09-23T21:03:51.8325689+08:00||;True|2025-09-23T10:03:32.2251920+08:00||;False|2025-09-23T09:38:08.2372201+08:00||;False|2025-09-23T09:37:49.9390545+08:00||;True|2024-03-11T21:31:45.8102398+08:00||;True|2024-03-11T07:26:24.7660541+08:00||;True|2024-03-08T22:08:40.0154831+08:00||;True|2024-03-03T10:14:36.8109114+08:00||;True|2024-03-02T18:44:57.3288537+08:00||;True|2024-01-24T17:51:37.9164415+08:00||;True|2024-01-24T16:36:50.5612157+08:00||;True|2024-01-24T15:51:35.7556653+08:00||;True|2024-01-17T23:40:40.7526618+08:00||;True|2024-01-17T23:36:10.3692844+08:00||;True|2024-01-17T23:22:03.2378834+08:00||;True|2024-01-03T11:35:44.7118292+08:00||;True|2024-01-03T11:11:23.4270453+08:00||;True|2024-01-03T11:04:35.2081526+08:00||;True|2024-01-03T10:57:03.7053107+08:00||;True|2024-01-03T10:51:50.7463989+08:00||;False|2024-01-03T10:50:24.9775312+08:00||;True|2024-01-03T10:47:30.1128183+08:00||;True|2024-01-03T10:42:55.8640657+08:00||;True|2024-01-03T09:24:24.3436056+08:00||;True|2024-01-02T23:40:38.2001198+08:00||;True|2024-01-02T23:08:36.7230444+08:00||;True|2024-01-02T22:53:43.9658255+08:00||;True|2024-01-02T22:25:38.5545279+08:00||;False|2024-01-02T22:24:42.6577609+08:00||;True|2024-01-02T22:04:33.4708889+08:00||;True|2024-01-02T21:49:57.9249898+08:00||;True|2023-12-28T22:42:58.5976180+08:00||;True|2023-12-28T22:24:09.2051205+08:00||;True|2023-12-28T22:05:48.4865497+08:00||;True|2023-12-28T21:50:57.4549336+08:00||;True|2023-12-28T21:45:30.4557939+08:00||;True|2023-12-28T21:19:59.3614594+08:00||;False|2023-12-28T21:17:04.3069097+08:00||;False|2023-12-28T21:15:56.7788810+08:00||;False|2023-12-28T21:14:57.3617402+08:00||;False|2023-12-28T21:10:45.4382469+08:00||;True|2023-12-28T19:45:33.1431914+08:00||;True|2023-12-26T11:30:36.6418716+08:00||;True|2023-12-26T11:17:40.6433651+08:00||;True|2023-12-26T09:13:56.0741559+08:00||;True|2023-12-26T09:10:55.5358737+08:00||;True|2023-12-25T23:15:34.6534359+08:00||;True|2023-12-25T23:09:47.1566176+08:00||;False|2023-12-25T23:07:32.1118803+08:00||;True|2023-12-25T22:59:50.4643459+08:00||;True|2023-12-25T22:50:14.3584798+08:00||;False|2023-12-25T22:49:20.0279513+08:00||;True|2023-12-25T22:44:07.4183973+08:00||;True|2023-12-25T22:35:27.3847085+08:00||;True|2023-12-25T22:23:21.3542658+08:00||;True|2023-12-25T22:12:00.5219522+08:00||;True|2023-12-25T16:52:12.5089621+08:00||;True|2023-12-25T16:43:30.8348193+08:00||;True|2023-12-25T16:35:08.2421925+08:00||;True|2023-12-25T16:25:21.3233455+08:00||;False|2023-12-25T16:24:39.1703901+08:00||;True|2023-12-25T16:24:01.4340091+08:00||;True|2023-12-25T16:10:06.5213850+08:00||;True|2023-12-25T15:42:17.1376331+08:00||;True|2023-12-25T15:29:47.8537015+08:00||;True|2023-12-25T14:04:54.3750643+08:00||;False|2023-12-25T14:04:07.9330700+08:00||;True|2023-12-25T13:51:58.1949269+08:00||;True|2023-12-25T13:41:42.4832670+08:00||;True|2023-12-25T13:00:25.3861450+08:00||;True|2023-12-25T12:48:45.3851245+08:00||; \ No newline at end of file diff --git a/app/src/components/switch/DayNightSwitch.vue b/app/src/components/switch/DayNightSwitch.vue index 62d73e6..9f496d1 100644 --- a/app/src/components/switch/DayNightSwitch.vue +++ b/app/src/components/switch/DayNightSwitch.vue @@ -1,62 +1,71 @@ diff --git a/app/src/pages/workplace/statics copy 2.vue b/app/src/pages/workplace/statics copy 2.vue new file mode 100644 index 0000000..572c088 --- /dev/null +++ b/app/src/pages/workplace/statics copy 2.vue @@ -0,0 +1,745 @@ + + + + + \ No newline at end of file diff --git a/app/src/pages/workplace/statics copy.vue b/app/src/pages/workplace/statics copy.vue new file mode 100644 index 0000000..db166d8 --- /dev/null +++ b/app/src/pages/workplace/statics copy.vue @@ -0,0 +1,922 @@ + + + + + \ No newline at end of file diff --git a/app/src/pages/workplace/statics.vue b/app/src/pages/workplace/statics.vue index db166d8..673fa24 100644 --- a/app/src/pages/workplace/statics.vue +++ b/app/src/pages/workplace/statics.vue @@ -1,567 +1,190 @@ @@ -584,16 +207,23 @@ interface Category { icon: string; } -// 3. 鍒濆Tab鏀逛负"瑙嗛浣滆"锛坈urrentTab榛樿鍊间粠'type'鏀逛负'author'锛 +// 鐘舵佺鐞 - 鍖呭惈鍠滄銆佹敹钘忋佸叧娉ㄧ殑鏁伴噺鍙婄┖闂寸粺璁 const totalVideos = ref(0); const totalAuthors = ref(0); const categoryTotal = ref(0); -const fileSizeTotal = ref(0); +const fileSizeTotal = ref('0.00'); +const totalDiskSize = ref('0.00'); + const favoriteCount = ref(0); const collectCount = ref(0); +const followCount = ref(0); // 鏂板锛氬叧娉ㄧ殑鏁伴噺 +const favoriteSize = ref('0.00'); // 鍠滄鍗犵敤绌洪棿 +const collectSize = ref('0.00'); // 鏀惰棌鍗犵敤绌洪棿 +const followSize = ref('0.00'); // 鏂板锛氬叧娉ㄥ崰鐢ㄧ┖闂 const categories = ref([]); const authors = ref([]); -const currentTab = ref('author'); // 榛樿鏄剧ず"瑙嗛浣滆"Tab +const currentTab = ref('author'); +const tabCount = ref(0); // tab鍒囨崲鏃舵樉绀烘暟閲 // 缁勪欢鍚嶇О defineOptions({ @@ -602,19 +232,34 @@ defineOptions({ // 鍔犺浇鏁版嵁 onMounted(() => { + // const html = document.documentElement; + // html.classList.add('dark-mode'); loadDashboardData(); }); +const changeTab = (e: any) => { + currentTab.value = e; + if (e == 'author') { + tabCount.value = totalAuthors.value; + } else { + tabCount.value = categoryTotal.value; + } +}; const loadDashboardData = async () => { try { const res = await useApiStore().VideoStatics(); - totalVideos.value = res.data.videoCount; totalAuthors.value = res.data.authorCount; categoryTotal.value = res.data.categoryCount; + totalVideos.value = res.data.videoCount; + fileSizeTotal.value = res.data.videoSizeTotal || 0.0; + totalDiskSize.value = res.data.totalDiskSize || 0.0; favoriteCount.value = res.data.favoriteCount; collectCount.value = res.data.collectCount; + followCount.value = res.data.followCount || 0; // 鏂板锛氳鍙栧叧娉ㄦ暟閲 + favoriteSize.value = res.data.videoFavoriteSize || 0.0; + collectSize.value = res.data.videoCollectSize || 0.0; + followSize.value = res.data.videoFollowSize || 0.0; // 鏂板锛氳鍙栧叧娉ㄥ崰鐢ㄧ┖闂 categories.value = res.data.categories; - fileSizeTotal.value = res.data.viedoSizeTotal; // 娉ㄦ剰锛氬師浠g爜"video"鎷煎啓閿欒锛坴iedo锛夛紝寤鸿淇涓"videoSizeTotal" authors.value = res.data.authors; // 鍒嗙被鍥炬爣鍜岄鑹查殢鏈哄垎閰 @@ -656,8 +301,6 @@ const categoriessss = ref([ 'tv', 'watch', 'charger', - 'router', - 'printer', ]); const colorArray = [ @@ -667,7 +310,6 @@ const colorArray = [ '#829399', '#A63446', '#4F6367', - '#EEF4ED', '#FE5F55', '#C7EFCF', '#78C0E0', @@ -680,243 +322,431 @@ const colorArray = [ \ No newline at end of file diff --git a/app/src/store/setting.ts b/app/src/store/setting.ts index d903c01..88d1634 100644 --- a/app/src/store/setting.ts +++ b/app/src/store/setting.ts @@ -6,7 +6,7 @@ export type Navigation = 'side' | 'head' | 'mix'; export const useSettingStore = defineStore('setting', () => { const navigation = ref('head'); const useTabs = ref(true); - const theme = ref('header-purple'); + const theme = ref('header-night'); const contentClass = ref('common'); const filterMenu = ref(false); diff --git a/app/src/theme/index.ts b/app/src/theme/index.ts index 81733b6..ef8c198 100644 --- a/app/src/theme/index.ts +++ b/app/src/theme/index.ts @@ -17,7 +17,8 @@ export function configTheme(key: string) { const { setNavigation, setTheme } = useSettingStore(); switch (key) { case 'night': - setBgSeriesColors({ 'bg-base': '#1D1D1F' }); + // setBgSeriesColors({ 'bg-base': '#1D1D1F' }); + setBgSeriesColors({ 'bg-base': '#1a1a2e' }); break; case 'header-dark': setNavigation('head'); @@ -84,12 +85,20 @@ export const themeList: Theme.ThemeConfig[] = [ }, { title: '鏆楀绱', - key: 'purple', + key: 'purple2', imgUrl: PurpleImg, config: { color: { middle: { 'bg-base': '#361F68' } }, }, }, + { + title: '鏆楀', + key: 'purple', + imgUrl: PurpleImg, + config: { + color: { middle: { 'bg-base': '#1a1a2e' } }, + }, + }, { title: '涓浗绾', key: 'china', diff --git a/app/vite.config.ts b/app/vite.config.ts index 8b9eda3..2056e57 100644 --- a/app/vite.config.ts +++ b/app/vite.config.ts @@ -26,7 +26,6 @@ const prodRollupOptions = { export default ({ command, mode }) => { // 鑾峰彇鐜鍙橀噺 const env = loadEnv(mode, process.cwd()); - return defineConfig({ server: { host: "0.0.0.0", @@ -85,7 +84,14 @@ export default ({ command, mode }) => { preprocessorOptions: { less: { plugins: [AntdvLessPlugin], - modifyVars: AntdvModifyVars, + + modifyVars: { + ...AntdvModifyVars, // 淇濈暀榛樿鍙橀噺锛堝彲閫夛紝鎸夐渶娣诲姞锛 + '@primary-color': '#722ed1', + // 浣犵殑鑷畾涔変富鑹茶皟锛堟牳蹇冿細瑕嗙洊榛樿鍊硷級 + // 鍏朵粬闇瑕佷慨鏀圭殑鍙橀噺 + // '@link-color': '#722ed1', + }, javascriptEnabled: true, }, }, diff --git a/dto/VideoStaticsDto.cs b/dto/VideoStaticsDto.cs index 80ba9cd..3f1897c 100644 --- a/dto/VideoStaticsDto.cs +++ b/dto/VideoStaticsDto.cs @@ -23,11 +23,19 @@ public long CategoryCount { get; set; } - public double ViedoSizeTotal { get; set; } + public string VideoSizeTotal { get; set; } + + public string VideoCollectSize { get; set; } + public string VideoFollowSize { get; set; } + public string VideoFavoriteSize { get; set; } public long CollectCount { get; set; } public long FavoriteCount { get; set; } + public long FollowCount { get; set; } + + + public string TotalDiskSize { get; set; } public List Authors { get; set; } = new List(); public List Categories { get; set; } = new List(); } diff --git a/extension/ServiceExtension.cs b/extension/ServiceExtension.cs index 32f26aa..6471d5e 100644 --- a/extension/ServiceExtension.cs +++ b/extension/ServiceExtension.cs @@ -1,9 +1,12 @@ 锘縰sing dy.net.job; using dy.net.service; +using dy.net.utils; +using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.AspNetCore.Mvc.Authorization; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.ResponseCompression; +using Microsoft.IdentityModel.Tokens; using Microsoft.OpenApi.Models; using Quartz; using Serilog; @@ -16,6 +19,7 @@ using Swashbuckle.AspNetCore.SwaggerUI; using System.IO.Compression; using System.Net.Http; using System.Reflection; +using System.Text; namespace dy.net.extension { @@ -72,6 +76,44 @@ namespace dy.net.extension return conn; } + + /// + /// 閰嶇疆JWT璁よ瘉 + /// + public static void ConfigureJwtAuthentication(this IServiceCollection services) + { + var key = Encoding.ASCII.GetBytes(Md5Util.JWT_TOKEN_KEY); + + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; + }) + .AddJwtBearer(options => + { + options.Events = new JwtBearerEvents + { + OnMessageReceived = context => + { + context.Token = context.Request.Headers["Authorization"] + .FirstOrDefault()?.Split(" ").Last(); + return Task.CompletedTask; + } + }; + options.RequireHttpsMetadata = false; + options.SaveToken = true; + options.TokenValidationParameters = new TokenValidationParameters + { + ValidateIssuerSigningKey = true, + IssuerSigningKey = new SymmetricSecurityKey(key), + ValidateIssuer = false, + ValidateAudience = false, + ValidateLifetime = true, + ClockSkew = TimeSpan.FromSeconds(60) + }; + }); + } + public static void AddSqlsugar(this IServiceCollection services, IConfiguration configuration) { DbType dbtype = GetDBType(configuration); diff --git a/job/DouYinCollectSyncJob.cs b/job/DouYinCollectSyncJob.cs index 99f7a38..fdbd25f 100644 --- a/job/DouYinCollectSyncJob.cs +++ b/job/DouYinCollectSyncJob.cs @@ -65,6 +65,11 @@ namespace dy.net.job Serilog.Log.Debug($"collect-Cookie-[{cookie.UserName}]鏃犳晥锛岃烦杩"); continue; } + if (string.IsNullOrWhiteSpace(cookie.SavePath)) + { + Serilog.Log.Debug($"collect-Cookie-[{cookie.UserName}]鏈缃繚瀛樿矾寰勶紝璺宠繃"); + continue; + } try { int syncCount = 0;// 璁板綍鏈Cookie鍚屾鐨勮棰戞暟閲 diff --git a/service/CommonService.cs b/service/CommonService.cs index 60537af..74be584 100644 --- a/service/CommonService.cs +++ b/service/CommonService.cs @@ -1,6 +1,8 @@ -锘縰sing dy.net.dto; +锘縰sing ClockSnowFlake; +using dy.net.dto; using dy.net.model; using SqlSugar; +using System.Reflection; using System.Threading.Tasks; namespace dy.net.service @@ -14,39 +16,49 @@ namespace dy.net.service this.sqlSugarClient = sqlSugarClient; } - public AppConfig GetConfig() + public AppConfig GetConfig() { - return sqlSugarClient.Queryable().First(); + return sqlSugarClient.Queryable().First(); } - public AppConfig InitConfig(AppConfig config) + public AppConfig InitConfig() { var conf = GetConfig(); if (conf != null) return conf; else { - var add = sqlSugarClient.Insertable(config).ExecuteCommand(); + AppConfig config = new AppConfig + { + Id = IdGener.GetLong().ToString(), + Cron = "30", + BatchCount = 10 + }; + sqlSugarClient.Insertable(config).ExecuteCommand(); return config; } + + } - public async Task UpdateConfig(AppConfig config) { + public async Task UpdateConfig(AppConfig config) + { - var cc = await sqlSugarClient.Queryable().FirstAsync(x=>x.Id== config.Id); + var cc = await sqlSugarClient.Queryable().FirstAsync(x => x.Id == config.Id); if (cc == null) return false; - else { + else + { cc.Cron = config.Cron; cc.BatchCount = config.BatchCount; } var update = await sqlSugarClient.Updateable(cc).ExecuteCommandAsync(); - return update > 0 ; + return update > 0; } /// @@ -54,11 +66,12 @@ namespace dy.net.service /// public void UpdateCollectViedoType() { - var collectViedos= sqlSugarClient.Queryable().Where(x=>string.IsNullOrWhiteSpace(x.ViedoType)).ToList(); + var collectViedos = sqlSugarClient.Queryable().Where(x => string.IsNullOrWhiteSpace(x.ViedoType)).ToList(); if (collectViedos.Any()) { - collectViedos.ForEach(x => { + collectViedos.ForEach(x => + { x.ViedoType = "2"; }); sqlSugarClient.Updateable(collectViedos).ExecuteCommand(); @@ -72,7 +85,7 @@ namespace dy.net.service { //var sql = "update dy_cookie set CollHasSyncd=0,FavHasSyncd=0,UperSyncd=0"; // sqlSugarClient.Ado.ExecuteCommand(sql) > 0; - var cookies= sqlSugarClient.Queryable().ToList(); + var cookies = sqlSugarClient.Queryable().ToList(); foreach (var cookie in cookies) { @@ -97,6 +110,67 @@ namespace dy.net.service return sqlSugarClient.Updateable(cookies).ExecuteCommand() > 0; } + #region 娴嬭瘯鍒涘缓鏁版嵁搴 + + ///// + ///// 鍒涘缓SQLite鏁版嵁搴撹繛鎺ュ瓧绗︿覆 + ///// + //private string CreateSqliteDBConn() + //{ + // var dbFolder = Path.Combine(Environment.CurrentDirectory, "db"); + // Directory.CreateDirectory(dbFolder); // 涓嶅瓨鍦ㄥ垯鍒涘缓锛屾棤闇鍒ゆ柇 + + // var dbPath = Path.Combine(dbFolder, "dy.sqlite"); + // if (!File.Exists(dbPath)) + // { + // using (File.Create(dbPath)) { } // 浣跨敤using纭繚鏂囦欢娴佸叧闂 + // } + + // return $"DataSource={dbPath}"; + //} + ///// + ///// 鍒濆鍖栨暟鎹簱 + ///// + //public ISqlSugarClient InitDataBase(DbType dbType, string connString) + //{ + // // 澶勭悊SQLite杩炴帴瀛楃涓 + // if (dbType == DbType.Sqlite) + // { + // connString = CreateSqliteDBConn(); + // } + + // if (string.IsNullOrWhiteSpace(connString)) + // { + // return null; + // } + + // return new SqlSugarClient(new ConnectionConfig + // { + // ConnectionString = connString, + // InitKeyType = InitKeyType.Attribute, + // DbType = dbType, + // IsAutoCloseConnection = true + // }, db => + // { + // // 鏃ュ織閰嶇疆 + // db.Aop.OnLogExecuting = (sql, pars) => Serilog.Log.Debug(sql); + // db.Aop.OnError = e => + // { + // Serilog.Log.Error(e.Message); + // Serilog.Log.Error(e.Sql); + // }; + + // // 鍒涘缓鏁版嵁搴撳拰琛 + // db.DbMaintenance.CreateDatabase(); + // var modelTypes = Assembly.GetExecutingAssembly() + // .GetTypes() + // .Where(t => t.Namespace?.StartsWith("dy.net.model") ?? false) + // .ToArray(); + // db.CodeFirst.InitTables(modelTypes); + // }); + //} + #endregion } + } diff --git a/service/DyCollectVideoService.cs b/service/DyCollectVideoService.cs index c87ff06..a09e2ad 100644 --- a/service/DyCollectVideoService.cs +++ b/service/DyCollectVideoService.cs @@ -59,26 +59,33 @@ namespace dy.net.service List list = await this._dyCollectVideoRepository.GetAllAsync(); if (!list.Any()) return new VideoStaticsDto(); - var Categories = list.GroupBy(x => x.Tag1).Select(x => new VideoStaticsItemDto { Name = x.Key, Count = x.LongCount() }).OrderByDescending(p=>p.Count).ToList(); + var Categories = list.GroupBy(x => x.Tag1).Select(x => new VideoStaticsItemDto { Name = x.Key, Count = x.LongCount() }).OrderByDescending(p => p.Count).ToList(); Categories.Where(x => string.IsNullOrWhiteSpace(x.Name)).ToList().ForEach(x => x.Name = "鍏朵粬"); var data = new VideoStaticsDto { AuthorCount = list.Select(x => x.AuthorId).Distinct().Count(), - CategoryCount=list.Select(x=>x.Tag1).Distinct().Count(), + CategoryCount = list.Select(x => x.Tag1).Distinct().Count(), VideoCount = list.Count, - Categories= Categories, - FavoriteCount= list.Count(x => x.ViedoType=="1"), - CollectCount= list.Count(x => x.ViedoType=="2"), - ViedoSizeTotal = ByteToGbConverter.ConvertBytesToGb(list.Sum(x=>x.FileSize)) + Categories = Categories, + FavoriteCount = list.Count(x => x.ViedoType == "1"), + CollectCount = list.Count(x => x.ViedoType == "2"), + FollowCount = list.Count(x => x.ViedoType == "3"), + + VideoSizeTotal = ByteToGbConverter.ConvertBytesToGb(list.Sum(x => x.FileSize)), + VideoFavoriteSize = ByteToGbConverter.ConvertBytesToGb(list.Where(x => x.ViedoType == "1").Sum(x => x.FileSize)), + VideoCollectSize = ByteToGbConverter.ConvertBytesToGb(list.Where(x => x.ViedoType == "2").Sum(x => x.FileSize)), + VideoFollowSize = ByteToGbConverter.ConvertBytesToGb(list.Where(x => x.ViedoType == "3").Sum(x => x.FileSize)), + + TotalDiskSize= ByteToGbConverter.GetHostTotalDiskSpaceGB(), }; - data.Authors = list.GroupBy(x => x.Author).Select(x => new VideoStaticsItemDto { Name = x.Key, Count = x.LongCount(), Icon=x.FirstOrDefault().AuthorAvatarUrl }).OrderByDescending(d=>d.Count).ToList(); + data.Authors = list.GroupBy(x => x.Author).Select(x => new VideoStaticsItemDto { Name = x.Key, Count = x.LongCount(), Icon = x.FirstOrDefault().AuthorAvatarUrl }).OrderByDescending(d => d.Count).ToList(); return data; } //鍒嗛〉鏌ヨ - public async Task<(List list, int totalCount)> GetPagedAsync(int pageIndex, int pageSize, string tag = null, string author = null,string viedoType=null,List? dates=null) + public async Task<(List list, int totalCount)> GetPagedAsync(int pageIndex, int pageSize, string tag = null, string author = null, string viedoType = null, List? dates = null) { return await _dyCollectVideoRepository.GetPagedAsync(pageIndex, pageSize, tag, author, viedoType, dates); } diff --git a/service/DyCookieService.cs b/service/DyCookieService.cs index 0b53303..9f270c1 100644 --- a/service/DyCookieService.cs +++ b/service/DyCookieService.cs @@ -26,14 +26,29 @@ namespace dy.net.service return await _cookieRepository.InsertAsync(dyUserCookies); } - public bool Init(DyUserCookies dyUserCookies) + public bool Init() { - var exist = _cookieRepository.GetFirst(x => x.Id == dyUserCookies.Id); - if(exist != null) + var initId= "2026"; + var exist = _cookieRepository.GetFirst(x => x.Id == initId); + if (exist != null) { return false; } - return _cookieRepository.Insert(dyUserCookies); + var cookie = new DyUserCookies + { + UserName = "douyin", + Cookies = "--", + Id = initId, + SavePath = "/app/collect", + Status = 0, + SecUserId = "--", + FavSavePath = "/app/favorite", + UpSavePath = "/app/uper", + CollHasSyncd = 0, + FavHasSyncd = 0, + UperSyncd = 0 + }; + return _cookieRepository.Insert(cookie); } // 鏌ヨ鍗曚釜 diff --git a/service/UserService.cs b/service/UserService.cs index e4ae5f6..29e79bd 100644 --- a/service/UserService.cs +++ b/service/UserService.cs @@ -30,8 +30,14 @@ namespace dy.net.service return await _userRepository.UpdateAvatar(avatar); } - public (int code, string erro) InitUser(LoginUserInfo userInfo) + public (int code, string erro) InitUser() { + LoginUserInfo userInfo = new LoginUserInfo + { + UserName = "douyin", + Password = "douyin2025", + CreateTime = DateTime.Now + }; return _userRepository.InitUser(userInfo); } } diff --git a/utils/ByteToGbConverter.cs b/utils/ByteToGbConverter.cs index 4d0e6a2..a544a2c 100644 --- a/utils/ByteToGbConverter.cs +++ b/utils/ByteToGbConverter.cs @@ -8,13 +8,52 @@ /// 瀛楄妭鏁帮紙闇浣跨敤long绫诲瀷閬垮厤澶ф暟鍊兼孩鍑猴級 /// 淇濈暀鐨勫皬鏁颁綅鏁 /// 杞崲鍚庣殑GB鍊 - public static double ConvertBytesToGb(long bytes, int decimalPlaces = 2) + public static string ConvertBytesToGb(long bytes, int decimalPlaces = 2) { // 1GB = 1024 * 1024 * 1024 = 1073741824 Byte double gb = (double)bytes / 1073741824; // 鍥涜垗浜斿叆淇濈暀鎸囧畾灏忔暟浣嶆暟 - return Math.Round(gb, decimalPlaces); + return Math.Round(gb, decimalPlaces).ToString("F2"); + } + + + /// + /// 鑾峰彇瀹夸富鏈烘墍鏈夋湰鍦板浐瀹氱鐩樼殑鎬荤┖闂达紙GB锛 + /// + /// 鎬荤┖闂村瓧绗︿覆锛堝 "1408.35 GB"锛夛紝澶辫触鏃惰繑鍥為敊璇俊鎭 + public static string GetHostTotalDiskSpaceGB() + { + try + { + // 1. 鑾峰彇鎵鏈夐┍鍔ㄥ櫒 + DriveInfo[] allDrives = DriveInfo.GetDrives(); + + // 2. 绛涢夛細浠呬繚鐣欌滃氨缁殑鏈湴鍥哄畾纾佺洏鈥濓紙DriveType.Fixed锛 + var fixedDrives = allDrives.Where(drive => + drive.IsReady && + drive.DriveType == DriveType.Fixed + ).ToList(); + + if (!fixedDrives.Any()) + { + return "鏈壘鍒板彲鐢ㄧ殑鏈湴鍥哄畾纾佺洏"; + } + + // 3. 绱姞鎵鏈夊浐瀹氱鐩樼殑鎬荤┖闂达紙瀛楄妭锛 + long totalBytes = fixedDrives.Sum(drive => drive.TotalSize); + + // 4. 杞崲涓篏B骞朵繚鐣2浣嶅皬鏁 + return ConvertBytesToGb(totalBytes); + } + catch (UnauthorizedAccessException) + { + return "鏉冮檺涓嶈冻锛屾棤娉曡闂儴鍒嗙鐩"; + } + catch (Exception ex) + { + return $"鑾峰彇瀹夸富鏈烘荤鐩樼┖闂村け璐ワ細{ex.Message}"; + } } } }