-
-
-
-
-
-
-
{{ category.name }}
-
浣滃搧鏁: {{ category.count }}
+
+
+
+
+
+
+
+
+
{{ category.name }}
+
浣滃搧鏁: {{ category.count }}
+
+
+ {{ Math.round((category.count / totalVideos) * 100) }}%
-
+
-
+
@@ -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}";
+ }
}
}
}