refactor: ♻️ 主题颜色变量封装 (#192)

Co-authored-by: tk <fiyne1a@dingtalk.com>
This commit is contained in:
nsnail 2024-11-11 16:14:51 +08:00 committed by GitHub
parent f00046265a
commit 4d63bd6bf5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 61 additions and 68 deletions

View File

@ -8,15 +8,14 @@ public sealed record SeedDataInsertedEvent : DataAbstraction, IEventSource
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SeedDataInsertedEvent" /> class. /// Initializes a new instance of the <see cref="SeedDataInsertedEvent" /> class.
/// </summary> /// </summary>
public SeedDataInsertedEvent(int insertedCount) public SeedDataInsertedEvent(int insertedCount, bool isConsumOnce = false)
{ {
IsConsumOnce = isConsumOnce;
InsertedCount = insertedCount; InsertedCount = insertedCount;
CreatedTime = DateTime.Now;
EventId = nameof(SeedDataInsertedEvent); EventId = nameof(SeedDataInsertedEvent);
} }
/// <inheritdoc />
public CancellationToken CancellationToken { get; }
/// <inheritdoc /> /// <inheritdoc />
public DateTime CreatedTime { get; } public DateTime CreatedTime { get; }
@ -27,10 +26,13 @@ public sealed record SeedDataInsertedEvent : DataAbstraction, IEventSource
public bool IsConsumOnce { get; } public bool IsConsumOnce { get; }
/// <inheritdoc /> /// <inheritdoc />
public object Payload { get; } public CancellationToken CancellationToken { get; init; }
/// <summary> /// <summary>
/// 插入数量 /// 插入数量
/// </summary> /// </summary>
public int InsertedCount { get; set; } public int InsertedCount { get; set; }
/// <inheritdoc />
public object Payload { get; init; }
} }

View File

@ -52,6 +52,7 @@ public sealed class ExampleController(IExampleCache cache) : ControllerBase<IExa
/// <summary> /// <summary>
/// 示例是否存在 /// 示例是否存在
/// </summary> /// </summary>
[NonAction]
public Task<bool> ExistAsync(QueryReq<QueryExampleReq> req) public Task<bool> ExistAsync(QueryReq<QueryExampleReq> req)
{ {
return Cache.ExistAsync(req); return Cache.ExistAsync(req);
@ -60,6 +61,7 @@ public sealed class ExampleController(IExampleCache cache) : ControllerBase<IExa
/// <summary> /// <summary>
/// 导出示例 /// 导出示例
/// </summary> /// </summary>
[NonAction]
public Task<IActionResult> ExportAsync(QueryReq<QueryExampleReq> req) public Task<IActionResult> ExportAsync(QueryReq<QueryExampleReq> req)
{ {
return Cache.ExportAsync(req); return Cache.ExportAsync(req);
@ -84,6 +86,7 @@ public sealed class ExampleController(IExampleCache cache) : ControllerBase<IExa
/// <summary> /// <summary>
/// 查询示例 /// 查询示例
/// </summary> /// </summary>
[NonAction]
public Task<IEnumerable<QueryExampleRsp>> QueryAsync(QueryReq<QueryExampleReq> req) public Task<IEnumerable<QueryExampleRsp>> QueryAsync(QueryReq<QueryExampleReq> req)
{ {
return Cache.QueryAsync(req); return Cache.QueryAsync(req);

View File

@ -5,7 +5,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0-rc.2.24474.3"/> <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0-rc.2.24474.3"/>
<PackageReference Include="xunit" Version="2.9.2"/> <PackageReference Include="xunit" Version="2.9.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0-pre.42"> <PackageReference Include="xunit.runner.visualstudio" Version="3.0.0-pre.49">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>

View File

@ -49,28 +49,6 @@ export default {
}, },
}, },
/**
* 示例是否存在
*/
exist: {
url: `${config.API_URL}/api/tpl/example/exist`,
name: `示例是否存在`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
/**
* 导出示例
*/
export: {
url: `${config.API_URL}/api/tpl/example/export`,
name: `导出示例`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
/** /**
* 获取单个示例 * 获取单个示例
*/ */
@ -92,15 +70,4 @@ export default {
return await http.post(this.url, data, config) return await http.post(this.url, data, config)
}, },
}, },
/**
* 查询示例
*/
query: {
url: `${config.API_URL}/api/tpl/example/query`,
name: `查询示例`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
} }

View File

@ -43,7 +43,7 @@ export default {
const contents = [] const contents = []
const msg = h('p', { style: 'width:230px;display:flex;justify-content:space-between' }, [ const msg = h('p', { style: 'width:230px;display:flex;justify-content:space-between' }, [
h('span', {}, this.$t('即将开始更新……')), h('span', {}, this.$t('即将开始更新……')),
h('a', { style: 'color:#21A675', href: 'javascript:window.location.reload()' }, this.$t('立即更新')), h('a', { style: 'color:var(--el-color-primary)', href: 'javascript:window.location.reload()' }, this.$t('立即更新')),
]) ])
const task = h('p', { style: 'font-weight:bold' }, version) const task = h('p', { style: 'font-weight:bold' }, version)
const progress = h( const progress = h(
@ -55,7 +55,7 @@ export default {
style: { style: {
width: '230px', width: '230px',
height: '6px', height: '6px',
'background-color': '#21A675', 'background-color': 'var(--el-color-primary)',
'margin-top': '6px', 'margin-top': '6px',
'border-radius': '6px', 'border-radius': '6px',
}, },

View File

@ -1,5 +1,7 @@
import DEFAULT_CONFIG from '@/config'
const T = { const T = {
color: ['#21A675', '#36CE9E', '#f56e6a', '#626c91', '#edb00d', '#909399'], color: [DEFAULT_CONFIG.APP_SET_COLOR, '#36CE9E', '#f56e6a', '#626c91', '#edb00d', '#909399'],
grid: { grid: {
left: '3%', left: '3%',
right: '3%', right: '3%',

View File

@ -440,7 +440,7 @@ export default {
} }
.sc-file-select__item__file .item-file.item-file-doc { .sc-file-select__item__file .item-file.item-file-doc {
color: #21a675; color: var(--el-color-primary);
} }
.sc-file-select__item__upload { .sc-file-select__item__upload {

View File

@ -125,7 +125,7 @@ export default {
.sc-filter-my-list li:hover { .sc-filter-my-list li:hover {
background: #ecf5ff; background: #ecf5ff;
color: #21a675; color: var(--el-color-primary);
} }
.sc-filter-my-list li label { .sc-filter-my-list li label {

View File

@ -53,7 +53,7 @@ export default {
.sc-page-header__icon span { .sc-page-header__icon span {
width: 2.5rem; width: 2.5rem;
height: 2.5rem; height: 2.5rem;
background: #21a675; background: var(--el-color-primary);
border-radius: 40%; border-radius: 40%;
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -3,7 +3,7 @@
export default { export default {
//标题 //标题
//APP_NAME: "NetAdmin", //APP_NAME: "标题",
//接口地址如遇跨域需使用nginx代理 //接口地址如遇跨域需使用nginx代理
//API_URL: "https://www.fastmock.site/mock/5039c4361c39a7e3252c5b55971f1bd3/api" //API_URL: import.meta.env.VITE_API_URL,
} }

View File

@ -1,4 +1,5 @@
import API from '@/api' import API from '@/api'
import DEFAULT_CONFIG from '@/config/index'
//文件选择器配置 //文件选择器配置
@ -43,11 +44,11 @@ export default {
files: { files: {
doc: { doc: {
icon: 'sc-icon-file-word-2-fill', icon: 'sc-icon-file-word-2-fill',
color: '#21A675', color: DEFAULT_CONFIG.APP_SET_COLOR,
}, },
docx: { docx: {
icon: 'sc-icon-file-word-2-fill', icon: 'sc-icon-file-word-2-fill',
color: '#21A675', color: DEFAULT_CONFIG.APP_SET_COLOR,
}, },
xls: { xls: {
icon: 'sc-icon-file-excel-2-fill', icon: 'sc-icon-file-excel-2-fill',

View File

@ -1,7 +1,7 @@
//业务配置 //业务配置
//会合并至this.$CONFIG //会合并至this.$CONFIG
//生产模式 public/config.js 同名key会覆盖这里的配置从而实现打包后的热更新 //生产模式 public/config.js 同名key会覆盖这里的配置从而实现打包后的热更新
//为避免和NetAdmin框架配置混淆建议添加前缀 MY_ //为避免和框架配置混淆建议添加前缀 MY_
//全局可使用 this.$CONFIG.MY_KEY 访问 //全局可使用 this.$CONFIG.MY_KEY 访问
export default { export default {

View File

@ -15,9 +15,9 @@
<el-main> <el-main>
<el-scrollbar> <el-scrollbar>
<el-menu <el-menu
:active-text-color="DEFAULT_CONFIG.APP_SET_COLOR"
:default-active="$route.meta.active || $route.fullPath" :default-active="$route.meta.active || $route.fullPath"
@select="select" @select="select"
active-text-color="#21A675"
background-color="#424c50" background-color="#424c50"
router router
text-color="#fff"> text-color="#fff">
@ -31,6 +31,7 @@
<script> <script>
import NavMenu from './NavMenu.vue' import NavMenu from './NavMenu.vue'
import DEFAULT_CONFIG from '@/config'
export default { export default {
components: { components: {
@ -42,7 +43,11 @@ export default {
menu: [], menu: [],
} }
}, },
computed: {}, computed: {
DEFAULT_CONFIG() {
return DEFAULT_CONFIG
},
},
created() { created() {
const menu = this.$router.sc_getMenu() const menu = this.$router.sc_getMenu()
this.menu = this.filterUrl(menu) this.menu = this.filterUrl(menu)

View File

@ -92,7 +92,7 @@ textarea {
bottom: 10rem; bottom: 10rem;
right: 0; right: 0;
z-index: 100; z-index: 100;
background: #21a675; background: var(--el-color-primary);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
@ -234,7 +234,7 @@ textarea {
} }
.aminui-side-split li.active { .aminui-side-split li.active {
background: #21a675; background: var(--el-color-primary);
color: #fff; color: #fff;
} }
@ -347,6 +347,7 @@ textarea {
.right-panel-search { .right-panel-search {
display: flex; display: flex;
flex-wrap: wrap;
align-items: center; align-items: center;
gap: 0.5rem; gap: 0.5rem;
} }
@ -410,7 +411,7 @@ textarea {
} }
.adminui-tags li.active { .adminui-tags li.active {
background: #21a675; background: var(--el-color-primary);
} }
.adminui-tags li.active a { .adminui-tags li.active a {

View File

@ -44,7 +44,17 @@
.el-date-editor { .el-date-editor {
--el-date-editor-daterange-width: 20rem; --el-date-editor-daterange-width: 20rem;
--el-date-editor-datetimerange-width: 30rem; --el-date-editor-datetimerange-width: 27rem;
.el-range-separator {
flex: unset;
padding: unset;
}
}
.el-range-editor.el-input__wrapper {
padding: 0 0.5rem;
justify-content: space-around;
} }
.el-menu { .el-menu {
@ -93,6 +103,9 @@
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
--el-header-height: auto;
gap: 0.5rem;
flex-wrap: wrap;
} }
.el-header .left-panel { .el-header .left-panel {

View File

@ -77,8 +77,6 @@
} }
.right-panel-search { .right-panel-search {
flex-direction: column;
align-items: flex-start;
} }
.right-panel { .right-panel {

View File

@ -20,7 +20,7 @@ export default (error, vm) => {
} }
const errorName = errorMap[error.name] || '未知错误' const errorName = errorMap[error.name] || '未知错误'
console.warn(`[NetAdmin error]: ${error}`) console.warn(`[error]: ${error}`)
console.error(error) console.error(error)
//throw error; //throw error;

View File

@ -381,7 +381,7 @@ tool.crypto = {
AES: { AES: {
encrypt(data, secretKey, config = {}) { encrypt(data, secretKey, config = {}) {
if (secretKey.length % 8 !== 0) { if (secretKey.length % 8 !== 0) {
console.warn('[NetAdmin error]: 秘钥长度需为8的倍数否则解密将会失败。') console.warn('[error]: 秘钥长度需为8的倍数否则解密将会失败。')
} }
const result = CryptoJS.AES.encrypt(data, CryptoJS.enc.Utf8.parse(secretKey), { const result = CryptoJS.AES.encrypt(data, CryptoJS.enc.Utf8.parse(secretKey), {
iv: CryptoJS.enc.Utf8.parse(config.iv || ''), iv: CryptoJS.enc.Utf8.parse(config.iv || ''),

View File

@ -178,8 +178,8 @@ export default {
.modItem-add:hover, .modItem-add:hover,
.modItem-add:hover i { .modItem-add:hover i {
border-color: #21a675; border-color: var(--el-color-primary);
color: #21a675 !important; color: var(--el-color-primary) !important;
} }
.setMods { .setMods {

View File

@ -72,11 +72,12 @@
<script> <script>
import colorTool from '@/utils/color' import colorTool from '@/utils/color'
import DEFAULT_CONFIG from '@/config'
export default { export default {
data() { data() {
return { return {
colorList: ['#21A675', '#009688', '#536dfe', '#ff5c93', '#c62f2f', '#fd726d'], colorList: [DEFAULT_CONFIG.APP_SET_COLOR, '#009688', '#536dfe', '#ff5c93', '#c62f2f', '#fd726d'],
config: { config: {
layout: this.$TOOL.data.get('APP_SET_LAYOUT') || this.$CONFIG.APP_SET_LAYOUT, layout: this.$TOOL.data.get('APP_SET_LAYOUT') || this.$CONFIG.APP_SET_LAYOUT,
menuIsCollapse: this.$TOOL.data.get('APP_SET_MENU_IS_COLLAPSE') || this.$CONFIG.APP_SET_MENU_IS_COLLAPSE, menuIsCollapse: this.$TOOL.data.get('APP_SET_MENU_IS_COLLAPSE') || this.$CONFIG.APP_SET_MENU_IS_COLLAPSE,
@ -84,7 +85,7 @@ export default {
layoutTags: this.$TOOL.data.get('APP_SET_MULTI_TAGS') || this.$CONFIG.APP_SET_MULTI_TAGS, layoutTags: this.$TOOL.data.get('APP_SET_MULTI_TAGS') || this.$CONFIG.APP_SET_MULTI_TAGS,
lang: this.$TOOL.data.get('APP_SET_LANG') || this.$CONFIG.APP_SET_LANG, lang: this.$TOOL.data.get('APP_SET_LANG') || this.$CONFIG.APP_SET_LANG,
dark: this.$TOOL.data.get('APP_SET_DARK') || this.$CONFIG.APP_SET_DARK, dark: this.$TOOL.data.get('APP_SET_DARK') || this.$CONFIG.APP_SET_DARK,
colorPrimary: this.$TOOL.data.get('APP_SET_COLOR') || this.$CONFIG.APP_SET_COLOR || '#17ABE3', colorPrimary: this.$TOOL.data.get('APP_SET_COLOR') || this.$CONFIG.APP_SET_COLOR || DEFAULT_CONFIG.APP_SET_COLOR,
autoExit: this.$TOOL.data.get('APP_SET_AUTO_EXIT') || this.$CONFIG.APP_SET_AUTO_EXIT, autoExit: this.$TOOL.data.get('APP_SET_AUTO_EXIT') || this.$CONFIG.APP_SET_AUTO_EXIT,
}, },
} }
@ -136,8 +137,8 @@ export default {
}, },
'config.colorPrimary'(val) { 'config.colorPrimary'(val) {
if (!val) { if (!val) {
val = '#21A675' val = DEFAULT_CONFIG.APP_SET_COLOR
this.config.colorPrimary = '#21A675' this.config.colorPrimary = DEFAULT_CONFIG.APP_SET_COLOR
} }
document.documentElement.style.setProperty('--el-color-primary', val) document.documentElement.style.setProperty('--el-color-primary', val)
for (let i = 1; i <= 9; i++) { for (let i = 1; i <= 9; i++) {

View File

@ -82,7 +82,7 @@
<el-table-column type="selection" width="50" /> <el-table-column type="selection" width="50" />
<el-table-column :label="$t('项名')" prop="key" sortable="custom" /> <el-table-column :label="$t('项名')" prop="key" sortable="custom" />
<el-table-column :label="$t('项值')" prop="value" sortable="custom" /> <el-table-column :label="$t('项值')" prop="value" sortable="custom" />
<el-table-column :label="$t('描述')" prop="summary" sortable="custom" /> <el-table-column :label="$t('备注')" prop="summary" sortable="custom" />
<el-table-column :label="$t('启用')" align="center" prop="enabled" sortable="custom" width="100"> <el-table-column :label="$t('启用')" align="center" prop="enabled" sortable="custom" width="100">
<template #default="{ row }"> <template #default="{ row }">
<el-switch v-model="row.enabled" @change="changeSwitch($event, row)"></el-switch> <el-switch v-model="row.enabled" @change="changeSwitch($event, row)"></el-switch>

View File

@ -13,7 +13,7 @@
<el-form-item :label="$t('项值')" prop="value"> <el-form-item :label="$t('项值')" prop="value">
<el-input v-model="form.value" clearable></el-input> <el-input v-model="form.value" clearable></el-input>
</el-form-item> </el-form-item>
<el-form-item :label="$t('描述')" prop="summary"> <el-form-item :label="$t('备注')" prop="summary">
<el-input v-model="form.summary" clearable></el-input> <el-input v-model="form.summary" clearable></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>