Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: project default setting structure was not correct (#240)
Browse files Browse the repository at this point in the history
* chore: update project setting preset

* Update project.ts

* Update useAppConfig.ts
  • Loading branch information
likui628 authored Nov 1, 2023
1 parent e4f6a7e commit ec1989e
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 153 deletions.
7 changes: 0 additions & 7 deletions apps/admin/src/init-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { initRequest } from '@vben/request'
import { useUserStoreWithout, useUserStore } from '@/store/user'
import { useI18n, useLocale } from '@vben/locale'
import { getGlobalConfig } from '@vben/utils'
import { useConfigStore } from '@/store/config'
import { projectSetting } from './setting'
import { initComp } from '@vben/vbencomponents'
import { initLayout } from '@vben/layouts'
Expand Down Expand Up @@ -83,7 +82,6 @@ async function initPackages() {
useLocale,
localeList,
useAppStore,
useConfigStore,
}
})
}
Expand All @@ -105,7 +103,6 @@ async function initPackages() {
listenerRouteChange,
useUserStore,
useAppStore,
useConfigStore,
Logo,
useMenuSetting,
useMultipleTabSetting,
Expand All @@ -122,10 +119,6 @@ async function initPackages() {

// Initial project configuration
function initAppConfigStore() {
// const configStore = useConfigStoreWithOut()
// const projectConfig = unref(configStore.getProjectConfig)
// const projCfg = deepMerge(projectSetting, projectConfig || {})
// configStore.setProjectConfig(projCfg)
const appConfig = useAppConfig()
appConfig.setAppConfig(projectSetting)
}
Expand Down
219 changes: 76 additions & 143 deletions apps/admin/src/setting/project.ts
Original file line number Diff line number Diff line change
@@ -1,181 +1,114 @@
import { ProjectConfig } from '@vben/types'
import { DefineAppConfigOptions } from '@vben/types'
import {
CacheTypeEnum,
ContentLayoutEnum,
MenuModeEnum,
MixSidebarTriggerEnum,
NavBarModeEnum,
PermissionModeEnum,
RouterTransitionEnum,
SessionTimeoutProcessingEnum,
SettingButtonPositionEnum,
ThemeEnum,
TriggerEnum,
RouterTransitionEnum,
} from '@vben/constants'

import {
SIDE_BAR_BG_COLOR_LIST,
HEADER_PRESET_BG_COLOR_LIST,
primaryColor,
SIDE_BAR_BG_COLOR_LIST,
} from './design'

// ! You need to clear the browser cache after the change
export const projectSetting: ProjectConfig = {
// Whether to show the configuration button
showSettingButton: true,

// Whether to show the theme switch button
showDarkModeToggle: true,

// `Settings` button position
export const projectSetting: DefineAppConfigOptions = {
theme: ThemeEnum.LIGHT,
navBarMode: NavBarModeEnum.SIDEBAR,
themeColor: primaryColor,
showThemeModeToggle: true,
openKeepAlive: true,
useOpenBackTop: true,
closeMessageOnSwitch: false,
removeAllHttpPending: true,
permissionCacheType: CacheTypeEnum.LOCAL,
settingButtonPosition: SettingButtonPositionEnum.AUTO,

// Permission mode
permissionMode: PermissionModeEnum.ROUTE_MAPPING,
// permissionMode: PermissionModeEnum.BACK,

// Permission-related cache is stored in sessionStorage or localStorage
permissionCacheType: CacheTypeEnum.LOCAL,

// Session timeout processing
sessionTimeoutProcessing: SessionTimeoutProcessingEnum.ROUTE_JUMP,

// color
themeColor: primaryColor,

// 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,

// Header configuration
headerSetting: {
// header bg color
bgColor: HEADER_PRESET_BG_COLOR_LIST[0],
// Fixed at the top
fixed: true,
// Whether to show top
lockTime: 0,
useLockPage: false,
canEmbedIFramePage: true,
closeMixSidebarOnChange: false,
openSettingDrawer: false,
sidebar: {
theme: ThemeEnum.LIGHT,
show: true,
visible: true,
bgColor: SIDE_BAR_BG_COLOR_LIST[0],
fixed: false,
width: 210,
mixSidebarWidth: 80,
collapsedWidth: 48,
collapsed: false,
trigger: TriggerEnum.CENTER,
},
menu: {
show: true,
// theme
canDrag: false,
split: false,
mode: MenuModeEnum.VERTICAL,
accordion: false,
collapsedShowTitle: false,
mixSideTrigger: MixSidebarTriggerEnum.CLICK,
mixSideFixed: false,
topMenuAlign: 'start',
dropdownPlacement: 'top-start',
subMenuWidth: 0,
},
header: {
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
show: true,
visible: true,
bgColor: HEADER_PRESET_BG_COLOR_LIST[0],
fixed: false,
height: 48,
showDoc: true,
// Whether to show the notification button
showBreadCrumb: true,
showBreadCrumbIcon: true,
showFullScreen: true,
showNotice: true,
// Whether to display the menu search
showSearch: true,
showLocalePicker: true,
showSetting: true,
},

// Menu configuration
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
logo: {
show: true,
// Menu width
menuWidth: 210,
// Menu mode
mode: MenuModeEnum.INLINE,
// 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,
visible: true,
showTitle: true,
},
tabTar: {
show: true,
visible: true,
height: 36,
cache: true,
canDrag: false,
showFold: true,
showQuick: true,
showRedo: true,
},
// Transition Setting
transitionSetting: {
// Whether to open the page switching animation
// The disabled state will also disable pageLoading
content: {
fullScreen: false,
mode: ContentLayoutEnum.FULL,
},
footer: {
height: 60,
show: false,
visible: false,
},
transition: {
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,
},

// Multi-label
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,
},

// 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,
}
2 changes: 1 addition & 1 deletion packages/constants/src/appEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export enum PermissionModeEnum {
export enum RouterTransitionEnum {
ZOOM_FADE = 'zoom-fade',
ZOOM_OUT = 'zoom-out',
FADE_SIDE = 'fade-slide',
FADE_SIDE = 'fade-side',
FADE = 'fade',
FADE_BOTTOM = 'fade-bottom',
FADE_SCALE = 'fade-scale',
Expand Down
2 changes: 0 additions & 2 deletions packages/layouts/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export interface ContextOptions {
useAppConfig: typeof useAppConfig
useRootSetting: typeof useRootSetting
useAppStore: () => unknown
useConfigStore: () => unknown
useHeaderSetting: typeof useHeaderSetting
useTabs: typeof useTabs
useUserStore: () => unknown
Expand Down Expand Up @@ -49,7 +48,6 @@ export let context: ContextOptions = {
useAppConfig,
useRootSetting,
useAppStore: () => undefined,
useConfigStore: () => undefined,
useUserStore: () => undefined,
useHeaderSetting,
useMenuSetting,
Expand Down

0 comments on commit ec1989e

Please sign in to comment.