xto-fronted 0.4.16 → 0.4.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ import { useMenuStore } from '@/stores/menu'
8
8
  import { Icon } from '@xto/base'
9
9
  import { Drawer } from '@xto/feedback'
10
10
 
11
- type LayoutMode = 'sidebar' | 'top' | 'mix'
11
+ type LayoutMode = 'sidebar' | 'top'
12
12
 
13
13
  const route = useRoute()
14
14
  const router = useRouter()
@@ -31,8 +31,7 @@ const greyMode = ref(false)
31
31
  // 布局模式选项
32
32
  const layoutOptions: { value: LayoutMode; label: string; icon: string }[] = [
33
33
  { value: 'sidebar', label: '左侧菜单', icon: 'sidebar-left' },
34
- { value: 'top', label: '顶部菜单', icon: 'menu' },
35
- { value: 'mix', label: '混合菜单', icon: 'grid' }
34
+ { value: 'top', label: '顶部菜单', icon: 'menu' }
36
35
  ]
37
36
 
38
37
  // 主题色选项
@@ -364,19 +363,10 @@ onUnmounted(() => {
364
363
  <div class="preview-content"></div>
365
364
  </div>
366
365
  </div>
367
- <div v-else-if="option.value === 'top'" class="layout-preview-top">
366
+ <div v-else class="layout-preview-top">
368
367
  <div class="preview-header-full"></div>
369
368
  <div class="preview-content-full"></div>
370
369
  </div>
371
- <div v-else class="layout-preview-mix">
372
- <div class="preview-header-mix">
373
- <div class="preview-mix-left"></div>
374
- </div>
375
- <div class="preview-mix-body">
376
- <div class="preview-mix-aside"></div>
377
- <div class="preview-mix-content"></div>
378
- </div>
379
- </div>
380
370
  </div>
381
371
  <span class="layout-option__label">{{ option.label }}</span>
382
372
  </div>
@@ -831,38 +821,6 @@ onUnmounted(() => {
831
821
  }
832
822
  }
833
823
 
834
- .layout-preview-mix {
835
- display: flex;
836
- flex-direction: column;
837
- height: 100%;
838
-
839
- .preview-header-mix {
840
- height: 25%;
841
- background-color: var(--color-primary-light-7);
842
- display: flex;
843
-
844
- .preview-mix-left {
845
- width: 30%;
846
- background-color: var(--color-primary);
847
- }
848
- }
849
-
850
- .preview-mix-body {
851
- flex: 1;
852
- display: flex;
853
-
854
- .preview-mix-aside {
855
- width: 25%;
856
- background-color: var(--color-primary-light-8);
857
- }
858
-
859
- .preview-mix-content {
860
- flex: 1;
861
- background-color: var(--bg-color-page);
862
- }
863
- }
864
- }
865
-
866
824
  .settings-color-options {
867
825
  display: flex;
868
826
  gap: 12px;
package/src/stores/app.ts CHANGED
@@ -7,7 +7,10 @@ import { ref, computed, watch } from 'vue'
7
7
  import { local } from '@/utils/storage'
8
8
 
9
9
  export type ThemeMode = 'light' | 'dark'
10
- export type LayoutMode = 'sidebar' | 'top' | 'mix'
10
+ export type LayoutMode = 'sidebar' | 'top'
11
+
12
+ // 支持的布局模式列表
13
+ const SUPPORTED_LAYOUTS: LayoutMode[] = ['sidebar', 'top']
11
14
 
12
15
  export const useAppStore = defineStore('app', () => {
13
16
  // 状态
@@ -15,7 +18,14 @@ export const useAppStore = defineStore('app', () => {
15
18
  const indexPath = ref<string>(local.get<string>('indexPath') || '/dashboard')
16
19
  const isDark = ref<boolean>(local.get<boolean>('isDark') || false)
17
20
  const theme = ref<ThemeMode>(local.get<ThemeMode>('theme') || 'light')
18
- const layout = ref<LayoutMode>(local.get<LayoutMode>('layout') || 'sidebar')
21
+
22
+ // 布局模式:读取localStorage,如果是不支持的值则默认sidebar
23
+ const savedLayout = local.get<string>('layout')
24
+ const layout = ref<LayoutMode>(
25
+ SUPPORTED_LAYOUTS.includes(savedLayout as LayoutMode)
26
+ ? (savedLayout as LayoutMode)
27
+ : 'sidebar'
28
+ )
19
29
  const isCollapsed = ref<boolean>(local.get<boolean>('isCollapsed') || false)
20
30
  const showTabs = ref<boolean>(local.get<boolean>('showTabs') ?? true)
21
31
  const showFooter = ref<boolean>(local.get<boolean>('showFooter') ?? true)
@@ -72,6 +82,9 @@ export const useAppStore = defineStore('app', () => {
72
82
 
73
83
  // 设置布局
74
84
  const setLayout = (mode: LayoutMode) => {
85
+ if (!SUPPORTED_LAYOUTS.includes(mode)) {
86
+ mode = 'sidebar'
87
+ }
75
88
  layout.value = mode
76
89
  local.set('layout', mode)
77
90
  }
@@ -127,6 +140,11 @@ export const useAppStore = defineStore('app', () => {
127
140
  if (primaryColor.value !== '#409eff') {
128
141
  document.documentElement.style.setProperty('--color-primary', primaryColor.value)
129
142
  }
143
+ // 清除无效的layout设置,确保使用支持的布局模式
144
+ if (!SUPPORTED_LAYOUTS.includes(layout.value)) {
145
+ layout.value = 'sidebar'
146
+ local.set('layout', 'sidebar')
147
+ }
130
148
  }
131
149
 
132
150
  // 监听主题变化