refactor: refacotr preference

This commit is contained in:
vben
2024-06-01 23:15:29 +08:00
parent f7b97e8a83
commit fed47f5e05
139 changed files with 2205 additions and 1450 deletions

View File

@@ -4,6 +4,11 @@ import {
IcRoundWbSunny,
MdiMoonAndStars,
} from '@vben-core/iconify';
import {
preferences,
updatePreferences,
usePreferences,
} from '@vben-core/preferences';
import {
ToggleGroup,
ToggleGroupItem,
@@ -11,7 +16,6 @@ import {
} from '@vben-core/shadcn-ui';
import { $t } from '@vben/locales';
import { preference, updatePreference, usePreference } from '@vben/preference';
import ThemeButton from './theme-button.vue';
@@ -24,10 +28,12 @@ withDefaults(defineProps<{ shouldOnHover?: boolean }>(), {
});
function handleChange(isDark: boolean) {
updatePreference({ theme: isDark ? 'dark' : 'light' });
updatePreferences({
app: { themeMode: isDark ? 'dark' : 'light' },
});
}
const { isDark } = usePreference();
const { isDark } = usePreferences();
const PRESETS = [
{
@@ -58,7 +64,7 @@ const PRESETS = [
/>
</template>
<ToggleGroup
:model-value="preference.theme"
:model-value="preferences.app.themeMode"
type="single"
variant="outline"
class="gap-2"