diff --git a/apps/antd-view/package.json b/apps/antd-view/package.json
index d4175345..5479fc2f 100644
--- a/apps/antd-view/package.json
+++ b/apps/antd-view/package.json
@@ -22,14 +22,14 @@
"typecheck": "vue-tsc --noEmit --skipLibCheck"
},
"dependencies": {
+ "@vben-core/preferences": "workspace:*",
+ "@vben-core/stores": "workspace:*",
"@vben/common-ui": "workspace:*",
"@vben/constants": "workspace:*",
"@vben/hooks": "workspace:*",
"@vben/icons": "workspace:*",
"@vben/layouts": "workspace:*",
"@vben/locales": "workspace:*",
- "@vben/preference": "workspace:*",
- "@vben/stores": "workspace:*",
"@vben/styles": "workspace:*",
"@vben/types": "workspace:*",
"@vben/utils": "workspace:*",
@@ -37,6 +37,7 @@
"ant-design-vue": "^4.2.1",
"axios": "^1.7.2",
"dayjs": "^1.11.11",
+ "pinia": "2.1.7",
"vue": "3.4.27",
"vue-router": "^4.3.2"
},
diff --git a/apps/antd-view/src/app.vue b/apps/antd-view/src/app.vue
index b73e7fd2..692545e0 100644
--- a/apps/antd-view/src/app.vue
+++ b/apps/antd-view/src/app.vue
@@ -1,8 +1,9 @@
diff --git a/apps/antd-view/src/bootstrap.ts b/apps/antd-view/src/bootstrap.ts
index 8917f6b7..14ebe828 100644
--- a/apps/antd-view/src/bootstrap.ts
+++ b/apps/antd-view/src/bootstrap.ts
@@ -1,8 +1,9 @@
import '@vben/styles';
+import { preferences } from '@vben-core/preferences';
+
+import { setupStore } from '@/store';
import { setupI18n } from '@vben/locales';
-import { preference } from '@vben/preference';
-import { setupStore } from '@vben/stores';
import { createApp } from 'vue';
import App from './app.vue';
@@ -12,7 +13,7 @@ async function bootstrap(namespace: string) {
const app = createApp(App);
// 国际化 i18n 配置
- await setupI18n(app, { defaultLocale: preference.locale });
+ await setupI18n(app, { defaultLocale: preferences.app.locale });
// 配置 pinia-store
await setupStore(app, { namespace });
diff --git a/apps/antd-view/src/layouts/basic.vue b/apps/antd-view/src/layouts/basic.vue
index 996113ac..031b5395 100644
--- a/apps/antd-view/src/layouts/basic.vue
+++ b/apps/antd-view/src/layouts/basic.vue
@@ -1,12 +1,13 @@
@@ -24,10 +25,7 @@ function handleUpdate(value: string) {
-
+
diff --git a/packages/business/common-ui/src/authentication/layout-toggle.vue b/packages/business/common-ui/src/authentication/layout-toggle.vue
index 2d91cb98..1feee130 100644
--- a/packages/business/common-ui/src/authentication/layout-toggle.vue
+++ b/packages/business/common-ui/src/authentication/layout-toggle.vue
@@ -1,17 +1,15 @@
diff --git a/packages/business/common-ui/src/index.ts b/packages/business/common-ui/src/index.ts
index 6806ec79..c3c0e869 100644
--- a/packages/business/common-ui/src/index.ts
+++ b/packages/business/common-ui/src/index.ts
@@ -4,7 +4,7 @@ export * from './global-provider';
export * from './global-search';
export * from './language-toggle';
export * from './notification';
-export * from './preference';
+export * from './preferences';
export * from './spinner';
export * from './theme-toggle';
export * from './user-dropdown';
diff --git a/packages/business/common-ui/src/language-toggle/language-toggle.vue b/packages/business/common-ui/src/language-toggle/language-toggle.vue
index eb5ff7f2..a187759e 100644
--- a/packages/business/common-ui/src/language-toggle/language-toggle.vue
+++ b/packages/business/common-ui/src/language-toggle/language-toggle.vue
@@ -1,26 +1,28 @@
-
- handleUpdate('shortcutKeys', value)"
- @update:navigation-style="(value) => handleUpdate('navigationStyle', value)"
- @update:navigation-accordion="
- (value) => handleUpdate('navigationAccordion', value)
- "
- @update:navigation-split="(value) => handleUpdate('navigationSplit', value)"
- @update:dynamic-title="(value) => handleUpdate('dynamicTitle', value)"
- @update:tabs-icon="(value) => handleUpdate('tabsIcon', value)"
- @update:side-collapse="(value) => handleUpdate('sideCollapse', value)"
- @update:locale="updateLocale"
- @update:header-visible="(value) => handleUpdate('headerVisible', value)"
- @update:side-visible="(value) => handleUpdate('sideVisible', value)"
- @update:footer-visible="(value) => handleUpdate('footerVisible', value)"
- @update:tabs-visible="(value) => handleUpdate('tabsVisible', value)"
- @update:header-mode="(value) => handleUpdate('headerMode', value)"
- @update:footer-fixed="(value) => handleUpdate('footerFixed', value)"
- @update:breadcrumb-visible="
- (value) => handleUpdate('breadcrumbVisible', value)
- "
- @update:breadcrumb-hide-only-one="
- (value) => handleUpdate('breadcrumbHideOnlyOne', value)
- "
- @update:side-collapse-show-title="
- (value) => handleUpdate('sideCollapseShowTitle', value)
- "
- @update:breadcrumb-home="(value) => handleUpdate('breadcrumbHome', value)"
- @update:breadcrumb-icon="(value) => handleUpdate('breadcrumbIcon', value)"
- @update:breadcrumb-style="(value) => handleUpdate('breadcrumbStyle', value)"
- @update:page-transition-enable="
- (value) => handleUpdate('pageTransitionEnable', value)
- "
- @update:color-gray-mode="(value) => handleUpdate('colorGrayMode', value)"
- @update:page-transition="(value) => handleUpdate('pageTransition', value)"
- @update:page-progress="(value) => handleUpdate('pageProgress', value)"
- @update:color-primary="(value) => handleUpdate('colorPrimary', value)"
- @update:color-weak-mode="(value) => handleUpdate('colorWeakMode', value)"
- @update:content-compact="(value) => handleUpdate('contentCompact', value)"
- @update:layout="(value) => handleUpdate('layout', value)"
- @update:semi-dark-menu="(value) => handleUpdate('semiDarkMenu', value)"
- @update:theme="(value) => handleUpdate('theme', value)"
- />
-
diff --git a/packages/business/common-ui/src/preference/use-open-preference.ts b/packages/business/common-ui/src/preference/use-open-preference.ts
deleted file mode 100644
index a8ebae2b..00000000
--- a/packages/business/common-ui/src/preference/use-open-preference.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { ref } from 'vue';
-
-const openPreference = ref(false);
-
-function useOpenPreference() {
- function handleOpenPreference() {
- openPreference.value = true;
- }
-
- return {
- handleOpenPreference,
- openPreference,
- };
-}
-
-export { useOpenPreference };
diff --git a/packages/business/common-ui/src/preference/blocks/block.vue b/packages/business/common-ui/src/preferences/blocks/block.vue
similarity index 100%
rename from packages/business/common-ui/src/preference/blocks/block.vue
rename to packages/business/common-ui/src/preferences/blocks/block.vue
diff --git a/packages/business/common-ui/src/preference/blocks/general/animation.vue b/packages/business/common-ui/src/preferences/blocks/general/animation.vue
similarity index 100%
rename from packages/business/common-ui/src/preference/blocks/general/animation.vue
rename to packages/business/common-ui/src/preferences/blocks/general/animation.vue
diff --git a/packages/business/common-ui/src/preference/blocks/general/general.vue b/packages/business/common-ui/src/preferences/blocks/general/general.vue
similarity index 79%
rename from packages/business/common-ui/src/preference/blocks/general/general.vue
rename to packages/business/common-ui/src/preferences/blocks/general/general.vue
index 29c4e45f..8d983446 100644
--- a/packages/business/common-ui/src/preference/blocks/general/general.vue
+++ b/packages/business/common-ui/src/preferences/blocks/general/general.vue
@@ -1,8 +1,9 @@
diff --git a/packages/business/common-ui/src/preference/blocks/index.ts b/packages/business/common-ui/src/preferences/blocks/index.ts
similarity index 100%
rename from packages/business/common-ui/src/preference/blocks/index.ts
rename to packages/business/common-ui/src/preferences/blocks/index.ts
diff --git a/packages/business/common-ui/src/preference/blocks/layout/breadcrumb.vue b/packages/business/common-ui/src/preferences/blocks/layout/breadcrumb.vue
similarity index 100%
rename from packages/business/common-ui/src/preference/blocks/layout/breadcrumb.vue
rename to packages/business/common-ui/src/preferences/blocks/layout/breadcrumb.vue
diff --git a/packages/business/common-ui/src/preference/blocks/layout/content.vue b/packages/business/common-ui/src/preferences/blocks/layout/content.vue
similarity index 100%
rename from packages/business/common-ui/src/preference/blocks/layout/content.vue
rename to packages/business/common-ui/src/preferences/blocks/layout/content.vue
diff --git a/packages/business/common-ui/src/preference/blocks/layout/footer.vue b/packages/business/common-ui/src/preferences/blocks/layout/footer.vue
similarity index 100%
rename from packages/business/common-ui/src/preference/blocks/layout/footer.vue
rename to packages/business/common-ui/src/preferences/blocks/layout/footer.vue
diff --git a/packages/business/common-ui/src/preference/blocks/layout/header.vue b/packages/business/common-ui/src/preferences/blocks/layout/header.vue
similarity index 87%
rename from packages/business/common-ui/src/preference/blocks/layout/header.vue
rename to packages/business/common-ui/src/preferences/blocks/layout/header.vue
index de44b933..92d08468 100644
--- a/packages/business/common-ui/src/preference/blocks/layout/header.vue
+++ b/packages/business/common-ui/src/preferences/blocks/layout/header.vue
@@ -1,5 +1,5 @@
+
+
+
diff --git a/packages/business/common-ui/src/preference/preference.vue b/packages/business/common-ui/src/preferences/preferences.vue
similarity index 95%
rename from packages/business/common-ui/src/preference/preference.vue
rename to packages/business/common-ui/src/preferences/preferences.vue
index 0cfc3463..17ef7382 100644
--- a/packages/business/common-ui/src/preference/preference.vue
+++ b/packages/business/common-ui/src/preferences/preferences.vue
@@ -1,8 +1,13 @@
@@ -132,7 +136,7 @@ function handleReset() {
diff --git a/packages/business/common-ui/src/preference/trigger.vue b/packages/business/common-ui/src/preferences/trigger.vue
similarity index 100%
rename from packages/business/common-ui/src/preference/trigger.vue
rename to packages/business/common-ui/src/preferences/trigger.vue
diff --git a/packages/business/common-ui/src/preferences/use-open-preferences.ts b/packages/business/common-ui/src/preferences/use-open-preferences.ts
new file mode 100644
index 00000000..eb9d847c
--- /dev/null
+++ b/packages/business/common-ui/src/preferences/use-open-preferences.ts
@@ -0,0 +1,16 @@
+import { ref } from 'vue';
+
+const openPreferences = ref(false);
+
+function useOpenPreferences() {
+ function handleOpenPreference() {
+ openPreferences.value = true;
+ }
+
+ return {
+ handleOpenPreference,
+ openPreferences,
+ };
+}
+
+export { useOpenPreferences };
diff --git a/packages/business/common-ui/src/theme-toggle/theme-toggle.vue b/packages/business/common-ui/src/theme-toggle/theme-toggle.vue
index b6e74f5e..8b761228 100644
--- a/packages/business/common-ui/src/theme-toggle/theme-toggle.vue
+++ b/packages/business/common-ui/src/theme-toggle/theme-toggle.vue
@@ -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 = [
/>
();
const openPopover = ref(false);
const openDialog = ref(false);
-const { handleOpenPreference } = useOpenPreference();
+const { handleOpenPreference } = useOpenPreferences();
const altView = computed(() => (isWindowsOs() ? 'Alt' : '⌥'));
const shortcutKeys = computed(() => {
- return props.enableShortcutKey && preference.shortcutKeys;
+ return props.enableShortcutKey && preferences.shortcutKeys.enable;
});
function handleLogout() {
@@ -161,7 +161,7 @@ if (shortcutKeys.value) {
diff --git a/packages/business/layouts/package.json b/packages/business/layouts/package.json
index 79d39e87..ea0dca23 100644
--- a/packages/business/layouts/package.json
+++ b/packages/business/layouts/package.json
@@ -44,13 +44,13 @@
"@vben-core/iconify": "workspace:*",
"@vben-core/layout-ui": "workspace:*",
"@vben-core/menu-ui": "workspace:*",
+ "@vben-core/preferences": "workspace:*",
"@vben-core/shadcn-ui": "workspace:*",
+ "@vben-core/stores": "workspace:*",
"@vben-core/tabs-ui": "workspace:*",
"@vben-core/toolkit": "workspace:*",
"@vben/common-ui": "workspace:*",
"@vben/locales": "workspace:*",
- "@vben/preference": "workspace:*",
- "@vben/stores": "workspace:*",
"vue": "3.4.27",
"vue-router": "^4.3.2"
},
diff --git a/packages/business/layouts/src/authentication/authentication.vue b/packages/business/layouts/src/authentication/authentication.vue
index adfe126a..6e754597 100644
--- a/packages/business/layouts/src/authentication/authentication.vue
+++ b/packages/business/layouts/src/authentication/authentication.vue
@@ -1,6 +1,8 @@
@@ -33,13 +36,13 @@ const { authPanelCenter, authPanelLeft, authPanelRight } = usePreference();
"
>
- {{ preference.appName }}
+ {{ appName }}
@@ -48,10 +51,7 @@ const { authPanelCenter, authPanelLeft, authPanelRight } = usePreference();
class="absolute inset-0 h-full w-full bg-[var(--color-authentication)]"
>
-
+
{{ $t('authentication.layout-title') }}
diff --git a/packages/business/layouts/src/authentication/from-view.vue b/packages/business/layouts/src/authentication/from-view.vue
index 27ef5dba..095982bd 100644
--- a/packages/business/layouts/src/authentication/from-view.vue
+++ b/packages/business/layouts/src/authentication/from-view.vue
@@ -1,5 +1,5 @@
diff --git a/packages/business/layouts/src/basic/header/header.vue b/packages/business/layouts/src/basic/header/header.vue
index 3069cc97..dd3dcc19 100644
--- a/packages/business/layouts/src/basic/header/header.vue
+++ b/packages/business/layouts/src/basic/header/header.vue
@@ -1,9 +1,9 @@
@@ -27,7 +31,7 @@ function handleScreenChange(screen: boolean) {
diff --git a/packages/business/layouts/src/basic/tabs/use-tabs.ts b/packages/business/layouts/src/basic/tabs/use-tabs.ts
index 5531a1e0..acf67cc5 100644
--- a/packages/business/layouts/src/basic/tabs/use-tabs.ts
+++ b/packages/business/layouts/src/basic/tabs/use-tabs.ts
@@ -11,6 +11,7 @@ import {
MdiPin,
MdiPinOff,
} from '@vben-core/iconify';
+import { storeToRefs, useAccessStore, useTabsStore } from '@vben-core/stores';
import { filterTree } from '@vben-core/toolkit';
import type {
RouteLocationNormalized,
@@ -18,7 +19,6 @@ import type {
} from 'vue-router';
import { $t } from '@vben/locales';
-import { storeToRefs, useAccessStore, useTabsStore } from '@vben/stores';
import { computed, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
diff --git a/packages/business/layouts/src/basic/widgets/breadcrumb.vue b/packages/business/layouts/src/basic/widgets/breadcrumb.vue
index e5a604a0..e5cbb09c 100644
--- a/packages/business/layouts/src/basic/widgets/breadcrumb.vue
+++ b/packages/business/layouts/src/basic/widgets/breadcrumb.vue
@@ -1,8 +1,8 @@