Skip to content

Commit

Permalink
refactor(projects): themeStore: isCustomizeInfoColor to isInfoFollowP…
Browse files Browse the repository at this point in the history
…rimary
  • Loading branch information
honghuangdc committed Nov 14, 2023
1 parent f0f0236 commit 0867f4b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 22 deletions.
8 changes: 2 additions & 6 deletions src/layouts/modules/theme-drawer/modules/theme-color.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,20 @@ const themeStore = useThemeStore();
function handleUpdateColor(color: string, key: App.Theme.ThemeColorKey) {
themeStore.updateThemeColors(key, color);
}
function handleUpdateCustomizeInfoColor(checked: boolean) {
themeStore.updateIsCustomizeInfoColor(!checked);
}
</script>

<template>
<ADivider>{{ $t('theme.themeColor.title') }}</ADivider>
<div class="flex-vertical-stretch gap-12px">
<SettingItem v-for="(_, key) in themeStore.themeColors" :key="key" :label="$t(`theme.themeColor.${key}`)">
<template v-if="key === 'info'" #suffix>
<ACheckbox :checked="!themeStore.isCustomizeInfoColor" @update:checked="handleUpdateCustomizeInfoColor">
<ACheckbox v-model:checked="themeStore.isInfoFollowPrimary">
{{ $t('theme.themeColor.followPrimary') }}
</ACheckbox>
</template>
<ColorPicker
:color="themeStore.themeColors[key]"
:disabled="key === 'info' && !themeStore.isCustomizeInfoColor"
:disabled="key === 'info' && themeStore.isInfoFollowPrimary"
@update:color="handleUpdateColor($event, key)"
/>
</SettingItem>
Expand Down
15 changes: 3 additions & 12 deletions src/store/modules/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ export const useThemeStore = defineStore(SetupStoreId.Theme, () => {
* theme colors
*/
const themeColors = computed(() => {
const { themeColor, otherColor, isCustomizeInfoColor } = settings.value;
const { themeColor, otherColor, isInfoFollowPrimary } = settings.value;
const colors: App.Theme.ThemeColor = {
primary: themeColor,
...otherColor,
info: isCustomizeInfoColor ? otherColor.info : themeColor
info: isInfoFollowPrimary ? themeColor : otherColor.info
};
return colors;
});
Expand All @@ -90,14 +90,6 @@ export const useThemeStore = defineStore(SetupStoreId.Theme, () => {
}
}

/**
* update is customize info color
* @param customize
*/
function updateIsCustomizeInfoColor(customize: boolean) {
settings.value.isCustomizeInfoColor = customize;
}

/**
* setup theme vars to html
*/
Expand Down Expand Up @@ -142,7 +134,6 @@ export const useThemeStore = defineStore(SetupStoreId.Theme, () => {
antdTheme,
setThemeLayout,
themeColors,
updateThemeColors,
updateIsCustomizeInfoColor
updateThemeColors
};
});
2 changes: 1 addition & 1 deletion src/store/modules/theme/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function initThemeSettings() {
warning: '#faad14',
error: '#f5222d'
},
isCustomizeInfoColor: false,
isInfoFollowPrimary: true,
layout: {
mode: 'vertical',
scrollMode: 'content'
Expand Down
5 changes: 2 additions & 3 deletions src/typings/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ declare namespace App {
*/
otherColor: OtherColor;
/**
* is customize info color
* @description if not, the info color will transformed by the primary color
* whether info color is followed by the primary color
*/
isCustomizeInfoColor: boolean;
isInfoFollowPrimary: boolean;
/**
* layout
*/
Expand Down

0 comments on commit 0867f4b

Please sign in to comment.