diff --git a/.commitlintrc.js b/.commitlintrc.js index fb715c83..a3481415 100644 --- a/.commitlintrc.js +++ b/.commitlintrc.js @@ -64,7 +64,7 @@ module.exports = { maxSubjectLength: Infinity, minSubjectLength: 0, scopeOverrides: undefined, - defaultBody: '', + defaultBody: '[skip ci]', defaultIssues: '', defaultScope: '', defaultSubject: '' diff --git a/build/code.quality.props b/build/code.quality.props index c9025f2a..46f3adfb 100644 --- a/build/code.quality.props +++ b/build/code.quality.props @@ -23,7 +23,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/scripts/1.git.pull.request.ps1 b/scripts/1.git.pull.request.ps1 index 1d29abac..2ef8123b 100644 --- a/scripts/1.git.pull.request.ps1 +++ b/scripts/1.git.pull.request.ps1 @@ -1,6 +1,10 @@ $branch = $( git branch --show-current ) git add ../ -./code.clean.ps1 +$skipFormat = Read-Host "输入 n 跳过代码整理" +if ($skipFormat -ne "n") +{ + ./code.clean.ps1 +} git add ../ ../node_modules/.bin/git-cz.ps1 git pull diff --git a/src/backend/NetAdmin.Domain/Dto/Sys/Dic/Content/GetDicValueReq.cs b/src/backend/NetAdmin.Domain/Dto/Sys/Dic/Content/GetDicValueReq.cs new file mode 100644 index 00000000..6be897c4 --- /dev/null +++ b/src/backend/NetAdmin.Domain/Dto/Sys/Dic/Content/GetDicValueReq.cs @@ -0,0 +1,19 @@ +using NetAdmin.Domain.DbMaps.Sys; + +namespace NetAdmin.Domain.Dto.Sys.Dic.Content; + +/// +/// 请求:获取字典值 +/// +public sealed record GetDicValueReq : Sys_DicContent +{ + /// + [JsonIgnore(Condition = JsonIgnoreCondition.Never)] + [Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.字典目录编号不能为空))] + public override long CatalogId { get; init; } + + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.键名称不能为空))] + public override string Key { get; init; } +} \ No newline at end of file diff --git a/src/backend/NetAdmin.Domain/Dto/Sys/RequestLog/QueryRequestLogRsp.cs b/src/backend/NetAdmin.Domain/Dto/Sys/RequestLog/QueryRequestLogRsp.cs index e466554b..98b3fd5d 100644 --- a/src/backend/NetAdmin.Domain/Dto/Sys/RequestLog/QueryRequestLogRsp.cs +++ b/src/backend/NetAdmin.Domain/Dto/Sys/RequestLog/QueryRequestLogRsp.cs @@ -16,7 +16,7 @@ public sealed record QueryRequestLogRsp : Sys_RequestLog, IRegister /// /// 操作系统 /// - public string Os => UserAgentParser.Create(CreatedUserAgent).Platform; + public string Os => UserAgentParser.Create(CreatedUserAgent)?.Platform; /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] diff --git a/src/backend/NetAdmin.Infrastructure/Extensions/StringExtensions.cs b/src/backend/NetAdmin.Infrastructure/Extensions/StringExtensions.cs index df0cae8c..7da0d83d 100644 --- a/src/backend/NetAdmin.Infrastructure/Extensions/StringExtensions.cs +++ b/src/backend/NetAdmin.Infrastructure/Extensions/StringExtensions.cs @@ -41,4 +41,12 @@ public static class StringExtensions { return _regex.Replace(me, string.Empty); } + + /// + /// 去掉前部字符串 + /// + public static string TrimStart(this string me, string clearStr) + { + return Regex.Replace(me, $"^{clearStr}", string.Empty); + } } \ No newline at end of file diff --git a/src/backend/NetAdmin.Infrastructure/Utils/UserAgentParser.cs b/src/backend/NetAdmin.Infrastructure/Utils/UserAgentParser.cs index 546c5e63..7d8e4965 100644 --- a/src/backend/NetAdmin.Infrastructure/Utils/UserAgentParser.cs +++ b/src/backend/NetAdmin.Infrastructure/Utils/UserAgentParser.cs @@ -278,7 +278,7 @@ public sealed class UserAgentParser /// public static UserAgentParser Create(string userAgentString) { - return new UserAgentParser(userAgentString); + return userAgentString == null ? null : new UserAgentParser(userAgentString); } private bool SetBrowser() diff --git a/src/backend/NetAdmin.SysComponent.Application/Modules/Sys/IDicModule.cs b/src/backend/NetAdmin.SysComponent.Application/Modules/Sys/IDicModule.cs index 9dee09ea..4cf68a23 100644 --- a/src/backend/NetAdmin.SysComponent.Application/Modules/Sys/IDicModule.cs +++ b/src/backend/NetAdmin.SysComponent.Application/Modules/Sys/IDicModule.cs @@ -49,6 +49,11 @@ public interface IDicModule /// Task GetContentAsync(QueryDicContentReq req); + /// + /// 获取字典值 + /// + public Task GetDicValueAsync(GetDicValueReq req); + /// /// 分页查询字典目录 /// diff --git a/src/backend/NetAdmin.SysComponent.Application/Services/Sys/DicService.cs b/src/backend/NetAdmin.SysComponent.Application/Services/Sys/DicService.cs index 6281e2bd..a04989cc 100644 --- a/src/backend/NetAdmin.SysComponent.Application/Services/Sys/DicService.cs +++ b/src/backend/NetAdmin.SysComponent.Application/Services/Sys/DicService.cs @@ -66,6 +66,28 @@ public sealed class DicService(IDicCatalogService catalogService, IDicContentSer return contentService.GetAsync(req); } + /// + public async Task GetDicValueAsync(GetDicValueReq req) + { + req.ThrowIfInvalid(); + var df = new DynamicFilterInfo { + Filters = [ + new DynamicFilterInfo { + Field = nameof(QueryDicContentReq.CatalogId) + , Operator = DynamicFilterOperators.Eq + , Value = req.CatalogId + } + , new DynamicFilterInfo { + Field = nameof(QueryDicContentReq.Key) + , Operator = DynamicFilterOperators.Eq + , Value = req.Key + } + ] + }; + var queryParam = new QueryReq { Count = 1, DynamicFilter = df }; + return (await QueryContentAsync(queryParam).ConfigureAwait(false)).FirstOrDefault()?.Value; + } + /// public Task> PagedQueryCatalogAsync(PagedQueryReq req) { diff --git a/src/backend/NetAdmin.SysComponent.Application/Services/Sys/JobService.cs b/src/backend/NetAdmin.SysComponent.Application/Services/Sys/JobService.cs index c788aba1..a253961b 100644 --- a/src/backend/NetAdmin.SysComponent.Application/Services/Sys/JobService.cs +++ b/src/backend/NetAdmin.SysComponent.Application/Services/Sys/JobService.cs @@ -79,6 +79,7 @@ public sealed class JobService(DefaultRepository rpo, IJobRecordService /// public async Task FinishJobAsync(UpdateJobReq req) { + req.ThrowIfInvalid(); var nextExecTime = GetNextExecTime(req.ExecutionCron); _ = await UpdateAsync(req with { Status = JobStatues.Idle @@ -100,22 +101,24 @@ public sealed class JobService(DefaultRepository rpo, IJobRecordService public async Task GetNextJobAsync() { var df = new DynamicFilterInfo { - Filters = [ new DynamicFilterInfo { Field = nameof(QueryJobReq.NextExecTime) - , Value = DateTime.UtcNow - , Operator = DynamicFilterOperators.LessThan - } - , new DynamicFilterInfo { - Field = nameof(QueryJobReq.Status) - , Value = JobStatues.Idle - , Operator = DynamicFilterOperators.Eq - } - , new DynamicFilterInfo { - Field = nameof(QueryJobReq.Enabled) - , Value = true - , Operator = DynamicFilterOperators.Eq - } - ] - }; + Filters = [ + new DynamicFilterInfo { + Field = nameof(QueryJobReq.NextExecTime) + , Value = DateTime.UtcNow + , Operator = DynamicFilterOperators.LessThan + } + , new DynamicFilterInfo { + Field = nameof(QueryJobReq.Status) + , Value = JobStatues.Idle + , Operator = DynamicFilterOperators.Eq + } + , new DynamicFilterInfo { + Field = nameof(QueryJobReq.Enabled) + , Value = true + , Operator = DynamicFilterOperators.Eq + } + ] + }; var job = await QueryInternal(new QueryReq { DynamicFilter = df, Count = 1 }, true) .Where(a => !Rpo.Orm.Select() .As("b") @@ -163,6 +166,7 @@ public sealed class JobService(DefaultRepository rpo, IJobRecordService /// public Task> RecordPagedQueryAsync(PagedQueryReq req) { + req.ThrowIfInvalid(); return jobRecordService.PagedQueryAsync(req); } @@ -217,7 +221,7 @@ public sealed class JobService(DefaultRepository rpo, IJobRecordService , a => a.Id == req.Keywords.Int64Try(0) || a.JobName.Contains(req.Keywords)) .OrderByPropertyNameIf(req.Prop?.Length > 0, req.Prop, req.Order == Orders.Ascending); return !orderByRandom && (!req.Prop?.Equals(nameof(req.Filter.Id), StringComparison.OrdinalIgnoreCase) ?? true) - ? ret.OrderByDescending(a => a.Id) + ? ret.OrderByDescending(a => a.LastExecTime) : ret.OrderByRandom(); } } \ No newline at end of file diff --git a/src/backend/NetAdmin.SysComponent.Cache/Sys/CacheCache.cs b/src/backend/NetAdmin.SysComponent.Cache/Sys/CacheCache.cs index dc589b55..10ebc7b7 100644 --- a/src/backend/NetAdmin.SysComponent.Cache/Sys/CacheCache.cs +++ b/src/backend/NetAdmin.SysComponent.Cache/Sys/CacheCache.cs @@ -13,8 +13,12 @@ public sealed class CacheCache(IDistributedCache cache, ICacheService service) / /// public Task CacheStatisticsAsync() { + #if !DEBUG return GetOrCreateAsync( // GetCacheKey(string.Empty), Service.CacheStatisticsAsync, TimeSpan.FromMinutes(1)); + #else + return Service.CacheStatisticsAsync(); + #endif } /// diff --git a/src/backend/NetAdmin.SysComponent.Cache/Sys/DicCache.cs b/src/backend/NetAdmin.SysComponent.Cache/Sys/DicCache.cs index f089d369..e3db5eb9 100644 --- a/src/backend/NetAdmin.SysComponent.Cache/Sys/DicCache.cs +++ b/src/backend/NetAdmin.SysComponent.Cache/Sys/DicCache.cs @@ -59,6 +59,18 @@ public sealed class DicCache(IDistributedCache cache, IDicService service) // return Service.GetContentAsync(req); } + /// + public Task GetDicValueAsync(GetDicValueReq req) + { + #if !DEBUG + return GetOrCreateAsync( // + GetCacheKey(req.GetHashCode().ToString(CultureInfo.InvariantCulture)) // + , () => Service.GetDicValueAsync(req), TimeSpan.FromMinutes(1)); + #else + return Service.GetDicValueAsync(req); + #endif + } + /// public Task> PagedQueryCatalogAsync(PagedQueryReq req) { diff --git a/src/backend/NetAdmin.SysComponent.Cache/Sys/UserCache.cs b/src/backend/NetAdmin.SysComponent.Cache/Sys/UserCache.cs index 8b7bdede..76a27958 100644 --- a/src/backend/NetAdmin.SysComponent.Cache/Sys/UserCache.cs +++ b/src/backend/NetAdmin.SysComponent.Cache/Sys/UserCache.cs @@ -74,7 +74,13 @@ public sealed class UserCache(IDistributedCache cache, IUserService service, IVe /// public Task> QueryAsync(QueryReq req) { + #if !DEBUG + return GetOrCreateAsync( // + GetCacheKey(req.GetHashCode().ToString(CultureInfo.InvariantCulture)) // + , () => Service.QueryAsync(req), TimeSpan.FromMinutes(1)); + #else return Service.QueryAsync(req); + #endif } /// @@ -185,8 +191,12 @@ public sealed class UserCache(IDistributedCache cache, IUserService service, IVe /// public Task UserInfoAsync() { + #if !DEBUG return GetOrCreateAsync( // GetCacheKey(Service.UserToken.Id.ToString(CultureInfo.InvariantCulture)), Service.UserInfoAsync , TimeSpan.FromMinutes(1)); + #else + return Service.UserInfoAsync(); + #endif } } \ No newline at end of file diff --git a/src/backend/NetAdmin.SysComponent.Host/Controllers/Sys/DicController.cs b/src/backend/NetAdmin.SysComponent.Host/Controllers/Sys/DicController.cs index 82de2dfc..f291031c 100644 --- a/src/backend/NetAdmin.SysComponent.Host/Controllers/Sys/DicController.cs +++ b/src/backend/NetAdmin.SysComponent.Host/Controllers/Sys/DicController.cs @@ -85,6 +85,14 @@ public sealed class DicController(IDicCache cache) : ControllerBase + /// 获取字典值 + /// + public Task GetDicValueAsync(GetDicValueReq req) + { + return Cache.GetDicValueAsync(req); + } + /// /// 分页查询字典目录 /// diff --git a/src/backend/NetAdmin.Tests/NetAdmin.Tests.csproj b/src/backend/NetAdmin.Tests/NetAdmin.Tests.csproj index 21b9e646..658bc2b7 100644 --- a/src/backend/NetAdmin.Tests/NetAdmin.Tests.csproj +++ b/src/backend/NetAdmin.Tests/NetAdmin.Tests.csproj @@ -9,7 +9,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/frontend/admin/package.json b/src/frontend/admin/package.json index d28a4906..67b9b0ba 100644 --- a/src/frontend/admin/package.json +++ b/src/frontend/admin/package.json @@ -1,5 +1,5 @@ { - "name": "NetAdmin", + "name": "net-admin", "private": true, "scripts": { "dev": "vite", @@ -17,7 +17,7 @@ "cropperjs": "^1.6.1", "crypto-js": "^4.2.0", "echarts": "^5.5.0", - "element-plus": "^2.5.6", + "element-plus": "^2.6.1", "json-bigint": "^1.0.0", "json5-to-table": "^0.1.8", "markdown-it": "^14.0.0", @@ -27,22 +27,22 @@ "qrcodejs2": "^0.0.2", "sortablejs": "^1.15.2", "tinymce": "^6.8.3", - "vue": "^3.4.20", - "vue-i18n": "^9.9.1", + "vue": "^3.4.21", + "vue-i18n": "^9.10.1", "vue-router": "^4.3.0", "vue3-json-viewer": "^2.2.2", "vuedraggable": "^4.0.3", "vuex": "^4.1.0", - "xgplayer": "^3.0.13", - "xgplayer-hls": "^3.0.13" + "xgplayer": "^3.0.14", + "xgplayer-hls": "^3.0.14" }, "devDependencies": { "@vitejs/plugin-vue": "^5.0.4", "prettier": "^3.2.5", "prettier-plugin-organize-attributes": "^1.0.0", "sass": "^1.71.1", - "terser": "^5.28.1", - "vite": "^5.1.4" + "terser": "^5.29.1", + "vite": "^5.1.5" }, "browserslist": [ "> 1%", diff --git a/src/frontend/admin/src/api/sys/dic.js b/src/frontend/admin/src/api/sys/dic.js index aa3a43f6..a61f7dba 100644 --- a/src/frontend/admin/src/api/sys/dic.js +++ b/src/frontend/admin/src/api/sys/dic.js @@ -93,6 +93,17 @@ export default { }, }, + /** + * 获取字典值 + */ + getDicValue: { + url: `${config.API_URL}/api/sys/dic/get.dic.value`, + name: `获取字典值`, + post: async function (data = {}, config = {}) { + return await http.post(this.url, data, config) + }, + }, + /** * 分页查询字典目录 */ diff --git a/src/frontend/admin/src/assets/icons/Collect.vue b/src/frontend/admin/src/assets/icons/Collect.vue new file mode 100644 index 00000000..99f81acf --- /dev/null +++ b/src/frontend/admin/src/assets/icons/Collect.vue @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/src/frontend/admin/src/assets/icons/index.js b/src/frontend/admin/src/assets/icons/index.js index a6dd59fc..00d521fe 100644 --- a/src/frontend/admin/src/assets/icons/index.js +++ b/src/frontend/admin/src/assets/icons/index.js @@ -62,4 +62,5 @@ export { default as ApiDoc } from './ApiDoc.vue' export { default as Help } from './Help.vue' export { default as Version } from './Version.vue' export { default as Home } from './Home.vue' -export { default as Exception } from './Exception.vue' \ No newline at end of file +export { default as Exception } from './Exception.vue' +export { default as Collect } from './Collect.vue' \ No newline at end of file diff --git a/src/frontend/admin/src/components/naColIndicator/index.vue b/src/frontend/admin/src/components/naColIndicator/index.vue index b805e01a..fe61085a 100644 --- a/src/frontend/admin/src/components/naColIndicator/index.vue +++ b/src/frontend/admin/src/components/naColIndicator/index.vue @@ -11,6 +11,7 @@ + diff --git a/src/frontend/admin/src/components/scFileExport/index.vue b/src/frontend/admin/src/components/scFileExport/index.vue index ca6914e3..74cc8284 100644 --- a/src/frontend/admin/src/components/scFileExport/index.vue +++ b/src/frontend/admin/src/components/scFileExport/index.vue @@ -21,7 +21,7 @@ - + diff --git a/src/frontend/admin/src/components/scTableSelect/index.vue b/src/frontend/admin/src/components/scTableSelect/index.vue index f582b154..4ae5b9d9 100644 --- a/src/frontend/admin/src/components/scTableSelect/index.vue +++ b/src/frontend/admin/src/components/scTableSelect/index.vue @@ -24,7 +24,7 @@ @visible-change="visibleChange" ref="select">