From 839b6015b8e31bf70e6f0bf0608fa729b028729b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=87=AF=E9=BE=99?= <502431556@qq.com> Date: Tue, 18 Jan 2022 16:22:47 +0800 Subject: [PATCH] feat(Layout): Add classic layout --- .vscode/settings.json | 3 +- src/App.vue | 19 ++- src/components/Breadcrumb/src/Breadcrumb.vue | 9 +- src/components/ColorRadioPicker/index.ts | 3 + .../ColorRadioPicker/src/ColorRadioPicker.vue | 60 ++++++++ .../ConfigGlobal/src/ConfigGlobal.vue | 25 ++-- .../LocaleDropdown/src/LocaleDropdown.vue | 4 +- src/components/Logo/src/Logo.vue | 23 ++- src/components/Menu/src/Menu.vue | 54 ++++++- src/components/Setting/src/Setting.vue | 113 ++++++++++++++- .../src/components/InterfaceDisplay.vue | 134 ++++++++++++++++++ .../SizeDropdown/src/SizeDropdown.vue | 6 +- src/components/TagsView/src/TagsView.vue | 4 +- src/config/app.ts | 73 ++++++---- src/config/locale.ts | 5 +- src/hooks/web/useLocale.ts | 2 +- src/layout/Layout.vue | 39 +++-- src/locales/en.ts | 21 ++- src/locales/zh-CN.ts | 21 ++- src/plugins/vueI18n/index.ts | 4 +- src/store/modules/app.ts | 125 ++++++++-------- src/store/modules/locale.ts | 10 +- src/styles/var.css | 6 +- src/utils/color.ts | 6 +- src/utils/index.ts | 4 + src/views/Login/Login.vue | 2 +- 26 files changed, 630 insertions(+), 145 deletions(-) create mode 100644 src/components/ColorRadioPicker/index.ts create mode 100644 src/components/ColorRadioPicker/src/ColorRadioPicker.vue create mode 100644 src/components/Setting/src/components/InterfaceDisplay.vue diff --git a/.vscode/settings.json b/.vscode/settings.json index 2dffb9990..4fde8c5ad 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,5 +14,6 @@ "i18n-ally.enabledParsers": ["ts"], "i18n-ally.sourceLanguage": "en", "i18n-ally.displayLanguage": "zh-CN", - "i18n-ally.enabledFrameworks": ["vue", "react"] + "i18n-ally.enabledFrameworks": ["vue", "react"], + "god.tsconfig": "./tsconfig.json" } diff --git a/src/App.vue b/src/App.vue index 9a798f416..0cf641917 100644 --- a/src/App.vue +++ b/src/App.vue @@ -6,7 +6,9 @@ import { isDark } from '@/utils/is' const appStore = useAppStore() -const size = computed(() => appStore.size) +const currentSize = computed(() => appStore.getCurrentSize) + +const greyMode = computed(() => appStore.getGreyMode) const initDark = () => { const isDarkTheme = isDark() @@ -17,12 +19,14 @@ initDark() diff --git a/src/components/Breadcrumb/src/Breadcrumb.vue b/src/components/Breadcrumb/src/Breadcrumb.vue index 031721eb2..1ddf751b1 100644 --- a/src/components/Breadcrumb/src/Breadcrumb.vue +++ b/src/components/Breadcrumb/src/Breadcrumb.vue @@ -2,13 +2,18 @@ import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus' import { ref, watch, computed, unref, defineComponent, TransitionGroup } from 'vue' import { useRouter } from 'vue-router' -// import { compile } from 'path-to-regexp' import { usePermissionStore } from '@/store/modules/permission' import { filterBreadcrumb } from './helper' import { filter, treeToList } from '@/utils/tree' import type { RouteLocationNormalizedLoaded, RouteMeta } from 'vue-router' import { useI18n } from '@/hooks/web/useI18n' import { Icon } from '@/components/Icon' +import { useAppStore } from '@/store/modules/app' + +const appStore = useAppStore() + +// 面包屑图标 +const breadcrumbIcon = computed(() => appStore.getBreadcrumbIcon) export default defineComponent({ name: 'Breadcrumb', @@ -41,7 +46,7 @@ export default defineComponent({ const meta = v.meta as RouteMeta return ( - {meta?.icon ? ( + {meta?.icon && breadcrumbIcon.value ? ( <> {t(v?.meta?.title)} diff --git a/src/components/ColorRadioPicker/index.ts b/src/components/ColorRadioPicker/index.ts new file mode 100644 index 000000000..6e3a7f22f --- /dev/null +++ b/src/components/ColorRadioPicker/index.ts @@ -0,0 +1,3 @@ +import ColorRadioPicker from './src/ColorRadioPicker.vue' + +export { ColorRadioPicker } diff --git a/src/components/ColorRadioPicker/src/ColorRadioPicker.vue b/src/components/ColorRadioPicker/src/ColorRadioPicker.vue new file mode 100644 index 000000000..639289cef --- /dev/null +++ b/src/components/ColorRadioPicker/src/ColorRadioPicker.vue @@ -0,0 +1,60 @@ + + + + + diff --git a/src/components/ConfigGlobal/src/ConfigGlobal.vue b/src/components/ConfigGlobal/src/ConfigGlobal.vue index 50d7aa9d2..8ca487544 100644 --- a/src/components/ConfigGlobal/src/ConfigGlobal.vue +++ b/src/components/ConfigGlobal/src/ConfigGlobal.vue @@ -1,5 +1,5 @@ diff --git a/src/components/LocaleDropdown/src/LocaleDropdown.vue b/src/components/LocaleDropdown/src/LocaleDropdown.vue index 7090d3f6c..159bd9358 100644 --- a/src/components/LocaleDropdown/src/LocaleDropdown.vue +++ b/src/components/LocaleDropdown/src/LocaleDropdown.vue @@ -8,13 +8,13 @@ const localeStore = useLocaleStore() const langMap = computed(() => localeStore.getLocaleMap) -const currentLang = computed(() => localeStore.getLocale) +const currentLang = computed(() => localeStore.getCurrentLocale) const setLang = (lang: LocaleType) => { if (lang === unref(currentLang).lang) return // 需要重新加载页面让整个语言多初始化 window.location.reload() - localeStore.setLocale({ + localeStore.setCurrentLocale({ lang }) const { changeLocale } = useLocale() diff --git a/src/components/Logo/src/Logo.vue b/src/components/Logo/src/Logo.vue index f3a039366..e4dc57dc2 100644 --- a/src/components/Logo/src/Logo.vue +++ b/src/components/Logo/src/Logo.vue @@ -1,5 +1,5 @@