xto-fronted 0.4.18 → 0.4.20
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.
- package/dist/{index-DmjW2npo.js → index-3zeoNaqT.js} +1 -1
- package/dist/{index-C2LrtpQb.js → index-BHZ_y8lp.js} +747 -732
- package/dist/{index-DK5nOrQA.js → index-BK8qDl14.js} +1 -1
- package/dist/{index-D6SM8jcQ.js → index-BNBv_FCu.js} +1 -1
- package/dist/index-BNwtCm83.js +345 -0
- package/dist/{index--Urjal10.js → index-CUAC0ZFB.js} +1 -1
- package/dist/index-CVMV9Tfg.js +142 -0
- package/dist/index-CbEIzXG9.js +475 -0
- package/dist/index-Do7uXDSi.js +2071 -0
- package/dist/index-DzerABZq.js +372 -0
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/stores/app.d.ts +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/Layout/Header.vue +61 -5
- package/src/components/Layout/index.vue +120 -104
- package/src/stores/app.ts +162 -180
package/src/stores/app.ts
CHANGED
|
@@ -1,181 +1,163 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 应用状态
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { defineStore } from 'pinia'
|
|
6
|
-
import { ref, computed, watch } from 'vue'
|
|
7
|
-
import { local } from '@/utils/storage'
|
|
8
|
-
|
|
9
|
-
export type ThemeMode = 'light' | 'dark'
|
|
10
|
-
export type LayoutMode = 'sidebar' | 'top'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
local.set('
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
//
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
//
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
//
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
primaryColor,
|
|
164
|
-
cachedViews,
|
|
165
|
-
themeClass,
|
|
166
|
-
setAppName,
|
|
167
|
-
setIndexPath,
|
|
168
|
-
toggleTheme,
|
|
169
|
-
toggleCollapse,
|
|
170
|
-
setTheme,
|
|
171
|
-
setLayout,
|
|
172
|
-
toggleTabs,
|
|
173
|
-
toggleFooter,
|
|
174
|
-
toggleBreadcrumb,
|
|
175
|
-
setPrimaryColor,
|
|
176
|
-
addCachedView,
|
|
177
|
-
removeCachedView,
|
|
178
|
-
clearCachedViews,
|
|
179
|
-
initTheme
|
|
180
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 应用状态
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { defineStore } from 'pinia'
|
|
6
|
+
import { ref, computed, watch } from 'vue'
|
|
7
|
+
import { local } from '@/utils/storage'
|
|
8
|
+
|
|
9
|
+
export type ThemeMode = 'light' | 'dark'
|
|
10
|
+
export type LayoutMode = 'sidebar' | 'top' | 'mix'
|
|
11
|
+
|
|
12
|
+
export const useAppStore = defineStore('app', () => {
|
|
13
|
+
// 状态
|
|
14
|
+
const appName = ref<string>(local.get<string>('appName') || 'XTO App')
|
|
15
|
+
const indexPath = ref<string>(local.get<string>('indexPath') || '/dashboard')
|
|
16
|
+
const isDark = ref<boolean>(local.get<boolean>('isDark') || false)
|
|
17
|
+
const theme = ref<ThemeMode>(local.get<ThemeMode>('theme') || 'light')
|
|
18
|
+
const layout = ref<LayoutMode>(local.get<LayoutMode>('layout') || 'sidebar')
|
|
19
|
+
const isCollapsed = ref<boolean>(local.get<boolean>('isCollapsed') || false)
|
|
20
|
+
const showTabs = ref<boolean>(local.get<boolean>('showTabs') ?? true)
|
|
21
|
+
const showFooter = ref<boolean>(local.get<boolean>('showFooter') ?? true)
|
|
22
|
+
const showBreadcrumb = ref<boolean>(local.get<boolean>('showBreadcrumb') ?? true)
|
|
23
|
+
const primaryColor = ref<string>(local.get<string>('primaryColor') || '#409eff')
|
|
24
|
+
const cachedViews = ref<string[]>([])
|
|
25
|
+
|
|
26
|
+
// 计算属性
|
|
27
|
+
const themeClass = computed(() => (isDark.value ? 'dark' : 'light'))
|
|
28
|
+
|
|
29
|
+
// 设置应用名称
|
|
30
|
+
const setAppName = (name: string) => {
|
|
31
|
+
appName.value = name
|
|
32
|
+
local.set('appName', name)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 设置默认首页路径
|
|
36
|
+
const setIndexPath = (path: string) => {
|
|
37
|
+
indexPath.value = path
|
|
38
|
+
local.set('indexPath', path)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 切换主题
|
|
42
|
+
const toggleTheme = () => {
|
|
43
|
+
isDark.value = !isDark.value
|
|
44
|
+
theme.value = isDark.value ? 'dark' : 'light'
|
|
45
|
+
updateTheme()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 设置主题
|
|
49
|
+
const setTheme = (mode: ThemeMode) => {
|
|
50
|
+
theme.value = mode
|
|
51
|
+
isDark.value = mode === 'dark'
|
|
52
|
+
updateTheme()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 更新主题
|
|
56
|
+
const updateTheme = () => {
|
|
57
|
+
const html = document.documentElement
|
|
58
|
+
if (isDark.value) {
|
|
59
|
+
html.classList.add('dark')
|
|
60
|
+
} else {
|
|
61
|
+
html.classList.remove('dark')
|
|
62
|
+
}
|
|
63
|
+
local.set('isDark', isDark.value)
|
|
64
|
+
local.set('theme', theme.value)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 切换菜单折叠
|
|
68
|
+
const toggleCollapse = () => {
|
|
69
|
+
isCollapsed.value = !isCollapsed.value
|
|
70
|
+
local.set('isCollapsed', isCollapsed.value)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 设置布局
|
|
74
|
+
const setLayout = (mode: LayoutMode) => {
|
|
75
|
+
layout.value = mode
|
|
76
|
+
local.set('layout', mode)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 切换标签页
|
|
80
|
+
const toggleTabs = () => {
|
|
81
|
+
showTabs.value = !showTabs.value
|
|
82
|
+
local.set('showTabs', showTabs.value)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// 切换底部
|
|
86
|
+
const toggleFooter = () => {
|
|
87
|
+
showFooter.value = !showFooter.value
|
|
88
|
+
local.set('showFooter', showFooter.value)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 切换面包屑
|
|
92
|
+
const toggleBreadcrumb = () => {
|
|
93
|
+
showBreadcrumb.value = !showBreadcrumb.value
|
|
94
|
+
local.set('showBreadcrumb', showBreadcrumb.value)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 设置主题色
|
|
98
|
+
const setPrimaryColor = (color: string) => {
|
|
99
|
+
primaryColor.value = color
|
|
100
|
+
document.documentElement.style.setProperty('--color-primary', color)
|
|
101
|
+
local.set('primaryColor', color)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// 添加缓存页面
|
|
105
|
+
const addCachedView = (name: string) => {
|
|
106
|
+
if (!cachedViews.value.includes(name)) {
|
|
107
|
+
cachedViews.value.push(name)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 移除缓存页面
|
|
112
|
+
const removeCachedView = (name: string) => {
|
|
113
|
+
const index = cachedViews.value.indexOf(name)
|
|
114
|
+
if (index > -1) {
|
|
115
|
+
cachedViews.value.splice(index, 1)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 清除缓存页面
|
|
120
|
+
const clearCachedViews = () => {
|
|
121
|
+
cachedViews.value = []
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 初始化主题
|
|
125
|
+
const initTheme = () => {
|
|
126
|
+
updateTheme()
|
|
127
|
+
if (primaryColor.value !== '#409eff') {
|
|
128
|
+
document.documentElement.style.setProperty('--color-primary', primaryColor.value)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// 监听主题变化
|
|
133
|
+
watch(isDark, updateTheme)
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
appName,
|
|
137
|
+
indexPath,
|
|
138
|
+
isDark,
|
|
139
|
+
theme,
|
|
140
|
+
layout,
|
|
141
|
+
isCollapsed,
|
|
142
|
+
showTabs,
|
|
143
|
+
showFooter,
|
|
144
|
+
showBreadcrumb,
|
|
145
|
+
primaryColor,
|
|
146
|
+
cachedViews,
|
|
147
|
+
themeClass,
|
|
148
|
+
setAppName,
|
|
149
|
+
setIndexPath,
|
|
150
|
+
toggleTheme,
|
|
151
|
+
toggleCollapse,
|
|
152
|
+
setTheme,
|
|
153
|
+
setLayout,
|
|
154
|
+
toggleTabs,
|
|
155
|
+
toggleFooter,
|
|
156
|
+
toggleBreadcrumb,
|
|
157
|
+
setPrimaryColor,
|
|
158
|
+
addCachedView,
|
|
159
|
+
removeCachedView,
|
|
160
|
+
clearCachedViews,
|
|
161
|
+
initTheme
|
|
162
|
+
}
|
|
181
163
|
})
|