xto-fronted 0.4.6 → 0.4.8

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.
Files changed (160) hide show
  1. package/.env.development +7 -7
  2. package/.env.production +7 -7
  3. package/dist/assets/403-AFBQifUI.js +1 -0
  4. package/dist/assets/403-BHEXXbt2.css +1 -0
  5. package/dist/assets/404-Ct_A1n7S.css +1 -0
  6. package/dist/assets/404-WFvpcD2_.js +1 -0
  7. package/dist/assets/_plugin-vue_export-helper-DlAUqK2U.js +1 -0
  8. package/dist/assets/index-1juADvYN.js +2 -0
  9. package/dist/assets/index-B-sX4Ru0.js +1 -0
  10. package/dist/assets/index-BMcziU5a.css +1 -0
  11. package/dist/assets/index-BRR97dc6.js +1 -0
  12. package/dist/assets/index-BZA0ksjx.css +1 -0
  13. package/dist/assets/index-BpV_8nl0.js +1 -0
  14. package/dist/assets/index-BvzhR4zp.js +1 -0
  15. package/dist/assets/index-CUh_s55Z.css +1 -0
  16. package/dist/assets/index-CVjdnIgR.css +1 -0
  17. package/dist/assets/index-CYq57-zj.js +1 -0
  18. package/dist/assets/index-CkL3sVAQ.js +2 -0
  19. package/dist/assets/index-CtrKVYJb.css +1 -0
  20. package/dist/assets/index-Cz2P_bsS.js +1 -0
  21. package/dist/assets/index-D9wlAuR_.js +1 -0
  22. package/dist/assets/index-DawJb02s.css +1 -0
  23. package/dist/assets/index-DfFR6NLf.js +1 -0
  24. package/dist/assets/index-DwVgMO8e.js +1 -0
  25. package/dist/assets/index-GDP-IkXE.css +1 -0
  26. package/dist/assets/index-Iaz1ZzPC.js +2 -0
  27. package/dist/assets/index-PfV8pzQz.css +1 -0
  28. package/dist/assets/index-Swfu6yvD.css +1 -0
  29. package/dist/assets/index-Te8_PRgJ.js +1 -0
  30. package/dist/assets/index-WyZ91RLx.css +1 -0
  31. package/dist/assets/index-tFYRoFdE.js +1 -0
  32. package/dist/assets/vendor-42ANG6Sg.js +6 -0
  33. package/dist/assets/vite-Dw-pgLOX.js +1 -0
  34. package/dist/assets/vue-vendor-Br-l7wbK.js +29 -0
  35. package/dist/assets/xto-base-C-IBqjVs.js +1 -0
  36. package/dist/assets/xto-base-C6eqMPdO.css +1 -0
  37. package/dist/assets/xto-business--V1F5Gwb.css +1 -0
  38. package/dist/assets/xto-core-DZK7Cyg0.js +1 -0
  39. package/dist/assets/xto-data-BFpiDgJi.js +1 -0
  40. package/dist/assets/xto-data-CnAQAQH2.css +1 -0
  41. package/dist/assets/xto-feedback-B7ipsTfz.js +1 -0
  42. package/dist/assets/xto-feedback-DBwJzoTj.css +1 -0
  43. package/dist/assets/xto-form-CrsyAjyr.css +1 -0
  44. package/dist/assets/xto-form-NRjKKNcY.js +1 -0
  45. package/dist/assets/xto-layout-BqU8RuWL.css +1 -0
  46. package/dist/assets/xto-navigation-BiSaXPfr.js +1 -0
  47. package/dist/assets/xto-navigation-C1cnSL2E.css +1 -0
  48. package/dist/assets/xto-navigation-CBPg4dCc.css +1 -0
  49. package/dist/assets/xto-navigation-CKabFu9d.js +1 -0
  50. package/dist/index-54irhCHL.js +1830 -0
  51. package/dist/{index-15Bu0M8D.js → index-BzRf1eoJ.js} +1 -1
  52. package/dist/{index-BO2Zf9u6.js → index-DH4aoCZb.js} +1 -1
  53. package/dist/{index-BBqvHkzE.js → index-Kqa7iZ9E.js} +1 -1
  54. package/dist/{index-BQqo0ZIb.js → index-pxkZlvBw.js} +1 -1
  55. package/dist/index.es.js +1 -1
  56. package/dist/index.html +28 -0
  57. package/dist/index.umd.js +1 -1
  58. package/dist/style.css +1 -1
  59. package/package.json +85 -86
  60. package/src/api/auth.ts +25 -25
  61. package/src/api/system.ts +66 -66
  62. package/src/assets/styles/_dark.scss +406 -406
  63. package/src/components/Layout/Header.vue +973 -973
  64. package/src/components/Layout/Sidebar.vue +273 -212
  65. package/src/components/Layout/index.vue +443 -63
  66. package/src/composables/useApp.ts +61 -61
  67. package/src/composables/useAuth.ts +16 -16
  68. package/src/directives/permission.ts +27 -27
  69. package/src/env.d.ts +18 -18
  70. package/src/index.ts +47 -47
  71. package/src/router/dynamicRoutes.ts +162 -162
  72. package/src/router/guards.ts +128 -128
  73. package/src/router/index.ts +79 -79
  74. package/src/stores/auth.ts +65 -65
  75. package/src/stores/menu.ts +48 -48
  76. package/src/stores/user.ts +50 -50
  77. package/src/types/api.d.ts +80 -80
  78. package/src/utils/auth.ts +99 -99
  79. package/src/utils/config.ts +80 -80
  80. package/src/utils/permission.ts +32 -32
  81. package/src/utils/request.ts +124 -124
  82. package/src/views/login/index.vue +194 -188
  83. package/vite.config.ts +135 -135
  84. package/dist/index-B3PLzNB0.js +0 -345
  85. package/dist/index-B6DTsC6l.js +0 -1715
  86. package/dist/index-B7etKk33.js +0 -372
  87. package/dist/index-B7mpL6Zf.js +0 -475
  88. package/dist/index-BC2PGkkJ.js +0 -1644
  89. package/dist/index-BGgbfcmf.js +0 -475
  90. package/dist/index-BGmUwemj.js +0 -372
  91. package/dist/index-BQFfQj5Q.js +0 -142
  92. package/dist/index-BkRneTya.js +0 -142
  93. package/dist/index-BlRrngsc.js +0 -475
  94. package/dist/index-BmVvM7sm.js +0 -345
  95. package/dist/index-Bn4ThpX9.js +0 -142
  96. package/dist/index-BwfjwDKr.js +0 -1477
  97. package/dist/index-BxIL2hrt.js +0 -475
  98. package/dist/index-C-3fhbN2.js +0 -1644
  99. package/dist/index-C0VN9nFF.js +0 -142
  100. package/dist/index-C0xyGOsz.js +0 -475
  101. package/dist/index-C3c8NAZq.js +0 -1477
  102. package/dist/index-C42VtP71.js +0 -142
  103. package/dist/index-C6Nm0r9k.js +0 -475
  104. package/dist/index-C6w0-8xN.js +0 -1648
  105. package/dist/index-CD364XjV.js +0 -142
  106. package/dist/index-CHww99-i.js +0 -345
  107. package/dist/index-CIgWYERJ.js +0 -1644
  108. package/dist/index-CTs6DTuQ.js +0 -345
  109. package/dist/index-CWRs4WMN.js +0 -372
  110. package/dist/index-Cb-SxHJp.js +0 -345
  111. package/dist/index-CeCysOnl.js +0 -345
  112. package/dist/index-Cg1UpC8D.js +0 -1644
  113. package/dist/index-Cgkqpyx2.js +0 -345
  114. package/dist/index-CiuDEfo-.js +0 -142
  115. package/dist/index-CmQfZC8r.js +0 -372
  116. package/dist/index-CmkjhpX_.js +0 -475
  117. package/dist/index-CpxpXTQX.js +0 -1462
  118. package/dist/index-CqXFk_ET.js +0 -345
  119. package/dist/index-Cqix1YLE.js +0 -1697
  120. package/dist/index-CtvB5J9E.js +0 -372
  121. package/dist/index-Cu3Z2-PY.js +0 -345
  122. package/dist/index-CvDxK7Ab.js +0 -372
  123. package/dist/index-D-FER0vJ.js +0 -372
  124. package/dist/index-D2fQ8TK8.js +0 -475
  125. package/dist/index-D3xVcFvg.js +0 -372
  126. package/dist/index-D4crnrO6.js +0 -142
  127. package/dist/index-D7EzwTM5.js +0 -372
  128. package/dist/index-D7TZamyY.js +0 -1664
  129. package/dist/index-D88fiqXR.js +0 -475
  130. package/dist/index-DEbpF-M4.js +0 -1457
  131. package/dist/index-DFXuyPge.js +0 -1627
  132. package/dist/index-DLgimJYb.js +0 -1667
  133. package/dist/index-DPEVEyik.js +0 -475
  134. package/dist/index-DWy_UGhI.js +0 -345
  135. package/dist/index-DYVtddfw.js +0 -142
  136. package/dist/index-DYnXaqYf.js +0 -142
  137. package/dist/index-DcvRPHuy.js +0 -372
  138. package/dist/index-DdC1uV2v.js +0 -1700
  139. package/dist/index-Dga14ZN7.js +0 -1774
  140. package/dist/index-Dk2V44uP.js +0 -372
  141. package/dist/index-DnJ481u1.js +0 -475
  142. package/dist/index-Do1CBqg8.js +0 -345
  143. package/dist/index-DqQRSPeF.js +0 -345
  144. package/dist/index-Jb4VMHIS.js +0 -142
  145. package/dist/index-MC3wWjNt.js +0 -475
  146. package/dist/index-MG0JePmx.js +0 -142
  147. package/dist/index-PRFGBLWt.js +0 -475
  148. package/dist/index-QgkT42dc.js +0 -372
  149. package/dist/index-TrLCW5xL.js +0 -372
  150. package/dist/index-YDlNLFVk.js +0 -142
  151. package/dist/index-ZAJgA3XD.js +0 -475
  152. package/dist/index-a_ilWAvi.js +0 -345
  153. package/dist/index-bi1TMGid.js +0 -372
  154. package/dist/index-fyarVCog.js +0 -475
  155. package/dist/index-mnTZtPFa.js +0 -345
  156. package/dist/index-orZCyV6I.js +0 -345
  157. package/dist/index-p3TbK44c.js +0 -142
  158. package/dist/index-sRwZYbZ4.js +0 -372
  159. package/dist/index-wATqKEcF.js +0 -142
  160. package/dist/setup.d.ts +0 -17
@@ -1,51 +1,51 @@
1
- /**
2
- * 用户状态
3
- */
4
-
5
- import { defineStore } from 'pinia'
6
- import { ref, computed } from 'vue'
7
- import type { UserInfo } from '@/types/api'
8
- import { local } from '@/utils/storage'
9
-
10
- const USER_INFO_KEY = 'user_info'
11
-
12
- export const useUserStore = defineStore('user', () => {
13
- // 状态
14
- const userInfo = ref<UserInfo | null>(local.get<UserInfo>(USER_INFO_KEY))
15
-
16
- // 计算属性
17
- const isLoggedIn = computed(() => !!userInfo.value)
18
- const userId = computed(() => userInfo.value?.userId || '')
19
- const userName = computed(() => userInfo.value?.userName || '')
20
- const departmentName = computed(() => userInfo.value?.departmentName || '')
21
- const email = computed(() => userInfo.value?.email || '')
22
- const mobilePhone = computed(() => userInfo.value?.mobilePhone || '')
23
- const positionName = computed(() => userInfo.value?.positionName || '')
24
- const avatar = computed(() => userInfo.value?.avatar || '')
25
-
26
- // 设置用户信息
27
- const setUserInfo = (info: UserInfo) => {
28
- userInfo.value = info
29
- local.set(USER_INFO_KEY, info)
30
- }
31
-
32
- // 清除用户信息
33
- const clearUserInfo = () => {
34
- userInfo.value = null
35
- local.remove(USER_INFO_KEY)
36
- }
37
-
38
- return {
39
- userInfo,
40
- isLoggedIn,
41
- userId,
42
- userName,
43
- departmentName,
44
- email,
45
- mobilePhone,
46
- positionName,
47
- avatar,
48
- setUserInfo,
49
- clearUserInfo
50
- }
1
+ /**
2
+ * 用户状态
3
+ */
4
+
5
+ import { defineStore } from 'pinia'
6
+ import { ref, computed } from 'vue'
7
+ import type { UserInfo } from '@/types/api'
8
+ import { local } from '@/utils/storage'
9
+
10
+ const USER_INFO_KEY = 'user_info'
11
+
12
+ export const useUserStore = defineStore('user', () => {
13
+ // 状态
14
+ const userInfo = ref<UserInfo | null>(local.get<UserInfo>(USER_INFO_KEY))
15
+
16
+ // 计算属性
17
+ const isLoggedIn = computed(() => !!userInfo.value)
18
+ const userId = computed(() => userInfo.value?.userId || '')
19
+ const userName = computed(() => userInfo.value?.userName || '')
20
+ const departmentName = computed(() => userInfo.value?.departmentName || '')
21
+ const email = computed(() => userInfo.value?.email || '')
22
+ const mobilePhone = computed(() => userInfo.value?.mobilePhone || '')
23
+ const positionName = computed(() => userInfo.value?.positionName || '')
24
+ const avatar = computed(() => userInfo.value?.avatar || '')
25
+
26
+ // 设置用户信息
27
+ const setUserInfo = (info: UserInfo) => {
28
+ userInfo.value = info
29
+ local.set(USER_INFO_KEY, info)
30
+ }
31
+
32
+ // 清除用户信息
33
+ const clearUserInfo = () => {
34
+ userInfo.value = null
35
+ local.remove(USER_INFO_KEY)
36
+ }
37
+
38
+ return {
39
+ userInfo,
40
+ isLoggedIn,
41
+ userId,
42
+ userName,
43
+ departmentName,
44
+ email,
45
+ mobilePhone,
46
+ positionName,
47
+ avatar,
48
+ setUserInfo,
49
+ clearUserInfo
50
+ }
51
51
  })
@@ -1,81 +1,81 @@
1
- /**
2
- * API 通用类型定义
3
- */
4
-
5
- // 基础响应
6
- export interface ApiResponse<T = unknown> {
7
- code: number
8
- data: T
9
- message: string
10
- }
11
-
12
- // 分页请求参数
13
- export interface PageParams {
14
- page: number
15
- pageSize: number
16
- [key: string]: unknown
17
- }
18
-
19
- // 分页响应
20
- export interface PageResponse<T> {
21
- list: T[]
22
- total: number
23
- page: number
24
- pageSize: number
25
- }
26
-
27
- // 用户信息(参考 tineco-ui)
28
- export interface UserInfo {
29
- appId: string
30
- userId: string
31
- userName: string
32
- departmentName?: string
33
- email?: string
34
- mobilePhone?: string
35
- positionName?: string
36
- avatar?: string
37
- }
38
-
39
- // 登录请求参数(参考 tineco-ui)
40
- export interface LoginParams {
41
- appId: string
42
- clientId: string
43
- uid: string
44
- password: string
45
- code?: boolean
46
- }
47
-
48
- // 登录响应(参考 tineco-ui)
49
- export interface LoginResult {
50
- access_token: string
51
- token_type: string
52
- refresh_token: string
53
- expires_time: number
54
- refresh_time: number
55
- code?: string
56
- }
57
-
58
- // 菜单项(参考 tineco-ui)
59
- export interface MenuItem {
60
- menuCode: string
61
- menuName: string
62
- menuUrl: string
63
- icon?: string
64
- closable?: boolean
65
- isDefault?: boolean
66
- isOut?: boolean
67
- type?: number // 1 为按钮,其他为菜单
68
- children?: MenuItem[]
69
- }
70
-
71
- // 角色信息
72
- export interface RoleInfo {
73
- id: number | string
74
- name: string
75
- code: string
76
- description?: string
77
- status: number
78
- permissions: string[]
79
- createTime?: string
80
- updateTime?: string
1
+ /**
2
+ * API 通用类型定义
3
+ */
4
+
5
+ // 基础响应
6
+ export interface ApiResponse<T = unknown> {
7
+ code: number
8
+ data: T
9
+ message: string
10
+ }
11
+
12
+ // 分页请求参数
13
+ export interface PageParams {
14
+ page: number
15
+ pageSize: number
16
+ [key: string]: unknown
17
+ }
18
+
19
+ // 分页响应
20
+ export interface PageResponse<T> {
21
+ list: T[]
22
+ total: number
23
+ page: number
24
+ pageSize: number
25
+ }
26
+
27
+ // 用户信息(参考 tineco-ui)
28
+ export interface UserInfo {
29
+ appId: string
30
+ userId: string
31
+ userName: string
32
+ departmentName?: string
33
+ email?: string
34
+ mobilePhone?: string
35
+ positionName?: string
36
+ avatar?: string
37
+ }
38
+
39
+ // 登录请求参数(参考 tineco-ui)
40
+ export interface LoginParams {
41
+ appId: string
42
+ clientId: string
43
+ uid: string
44
+ password: string
45
+ code?: boolean
46
+ }
47
+
48
+ // 登录响应(参考 tineco-ui)
49
+ export interface LoginResult {
50
+ access_token: string
51
+ token_type: string
52
+ refresh_token: string
53
+ expires_time: number
54
+ refresh_time: number
55
+ code?: string
56
+ }
57
+
58
+ // 菜单项(参考 tineco-ui)
59
+ export interface MenuItem {
60
+ menuCode: string
61
+ menuName: string
62
+ menuUrl: string
63
+ icon?: string
64
+ closable?: boolean
65
+ isDefault?: boolean
66
+ isOut?: boolean
67
+ type?: number // 1 为按钮,其他为菜单
68
+ children?: MenuItem[]
69
+ }
70
+
71
+ // 角色信息
72
+ export interface RoleInfo {
73
+ id: number | string
74
+ name: string
75
+ code: string
76
+ description?: string
77
+ status: number
78
+ permissions: string[]
79
+ createTime?: string
80
+ updateTime?: string
81
81
  }
package/src/utils/auth.ts CHANGED
@@ -1,100 +1,100 @@
1
- /**
2
- * Token 管理
3
- */
4
-
5
- import { local } from './storage'
6
-
7
- const TOKEN_KEY = 'token'
8
- const TOKEN_TYPE_KEY = 'token_type'
9
- const REFRESH_TOKEN_KEY = 'refresh_token'
10
- const TOKEN_EXPIRE_KEY = 'expires_time'
11
- const REFRESH_TIME_KEY = 'refresh_time'
12
- const CODE_KEY = 'code'
13
-
14
- export interface TokenInfo {
15
- access_token: string
16
- token_type: string
17
- refresh_token: string
18
- expires_time: number
19
- refresh_time: number
20
- code?: string
21
- }
22
-
23
- export const getToken = (): string | null => {
24
- return local.get<string>(TOKEN_KEY)
25
- }
26
-
27
- export const setToken = (token: string): void => {
28
- local.set(TOKEN_KEY, token)
29
- }
30
-
31
- export const getTokenType = (): string | null => {
32
- return local.get<string>(TOKEN_TYPE_KEY)
33
- }
34
-
35
- export const setTokenType = (tokenType: string): void => {
36
- local.set(TOKEN_TYPE_KEY, tokenType)
37
- }
38
-
39
- export const getRefreshToken = (): string | null => {
40
- return local.get<string>(REFRESH_TOKEN_KEY)
41
- }
42
-
43
- export const setRefreshToken = (refreshToken: string): void => {
44
- local.set(REFRESH_TOKEN_KEY, refreshToken)
45
- }
46
-
47
- export const getTokenExpire = (): number | null => {
48
- return local.get<number>(TOKEN_EXPIRE_KEY)
49
- }
50
-
51
- export const setTokenExpire = (expireTime: number): void => {
52
- local.set(TOKEN_EXPIRE_KEY, expireTime)
53
- }
54
-
55
- export const getRefreshTime = (): number | null => {
56
- return local.get<number>(REFRESH_TIME_KEY)
57
- }
58
-
59
- export const setRefreshTime = (refreshTime: number): void => {
60
- local.set(REFRESH_TIME_KEY, refreshTime)
61
- }
62
-
63
- export const getCode = (): string | null => {
64
- return local.get<string>(CODE_KEY)
65
- }
66
-
67
- export const setCode = (code: string): void => {
68
- local.set(CODE_KEY, code)
69
- }
70
-
71
- export const setTokenInfo = (info: TokenInfo): void => {
72
- setToken(info.access_token)
73
- setTokenType(info.token_type || 'Bearer')
74
- setRefreshToken(info.refresh_token)
75
- setTokenExpire(info.expires_time)
76
- setRefreshTime(info.refresh_time)
77
- if (info.code) {
78
- setCode(info.code)
79
- }
80
- }
81
-
82
- export const clearToken = (): void => {
83
- local.remove(TOKEN_KEY)
84
- local.remove(TOKEN_TYPE_KEY)
85
- local.remove(REFRESH_TOKEN_KEY)
86
- local.remove(TOKEN_EXPIRE_KEY)
87
- local.remove(REFRESH_TIME_KEY)
88
- local.remove(CODE_KEY)
89
- }
90
-
91
- export const isTokenExpired = (): boolean => {
92
- const expireTime = getTokenExpire()
93
- if (!expireTime) return true
94
- return Date.now() > expireTime
95
- }
96
-
97
- export const hasToken = (): boolean => {
98
- const token = getToken()
99
- return !!token && !isTokenExpired()
1
+ /**
2
+ * Token 管理
3
+ */
4
+
5
+ import { local } from './storage'
6
+
7
+ const TOKEN_KEY = 'token'
8
+ const TOKEN_TYPE_KEY = 'token_type'
9
+ const REFRESH_TOKEN_KEY = 'refresh_token'
10
+ const TOKEN_EXPIRE_KEY = 'expires_time'
11
+ const REFRESH_TIME_KEY = 'refresh_time'
12
+ const CODE_KEY = 'code'
13
+
14
+ export interface TokenInfo {
15
+ access_token: string
16
+ token_type: string
17
+ refresh_token: string
18
+ expires_time: number
19
+ refresh_time: number
20
+ code?: string
21
+ }
22
+
23
+ export const getToken = (): string | null => {
24
+ return local.get<string>(TOKEN_KEY)
25
+ }
26
+
27
+ export const setToken = (token: string): void => {
28
+ local.set(TOKEN_KEY, token)
29
+ }
30
+
31
+ export const getTokenType = (): string | null => {
32
+ return local.get<string>(TOKEN_TYPE_KEY)
33
+ }
34
+
35
+ export const setTokenType = (tokenType: string): void => {
36
+ local.set(TOKEN_TYPE_KEY, tokenType)
37
+ }
38
+
39
+ export const getRefreshToken = (): string | null => {
40
+ return local.get<string>(REFRESH_TOKEN_KEY)
41
+ }
42
+
43
+ export const setRefreshToken = (refreshToken: string): void => {
44
+ local.set(REFRESH_TOKEN_KEY, refreshToken)
45
+ }
46
+
47
+ export const getTokenExpire = (): number | null => {
48
+ return local.get<number>(TOKEN_EXPIRE_KEY)
49
+ }
50
+
51
+ export const setTokenExpire = (expireTime: number): void => {
52
+ local.set(TOKEN_EXPIRE_KEY, expireTime)
53
+ }
54
+
55
+ export const getRefreshTime = (): number | null => {
56
+ return local.get<number>(REFRESH_TIME_KEY)
57
+ }
58
+
59
+ export const setRefreshTime = (refreshTime: number): void => {
60
+ local.set(REFRESH_TIME_KEY, refreshTime)
61
+ }
62
+
63
+ export const getCode = (): string | null => {
64
+ return local.get<string>(CODE_KEY)
65
+ }
66
+
67
+ export const setCode = (code: string): void => {
68
+ local.set(CODE_KEY, code)
69
+ }
70
+
71
+ export const setTokenInfo = (info: TokenInfo): void => {
72
+ setToken(info.access_token)
73
+ setTokenType(info.token_type || 'Bearer')
74
+ setRefreshToken(info.refresh_token)
75
+ setTokenExpire(info.expires_time)
76
+ setRefreshTime(info.refresh_time)
77
+ if (info.code) {
78
+ setCode(info.code)
79
+ }
80
+ }
81
+
82
+ export const clearToken = (): void => {
83
+ local.remove(TOKEN_KEY)
84
+ local.remove(TOKEN_TYPE_KEY)
85
+ local.remove(REFRESH_TOKEN_KEY)
86
+ local.remove(TOKEN_EXPIRE_KEY)
87
+ local.remove(REFRESH_TIME_KEY)
88
+ local.remove(CODE_KEY)
89
+ }
90
+
91
+ export const isTokenExpired = (): boolean => {
92
+ const expireTime = getTokenExpire()
93
+ if (!expireTime) return true
94
+ return Date.now() > expireTime
95
+ }
96
+
97
+ export const hasToken = (): boolean => {
98
+ const token = getToken()
99
+ return !!token && !isTokenExpired()
100
100
  }
@@ -1,81 +1,81 @@
1
- /**
2
- * 应用配置(动态设置,避免 import.meta.env 静态替换)
3
- */
4
-
5
- import { ref } from 'vue'
6
-
7
- // 配置状态
8
- const appId = ref<string>('')
9
- const clientId = ref<string>('')
10
- const apiBaseUrl = ref<string>('')
11
-
12
- /**
13
- * 初始化应用配置
14
- * 在项目入口文件(main.ts)中调用此函数设置配置
15
- */
16
- export function initAppConfig(config: {
17
- appId?: string
18
- clientId?: string
19
- apiBaseUrl?: string
20
- }) {
21
- if (config.appId) {
22
- appId.value = config.appId
23
- }
24
- if (config.clientId) {
25
- clientId.value = config.clientId
26
- }
27
- if (config.apiBaseUrl) {
28
- apiBaseUrl.value = config.apiBaseUrl
29
- }
30
- }
31
-
32
- /**
33
- * 获取 AppId
34
- * 优先使用动态配置,其次使用环境变量
35
- */
36
- export function getAppId(): string {
37
- if (appId.value) {
38
- return appId.value
39
- }
40
- // 尝试从环境变量获取(使用方项目构建时会注入)
41
- try {
42
- return import.meta.env.VITE_APP_ID || ''
43
- } catch {
44
- return ''
45
- }
46
- }
47
-
48
- /**
49
- * 获取 ClientId
50
- */
51
- export function getClientId(): string {
52
- if (clientId.value) {
53
- return clientId.value
54
- }
55
- try {
56
- return import.meta.env.VITE_APP_CLIENT_ID || ''
57
- } catch {
58
- return ''
59
- }
60
- }
61
-
62
- /**
63
- * 获取 API 基础路径
64
- */
65
- export function getApiBaseUrl(): string {
66
- if (apiBaseUrl.value) {
67
- return apiBaseUrl.value
68
- }
69
- try {
70
- return import.meta.env.VITE_API_BASE_URL || ''
71
- } catch {
72
- return ''
73
- }
74
- }
75
-
76
- // 导出响应式引用(供特殊场景直接使用)
77
- export const appConfig = {
78
- appId,
79
- clientId,
80
- apiBaseUrl
1
+ /**
2
+ * 应用配置(动态设置,避免 import.meta.env 静态替换)
3
+ */
4
+
5
+ import { ref } from 'vue'
6
+
7
+ // 配置状态
8
+ const appId = ref<string>('')
9
+ const clientId = ref<string>('')
10
+ const apiBaseUrl = ref<string>('')
11
+
12
+ /**
13
+ * 初始化应用配置
14
+ * 在项目入口文件(main.ts)中调用此函数设置配置
15
+ */
16
+ export function initAppConfig(config: {
17
+ appId?: string
18
+ clientId?: string
19
+ apiBaseUrl?: string
20
+ }) {
21
+ if (config.appId) {
22
+ appId.value = config.appId
23
+ }
24
+ if (config.clientId) {
25
+ clientId.value = config.clientId
26
+ }
27
+ if (config.apiBaseUrl) {
28
+ apiBaseUrl.value = config.apiBaseUrl
29
+ }
30
+ }
31
+
32
+ /**
33
+ * 获取 AppId
34
+ * 优先使用动态配置,其次使用环境变量
35
+ */
36
+ export function getAppId(): string {
37
+ if (appId.value) {
38
+ return appId.value
39
+ }
40
+ // 尝试从环境变量获取(使用方项目构建时会注入)
41
+ try {
42
+ return import.meta.env.VITE_APP_ID || ''
43
+ } catch {
44
+ return ''
45
+ }
46
+ }
47
+
48
+ /**
49
+ * 获取 ClientId
50
+ */
51
+ export function getClientId(): string {
52
+ if (clientId.value) {
53
+ return clientId.value
54
+ }
55
+ try {
56
+ return import.meta.env.VITE_APP_CLIENT_ID || ''
57
+ } catch {
58
+ return ''
59
+ }
60
+ }
61
+
62
+ /**
63
+ * 获取 API 基础路径
64
+ */
65
+ export function getApiBaseUrl(): string {
66
+ if (apiBaseUrl.value) {
67
+ return apiBaseUrl.value
68
+ }
69
+ try {
70
+ return import.meta.env.VITE_API_BASE_URL || ''
71
+ } catch {
72
+ return ''
73
+ }
74
+ }
75
+
76
+ // 导出响应式引用(供特殊场景直接使用)
77
+ export const appConfig = {
78
+ appId,
79
+ clientId,
80
+ apiBaseUrl
81
81
  }
@@ -1,33 +1,33 @@
1
- /**
2
- * 权限工具函数
3
- * 注意:tineco-ui 不支持 permissions 和 roles 字段,这些函数暂时返回登录状态
4
- */
5
-
6
- import { useUserStore } from '@/stores/user'
7
-
8
- /**
9
- * 检查是否有权限
10
- * @param _permission 权限标识(暂不使用)
11
- */
12
- export function hasPermission(_permission: string | string[]): boolean {
13
- const userStore = useUserStore()
14
- // tineco-ui 不支持 permissions 字段,暂时返回已登录状态
15
- return userStore.isLoggedIn
16
- }
17
-
18
- /**
19
- * 检查是否有角色
20
- * @param _role 角色标识(暂不使用)
21
- */
22
- export function hasRole(_role: string | string[]): boolean {
23
- const userStore = useUserStore()
24
- // tineco-ui 不支持 roles 字段,暂时返回已登录状态
25
- return userStore.isLoggedIn
26
- }
27
-
28
- /**
29
- * 检查是否是管理员
30
- */
31
- export function isAdmin(): boolean {
32
- return true // tineco-ui 不支持 roles 字段,暂时返回 true
1
+ /**
2
+ * 权限工具函数
3
+ * 注意:tineco-ui 不支持 permissions 和 roles 字段,这些函数暂时返回登录状态
4
+ */
5
+
6
+ import { useUserStore } from '@/stores/user'
7
+
8
+ /**
9
+ * 检查是否有权限
10
+ * @param _permission 权限标识(暂不使用)
11
+ */
12
+ export function hasPermission(_permission: string | string[]): boolean {
13
+ const userStore = useUserStore()
14
+ // tineco-ui 不支持 permissions 字段,暂时返回已登录状态
15
+ return userStore.isLoggedIn
16
+ }
17
+
18
+ /**
19
+ * 检查是否有角色
20
+ * @param _role 角色标识(暂不使用)
21
+ */
22
+ export function hasRole(_role: string | string[]): boolean {
23
+ const userStore = useUserStore()
24
+ // tineco-ui 不支持 roles 字段,暂时返回已登录状态
25
+ return userStore.isLoggedIn
26
+ }
27
+
28
+ /**
29
+ * 检查是否是管理员
30
+ */
31
+ export function isAdmin(): boolean {
32
+ return true // tineco-ui 不支持 roles 字段,暂时返回 true
33
33
  }