From 3b0ace386861363e12471511910229ab9977b4f5 Mon Sep 17 00:00:00 2001 From: CyberShen123 Date: Thu, 2 Oct 2025 23:52:41 +0800 Subject: [PATCH 1/2] feat(projects): support set global redius --- .../theme-drawer/modules/appearance/index.vue | 2 ++ .../appearance/modules/theme-radius.vue | 22 +++++++++++++++++++ src/locales/langs/en-us.ts | 3 +++ src/locales/langs/zh-cn.ts | 3 +++ src/store/modules/theme/index.ts | 2 +- src/store/modules/theme/shared.ts | 8 +++---- src/theme/settings.ts | 1 + src/typings/app.d.ts | 5 +++++ src/views/home/modules/card-data.vue | 8 ++++++- uno.config.ts | 2 +- 10 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 src/layouts/modules/theme-drawer/modules/appearance/modules/theme-radius.vue diff --git a/src/layouts/modules/theme-drawer/modules/appearance/index.vue b/src/layouts/modules/theme-drawer/modules/appearance/index.vue index 259828c5..a7f65e40 100644 --- a/src/layouts/modules/theme-drawer/modules/appearance/index.vue +++ b/src/layouts/modules/theme-drawer/modules/appearance/index.vue @@ -1,6 +1,7 @@ + + + + diff --git a/src/locales/langs/en-us.ts b/src/locales/langs/en-us.ts index 523648c1..4f8bd7bb 100644 --- a/src/locales/langs/en-us.ts +++ b/src/locales/langs/en-us.ts @@ -83,6 +83,9 @@ const local: App.I18n.Schema = { error: 'Error', followPrimary: 'Follow Primary' }, + themeRadius: { + title: 'Theme Radius' + }, recommendColor: 'Apply Recommended Color Algorithm', recommendColorDesc: 'The recommended color algorithm refers to', preset: { diff --git a/src/locales/langs/zh-cn.ts b/src/locales/langs/zh-cn.ts index f7f888f4..e2c27fcc 100644 --- a/src/locales/langs/zh-cn.ts +++ b/src/locales/langs/zh-cn.ts @@ -83,6 +83,9 @@ const local: App.I18n.Schema = { error: '错误色', followPrimary: '跟随主色' }, + themeRadius: { + title: '主题圆角' + }, recommendColor: '应用推荐算法的颜色', recommendColorDesc: '推荐颜色的算法参照', preset: { diff --git a/src/store/modules/theme/index.ts b/src/store/modules/theme/index.ts index b0380471..26422b82 100644 --- a/src/store/modules/theme/index.ts +++ b/src/store/modules/theme/index.ts @@ -53,7 +53,7 @@ export const useThemeStore = defineStore(SetupStoreId.Theme, () => { }); /** Naive theme */ - const naiveTheme = computed(() => getNaiveTheme(themeColors.value, settings.value.recommendColor)); + const naiveTheme = computed(() => getNaiveTheme(themeColors.value, settings.value)); /** * Settings json diff --git a/src/store/modules/theme/shared.ts b/src/store/modules/theme/shared.ts index e980a799..02bf9384 100644 --- a/src/store/modules/theme/shared.ts +++ b/src/store/modules/theme/shared.ts @@ -239,19 +239,19 @@ function getNaiveThemeColors(colors: App.Theme.ThemeColor, recommended = false) * @param colors Theme colors * @param [recommended=false] Use recommended color. Default is `false` */ -export function getNaiveTheme(colors: App.Theme.ThemeColor, recommended = false) { +export function getNaiveTheme(colors: App.Theme.ThemeColor, settings: App.Theme.ThemeSetting) { const { primary: colorLoading } = colors; const theme: GlobalThemeOverrides = { common: { - ...getNaiveThemeColors(colors, recommended), - borderRadius: '6px' + ...getNaiveThemeColors(colors, settings.recommendColor), + borderRadius: `${settings.themeRadius}px` }, LoadingBar: { colorLoading }, Tag: { - borderRadius: '6px' + borderRadius: `${settings.themeRadius}px` } }; diff --git a/src/theme/settings.ts b/src/theme/settings.ts index 4a4e0a0a..ca50fcfd 100644 --- a/src/theme/settings.ts +++ b/src/theme/settings.ts @@ -5,6 +5,7 @@ export const themeSettings: App.Theme.ThemeSetting = { colourWeakness: false, recommendColor: false, themeColor: '#646cff', + themeRadius: 8, otherColor: { info: '#2080f0', success: '#52c41a', diff --git a/src/typings/app.d.ts b/src/typings/app.d.ts index 33dbbdfe..ff2ca3e3 100644 --- a/src/typings/app.d.ts +++ b/src/typings/app.d.ts @@ -16,6 +16,8 @@ declare namespace App { recommendColor: boolean; /** Theme color */ themeColor: string; + /** Theme radius */ + themeRadius: number; /** Other color */ otherColor: OtherColor; /** Whether info color is followed by the primary color */ @@ -377,6 +379,9 @@ declare namespace App { } & Theme.ThemeColor; recommendColor: string; recommendColorDesc: string; + themeRadius: { + title: string; + }; preset: { title: string; apply: string; diff --git a/src/views/home/modules/card-data.vue b/src/views/home/modules/card-data.vue index 59104700..7b802d88 100644 --- a/src/views/home/modules/card-data.vue +++ b/src/views/home/modules/card-data.vue @@ -1,6 +1,7 @@