xto-fronted 0.4.92 → 0.4.94
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/assets/404-C9Uh6Uu-.css +1 -0
- package/dist/assets/404-zjGLLssH.js +1 -0
- package/dist/assets/_plugin-vue_export-helper-DlAUqK2U.js +1 -0
- package/dist/assets/index-B5xc4gQB.css +1 -0
- package/dist/assets/index-BDgOY6Rp.js +1 -0
- package/dist/assets/index-BIoRANs0.js +1 -0
- package/dist/assets/index-BRR97dc6.js +1 -0
- package/dist/assets/index-Bz0BgZQ1.js +1 -0
- package/dist/assets/index-CAdztNsv.css +1 -0
- package/dist/assets/index-CCXrcISf.css +1 -0
- package/dist/assets/index-CfpZmcpk.css +1 -0
- package/dist/assets/index-CwJSA85U.js +1 -0
- package/dist/assets/index-CwRA10ac.js +1 -0
- package/dist/assets/index-D8NDxq9d.js +1 -0
- package/dist/assets/index-DEB6-Iv_.js +2 -0
- package/dist/assets/index-DM4Ezclc.css +1 -0
- package/dist/assets/index-DYv7nImj.css +1 -0
- package/dist/assets/index-t-2Y0KhA.css +1 -0
- package/dist/assets/vendor-CUVPinTg.js +13 -0
- package/dist/assets/vue-vendor-DeJXJVbN.js +29 -0
- package/dist/assets/xto-base-CL2NKZJJ.css +1 -0
- package/dist/assets/xto-base-PwLGsxxb.js +1 -0
- package/dist/assets/xto-business--V1F5Gwb.css +1 -0
- package/dist/assets/xto-core-CtL4zKiV.js +1 -0
- package/dist/assets/xto-data-MxZsiJgi.css +1 -0
- package/dist/assets/xto-data-bCXQa7fT.js +1 -0
- package/dist/assets/xto-feedback-Bxx38c3P.css +1 -0
- package/dist/assets/xto-feedback-CPydp0kn.js +1 -0
- package/dist/assets/xto-form-Cu6q3VLG.css +1 -0
- package/dist/assets/xto-form-bywohdAf.js +1 -0
- package/dist/assets/xto-layout-BDD6sSlM.css +1 -0
- package/dist/assets/xto-navigation-Bbdpine9.js +1 -0
- package/dist/assets/xto-navigation-XfpyMpEo.css +1 -0
- package/dist/{index-CsjBlLrl.js → index-3ekBp4iW.js} +2 -2
- package/dist/{index-CvYIvRSW.js → index-58aI1w0v.js} +2 -2
- package/dist/{index--qRfsJ32.js → index-A_B_Ap_A.js} +1510 -1537
- package/dist/{index-DAPLMrmP.js → index-B5DLfOYb.js} +23 -23
- package/dist/index-BAmYUT0G.js +189 -0
- package/dist/index-BRvi9qW-.js +515 -0
- package/dist/index-BVGW4DDQ.js +189 -0
- package/dist/index-Bmf0YbVq.js +189 -0
- package/dist/index-C2-a5KSQ.js +4233 -0
- package/dist/{index-DjkSMw-x.js → index-CeZ0CSSs.js} +2 -2
- package/dist/index-Cf8E7FM1.js +4270 -0
- package/dist/index-ChowNrlU.js +641 -0
- package/dist/index-D25KzR0I.js +479 -0
- package/dist/index-DCBIjLHy.js +515 -0
- package/dist/index-DEYOivza.js +641 -0
- package/dist/index-DReodgBw.js +4233 -0
- package/dist/index-DjERNRXX.js +515 -0
- package/dist/index-LSdsO2Ox.js +479 -0
- package/dist/index-gBlRG4kk.js +479 -0
- package/dist/index-xWU3J3OH.js +641 -0
- package/dist/index.es.js +1 -1
- package/dist/index.html +28 -0
- package/dist/index.umd.js +8 -8
- package/dist/style.css +1 -1
- package/package.json +91 -91
- package/src/App.vue +48 -48
- package/src/assets/styles/_dark.scss +639 -639
- package/src/assets/styles/_root.scss +183 -183
- package/src/assets/styles/_variables.scss +69 -69
- package/src/assets/styles/index.scss +460 -460
- package/src/components/Layout/MixTopMenu.vue +4 -1
- package/src/components/Layout/Sidebar.vue +201 -198
- package/src/components/Layout/SidebarMenuItem.vue +158 -158
- package/src/components/Layout/TopMenu.vue +1173 -1170
- package/src/components/Layout/index.vue +192 -192
- package/src/composables/useI18n.ts +43 -43
- package/src/index.ts +100 -100
- package/src/router/layoutRoute.ts +59 -59
- package/src/stores/index.ts +15 -15
- package/src/stores/locale.ts +66 -66
- package/src/types/json-bigint.d.ts +18 -18
- package/src/types/xto.d.ts +172 -172
- package/src/utils/request.ts +184 -184
- package/src/views/dashboard/index.vue +545 -545
- package/src/views/error/403.vue +251 -251
- package/src/views/error/404.vue +253 -253
- package/src/views/login/index.vue +586 -586
- package/src/views/system/menu/index.vue +690 -690
- package/src/views/system/role/index.vue +583 -583
- package/src/views/system/user/index.vue +655 -655
|
@@ -1,193 +1,193 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed } from 'vue'
|
|
3
|
-
import { useAppStore } from '@/stores/app'
|
|
4
|
-
import { useMenuStore } from '@/stores/menu'
|
|
5
|
-
import Sidebar from './Sidebar.vue'
|
|
6
|
-
import Header from './Header.vue'
|
|
7
|
-
import TopMenu from './TopMenu.vue'
|
|
8
|
-
import MixTopMenu from './MixTopMenu.vue'
|
|
9
|
-
|
|
10
|
-
const appStore = useAppStore()
|
|
11
|
-
const menuStore = useMenuStore()
|
|
12
|
-
|
|
13
|
-
const sidebarWidth = computed(() =>
|
|
14
|
-
appStore.isCollapsed ? '64px' : '210px'
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
// 布局模式
|
|
18
|
-
const layoutMode = computed(() => appStore.layout)
|
|
19
|
-
|
|
20
|
-
// 是否显示混合模式(mix模式)
|
|
21
|
-
const isMixMode = computed(() => layoutMode.value === 'mix')
|
|
22
|
-
|
|
23
|
-
// 左侧菜单数据
|
|
24
|
-
// sidebar模式:显示全部菜单
|
|
25
|
-
// mix模式:显示当前选中一级菜单的子菜单
|
|
26
|
-
const sidebarMenuList = computed(() => {
|
|
27
|
-
if (layoutMode.value === 'sidebar') {
|
|
28
|
-
return menuStore.menuList
|
|
29
|
-
} else if (layoutMode.value === 'mix') {
|
|
30
|
-
// mix模式下显示当前选中一级菜单的子菜单
|
|
31
|
-
return appStore.mixSubMenus
|
|
32
|
-
}
|
|
33
|
-
return []
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
// mix模式下是否显示左侧菜单(有子菜单时才显示)
|
|
37
|
-
const showMixSidebar = computed(() => {
|
|
38
|
-
if (!isMixMode.value) return false
|
|
39
|
-
return sidebarMenuList.value.length > 0
|
|
40
|
-
})
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
<template>
|
|
44
|
-
<!-- sidebar模式:左侧菜单 + 顶部Header + 主内容 -->
|
|
45
|
-
<div v-if="layoutMode === 'sidebar'" class="layout layout--sidebar">
|
|
46
|
-
<aside class="layout__aside" :style="{ width: sidebarWidth }">
|
|
47
|
-
<Sidebar :menu-list="sidebarMenuList" :show-logo="true" :show-user="true" />
|
|
48
|
-
</aside>
|
|
49
|
-
<div class="layout__main">
|
|
50
|
-
<header class="layout__header">
|
|
51
|
-
<Header />
|
|
52
|
-
</header>
|
|
53
|
-
<main class="layout__content">
|
|
54
|
-
<router-view />
|
|
55
|
-
</main>
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
|
|
59
|
-
<!-- top模式:顶部菜单 + 主内容 -->
|
|
60
|
-
<div v-if="layoutMode === 'top'" class="layout layout--top">
|
|
61
|
-
<div class="layout__top-menu">
|
|
62
|
-
<TopMenu />
|
|
63
|
-
</div>
|
|
64
|
-
<div class="layout__main">
|
|
65
|
-
<main class="layout__content">
|
|
66
|
-
<router-view />
|
|
67
|
-
</main>
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
|
|
71
|
-
<!-- mix模式:顶部一级菜单 + (左侧子菜单 + 主内容) -->
|
|
72
|
-
<div v-if="layoutMode === 'mix'" class="layout layout--mix">
|
|
73
|
-
<!-- 顶部一级菜单 -->
|
|
74
|
-
<div class="layout__mix-top-menu">
|
|
75
|
-
<MixTopMenu />
|
|
76
|
-
</div>
|
|
77
|
-
<!-- 下方:左侧子菜单 + 主内容 -->
|
|
78
|
-
<div class="layout__mix-body">
|
|
79
|
-
<aside v-if="showMixSidebar" class="layout__aside" :style="{ width: sidebarWidth }">
|
|
80
|
-
<Sidebar :menu-list="sidebarMenuList" :show-logo="false" :show-user="false" />
|
|
81
|
-
</aside>
|
|
82
|
-
<main class="layout__content">
|
|
83
|
-
<router-view />
|
|
84
|
-
</main>
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
</template>
|
|
88
|
-
|
|
89
|
-
<style lang="scss" scoped>
|
|
90
|
-
.layout {
|
|
91
|
-
display: flex;
|
|
92
|
-
width: 100%;
|
|
93
|
-
height: 100%;
|
|
94
|
-
|
|
95
|
-
// 左侧菜单模式
|
|
96
|
-
&--sidebar {
|
|
97
|
-
flex-direction: row;
|
|
98
|
-
|
|
99
|
-
.layout__aside {
|
|
100
|
-
height: 100%;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.layout__main {
|
|
104
|
-
flex: 1;
|
|
105
|
-
display: flex;
|
|
106
|
-
flex-direction: column;
|
|
107
|
-
height: 100%;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// 顶部菜单模式
|
|
112
|
-
&--top {
|
|
113
|
-
flex-direction: column;
|
|
114
|
-
|
|
115
|
-
.layout__main {
|
|
116
|
-
flex: 1;
|
|
117
|
-
display: flex;
|
|
118
|
-
flex-direction: column;
|
|
119
|
-
height: calc(100% - 50px);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.layout__content {
|
|
123
|
-
flex: 1;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// 混合菜单模式
|
|
128
|
-
&--mix {
|
|
129
|
-
flex-direction: column;
|
|
130
|
-
|
|
131
|
-
.layout__mix-top-menu {
|
|
132
|
-
width: 100%;
|
|
133
|
-
height: 50px;
|
|
134
|
-
background-color: var(--bg-color);
|
|
135
|
-
border-bottom: 1px solid var(--color-border-lighter);
|
|
136
|
-
flex-shrink: 0;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.layout__mix-body {
|
|
140
|
-
flex: 1;
|
|
141
|
-
display: flex;
|
|
142
|
-
flex-direction: row;
|
|
143
|
-
height: calc(100% - 50px);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
&__aside {
|
|
148
|
-
transition: width 0.3s;
|
|
149
|
-
overflow: hidden;
|
|
150
|
-
flex-shrink: 0;
|
|
151
|
-
height: 100%;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
&__top-menu {
|
|
155
|
-
width: 100%;
|
|
156
|
-
height: 50px;
|
|
157
|
-
box-sizing: border-box;
|
|
158
|
-
background-color: var(--bg-color);
|
|
159
|
-
border-bottom: 1px solid var(--color-border-lighter);
|
|
160
|
-
flex-shrink: 0;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
&__mix-top-menu {
|
|
164
|
-
width: 100%;
|
|
165
|
-
height: 50px;
|
|
166
|
-
box-sizing: border-box;
|
|
167
|
-
flex-shrink: 0;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
&__main {
|
|
171
|
-
flex: 1;
|
|
172
|
-
display: flex;
|
|
173
|
-
flex-direction: column;
|
|
174
|
-
overflow: hidden;
|
|
175
|
-
height: 100%;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
&__header {
|
|
179
|
-
height: 50px;
|
|
180
|
-
box-sizing: border-box;
|
|
181
|
-
background-color: var(--bg-color);
|
|
182
|
-
border-bottom: 1px solid var(--color-border-lighter);
|
|
183
|
-
flex-shrink: 0;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
&__content {
|
|
187
|
-
flex: 1;
|
|
188
|
-
overflow: auto;
|
|
189
|
-
background-color: var(--bg-color-page);
|
|
190
|
-
padding: 0;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { useAppStore } from '@/stores/app'
|
|
4
|
+
import { useMenuStore } from '@/stores/menu'
|
|
5
|
+
import Sidebar from './Sidebar.vue'
|
|
6
|
+
import Header from './Header.vue'
|
|
7
|
+
import TopMenu from './TopMenu.vue'
|
|
8
|
+
import MixTopMenu from './MixTopMenu.vue'
|
|
9
|
+
|
|
10
|
+
const appStore = useAppStore()
|
|
11
|
+
const menuStore = useMenuStore()
|
|
12
|
+
|
|
13
|
+
const sidebarWidth = computed(() =>
|
|
14
|
+
appStore.isCollapsed ? '64px' : '210px'
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
// 布局模式
|
|
18
|
+
const layoutMode = computed(() => appStore.layout)
|
|
19
|
+
|
|
20
|
+
// 是否显示混合模式(mix模式)
|
|
21
|
+
const isMixMode = computed(() => layoutMode.value === 'mix')
|
|
22
|
+
|
|
23
|
+
// 左侧菜单数据
|
|
24
|
+
// sidebar模式:显示全部菜单
|
|
25
|
+
// mix模式:显示当前选中一级菜单的子菜单
|
|
26
|
+
const sidebarMenuList = computed(() => {
|
|
27
|
+
if (layoutMode.value === 'sidebar') {
|
|
28
|
+
return menuStore.menuList
|
|
29
|
+
} else if (layoutMode.value === 'mix') {
|
|
30
|
+
// mix模式下显示当前选中一级菜单的子菜单
|
|
31
|
+
return appStore.mixSubMenus
|
|
32
|
+
}
|
|
33
|
+
return []
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
// mix模式下是否显示左侧菜单(有子菜单时才显示)
|
|
37
|
+
const showMixSidebar = computed(() => {
|
|
38
|
+
if (!isMixMode.value) return false
|
|
39
|
+
return sidebarMenuList.value.length > 0
|
|
40
|
+
})
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<template>
|
|
44
|
+
<!-- sidebar模式:左侧菜单 + 顶部Header + 主内容 -->
|
|
45
|
+
<div v-if="layoutMode === 'sidebar'" class="layout layout--sidebar">
|
|
46
|
+
<aside class="layout__aside" :style="{ width: sidebarWidth }">
|
|
47
|
+
<Sidebar :menu-list="sidebarMenuList" :show-logo="true" :show-user="true" />
|
|
48
|
+
</aside>
|
|
49
|
+
<div class="layout__main">
|
|
50
|
+
<header class="layout__header">
|
|
51
|
+
<Header />
|
|
52
|
+
</header>
|
|
53
|
+
<main class="layout__content">
|
|
54
|
+
<router-view />
|
|
55
|
+
</main>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<!-- top模式:顶部菜单 + 主内容 -->
|
|
60
|
+
<div v-if="layoutMode === 'top'" class="layout layout--top">
|
|
61
|
+
<div class="layout__top-menu">
|
|
62
|
+
<TopMenu />
|
|
63
|
+
</div>
|
|
64
|
+
<div class="layout__main">
|
|
65
|
+
<main class="layout__content">
|
|
66
|
+
<router-view />
|
|
67
|
+
</main>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<!-- mix模式:顶部一级菜单 + (左侧子菜单 + 主内容) -->
|
|
72
|
+
<div v-if="layoutMode === 'mix'" class="layout layout--mix">
|
|
73
|
+
<!-- 顶部一级菜单 -->
|
|
74
|
+
<div class="layout__mix-top-menu">
|
|
75
|
+
<MixTopMenu />
|
|
76
|
+
</div>
|
|
77
|
+
<!-- 下方:左侧子菜单 + 主内容 -->
|
|
78
|
+
<div class="layout__mix-body">
|
|
79
|
+
<aside v-if="showMixSidebar" class="layout__aside" :style="{ width: sidebarWidth }">
|
|
80
|
+
<Sidebar :menu-list="sidebarMenuList" :show-logo="false" :show-user="false" />
|
|
81
|
+
</aside>
|
|
82
|
+
<main class="layout__content">
|
|
83
|
+
<router-view />
|
|
84
|
+
</main>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</template>
|
|
88
|
+
|
|
89
|
+
<style lang="scss" scoped>
|
|
90
|
+
.layout {
|
|
91
|
+
display: flex;
|
|
92
|
+
width: 100%;
|
|
93
|
+
height: 100%;
|
|
94
|
+
|
|
95
|
+
// 左侧菜单模式
|
|
96
|
+
&--sidebar {
|
|
97
|
+
flex-direction: row;
|
|
98
|
+
|
|
99
|
+
.layout__aside {
|
|
100
|
+
height: 100%;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.layout__main {
|
|
104
|
+
flex: 1;
|
|
105
|
+
display: flex;
|
|
106
|
+
flex-direction: column;
|
|
107
|
+
height: 100%;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 顶部菜单模式
|
|
112
|
+
&--top {
|
|
113
|
+
flex-direction: column;
|
|
114
|
+
|
|
115
|
+
.layout__main {
|
|
116
|
+
flex: 1;
|
|
117
|
+
display: flex;
|
|
118
|
+
flex-direction: column;
|
|
119
|
+
height: calc(100% - 50px);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.layout__content {
|
|
123
|
+
flex: 1;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// 混合菜单模式
|
|
128
|
+
&--mix {
|
|
129
|
+
flex-direction: column;
|
|
130
|
+
|
|
131
|
+
.layout__mix-top-menu {
|
|
132
|
+
width: 100%;
|
|
133
|
+
height: 50px;
|
|
134
|
+
background-color: var(--bg-color);
|
|
135
|
+
border-bottom: 1px solid var(--color-border-lighter);
|
|
136
|
+
flex-shrink: 0;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.layout__mix-body {
|
|
140
|
+
flex: 1;
|
|
141
|
+
display: flex;
|
|
142
|
+
flex-direction: row;
|
|
143
|
+
height: calc(100% - 50px);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&__aside {
|
|
148
|
+
transition: width 0.3s;
|
|
149
|
+
overflow: hidden;
|
|
150
|
+
flex-shrink: 0;
|
|
151
|
+
height: 100%;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
&__top-menu {
|
|
155
|
+
width: 100%;
|
|
156
|
+
height: 50px;
|
|
157
|
+
box-sizing: border-box;
|
|
158
|
+
background-color: var(--bg-color);
|
|
159
|
+
border-bottom: 1px solid var(--color-border-lighter);
|
|
160
|
+
flex-shrink: 0;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
&__mix-top-menu {
|
|
164
|
+
width: 100%;
|
|
165
|
+
height: 50px;
|
|
166
|
+
box-sizing: border-box;
|
|
167
|
+
flex-shrink: 0;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
&__main {
|
|
171
|
+
flex: 1;
|
|
172
|
+
display: flex;
|
|
173
|
+
flex-direction: column;
|
|
174
|
+
overflow: hidden;
|
|
175
|
+
height: 100%;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
&__header {
|
|
179
|
+
height: 50px;
|
|
180
|
+
box-sizing: border-box;
|
|
181
|
+
background-color: var(--bg-color);
|
|
182
|
+
border-bottom: 1px solid var(--color-border-lighter);
|
|
183
|
+
flex-shrink: 0;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
&__content {
|
|
187
|
+
flex: 1;
|
|
188
|
+
overflow: auto;
|
|
189
|
+
background-color: var(--bg-color-page);
|
|
190
|
+
padding: 0;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
193
|
</style>
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 国际化组合式函数
|
|
3
|
-
* 提供便捷的国际化操作
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { useLocaleStore } from '@/stores/locale'
|
|
7
|
-
import type { LocaleCode, LocaleMessages } from '@xto/core/locale'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 使用国际化
|
|
11
|
-
* 封装 locale store,提供更简洁的 API
|
|
12
|
-
*/
|
|
13
|
-
export function useI18n() {
|
|
14
|
-
const localeStore = useLocaleStore()
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
/** 当前语言代码 */
|
|
18
|
-
locale: localeStore.locale,
|
|
19
|
-
/** 当前语言名称 */
|
|
20
|
-
localeName: localeStore.localeName,
|
|
21
|
-
/** 支持的语言列表 */
|
|
22
|
-
locales: localeStore.locales,
|
|
23
|
-
/** 翻译函数 */
|
|
24
|
-
t: localeStore.t,
|
|
25
|
-
/** 当前语言包 */
|
|
26
|
-
messages: localeStore.messages,
|
|
27
|
-
/** 切换语言 */
|
|
28
|
-
setLocale: localeStore.changeLocale,
|
|
29
|
-
/** 添加自定义翻译 */
|
|
30
|
-
addMessages: localeStore.addMessages
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 创建翻译函数
|
|
36
|
-
* 用于在非组件上下文中使用翻译
|
|
37
|
-
*/
|
|
38
|
-
export function createTranslator() {
|
|
39
|
-
const localeStore = useLocaleStore()
|
|
40
|
-
return localeStore.t
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// 导出类型
|
|
1
|
+
/**
|
|
2
|
+
* 国际化组合式函数
|
|
3
|
+
* 提供便捷的国际化操作
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { useLocaleStore } from '@/stores/locale'
|
|
7
|
+
import type { LocaleCode, LocaleMessages } from '@xto/core/locale'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 使用国际化
|
|
11
|
+
* 封装 locale store,提供更简洁的 API
|
|
12
|
+
*/
|
|
13
|
+
export function useI18n() {
|
|
14
|
+
const localeStore = useLocaleStore()
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
/** 当前语言代码 */
|
|
18
|
+
locale: localeStore.locale,
|
|
19
|
+
/** 当前语言名称 */
|
|
20
|
+
localeName: localeStore.localeName,
|
|
21
|
+
/** 支持的语言列表 */
|
|
22
|
+
locales: localeStore.locales,
|
|
23
|
+
/** 翻译函数 */
|
|
24
|
+
t: localeStore.t,
|
|
25
|
+
/** 当前语言包 */
|
|
26
|
+
messages: localeStore.messages,
|
|
27
|
+
/** 切换语言 */
|
|
28
|
+
setLocale: localeStore.changeLocale,
|
|
29
|
+
/** 添加自定义翻译 */
|
|
30
|
+
addMessages: localeStore.addMessages
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 创建翻译函数
|
|
36
|
+
* 用于在非组件上下文中使用翻译
|
|
37
|
+
*/
|
|
38
|
+
export function createTranslator() {
|
|
39
|
+
const localeStore = useLocaleStore()
|
|
40
|
+
return localeStore.t
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// 导出类型
|
|
44
44
|
export type { LocaleCode, LocaleMessages }
|
package/src/index.ts
CHANGED
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
// 样式
|
|
2
|
-
import './style.scss'
|
|
3
|
-
|
|
4
|
-
// 配置
|
|
5
|
-
import { initAppConfig, getAppId, getClientId, getApiBaseUrl } from './utils/config'
|
|
6
|
-
import type { LocaleCode } from '@xto/core/locale'
|
|
7
|
-
|
|
8
|
-
// XtoConfig 类型定义
|
|
9
|
-
export interface XtoConfig {
|
|
10
|
-
appName?: string
|
|
11
|
-
appId?: string
|
|
12
|
-
clientId?: string
|
|
13
|
-
apiBaseUrl?: string
|
|
14
|
-
indexPath?: string
|
|
15
|
-
loginPath?: string
|
|
16
|
-
locale?: LocaleCode
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 初始化 XTO 应用
|
|
21
|
-
* 在项目入口文件中调用此函数设置应用配置
|
|
22
|
-
* @param config 应用配置
|
|
23
|
-
*/
|
|
24
|
-
export function createXtoApp(config: Partial<XtoConfig>) {
|
|
25
|
-
initAppConfig({
|
|
26
|
-
appId: config.appId,
|
|
27
|
-
clientId: config.clientId,
|
|
28
|
-
apiBaseUrl: config.apiBaseUrl
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
// 设置初始语言(如果提供)
|
|
32
|
-
if (config.locale) {
|
|
33
|
-
import('./stores/locale').then(({ useLocaleStore }) => {
|
|
34
|
-
const localeStore = useLocaleStore()
|
|
35
|
-
localeStore.changeLocale(config.locale!)
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
config: {
|
|
41
|
-
appName: config.appName || 'XTO App',
|
|
42
|
-
appId: getAppId(),
|
|
43
|
-
clientId: getClientId(),
|
|
44
|
-
apiBaseUrl: getApiBaseUrl(),
|
|
45
|
-
indexPath: config.indexPath || '/dashboard',
|
|
46
|
-
loginPath: config.loginPath || '/login',
|
|
47
|
-
locale: config.locale || 'zh-CN'
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// 组件
|
|
53
|
-
export { default as Layout } from './components/Layout/index.vue'
|
|
54
|
-
export { default as Header } from './components/Layout/Header.vue'
|
|
55
|
-
export { default as Sidebar } from './components/Layout/Sidebar.vue'
|
|
56
|
-
export { default as Tabs } from './components/Layout/Tabs.vue'
|
|
57
|
-
export { default as Footer } from './components/Layout/Footer.vue'
|
|
58
|
-
|
|
59
|
-
// 错误页面组件
|
|
60
|
-
export { default as Login } from './views/login/index.vue'
|
|
61
|
-
export { default as NotFound } from './views/error/404.vue'
|
|
62
|
-
export { default as Forbidden } from './views/error/403.vue'
|
|
63
|
-
|
|
64
|
-
// 组合式函数
|
|
65
|
-
export * from './composables/useApp'
|
|
66
|
-
export * from './composables/useAuth'
|
|
67
|
-
export * from './composables/useForm'
|
|
68
|
-
export * from './composables/useTable'
|
|
69
|
-
export * from './composables/useI18n'
|
|
70
|
-
|
|
71
|
-
// 工具函数
|
|
72
|
-
export * from './utils/auth'
|
|
73
|
-
export * from './utils/permission'
|
|
74
|
-
export * from './utils/request'
|
|
75
|
-
export * from './utils/storage'
|
|
76
|
-
export * from './utils/config'
|
|
77
|
-
|
|
78
|
-
// Store
|
|
79
|
-
export * from './stores/app'
|
|
80
|
-
export * from './stores/auth'
|
|
81
|
-
export * from './stores/menu'
|
|
82
|
-
export * from './stores/user'
|
|
83
|
-
export * from './stores/locale'
|
|
84
|
-
|
|
85
|
-
// 路由
|
|
86
|
-
export { default as router, resetRouter } from './router'
|
|
87
|
-
export * from './router/staticRoutes'
|
|
88
|
-
export * from './router/dynamicRoutes'
|
|
89
|
-
export { createLayoutRoute, createRouter } from './router/layoutRoute'
|
|
90
|
-
export { setupRouterGuards } from './router/guards'
|
|
91
|
-
|
|
92
|
-
// API
|
|
93
|
-
export * from './api/auth'
|
|
94
|
-
export * from './api/system'
|
|
95
|
-
export * from './api/user'
|
|
96
|
-
|
|
97
|
-
// 枚举
|
|
98
|
-
export * from './enums'
|
|
99
|
-
|
|
100
|
-
// 指令
|
|
1
|
+
// 样式
|
|
2
|
+
import './style.scss'
|
|
3
|
+
|
|
4
|
+
// 配置
|
|
5
|
+
import { initAppConfig, getAppId, getClientId, getApiBaseUrl } from './utils/config'
|
|
6
|
+
import type { LocaleCode } from '@xto/core/locale'
|
|
7
|
+
|
|
8
|
+
// XtoConfig 类型定义
|
|
9
|
+
export interface XtoConfig {
|
|
10
|
+
appName?: string
|
|
11
|
+
appId?: string
|
|
12
|
+
clientId?: string
|
|
13
|
+
apiBaseUrl?: string
|
|
14
|
+
indexPath?: string
|
|
15
|
+
loginPath?: string
|
|
16
|
+
locale?: LocaleCode
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 初始化 XTO 应用
|
|
21
|
+
* 在项目入口文件中调用此函数设置应用配置
|
|
22
|
+
* @param config 应用配置
|
|
23
|
+
*/
|
|
24
|
+
export function createXtoApp(config: Partial<XtoConfig>) {
|
|
25
|
+
initAppConfig({
|
|
26
|
+
appId: config.appId,
|
|
27
|
+
clientId: config.clientId,
|
|
28
|
+
apiBaseUrl: config.apiBaseUrl
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
// 设置初始语言(如果提供)
|
|
32
|
+
if (config.locale) {
|
|
33
|
+
import('./stores/locale').then(({ useLocaleStore }) => {
|
|
34
|
+
const localeStore = useLocaleStore()
|
|
35
|
+
localeStore.changeLocale(config.locale!)
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
config: {
|
|
41
|
+
appName: config.appName || 'XTO App',
|
|
42
|
+
appId: getAppId(),
|
|
43
|
+
clientId: getClientId(),
|
|
44
|
+
apiBaseUrl: getApiBaseUrl(),
|
|
45
|
+
indexPath: config.indexPath || '/dashboard',
|
|
46
|
+
loginPath: config.loginPath || '/login',
|
|
47
|
+
locale: config.locale || 'zh-CN'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 组件
|
|
53
|
+
export { default as Layout } from './components/Layout/index.vue'
|
|
54
|
+
export { default as Header } from './components/Layout/Header.vue'
|
|
55
|
+
export { default as Sidebar } from './components/Layout/Sidebar.vue'
|
|
56
|
+
export { default as Tabs } from './components/Layout/Tabs.vue'
|
|
57
|
+
export { default as Footer } from './components/Layout/Footer.vue'
|
|
58
|
+
|
|
59
|
+
// 错误页面组件
|
|
60
|
+
export { default as Login } from './views/login/index.vue'
|
|
61
|
+
export { default as NotFound } from './views/error/404.vue'
|
|
62
|
+
export { default as Forbidden } from './views/error/403.vue'
|
|
63
|
+
|
|
64
|
+
// 组合式函数
|
|
65
|
+
export * from './composables/useApp'
|
|
66
|
+
export * from './composables/useAuth'
|
|
67
|
+
export * from './composables/useForm'
|
|
68
|
+
export * from './composables/useTable'
|
|
69
|
+
export * from './composables/useI18n'
|
|
70
|
+
|
|
71
|
+
// 工具函数
|
|
72
|
+
export * from './utils/auth'
|
|
73
|
+
export * from './utils/permission'
|
|
74
|
+
export * from './utils/request'
|
|
75
|
+
export * from './utils/storage'
|
|
76
|
+
export * from './utils/config'
|
|
77
|
+
|
|
78
|
+
// Store
|
|
79
|
+
export * from './stores/app'
|
|
80
|
+
export * from './stores/auth'
|
|
81
|
+
export * from './stores/menu'
|
|
82
|
+
export * from './stores/user'
|
|
83
|
+
export * from './stores/locale'
|
|
84
|
+
|
|
85
|
+
// 路由
|
|
86
|
+
export { default as router, resetRouter } from './router'
|
|
87
|
+
export * from './router/staticRoutes'
|
|
88
|
+
export * from './router/dynamicRoutes'
|
|
89
|
+
export { createLayoutRoute, createRouter } from './router/layoutRoute'
|
|
90
|
+
export { setupRouterGuards } from './router/guards'
|
|
91
|
+
|
|
92
|
+
// API
|
|
93
|
+
export * from './api/auth'
|
|
94
|
+
export * from './api/system'
|
|
95
|
+
export * from './api/user'
|
|
96
|
+
|
|
97
|
+
// 枚举
|
|
98
|
+
export * from './enums'
|
|
99
|
+
|
|
100
|
+
// 指令
|
|
101
101
|
export { default as permissionDirective } from './directives/permission'
|