zant-admin 1.0.4 → 2.0.1
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.en.md +414 -25
- package/README.md +460 -285
- package/bin/cli.js +3 -3
- package/bin/generator.js +502 -502
- package/bin/prompts.js +158 -158
- package/bin/utils.js +133 -133
- package/package.json +2 -2
- package/public/logo.png +0 -0
- package/src/App.vue +16 -16
- package/src/api/methods/department.js +36 -0
- package/src/api/methods/employee.js +22 -0
- package/src/api/methods/logError.js +8 -8
- package/src/api/methods/logOperation.js +8 -8
- package/src/api/methods/login.js +6 -6
- package/src/api/methods/position.js +26 -0
- package/src/api/methods/quartz.js +36 -36
- package/src/api/methods/region.js +16 -16
- package/src/api/methods/sysAccount.js +29 -29
- package/src/api/methods/sysDict.js +29 -29
- package/src/api/methods/sysDictItem.js +26 -26
- package/src/api/methods/sysMenu.js +42 -42
- package/src/api/methods/sysRole.js +35 -35
- package/src/api/methods/sysUser.js +25 -25
- package/src/api/methods/system.js +15 -15
- package/src/api/request.js +225 -225
- package/src/assets/css/style.css +2 -2
- package/src/assets/css/zcui.css +1023 -1023
- package/src/assets/imgs/logo.png +0 -0
- package/src/assets/imgs/md/console.png +0 -0
- package/src/assets/imgs/md/login.png +0 -0
- package/src/assets/imgs/md/menu.png +0 -0
- package/src/assets/imgs/md/serviceMonitoring.png +0 -0
- package/src/assets/imgs/md/statistics.png +0 -0
- package/src/components/FormTable.vue +5 -19
- package/src/components/IconPicker.vue +351 -351
- package/src/components/MainPage.vue +838 -838
- package/src/components/details/logErrorDetails.vue +58 -58
- package/src/components/details/logOperationDetails.vue +76 -76
- package/src/components/edit/QuartzEdit.vue +221 -221
- package/src/components/edit/SysAccountEdit.vue +185 -185
- package/src/components/edit/SysDictEdit.vue +116 -116
- package/src/components/edit/SysDictItemEdit.vue +136 -136
- package/src/components/edit/SysRoleEdit.vue +111 -111
- package/src/components/edit/organizationalStructure/DepartmentEdit.vue +162 -0
- package/src/components/edit/organizationalStructure/EmployeeEdit.vue +295 -0
- package/src/components/edit/organizationalStructure/PositionEdit.vue +166 -0
- package/src/components/edit/sysMenuEdit.vue +2 -1
- package/src/config/index.js +74 -74
- package/src/directives/permission.js +49 -49
- package/src/main.js +37 -37
- package/src/router/index.js +4 -6
- package/src/stores/config.js +43 -43
- package/src/stores/dict.js +33 -33
- package/src/stores/menu.js +81 -81
- package/src/stores/user.js +21 -21
- package/src/utils/baseEcharts.js +661 -661
- package/src/utils/dictTemplate.js +26 -26
- package/src/utils/regionUtils.js +173 -173
- package/src/utils/useFormCRUD.js +59 -59
- package/src/views/baiscstatis/center.vue +474 -474
- package/src/views/baiscstatis/iframePage.vue +29 -29
- package/src/views/baiscstatis/notFound.vue +192 -192
- package/src/views/console.vue +821 -821
- package/src/views/demo/button.vue +269 -269
- package/src/views/demo/importexport.vue +119 -119
- package/src/views/demo/region.vue +322 -322
- package/src/views/demo/statistics.vue +214 -214
- package/src/views/home.vue +6 -6
- package/src/views/login.vue +264 -149
- package/src/views/operations/log/logError.vue +78 -78
- package/src/views/operations/log/logLogin.vue +66 -66
- package/src/views/operations/log/logOperation.vue +103 -103
- package/src/views/operations/log/logQuartz.vue +56 -56
- package/src/views/operations/quartz.vue +179 -179
- package/src/views/operations/serviceMonitoring.vue +134 -134
- package/src/views/organizationalStructure/department.vue +194 -0
- package/src/views/organizationalStructure/employee.vue +234 -0
- package/src/views/organizationalStructure/position.vue +196 -0
- package/src/views/system/sysAccount.vue +128 -128
- package/src/views/system/sysDict.vue +159 -159
- package/src/views/system/sysDictItem.vue +118 -118
- package/src/views/system/sysMenu.vue +225 -225
- package/src/views/system/sysRole.vue +207 -207
- package/src/assets/imgs/md/1.png +0 -0
- package/src/assets/imgs/md/10.png +0 -0
- package/src/assets/imgs/md/11.png +0 -0
- package/src/assets/imgs/md/2.png +0 -0
- package/src/assets/imgs/md/3.png +0 -0
- package/src/assets/imgs/md/4.png +0 -0
- package/src/assets/imgs/md/5.png +0 -0
- package/src/assets/imgs/md/6.png +0 -0
- package/src/assets/imgs/md/7.png +0 -0
- package/src/assets/imgs/md/8.png +0 -0
- package/src/assets/imgs/md/9.png +0 -0
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { menuStore } from '@/stores/menu'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 按钮权限指令
|
|
5
|
-
* 使用方式:v-permission="'user:add'" 或 v-permission="['user:add', 'user:edit']"
|
|
6
|
-
*/
|
|
7
|
-
const permission = {
|
|
8
|
-
mounted(el, binding) {
|
|
9
|
-
const { value } = binding
|
|
10
|
-
const store = menuStore()
|
|
11
|
-
const { permissions } = store
|
|
12
|
-
|
|
13
|
-
if (value && value instanceof Array) {
|
|
14
|
-
// 多个权限,满足其中一个即可
|
|
15
|
-
const hasPermission = value.some(permission =>
|
|
16
|
-
permissions.includes(permission),
|
|
17
|
-
)
|
|
18
|
-
if (!hasPermission) {
|
|
19
|
-
el.parentNode && el.parentNode.removeChild(el)
|
|
20
|
-
}
|
|
21
|
-
} else if (value && typeof value === 'string') {
|
|
22
|
-
// 单个权限
|
|
23
|
-
if (!permissions.includes(value)) {
|
|
24
|
-
el.parentNode && el.parentNode.removeChild(el)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
updated(el, binding) {
|
|
29
|
-
// 更新时重新检查权限
|
|
30
|
-
const { value } = binding
|
|
31
|
-
const store = menuStore()
|
|
32
|
-
const { permissions } = store
|
|
33
|
-
|
|
34
|
-
if (value && value instanceof Array) {
|
|
35
|
-
const hasPermission = value.some(permission =>
|
|
36
|
-
permissions.includes(permission),
|
|
37
|
-
)
|
|
38
|
-
if (!hasPermission && el.parentNode) {
|
|
39
|
-
el.parentNode.removeChild(el)
|
|
40
|
-
}
|
|
41
|
-
} else if (value && typeof value === 'string') {
|
|
42
|
-
if (!permissions.includes(value) && el.parentNode) {
|
|
43
|
-
el.parentNode.removeChild(el)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export default permission
|
|
1
|
+
import { menuStore } from '@/stores/menu'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 按钮权限指令
|
|
5
|
+
* 使用方式:v-permission="'user:add'" 或 v-permission="['user:add', 'user:edit']"
|
|
6
|
+
*/
|
|
7
|
+
const permission = {
|
|
8
|
+
mounted(el, binding) {
|
|
9
|
+
const { value } = binding
|
|
10
|
+
const store = menuStore()
|
|
11
|
+
const { permissions } = store
|
|
12
|
+
|
|
13
|
+
if (value && value instanceof Array) {
|
|
14
|
+
// 多个权限,满足其中一个即可
|
|
15
|
+
const hasPermission = value.some(permission =>
|
|
16
|
+
permissions.includes(permission),
|
|
17
|
+
)
|
|
18
|
+
if (!hasPermission) {
|
|
19
|
+
el.parentNode && el.parentNode.removeChild(el)
|
|
20
|
+
}
|
|
21
|
+
} else if (value && typeof value === 'string') {
|
|
22
|
+
// 单个权限
|
|
23
|
+
if (!permissions.includes(value)) {
|
|
24
|
+
el.parentNode && el.parentNode.removeChild(el)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
updated(el, binding) {
|
|
29
|
+
// 更新时重新检查权限
|
|
30
|
+
const { value } = binding
|
|
31
|
+
const store = menuStore()
|
|
32
|
+
const { permissions } = store
|
|
33
|
+
|
|
34
|
+
if (value && value instanceof Array) {
|
|
35
|
+
const hasPermission = value.some(permission =>
|
|
36
|
+
permissions.includes(permission),
|
|
37
|
+
)
|
|
38
|
+
if (!hasPermission && el.parentNode) {
|
|
39
|
+
el.parentNode.removeChild(el)
|
|
40
|
+
}
|
|
41
|
+
} else if (value && typeof value === 'string') {
|
|
42
|
+
if (!permissions.includes(value) && el.parentNode) {
|
|
43
|
+
el.parentNode.removeChild(el)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default permission
|
package/src/main.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { createApp } from 'vue'
|
|
2
|
-
import { createPinia } from 'pinia'
|
|
3
|
-
import piniaPersist from 'pinia-plugin-persist'
|
|
4
|
-
import Antd from 'ant-design-vue'
|
|
5
|
-
import App from './App.vue'
|
|
6
|
-
import router from './router'
|
|
7
|
-
import './assets/css/style.css'
|
|
8
|
-
import './assets/css/zcui.css'
|
|
9
|
-
import * as Icons from '@ant-design/icons-vue'
|
|
10
|
-
// 引入权限指令
|
|
11
|
-
import permission from './directives/permission'
|
|
12
|
-
// 引入 Ant Design Vue 的语言包
|
|
13
|
-
|
|
14
|
-
const app = createApp(App)
|
|
15
|
-
// 注册所有图标为全局组件
|
|
16
|
-
Object.keys(Icons).forEach(key => {
|
|
17
|
-
app.component(key, Icons[key])
|
|
18
|
-
})
|
|
19
|
-
// 将图标注册为全局变量
|
|
20
|
-
app.config.globalProperties.$icons = Icons
|
|
21
|
-
|
|
22
|
-
const pinia = createPinia()
|
|
23
|
-
// 配置 Pinia 持久化插件
|
|
24
|
-
pinia.use(piniaPersist)
|
|
25
|
-
// 使用 Pinia
|
|
26
|
-
app.use(pinia)
|
|
27
|
-
//使用 Ant Design
|
|
28
|
-
app.use(Antd)
|
|
29
|
-
|
|
30
|
-
// 使用路由
|
|
31
|
-
app.use(router)
|
|
32
|
-
|
|
33
|
-
// 注册权限指令
|
|
34
|
-
app.directive('permission', permission)
|
|
35
|
-
|
|
36
|
-
// 挂载应用
|
|
37
|
-
app.mount('#app')
|
|
1
|
+
import { createApp } from 'vue'
|
|
2
|
+
import { createPinia } from 'pinia'
|
|
3
|
+
import piniaPersist from 'pinia-plugin-persist'
|
|
4
|
+
import Antd from 'ant-design-vue'
|
|
5
|
+
import App from './App.vue'
|
|
6
|
+
import router from './router'
|
|
7
|
+
import './assets/css/style.css'
|
|
8
|
+
import './assets/css/zcui.css'
|
|
9
|
+
import * as Icons from '@ant-design/icons-vue'
|
|
10
|
+
// 引入权限指令
|
|
11
|
+
import permission from './directives/permission'
|
|
12
|
+
// 引入 Ant Design Vue 的语言包
|
|
13
|
+
|
|
14
|
+
const app = createApp(App)
|
|
15
|
+
// 注册所有图标为全局组件
|
|
16
|
+
Object.keys(Icons).forEach(key => {
|
|
17
|
+
app.component(key, Icons[key])
|
|
18
|
+
})
|
|
19
|
+
// 将图标注册为全局变量
|
|
20
|
+
app.config.globalProperties.$icons = Icons
|
|
21
|
+
|
|
22
|
+
const pinia = createPinia()
|
|
23
|
+
// 配置 Pinia 持久化插件
|
|
24
|
+
pinia.use(piniaPersist)
|
|
25
|
+
// 使用 Pinia
|
|
26
|
+
app.use(pinia)
|
|
27
|
+
//使用 Ant Design
|
|
28
|
+
app.use(Antd)
|
|
29
|
+
|
|
30
|
+
// 使用路由
|
|
31
|
+
app.use(router)
|
|
32
|
+
|
|
33
|
+
// 注册权限指令
|
|
34
|
+
app.directive('permission', permission)
|
|
35
|
+
|
|
36
|
+
// 挂载应用
|
|
37
|
+
app.mount('#app')
|
package/src/router/index.js
CHANGED
|
@@ -45,6 +45,7 @@ const routes = [
|
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
path: 'notFound',
|
|
48
|
+
meta: { title: '404 Not Found', cache: true },
|
|
48
49
|
component: () => import('../views/baiscstatis/notFound.vue'),
|
|
49
50
|
},
|
|
50
51
|
],
|
|
@@ -95,7 +96,7 @@ async function loadDynamicRoutes() {
|
|
|
95
96
|
const parentRoute = {
|
|
96
97
|
path: route.path,
|
|
97
98
|
component: home,
|
|
98
|
-
|
|
99
|
+
meta: { title: route.title },
|
|
99
100
|
// children: [],
|
|
100
101
|
}
|
|
101
102
|
const addRoutes = (parentRoute, children) => {
|
|
@@ -103,9 +104,8 @@ async function loadDynamicRoutes() {
|
|
|
103
104
|
parentRoute.children = children.map(child => {
|
|
104
105
|
const childRoute = {
|
|
105
106
|
path: child.path,
|
|
106
|
-
meta: { title: child.title },
|
|
107
107
|
name: child.path.replace(/\//g, '-').substring(1),
|
|
108
|
-
meta: { cache: child.cache, fullPath: child.path },
|
|
108
|
+
meta: { title: child.title, cache: child.cache, fullPath: child.path },
|
|
109
109
|
}
|
|
110
110
|
if (child.type != 1) {
|
|
111
111
|
childRoute.component = loadComponent(child.path)
|
|
@@ -151,10 +151,8 @@ async function loadDynamicRoutes() {
|
|
|
151
151
|
|
|
152
152
|
// 全局前置守卫
|
|
153
153
|
router.beforeEach(async (to, from, next) => {
|
|
154
|
-
// document.title = to.meta.title || 'ZCloudVue'
|
|
155
|
-
// document.title = 'ZCloudVue'
|
|
156
154
|
const config = configStore()
|
|
157
|
-
document.title = config.projectName
|
|
155
|
+
document.title = to.meta.title ? to.meta.title + ' - ' + config.projectName : config.projectName
|
|
158
156
|
const user = useUserStore()
|
|
159
157
|
|
|
160
158
|
// 如果目标路由在白名单中,直接放行
|
package/src/stores/config.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { defineStore } from 'pinia'
|
|
2
|
-
import dayjs from 'dayjs'
|
|
3
|
-
import zhCN from 'ant-design-vue/es/locale/zh_CN'
|
|
4
|
-
import enUS from 'ant-design-vue/es/locale/en_US'
|
|
5
|
-
import 'dayjs/locale/zh-cn' // 中文
|
|
6
|
-
import 'dayjs/locale/en' // 英文
|
|
7
|
-
import { appConfig } from '@/config' // 导入全局配置
|
|
8
|
-
|
|
9
|
-
export const configStore = defineStore({
|
|
10
|
-
id: 'CONFIG',
|
|
11
|
-
state: () => ({
|
|
12
|
-
themeClass: appConfig.defaultTheme,
|
|
13
|
-
navigationMode: appConfig.defaultNavigationMode,
|
|
14
|
-
tableSize: appConfig.defaultTableSize,
|
|
15
|
-
tableBordered: appConfig.defaultTableBordered,
|
|
16
|
-
locale: zhCN,
|
|
17
|
-
dayjsLocale: appConfig.defaultLanguage,
|
|
18
|
-
projectName: appConfig.title, // 使用全局配置中的项目名称
|
|
19
|
-
}),
|
|
20
|
-
actions: {
|
|
21
|
-
setLocale(locale) {
|
|
22
|
-
this.locale = locale
|
|
23
|
-
this.dayjsLocale = locale === zhCN ? 'zh-cn' : 'en'
|
|
24
|
-
dayjs.locale(this.dayjsLocale)
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
persist: {
|
|
28
|
-
enabled: true,
|
|
29
|
-
strategies: [
|
|
30
|
-
{
|
|
31
|
-
key: 'CONFIG',
|
|
32
|
-
storage: localStorage,
|
|
33
|
-
paths: [
|
|
34
|
-
'themeClass',
|
|
35
|
-
'navigationMode',
|
|
36
|
-
'tableSize',
|
|
37
|
-
'tableBordered',
|
|
38
|
-
'locale',
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
},
|
|
43
|
-
})
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import dayjs from 'dayjs'
|
|
3
|
+
import zhCN from 'ant-design-vue/es/locale/zh_CN'
|
|
4
|
+
import enUS from 'ant-design-vue/es/locale/en_US'
|
|
5
|
+
import 'dayjs/locale/zh-cn' // 中文
|
|
6
|
+
import 'dayjs/locale/en' // 英文
|
|
7
|
+
import { appConfig } from '@/config' // 导入全局配置
|
|
8
|
+
|
|
9
|
+
export const configStore = defineStore({
|
|
10
|
+
id: 'CONFIG',
|
|
11
|
+
state: () => ({
|
|
12
|
+
themeClass: appConfig.defaultTheme,
|
|
13
|
+
navigationMode: appConfig.defaultNavigationMode,
|
|
14
|
+
tableSize: appConfig.defaultTableSize,
|
|
15
|
+
tableBordered: appConfig.defaultTableBordered,
|
|
16
|
+
locale: zhCN,
|
|
17
|
+
dayjsLocale: appConfig.defaultLanguage,
|
|
18
|
+
projectName: appConfig.title, // 使用全局配置中的项目名称
|
|
19
|
+
}),
|
|
20
|
+
actions: {
|
|
21
|
+
setLocale(locale) {
|
|
22
|
+
this.locale = locale
|
|
23
|
+
this.dayjsLocale = locale === zhCN ? 'zh-cn' : 'en'
|
|
24
|
+
dayjs.locale(this.dayjsLocale)
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
persist: {
|
|
28
|
+
enabled: true,
|
|
29
|
+
strategies: [
|
|
30
|
+
{
|
|
31
|
+
key: 'CONFIG',
|
|
32
|
+
storage: localStorage,
|
|
33
|
+
paths: [
|
|
34
|
+
'themeClass',
|
|
35
|
+
'navigationMode',
|
|
36
|
+
'tableSize',
|
|
37
|
+
'tableBordered',
|
|
38
|
+
'locale',
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
})
|
package/src/stores/dict.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { defineStore } from 'pinia'
|
|
2
|
-
import sysDict from '@/api/methods/sysDict'
|
|
3
|
-
export const dictStore = defineStore({
|
|
4
|
-
id: 'SYS_DICT',
|
|
5
|
-
state: () => ({
|
|
6
|
-
items: {},
|
|
7
|
-
}),
|
|
8
|
-
actions: {
|
|
9
|
-
initDictList() {
|
|
10
|
-
sysDict
|
|
11
|
-
.getDictList()
|
|
12
|
-
.then(res => {
|
|
13
|
-
res.data.forEach(item => {
|
|
14
|
-
this.items[item.type] = item.sysDictItem
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
.catch()
|
|
18
|
-
},
|
|
19
|
-
getDictItems(type) {
|
|
20
|
-
return this.items[type]
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
persist: {
|
|
24
|
-
enabled: true,
|
|
25
|
-
strategies: [
|
|
26
|
-
{
|
|
27
|
-
key: 'SYS_DICT',
|
|
28
|
-
storage: localStorage,
|
|
29
|
-
paths: ['items'],
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
})
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import sysDict from '@/api/methods/sysDict'
|
|
3
|
+
export const dictStore = defineStore({
|
|
4
|
+
id: 'SYS_DICT',
|
|
5
|
+
state: () => ({
|
|
6
|
+
items: {},
|
|
7
|
+
}),
|
|
8
|
+
actions: {
|
|
9
|
+
initDictList() {
|
|
10
|
+
sysDict
|
|
11
|
+
.getDictList()
|
|
12
|
+
.then(res => {
|
|
13
|
+
res.data.forEach(item => {
|
|
14
|
+
this.items[item.type] = item.sysDictItem
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
.catch()
|
|
18
|
+
},
|
|
19
|
+
getDictItems(type) {
|
|
20
|
+
return this.items[type]
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
persist: {
|
|
24
|
+
enabled: true,
|
|
25
|
+
strategies: [
|
|
26
|
+
{
|
|
27
|
+
key: 'SYS_DICT',
|
|
28
|
+
storage: localStorage,
|
|
29
|
+
paths: ['items'],
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
})
|
package/src/stores/menu.js
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import { defineStore } from 'pinia'
|
|
2
|
-
|
|
3
|
-
export const menuStore = defineStore({
|
|
4
|
-
id: 'MENU_RESULT',
|
|
5
|
-
state: () => {
|
|
6
|
-
return {
|
|
7
|
-
openmenuKey: [],
|
|
8
|
-
selectmenuKey: [],
|
|
9
|
-
tagmenus: [
|
|
10
|
-
{
|
|
11
|
-
key: 0,
|
|
12
|
-
parentId: '0',
|
|
13
|
-
title: `控制台`,
|
|
14
|
-
closable: false,
|
|
15
|
-
path: '/console',
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
menus: [],
|
|
19
|
-
permissions: [],
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
actions: {
|
|
23
|
-
setSelectmenuKey(keys) {
|
|
24
|
-
this.selectmenuKey = keys
|
|
25
|
-
},
|
|
26
|
-
setOpenmenuKey(keys) {
|
|
27
|
-
this.openmenuKey = keys
|
|
28
|
-
},
|
|
29
|
-
setMenus(menus) {
|
|
30
|
-
this.menus = menus
|
|
31
|
-
},
|
|
32
|
-
setPermissions(permissions) {
|
|
33
|
-
this.permissions = permissions
|
|
34
|
-
},
|
|
35
|
-
// 检查是否有指定权限
|
|
36
|
-
hasPermission(permission) {
|
|
37
|
-
if (!permission) return true
|
|
38
|
-
return this.permissions.includes(permission)
|
|
39
|
-
},
|
|
40
|
-
// 检查是否有多个权限中的任意一个
|
|
41
|
-
hasAnyPermission(permissions) {
|
|
42
|
-
if (
|
|
43
|
-
!permissions ||
|
|
44
|
-
!Array.isArray(permissions) ||
|
|
45
|
-
permissions.length === 0
|
|
46
|
-
)
|
|
47
|
-
return true
|
|
48
|
-
return permissions.some(permission =>
|
|
49
|
-
this.permissions.includes(permission),
|
|
50
|
-
)
|
|
51
|
-
},
|
|
52
|
-
// 检查是否拥有所有权限
|
|
53
|
-
hasAllPermissions(permissions) {
|
|
54
|
-
if (
|
|
55
|
-
!permissions ||
|
|
56
|
-
!Array.isArray(permissions) ||
|
|
57
|
-
permissions.length === 0
|
|
58
|
-
)
|
|
59
|
-
return true
|
|
60
|
-
return permissions.every(permission =>
|
|
61
|
-
this.permissions.includes(permission),
|
|
62
|
-
)
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
persist: {
|
|
66
|
-
enabled: true,
|
|
67
|
-
strategies: [
|
|
68
|
-
{
|
|
69
|
-
key: 'MENU_RESULT',
|
|
70
|
-
storage: localStorage,
|
|
71
|
-
paths: [
|
|
72
|
-
'menus',
|
|
73
|
-
'openmenuKey',
|
|
74
|
-
'selectmenuKey',
|
|
75
|
-
'tagmenus',
|
|
76
|
-
'permissions',
|
|
77
|
-
],
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
},
|
|
81
|
-
})
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
|
|
3
|
+
export const menuStore = defineStore({
|
|
4
|
+
id: 'MENU_RESULT',
|
|
5
|
+
state: () => {
|
|
6
|
+
return {
|
|
7
|
+
openmenuKey: [],
|
|
8
|
+
selectmenuKey: [],
|
|
9
|
+
tagmenus: [
|
|
10
|
+
{
|
|
11
|
+
key: 0,
|
|
12
|
+
parentId: '0',
|
|
13
|
+
title: `控制台`,
|
|
14
|
+
closable: false,
|
|
15
|
+
path: '/console',
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
menus: [],
|
|
19
|
+
permissions: [],
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
actions: {
|
|
23
|
+
setSelectmenuKey(keys) {
|
|
24
|
+
this.selectmenuKey = keys
|
|
25
|
+
},
|
|
26
|
+
setOpenmenuKey(keys) {
|
|
27
|
+
this.openmenuKey = keys
|
|
28
|
+
},
|
|
29
|
+
setMenus(menus) {
|
|
30
|
+
this.menus = menus
|
|
31
|
+
},
|
|
32
|
+
setPermissions(permissions) {
|
|
33
|
+
this.permissions = permissions
|
|
34
|
+
},
|
|
35
|
+
// 检查是否有指定权限
|
|
36
|
+
hasPermission(permission) {
|
|
37
|
+
if (!permission) return true
|
|
38
|
+
return this.permissions.includes(permission)
|
|
39
|
+
},
|
|
40
|
+
// 检查是否有多个权限中的任意一个
|
|
41
|
+
hasAnyPermission(permissions) {
|
|
42
|
+
if (
|
|
43
|
+
!permissions ||
|
|
44
|
+
!Array.isArray(permissions) ||
|
|
45
|
+
permissions.length === 0
|
|
46
|
+
)
|
|
47
|
+
return true
|
|
48
|
+
return permissions.some(permission =>
|
|
49
|
+
this.permissions.includes(permission),
|
|
50
|
+
)
|
|
51
|
+
},
|
|
52
|
+
// 检查是否拥有所有权限
|
|
53
|
+
hasAllPermissions(permissions) {
|
|
54
|
+
if (
|
|
55
|
+
!permissions ||
|
|
56
|
+
!Array.isArray(permissions) ||
|
|
57
|
+
permissions.length === 0
|
|
58
|
+
)
|
|
59
|
+
return true
|
|
60
|
+
return permissions.every(permission =>
|
|
61
|
+
this.permissions.includes(permission),
|
|
62
|
+
)
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
persist: {
|
|
66
|
+
enabled: true,
|
|
67
|
+
strategies: [
|
|
68
|
+
{
|
|
69
|
+
key: 'MENU_RESULT',
|
|
70
|
+
storage: localStorage,
|
|
71
|
+
paths: [
|
|
72
|
+
'menus',
|
|
73
|
+
'openmenuKey',
|
|
74
|
+
'selectmenuKey',
|
|
75
|
+
'tagmenus',
|
|
76
|
+
'permissions',
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
})
|
package/src/stores/user.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { defineStore } from 'pinia'
|
|
2
|
-
export const useUserStore = defineStore({
|
|
3
|
-
id: 'TOKEN_USER_INFO',
|
|
4
|
-
state: () => {
|
|
5
|
-
return {
|
|
6
|
-
token: '',
|
|
7
|
-
userInfo: {},
|
|
8
|
-
}
|
|
9
|
-
},
|
|
10
|
-
actions: {},
|
|
11
|
-
persist: {
|
|
12
|
-
enabled: true,
|
|
13
|
-
strategies: [
|
|
14
|
-
{
|
|
15
|
-
key: 'TOKEN_USER_INFO',
|
|
16
|
-
storage: localStorage,
|
|
17
|
-
paths: ['token', 'userInfo'],
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
})
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
export const useUserStore = defineStore({
|
|
3
|
+
id: 'TOKEN_USER_INFO',
|
|
4
|
+
state: () => {
|
|
5
|
+
return {
|
|
6
|
+
token: '',
|
|
7
|
+
userInfo: {},
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
actions: {},
|
|
11
|
+
persist: {
|
|
12
|
+
enabled: true,
|
|
13
|
+
strategies: [
|
|
14
|
+
{
|
|
15
|
+
key: 'TOKEN_USER_INFO',
|
|
16
|
+
storage: localStorage,
|
|
17
|
+
paths: ['token', 'userInfo'],
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
})
|