xto-fronted 0.1.1 → 0.1.3

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 (67) hide show
  1. package/.env.development +3 -4
  2. package/.env.production +3 -4
  3. package/bin/cli.js +104 -0
  4. package/dist/{403-MQkNUulz.js → 403-DM5wfQkM.js} +6 -6
  5. package/dist/{404-BOFYLq4X.js → 404-BurAu5LC.js} +7 -7
  6. package/dist/api/auth.d.ts +9 -8
  7. package/dist/api/menu.d.ts +3 -0
  8. package/dist/api/user.d.ts +2 -12
  9. package/dist/composables/index.d.ts +8 -0
  10. package/dist/composables/useApp.d.ts +64 -0
  11. package/dist/composables/useAuth.d.ts +19 -4
  12. package/dist/composables/useMenu.d.ts +34 -0
  13. package/dist/config/index.d.ts +11 -0
  14. package/dist/index-BNiEld34.js +15 -0
  15. package/dist/index-Be9RiEfo.js +98 -0
  16. package/dist/index-BqRv1bdN.js +1185 -0
  17. package/dist/index-CQLVXvNJ.js +15 -0
  18. package/dist/index-CyiE8n2V.js +15 -0
  19. package/dist/index-xauR1bOL.js +15 -0
  20. package/dist/index.d.ts +7 -4
  21. package/dist/index.es.js +50 -66
  22. package/dist/index.umd.js +1 -1
  23. package/dist/stores/auth.d.ts +60 -23
  24. package/dist/stores/menu.d.ts +40 -29
  25. package/dist/stores/user.d.ts +63 -84
  26. package/dist/style.css +1 -1
  27. package/dist/utils/auth.d.ts +15 -7
  28. package/dist/utils/permission.d.ts +1 -6
  29. package/dist/views/system/menu/index.vue.d.ts +1 -3
  30. package/dist/views/system/role/index.vue.d.ts +1 -3
  31. package/dist/views/system/user/index.vue.d.ts +1 -3
  32. package/package.json +27 -19
  33. package/src/api/auth.ts +34 -25
  34. package/src/api/menu.ts +13 -0
  35. package/src/api/user.ts +11 -45
  36. package/src/components/Layout/Header.vue +334 -389
  37. package/src/components/Layout/Sidebar.vue +212 -296
  38. package/src/components/Layout/Tabs.vue +19 -133
  39. package/src/composables/index.ts +9 -0
  40. package/src/composables/useApp.ts +170 -0
  41. package/src/composables/useAuth.ts +69 -44
  42. package/src/composables/useMenu.ts +141 -0
  43. package/src/config/index.ts +19 -0
  44. package/src/directives/permission.ts +40 -37
  45. package/src/index.ts +9 -4
  46. package/src/router/index.ts +70 -80
  47. package/src/stores/auth.ts +44 -31
  48. package/src/stores/menu.ts +157 -79
  49. package/src/stores/user.ts +40 -72
  50. package/src/types/api.d.ts +102 -83
  51. package/src/types/xto.d.ts +148 -148
  52. package/src/utils/auth.ts +85 -61
  53. package/src/utils/permission.ts +29 -41
  54. package/src/utils/request.ts +125 -125
  55. package/src/utils/storage.ts +10 -1
  56. package/src/views/dashboard/index.vue +31 -283
  57. package/src/views/login/index.vue +140 -247
  58. package/src/views/system/menu/index.vue +31 -380
  59. package/src/views/system/role/index.vue +31 -303
  60. package/src/views/system/user/index.vue +31 -326
  61. package/vite.config.ts +3 -3
  62. package/dist/index-BJxYdNPy.js +0 -475
  63. package/dist/index-BvnIIBR1.js +0 -142
  64. package/dist/index-CEvAq6KE.js +0 -372
  65. package/dist/index-DPkqej__.js +0 -345
  66. package/dist/index-pq9Z5K62.js +0 -184
  67. package/dist/index-vVfjShJR.js +0 -1183
@@ -1,84 +1,103 @@
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
- // 用户信息
28
- export interface UserInfo {
29
- id: number | string
30
- username: string
31
- nickname: string
32
- avatar?: string
33
- email?: string
34
- phone?: string
35
- status: number
36
- roles: string[]
37
- permissions: string[]
38
- createTime?: string
39
- updateTime?: string
40
- }
41
-
42
- // 登录请求
43
- export interface LoginParams {
44
- username: string
45
- password: string
46
- captcha?: string
47
- }
48
-
49
- // 登录响应
50
- export interface LoginResult {
51
- token: string
52
- refreshToken: string
53
- expireTime: number
54
- user: UserInfo
55
- }
56
-
57
- // 菜单项
58
- export interface MenuItem {
59
- id: number | string
60
- name: string
61
- path: string
62
- component?: string
63
- redirect?: string
64
- icon?: string
65
- title: string
66
- hidden?: boolean
67
- keepAlive?: boolean
68
- affix?: boolean
69
- order?: number
70
- parentId?: number | string | null
71
- children?: MenuItem[]
72
- }
73
-
74
- // 角色信息
75
- export interface RoleInfo {
76
- id: number | string
77
- name: string
78
- code: string
79
- description?: string
80
- status: number
81
- permissions: string[]
82
- createTime?: string
83
- 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
+ // 用户信息(来自后端)
28
+ export interface UserInfo {
29
+ uId: string
30
+ appId: string
31
+ userId: string
32
+ userName: string
33
+ departmentName?: string
34
+ email?: string
35
+ mobilePhone?: string
36
+ positionName?: string
37
+ avatar?: string
38
+ workNo?: string
39
+ }
40
+
41
+ // 登录请求
42
+ export interface LoginParams {
43
+ uid: string
44
+ password: string
45
+ }
46
+
47
+ // 登录响应
48
+ export interface LoginResult {
49
+ access_token: string
50
+ refresh_token: string
51
+ expires_time: string
52
+ refresh_time: string
53
+ token_type: string
54
+ code: string
55
+ }
56
+
57
+ // 后端菜单项
58
+ export interface RemoteMenuItem {
59
+ menuCode: string
60
+ menuName: string
61
+ menuUrl: string
62
+ icon?: string
63
+ closable?: boolean
64
+ isDefault?: boolean
65
+ isOut?: boolean
66
+ type: number // 0: 菜单, 1: 按钮
67
+ children?: RemoteMenuItem[]
68
+ }
69
+
70
+ // 前端菜单项
71
+ export interface MenuItem {
72
+ code: string
73
+ name: string
74
+ path: string
75
+ component?: string
76
+ redirect?: string
77
+ icon?: string
78
+ title: string
79
+ hidden?: boolean
80
+ keepAlive?: boolean
81
+ affix?: boolean
82
+ default?: boolean
83
+ out?: boolean
84
+ closable?: boolean
85
+ children?: MenuItem[]
86
+ }
87
+
88
+ // 按钮权限
89
+ export interface ButtonPermission {
90
+ code: string
91
+ }
92
+
93
+ // 角色信息
94
+ export interface RoleInfo {
95
+ id: number | string
96
+ name: string
97
+ code: string
98
+ description?: string
99
+ status: number
100
+ permissions: string[]
101
+ createTime?: string
102
+ updateTime?: string
84
103
  }
@@ -1,149 +1,149 @@
1
- declare module '@xto/core' {
2
- export const version: string
3
- export function install(app: any): void
4
- }
5
-
6
- declare module '@xto/core/es/index/index.mjs' {
7
- export * from '@xto/core'
8
- }
9
-
10
- declare module '@xto/core/es/theme/index.mjs' {
11
- export const theme: any
12
- }
13
-
14
- declare module '@xto/core/es/hooks/index.mjs' {
15
- export const hooks: any
16
- }
17
-
18
- declare module '@xto/core/es/utils/index.mjs' {
19
- export const utils: any
20
- }
21
-
22
- declare module '@xto/base' {
23
- import { DefineComponent } from 'vue'
24
- export const Button: DefineComponent<any, any, any>
25
- export const Loading: DefineComponent<any, any, any>
26
- export const Icon: DefineComponent<any, any, any>
27
- export const Avatar: DefineComponent<any, any, any>
28
- export const Badge: DefineComponent<any, any, any>
29
- export const Tag: DefineComponent<any, any, any>
30
- export const Divider: DefineComponent<any, any, any>
31
- export const Space: DefineComponent<any, any, any>
32
- }
33
-
34
- declare module '@xto/base/es/style.css' {
35
- const content: string
36
- export default content
37
- }
38
-
39
- declare module '@xto/form' {
40
- import { DefineComponent } from 'vue'
41
- export const Input: DefineComponent<any, any, any>
42
- export const InputNumber: DefineComponent<any, any, any>
43
- export const Select: DefineComponent<any, any, any>
44
- export const Checkbox: DefineComponent<any, any, any>
45
- export const Radio: DefineComponent<any, any, any>
46
- export const Switch: DefineComponent<any, any, any>
47
- export const DatePicker: DefineComponent<any, any, any>
48
- export const Form: DefineComponent<any, any, any>
49
- export const FormItem: DefineComponent<any, any, any>
50
- export const Upload: DefineComponent<any, any, any>
51
- export const FormRule: any
52
- }
53
-
54
- declare module '@xto/form/es/style.css' {
55
- const content: string
56
- export default content
57
- }
58
-
59
- declare module '@xto/data' {
60
- import { DefineComponent } from 'vue'
61
- export const Table: DefineComponent<any, any, any>
62
- export const Pagination: DefineComponent<any, any, any>
63
- export const Tree: DefineComponent<any, any, any>
64
- export const TreeNode: DefineComponent<any, any, any>
65
- export const List: DefineComponent<any, any, any>
66
- export const Card: DefineComponent<any, any, any>
67
- export const Descriptions: DefineComponent<any, any, any>
68
- export const Tag: DefineComponent<any, any, any>
69
- export const Progress: DefineComponent<any, any, any>
70
- }
71
-
72
- declare module '@xto/data/es/style.css' {
73
- const content: string
74
- export default content
75
- }
76
-
77
- declare module '@xto/feedback' {
78
- import { DefineComponent } from 'vue'
79
- export const Message: {
80
- success: (msg: string) => void
81
- error: (msg: string) => void
82
- warning: (msg: string) => void
83
- info: (msg: string) => void
84
- }
85
- export const Notification: {
86
- success: (options: any) => void
87
- error: (options: any) => void
88
- warning: (options: any) => void
89
- info: (options: any) => void
90
- }
91
- export const Modal: DefineComponent<any, any, any>
92
- export const Drawer: DefineComponent<any, any, any>
93
- export const Popconfirm: DefineComponent<any, any, any>
94
- export const Tooltip: DefineComponent<any, any, any>
95
- export const Popover: DefineComponent<any, any, any>
96
- }
97
-
98
- declare module '@xto/feedback/es/style.css' {
99
- const content: string
100
- export default content
101
- }
102
-
103
- declare module '@xto/navigation' {
104
- import { DefineComponent } from 'vue'
105
- export const Menu: DefineComponent<any, any, any>
106
- export const MenuItem: DefineComponent<any, any, any>
107
- export const SubMenu: DefineComponent<any, any, any>
108
- export const Tabs: DefineComponent<any, any, any>
109
- export const TabPane: DefineComponent<any, any, any>
110
- export const Breadcrumb: DefineComponent<any, any, any>
111
- export const BreadcrumbItem: DefineComponent<any, any, any>
112
- export const Dropdown: DefineComponent<any, any, any>
113
- export const DropdownMenu: DefineComponent<any, any, any>
114
- export const DropdownItem: DefineComponent<any, any, any>
115
- }
116
-
117
- declare module '@xto/navigation/es/style.css' {
118
- const content: string
119
- export default content
120
- }
121
-
122
- declare module '@xto/layout' {
123
- import { DefineComponent } from 'vue'
124
- export const Layout: DefineComponent<any, any, any>
125
- export const Header: DefineComponent<any, any, any>
126
- export const Sider: DefineComponent<any, any, any>
127
- export const Content: DefineComponent<any, any, any>
128
- export const Footer: DefineComponent<any, any, any>
129
- export const Container: DefineComponent<any, any, any>
130
- }
131
-
132
- declare module '@xto/layout/es/style.css' {
133
- const content: string
134
- export default content
135
- }
136
-
137
- declare module '@xto/business' {
138
- import { DefineComponent } from 'vue'
139
- export const LoginForm: DefineComponent<any, any, any>
140
- export const RegisterForm: DefineComponent<any, any, any>
141
- export const SearchResult: DefineComponent<any, any, any>
142
- export const Comment: DefineComponent<any, any, any>
143
- export const Statistic: DefineComponent<any, any, any>
144
- }
145
-
146
- declare module '@xto/business/es/style.css' {
147
- const content: string
148
- export default content
1
+ declare module '@xto/core' {
2
+ export const version: string
3
+ export function install(app: any): void
4
+ }
5
+
6
+ declare module '@xto/core/es/index/index.mjs' {
7
+ export * from '@xto/core'
8
+ }
9
+
10
+ declare module '@xto/core/es/theme/index.mjs' {
11
+ export const theme: any
12
+ }
13
+
14
+ declare module '@xto/core/es/hooks/index.mjs' {
15
+ export const hooks: any
16
+ }
17
+
18
+ declare module '@xto/core/es/utils/index.mjs' {
19
+ export const utils: any
20
+ }
21
+
22
+ declare module '@xto/base' {
23
+ import { DefineComponent } from 'vue'
24
+ export const Button: DefineComponent<any, any, any>
25
+ export const Loading: DefineComponent<any, any, any>
26
+ export const Icon: DefineComponent<any, any, any>
27
+ export const Avatar: DefineComponent<any, any, any>
28
+ export const Badge: DefineComponent<any, any, any>
29
+ export const Tag: DefineComponent<any, any, any>
30
+ export const Divider: DefineComponent<any, any, any>
31
+ export const Space: DefineComponent<any, any, any>
32
+ }
33
+
34
+ declare module '@xto/base/es/style.css' {
35
+ const content: string
36
+ export default content
37
+ }
38
+
39
+ declare module '@xto/form' {
40
+ import { DefineComponent } from 'vue'
41
+ export const Input: DefineComponent<any, any, any>
42
+ export const InputNumber: DefineComponent<any, any, any>
43
+ export const Select: DefineComponent<any, any, any>
44
+ export const Checkbox: DefineComponent<any, any, any>
45
+ export const Radio: DefineComponent<any, any, any>
46
+ export const Switch: DefineComponent<any, any, any>
47
+ export const DatePicker: DefineComponent<any, any, any>
48
+ export const Form: DefineComponent<any, any, any>
49
+ export const FormItem: DefineComponent<any, any, any>
50
+ export const Upload: DefineComponent<any, any, any>
51
+ export const FormRule: any
52
+ }
53
+
54
+ declare module '@xto/form/es/style.css' {
55
+ const content: string
56
+ export default content
57
+ }
58
+
59
+ declare module '@xto/data' {
60
+ import { DefineComponent } from 'vue'
61
+ export const Table: DefineComponent<any, any, any>
62
+ export const Pagination: DefineComponent<any, any, any>
63
+ export const Tree: DefineComponent<any, any, any>
64
+ export const TreeNode: DefineComponent<any, any, any>
65
+ export const List: DefineComponent<any, any, any>
66
+ export const Card: DefineComponent<any, any, any>
67
+ export const Descriptions: DefineComponent<any, any, any>
68
+ export const Tag: DefineComponent<any, any, any>
69
+ export const Progress: DefineComponent<any, any, any>
70
+ }
71
+
72
+ declare module '@xto/data/es/style.css' {
73
+ const content: string
74
+ export default content
75
+ }
76
+
77
+ declare module '@xto/feedback' {
78
+ import { DefineComponent } from 'vue'
79
+ export const Message: {
80
+ success: (msg: string) => void
81
+ error: (msg: string) => void
82
+ warning: (msg: string) => void
83
+ info: (msg: string) => void
84
+ }
85
+ export const Notification: {
86
+ success: (options: any) => void
87
+ error: (options: any) => void
88
+ warning: (options: any) => void
89
+ info: (options: any) => void
90
+ }
91
+ export const Modal: DefineComponent<any, any, any>
92
+ export const Drawer: DefineComponent<any, any, any>
93
+ export const Popconfirm: DefineComponent<any, any, any>
94
+ export const Tooltip: DefineComponent<any, any, any>
95
+ export const Popover: DefineComponent<any, any, any>
96
+ }
97
+
98
+ declare module '@xto/feedback/es/style.css' {
99
+ const content: string
100
+ export default content
101
+ }
102
+
103
+ declare module '@xto/navigation' {
104
+ import { DefineComponent } from 'vue'
105
+ export const Menu: DefineComponent<any, any, any>
106
+ export const MenuItem: DefineComponent<any, any, any>
107
+ export const SubMenu: DefineComponent<any, any, any>
108
+ export const Tabs: DefineComponent<any, any, any>
109
+ export const TabPane: DefineComponent<any, any, any>
110
+ export const Breadcrumb: DefineComponent<any, any, any>
111
+ export const BreadcrumbItem: DefineComponent<any, any, any>
112
+ export const Dropdown: DefineComponent<any, any, any>
113
+ export const DropdownMenu: DefineComponent<any, any, any>
114
+ export const DropdownItem: DefineComponent<any, any, any>
115
+ }
116
+
117
+ declare module '@xto/navigation/es/style.css' {
118
+ const content: string
119
+ export default content
120
+ }
121
+
122
+ declare module '@xto/layout' {
123
+ import { DefineComponent } from 'vue'
124
+ export const Layout: DefineComponent<any, any, any>
125
+ export const Header: DefineComponent<any, any, any>
126
+ export const Sider: DefineComponent<any, any, any>
127
+ export const Content: DefineComponent<any, any, any>
128
+ export const Footer: DefineComponent<any, any, any>
129
+ export const Container: DefineComponent<any, any, any>
130
+ }
131
+
132
+ declare module '@xto/layout/es/style.css' {
133
+ const content: string
134
+ export default content
135
+ }
136
+
137
+ declare module '@xto/business' {
138
+ import { DefineComponent } from 'vue'
139
+ export const LoginForm: DefineComponent<any, any, any>
140
+ export const RegisterForm: DefineComponent<any, any, any>
141
+ export const SearchResult: DefineComponent<any, any, any>
142
+ export const Comment: DefineComponent<any, any, any>
143
+ export const Statistic: DefineComponent<any, any, any>
144
+ }
145
+
146
+ declare module '@xto/business/es/style.css' {
147
+ const content: string
148
+ export default content
149
149
  }
package/src/utils/auth.ts CHANGED
@@ -1,62 +1,86 @@
1
- /**
2
- * Token 管理
3
- */
4
-
5
- import { local } from './storage'
6
-
7
- const TOKEN_KEY = 'token'
8
- const REFRESH_TOKEN_KEY = 'refresh_token'
9
- const TOKEN_EXPIRE_KEY = 'token_expire'
10
-
11
- export interface TokenInfo {
12
- token: string
13
- refreshToken: string
14
- expireTime: number
15
- }
16
-
17
- export const getToken = (): string | null => {
18
- return local.get<string>(TOKEN_KEY)
19
- }
20
-
21
- export const setToken = (token: string): void => {
22
- local.set(TOKEN_KEY, token)
23
- }
24
-
25
- export const getRefreshToken = (): string | null => {
26
- return local.get<string>(REFRESH_TOKEN_KEY)
27
- }
28
-
29
- export const setRefreshToken = (refreshToken: string): void => {
30
- local.set(REFRESH_TOKEN_KEY, refreshToken)
31
- }
32
-
33
- export const getTokenExpire = (): number | null => {
34
- return local.get<number>(TOKEN_EXPIRE_KEY)
35
- }
36
-
37
- export const setTokenExpire = (expireTime: number): void => {
38
- local.set(TOKEN_EXPIRE_KEY, expireTime)
39
- }
40
-
41
- export const setTokenInfo = (info: TokenInfo): void => {
42
- setToken(info.token)
43
- setRefreshToken(info.refreshToken)
44
- setTokenExpire(info.expireTime)
45
- }
46
-
47
- export const clearToken = (): void => {
48
- local.remove(TOKEN_KEY)
49
- local.remove(REFRESH_TOKEN_KEY)
50
- local.remove(TOKEN_EXPIRE_KEY)
51
- }
52
-
53
- export const isTokenExpired = (): boolean => {
54
- const expireTime = getTokenExpire()
55
- if (!expireTime) return true
56
- return Date.now() > expireTime
57
- }
58
-
59
- export const hasToken = (): boolean => {
60
- const token = getToken()
61
- return !!token && !isTokenExpired()
1
+ /**
2
+ * Token 管理
3
+ */
4
+
5
+ import { local } from './storage'
6
+
7
+ const TOKEN_KEY = 'login_info'
8
+ const USER_INFO_KEY = 'user_info'
9
+
10
+ export interface LoginInfo {
11
+ accessToken: string
12
+ refreshToken: string
13
+ expiresTime: string
14
+ refreshTime: string
15
+ tokenType: string
16
+ code: string
17
+ }
18
+
19
+ export interface TokenInfo {
20
+ token: string
21
+ refreshToken: string
22
+ expireTime: number
23
+ }
24
+
25
+ // 获取登录信息
26
+ export const getLoginInfo = (): LoginInfo | null => {
27
+ return local.get<LoginInfo>(TOKEN_KEY)
28
+ }
29
+
30
+ // 设置登录信息
31
+ export const setLoginInfo = (data: Record<string, unknown>): void => {
32
+ const loginInfo: LoginInfo = {
33
+ accessToken: data['access_token'] as string,
34
+ refreshToken: data['refresh_token'] as string,
35
+ expiresTime: data['expires_time'] as string,
36
+ refreshTime: data['refresh_time'] as string,
37
+ tokenType: data['token_type'] as string,
38
+ code: data['code'] as string
39
+ }
40
+ local.set(TOKEN_KEY, loginInfo)
41
+ }
42
+
43
+ // 获取 access token
44
+ export const getToken = (): string | null => {
45
+ const loginInfo = getLoginInfo()
46
+ return loginInfo?.accessToken || null
47
+ }
48
+
49
+ // 获取 token type
50
+ export const getTokenType = (): string => {
51
+ const loginInfo = getLoginInfo()
52
+ return loginInfo?.tokenType || 'Bearer'
53
+ }
54
+
55
+ // 获取 code
56
+ export const getCode = (): string | null => {
57
+ const loginInfo = getLoginInfo()
58
+ return loginInfo?.code || null
59
+ }
60
+
61
+ // 清除登录信息
62
+ export const clearToken = (): void => {
63
+ local.remove(TOKEN_KEY)
64
+ local.remove(USER_INFO_KEY)
65
+ }
66
+
67
+ // 检查是否有 token
68
+ export const hasToken = (): boolean => {
69
+ const token = getToken()
70
+ return !!token
71
+ }
72
+
73
+ // 设置用户信息
74
+ export const setUserInfo = (userInfo: Record<string, unknown>): void => {
75
+ local.set(USER_INFO_KEY, userInfo)
76
+ }
77
+
78
+ // 获取用户信息
79
+ export const getUserInfo = (): Record<string, unknown> | null => {
80
+ return local.get<Record<string, unknown>>(USER_INFO_KEY)
81
+ }
82
+
83
+ // 清除用户信息
84
+ export const clearUserInfo = (): void => {
85
+ local.remove(USER_INFO_KEY)
62
86
  }