xto-fronted 0.1.7 → 0.1.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.
- package/README.md +23 -0
- package/dist/components/Login/index.vue.d.ts +15 -0
- package/dist/config/index.d.ts +25 -5
- package/dist/index.d.ts +17 -4
- package/dist/index.es.js +1272 -55
- package/dist/index.umd.js +1 -1
- package/dist/router/dynamicRoutes.d.ts +19 -25
- package/dist/router/index.d.ts +24 -4
- package/dist/router/staticRoutes.d.ts +15 -2
- package/dist/stores/menu.d.ts +14 -8
- package/dist/style.css +1 -1
- package/dist/utils/request.d.ts +8 -0
- package/package.json +2 -10
- package/.env.development +0 -3
- package/.env.production +0 -3
- package/dist/403-DM5wfQkM.js +0 -31
- package/dist/404-BurAu5LC.js +0 -31
- package/dist/index-BNiEld34.js +0 -15
- package/dist/index-Be9RiEfo.js +0 -98
- package/dist/index-BqRv1bdN.js +0 -1185
- package/dist/index-CQLVXvNJ.js +0 -15
- package/dist/index-CyiE8n2V.js +0 -15
- package/dist/index-xauR1bOL.js +0 -15
- package/dist/views/dashboard/index.vue.d.ts +0 -2
- package/dist/views/login/index.vue.d.ts +0 -4
- package/dist/views/system/menu/index.vue.d.ts +0 -2
- package/dist/views/system/role/index.vue.d.ts +0 -2
- package/dist/views/system/user/index.vue.d.ts +0 -2
- package/index.html +0 -13
- package/public/vite.svg +0 -10
- package/src/App.vue +0 -20
- package/src/api/auth.ts +0 -35
- package/src/api/menu.ts +0 -13
- package/src/api/system.ts +0 -65
- package/src/api/user.ts +0 -12
- package/src/assets/styles/_dark.scss +0 -407
- package/src/assets/styles/_reset.scss +0 -126
- package/src/assets/styles/_root.scss +0 -140
- package/src/assets/styles/_transition.scss +0 -119
- package/src/assets/styles/_variables.scss +0 -45
- package/src/assets/styles/index.scss +0 -187
- package/src/components/Layout/Footer.vue +0 -17
- package/src/components/Layout/Header.vue +0 -335
- package/src/components/Layout/Sidebar.vue +0 -213
- package/src/components/Layout/Tabs.vue +0 -20
- package/src/components/Layout/index.vue +0 -62
- package/src/composables/index.ts +0 -9
- package/src/composables/useApp.ts +0 -170
- package/src/composables/useAuth.ts +0 -70
- package/src/composables/useForm.ts +0 -79
- package/src/composables/useMenu.ts +0 -141
- package/src/composables/useTable.ts +0 -97
- package/src/config/index.ts +0 -19
- package/src/directives/permission.ts +0 -41
- package/src/enums/index.ts +0 -63
- package/src/env.d.ts +0 -17
- package/src/index.ts +0 -44
- package/src/main.ts +0 -29
- package/src/router/dynamicRoutes.ts +0 -163
- package/src/router/index.ts +0 -71
- package/src/router/staticRoutes.ts +0 -43
- package/src/stores/app.ts +0 -145
- package/src/stores/auth.ts +0 -45
- package/src/stores/index.ts +0 -15
- package/src/stores/menu.ts +0 -158
- package/src/stores/user.ts +0 -41
- package/src/types/api.d.ts +0 -103
- package/src/types/global.d.ts +0 -45
- package/src/types/router.d.ts +0 -48
- package/src/types/xto.d.ts +0 -149
- package/src/utils/auth.ts +0 -86
- package/src/utils/permission.ts +0 -30
- package/src/utils/request.ts +0 -126
- package/src/utils/storage.ts +0 -72
- package/src/views/dashboard/index.vue +0 -32
- package/src/views/error/403.vue +0 -57
- package/src/views/error/404.vue +0 -57
- package/src/views/login/index.vue +0 -141
- package/src/views/system/menu/index.vue +0 -32
- package/src/views/system/role/index.vue +0 -32
- package/src/views/system/user/index.vue +0 -32
- package/tsconfig.json +0 -26
- package/tsconfig.node.json +0 -11
- package/vite.config.ts +0 -139
- /package/dist/{views/error → components/Error}/403.vue.d.ts +0 -0
- /package/dist/{views/error → components/Error}/404.vue.d.ts +0 -0
package/src/stores/menu.ts
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 菜单状态
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { defineStore } from 'pinia'
|
|
6
|
-
import { ref, computed } from 'vue'
|
|
7
|
-
import type { MenuItem, RemoteMenuItem } from '@/types/api'
|
|
8
|
-
import { local } from '@/utils/storage'
|
|
9
|
-
|
|
10
|
-
export const useMenuStore = defineStore('menu', () => {
|
|
11
|
-
// 存储 key
|
|
12
|
-
const MENU_LIST_KEY = 'menu_list'
|
|
13
|
-
const MENU_BTN_LIST_KEY = 'menu_btn_list'
|
|
14
|
-
|
|
15
|
-
// 状态
|
|
16
|
-
const menuList = ref<MenuItem[]>(local.get<MenuItem[]>(MENU_LIST_KEY) || [])
|
|
17
|
-
const menuBtnListMap = ref<Record<string, MenuItem[]>>(local.get<Record<string, MenuItem[]>>(MENU_BTN_LIST_KEY) || {})
|
|
18
|
-
|
|
19
|
-
// 首页菜单信息
|
|
20
|
-
const indexMenu: MenuItem = {
|
|
21
|
-
code: 'home',
|
|
22
|
-
name: '首页',
|
|
23
|
-
icon: 'home',
|
|
24
|
-
closable: false,
|
|
25
|
-
default: false,
|
|
26
|
-
out: false,
|
|
27
|
-
path: '/dashboard',
|
|
28
|
-
title: '首页'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// 计算属性
|
|
32
|
-
const hasMenu = computed(() => menuList.value.length > 0)
|
|
33
|
-
|
|
34
|
-
// 获取首页地址
|
|
35
|
-
const index = computed(() => {
|
|
36
|
-
function recursion(menuList: MenuItem[]): string | null {
|
|
37
|
-
if (menuList && menuList.length > 0) {
|
|
38
|
-
for (let i = 0; i < menuList.length; i++) {
|
|
39
|
-
const menu = menuList[i]
|
|
40
|
-
if (menu.default) {
|
|
41
|
-
return menu.path
|
|
42
|
-
} else {
|
|
43
|
-
const url = recursion(menu.children || [])
|
|
44
|
-
if (url) {
|
|
45
|
-
return url
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return null
|
|
51
|
-
}
|
|
52
|
-
const indexUrl = recursion(menuList.value)
|
|
53
|
-
return indexUrl || indexMenu.path
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
// 解析后端菜单数据
|
|
57
|
-
const parseMenuData = (remoteMenuList: RemoteMenuItem[], parentMenuUrl?: string) => {
|
|
58
|
-
const localMenuList: MenuItem[] = []
|
|
59
|
-
|
|
60
|
-
if (!remoteMenuList || remoteMenuList.length <= 0) {
|
|
61
|
-
return localMenuList
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
remoteMenuList.forEach(remoteMenu => {
|
|
65
|
-
if (remoteMenu.type === 1) {
|
|
66
|
-
// 按钮权限
|
|
67
|
-
const btn: MenuItem = {
|
|
68
|
-
code: remoteMenu.menuCode,
|
|
69
|
-
name: remoteMenu.menuName,
|
|
70
|
-
path: '',
|
|
71
|
-
title: remoteMenu.menuName
|
|
72
|
-
}
|
|
73
|
-
const parentUrl = parentMenuUrl || ''
|
|
74
|
-
let btnList = menuBtnListMap.value[parentUrl] || []
|
|
75
|
-
btnList.push(btn)
|
|
76
|
-
menuBtnListMap.value[parentUrl] = btnList
|
|
77
|
-
} else {
|
|
78
|
-
// 菜单权限
|
|
79
|
-
const children: MenuItem[] = []
|
|
80
|
-
let menuPath = remoteMenu.menuUrl
|
|
81
|
-
|
|
82
|
-
// 处理外链
|
|
83
|
-
let isOut = remoteMenu.isOut || false
|
|
84
|
-
if (!isOut && remoteMenu.menuUrl) {
|
|
85
|
-
if (remoteMenu.menuUrl.startsWith('http')) {
|
|
86
|
-
menuPath = '/iframe/' + encodeURIComponent(menuPath)
|
|
87
|
-
} else if (remoteMenu.menuUrl.startsWith('keep-alive:')) {
|
|
88
|
-
menuPath = '/iframe/keep-alive/' + encodeURIComponent(menuPath.split('keep-alive:')[1])
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const menu: MenuItem = {
|
|
93
|
-
code: remoteMenu.menuCode,
|
|
94
|
-
name: remoteMenu.menuName,
|
|
95
|
-
path: menuPath,
|
|
96
|
-
icon: remoteMenu.icon,
|
|
97
|
-
closable: remoteMenu.closable,
|
|
98
|
-
default: remoteMenu.isDefault,
|
|
99
|
-
out: isOut,
|
|
100
|
-
children: children,
|
|
101
|
-
title: remoteMenu.menuName
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
localMenuList.push(menu)
|
|
105
|
-
|
|
106
|
-
// 递归处理子菜单
|
|
107
|
-
if (remoteMenu.children && remoteMenu.children.length > 0) {
|
|
108
|
-
const childMenus = parseMenuData(remoteMenu.children, remoteMenu.menuUrl)
|
|
109
|
-
menu.children = childMenus
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
return localMenuList
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// 设置菜单
|
|
118
|
-
const setMenuList = (menus: MenuItem[]) => {
|
|
119
|
-
menuList.value = menus
|
|
120
|
-
local.set(MENU_LIST_KEY, menus)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// 设置菜单(从后端数据)
|
|
124
|
-
const setMenuFromRemote = (remoteMenus: RemoteMenuItem[]) => {
|
|
125
|
-
// 清除旧数据
|
|
126
|
-
clearMenu()
|
|
127
|
-
|
|
128
|
-
// 添加首页
|
|
129
|
-
menuList.value.push(indexMenu)
|
|
130
|
-
|
|
131
|
-
// 解析后端菜单
|
|
132
|
-
const parsedMenus = parseMenuData(remoteMenus)
|
|
133
|
-
menuList.value.push(...parsedMenus)
|
|
134
|
-
|
|
135
|
-
// 保存到本地存储
|
|
136
|
-
local.set(MENU_LIST_KEY, menuList.value)
|
|
137
|
-
local.set(MENU_BTN_LIST_KEY, menuBtnListMap.value)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// 清除菜单
|
|
141
|
-
const clearMenu = () => {
|
|
142
|
-
menuList.value = []
|
|
143
|
-
menuBtnListMap.value = {}
|
|
144
|
-
local.remove(MENU_LIST_KEY)
|
|
145
|
-
local.remove(MENU_BTN_LIST_KEY)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
menuList,
|
|
150
|
-
menuBtnListMap,
|
|
151
|
-
hasMenu,
|
|
152
|
-
index,
|
|
153
|
-
indexMenu,
|
|
154
|
-
setMenuList,
|
|
155
|
-
setMenuFromRemote,
|
|
156
|
-
clearMenu
|
|
157
|
-
}
|
|
158
|
-
})
|
package/src/stores/user.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
export const useUserStore = defineStore('user', () => {
|
|
11
|
-
// 状态
|
|
12
|
-
const userInfo = ref<UserInfo | null>(local.get<UserInfo>('user_info'))
|
|
13
|
-
|
|
14
|
-
// 计算属性
|
|
15
|
-
const isLoggedIn = computed(() => !!userInfo.value)
|
|
16
|
-
const userName = computed(() => userInfo.value?.userName || '')
|
|
17
|
-
const avatar = computed(() => userInfo.value?.avatar || '')
|
|
18
|
-
const userId = computed(() => userInfo.value?.userId)
|
|
19
|
-
|
|
20
|
-
// 设置用户信息
|
|
21
|
-
const setUserInfo = (info: UserInfo) => {
|
|
22
|
-
userInfo.value = info
|
|
23
|
-
local.set('user_info', info)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// 清除用户信息
|
|
27
|
-
const clearUserInfo = () => {
|
|
28
|
-
userInfo.value = null
|
|
29
|
-
local.remove('user_info')
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
userInfo,
|
|
34
|
-
isLoggedIn,
|
|
35
|
-
userName,
|
|
36
|
-
avatar,
|
|
37
|
-
userId,
|
|
38
|
-
setUserInfo,
|
|
39
|
-
clearUserInfo
|
|
40
|
-
}
|
|
41
|
-
})
|
package/src/types/api.d.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
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
|
|
103
|
-
}
|
package/src/types/global.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 全局类型定义
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
// 通用对象类型
|
|
6
|
-
export type AnyObject = Record<string, unknown>
|
|
7
|
-
|
|
8
|
-
// 通用函数类型
|
|
9
|
-
export type AnyFunction = (...args: unknown[]) => unknown
|
|
10
|
-
|
|
11
|
-
// 值类型
|
|
12
|
-
export type ValueOf<T> = T[keyof T]
|
|
13
|
-
|
|
14
|
-
// 可空类型
|
|
15
|
-
export type Nullable<T> = T | null
|
|
16
|
-
|
|
17
|
-
// 可选类型
|
|
18
|
-
export type Optional<T> = T | undefined
|
|
19
|
-
|
|
20
|
-
// 深度可选
|
|
21
|
-
export type DeepPartial<T> = {
|
|
22
|
-
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// 深度必需
|
|
26
|
-
export type DeepRequired<T> = {
|
|
27
|
-
[P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : T[P]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// 深度只读
|
|
31
|
-
export type DeepReadonly<T> = {
|
|
32
|
-
readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P]
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// 提取数组元素类型
|
|
36
|
-
export type ArrayElement<T> = T extends readonly (infer E)[] ? E : never
|
|
37
|
-
|
|
38
|
-
// 提取 Promise 值类型
|
|
39
|
-
export type Awaited<T> = T extends Promise<infer U> ? U : T
|
|
40
|
-
|
|
41
|
-
// 排除 null 和 undefined
|
|
42
|
-
export type NonNullable<T> = T extends null | undefined ? never : T
|
|
43
|
-
|
|
44
|
-
// 枚举值类型
|
|
45
|
-
export type EnumValue<T extends Record<string, string | number>> = T[keyof T]
|
package/src/types/router.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 路由类型定义
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import 'vue-router'
|
|
6
|
-
|
|
7
|
-
declare module 'vue-router' {
|
|
8
|
-
interface RouteMeta {
|
|
9
|
-
// 页面标题
|
|
10
|
-
title?: string
|
|
11
|
-
// 图标
|
|
12
|
-
icon?: string
|
|
13
|
-
// 是否隐藏菜单
|
|
14
|
-
hidden?: boolean
|
|
15
|
-
// 是否缓存页面
|
|
16
|
-
keepAlive?: boolean
|
|
17
|
-
// 是否固定在 tabs 中
|
|
18
|
-
affix?: boolean
|
|
19
|
-
// 权限标识
|
|
20
|
-
permissions?: string[]
|
|
21
|
-
// 角色标识
|
|
22
|
-
roles?: string[]
|
|
23
|
-
// 面包屑
|
|
24
|
-
breadcrumb?: boolean
|
|
25
|
-
// 当前激活菜单
|
|
26
|
-
activeMenu?: string
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// 路由项
|
|
31
|
-
export interface AppRoute {
|
|
32
|
-
path: string
|
|
33
|
-
name?: string
|
|
34
|
-
redirect?: string
|
|
35
|
-
component?: () => Promise<unknown>
|
|
36
|
-
meta?: RouteMeta
|
|
37
|
-
children?: AppRoute[]
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// 动态路由
|
|
41
|
-
export interface DynamicRoute {
|
|
42
|
-
path: string
|
|
43
|
-
name: string
|
|
44
|
-
component: string
|
|
45
|
-
redirect?: string
|
|
46
|
-
meta?: RouteMeta
|
|
47
|
-
children?: DynamicRoute[]
|
|
48
|
-
}
|
package/src/types/xto.d.ts
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
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
|
-
}
|
package/src/utils/auth.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
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)
|
|
86
|
-
}
|
package/src/utils/permission.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 权限工具函数
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { useMenuStore } from '@/stores/menu'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 检查是否有权限(基于菜单按钮权限)
|
|
9
|
-
* @param permission 权限标识
|
|
10
|
-
*/
|
|
11
|
-
export function hasPermission(permission: string | string[]): boolean {
|
|
12
|
-
const menuStore = useMenuStore()
|
|
13
|
-
const currentPath = window.location.pathname
|
|
14
|
-
const btnList = menuStore.menuBtnListMap[currentPath] || []
|
|
15
|
-
const btnCodes = btnList.map(item => item.code)
|
|
16
|
-
|
|
17
|
-
if (Array.isArray(permission)) {
|
|
18
|
-
return permission.some(p => btnCodes.includes(p))
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return btnCodes.includes(permission)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 检查是否是管理员
|
|
26
|
-
*/
|
|
27
|
-
export function isAdmin(): boolean {
|
|
28
|
-
// 暂时返回 true,后续可根据实际需求实现
|
|
29
|
-
return true
|
|
30
|
-
}
|