xto-fronted 0.2.7 → 0.3.0
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/composables/useApp.d.ts +32 -0
- package/dist/index-B3PLzNB0.js +345 -0
- package/dist/index-B7mpL6Zf.js +475 -0
- package/dist/index-C3c8NAZq.js +1477 -0
- package/dist/index-CTs6DTuQ.js +345 -0
- package/dist/index-CtvB5J9E.js +372 -0
- package/dist/index-CvDxK7Ab.js +372 -0
- package/dist/index-DEbpF-M4.js +1457 -0
- package/dist/index-ZAJgA3XD.js +475 -0
- package/dist/index-p3TbK44c.js +142 -0
- package/dist/index-wATqKEcF.js +142 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +37 -37
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
- package/src/composables/useApp.ts +62 -0
- package/src/index.ts +2 -4
- package/src/setup.ts +0 -54
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 应用组合函数
|
|
3
|
+
* 提供应用级别的状态和方法
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { computed } from 'vue'
|
|
7
|
+
import { useAppStore } from '@/stores/app'
|
|
8
|
+
import { useUserStore } from '@/stores/user'
|
|
9
|
+
import { useAuthStore } from '@/stores/auth'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 应用级别组合函数
|
|
13
|
+
* @returns 应用状态和方法
|
|
14
|
+
*/
|
|
15
|
+
export function useApp() {
|
|
16
|
+
const appStore = useAppStore()
|
|
17
|
+
const userStore = useUserStore()
|
|
18
|
+
const authStore = useAuthStore()
|
|
19
|
+
|
|
20
|
+
// 用户名
|
|
21
|
+
const userName = computed(() => userStore.nickname || userStore.username || '')
|
|
22
|
+
|
|
23
|
+
// 用户信息
|
|
24
|
+
const userInfo = computed(() => userStore.userInfo)
|
|
25
|
+
|
|
26
|
+
// 应用名称
|
|
27
|
+
const appName = computed(() => appStore.appName)
|
|
28
|
+
|
|
29
|
+
// 是否已登录
|
|
30
|
+
const isLoggedIn = computed(() => authStore.isLoggedIn)
|
|
31
|
+
|
|
32
|
+
// 主题相关
|
|
33
|
+
const isDark = computed(() => appStore.isDark)
|
|
34
|
+
const theme = computed(() => appStore.theme)
|
|
35
|
+
|
|
36
|
+
// 布局相关
|
|
37
|
+
const isCollapsed = computed(() => appStore.isCollapsed)
|
|
38
|
+
const layout = computed(() => appStore.layout)
|
|
39
|
+
|
|
40
|
+
// 切换主题
|
|
41
|
+
const toggleTheme = () => {
|
|
42
|
+
appStore.toggleTheme()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 切换菜单折叠
|
|
46
|
+
const toggleCollapse = () => {
|
|
47
|
+
appStore.toggleCollapse()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
userName,
|
|
52
|
+
userInfo,
|
|
53
|
+
appName,
|
|
54
|
+
isLoggedIn,
|
|
55
|
+
isDark,
|
|
56
|
+
theme,
|
|
57
|
+
isCollapsed,
|
|
58
|
+
layout,
|
|
59
|
+
toggleTheme,
|
|
60
|
+
toggleCollapse
|
|
61
|
+
}
|
|
62
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { default as NotFound } from './views/error/404.vue'
|
|
|
11
11
|
export { default as Forbidden } from './views/error/403.vue'
|
|
12
12
|
|
|
13
13
|
// 组合式函数
|
|
14
|
+
export * from './composables/useApp'
|
|
14
15
|
export * from './composables/useAuth'
|
|
15
16
|
export * from './composables/useForm'
|
|
16
17
|
export * from './composables/useTable'
|
|
@@ -42,7 +43,4 @@ export * from './api/user'
|
|
|
42
43
|
export * from './enums'
|
|
43
44
|
|
|
44
45
|
// 指令
|
|
45
|
-
export { default as permissionDirective } from './directives/permission'
|
|
46
|
-
|
|
47
|
-
// 应用初始化
|
|
48
|
-
export { createXtoApp } from './setup'
|
|
46
|
+
export { default as permissionDirective } from './directives/permission'
|
package/src/setup.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 应用初始化配置
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { useAppStore } from './stores/app'
|
|
6
|
-
import { useAuthStore } from './stores/auth'
|
|
7
|
-
|
|
8
|
-
interface XtoAppConfig {
|
|
9
|
-
appName?: string
|
|
10
|
-
baseUrl?: string
|
|
11
|
-
appId?: string
|
|
12
|
-
clientId?: string
|
|
13
|
-
indexPath?: string
|
|
14
|
-
loginPath?: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 创建 XTO 应用配置
|
|
19
|
-
* @param config 应用配置
|
|
20
|
-
*/
|
|
21
|
-
export function createXtoApp(config: XtoAppConfig = {}) {
|
|
22
|
-
const appStore = useAppStore()
|
|
23
|
-
const authStore = useAuthStore()
|
|
24
|
-
|
|
25
|
-
// 设置应用名称
|
|
26
|
-
if (config.appName) {
|
|
27
|
-
appStore.setAppName(config.appName)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// 设置 API 基础路径
|
|
31
|
-
if (config.baseUrl) {
|
|
32
|
-
authStore.setBaseUrl(config.baseUrl)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// 设置应用 ID
|
|
36
|
-
if (config.appId) {
|
|
37
|
-
authStore.setAppId(config.appId)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// 设置客户端 ID
|
|
41
|
-
if (config.clientId) {
|
|
42
|
-
authStore.setClientId(config.clientId)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// 设置默认首页路径
|
|
46
|
-
if (config.indexPath) {
|
|
47
|
-
appStore.setIndexPath(config.indexPath)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// 设置登录页路径
|
|
51
|
-
if (config.loginPath) {
|
|
52
|
-
authStore.setLoginPath(config.loginPath)
|
|
53
|
-
}
|
|
54
|
-
}
|