From 99d6fdd60f4e406d4fbb7bed2effda283435272b Mon Sep 17 00:00:00 2001 From: h_mo <596417202@qq.com> Date: Wed, 1 Feb 2023 18:02:36 +0800 Subject: [PATCH 01/22] wip: layout store --- packages/layouts/index.ts | 1 + packages/layouts/src/components/main.vue | 7 ++ packages/layouts/src/store/index.ts | 1 + .../src/store/modules/headerSetting.ts | 62 ++++++++++ .../layouts/src/store/modules/menuSetting.ts | 113 ++++++++++++++++++ .../src/store/modules/multiTabsSetting.ts | 41 +++++++ packages/layouts/src/store/modules/test.ts | 2 +- .../src/store/modules/transitionSetting.ts | 38 ++++++ 8 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 packages/layouts/src/store/index.ts create mode 100644 packages/layouts/src/store/modules/headerSetting.ts create mode 100644 packages/layouts/src/store/modules/menuSetting.ts create mode 100644 packages/layouts/src/store/modules/multiTabsSetting.ts create mode 100644 packages/layouts/src/store/modules/transitionSetting.ts diff --git a/packages/layouts/index.ts b/packages/layouts/index.ts index 49c05a5d..d206c837 100644 --- a/packages/layouts/index.ts +++ b/packages/layouts/index.ts @@ -1,3 +1,4 @@ export { default as Layout } from './src/index.vue' export { initLayout } from './bridge' export { default as DarkModeToggle } from './src/components/setting/components/DarkModeToggle.vue' +export * from './src/store/index' diff --git a/packages/layouts/src/components/main.vue b/packages/layouts/src/components/main.vue index 17fca523..4b06e58d 100644 --- a/packages/layouts/src/components/main.vue +++ b/packages/layouts/src/components/main.vue @@ -1,10 +1,17 @@ + + change {{ bgColor }} + diff --git a/packages/layouts/src/store/index.ts b/packages/layouts/src/store/index.ts new file mode 100644 index 00000000..c6b39924 --- /dev/null +++ b/packages/layouts/src/store/index.ts @@ -0,0 +1 @@ +export { useLayoutTest } from './modules/test' diff --git a/packages/layouts/src/store/modules/headerSetting.ts b/packages/layouts/src/store/modules/headerSetting.ts new file mode 100644 index 00000000..f1019aeb --- /dev/null +++ b/packages/layouts/src/store/modules/headerSetting.ts @@ -0,0 +1,62 @@ +import { defineStore } from '@vben/pinia' +import { HeaderSetting } from '@vben/types' +import { ThemeEnum, HEADER_PRESET_BG_COLOR_LIST } from '@vben/constants' + +export const useHeaderSettingStore = defineStore({ + id: 'LAYOUT_HEADER_SETTING', + // persist: true, + state: (): HeaderSetting => ({ + // header bg color + bgColor: HEADER_PRESET_BG_COLOR_LIST[0], + // Fixed at the top + fixed: true, + // Whether to show top + show: true, + // theme + theme: ThemeEnum.LIGHT, + // Whether to enable the lock screen function + useLockPage: true, + // Whether to show the full screen button + showFullScreen: true, + // Whether to show the document button + showDoc: true, + // Whether to show the notification button + showNotice: true, + // Whether to display the menu search + showSearch: true, + showLocalePicker: true, + }), + getters: {}, + actions: { + setBgColor(value: string) { + this.bgColor = value + }, + setFixed(value: boolean) { + this.fixed = value + }, + setShow(value: boolean) { + this.show = value + }, + setTheme(value: ThemeEnum) { + this.theme = value + }, + setUseLockPage(value: boolean) { + this.useLockPage = value + }, + setShowFullScreen(value: boolean) { + this.showFullScreen = value + }, + setShowDoc(value: boolean) { + this.showDoc = value + }, + setShowNotice(value: boolean) { + this.showNotice = value + }, + setShowSearch(value: boolean) { + this.showSearch = value + }, + setShowLocalePicker(value: boolean) { + this.showLocalePicker = value + }, + }, +}) diff --git a/packages/layouts/src/store/modules/menuSetting.ts b/packages/layouts/src/store/modules/menuSetting.ts new file mode 100644 index 00000000..78b42f9b --- /dev/null +++ b/packages/layouts/src/store/modules/menuSetting.ts @@ -0,0 +1,113 @@ +import { defineStore } from '@vben/pinia' +import { MenuSetting } from '@vben/types' +import { + ThemeEnum, + SIDE_BAR_BG_COLOR_LIST, + MenuModeEnum, + MenuTypeEnum, + TriggerEnum, + MixSidebarTriggerEnum, +} from '@vben/constants' + +export const useMenuSettingStore = defineStore({ + id: 'LAYOUT_MENU_SETTING', + // persist: true, + state: (): MenuSetting => ({ + // sidebar menu bg color + bgColor: SIDE_BAR_BG_COLOR_LIST[0], + // Whether to fix the left menu + fixed: true, + // Menu collapse + collapsed: false, + // Whether to display the menu name when folding the menu + collapsedShowTitle: false, + // Whether it can be dragged + // Only limited to the opening of the left menu, the mouse has a drag bar on the right side of the menu + canDrag: false, + // Whether to show no dom + show: true, + // Whether to show dom + hidden: false, + // Menu width + menuWidth: 210, + // Menu mode + mode: MenuModeEnum.INLINE, + // Menu type + type: MenuTypeEnum.SIDEBAR, + // Menu theme + theme: ThemeEnum.DARK, + // Split menu + split: false, + // Top menu layout + topMenuAlign: 'center', + // Fold trigger position + trigger: TriggerEnum.HEADER, + // Turn on accordion mode, only show a menu + accordion: true, + // Switch page to close menu + closeMixSidebarOnChange: false, + // Module opening method ‘click’ |'hover' + mixSideTrigger: MixSidebarTriggerEnum.CLICK, + // Fixed expanded menu + mixSideFixed: false, + }), + getters: { + // getIsSidebarType(){}, + }, + actions: { + setBgColor(value: string) { + this.bgColor = value + }, + setFixed(value: boolean) { + this.fixed = value + }, + setCollapsed(value: boolean) { + this.collapsed = value + }, + setCollapsedShowTitle(value: boolean) { + this.collapsedShowTitle = value + }, + setCanDrag(value: boolean) { + this.canDrag = value + }, + setShow(value: boolean) { + this.show = value + }, + setHidden(value: boolean) { + this.hidden = value + }, + setMenuWidth(value: number) { + this.menuWidth = value + }, + setMode(value: MenuModeEnum) { + this.mode = value + }, + setType(value: MenuTypeEnum) { + this.type = value + }, + setTheme(value: ThemeEnum) { + this.theme = value + }, + setSplit(value: boolean) { + this.split = value + }, + setTopMenuAlign(value: 'start' | 'center' | 'end') { + this.topMenuAlign = value + }, + setTrigger(value: TriggerEnum) { + this.trigger = value + }, + setAccordion(value: boolean) { + this.accordion = value + }, + setCloseMixSidebarOnChange(value: boolean) { + this.closeMixSidebarOnChange = value + }, + setMixSideTrigger(value: MixSidebarTriggerEnum) { + this.mixSideTrigger = value + }, + setMixSideFixed(value: boolean) { + this.mixSideFixed = value + }, + }, +}) diff --git a/packages/layouts/src/store/modules/multiTabsSetting.ts b/packages/layouts/src/store/modules/multiTabsSetting.ts new file mode 100644 index 00000000..36a77173 --- /dev/null +++ b/packages/layouts/src/store/modules/multiTabsSetting.ts @@ -0,0 +1,41 @@ +import { defineStore } from '@vben/pinia' +import { MultiTabsSetting } from '@vben/types' + +export const useMultiTabsSettingStore = defineStore({ + id: 'LAYOUT_MULTI_TABS_SETTING', + // persist: true, + state: (): MultiTabsSetting => ({ + cache: false, + // Turn on + show: true, + // Is it possible to drag and drop sorting tabs + canDrag: true, + // Turn on quick actions + showQuick: true, + // Whether to show the refresh button + showRedo: true, + // Whether to show the collapse button + showFold: true, + }), + getters: {}, + actions: { + setCache(value: boolean) { + this.cache = value + }, + setShow(value: boolean) { + this.show = value + }, + setCanDrag(value: boolean) { + this.canDrag = value + }, + setShowQuick(value: boolean) { + this.showQuick = value + }, + setShowRedo(value: boolean) { + this.showRedo = value + }, + setShowFold(value: boolean) { + this.showFold = value + }, + }, +}) diff --git a/packages/layouts/src/store/modules/test.ts b/packages/layouts/src/store/modules/test.ts index cec98ad0..8595ae92 100644 --- a/packages/layouts/src/store/modules/test.ts +++ b/packages/layouts/src/store/modules/test.ts @@ -10,5 +10,5 @@ export const useLayoutTest = defineStore({ this.test = value }, }, - persist: true, + // persist: true, }) diff --git a/packages/layouts/src/store/modules/transitionSetting.ts b/packages/layouts/src/store/modules/transitionSetting.ts new file mode 100644 index 00000000..3a40c8c8 --- /dev/null +++ b/packages/layouts/src/store/modules/transitionSetting.ts @@ -0,0 +1,38 @@ +import { defineStore } from '@vben/pinia' +import { TransitionSetting } from '@vben/types' +import { RouterTransitionEnum } from '@vben/constants' + +export const useTransitionSettingStore = defineStore({ + id: 'LAYOUT_TRANSITION_SETTING', + // persist: true, + state: (): TransitionSetting => ({ + // Whether to open the page switching animation + // The disabled state will also disable pageLoading + enable: true, + + // Route basic switching animation + basicTransition: RouterTransitionEnum.FADE_SIDE, + + // Whether to open page switching loading + // Only open when enable=true + openPageLoading: true, + + // Whether to open the top progress bar + openNProgress: false, + }), + getters: {}, + actions: { + setEnable(value: boolean) { + this.enable = value + }, + setBasicTransition(value: RouterTransitionEnum) { + this.basicTransition = value + }, + setOpenPageLoading(value: boolean) { + this.openPageLoading = value + }, + setOpenNProgress(value: boolean) { + this.openNProgress = value + }, + }, +}) From ea9fac0735b080d4d36949b013038b1da5cea494 Mon Sep 17 00:00:00 2001 From: h_mo <596417202@qq.com> Date: Wed, 1 Feb 2023 22:23:22 +0800 Subject: [PATCH 02/22] wip: layout store --- packages/layouts/src/store/index.ts | 6 +- .../layouts/src/store/modules/menuSetting.ts | 10 +- .../src/store/modules/sporadicSetting.ts | 130 ++++++++++++++++++ packages/layouts/src/store/modules/test.ts | 14 -- packages/types/src/setting.ts | 53 +++---- 5 files changed, 172 insertions(+), 41 deletions(-) create mode 100644 packages/layouts/src/store/modules/sporadicSetting.ts delete mode 100644 packages/layouts/src/store/modules/test.ts diff --git a/packages/layouts/src/store/index.ts b/packages/layouts/src/store/index.ts index c6b39924..cc729d66 100644 --- a/packages/layouts/src/store/index.ts +++ b/packages/layouts/src/store/index.ts @@ -1 +1,5 @@ -export { useLayoutTest } from './modules/test' +export { useSporadicSetting } from './modules/sporadicSetting' +export { useHeaderSettingStore } from './modules/headerSetting' +export { useMenuSettingStore } from './modules/menuSetting' +export { useTransitionSettingStore } from './modules/transitionSetting' +export { useMultiTabsSettingStore } from './modules/multiTabsSetting' diff --git a/packages/layouts/src/store/modules/menuSetting.ts b/packages/layouts/src/store/modules/menuSetting.ts index 78b42f9b..4698a09c 100644 --- a/packages/layouts/src/store/modules/menuSetting.ts +++ b/packages/layouts/src/store/modules/menuSetting.ts @@ -52,7 +52,15 @@ export const useMenuSettingStore = defineStore({ mixSideFixed: false, }), getters: { - // getIsSidebarType(){}, + isSidebarType: (state) => { + return state.type === MenuTypeEnum.SIDEBAR + }, + isTopMenu: (state) => { + return state.type === MenuTypeEnum.SIDEBAR + }, + menuShowLogo: (state) => { + return state.type === MenuTypeEnum.SIDEBAR + }, }, actions: { setBgColor(value: string) { diff --git a/packages/layouts/src/store/modules/sporadicSetting.ts b/packages/layouts/src/store/modules/sporadicSetting.ts new file mode 100644 index 00000000..9003def9 --- /dev/null +++ b/packages/layouts/src/store/modules/sporadicSetting.ts @@ -0,0 +1,130 @@ +import { defineStore } from '@vben/pinia' +import { SporadicSetting } from '@vben/types' +import { + SettingButtonPositionEnum, + PermissionModeEnum, + CacheTypeEnum, + SessionTimeoutProcessingEnum, + ContentLayoutEnum, +} from '@vben/constants' + +export const useSporadicSetting = defineStore({ + id: 'LAYOUT_SPORADIC_SETTING', + // persist: true, + state: (): SporadicSetting => ({ + // Whether to show the configuration button + showSettingButton: true, + // Whether to show the theme switch button + showDarkModeToggle: true, + // `Settings` button position + settingButtonPosition: SettingButtonPositionEnum.AUTO, + // Permission mode + permissionMode: PermissionModeEnum.ROUTE_MAPPING, + // Permission-related cache is stored in sessionStorage or localStorage + permissionCacheType: CacheTypeEnum.LOCAL, + // Session timeout processing + sessionTimeoutProcessing: SessionTimeoutProcessingEnum.ROUTE_JUMP, + // color + themeColor: '#0960bd', + // Website gray mode, open for possible mourning dates + grayMode: false, + // Color Weakness Mode + colorWeak: false, + // Whether to cancel the menu, the top, the multi-tab page display, for possible embedded in other systems + fullContent: false, + // content mode + contentMode: ContentLayoutEnum.FULL, + // Whether to display the logo + showLogo: true, + // Whether to show footer + showFooter: false, + // Whether to open the top progress bar + openNProgress: false, + // Whether to enable KeepAlive cache is best to close during development, otherwise the cache needs to be cleared every time + openKeepAlive: true, + // Automatic screen lock time, 0 does not lock the screen. Unit minute default 0 + lockTime: 0, + // Whether to show breadcrumbs + showBreadCrumb: true, + // Whether to show the breadcrumb icon + showBreadCrumbIcon: true, + // Whether to open back to top + useOpenBackTop: true, + // Is it possible to embed iframe pages + canEmbedIFramePage: true, + // Whether to delete unclosed messages and notify when switching the interface + closeMessageOnSwitch: true, + // Whether to cancel the http request that has been sent but not responded when switching the interface. + // If it is enabled, I want to overwrite a single interface. Can be set in a separate interface + removeAllHttpPending: false, + }), + getters: {}, + actions: { + setShowSettingButton(value: boolean) { + this.showSettingButton = value + }, + setShowDarkModeToggle(value: boolean) { + this.showDarkModeToggle = value + }, + setSettingButtonPosition(value: SettingButtonPositionEnum) { + this.settingButtonPosition = value + }, + setPermissionMode(value: PermissionModeEnum) { + this.permissionMode = value + }, + setPermissionCacheType(value: CacheTypeEnum) { + this.permissionCacheType = value + }, + setSessionTimeoutProcessing(value: SessionTimeoutProcessingEnum) { + this.sessionTimeoutProcessing = value + }, + setThemeColor(value: string) { + this.themeColor = value + }, + setGrayMode(value: boolean) { + this.grayMode = value + }, + setColorWeak(value: boolean) { + this.colorWeak = value + }, + setFullContent(value: boolean) { + this.fullContent = value + }, + setContentMode(value: ContentLayoutEnum) { + this.contentMode = value + }, + setShowLogo(value: boolean) { + this.showLogo = value + }, + setShowFooter(value: boolean) { + this.showFooter = value + }, + setOpenNProgress(value: boolean) { + this.openNProgress = value + }, + setOpenKeepAlive(value: boolean) { + this.openKeepAlive = value + }, + setLockTime(value: number) { + this.lockTime = value + }, + setShowBreadCrumb(value: boolean) { + this.showBreadCrumb = value + }, + setShowBreadCrumbIcon(value: boolean) { + this.showBreadCrumbIcon = value + }, + setUseOpenBackTop(value: boolean) { + this.useOpenBackTop = value + }, + setCanEmbedIFramePage(value: boolean) { + this.canEmbedIFramePage = value + }, + setCloseMessageOnSwitch(value: boolean) { + this.closeMessageOnSwitch = value + }, + setRemoveAllHttpPending(value: boolean) { + this.removeAllHttpPending = value + }, + }, +}) diff --git a/packages/layouts/src/store/modules/test.ts b/packages/layouts/src/store/modules/test.ts deleted file mode 100644 index 8595ae92..00000000 --- a/packages/layouts/src/store/modules/test.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { defineStore } from '@vben/pinia' - -export const useLayoutTest = defineStore({ - id: 'use--layout--test', - state: () => ({ - test: 'layout 测试', - }), - actions: { - setTest(value: string) { - this.test = value - }, - }, - // persist: true, -}) diff --git a/packages/types/src/setting.ts b/packages/types/src/setting.ts index 02614616..b85aa002 100644 --- a/packages/types/src/setting.ts +++ b/packages/types/src/setting.ts @@ -9,7 +9,7 @@ import { SettingButtonPositionEnum, ThemeEnum, TriggerEnum, - RouterTransitionEnum + RouterTransitionEnum, } from '@vben/constants' import { LocaleType } from './config' // export type LocaleType = 'zh_CN' | 'en' | 'ru' | 'ja' | 'ko' @@ -73,16 +73,34 @@ export interface LocaleSetting { export interface TransitionSetting { // Whether to open the page switching animation - enable: boolean; + enable: boolean // Route basic switching animation - basicTransition: RouterTransitionEnum; + basicTransition: RouterTransitionEnum // Whether to open page switching loading - openPageLoading: boolean; + openPageLoading: boolean // Whether to open the top progress bar - openNProgress: boolean; + openNProgress: boolean } -export interface ProjectConfig { +export interface SporadicSetting { + // Whether to open the top progress bar + openNProgress: boolean + // pageLayout whether to enable keep-alive + openKeepAlive: boolean + // Lock screen time + lockTime: number + // Show breadcrumbs + showBreadCrumb: boolean + // Show breadcrumb icon + showBreadCrumbIcon: boolean + // Whether to open back to top + useOpenBackTop: boolean + // Is it possible to embed iframe pages + canEmbedIFramePage: boolean + // Whether to delete unclosed messages and notify when switching the interface + closeMessageOnSwitch: boolean + // Whether to cancel the http request that has been sent but not responded when switching the interface. + removeAllHttpPending: boolean // Storage location of permission related information permissionCacheType: CacheTypeEnum // Whether to show the configuration button @@ -110,6 +128,9 @@ export interface ProjectConfig { showLogo: boolean // Whether to show the global footer showFooter: boolean +} + +export interface ProjectConfig extends SporadicSetting { // menuType: MenuTypeEnum; headerSetting: HeaderSetting // menuSetting @@ -117,23 +138,5 @@ export interface ProjectConfig { // Multi-tab settings multiTabsSetting: MultiTabsSetting // Animation configuration - transitionSetting: TransitionSetting; - // Whether to open the top progress bar - openNProgress: false - // pageLayout whether to enable keep-alive - openKeepAlive: boolean - // Lock screen time - lockTime: number - // Show breadcrumbs - showBreadCrumb: boolean - // Show breadcrumb icon - showBreadCrumbIcon: boolean - // Whether to open back to top - useOpenBackTop: boolean - // Is it possible to embed iframe pages - canEmbedIFramePage: boolean - // Whether to delete unclosed messages and notify when switching the interface - closeMessageOnSwitch: boolean - // Whether to cancel the http request that has been sent but not responded when switching the interface. - removeAllHttpPending: boolean + transitionSetting: TransitionSetting } From 20967794e20a84c2cc11d12f36bce068e9617743 Mon Sep 17 00:00:00 2001 From: h_mo <596417202@qq.com> Date: Thu, 2 Feb 2023 10:15:52 +0800 Subject: [PATCH 03/22] =?UTF-8?q?perf:=20=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/admin/src/pages/sys/login/login.vue | 1 - .../layouts/src/components/lock/LockModal.vue | 66 +++++----- .../setting/components/SettingDrawer.vue | 114 +++++++++++------- 3 files changed, 103 insertions(+), 78 deletions(-) diff --git a/apps/admin/src/pages/sys/login/login.vue b/apps/admin/src/pages/sys/login/login.vue index 2f2ca608..cf837c4b 100644 --- a/apps/admin/src/pages/sys/login/login.vue +++ b/apps/admin/src/pages/sys/login/login.vue @@ -6,7 +6,6 @@ import ForgetPasswordForm from './forget-password-form.vue' import RegisterForm from './register-form.vue' import MobileForm from './mobile-form.vue' import QrCodeForm from './qrcode-form.vue' -import { DarkModeToggle } from '@vben/layouts' const { bem } = createNamespace('login') defineProps({ diff --git a/packages/layouts/src/components/lock/LockModal.vue b/packages/layouts/src/components/lock/LockModal.vue index 8c9b66e8..19219198 100644 --- a/packages/layouts/src/components/lock/LockModal.vue +++ b/packages/layouts/src/components/lock/LockModal.vue @@ -1,25 +1,25 @@ - + - + {{ getUserInfo.realName }} - + - {{ t('layout.header.lockScreenBtn')}} + {{ t('layout.header.lockScreenBtn') }} - + diff --git a/packages/layouts/src/components/setting/components/SettingDrawer.vue b/packages/layouts/src/components/setting/components/SettingDrawer.vue index 7ab1992f..6b0c2b20 100644 --- a/packages/layouts/src/components/setting/components/SettingDrawer.vue +++ b/packages/layouts/src/components/setting/components/SettingDrawer.vue @@ -1,5 +1,4 @@ @@ -48,32 +39,65 @@ const onVisible = (show: boolean)=>{ {{ t('layout.setting.drawerTitle') }} - {{ t('layout.setting.darkMode') }} - + {{ + t('layout.setting.darkMode') + }} + - {{ t('layout.setting.navMode') }} - { - baseHandler(HandlerSettingEnum.CHANGE_LAYOUT,{ - mode: item.mode, - type: item.type, - split: getIsHorizontal ? false : undefined, - }) - }"/> - {{ t('layout.setting.sysTheme') }} - - {{ t('layout.setting.headerTheme') }} - - {{ t('layout.setting.sidebarTheme') }} - - {{ t('layout.setting.interfaceFunction') }} + {{ + t('layout.setting.navMode') + }} + { + baseHandler(HandlerSettingEnum.CHANGE_LAYOUT, { + mode: item.mode, + type: item.type, + split: getIsHorizontal ? false : undefined, + }) + } + " + /> + {{ + t('layout.setting.sysTheme') + }} + + {{ + t('layout.setting.headerTheme') + }} + + {{ + t('layout.setting.sidebarTheme') + }} + + {{ t('layout.setting.interfaceFunction') }} - - {{ t('layout.setting.interfaceDisplay') }} - - {{ t('layout.setting.animation') }} - - - + + {{ + t('layout.setting.interfaceDisplay') + }} + + {{ + t('layout.setting.animation') + }} + + + From 099d2b40f2b154f5ebf8aca6e1d0238730b0791a Mon Sep 17 00:00:00 2001 From: h_mo <596417202@qq.com> Date: Thu, 2 Feb 2023 15:46:02 +0800 Subject: [PATCH 04/22] chore: Configure .npmrx --- .npmrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.npmrc b/.npmrc index 68fbcd57..b07f5c51 100644 --- a/.npmrc +++ b/.npmrc @@ -6,3 +6,4 @@ public-hoist-pattern[]=*eslint* public-hoist-pattern[]=*prettier* public-hoist-pattern[]=*vite-plugin-mock* public-hoist-pattern[]=vite +strict-peer-dependencies=false From 1cb9848ce46399e413040b2c8218886aefee585c Mon Sep 17 00:00:00 2001 From: h_mo <596417202@qq.com> Date: Thu, 2 Feb 2023 18:00:52 +0800 Subject: [PATCH 05/22] wip: grid-layout --- apps/admin/package.json | 1 + apps/admin/src/layout/index.vue | 4 +- packages/grid-layouts/index.ts | 3 ++ packages/grid-layouts/package.json | 22 ++++++++ .../grid-layouts/src/components/Layout.vue | 19 +++++++ .../src/components/LayoutContent.vue | 10 ++++ .../src/components/LayoutFooter.vue | 6 +++ .../src/components/LayoutHeader.vue | 6 +++ .../src/components/LayoutLogo.vue | 5 ++ .../src/components/LayoutSidebar.vue | 6 +++ .../grid-layouts/src/components/LayoutTab.vue | 6 +++ packages/grid-layouts/src/index.vue | 7 +++ .../src/store/index.ts | 6 +++ .../src/store/modules/headerSetting.ts | 0 .../src/store/modules/layoutComposables.ts | 52 +++++++++++++++++++ .../src/store/modules/menuSetting.ts | 45 +++++++++++++--- .../src/store/modules/multiTabsSetting.ts | 0 .../src/store/modules/sporadicSetting.ts | 0 .../src/store/modules/transitionSetting.ts | 0 packages/layouts/index.ts | 1 - packages/layouts/src/components/main.vue | 7 --- packages/styles/src/grid-layout.scss | 32 ++++++++++++ packages/styles/src/index.ts | 1 + 23 files changed, 222 insertions(+), 17 deletions(-) create mode 100644 packages/grid-layouts/index.ts create mode 100644 packages/grid-layouts/package.json create mode 100644 packages/grid-layouts/src/components/Layout.vue create mode 100644 packages/grid-layouts/src/components/LayoutContent.vue create mode 100644 packages/grid-layouts/src/components/LayoutFooter.vue create mode 100644 packages/grid-layouts/src/components/LayoutHeader.vue create mode 100644 packages/grid-layouts/src/components/LayoutLogo.vue create mode 100644 packages/grid-layouts/src/components/LayoutSidebar.vue create mode 100644 packages/grid-layouts/src/components/LayoutTab.vue create mode 100644 packages/grid-layouts/src/index.vue rename packages/{layouts => grid-layouts}/src/store/index.ts (73%) rename packages/{layouts => grid-layouts}/src/store/modules/headerSetting.ts (100%) create mode 100644 packages/grid-layouts/src/store/modules/layoutComposables.ts rename packages/{layouts => grid-layouts}/src/store/modules/menuSetting.ts (70%) rename packages/{layouts => grid-layouts}/src/store/modules/multiTabsSetting.ts (100%) rename packages/{layouts => grid-layouts}/src/store/modules/sporadicSetting.ts (100%) rename packages/{layouts => grid-layouts}/src/store/modules/transitionSetting.ts (100%) create mode 100644 packages/styles/src/grid-layout.scss diff --git a/apps/admin/package.json b/apps/admin/package.json index 1a9c545e..1444ed88 100644 --- a/apps/admin/package.json +++ b/apps/admin/package.json @@ -29,6 +29,7 @@ "@vben/constants": "workspace:*", "@vben/demo": "workspace:*", "@vben/directives": "workspace:*", + "@vben/grid-layouts": "workspace:*", "@vben/hooks": "workspace:*", "@vben/layouts": "workspace:*", "@vben/locale": "workspace:*", diff --git a/apps/admin/src/layout/index.vue b/apps/admin/src/layout/index.vue index 0f776d75..d460f8f5 100644 --- a/apps/admin/src/layout/index.vue +++ b/apps/admin/src/layout/index.vue @@ -1,5 +1,7 @@ diff --git a/packages/grid-layouts/index.ts b/packages/grid-layouts/index.ts new file mode 100644 index 00000000..7d6fc701 --- /dev/null +++ b/packages/grid-layouts/index.ts @@ -0,0 +1,3 @@ +export { default as Layout } from './src/index.vue' + +export * from './src/store' diff --git a/packages/grid-layouts/package.json b/packages/grid-layouts/package.json new file mode 100644 index 00000000..81623748 --- /dev/null +++ b/packages/grid-layouts/package.json @@ -0,0 +1,22 @@ +{ + "name": "@vben/grid-layouts", + "version": "3.0.0-bata.1", + "main": "index.ts", + "module": "index.ts", + "license": "MIT", + "scripts": { + "clean": "pnpm rimraf node_modules && pnpm rimraf dist && pnpm rimraf .turbo" + }, + "dependencies": { + "@vben/constants": "workspace:*", + "@vben/directives": "workspace:*", + "@vben/hooks": "workspace:*", + "@vben/locale": "workspace:*", + "@vben/pinia": "workspace:*", + "@vben/types": "workspace:*", + "@vben/utils": "workspace:*", + "@vben/vbencomponents": "workspace:*", + "vue": "3.2.45", + "vue-router": "^4.1.6" + } +} diff --git a/packages/grid-layouts/src/components/Layout.vue b/packages/grid-layouts/src/components/Layout.vue new file mode 100644 index 00000000..981effcd --- /dev/null +++ b/packages/grid-layouts/src/components/Layout.vue @@ -0,0 +1,19 @@ + + + + + + + + + + diff --git a/packages/grid-layouts/src/components/LayoutContent.vue b/packages/grid-layouts/src/components/LayoutContent.vue new file mode 100644 index 00000000..b932153c --- /dev/null +++ b/packages/grid-layouts/src/components/LayoutContent.vue @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/packages/grid-layouts/src/components/LayoutFooter.vue b/packages/grid-layouts/src/components/LayoutFooter.vue new file mode 100644 index 00000000..d8df79b1 --- /dev/null +++ b/packages/grid-layouts/src/components/LayoutFooter.vue @@ -0,0 +1,6 @@ + + + + + diff --git a/packages/grid-layouts/src/components/LayoutHeader.vue b/packages/grid-layouts/src/components/LayoutHeader.vue new file mode 100644 index 00000000..9715ed64 --- /dev/null +++ b/packages/grid-layouts/src/components/LayoutHeader.vue @@ -0,0 +1,6 @@ + + + + + diff --git a/packages/grid-layouts/src/components/LayoutLogo.vue b/packages/grid-layouts/src/components/LayoutLogo.vue new file mode 100644 index 00000000..8a7cf934 --- /dev/null +++ b/packages/grid-layouts/src/components/LayoutLogo.vue @@ -0,0 +1,5 @@ + + + + diff --git a/packages/grid-layouts/src/components/LayoutSidebar.vue b/packages/grid-layouts/src/components/LayoutSidebar.vue new file mode 100644 index 00000000..9e06e578 --- /dev/null +++ b/packages/grid-layouts/src/components/LayoutSidebar.vue @@ -0,0 +1,6 @@ + + + + + diff --git a/packages/grid-layouts/src/components/LayoutTab.vue b/packages/grid-layouts/src/components/LayoutTab.vue new file mode 100644 index 00000000..12ab180c --- /dev/null +++ b/packages/grid-layouts/src/components/LayoutTab.vue @@ -0,0 +1,6 @@ + + + + + diff --git a/packages/grid-layouts/src/index.vue b/packages/grid-layouts/src/index.vue new file mode 100644 index 00000000..2c0eb78b --- /dev/null +++ b/packages/grid-layouts/src/index.vue @@ -0,0 +1,7 @@ + + + + + diff --git a/packages/layouts/src/store/index.ts b/packages/grid-layouts/src/store/index.ts similarity index 73% rename from packages/layouts/src/store/index.ts rename to packages/grid-layouts/src/store/index.ts index cc729d66..c1e8ede9 100644 --- a/packages/layouts/src/store/index.ts +++ b/packages/grid-layouts/src/store/index.ts @@ -3,3 +3,9 @@ export { useHeaderSettingStore } from './modules/headerSetting' export { useMenuSettingStore } from './modules/menuSetting' export { useTransitionSettingStore } from './modules/transitionSetting' export { useMultiTabsSettingStore } from './modules/multiTabsSetting' +export { + useLayoutHeader, + useLayoutFooter, + useLayoutSidebar, + useLayoutTab, +} from './modules/layoutComposables' diff --git a/packages/layouts/src/store/modules/headerSetting.ts b/packages/grid-layouts/src/store/modules/headerSetting.ts similarity index 100% rename from packages/layouts/src/store/modules/headerSetting.ts rename to packages/grid-layouts/src/store/modules/headerSetting.ts diff --git a/packages/grid-layouts/src/store/modules/layoutComposables.ts b/packages/grid-layouts/src/store/modules/layoutComposables.ts new file mode 100644 index 00000000..c629f3b7 --- /dev/null +++ b/packages/grid-layouts/src/store/modules/layoutComposables.ts @@ -0,0 +1,52 @@ +import { defineStore } from '@vben/pinia' +import { useElementSize } from '@vben/utils' +import { ref } from 'vue' + +export const useLayoutHeader = defineStore('LAYOUT_HEADER', () => { + const headerRef = ref() + + const { height: headerHeight, width: headerWidth } = useElementSize(headerRef) + + return { + headerRef, + headerHeight, + headerWidth, + } +}) + +export const useLayoutSidebar = defineStore('LAYOUT_SIDEBAR', () => { + const sidebarRef = ref() + + const { height: sidebarHeight, width: sidebarWidth } = + useElementSize(sidebarRef) + + return { + sidebarRef, + sidebarHeight, + sidebarWidth, + } +}) + +export const useLayoutTab = defineStore('LAYOUT_TAB', () => { + const tabRef = ref() + + const { height: tabHeight, width: tabWidth } = useElementSize(tabRef) + + return { + tabRef, + tabHeight, + tabWidth, + } +}) + +export const useLayoutFooter = defineStore('LAYOUT_FOOTER', () => { + const footerRef = ref() + + const { height: footerHeight, width: footerWidth } = useElementSize(footerRef) + + return { + footerRef, + footerHeight, + footerWidth, + } +}) diff --git a/packages/layouts/src/store/modules/menuSetting.ts b/packages/grid-layouts/src/store/modules/menuSetting.ts similarity index 70% rename from packages/layouts/src/store/modules/menuSetting.ts rename to packages/grid-layouts/src/store/modules/menuSetting.ts index 4698a09c..bd6bdc80 100644 --- a/packages/layouts/src/store/modules/menuSetting.ts +++ b/packages/grid-layouts/src/store/modules/menuSetting.ts @@ -52,14 +52,40 @@ export const useMenuSettingStore = defineStore({ mixSideFixed: false, }), getters: { - isSidebarType: (state) => { - return state.type === MenuTypeEnum.SIDEBAR - }, - isTopMenu: (state) => { - return state.type === MenuTypeEnum.SIDEBAR - }, - menuShowLogo: (state) => { - return state.type === MenuTypeEnum.SIDEBAR + isSidebarType: (state) => state.type === MenuTypeEnum.SIDEBAR, + isTopMenu: (state) => state.type === MenuTypeEnum.SIDEBAR, + isMixSidebar: (state) => state.type === MenuTypeEnum.MIX_SIDEBAR, + isMixMode: (state) => + state.mode === MenuModeEnum.INLINE && state.type === MenuTypeEnum.MIX, + showMenuLogo: (state) => state.type === MenuTypeEnum.SIDEBAR, + showTopMenu: (state) => { + return state.mode === MenuModeEnum.HORIZONTAL || state.split + }, + showHeaderTrigger: (state) => { + if (state.type === MenuTypeEnum.TOP_MENU || !state.show || state.hidden) + return false + return state.trigger === TriggerEnum.HEADER + }, + isHorizontal: (state) => state.mode === MenuModeEnum.HORIZONTAL, + // TODO + ShowSidebar: (state) => { + const fullContent = false + return ( + state.split || + (state.show && state.mode !== MenuModeEnum.HORIZONTAL && !fullContent) + ) + }, + // TODO + getRealWidth: (state) => { + return 0 + }, + // TODO + getMiniWidthNumber: (state) => { + return 0 + }, + // TODO + getCalcContentWidth: (state) => { + return 0 }, }, actions: { @@ -117,5 +143,8 @@ export const useMenuSettingStore = defineStore({ setMixSideFixed(value: boolean) { this.mixSideFixed = value }, + toggleCollapsed() { + this.setCollapsed(!this.collapsed) + }, }, }) diff --git a/packages/layouts/src/store/modules/multiTabsSetting.ts b/packages/grid-layouts/src/store/modules/multiTabsSetting.ts similarity index 100% rename from packages/layouts/src/store/modules/multiTabsSetting.ts rename to packages/grid-layouts/src/store/modules/multiTabsSetting.ts diff --git a/packages/layouts/src/store/modules/sporadicSetting.ts b/packages/grid-layouts/src/store/modules/sporadicSetting.ts similarity index 100% rename from packages/layouts/src/store/modules/sporadicSetting.ts rename to packages/grid-layouts/src/store/modules/sporadicSetting.ts diff --git a/packages/layouts/src/store/modules/transitionSetting.ts b/packages/grid-layouts/src/store/modules/transitionSetting.ts similarity index 100% rename from packages/layouts/src/store/modules/transitionSetting.ts rename to packages/grid-layouts/src/store/modules/transitionSetting.ts diff --git a/packages/layouts/index.ts b/packages/layouts/index.ts index d206c837..49c05a5d 100644 --- a/packages/layouts/index.ts +++ b/packages/layouts/index.ts @@ -1,4 +1,3 @@ export { default as Layout } from './src/index.vue' export { initLayout } from './bridge' export { default as DarkModeToggle } from './src/components/setting/components/DarkModeToggle.vue' -export * from './src/store/index' diff --git a/packages/layouts/src/components/main.vue b/packages/layouts/src/components/main.vue index 4b06e58d..17fca523 100644 --- a/packages/layouts/src/components/main.vue +++ b/packages/layouts/src/components/main.vue @@ -1,17 +1,10 @@ - - change {{ bgColor }} - diff --git a/packages/styles/src/grid-layout.scss b/packages/styles/src/grid-layout.scss new file mode 100644 index 00000000..737c0ccf --- /dev/null +++ b/packages/styles/src/grid-layout.scss @@ -0,0 +1,32 @@ +.vben-grid-layout-container{ + display: grid; + grid-template-columns: 50vw 50vw; + grid-template-rows: auto; + grid-template-areas: + "vben-sidebar vben-header" + "vben-sidebar vben-content"; +} + +.vben-grid-layout-header{ + grid-area: vben-header; + background: #666666; +} + +.vben-grid-layout-sidebar{ + grid-area: vben-sidebar; + background: #18a058; +} + +.vben-grid-layout-tab{ + grid-area: vben-tab; + background: #0960bd; +} + +.vben-grid-layout-content{ + grid-area: vben-content; + background: #ed6f6f; +} + +.vben-grid-layout-footer{ + grid-area: vben-footer; +} diff --git a/packages/styles/src/index.ts b/packages/styles/src/index.ts index f705f866..ef796296 100644 --- a/packages/styles/src/index.ts +++ b/packages/styles/src/index.ts @@ -1,4 +1,5 @@ import './common.css' import './entry.css' import './variables.css' +import './grid-layout.scss' import 'uno.css' From b48f6d32af134bd6a2a556a0a2f2570fcd121a04 Mon Sep 17 00:00:00 2001 From: h_mo <596417202@qq.com> Date: Thu, 2 Feb 2023 23:19:23 +0800 Subject: [PATCH 06/22] =?UTF-8?q?wip:=20grid-layout=20=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grid-layouts/src/components/Layout.vue | 31 +++---- .../src/components/LayoutContent.vue | 5 +- .../src/components/LayoutFooter.vue | 5 +- .../src/components/LayoutHeader.vue | 5 +- .../src/components/LayoutLogo.vue | 6 +- .../src/components/LayoutSidebar.vue | 5 +- .../grid-layouts/src/components/LayoutTab.vue | 5 +- packages/grid-layouts/src/components/Main.vue | 31 +++++++ packages/grid-layouts/src/index.vue | 2 +- packages/styles/src/grid-layout.scss | 85 +++++++++++++------ packages/styles/src/variables.css | 18 ++++ 11 files changed, 139 insertions(+), 59 deletions(-) create mode 100644 packages/grid-layouts/src/components/Main.vue diff --git a/packages/grid-layouts/src/components/Layout.vue b/packages/grid-layouts/src/components/Layout.vue index 981effcd..006add73 100644 --- a/packages/grid-layouts/src/components/Layout.vue +++ b/packages/grid-layouts/src/components/Layout.vue @@ -1,19 +1,20 @@ - - - - - - + + + + + + - + diff --git a/packages/grid-layouts/src/components/LayoutContent.vue b/packages/grid-layouts/src/components/LayoutContent.vue index b932153c..b36e7380 100644 --- a/packages/grid-layouts/src/components/LayoutContent.vue +++ b/packages/grid-layouts/src/components/LayoutContent.vue @@ -1,9 +1,10 @@ - + diff --git a/packages/grid-layouts/src/components/LayoutFooter.vue b/packages/grid-layouts/src/components/LayoutFooter.vue index d8df79b1..0603d6ba 100644 --- a/packages/grid-layouts/src/components/LayoutFooter.vue +++ b/packages/grid-layouts/src/components/LayoutFooter.vue @@ -1,6 +1,5 @@ - + - + diff --git a/packages/grid-layouts/src/components/LayoutHeader.vue b/packages/grid-layouts/src/components/LayoutHeader.vue index 9715ed64..3c4cde09 100644 --- a/packages/grid-layouts/src/components/LayoutHeader.vue +++ b/packages/grid-layouts/src/components/LayoutHeader.vue @@ -1,6 +1,5 @@ - + - + header diff --git a/packages/grid-layouts/src/components/LayoutLogo.vue b/packages/grid-layouts/src/components/LayoutLogo.vue index 8a7cf934..4e196201 100644 --- a/packages/grid-layouts/src/components/LayoutLogo.vue +++ b/packages/grid-layouts/src/components/LayoutLogo.vue @@ -1,5 +1,3 @@ - - - + + diff --git a/packages/grid-layouts/src/components/LayoutSidebar.vue b/packages/grid-layouts/src/components/LayoutSidebar.vue index 9e06e578..ebfd1503 100644 --- a/packages/grid-layouts/src/components/LayoutSidebar.vue +++ b/packages/grid-layouts/src/components/LayoutSidebar.vue @@ -1,6 +1,5 @@ - + - + sidebar diff --git a/packages/grid-layouts/src/components/LayoutTab.vue b/packages/grid-layouts/src/components/LayoutTab.vue index 12ab180c..d56609ca 100644 --- a/packages/grid-layouts/src/components/LayoutTab.vue +++ b/packages/grid-layouts/src/components/LayoutTab.vue @@ -1,6 +1,5 @@ - + - + tab diff --git a/packages/grid-layouts/src/components/Main.vue b/packages/grid-layouts/src/components/Main.vue new file mode 100644 index 00000000..1faea74b --- /dev/null +++ b/packages/grid-layouts/src/components/Main.vue @@ -0,0 +1,31 @@ + + + + {{ type }} + + + + + diff --git a/packages/grid-layouts/src/index.vue b/packages/grid-layouts/src/index.vue index 2c0eb78b..2db24aa0 100644 --- a/packages/grid-layouts/src/index.vue +++ b/packages/grid-layouts/src/index.vue @@ -2,6 +2,6 @@ import Layout from './components/Layout.vue' - + diff --git a/packages/styles/src/grid-layout.scss b/packages/styles/src/grid-layout.scss index 737c0ccf..14e76125 100644 --- a/packages/styles/src/grid-layout.scss +++ b/packages/styles/src/grid-layout.scss @@ -1,32 +1,67 @@ -.vben-grid-layout-container{ +.vben-grid-layout-container { display: grid; - grid-template-columns: 50vw 50vw; - grid-template-rows: auto; - grid-template-areas: - "vben-sidebar vben-header" - "vben-sidebar vben-content"; -} + grid-template-columns: var(--aside-width) 1fr; + grid-template-rows: var(--header-height) var(--tab-height) 1fr; -.vben-grid-layout-header{ - grid-area: vben-header; - background: #666666; -} + &.layout-sidebar, &.layout-mix-sidebar { + grid-template-areas: + 'vben-sidebar vben-header' + 'vben-sidebar vben-tab' + 'vben-sidebar vben-content'; + } -.vben-grid-layout-sidebar{ - grid-area: vben-sidebar; - background: #18a058; -} + &.layout-mix-sidebar { + --aside-width: 80px; + } -.vben-grid-layout-tab{ - grid-area: vben-tab; - background: #0960bd; -} + &.layout-mix, &.layout-top-menu { + grid-template-areas: + 'vben-header vben-header' + 'vben-sidebar vben-tab' + 'vben-sidebar vben-content'; + } -.vben-grid-layout-content{ - grid-area: vben-content; - background: #ed6f6f; -} + &.layout-top-menu { + --aside-width: 0; + } + + .vben-grid-layout-header, .vben-grid-layout-sidebar, + .vben-grid-layout-tab, .vben-grid-layout-content, + .vben-grid-layout-main, .vben-grid-layout-footer{ + transition: grid-template-rows 3s, grid-template-columns 3s, grid-template-areas 3s; + //-webkit-transition: all 30s; + } + + .vben-grid-layout-header { + grid-area: vben-header; + background: #666666; + } + + .vben-grid-layout-sidebar { + grid-area: vben-sidebar; + background: #18a058; + } + + .vben-grid-layout-tab { + grid-area: vben-tab; + background: #0960bd; + } + + .vben-grid-layout-content { + grid-area: vben-content; + overflow: auto; + display: grid; + grid-template-columns: 100%; + grid-template-rows: 1fr minmax(0, var(--footer-height)); + + background: #ed6f6f; + } + + .vben-grid-layout-main { + background-color: aqua; + } -.vben-grid-layout-footer{ - grid-area: vben-footer; + .vben-grid-layout-footer { + background-color: blueviolet; + } } diff --git a/packages/styles/src/variables.css b/packages/styles/src/variables.css index aebc45ec..0e98ccc0 100644 --- a/packages/styles/src/variables.css +++ b/packages/styles/src/variables.css @@ -7,9 +7,27 @@ /* component */ --component-background-color: #fff; + /* header */ + --header-height: 48px; + --header-width: calc(100% - var(--aside-width)); + + /* tab */ + --tab-height: 36px; + --tab-width: calc(100% - var(--aside-width)); + /* aside */ + --aside-height: calc(100% - var(--header-height)); + --aside-width: 210px; --aside-background-color: #001628; --aside-submenu-background-color: #0c2135; + + /* main */ + --main-height: calc(100% - var(--footer-height)); + --main-width: 100%; + + /* footer */ + --footer-height: 60px; + --footer-width: 100%; } @media (prefers-color-scheme: dark) { From 3241d059a9c8d735c229f9541326fcb9acbd5bd4 Mon Sep 17 00:00:00 2001 From: h_mo <596417202@qq.com> Date: Fri, 3 Feb 2023 17:59:41 +0800 Subject: [PATCH 07/22] =?UTF-8?q?wip:=20grid-layout=20=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E8=BF=87=E6=B8=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/constants/src/menuEnum.ts | 2 + .../grid-layouts/src/components/Layout.vue | 38 ++++++++--- .../src/components/LayoutContent.vue | 11 --- .../src/components/LayoutSidebar.vue | 5 -- packages/grid-layouts/src/components/Main.vue | 13 +++- .../components/composables/LayoutContent.vue | 14 ++++ .../{ => composables}/LayoutFooter.vue | 0 .../{ => composables}/LayoutHeader.vue | 0 .../{ => composables}/LayoutLogo.vue | 0 .../components/composables/LayoutSidebar.vue | 13 ++++ .../{ => composables}/LayoutTab.vue | 0 .../src/components/sidebar/ToggleButton.vue | 67 +++++++++++++++++++ .../src/components/trigger/HeaderTrgger.vue | 5 ++ .../components/trigger/SiderCenterTrgger.vue | 5 ++ .../components/trigger/SiderFooterTrgger.vue | 5 ++ .../src/components/trigger/inedx.vue | 5 ++ .../src/hooks/useComprehensive.ts | 22 ++++++ packages/grid-layouts/src/store/index.ts | 1 + .../src/store/modules/layoutComposables.ts | 13 ++++ .../src/store/modules/menuSetting.ts | 19 ++++-- packages/styles/src/grid-layout.scss | 37 ++++++---- packages/styles/src/variables.css | 21 ++++++ packages/types/src/setting.ts | 4 ++ .../src/iconify/src/Iconify.vue | 2 +- 24 files changed, 256 insertions(+), 46 deletions(-) delete mode 100644 packages/grid-layouts/src/components/LayoutContent.vue delete mode 100644 packages/grid-layouts/src/components/LayoutSidebar.vue create mode 100644 packages/grid-layouts/src/components/composables/LayoutContent.vue rename packages/grid-layouts/src/components/{ => composables}/LayoutFooter.vue (100%) rename packages/grid-layouts/src/components/{ => composables}/LayoutHeader.vue (100%) rename packages/grid-layouts/src/components/{ => composables}/LayoutLogo.vue (100%) create mode 100644 packages/grid-layouts/src/components/composables/LayoutSidebar.vue rename packages/grid-layouts/src/components/{ => composables}/LayoutTab.vue (100%) create mode 100644 packages/grid-layouts/src/components/sidebar/ToggleButton.vue create mode 100644 packages/grid-layouts/src/components/trigger/HeaderTrgger.vue create mode 100644 packages/grid-layouts/src/components/trigger/SiderCenterTrgger.vue create mode 100644 packages/grid-layouts/src/components/trigger/SiderFooterTrgger.vue create mode 100644 packages/grid-layouts/src/components/trigger/inedx.vue create mode 100644 packages/grid-layouts/src/hooks/useComprehensive.ts diff --git a/packages/constants/src/menuEnum.ts b/packages/constants/src/menuEnum.ts index 5903c3e1..98289e33 100644 --- a/packages/constants/src/menuEnum.ts +++ b/packages/constants/src/menuEnum.ts @@ -18,6 +18,8 @@ export enum TriggerEnum { NONE = 'NONE', // 菜单底部 FOOTER = 'FOOTER', + // 菜单中间 + CENTER = 'CENTER', // 头部 HEADER = 'HEADER', } diff --git a/packages/grid-layouts/src/components/Layout.vue b/packages/grid-layouts/src/components/Layout.vue index 006add73..bacc8e93 100644 --- a/packages/grid-layouts/src/components/Layout.vue +++ b/packages/grid-layouts/src/components/Layout.vue @@ -1,20 +1,36 @@ - - - - - + + + + + diff --git a/packages/grid-layouts/src/components/LayoutContent.vue b/packages/grid-layouts/src/components/LayoutContent.vue deleted file mode 100644 index b36e7380..00000000 --- a/packages/grid-layouts/src/components/LayoutContent.vue +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - diff --git a/packages/grid-layouts/src/components/LayoutSidebar.vue b/packages/grid-layouts/src/components/LayoutSidebar.vue deleted file mode 100644 index ebfd1503..00000000 --- a/packages/grid-layouts/src/components/LayoutSidebar.vue +++ /dev/null @@ -1,5 +0,0 @@ - - - sidebar - - diff --git a/packages/grid-layouts/src/components/Main.vue b/packages/grid-layouts/src/components/Main.vue index 1faea74b..be29974c 100644 --- a/packages/grid-layouts/src/components/Main.vue +++ b/packages/grid-layouts/src/components/Main.vue @@ -1,7 +1,11 @@ @@ -25,6 +34,8 @@ const handlerChange = (value) => { :value="type" @update:value="handlerChange" /> + layoutStyles: {{ getLayoutStyles }} + headerWidth: {{ headerWidth }}, headerHeight: {{ headerHeight }} diff --git a/packages/grid-layouts/src/components/composables/LayoutContent.vue b/packages/grid-layouts/src/components/composables/LayoutContent.vue new file mode 100644 index 00000000..2d884d27 --- /dev/null +++ b/packages/grid-layouts/src/components/composables/LayoutContent.vue @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/packages/grid-layouts/src/components/LayoutFooter.vue b/packages/grid-layouts/src/components/composables/LayoutFooter.vue similarity index 100% rename from packages/grid-layouts/src/components/LayoutFooter.vue rename to packages/grid-layouts/src/components/composables/LayoutFooter.vue diff --git a/packages/grid-layouts/src/components/LayoutHeader.vue b/packages/grid-layouts/src/components/composables/LayoutHeader.vue similarity index 100% rename from packages/grid-layouts/src/components/LayoutHeader.vue rename to packages/grid-layouts/src/components/composables/LayoutHeader.vue diff --git a/packages/grid-layouts/src/components/LayoutLogo.vue b/packages/grid-layouts/src/components/composables/LayoutLogo.vue similarity index 100% rename from packages/grid-layouts/src/components/LayoutLogo.vue rename to packages/grid-layouts/src/components/composables/LayoutLogo.vue diff --git a/packages/grid-layouts/src/components/composables/LayoutSidebar.vue b/packages/grid-layouts/src/components/composables/LayoutSidebar.vue new file mode 100644 index 00000000..a5e88cf8 --- /dev/null +++ b/packages/grid-layouts/src/components/composables/LayoutSidebar.vue @@ -0,0 +1,13 @@ + + + + + sidebar + + + + + diff --git a/packages/grid-layouts/src/components/LayoutTab.vue b/packages/grid-layouts/src/components/composables/LayoutTab.vue similarity index 100% rename from packages/grid-layouts/src/components/LayoutTab.vue rename to packages/grid-layouts/src/components/composables/LayoutTab.vue diff --git a/packages/grid-layouts/src/components/sidebar/ToggleButton.vue b/packages/grid-layouts/src/components/sidebar/ToggleButton.vue new file mode 100644 index 00000000..a926c04b --- /dev/null +++ b/packages/grid-layouts/src/components/sidebar/ToggleButton.vue @@ -0,0 +1,67 @@ + + + + + + + + diff --git a/packages/grid-layouts/src/components/trigger/HeaderTrgger.vue b/packages/grid-layouts/src/components/trigger/HeaderTrgger.vue new file mode 100644 index 00000000..8a7cf934 --- /dev/null +++ b/packages/grid-layouts/src/components/trigger/HeaderTrgger.vue @@ -0,0 +1,5 @@ + + + + diff --git a/packages/grid-layouts/src/components/trigger/SiderCenterTrgger.vue b/packages/grid-layouts/src/components/trigger/SiderCenterTrgger.vue new file mode 100644 index 00000000..8a7cf934 --- /dev/null +++ b/packages/grid-layouts/src/components/trigger/SiderCenterTrgger.vue @@ -0,0 +1,5 @@ + + + + diff --git a/packages/grid-layouts/src/components/trigger/SiderFooterTrgger.vue b/packages/grid-layouts/src/components/trigger/SiderFooterTrgger.vue new file mode 100644 index 00000000..8a7cf934 --- /dev/null +++ b/packages/grid-layouts/src/components/trigger/SiderFooterTrgger.vue @@ -0,0 +1,5 @@ + + + + diff --git a/packages/grid-layouts/src/components/trigger/inedx.vue b/packages/grid-layouts/src/components/trigger/inedx.vue new file mode 100644 index 00000000..8a7cf934 --- /dev/null +++ b/packages/grid-layouts/src/components/trigger/inedx.vue @@ -0,0 +1,5 @@ + + + + diff --git a/packages/grid-layouts/src/hooks/useComprehensive.ts b/packages/grid-layouts/src/hooks/useComprehensive.ts new file mode 100644 index 00000000..1d9092fb --- /dev/null +++ b/packages/grid-layouts/src/hooks/useComprehensive.ts @@ -0,0 +1,22 @@ +import { useMenuSettingStore } from '../store/modules/menuSetting' +import { computed } from 'vue' + +export const useComprehensive = () => { + const menuSettingStore = useMenuSettingStore() + const getLayoutStyles = computed(() => { + let asideWidth = menuSettingStore.width + + if (menuSettingStore.isMixSidebar) + asideWidth = menuSettingStore.mixSidebarWidth + if (menuSettingStore.collapsed) asideWidth = menuSettingStore.collapsedWidth + if (menuSettingStore.isTopMenu) asideWidth = 0 + + return { + '--aside-width': asideWidth + 'px', + '--aside-visible': menuSettingStore.visible ? 'visible' : 'hidden', + } + }) + return { + getLayoutStyles, + } +} diff --git a/packages/grid-layouts/src/store/index.ts b/packages/grid-layouts/src/store/index.ts index c1e8ede9..efd93591 100644 --- a/packages/grid-layouts/src/store/index.ts +++ b/packages/grid-layouts/src/store/index.ts @@ -8,4 +8,5 @@ export { useLayoutFooter, useLayoutSidebar, useLayoutTab, + useLayoutContent, } from './modules/layoutComposables' diff --git a/packages/grid-layouts/src/store/modules/layoutComposables.ts b/packages/grid-layouts/src/store/modules/layoutComposables.ts index c629f3b7..7b4daed7 100644 --- a/packages/grid-layouts/src/store/modules/layoutComposables.ts +++ b/packages/grid-layouts/src/store/modules/layoutComposables.ts @@ -39,6 +39,19 @@ export const useLayoutTab = defineStore('LAYOUT_TAB', () => { } }) +export const useLayoutContent = defineStore('LAYOUT_FOOTER', () => { + const contentRef = ref() + + const { height: contentHeight, width: contentWidth } = + useElementSize(contentRef) + + return { + contentRef, + contentHeight, + contentWidth, + } +}) + export const useLayoutFooter = defineStore('LAYOUT_FOOTER', () => { const footerRef = ref() diff --git a/packages/grid-layouts/src/store/modules/menuSetting.ts b/packages/grid-layouts/src/store/modules/menuSetting.ts index bd6bdc80..888458c8 100644 --- a/packages/grid-layouts/src/store/modules/menuSetting.ts +++ b/packages/grid-layouts/src/store/modules/menuSetting.ts @@ -1,12 +1,12 @@ import { defineStore } from '@vben/pinia' import { MenuSetting } from '@vben/types' import { - ThemeEnum, - SIDE_BAR_BG_COLOR_LIST, MenuModeEnum, MenuTypeEnum, - TriggerEnum, MixSidebarTriggerEnum, + SIDE_BAR_BG_COLOR_LIST, + ThemeEnum, + TriggerEnum, } from '@vben/constants' export const useMenuSettingStore = defineStore({ @@ -50,10 +50,15 @@ export const useMenuSettingStore = defineStore({ mixSideTrigger: MixSidebarTriggerEnum.CLICK, // Fixed expanded menu mixSideFixed: false, + // Whether to visible dom + visible: true, + width: 210, + mixSidebarWidth: 80, + collapsedWidth: 48, }), getters: { - isSidebarType: (state) => state.type === MenuTypeEnum.SIDEBAR, - isTopMenu: (state) => state.type === MenuTypeEnum.SIDEBAR, + isSidebar: (state) => state.type === MenuTypeEnum.SIDEBAR, + isTopMenu: (state) => state.type === MenuTypeEnum.TOP_MENU, isMixSidebar: (state) => state.type === MenuTypeEnum.MIX_SIDEBAR, isMixMode: (state) => state.mode === MenuModeEnum.INLINE && state.type === MenuTypeEnum.MIX, @@ -117,6 +122,7 @@ export const useMenuSettingStore = defineStore({ this.mode = value }, setType(value: MenuTypeEnum) { + this.setVisible(value !== MenuTypeEnum.TOP_MENU) this.type = value }, setTheme(value: ThemeEnum) { @@ -143,6 +149,9 @@ export const useMenuSettingStore = defineStore({ setMixSideFixed(value: boolean) { this.mixSideFixed = value }, + setVisible(value: boolean) { + this.visible = value + }, toggleCollapsed() { this.setCollapsed(!this.collapsed) }, diff --git a/packages/styles/src/grid-layout.scss b/packages/styles/src/grid-layout.scss index 14e76125..e2ad5450 100644 --- a/packages/styles/src/grid-layout.scss +++ b/packages/styles/src/grid-layout.scss @@ -1,9 +1,16 @@ .vben-grid-layout-container { display: grid; - grid-template-columns: var(--aside-width) 1fr; + grid-template-columns: minmax(0, var(--aside-width)) minmax(640px, 1fr); grid-template-rows: var(--header-height) var(--tab-height) 1fr; - - &.layout-sidebar, &.layout-mix-sidebar { + grid-gap: 3px; + transition: grid-template-columns .3s, grid-template-rows .3s; + transition-timing-function: var(--transition-bezier); + &, + * { + box-sizing: border-box; + } + &.layout-sidebar, + &.layout-mix-sidebar { grid-template-areas: 'vben-sidebar vben-header' 'vben-sidebar vben-tab' @@ -14,7 +21,8 @@ --aside-width: 80px; } - &.layout-mix, &.layout-top-menu { + &.layout-mix, + &.layout-top-menu { grid-template-areas: 'vben-header vben-header' 'vben-sidebar vben-tab' @@ -25,13 +33,6 @@ --aside-width: 0; } - .vben-grid-layout-header, .vben-grid-layout-sidebar, - .vben-grid-layout-tab, .vben-grid-layout-content, - .vben-grid-layout-main, .vben-grid-layout-footer{ - transition: grid-template-rows 3s, grid-template-columns 3s, grid-template-areas 3s; - //-webkit-transition: all 30s; - } - .vben-grid-layout-header { grid-area: vben-header; background: #666666; @@ -39,7 +40,19 @@ .vben-grid-layout-sidebar { grid-area: vben-sidebar; - background: #18a058; + position: relative; + visibility: var(--aside-visible); + + .vben-grid-layout-sidebar__border { + content: ''; + position: absolute; + top: 0; + bottom: 0; + right: 0; + width: 1px; + background-color: var(--layout-border-color); + transition: background-color 0.3s var(--transition-bezier); + } } .vben-grid-layout-tab { diff --git a/packages/styles/src/variables.css b/packages/styles/src/variables.css index 0e98ccc0..0adfc84c 100644 --- a/packages/styles/src/variables.css +++ b/packages/styles/src/variables.css @@ -7,6 +7,18 @@ /* component */ --component-background-color: #fff; + /* transition */ + --transition-bezier:cubic-bezier(0.4, 0, 0.2, 1); + --transition-all: all 0.3s var(--transition-bezier); + + /* layout start */ + + --layout-border-color: rgb(239, 239, 245); + --layout-color: #fff; + --layout-text-color: rgb(51, 54, 57); + --layout-border-color: rgb(239, 239, 245); + --layout-toggle-button-icon-color: rgb(51, 54, 57); + /* header */ --header-height: 48px; --header-width: calc(100% - var(--aside-width)); @@ -18,9 +30,16 @@ /* aside */ --aside-height: calc(100% - var(--header-height)); --aside-width: 210px; + --aside-visible: visible; --aside-background-color: #001628; --aside-submenu-background-color: #0c2135; + + --layout-toggle-button-color: #FFF; + --layout-toggle-button-border: 1px solid rgb(239, 239, 245); + --layout-toggle-bar-color: rgba(191, 191, 191, 1); + --layout-toggle-bar-color-hover: rgba(153, 153, 153, 1); + /* main */ --main-height: calc(100% - var(--footer-height)); --main-width: 100%; @@ -28,6 +47,8 @@ /* footer */ --footer-height: 60px; --footer-width: 100%; + + /* layout end */ } @media (prefers-color-scheme: dark) { diff --git a/packages/types/src/setting.ts b/packages/types/src/setting.ts index b85aa002..ea06e055 100644 --- a/packages/types/src/setting.ts +++ b/packages/types/src/setting.ts @@ -33,6 +33,10 @@ export interface MenuSetting { collapsedShowTitle: boolean mixSideTrigger: MixSidebarTriggerEnum mixSideFixed: boolean + visible: boolean + readonly width: number + readonly mixSidebarWidth: number + readonly collapsedWidth: number } export interface MultiTabsSetting { diff --git a/packages/vbenComponents/src/iconify/src/Iconify.vue b/packages/vbenComponents/src/iconify/src/Iconify.vue index e901d333..607a8b9f 100644 --- a/packages/vbenComponents/src/iconify/src/Iconify.vue +++ b/packages/vbenComponents/src/iconify/src/Iconify.vue @@ -87,7 +87,7 @@ onMounted(update) diff --git a/packages/grid-layouts/src/components/composables/LayoutSidebar.vue b/packages/grid-layouts/src/components/composables/LayoutSidebar.vue index a5e88cf8..ac5accaa 100644 --- a/packages/grid-layouts/src/components/composables/LayoutSidebar.vue +++ b/packages/grid-layouts/src/components/composables/LayoutSidebar.vue @@ -1,13 +1,19 @@ - + sidebar - + diff --git a/packages/grid-layouts/src/components/sidebar/ToggleButton.vue b/packages/grid-layouts/src/components/sidebar/ToggleButton.vue deleted file mode 100644 index a926c04b..00000000 --- a/packages/grid-layouts/src/components/sidebar/ToggleButton.vue +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - diff --git a/packages/grid-layouts/src/components/trigger/HeaderTrgger.vue b/packages/grid-layouts/src/components/trigger/HeaderTrgger.vue deleted file mode 100644 index 8a7cf934..00000000 --- a/packages/grid-layouts/src/components/trigger/HeaderTrgger.vue +++ /dev/null @@ -1,5 +0,0 @@ - - - - diff --git a/packages/grid-layouts/src/components/trigger/HeaderTrigger.vue b/packages/grid-layouts/src/components/trigger/HeaderTrigger.vue new file mode 100644 index 00000000..07f02835 --- /dev/null +++ b/packages/grid-layouts/src/components/trigger/HeaderTrigger.vue @@ -0,0 +1,19 @@ + + + + + + diff --git a/packages/grid-layouts/src/components/trigger/SiderCenterTrgger.vue b/packages/grid-layouts/src/components/trigger/SiderCenterTrgger.vue deleted file mode 100644 index 8a7cf934..00000000 --- a/packages/grid-layouts/src/components/trigger/SiderCenterTrgger.vue +++ /dev/null @@ -1,5 +0,0 @@ - - - - diff --git a/packages/grid-layouts/src/components/trigger/SiderCenterTrigger.vue b/packages/grid-layouts/src/components/trigger/SiderCenterTrigger.vue new file mode 100644 index 00000000..1b9201c1 --- /dev/null +++ b/packages/grid-layouts/src/components/trigger/SiderCenterTrigger.vue @@ -0,0 +1,37 @@ + + + + + + + diff --git a/packages/grid-layouts/src/components/trigger/SiderFooterTrgger.vue b/packages/grid-layouts/src/components/trigger/SiderFooterTrgger.vue deleted file mode 100644 index 8a7cf934..00000000 --- a/packages/grid-layouts/src/components/trigger/SiderFooterTrgger.vue +++ /dev/null @@ -1,5 +0,0 @@ - - - - diff --git a/packages/grid-layouts/src/components/trigger/SiderFooterTrigger.vue b/packages/grid-layouts/src/components/trigger/SiderFooterTrigger.vue new file mode 100644 index 00000000..55362d80 --- /dev/null +++ b/packages/grid-layouts/src/components/trigger/SiderFooterTrigger.vue @@ -0,0 +1,20 @@ + + + + + + diff --git a/packages/grid-layouts/src/components/trigger/inedx.vue b/packages/grid-layouts/src/components/trigger/inedx.vue index 8a7cf934..b6d6ac23 100644 --- a/packages/grid-layouts/src/components/trigger/inedx.vue +++ b/packages/grid-layouts/src/components/trigger/inedx.vue @@ -1,5 +1,19 @@ + + + - diff --git a/packages/grid-layouts/src/hooks/useComprehensive.ts b/packages/grid-layouts/src/hooks/useComprehensive.ts index 1d9092fb..eb5e910e 100644 --- a/packages/grid-layouts/src/hooks/useComprehensive.ts +++ b/packages/grid-layouts/src/hooks/useComprehensive.ts @@ -13,7 +13,7 @@ export const useComprehensive = () => { return { '--aside-width': asideWidth + 'px', - '--aside-visible': menuSettingStore.visible ? 'visible' : 'hidden', + '--aside-visible': menuSettingStore.hidden ? 'hidden' : 'visible', } }) return { diff --git a/packages/grid-layouts/src/store/modules/menuSetting.ts b/packages/grid-layouts/src/store/modules/menuSetting.ts index 888458c8..aafd112f 100644 --- a/packages/grid-layouts/src/store/modules/menuSetting.ts +++ b/packages/grid-layouts/src/store/modules/menuSetting.ts @@ -41,7 +41,7 @@ export const useMenuSettingStore = defineStore({ // Top menu layout topMenuAlign: 'center', // Fold trigger position - trigger: TriggerEnum.HEADER, + trigger: TriggerEnum.CENTER, // Turn on accordion mode, only show a menu accordion: true, // Switch page to close menu @@ -50,8 +50,6 @@ export const useMenuSettingStore = defineStore({ mixSideTrigger: MixSidebarTriggerEnum.CLICK, // Fixed expanded menu mixSideFixed: false, - // Whether to visible dom - visible: true, width: 210, mixSidebarWidth: 80, collapsedWidth: 48, @@ -71,6 +69,7 @@ export const useMenuSettingStore = defineStore({ return false return state.trigger === TriggerEnum.HEADER }, + showFooterTrigger: (state) => state.trigger === TriggerEnum.FOOTER, isHorizontal: (state) => state.mode === MenuModeEnum.HORIZONTAL, // TODO ShowSidebar: (state) => { @@ -122,7 +121,7 @@ export const useMenuSettingStore = defineStore({ this.mode = value }, setType(value: MenuTypeEnum) { - this.setVisible(value !== MenuTypeEnum.TOP_MENU) + this.setHidden(value === MenuTypeEnum.TOP_MENU) this.type = value }, setTheme(value: ThemeEnum) { @@ -149,9 +148,6 @@ export const useMenuSettingStore = defineStore({ setMixSideFixed(value: boolean) { this.mixSideFixed = value }, - setVisible(value: boolean) { - this.visible = value - }, toggleCollapsed() { this.setCollapsed(!this.collapsed) }, diff --git a/packages/styles/src/common.css b/packages/styles/src/common.css index fca86706..62ab6c4f 100644 --- a/packages/styles/src/common.css +++ b/packages/styles/src/common.css @@ -10,6 +10,9 @@ body { overflow: visible !important; overflow-x: hidden !important; } +*{ + box-sizing: border-box; +} a:focus, a:active, diff --git a/packages/styles/src/grid-layout.scss b/packages/styles/src/grid-layout.scss index e2ad5450..1315693d 100644 --- a/packages/styles/src/grid-layout.scss +++ b/packages/styles/src/grid-layout.scss @@ -5,10 +5,7 @@ grid-gap: 3px; transition: grid-template-columns .3s, grid-template-rows .3s; transition-timing-function: var(--transition-bezier); - &, - * { - box-sizing: border-box; - } + &.layout-sidebar, &.layout-mix-sidebar { grid-template-areas: diff --git a/packages/styles/src/variables.css b/packages/styles/src/variables.css index 0adfc84c..573cab1e 100644 --- a/packages/styles/src/variables.css +++ b/packages/styles/src/variables.css @@ -35,10 +35,10 @@ --aside-submenu-background-color: #0c2135; - --layout-toggle-button-color: #FFF; - --layout-toggle-button-border: 1px solid rgb(239, 239, 245); - --layout-toggle-bar-color: rgba(191, 191, 191, 1); - --layout-toggle-bar-color-hover: rgba(153, 153, 153, 1); + --trigger-color: #FFF; + --trigger-border: 1px solid rgb(239, 239, 245); +--trigger-border-color: rgb(239, 239, 245); + --trigger-icon-color: rgb(51, 54, 57); /* main */ --main-height: calc(100% - var(--footer-height)); diff --git a/packages/types/src/setting.ts b/packages/types/src/setting.ts index ea06e055..cf4717da 100644 --- a/packages/types/src/setting.ts +++ b/packages/types/src/setting.ts @@ -33,7 +33,6 @@ export interface MenuSetting { collapsedShowTitle: boolean mixSideTrigger: MixSidebarTriggerEnum mixSideFixed: boolean - visible: boolean readonly width: number readonly mixSidebarWidth: number readonly collapsedWidth: number From 61cb39549c34210980414e97657f2c6bd8d705bf Mon Sep 17 00:00:00 2001 From: h_mo <596417202@qq.com> Date: Sat, 4 Feb 2023 13:58:35 +0800 Subject: [PATCH 09/22] =?UTF-8?q?perf:=20grid-layout=20=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grid-layouts/src/components/Layout.vue | 31 +++++++- .../components/composables/LayoutContent.vue | 10 ++- .../components/composables/LayoutFooter.vue | 5 +- .../components/composables/LayoutHeader.vue | 3 +- .../components/composables/LayoutSidebar.vue | 15 ++-- .../src/components/composables/LayoutTab.vue | 3 +- .../components/trigger/SiderCenterTrigger.vue | 18 ----- .../src/hooks/useComprehensive.ts | 1 - packages/styles/src/grid-layout.scss | 77 ------------------- packages/styles/src/index.ts | 1 - packages/styles/src/variables.css | 10 +-- 11 files changed, 55 insertions(+), 119 deletions(-) delete mode 100644 packages/styles/src/grid-layout.scss diff --git a/packages/grid-layouts/src/components/Layout.vue b/packages/grid-layouts/src/components/Layout.vue index bacc8e93..d24a65e4 100644 --- a/packages/grid-layouts/src/components/Layout.vue +++ b/packages/grid-layouts/src/components/Layout.vue @@ -3,6 +3,7 @@ import LayoutHeader from './composables/LayoutHeader.vue' import LayoutSidebar from './composables/LayoutSidebar.vue' import LayoutContent from './composables/LayoutContent.vue' import LayoutTab from './composables/LayoutTab.vue' +import Feature from './feature/index.vue' import { storeToRefs } from '@vben/pinia' import { useLayoutHeader, @@ -23,14 +24,38 @@ const { type } = storeToRefs(useMenuSettingStore()) + - + diff --git a/packages/grid-layouts/src/components/composables/LayoutContent.vue b/packages/grid-layouts/src/components/composables/LayoutContent.vue index 2d884d27..eba0af6b 100644 --- a/packages/grid-layouts/src/components/composables/LayoutContent.vue +++ b/packages/grid-layouts/src/components/composables/LayoutContent.vue @@ -6,9 +6,15 @@ import { storeToRefs } from '@vben/pinia' const { footerRef } = storeToRefs(useLayoutFooter()) - + - + diff --git a/packages/grid-layouts/src/components/composables/LayoutFooter.vue b/packages/grid-layouts/src/components/composables/LayoutFooter.vue index 0603d6ba..c0ad3d1c 100644 --- a/packages/grid-layouts/src/components/composables/LayoutFooter.vue +++ b/packages/grid-layouts/src/components/composables/LayoutFooter.vue @@ -1,5 +1,6 @@ - + - diff --git a/packages/grid-layouts/src/components/composables/LayoutHeader.vue b/packages/grid-layouts/src/components/composables/LayoutHeader.vue index 244dacda..0f83b039 100644 --- a/packages/grid-layouts/src/components/composables/LayoutHeader.vue +++ b/packages/grid-layouts/src/components/composables/LayoutHeader.vue @@ -7,9 +7,8 @@ const { showHeaderTrigger } = storeToRefs(menuSettingStore) - + header - diff --git a/packages/grid-layouts/src/components/composables/LayoutSidebar.vue b/packages/grid-layouts/src/components/composables/LayoutSidebar.vue index ac5accaa..f2030250 100644 --- a/packages/grid-layouts/src/components/composables/LayoutSidebar.vue +++ b/packages/grid-layouts/src/components/composables/LayoutSidebar.vue @@ -3,17 +3,22 @@ import Trigger from '../trigger/inedx.vue' import { useMenuSettingStore } from '../../store' import { storeToRefs } from '@vben/pinia' const menuSettingStore = useMenuSettingStore() -const { showHeaderTrigger, showFooterTrigger } = storeToRefs(menuSettingStore) +const { showHeaderTrigger, showFooterTrigger, hidden } = + storeToRefs(menuSettingStore) sidebar - + - diff --git a/packages/grid-layouts/src/components/composables/LayoutTab.vue b/packages/grid-layouts/src/components/composables/LayoutTab.vue index d56609ca..8a7848f6 100644 --- a/packages/grid-layouts/src/components/composables/LayoutTab.vue +++ b/packages/grid-layouts/src/components/composables/LayoutTab.vue @@ -1,5 +1,4 @@ - tab + tab - diff --git a/packages/grid-layouts/src/components/trigger/SiderCenterTrigger.vue b/packages/grid-layouts/src/components/trigger/SiderCenterTrigger.vue index 1b9201c1..8d50a413 100644 --- a/packages/grid-layouts/src/components/trigger/SiderCenterTrigger.vue +++ b/packages/grid-layouts/src/components/trigger/SiderCenterTrigger.vue @@ -17,21 +17,3 @@ const { collapsed } = storeToRefs(menuSettingStore) /> - diff --git a/packages/grid-layouts/src/hooks/useComprehensive.ts b/packages/grid-layouts/src/hooks/useComprehensive.ts index eb5e910e..752072a6 100644 --- a/packages/grid-layouts/src/hooks/useComprehensive.ts +++ b/packages/grid-layouts/src/hooks/useComprehensive.ts @@ -13,7 +13,6 @@ export const useComprehensive = () => { return { '--aside-width': asideWidth + 'px', - '--aside-visible': menuSettingStore.hidden ? 'hidden' : 'visible', } }) return { diff --git a/packages/styles/src/grid-layout.scss b/packages/styles/src/grid-layout.scss deleted file mode 100644 index 1315693d..00000000 --- a/packages/styles/src/grid-layout.scss +++ /dev/null @@ -1,77 +0,0 @@ -.vben-grid-layout-container { - display: grid; - grid-template-columns: minmax(0, var(--aside-width)) minmax(640px, 1fr); - grid-template-rows: var(--header-height) var(--tab-height) 1fr; - grid-gap: 3px; - transition: grid-template-columns .3s, grid-template-rows .3s; - transition-timing-function: var(--transition-bezier); - - &.layout-sidebar, - &.layout-mix-sidebar { - grid-template-areas: - 'vben-sidebar vben-header' - 'vben-sidebar vben-tab' - 'vben-sidebar vben-content'; - } - - &.layout-mix-sidebar { - --aside-width: 80px; - } - - &.layout-mix, - &.layout-top-menu { - grid-template-areas: - 'vben-header vben-header' - 'vben-sidebar vben-tab' - 'vben-sidebar vben-content'; - } - - &.layout-top-menu { - --aside-width: 0; - } - - .vben-grid-layout-header { - grid-area: vben-header; - background: #666666; - } - - .vben-grid-layout-sidebar { - grid-area: vben-sidebar; - position: relative; - visibility: var(--aside-visible); - - .vben-grid-layout-sidebar__border { - content: ''; - position: absolute; - top: 0; - bottom: 0; - right: 0; - width: 1px; - background-color: var(--layout-border-color); - transition: background-color 0.3s var(--transition-bezier); - } - } - - .vben-grid-layout-tab { - grid-area: vben-tab; - background: #0960bd; - } - - .vben-grid-layout-content { - grid-area: vben-content; - overflow: auto; - display: grid; - grid-template-columns: 100%; - grid-template-rows: 1fr minmax(0, var(--footer-height)); - - background: #ed6f6f; - } - - .vben-grid-layout-main { - background-color: aqua; - } - - .vben-grid-layout-footer { - background-color: blueviolet; - } -} diff --git a/packages/styles/src/index.ts b/packages/styles/src/index.ts index ef796296..f705f866 100644 --- a/packages/styles/src/index.ts +++ b/packages/styles/src/index.ts @@ -1,5 +1,4 @@ import './common.css' import './entry.css' import './variables.css' -import './grid-layout.scss' import 'uno.css' diff --git a/packages/styles/src/variables.css b/packages/styles/src/variables.css index 573cab1e..a2101bfc 100644 --- a/packages/styles/src/variables.css +++ b/packages/styles/src/variables.css @@ -8,7 +8,7 @@ --component-background-color: #fff; /* transition */ - --transition-bezier:cubic-bezier(0.4, 0, 0.2, 1); + --transition-bezier: cubic-bezier(0.4, 0, 0.2, 1); --transition-all: all 0.3s var(--transition-bezier); /* layout start */ @@ -26,18 +26,16 @@ /* tab */ --tab-height: 36px; --tab-width: calc(100% - var(--aside-width)); - + /* aside */ --aside-height: calc(100% - var(--header-height)); --aside-width: 210px; - --aside-visible: visible; --aside-background-color: #001628; --aside-submenu-background-color: #0c2135; - - --trigger-color: #FFF; + --trigger-color: #fff; --trigger-border: 1px solid rgb(239, 239, 245); ---trigger-border-color: rgb(239, 239, 245); + --trigger-border-color: rgb(239, 239, 245); --trigger-icon-color: rgb(51, 54, 57); /* main */ From 0110a1564aa9798a89e00dc639280a9019ed8028 Mon Sep 17 00:00:00 2001 From: h_mo <596417202@qq.com> Date: Sat, 4 Feb 2023 23:14:15 +0800 Subject: [PATCH 10/22] =?UTF-8?q?feat:=20grid-layout=20setting=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grid-layouts/src/components/Layout.vue | 2 +- .../components/composables/LayoutContent.vue | 2 +- .../components/composables/LayoutFooter.vue | 4 +- .../components/composables/LayoutHeader.vue | 23 ++- .../src/components/feature/index.vue | 8 + .../src/components/setting/FixedButton.vue | 15 ++ .../src/components/setting/SettingDrawer.vue | 120 ++++++++++++ .../components/setting/components/Content.vue | 128 ++++++++++++ .../setting/components/DarkModeToggle.vue | 26 +++ .../setting/components/Features.vue | 164 ++++++++++++++++ .../setting/components/FooterButtons.vue | 74 +++++++ .../setting/components/InputNumberItem.vue | 39 ++++ .../components/NavigationBarPicker.vue | 108 ++++++++++ .../setting/components/SelectItem.vue | 48 +++++ .../setting/components/SettingDrawer.vue | 103 ++++++++++ .../setting/components/SwitchItem.vue | 34 ++++ .../setting/components/ThemeColorPicker.vue | 53 +++++ .../setting/components/Transitions.vue | 41 ++++ .../src/components/setting/index.vue | 15 ++ .../src/components/trigger/HeaderTrigger.vue | 2 +- packages/grid-layouts/src/logics/constant.ts | 112 +++++++++++ packages/grid-layouts/src/logics/handler.ts | 185 ++++++++++++++++++ packages/grid-layouts/src/store/index.ts | 2 +- .../src/store/modules/headerSetting.ts | 4 +- .../src/store/modules/menuSetting.ts | 1 + .../src/store/modules/sporadicSetting.ts | 10 +- packages/locale/src/lang/en/layout.ts | 1 + packages/locale/src/lang/zh-CN/layout.ts | 1 + packages/styles/src/variables.css | 1 + packages/types/src/setting.ts | 2 + packages/utils/index.ts | 1 + 31 files changed, 1316 insertions(+), 13 deletions(-) create mode 100644 packages/grid-layouts/src/components/feature/index.vue create mode 100644 packages/grid-layouts/src/components/setting/FixedButton.vue create mode 100644 packages/grid-layouts/src/components/setting/SettingDrawer.vue create mode 100644 packages/grid-layouts/src/components/setting/components/Content.vue create mode 100644 packages/grid-layouts/src/components/setting/components/DarkModeToggle.vue create mode 100644 packages/grid-layouts/src/components/setting/components/Features.vue create mode 100644 packages/grid-layouts/src/components/setting/components/FooterButtons.vue create mode 100644 packages/grid-layouts/src/components/setting/components/InputNumberItem.vue create mode 100644 packages/grid-layouts/src/components/setting/components/NavigationBarPicker.vue create mode 100644 packages/grid-layouts/src/components/setting/components/SelectItem.vue create mode 100644 packages/grid-layouts/src/components/setting/components/SettingDrawer.vue create mode 100644 packages/grid-layouts/src/components/setting/components/SwitchItem.vue create mode 100644 packages/grid-layouts/src/components/setting/components/ThemeColorPicker.vue create mode 100644 packages/grid-layouts/src/components/setting/components/Transitions.vue create mode 100644 packages/grid-layouts/src/components/setting/index.vue create mode 100644 packages/grid-layouts/src/logics/constant.ts create mode 100644 packages/grid-layouts/src/logics/handler.ts diff --git a/packages/grid-layouts/src/components/Layout.vue b/packages/grid-layouts/src/components/Layout.vue index d24a65e4..d66554d0 100644 --- a/packages/grid-layouts/src/components/Layout.vue +++ b/packages/grid-layouts/src/components/Layout.vue @@ -28,11 +28,11 @@ const { type } = storeToRefs(useMenuSettingStore()) :class="[`${type}`]" :style="getLayoutStyles" > - + diff --git a/packages/grid-layouts/src/components/feature/index.vue b/packages/grid-layouts/src/components/feature/index.vue new file mode 100644 index 00000000..44b2c7a6 --- /dev/null +++ b/packages/grid-layouts/src/components/feature/index.vue @@ -0,0 +1,8 @@ + + + + + diff --git a/packages/grid-layouts/src/components/setting/FixedButton.vue b/packages/grid-layouts/src/components/setting/FixedButton.vue new file mode 100644 index 00000000..d1ec25f0 --- /dev/null +++ b/packages/grid-layouts/src/components/setting/FixedButton.vue @@ -0,0 +1,15 @@ + + + + + + diff --git a/packages/grid-layouts/src/components/setting/SettingDrawer.vue b/packages/grid-layouts/src/components/setting/SettingDrawer.vue new file mode 100644 index 00000000..b22dcf52 --- /dev/null +++ b/packages/grid-layouts/src/components/setting/SettingDrawer.vue @@ -0,0 +1,120 @@ + + + + + + {{ t('layout.setting.drawerTitle') }} + + + {{ t('layout.setting.darkMode') }} + + + + {{ t('layout.setting.navMode') }} + + { + baseHandler(HandlerSettingEnum.CHANGE_LAYOUT, { + mode: item.mode, + type: item.type, + split: isHorizontal ? false : undefined, + }) + } + " + /> + + + {{ t('layout.setting.sysTheme') }} + + + + + {{ t('layout.setting.headerTheme') }} + + + {{ + t('layout.setting.sidebarTheme') + }} + + + + + {{ t('layout.setting.interfaceFunction') }} + + + + + {{ t('layout.setting.interfaceDisplay') }} + + + + {{ t('layout.setting.animation') }} + + + + + + + + diff --git a/packages/grid-layouts/src/components/setting/components/Content.vue b/packages/grid-layouts/src/components/setting/components/Content.vue new file mode 100644 index 00000000..72f1c300 --- /dev/null +++ b/packages/grid-layouts/src/components/setting/components/Content.vue @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + diff --git a/packages/grid-layouts/src/components/setting/components/DarkModeToggle.vue b/packages/grid-layouts/src/components/setting/components/DarkModeToggle.vue new file mode 100644 index 00000000..1b92091a --- /dev/null +++ b/packages/grid-layouts/src/components/setting/components/DarkModeToggle.vue @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + diff --git a/packages/grid-layouts/src/components/setting/components/Features.vue b/packages/grid-layouts/src/components/setting/components/Features.vue new file mode 100644 index 00000000..c155be0e --- /dev/null +++ b/packages/grid-layouts/src/components/setting/components/Features.vue @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/grid-layouts/src/components/setting/components/FooterButtons.vue b/packages/grid-layouts/src/components/setting/components/FooterButtons.vue new file mode 100644 index 00000000..5a8da527 --- /dev/null +++ b/packages/grid-layouts/src/components/setting/components/FooterButtons.vue @@ -0,0 +1,74 @@ + + + + + + + + {{ t('layout.setting.copyBtn') }} + + + + + + {{ t('common.resetText') }} + + + + + + {{ t('layout.setting.clearBtn') }} + + + diff --git a/packages/grid-layouts/src/components/setting/components/InputNumberItem.vue b/packages/grid-layouts/src/components/setting/components/InputNumberItem.vue new file mode 100644 index 00000000..bc6d202e --- /dev/null +++ b/packages/grid-layouts/src/components/setting/components/InputNumberItem.vue @@ -0,0 +1,39 @@ + + + + {{ title }} + + + {{ suffix }} + + + + diff --git a/packages/grid-layouts/src/components/setting/components/NavigationBarPicker.vue b/packages/grid-layouts/src/components/setting/components/NavigationBarPicker.vue new file mode 100644 index 00000000..37fff21d --- /dev/null +++ b/packages/grid-layouts/src/components/setting/components/NavigationBarPicker.vue @@ -0,0 +1,108 @@ + + + + + + + + + + + + {{ t(item.title) }} + + + + + + diff --git a/packages/grid-layouts/src/components/setting/components/SelectItem.vue b/packages/grid-layouts/src/components/setting/components/SelectItem.vue new file mode 100644 index 00000000..fba36eb1 --- /dev/null +++ b/packages/grid-layouts/src/components/setting/components/SelectItem.vue @@ -0,0 +1,48 @@ + + + + + {{ title }} + + + + + diff --git a/packages/grid-layouts/src/components/setting/components/SettingDrawer.vue b/packages/grid-layouts/src/components/setting/components/SettingDrawer.vue new file mode 100644 index 00000000..6b0c2b20 --- /dev/null +++ b/packages/grid-layouts/src/components/setting/components/SettingDrawer.vue @@ -0,0 +1,103 @@ + + + + + + {{ t('layout.setting.drawerTitle') }} + + {{ + t('layout.setting.darkMode') + }} + + + {{ + t('layout.setting.navMode') + }} + { + baseHandler(HandlerSettingEnum.CHANGE_LAYOUT, { + mode: item.mode, + type: item.type, + split: getIsHorizontal ? false : undefined, + }) + } + " + /> + {{ + t('layout.setting.sysTheme') + }} + + {{ + t('layout.setting.headerTheme') + }} + + {{ + t('layout.setting.sidebarTheme') + }} + + {{ t('layout.setting.interfaceFunction') }} + + + {{ + t('layout.setting.interfaceDisplay') + }} + + {{ + t('layout.setting.animation') + }} + + + + + + diff --git a/packages/grid-layouts/src/components/setting/components/SwitchItem.vue b/packages/grid-layouts/src/components/setting/components/SwitchItem.vue new file mode 100644 index 00000000..fbc977ce --- /dev/null +++ b/packages/grid-layouts/src/components/setting/components/SwitchItem.vue @@ -0,0 +1,34 @@ + + + + {{ title }} + + + + + + + + + + diff --git a/packages/grid-layouts/src/components/setting/components/ThemeColorPicker.vue b/packages/grid-layouts/src/components/setting/components/ThemeColorPicker.vue new file mode 100644 index 00000000..8d4b834f --- /dev/null +++ b/packages/grid-layouts/src/components/setting/components/ThemeColorPicker.vue @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + diff --git a/packages/grid-layouts/src/components/setting/components/Transitions.vue b/packages/grid-layouts/src/components/setting/components/Transitions.vue new file mode 100644 index 00000000..b20b71c0 --- /dev/null +++ b/packages/grid-layouts/src/components/setting/components/Transitions.vue @@ -0,0 +1,41 @@ + + + + + + + + + diff --git a/packages/grid-layouts/src/components/setting/index.vue b/packages/grid-layouts/src/components/setting/index.vue new file mode 100644 index 00000000..b08d4e91 --- /dev/null +++ b/packages/grid-layouts/src/components/setting/index.vue @@ -0,0 +1,15 @@ + + + + + + diff --git a/packages/grid-layouts/src/components/trigger/HeaderTrigger.vue b/packages/grid-layouts/src/components/trigger/HeaderTrigger.vue index 07f02835..ac20e0b5 100644 --- a/packages/grid-layouts/src/components/trigger/HeaderTrigger.vue +++ b/packages/grid-layouts/src/components/trigger/HeaderTrigger.vue @@ -7,7 +7,7 @@ const { collapsed } = storeToRefs(menuSettingStore) { + return [ + { + value: TriggerEnum.NONE, + label: t('layout.setting.menuTriggerNone'), + }, + { + value: TriggerEnum.FOOTER, + label: t('layout.setting.menuTriggerBottom'), + }, + { + value: TriggerEnum.CENTER, + label: t('layout.setting.menuTriggerCenter'), + }, + ...(split + ? [] + : [ + { + value: TriggerEnum.HEADER, + label: t('layout.setting.menuTriggerTop'), + }, + ]), + ] +} + +export const routerTransitionOptions = [ + RouterTransitionEnum.ZOOM_FADE, + RouterTransitionEnum.FADE, + RouterTransitionEnum.ZOOM_OUT, + RouterTransitionEnum.FADE_SIDE, + RouterTransitionEnum.FADE_BOTTOM, + RouterTransitionEnum.FADE_SCALE, +].map((item) => { + return { + label: item, + value: item, + } +}) + +export const mixSidebarTriggerOptions = [ + { + value: MixSidebarTriggerEnum.HOVER, + label: t('layout.setting.triggerHover'), + }, + { + value: MixSidebarTriggerEnum.CLICK, + label: t('layout.setting.triggerClick'), + }, +] diff --git a/packages/grid-layouts/src/logics/handler.ts b/packages/grid-layouts/src/logics/handler.ts new file mode 100644 index 00000000..3f490e38 --- /dev/null +++ b/packages/grid-layouts/src/logics/handler.ts @@ -0,0 +1,185 @@ +import { HandlerSettingEnum } from '@vben/constants' +import { + useHeaderSettingStore, + useMenuSettingStore, + useMultiTabsSettingStore, + useSporadicSettingStore, + useTransitionSettingStore, +} from '../store' + +export function baseHandler(event: HandlerSettingEnum, value: any) { + handler(event, value) +} + +export function handler(event: HandlerSettingEnum, value: any) { + const sporadicSettingStore = useSporadicSettingStore() + const menuSettingStore = useMenuSettingStore() + const headerSettingStore = useHeaderSettingStore() + const multiTabsSettingStore = useMultiTabsSettingStore() + const transitionSettingStore = useTransitionSettingStore() + // @ts-ignore + switch (event) { + case HandlerSettingEnum.CHANGE_LAYOUT: + const { mode, type, split } = value + menuSettingStore.setType(type) + menuSettingStore.setMode(mode) + menuSettingStore.setSplit(split) + break + + case HandlerSettingEnum.CHANGE_THEME_COLOR: + // if (getThemeColor.value === value) { + // return {} + // } + // changeTheme(value); + sporadicSettingStore.setThemeColor(value) + break + + case HandlerSettingEnum.CHANGE_THEME: + // if (getDarkMode.value === value) { + // return {} + // } + // updateDarkTheme(value); + break + + case HandlerSettingEnum.MENU_HAS_DRAG: + menuSettingStore.setCanDrag(value) + break + + case HandlerSettingEnum.MENU_ACCORDION: + menuSettingStore.setAccordion(value) + break + + case HandlerSettingEnum.MENU_TRIGGER: + menuSettingStore.setTrigger(value) + break + + case HandlerSettingEnum.MENU_TOP_ALIGN: + menuSettingStore.setTopMenuAlign(value) + break + case HandlerSettingEnum.MENU_COLLAPSED: + menuSettingStore.setCollapsed(value) + break + + case HandlerSettingEnum.MENU_WIDTH: + return { menuSetting: { menuWidth: value } } + + case HandlerSettingEnum.MENU_SHOW_SIDEBAR: + menuSettingStore.setShow(value) + break + + case HandlerSettingEnum.MENU_COLLAPSED_SHOW_TITLE: + return { menuSetting: { collapsedShowTitle: value } } + + case HandlerSettingEnum.MENU_THEME: + // updateSidebarBgColor(value); + menuSettingStore.setBgColor(value) + break + + case HandlerSettingEnum.MENU_SPLIT: + menuSettingStore.setSplit(value) + break + + case HandlerSettingEnum.MENU_CLOSE_MIX_SIDEBAR_ON_CHANGE: + menuSettingStore.setCloseMixSidebarOnChange(value) + break + + case HandlerSettingEnum.MENU_FIXED: + menuSettingStore.setFixed(value) + break + + case HandlerSettingEnum.MENU_TRIGGER_MIX_SIDEBAR: + menuSettingStore.setMixSideTrigger(value) + break + + case HandlerSettingEnum.MENU_FIXED_MIX_SIDEBAR: + menuSettingStore.setMixSideFixed(value) + break + + // ============transition================== + case HandlerSettingEnum.OPEN_PAGE_LOADING: + transitionSettingStore.setOpenPageLoading(value) + break + + case HandlerSettingEnum.ROUTER_TRANSITION: + transitionSettingStore.setBasicTransition(value) + break + + case HandlerSettingEnum.OPEN_ROUTE_TRANSITION: + transitionSettingStore.setEnable(value) + break + + case HandlerSettingEnum.OPEN_PROGRESS: + transitionSettingStore.setOpenNProgress(value) + break + // ============sporadic================== + + case HandlerSettingEnum.LOCK_TIME: + sporadicSettingStore.setLockTime(value) + break + + case HandlerSettingEnum.FULL_CONTENT: + sporadicSettingStore.setFullContent(value) + break + case HandlerSettingEnum.CONTENT_MODE: + sporadicSettingStore.setContentMode(value) + break + + case HandlerSettingEnum.SHOW_BREADCRUMB: + sporadicSettingStore.setShowBreadCrumb(value) + break + case HandlerSettingEnum.SHOW_BREADCRUMB_ICON: + sporadicSettingStore.setShowBreadCrumbIcon(value) + break + + case HandlerSettingEnum.GRAY_MODE: + // updateGrayMode(value) + sporadicSettingStore.setGrayMode(value) + break + case HandlerSettingEnum.SHOW_FOOTER: + sporadicSettingStore.setShowFooter(value) + break + + case HandlerSettingEnum.COLOR_WEAK: + // updateColorWeak(value) + sporadicSettingStore.setColorWeak(value) + break + + case HandlerSettingEnum.SHOW_LOGO: + sporadicSettingStore.setShowLogo(value) + break + + // ============tabs================== + case HandlerSettingEnum.TABS_SHOW_QUICK: + multiTabsSettingStore.setShowQuick(value) + break + case HandlerSettingEnum.TABS_SHOW: + multiTabsSettingStore.setShow(value) + break + + case HandlerSettingEnum.TABS_SHOW_REDO: + multiTabsSettingStore.setShowRedo(value) + break + + case HandlerSettingEnum.TABS_SHOW_FOLD: + multiTabsSettingStore.setShowFold(value) + break + + // ============header================== + case HandlerSettingEnum.HEADER_THEME: + // updateHeaderBgColor(value); + headerSettingStore.setBgColor(value) + break + + case HandlerSettingEnum.HEADER_SEARCH: + headerSettingStore.setShowSearch(value) + break + case HandlerSettingEnum.HEADER_FIXED: + headerSettingStore.setFixed(value) + break + case HandlerSettingEnum.HEADER_SHOW: + headerSettingStore.setShow(value) + break + default: + return + } +} diff --git a/packages/grid-layouts/src/store/index.ts b/packages/grid-layouts/src/store/index.ts index efd93591..cba74339 100644 --- a/packages/grid-layouts/src/store/index.ts +++ b/packages/grid-layouts/src/store/index.ts @@ -1,4 +1,4 @@ -export { useSporadicSetting } from './modules/sporadicSetting' +export { useSporadicSettingStore } from './modules/sporadicSetting' export { useHeaderSettingStore } from './modules/headerSetting' export { useMenuSettingStore } from './modules/menuSetting' export { useTransitionSettingStore } from './modules/transitionSetting' diff --git a/packages/grid-layouts/src/store/modules/headerSetting.ts b/packages/grid-layouts/src/store/modules/headerSetting.ts index f1019aeb..131a506d 100644 --- a/packages/grid-layouts/src/store/modules/headerSetting.ts +++ b/packages/grid-layouts/src/store/modules/headerSetting.ts @@ -26,7 +26,9 @@ export const useHeaderSettingStore = defineStore({ showSearch: true, showLocalePicker: true, }), - getters: {}, + getters: { + isDark: (state) => state.theme === ThemeEnum.DARK, + }, actions: { setBgColor(value: string) { this.bgColor = value diff --git a/packages/grid-layouts/src/store/modules/menuSetting.ts b/packages/grid-layouts/src/store/modules/menuSetting.ts index aafd112f..e3bf7569 100644 --- a/packages/grid-layouts/src/store/modules/menuSetting.ts +++ b/packages/grid-layouts/src/store/modules/menuSetting.ts @@ -58,6 +58,7 @@ export const useMenuSettingStore = defineStore({ isSidebar: (state) => state.type === MenuTypeEnum.SIDEBAR, isTopMenu: (state) => state.type === MenuTypeEnum.TOP_MENU, isMixSidebar: (state) => state.type === MenuTypeEnum.MIX_SIDEBAR, + isMix: (state) => state.type === MenuTypeEnum.MIX, isMixMode: (state) => state.mode === MenuModeEnum.INLINE && state.type === MenuTypeEnum.MIX, showMenuLogo: (state) => state.type === MenuTypeEnum.SIDEBAR, diff --git a/packages/grid-layouts/src/store/modules/sporadicSetting.ts b/packages/grid-layouts/src/store/modules/sporadicSetting.ts index 9003def9..1608019f 100644 --- a/packages/grid-layouts/src/store/modules/sporadicSetting.ts +++ b/packages/grid-layouts/src/store/modules/sporadicSetting.ts @@ -8,7 +8,7 @@ import { ContentLayoutEnum, } from '@vben/constants' -export const useSporadicSetting = defineStore({ +export const useSporadicSettingStore = defineStore({ id: 'LAYOUT_SPORADIC_SETTING', // persist: true, state: (): SporadicSetting => ({ @@ -18,6 +18,8 @@ export const useSporadicSetting = defineStore({ showDarkModeToggle: true, // `Settings` button position settingButtonPosition: SettingButtonPositionEnum.AUTO, + // Whether to show the Setting Drawer + showSettingDrawer: false, // Permission mode permissionMode: PermissionModeEnum.ROUTE_MAPPING, // Permission-related cache is stored in sessionStorage or localStorage @@ -69,6 +71,12 @@ export const useSporadicSetting = defineStore({ setSettingButtonPosition(value: SettingButtonPositionEnum) { this.settingButtonPosition = value }, + setShowSettingDrawer(value: boolean) { + this.showSettingDrawer = value + }, + toggleSettingDrawerVisible() { + this.setShowSettingDrawer(!this.showSettingDrawer) + }, setPermissionMode(value: PermissionModeEnum) { this.permissionMode = value }, diff --git a/packages/locale/src/lang/en/layout.ts b/packages/locale/src/lang/en/layout.ts index d3c0390c..01824e06 100644 --- a/packages/locale/src/lang/en/layout.ts +++ b/packages/locale/src/lang/en/layout.ts @@ -39,6 +39,7 @@ export default { menuTriggerNone: 'Not Show', menuTriggerBottom: 'Bottom', menuTriggerTop: 'Top', + menuTriggerCenter: 'Sideways', // menu type menuTypeSidebar: 'Left menu mode', menuTypeMixSidebar: 'Left menu mixed mode', diff --git a/packages/locale/src/lang/zh-CN/layout.ts b/packages/locale/src/lang/zh-CN/layout.ts index 3e4e50c0..40f091c4 100644 --- a/packages/locale/src/lang/zh-CN/layout.ts +++ b/packages/locale/src/lang/zh-CN/layout.ts @@ -40,6 +40,7 @@ export default { menuTriggerNone: '不显示', menuTriggerBottom: '底部', menuTriggerTop: '顶部', + menuTriggerCenter: '侧边', // menu type menuTypeSidebar: '左侧菜单模式', menuTypeMixSidebar: '左侧菜单混合模式', diff --git a/packages/styles/src/variables.css b/packages/styles/src/variables.css index a2101bfc..561398ed 100644 --- a/packages/styles/src/variables.css +++ b/packages/styles/src/variables.css @@ -51,5 +51,6 @@ @media (prefers-color-scheme: dark) { :root { + visibility: visible; } } diff --git a/packages/types/src/setting.ts b/packages/types/src/setting.ts index cf4717da..e374f950 100644 --- a/packages/types/src/setting.ts +++ b/packages/types/src/setting.ts @@ -112,6 +112,8 @@ export interface SporadicSetting { showDarkModeToggle: boolean // Configure where the button is displayed settingButtonPosition: SettingButtonPositionEnum + // Configure where the Setting Drawer is displayed + showSettingDrawer: boolean // Permission mode permissionMode: PermissionModeEnum // Session timeout processing diff --git a/packages/utils/index.ts b/packages/utils/index.ts index 986b306b..600d0e0c 100644 --- a/packages/utils/index.ts +++ b/packages/utils/index.ts @@ -8,6 +8,7 @@ export { clone, isArray, isString, + toString, } from 'lodash-es' // @ts-ignore import Sortable from 'sortablejs' From e4e2d82f36d1c8a7db5e94c971c88b4801ee9f84 Mon Sep 17 00:00:00 2001 From: h_mo <596417202@qq.com> Date: Mon, 6 Feb 2023 18:05:05 +0800 Subject: [PATCH 11/22] pref: grid-layout setting --- .../grid-layouts/src/components/Layout.vue | 6 +-- packages/grid-layouts/src/components/Main.vue | 20 +------ .../src/components/breadcrumb/index.vue | 14 +++++ .../components/composables/LayoutContent.vue | 2 + .../components/composables/LayoutFooter.vue | 14 ++++- .../components/composables/LayoutHeader.vue | 21 ++++---- .../src/components/composables/LayoutLogo.vue | 3 -- .../components/composables/LayoutSidebar.vue | 5 +- .../src/components/composables/LayoutTab.vue | 28 +++++++++- .../src/components/logo/index.vue | 29 +++++++++++ .../grid-layouts/src/components/render.ts | 7 +++ .../src/components/setting/FixedButton.vue | 4 +- .../components/setting/components/Content.vue | 52 +++++++------------ .../setting/components/Transitions.vue | 2 +- .../src/components/tab-bar/FoldButton.vue | 15 ++++++ .../src/components/tab-bar/TabQuick.vue | 12 +++++ .../src/components/tab-bar/TabRedo.vue | 25 +++++++++ .../src/components/trigger/inedx.vue | 18 +++---- .../src/hooks/useComprehensive.ts | 39 +++++++++++--- .../src/store/modules/headerSetting.ts | 7 +++ .../src/store/modules/menuSetting.ts | 1 + .../src/store/modules/multiTabsSetting.ts | 8 ++- .../src/store/modules/sporadicSetting.ts | 6 +++ packages/styles/src/variables.css | 4 +- packages/types/src/setting.ts | 6 +++ 25 files changed, 250 insertions(+), 98 deletions(-) create mode 100644 packages/grid-layouts/src/components/breadcrumb/index.vue delete mode 100644 packages/grid-layouts/src/components/composables/LayoutLogo.vue create mode 100644 packages/grid-layouts/src/components/logo/index.vue create mode 100644 packages/grid-layouts/src/components/render.ts create mode 100644 packages/grid-layouts/src/components/tab-bar/FoldButton.vue create mode 100644 packages/grid-layouts/src/components/tab-bar/TabQuick.vue create mode 100644 packages/grid-layouts/src/components/tab-bar/TabRedo.vue diff --git a/packages/grid-layouts/src/components/Layout.vue b/packages/grid-layouts/src/components/Layout.vue index d66554d0..2435eb92 100644 --- a/packages/grid-layouts/src/components/Layout.vue +++ b/packages/grid-layouts/src/components/Layout.vue @@ -39,7 +39,7 @@ const { type } = storeToRefs(useMenuSettingStore()) .grid-layout-container { display: grid; grid-template-columns: minmax(0, var(--aside-width)) minmax(640px, 1fr); - grid-template-rows: var(--header-height) var(--tab-height) 1fr; + grid-template-rows: var(--header-height) var(--tab-bar-height) 1fr; grid-gap: 3px; transition: grid-template-columns 0.3s, grid-template-rows 0.3s; transition-timing-function: var(--transition-bezier); @@ -47,14 +47,14 @@ const { type } = storeToRefs(useMenuSettingStore()) &.mix-sidebar { grid-template-areas: 'grid-sidebar grid-header' - 'grid-sidebar grid-tab-nav' + 'grid-sidebar grid-tab-bar' 'grid-sidebar grid-content'; } &.mix, &.top-menu { grid-template-areas: 'grid-header grid-header' - 'grid-sidebar grid-tab-nav' + 'grid-sidebar grid-tab-bar' 'grid-sidebar grid-content'; } } diff --git a/packages/grid-layouts/src/components/Main.vue b/packages/grid-layouts/src/components/Main.vue index 5f91678c..977b789f 100644 --- a/packages/grid-layouts/src/components/Main.vue +++ b/packages/grid-layouts/src/components/Main.vue @@ -1,35 +1,19 @@ - {{ type }} - + main - {{ type }} + layoutStyles: {{ getLayoutStyles }} headerWidth: {{ headerWidth }}, headerHeight: {{ headerHeight }} diff --git a/packages/grid-layouts/src/components/breadcrumb/index.vue b/packages/grid-layouts/src/components/breadcrumb/index.vue new file mode 100644 index 00000000..a81c9567 --- /dev/null +++ b/packages/grid-layouts/src/components/breadcrumb/index.vue @@ -0,0 +1,14 @@ + + + + + + + + breadcrumb + diff --git a/packages/grid-layouts/src/components/composables/LayoutContent.vue b/packages/grid-layouts/src/components/composables/LayoutContent.vue index 5fb6e8a0..7c3d8ee5 100644 --- a/packages/grid-layouts/src/components/composables/LayoutContent.vue +++ b/packages/grid-layouts/src/components/composables/LayoutContent.vue @@ -15,6 +15,8 @@ const { footerRef } = storeToRefs(useLayoutFooter()) .grid-layout-content { grid-template-columns: 100%; grid-template-rows: 1fr minmax(0, var(--footer-height)); + transition: grid-template-columns 0.3s, grid-template-rows 0.3s; + transition-timing-function: var(--transition-bezier); background: #ed6f6f; } diff --git a/packages/grid-layouts/src/components/composables/LayoutFooter.vue b/packages/grid-layouts/src/components/composables/LayoutFooter.vue index 26d3e2ab..cc8370ce 100644 --- a/packages/grid-layouts/src/components/composables/LayoutFooter.vue +++ b/packages/grid-layouts/src/components/composables/LayoutFooter.vue @@ -1,4 +1,14 @@ - + - + diff --git a/packages/grid-layouts/src/components/composables/LayoutHeader.vue b/packages/grid-layouts/src/components/composables/LayoutHeader.vue index ffc5176b..ae1b6ca5 100644 --- a/packages/grid-layouts/src/components/composables/LayoutHeader.vue +++ b/packages/grid-layouts/src/components/composables/LayoutHeader.vue @@ -1,29 +1,26 @@ - + + - left + - diff --git a/packages/grid-layouts/src/components/composables/LayoutLogo.vue b/packages/grid-layouts/src/components/composables/LayoutLogo.vue deleted file mode 100644 index 4e196201..00000000 --- a/packages/grid-layouts/src/components/composables/LayoutLogo.vue +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/packages/grid-layouts/src/components/composables/LayoutSidebar.vue b/packages/grid-layouts/src/components/composables/LayoutSidebar.vue index f2030250..deb43d32 100644 --- a/packages/grid-layouts/src/components/composables/LayoutSidebar.vue +++ b/packages/grid-layouts/src/components/composables/LayoutSidebar.vue @@ -3,8 +3,7 @@ import Trigger from '../trigger/inedx.vue' import { useMenuSettingStore } from '../../store' import { storeToRefs } from '@vben/pinia' const menuSettingStore = useMenuSettingStore() -const { showHeaderTrigger, showFooterTrigger, hidden } = - storeToRefs(menuSettingStore) +const { showFooterTrigger, hidden } = storeToRefs(menuSettingStore) - + diff --git a/packages/grid-layouts/src/components/composables/LayoutTab.vue b/packages/grid-layouts/src/components/composables/LayoutTab.vue index 8a7848f6..dd2f3507 100644 --- a/packages/grid-layouts/src/components/composables/LayoutTab.vue +++ b/packages/grid-layouts/src/components/composables/LayoutTab.vue @@ -1,4 +1,28 @@ - + - tab + + + Multiple Tab + + + + + + + + diff --git a/packages/grid-layouts/src/components/logo/index.vue b/packages/grid-layouts/src/components/logo/index.vue new file mode 100644 index 00000000..814534d3 --- /dev/null +++ b/packages/grid-layouts/src/components/logo/index.vue @@ -0,0 +1,29 @@ + + + + + + + {{ title }} + + diff --git a/packages/grid-layouts/src/components/render.ts b/packages/grid-layouts/src/components/render.ts new file mode 100644 index 00000000..4e287e53 --- /dev/null +++ b/packages/grid-layouts/src/components/render.ts @@ -0,0 +1,7 @@ +import { h } from 'vue' +import { VbenIconify } from '@vben/vbencomponents' + +export const renderIcon = (icon: string) => { + if (!icon) return undefined + return () => h(VbenIconify, { icon }) +} diff --git a/packages/grid-layouts/src/components/setting/FixedButton.vue b/packages/grid-layouts/src/components/setting/FixedButton.vue index d1ec25f0..465d2bc8 100644 --- a/packages/grid-layouts/src/components/setting/FixedButton.vue +++ b/packages/grid-layouts/src/components/setting/FixedButton.vue @@ -5,10 +5,10 @@ const sporadicSettingStore = useSporadicSettingStore() diff --git a/packages/grid-layouts/src/components/setting/components/Content.vue b/packages/grid-layouts/src/components/setting/components/Content.vue index 72f1c300..79cfb316 100644 --- a/packages/grid-layouts/src/components/setting/components/Content.vue +++ b/packages/grid-layouts/src/components/setting/components/Content.vue @@ -12,22 +12,6 @@ import { storeToRefs } from '@vben/pinia' const { t } = useI18n() -// const { -// getShowFooter, -// getShowBreadCrumb, -// getShowBreadCrumbIcon, -// getShowLogo, -// getFullContent, -// getColorWeak, -// getGrayMode, -// } = useRootSetting() - -// const { getIsHorizontal, getShowMenu, getIsMixSidebar } = useMenuSetting() -// -// const { getShowHeader } = useHeaderSetting() -// -// const { getShowMultipleTab, getShowQuick, getShowRedo, getShowFold } = -// useMultipleTabSetting() const { isMixSidebar, show: showMenu, @@ -52,6 +36,11 @@ const { show: showHeader } = storeToRefs(useHeaderSettingStore()) + + + - - - diff --git a/packages/grid-layouts/src/components/tab-bar/FoldButton.vue b/packages/grid-layouts/src/components/tab-bar/FoldButton.vue new file mode 100644 index 00000000..686d0e6c --- /dev/null +++ b/packages/grid-layouts/src/components/tab-bar/FoldButton.vue @@ -0,0 +1,15 @@ + + + + + + + diff --git a/packages/grid-layouts/src/components/tab-bar/TabQuick.vue b/packages/grid-layouts/src/components/tab-bar/TabQuick.vue new file mode 100644 index 00000000..1751dea6 --- /dev/null +++ b/packages/grid-layouts/src/components/tab-bar/TabQuick.vue @@ -0,0 +1,12 @@ + + + + + + diff --git a/packages/grid-layouts/src/components/tab-bar/TabRedo.vue b/packages/grid-layouts/src/components/tab-bar/TabRedo.vue new file mode 100644 index 00000000..e24c3cf4 --- /dev/null +++ b/packages/grid-layouts/src/components/tab-bar/TabRedo.vue @@ -0,0 +1,25 @@ + + + + + + + diff --git a/packages/grid-layouts/src/components/trigger/inedx.vue b/packages/grid-layouts/src/components/trigger/inedx.vue index b6d6ac23..b7f25791 100644 --- a/packages/grid-layouts/src/components/trigger/inedx.vue +++ b/packages/grid-layouts/src/components/trigger/inedx.vue @@ -5,15 +5,15 @@ import { TriggerEnum } from '@vben/constants' import CenterTrigger from './SiderCenterTrigger.vue' import FooterTrigger from './SiderFooterTrigger.vue' import HeaderTrigger from './HeaderTrigger.vue' -const { trigger } = storeToRefs(useMenuSettingStore()) -const triggers = { - [TriggerEnum.HEADER]: HeaderTrigger, - [TriggerEnum.CENTER]: CenterTrigger, - [TriggerEnum.FOOTER]: FooterTrigger, -} +import { computed, defineComponent, unref } from 'vue' +const { trigger, showHeaderTrigger } = storeToRefs(useMenuSettingStore()) +const component = computed>(() => { + if (unref(showHeaderTrigger)) return HeaderTrigger + if (unref(trigger) === TriggerEnum.CENTER) return CenterTrigger + if (unref(trigger) === TriggerEnum.FOOTER) return FooterTrigger + return undefined +}) - - - + diff --git a/packages/grid-layouts/src/hooks/useComprehensive.ts b/packages/grid-layouts/src/hooks/useComprehensive.ts index 752072a6..eaae148d 100644 --- a/packages/grid-layouts/src/hooks/useComprehensive.ts +++ b/packages/grid-layouts/src/hooks/useComprehensive.ts @@ -1,20 +1,47 @@ import { useMenuSettingStore } from '../store/modules/menuSetting' import { computed } from 'vue' +import { + useHeaderSettingStore, + useMultiTabsSettingStore, + useSporadicSettingStore, +} from '../store' export const useComprehensive = () => { const menuSettingStore = useMenuSettingStore() + const headerSettingStore = useHeaderSettingStore() + const multipleTabStore = useMultiTabsSettingStore() + const sporadicSettingStore = useSporadicSettingStore() const getLayoutStyles = computed(() => { - let asideWidth = menuSettingStore.width + const getAsideWidth = () => { + if (menuSettingStore.isMixSidebar) return menuSettingStore.mixSidebarWidth + if (menuSettingStore.collapsed) return menuSettingStore.collapsedWidth + if (menuSettingStore.isTopMenu || menuSettingStore.hidden) return 0 + return menuSettingStore.width + } + + const getHeaderHeight = () => { + if (headerSettingStore.hidden) return 0 + return headerSettingStore.height + } - if (menuSettingStore.isMixSidebar) - asideWidth = menuSettingStore.mixSidebarWidth - if (menuSettingStore.collapsed) asideWidth = menuSettingStore.collapsedWidth - if (menuSettingStore.isTopMenu) asideWidth = 0 + const getTabBarHeight = () => { + if (multipleTabStore.hidden) return 0 + return multipleTabStore.height + } + + const getFooterHeight = () => { + if (sporadicSettingStore.hiddenFooter) return 0 + return sporadicSettingStore.footerHeight + } return { - '--aside-width': asideWidth + 'px', + '--aside-width': `${getAsideWidth()}px`, + '--header-height': `${getHeaderHeight()}px`, + '--tab-bar-height': `${getTabBarHeight()}px`, + '--footer-height': `${getFooterHeight()}px`, } }) + return { getLayoutStyles, } diff --git a/packages/grid-layouts/src/store/modules/headerSetting.ts b/packages/grid-layouts/src/store/modules/headerSetting.ts index 131a506d..c53ff3be 100644 --- a/packages/grid-layouts/src/store/modules/headerSetting.ts +++ b/packages/grid-layouts/src/store/modules/headerSetting.ts @@ -12,6 +12,8 @@ export const useHeaderSettingStore = defineStore({ fixed: true, // Whether to show top show: true, + // Whether to show dom + hidden: false, // theme theme: ThemeEnum.LIGHT, // Whether to enable the lock screen function @@ -25,6 +27,7 @@ export const useHeaderSettingStore = defineStore({ // Whether to display the menu search showSearch: true, showLocalePicker: true, + height: 48, }), getters: { isDark: (state) => state.theme === ThemeEnum.DARK, @@ -38,6 +41,10 @@ export const useHeaderSettingStore = defineStore({ }, setShow(value: boolean) { this.show = value + this.setHidden(!value) + }, + setHidden(value: boolean) { + this.hidden = value }, setTheme(value: ThemeEnum) { this.theme = value diff --git a/packages/grid-layouts/src/store/modules/menuSetting.ts b/packages/grid-layouts/src/store/modules/menuSetting.ts index e3bf7569..94871911 100644 --- a/packages/grid-layouts/src/store/modules/menuSetting.ts +++ b/packages/grid-layouts/src/store/modules/menuSetting.ts @@ -111,6 +111,7 @@ export const useMenuSettingStore = defineStore({ }, setShow(value: boolean) { this.show = value + this.setHidden(!value) }, setHidden(value: boolean) { this.hidden = value diff --git a/packages/grid-layouts/src/store/modules/multiTabsSetting.ts b/packages/grid-layouts/src/store/modules/multiTabsSetting.ts index 36a77173..bc21de84 100644 --- a/packages/grid-layouts/src/store/modules/multiTabsSetting.ts +++ b/packages/grid-layouts/src/store/modules/multiTabsSetting.ts @@ -7,7 +7,8 @@ export const useMultiTabsSettingStore = defineStore({ state: (): MultiTabsSetting => ({ cache: false, // Turn on - show: true, + show: true, // Turn on + hidden: false, // Is it possible to drag and drop sorting tabs canDrag: true, // Turn on quick actions @@ -16,6 +17,7 @@ export const useMultiTabsSettingStore = defineStore({ showRedo: true, // Whether to show the collapse button showFold: true, + height: 36, }), getters: {}, actions: { @@ -24,6 +26,10 @@ export const useMultiTabsSettingStore = defineStore({ }, setShow(value: boolean) { this.show = value + this.hidden = !value + }, + setHidden(value: boolean) { + this.hidden = value }, setCanDrag(value: boolean) { this.canDrag = value diff --git a/packages/grid-layouts/src/store/modules/sporadicSetting.ts b/packages/grid-layouts/src/store/modules/sporadicSetting.ts index 1608019f..f3c891f8 100644 --- a/packages/grid-layouts/src/store/modules/sporadicSetting.ts +++ b/packages/grid-layouts/src/store/modules/sporadicSetting.ts @@ -40,6 +40,8 @@ export const useSporadicSettingStore = defineStore({ showLogo: true, // Whether to show footer showFooter: false, + hiddenFooter: true, + footerHeight: 60, // Whether to open the top progress bar openNProgress: false, // Whether to enable KeepAlive cache is best to close during development, otherwise the cache needs to be cleared every time @@ -106,6 +108,10 @@ export const useSporadicSettingStore = defineStore({ }, setShowFooter(value: boolean) { this.showFooter = value + this.setHiddenFooter(!value) + }, + setHiddenFooter(value: boolean) { + this.hiddenFooter = value }, setOpenNProgress(value: boolean) { this.openNProgress = value diff --git a/packages/styles/src/variables.css b/packages/styles/src/variables.css index 561398ed..69a5dd8d 100644 --- a/packages/styles/src/variables.css +++ b/packages/styles/src/variables.css @@ -24,8 +24,8 @@ --header-width: calc(100% - var(--aside-width)); /* tab */ - --tab-height: 36px; - --tab-width: calc(100% - var(--aside-width)); + --tab-bar-height: 36px; + --tab-bar-width: calc(100% - var(--aside-width)); /* aside */ --aside-height: calc(100% - var(--header-height)); diff --git a/packages/types/src/setting.ts b/packages/types/src/setting.ts index e374f950..e40ee86c 100644 --- a/packages/types/src/setting.ts +++ b/packages/types/src/setting.ts @@ -41,16 +41,19 @@ export interface MenuSetting { export interface MultiTabsSetting { cache: boolean show: boolean + hidden: boolean showQuick: boolean canDrag: boolean showRedo: boolean showFold: boolean + readonly height: number } export interface HeaderSetting { bgColor: string fixed: boolean show: boolean + hidden: boolean theme: ThemeEnum // Turn on full screen showFullScreen: boolean @@ -62,6 +65,7 @@ export interface HeaderSetting { showNotice: boolean showSearch: boolean showLocalePicker: boolean + readonly height: number } export interface LocaleSetting { @@ -133,6 +137,8 @@ export interface SporadicSetting { showLogo: boolean // Whether to show the global footer showFooter: boolean + hiddenFooter: boolean + readonly footerHeight: number } export interface ProjectConfig extends SporadicSetting { From 74d3ab09f85af218f29c8835be7c95cde96d6438 Mon Sep 17 00:00:00 2001 From: h_mo <596417202@qq.com> Date: Mon, 6 Feb 2023 23:59:51 +0800 Subject: [PATCH 12/22] pref: grid-layout setting --- .../components/composables/LayoutFooter.vue | 2 +- .../components/composables/LayoutHeader.vue | 4 ++- .../components/composables/LayoutSidebar.vue | 13 ++++--- .../src/components/logo/index.vue | 36 +++++++++++++++---- .../setting/components/Features.vue | 2 +- .../src/components/tab-bar/FoldButton.vue | 2 +- .../src/components/tab-bar/TabQuick.vue | 2 +- .../src/components/tab-bar/TabRedo.vue | 2 +- .../src/components/trigger/HeaderTrigger.vue | 2 +- .../src/components/trigger/inedx.vue | 5 ++- .../src/hooks/useComprehensive.ts | 21 +++++++++-- 11 files changed, 71 insertions(+), 20 deletions(-) diff --git a/packages/grid-layouts/src/components/composables/LayoutFooter.vue b/packages/grid-layouts/src/components/composables/LayoutFooter.vue index cc8370ce..e9abcb83 100644 --- a/packages/grid-layouts/src/components/composables/LayoutFooter.vue +++ b/packages/grid-layouts/src/components/composables/LayoutFooter.vue @@ -6,7 +6,7 @@ const { hiddenFooter } = storeToRefs(useSporadicSettingStore())