mooho-base-admin-plus 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +5 -0
- package/.env.development +0 -0
- package/.env.production +0 -0
- package/.eslintignore +11 -0
- package/.eslintrc.js +47 -0
- package/.prettierrc +15 -0
- package/README.md +18 -0
- package/dist/favicon.ico +0 -0
- package/dist/mooho-base-admin-plus.min.esm.js +131746 -0
- package/dist/mooho-base-admin-plus.min.js +279 -0
- package/dist/setting.js +31 -0
- package/dist/static/images/app-barcode.png +0 -0
- package/dist/static/images/login/bg.png +0 -0
- package/dist/static/images/login/logo.png +0 -0
- package/dist/static/images/login/password-active.png +0 -0
- package/dist/static/images/login/password-default.png +0 -0
- package/dist/static/images/login/signIn-img.png +0 -0
- package/dist/static/images/login/user-active.png +0 -0
- package/dist/static/images/login/user-default.png +0 -0
- package/dist/static/images/logo-dark.png +0 -0
- package/dist/static/images/logo-small.png +0 -0
- package/dist/static/images/logo.png +0 -0
- package/dist/static/images/logo.svg +510 -0
- package/dist/static/images/no-image.png +0 -0
- package/dist/style.css +4 -0
- package/index.html +18 -0
- package/other/pda.vue +28 -0
- package/package.json +59 -0
- package/public/favicon.ico +0 -0
- package/public/setting.js +31 -0
- package/public/static/images/app-barcode.png +0 -0
- package/public/static/images/login/bg.png +0 -0
- package/public/static/images/login/logo.png +0 -0
- package/public/static/images/login/password-active.png +0 -0
- package/public/static/images/login/password-default.png +0 -0
- package/public/static/images/login/signIn-img.png +0 -0
- package/public/static/images/login/user-active.png +0 -0
- package/public/static/images/login/user-default.png +0 -0
- package/public/static/images/logo-dark.png +0 -0
- package/public/static/images/logo-small.png +0 -0
- package/public/static/images/logo.png +0 -0
- package/public/static/images/logo.svg +510 -0
- package/public/static/images/no-image.png +0 -0
- package/src/App.vue +60 -0
- package/src/api/application.js +35 -0
- package/src/api/customModel.js +187 -0
- package/src/api/customPage.js +15 -0
- package/src/api/customTable.js +24 -0
- package/src/api/dataSource.js +93 -0
- package/src/api/dataView.js +199 -0
- package/src/api/dictType.js +23 -0
- package/src/api/entityView.js +13 -0
- package/src/api/enum.js +15 -0
- package/src/api/filterColumn.js +16 -0
- package/src/api/model.js +244 -0
- package/src/api/movePlan.js +29 -0
- package/src/api/notification.js +28 -0
- package/src/api/openApiPermission.js +25 -0
- package/src/api/permission.js +51 -0
- package/src/api/planJob.js +15 -0
- package/src/api/process.js +23 -0
- package/src/api/processDef.js +36 -0
- package/src/api/processInst.js +16 -0
- package/src/api/rolePermission.js +17 -0
- package/src/api/roleProperty.js +36 -0
- package/src/api/shortcut.js +20 -0
- package/src/api/system.js +23 -0
- package/src/api/task.js +56 -0
- package/src/api/taskQueue.js +24 -0
- package/src/api/user.js +45 -0
- package/src/api/viewColumn.js +16 -0
- package/src/assets/svg/body.svg +17 -0
- package/src/assets/svg/header-theme-dark.svg +40 -0
- package/src/assets/svg/header-theme-primary.svg +40 -0
- package/src/assets/svg/header-top.svg +40 -0
- package/src/assets/svg/icon-happy.svg +1 -0
- package/src/assets/svg/icon-sad.svg +1 -0
- package/src/assets/svg/icon-social-bilibili.svg +1 -0
- package/src/assets/svg/icon-social-dingding.svg +1 -0
- package/src/assets/svg/icon-social-facebook.svg +1 -0
- package/src/assets/svg/icon-social-juejin.svg +1 -0
- package/src/assets/svg/icon-social-qq.svg +1 -0
- package/src/assets/svg/icon-social-twitter.svg +1 -0
- package/src/assets/svg/icon-social-wechat.svg +1 -0
- package/src/assets/svg/icon-social-weibo.svg +1 -0
- package/src/assets/svg/icon-social-zhihu.svg +1 -0
- package/src/assets/svg/nav-theme-dark.svg +40 -0
- package/src/assets/svg/nav-theme-light.svg +40 -0
- package/src/components/copyright/index.vue +28 -0
- package/src/components/home/notice-list.vue +62 -0
- package/src/components/home/shortcut.vue +125 -0
- package/src/components/input/dialog-select.vue +301 -0
- package/src/components/input/item-select.vue +195 -0
- package/src/components/link/index.vue +54 -0
- package/src/components/richEditor/index.vue +86 -0
- package/src/components/upload/file-upload.vue +84 -0
- package/src/components/upload/upload-attachment.vue +119 -0
- package/src/components/upload/upload-image.vue +212 -0
- package/src/components/view/column-check.vue +223 -0
- package/src/components/view/column-edit.vue +850 -0
- package/src/components/view/column-select.vue +206 -0
- package/src/components/view/condition-edit.vue +164 -0
- package/src/components/view/filter-edit.vue +633 -0
- package/src/components/view/filter-setting.vue +126 -0
- package/src/components/view/form-setting-layout.vue +375 -0
- package/src/components/view/form-setting.vue +247 -0
- package/src/components/view/group-column.vue +104 -0
- package/src/components/view/group-method.vue +104 -0
- package/src/components/view/mixin.js +72 -0
- package/src/components/view/modal-form-filter.vue +319 -0
- package/src/components/view/modal-form-sort.vue +248 -0
- package/src/components/view/modal-form.vue +453 -0
- package/src/components/view/modal-table.vue +471 -0
- package/src/components/view/table-filter.vue +702 -0
- package/src/components/view/table-setting.vue +533 -0
- package/src/components/view/view-chart.vue +423 -0
- package/src/components/view/view-form-draggable.vue +837 -0
- package/src/components/view/view-form.vue +1444 -0
- package/src/components/view/view-table.vue +2261 -0
- package/src/components/workflow/flow-chart.vue +846 -0
- package/src/directive/focus.js +10 -0
- package/src/directive/tabHide.js +9 -0
- package/src/i18n/index.js +15 -0
- package/src/i18n/locale/en-US.js +1 -0
- package/src/i18n/locale/lang.js +1 -0
- package/src/i18n/locale/zh-CN.js +1 -0
- package/src/i18n/locale.js +102 -0
- package/src/index.js +222 -0
- package/src/layouts/basic-layout/header-breadcrumb/index.vue +122 -0
- package/src/layouts/basic-layout/header-collapse/index.vue +44 -0
- package/src/layouts/basic-layout/header-fullscreen/index.vue +19 -0
- package/src/layouts/basic-layout/header-i18n/index.vue +45 -0
- package/src/layouts/basic-layout/header-log/index.vue +41 -0
- package/src/layouts/basic-layout/header-logo/index.vue +23 -0
- package/src/layouts/basic-layout/header-notice/index.vue +218 -0
- package/src/layouts/basic-layout/header-reload/index.vue +21 -0
- package/src/layouts/basic-layout/header-search/index.vue +37 -0
- package/src/layouts/basic-layout/header-setting/index.vue +219 -0
- package/src/layouts/basic-layout/header-user/index.vue +175 -0
- package/src/layouts/basic-layout/i18n.js +50 -0
- package/src/layouts/basic-layout/index.vue +280 -0
- package/src/layouts/basic-layout/menu-head/index.vue +120 -0
- package/src/layouts/basic-layout/menu-head/title.vue +48 -0
- package/src/layouts/basic-layout/menu-side/index.vue +113 -0
- package/src/layouts/basic-layout/menu-side/menu-collapse.vue +76 -0
- package/src/layouts/basic-layout/menu-side/menu-item.vue +31 -0
- package/src/layouts/basic-layout/menu-side/menu-title.vue +56 -0
- package/src/layouts/basic-layout/menu-side/submenu.vue +31 -0
- package/src/layouts/basic-layout/mixins/click-item.js +21 -0
- package/src/layouts/basic-layout/mixins/sider-menu-badge.js +13 -0
- package/src/layouts/basic-layout/mixins/translate-title.js +11 -0
- package/src/layouts/basic-layout/tabs/index.vue +192 -0
- package/src/layouts/basic-layout/water-mark/index.vue +29 -0
- package/src/libs/lodop/index.js +145 -0
- package/src/libs/random_str.js +10 -0
- package/src/libs/request/index.js +158 -0
- package/src/libs/system/index.js +234 -0
- package/src/libs/util.cookies.js +44 -0
- package/src/libs/util.db.js +13 -0
- package/src/libs/util.js +55 -0
- package/src/libs/util.log.js +88 -0
- package/src/libs/water-mark.js +44 -0
- package/src/menu/header.js +20 -0
- package/src/menu/modules/dashboard.js +23 -0
- package/src/menu/sider.js +12 -0
- package/src/mixins/app.js +9 -0
- package/src/mixins/page.js +643 -0
- package/src/pages/account/login.vue +101 -0
- package/src/pages/common/home.vue +169 -0
- package/src/pages/common/task-form.vue +350 -0
- package/src/pages/common/todo.vue +31 -0
- package/src/pages/system/apiLog.vue +79 -0
- package/src/pages/system/applicationType.vue +182 -0
- package/src/pages/system/customPage.vue +62 -0
- package/src/pages/system/customTable.vue +98 -0
- package/src/pages/system/dict.vue +36 -0
- package/src/pages/system/dictType.vue +58 -0
- package/src/pages/system/entityView.vue +38 -0
- package/src/pages/system/error/404.vue +6 -0
- package/src/pages/system/extendColumn.vue +99 -0
- package/src/pages/system/formView.vue +136 -0
- package/src/pages/system/log.vue +55 -0
- package/src/pages/system/notice.vue +26 -0
- package/src/pages/system/openApi.vue +26 -0
- package/src/pages/system/openUser.vue +66 -0
- package/src/pages/system/organization.vue +98 -0
- package/src/pages/system/organizationType.vue +26 -0
- package/src/pages/system/permission.vue +175 -0
- package/src/pages/system/planJob.vue +40 -0
- package/src/pages/system/printTemplate.vue +48 -0
- package/src/pages/system/process.vue +79 -0
- package/src/pages/system/processType.vue +26 -0
- package/src/pages/system/role.vue +395 -0
- package/src/pages/system/rolePropertyEdit.vue +480 -0
- package/src/pages/system/sequenceSetting.vue +26 -0
- package/src/pages/system/systemData.vue +52 -0
- package/src/pages/system/tableView.vue +386 -0
- package/src/pages/system/taskQueue.vue +48 -0
- package/src/pages/system/user.vue +250 -0
- package/src/pages/template/processPage.vue +243 -0
- package/src/pages/template/reportPage.vue +66 -0
- package/src/pages/template/viewPage.vue +139 -0
- package/src/plugins/auth/index.js +21 -0
- package/src/plugins/error/index.js +31 -0
- package/src/plugins/index.js +24 -0
- package/src/plugins/sweetalert2/index.js +20 -0
- package/src/router/dynamic.js +183 -0
- package/src/router/index.js +84 -0
- package/src/setting.js +202 -0
- package/src/store/index.js +9 -0
- package/src/store/modules/admin/index.js +16 -0
- package/src/store/modules/admin/modules/account.js +103 -0
- package/src/store/modules/admin/modules/cache.js +119 -0
- package/src/store/modules/admin/modules/dataView.js +112 -0
- package/src/store/modules/admin/modules/db.js +231 -0
- package/src/store/modules/admin/modules/i18n.js +87 -0
- package/src/store/modules/admin/modules/layout.js +115 -0
- package/src/store/modules/admin/modules/loader.js +44 -0
- package/src/store/modules/admin/modules/log.js +77 -0
- package/src/store/modules/admin/modules/menu.js +338 -0
- package/src/store/modules/admin/modules/page.js +466 -0
- package/src/store/modules/admin/modules/user.js +96 -0
- package/src/store/modules/admin/modules/viewPage.js +34 -0
- package/src/styles/common.less +47 -0
- package/src/styles/css/default.css +510 -0
- package/src/styles/css/login.css +1217 -0
- package/src/styles/default/index.less +6 -0
- package/src/styles/font/demo.css +539 -0
- package/src/styles/font/demo_index.html +372 -0
- package/src/styles/font/icon-demo/demo.css +539 -0
- package/src/styles/font/icon-demo/demo_index.html +423 -0
- package/src/styles/font/icon-demo/iconfont.css +61 -0
- package/src/styles/font/icon-demo/iconfont.eot +0 -0
- package/src/styles/font/icon-demo/iconfont.js +1 -0
- package/src/styles/font/icon-demo/iconfont.svg +59 -0
- package/src/styles/font/icon-demo/iconfont.ttf +0 -0
- package/src/styles/font/icon-demo/iconfont.woff +0 -0
- package/src/styles/font/icon-demo/iconfont.woff2 +0 -0
- package/src/styles/font/iconfont.css +47 -0
- package/src/styles/font/iconfont.js +1 -0
- package/src/styles/font/iconfont.json +65 -0
- package/src/styles/font/iconfont.ttf +0 -0
- package/src/styles/font/iconfont.woff +0 -0
- package/src/styles/font/iconfont.woff2 +0 -0
- package/src/styles/font/ionicons.svg +870 -0
- package/src/styles/font/ionicons.ttf +0 -0
- package/src/styles/font/ionicons.woff +0 -0
- package/src/styles/font/ionicons.woff2 +0 -0
- package/src/styles/index.less +7 -0
- package/src/styles/layout/basic-layout/layout.less +527 -0
- package/src/styles/layout/basic-layout/menu.less +274 -0
- package/src/styles/layout/index.less +2 -0
- package/src/styles/setting.less +6 -0
- package/styleguide.config.js +22 -0
- package/test/api/barcode.js +50 -0
- package/test/api/inbound.js +47 -0
- package/test/api/interfaceLog.js +15 -0
- package/test/api/interfaceQueue.js +15 -0
- package/test/api/interfaceServer.js +29 -0
- package/test/api/movePlan.js +50 -0
- package/test/api/movePlanItem.js +13 -0
- package/test/api/moveType.js +22 -0
- package/test/api/openApiPermission.js +25 -0
- package/test/api/outbound.js +40 -0
- package/test/api/permission.js +34 -0
- package/test/api/rolePermission.js +17 -0
- package/test/api/user.js +40 -0
- package/test/api/viewColumn.js +16 -0
- package/test/api/warehouse.js +13 -0
- package/test/api/warehouseMoveType.js +18 -0
- package/test/main.js +55 -0
- package/test/package.js +33 -0
- package/test/pages/home/index.vue +22 -0
- package/test/pages/task/test.vue +28 -0
- package/test/pages/test/dataViewTest.vue +28 -0
- package/test/pages/test/logReport.vue +25 -0
- package/test/pages/test/testPage.vue +38 -0
- package/test/router/routes.js +88 -0
- package/test/setting.env.js +22 -0
- package/test/styles/css/custom.css +0 -0
- package/test/styles/css/login.css +1217 -0
- package/vite.config.js +72 -0
- package/vue.config.js +20 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import store from '../../store';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import util from '../util';
|
|
4
|
+
import router from '../../router';
|
|
5
|
+
import swal from 'sweetalert2';
|
|
6
|
+
import Setting from '../../setting';
|
|
7
|
+
|
|
8
|
+
// import { Message, Notice } from 'view-design';
|
|
9
|
+
|
|
10
|
+
// 创建一个错误
|
|
11
|
+
function errorCreate(msg) {
|
|
12
|
+
const err = new Error(msg);
|
|
13
|
+
errorLog(err);
|
|
14
|
+
throw err;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 记录和显示错误
|
|
18
|
+
function errorLog(err) {
|
|
19
|
+
// 添加到日志
|
|
20
|
+
store.dispatch('admin/log/push', {
|
|
21
|
+
message: '数据请求异常',
|
|
22
|
+
type: 'error',
|
|
23
|
+
meta: {
|
|
24
|
+
error: err
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
// 打印到控制台
|
|
28
|
+
if (process.env.NODE_ENV === 'development') {
|
|
29
|
+
util.log.error('>>>>>> Error >>>>>>');
|
|
30
|
+
console.log(err);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
swal.fire({
|
|
34
|
+
title: err.message,
|
|
35
|
+
icon: 'error',
|
|
36
|
+
confirmButtonText: '确定',
|
|
37
|
+
confirmButtonColor: '#2d8cf0',
|
|
38
|
+
cancelButtonText: '取消'
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//axios.defaults.baseURL = 'aaa';
|
|
43
|
+
|
|
44
|
+
// 创建一个 axios 实例
|
|
45
|
+
const service = axios.create({
|
|
46
|
+
baseURL: Setting.apiBaseURL
|
|
47
|
+
// timeout: 5000 // 请求超时时间
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// 请求拦截器
|
|
51
|
+
service.interceptors.request.use(
|
|
52
|
+
config => {
|
|
53
|
+
store.commit('admin/loader/start');
|
|
54
|
+
|
|
55
|
+
// 在请求发送之前做一些处理
|
|
56
|
+
const token = util.cookies.get('token');
|
|
57
|
+
// 让每个请求携带token-- ['X-Token']为自定义key 请根据实际情况自行修改
|
|
58
|
+
config.headers['Authorization'] = 'Bearer ' + token;
|
|
59
|
+
return config;
|
|
60
|
+
},
|
|
61
|
+
error => {
|
|
62
|
+
// 发送失败
|
|
63
|
+
console.log(error);
|
|
64
|
+
Promise.reject(error);
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
// 响应拦截器
|
|
69
|
+
service.interceptors.response.use(
|
|
70
|
+
response => {
|
|
71
|
+
store.commit('admin/loader/end');
|
|
72
|
+
|
|
73
|
+
// dataAxios 是 axios 返回数据中的 data
|
|
74
|
+
const dataAxios = response.data;
|
|
75
|
+
|
|
76
|
+
// return dataAxios;
|
|
77
|
+
|
|
78
|
+
// 这个状态码是和后端约定的
|
|
79
|
+
const code = dataAxios.code;
|
|
80
|
+
|
|
81
|
+
// console.log('dataAxios', dataAxios)
|
|
82
|
+
// console.log('code', code)
|
|
83
|
+
// 根据 code 进行判断
|
|
84
|
+
if (code == null) {
|
|
85
|
+
// 如果没有 code 代表这不是项目后端开发的接口
|
|
86
|
+
return dataAxios;
|
|
87
|
+
} else {
|
|
88
|
+
// 有 code 代表这是一个后端接口 可以进行进一步的判断
|
|
89
|
+
switch (code) {
|
|
90
|
+
case 0:
|
|
91
|
+
// [ 示例 ] code === 0 代表没有错误
|
|
92
|
+
return dataAxios.data;
|
|
93
|
+
// case 401:
|
|
94
|
+
// console.log('401');
|
|
95
|
+
// router.push('/account/login');
|
|
96
|
+
// // [ 示例 ] code === 0 代表没有错误
|
|
97
|
+
// return dataAxios.data;
|
|
98
|
+
// case 'xxx':
|
|
99
|
+
// // [ 示例 ] 其它和后台约定的 code
|
|
100
|
+
// errorCreate(`[ code: xxx ] ${dataAxios.msg}: ${response.config.url}`);
|
|
101
|
+
// break;
|
|
102
|
+
default:
|
|
103
|
+
// 不是正确的 code
|
|
104
|
+
errorCreate(dataAxios.message);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
error => {
|
|
109
|
+
if (error && error.response && error.response.status === 401) {
|
|
110
|
+
router.push('/login?redirect=' + router.history._startLocation);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
store.commit('admin/loader/end');
|
|
114
|
+
if (error && error.response) {
|
|
115
|
+
switch (error.response.status) {
|
|
116
|
+
case 400:
|
|
117
|
+
error.message = '请求错误';
|
|
118
|
+
break;
|
|
119
|
+
case 401:
|
|
120
|
+
error.message = '未授权,请登录';
|
|
121
|
+
break;
|
|
122
|
+
case 403:
|
|
123
|
+
error.message = '拒绝访问';
|
|
124
|
+
break;
|
|
125
|
+
case 404:
|
|
126
|
+
error.message = `请求地址出错: ${error.response.config.url}`;
|
|
127
|
+
break;
|
|
128
|
+
case 408:
|
|
129
|
+
error.message = '请求超时';
|
|
130
|
+
break;
|
|
131
|
+
case 500:
|
|
132
|
+
error.message = '内部错误';
|
|
133
|
+
break;
|
|
134
|
+
case 501:
|
|
135
|
+
error.message = '服务未实现';
|
|
136
|
+
break;
|
|
137
|
+
case 502:
|
|
138
|
+
error.message = '网关错误';
|
|
139
|
+
break;
|
|
140
|
+
case 503:
|
|
141
|
+
error.message = '服务不可用';
|
|
142
|
+
break;
|
|
143
|
+
case 504:
|
|
144
|
+
error.message = '网关超时';
|
|
145
|
+
break;
|
|
146
|
+
case 505:
|
|
147
|
+
error.message = 'HTTP版本不受支持';
|
|
148
|
+
break;
|
|
149
|
+
default:
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
errorLog(error);
|
|
154
|
+
return Promise.reject(error);
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
export default service;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 系统内置方法集,正常情况下您不应该修改或移除此文件
|
|
3
|
+
* */
|
|
4
|
+
|
|
5
|
+
import { cloneDeep } from 'lodash';
|
|
6
|
+
import Setting from '../../setting';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @description 根据当前路由,找打顶部菜单名称
|
|
10
|
+
* @param {String} currentPath 当前路径
|
|
11
|
+
* @param {Array} menuList 所有路径
|
|
12
|
+
* */
|
|
13
|
+
function getHeaderName(currentPath, menuList) {
|
|
14
|
+
const allMenus = [];
|
|
15
|
+
menuList.forEach(menu => {
|
|
16
|
+
const headerName = menu.header || '';
|
|
17
|
+
const menus = transferMenu(menu, headerName);
|
|
18
|
+
allMenus.push({
|
|
19
|
+
path: menu.path,
|
|
20
|
+
header: headerName
|
|
21
|
+
});
|
|
22
|
+
menus.forEach(item => allMenus.push(item));
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const currentMenu = allMenus.find(item => item.path === currentPath);
|
|
26
|
+
return currentMenu ? currentMenu.header : null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function transferMenu(menu, headerName) {
|
|
30
|
+
if (menu.children && menu.children.length) {
|
|
31
|
+
return menu.children.reduce((all, item) => {
|
|
32
|
+
all.push({
|
|
33
|
+
path: item.path,
|
|
34
|
+
header: headerName
|
|
35
|
+
});
|
|
36
|
+
const foundChildren = transferMenu(item, headerName);
|
|
37
|
+
return all.concat(foundChildren);
|
|
38
|
+
}, []);
|
|
39
|
+
} else {
|
|
40
|
+
return [menu];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { getHeaderName };
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @description 根据当前顶栏菜单 name,找到对应的二级菜单
|
|
48
|
+
* @param {Array} menuList 所有的二级菜单
|
|
49
|
+
* @param {String} headerName 当前顶栏菜单的 name
|
|
50
|
+
* */
|
|
51
|
+
function getMenuSider(menuList, headerName = '') {
|
|
52
|
+
if (headerName) {
|
|
53
|
+
return menuList.filter(item => item.header === headerName);
|
|
54
|
+
} else {
|
|
55
|
+
return menuList;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { getMenuSider };
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @description 根据当前路由,找到其所有父菜单 path,作为展开侧边栏 open-names 依据
|
|
63
|
+
* @param {String} currentPath 当前路径
|
|
64
|
+
* @param {Array} menuList 所有路径
|
|
65
|
+
* */
|
|
66
|
+
function getSiderSubmenu(currentPath, menuList) {
|
|
67
|
+
const allMenus = [];
|
|
68
|
+
menuList.forEach(menu => {
|
|
69
|
+
const menus = transferSubMenu(menu, []);
|
|
70
|
+
allMenus.push({
|
|
71
|
+
path: menu.path,
|
|
72
|
+
openNames: []
|
|
73
|
+
});
|
|
74
|
+
menus.forEach(item => allMenus.push(item));
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const currentMenu = allMenus.find(item => item.path === currentPath);
|
|
78
|
+
return currentMenu ? currentMenu.openNames : [];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function transferSubMenu(menu, openNames) {
|
|
82
|
+
if (menu.children && menu.children.length) {
|
|
83
|
+
const itemOpenNames = openNames.concat([menu.path]);
|
|
84
|
+
return menu.children.reduce((all, item) => {
|
|
85
|
+
all.push({
|
|
86
|
+
path: item.path,
|
|
87
|
+
openNames: itemOpenNames
|
|
88
|
+
});
|
|
89
|
+
const foundChildren = transferSubMenu(item, itemOpenNames);
|
|
90
|
+
return all.concat(foundChildren);
|
|
91
|
+
}, []);
|
|
92
|
+
} else {
|
|
93
|
+
return [menu].map(item => {
|
|
94
|
+
return {
|
|
95
|
+
path: item.path,
|
|
96
|
+
openNames: openNames
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { getSiderSubmenu };
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @description 递归获取所有子菜单
|
|
106
|
+
* */
|
|
107
|
+
function getAllSiderMenu(menuList) {
|
|
108
|
+
let allMenus = [];
|
|
109
|
+
|
|
110
|
+
menuList.forEach(menu => {
|
|
111
|
+
if (menu.children && menu.children.length) {
|
|
112
|
+
const menus = getMenuChildren(menu);
|
|
113
|
+
menus.forEach(item => allMenus.push(item));
|
|
114
|
+
} else {
|
|
115
|
+
allMenus.push(menu);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return allMenus;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function getMenuChildren(menu) {
|
|
123
|
+
if (menu.children && menu.children.length) {
|
|
124
|
+
return menu.children.reduce((all, item) => {
|
|
125
|
+
const foundChildren = getMenuChildren(item);
|
|
126
|
+
return all.concat(foundChildren);
|
|
127
|
+
}, []);
|
|
128
|
+
} else {
|
|
129
|
+
return [menu];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export { getAllSiderMenu };
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @description 将菜单转为平级
|
|
137
|
+
* */
|
|
138
|
+
function flattenSiderMenu(menuList, newList) {
|
|
139
|
+
menuList.forEach(menu => {
|
|
140
|
+
let newMenu = {};
|
|
141
|
+
for (let i in menu) {
|
|
142
|
+
if (i !== 'children') newMenu[i] = cloneDeep(menu[i]);
|
|
143
|
+
}
|
|
144
|
+
newList.push(newMenu);
|
|
145
|
+
menu.children && flattenSiderMenu(menu.children, newList);
|
|
146
|
+
});
|
|
147
|
+
return newList;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export { flattenSiderMenu };
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @description 判断列表1中是否包含了列表2中的某一项
|
|
154
|
+
* 因为用户权限 access 为数组,includes 方法无法直接得出结论
|
|
155
|
+
* */
|
|
156
|
+
function includeArray(list1, list2) {
|
|
157
|
+
let status = false;
|
|
158
|
+
list2.forEach(item => {
|
|
159
|
+
if (list1.includes(item)) status = true;
|
|
160
|
+
});
|
|
161
|
+
return status;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { includeArray };
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @description 动态菜单相关
|
|
168
|
+
* */
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @description 保存动态侧边菜单到本地
|
|
172
|
+
* */
|
|
173
|
+
function setNativeMenuSider(data) {
|
|
174
|
+
if (data) {
|
|
175
|
+
localStorage.setItem(`admin-plus-${Setting.appID}-menu-sider`, JSON.stringify(data));
|
|
176
|
+
} else {
|
|
177
|
+
localStorage.removeItem(`admin-plus-${Setting.appID}-menu-sider`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export { setNativeMenuSider };
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @description 读取本地的动态侧边菜单
|
|
185
|
+
* */
|
|
186
|
+
function getNativeMenuSider() {
|
|
187
|
+
return JSON.parse(localStorage.getItem(`admin-plus-${Setting.appID}-menu-sider`) || '[]');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export { getNativeMenuSider };
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @description 保存动态顶栏菜单到本地
|
|
194
|
+
* */
|
|
195
|
+
function setNativeMenuHeader(data) {
|
|
196
|
+
if (data) {
|
|
197
|
+
localStorage.setItem(`admin-plus-${Setting.appID}-menu-header`, JSON.stringify(data));
|
|
198
|
+
} else {
|
|
199
|
+
localStorage.removeItem(`admin-plus-${Setting.appID}-menu-header`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export { setNativeMenuHeader };
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @description 读取本地的动态顶栏菜单
|
|
207
|
+
* */
|
|
208
|
+
function getNativeMenuHeader() {
|
|
209
|
+
return JSON.parse(localStorage.getItem(`admin-plus-${Setting.appID}-menu-header`) || '[]');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export { getNativeMenuHeader };
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* @description 保存权限到本地
|
|
216
|
+
* */
|
|
217
|
+
function setNativePermission(data) {
|
|
218
|
+
if (data) {
|
|
219
|
+
localStorage.setItem(`admin-plus-${Setting.appID}-permission`, JSON.stringify(data));
|
|
220
|
+
} else {
|
|
221
|
+
localStorage.removeItem(`admin-plus-${Setting.appID}-permission`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export { setNativePermission };
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @description 读取本地的权限
|
|
229
|
+
* */
|
|
230
|
+
function getNativePermission() {
|
|
231
|
+
return JSON.parse(localStorage.getItem(`admin-plus-${Setting.appID}-permission`) || '[]');
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export { getNativePermission };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import Cookies from 'js-cookie';
|
|
2
|
+
import Setting from '../setting';
|
|
3
|
+
|
|
4
|
+
const cookies = {};
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description 存储 cookie 值
|
|
8
|
+
* @param {String} name cookie name
|
|
9
|
+
* @param {String} value cookie value
|
|
10
|
+
* @param {Object} cookieSetting cookie setting
|
|
11
|
+
*/
|
|
12
|
+
cookies.set = function (name = 'default', value = '', cookieSetting = {}) {
|
|
13
|
+
let currentCookieSetting = {};
|
|
14
|
+
|
|
15
|
+
if (Setting.cookiesExpires !== 0) currentCookieSetting.expires = Setting.cookiesExpires;
|
|
16
|
+
|
|
17
|
+
Object.assign(currentCookieSetting, cookieSetting);
|
|
18
|
+
Cookies.set(`admin-plus-${Setting.appID}-${name}`, value, currentCookieSetting);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @description 拿到 cookie 值
|
|
23
|
+
* @param {String} name cookie name
|
|
24
|
+
*/
|
|
25
|
+
cookies.get = function (name = 'default') {
|
|
26
|
+
return Cookies.get(`admin-plus-${Setting.appID}-${name}`);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @description 拿到 cookie 全部的值
|
|
31
|
+
*/
|
|
32
|
+
cookies.getAll = function () {
|
|
33
|
+
return Cookies.get();
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @description 删除 cookie
|
|
38
|
+
* @param {String} name cookie name
|
|
39
|
+
*/
|
|
40
|
+
cookies.remove = function (name = 'default') {
|
|
41
|
+
return Cookies.remove(`admin-plus-${Setting.appID}-${name}`);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default cookies;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import low from 'lowdb';
|
|
2
|
+
import LocalStorage from 'lowdb/adapters/LocalStorage';
|
|
3
|
+
import Setting from '../setting';
|
|
4
|
+
|
|
5
|
+
const adapter = new LocalStorage(`admin-plus-${Setting.appID}`);
|
|
6
|
+
const db = low(adapter);
|
|
7
|
+
|
|
8
|
+
db.defaults({
|
|
9
|
+
sys: {},
|
|
10
|
+
database: {}
|
|
11
|
+
}).write();
|
|
12
|
+
|
|
13
|
+
export default db;
|
package/src/libs/util.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import cookies from './util.cookies';
|
|
2
|
+
import log from './util.log';
|
|
3
|
+
import db from './util.db';
|
|
4
|
+
|
|
5
|
+
import Setting from '../setting';
|
|
6
|
+
|
|
7
|
+
const util = {
|
|
8
|
+
cookies,
|
|
9
|
+
log,
|
|
10
|
+
db
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function tTitle(title = '') {
|
|
14
|
+
const $t = window ? window.$app.$t : null;
|
|
15
|
+
if ($t) {
|
|
16
|
+
if (title.indexOf('$t:') === 0) {
|
|
17
|
+
return $t(title.split('$t:')[1]);
|
|
18
|
+
} else {
|
|
19
|
+
return title;
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
return title;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @description 更改标题
|
|
28
|
+
* @param {Object} title 标题
|
|
29
|
+
* @param {Object} count 未读消息数提示(可视情况选择使用或不使用)
|
|
30
|
+
*/
|
|
31
|
+
util.title = function ({ title, count }) {
|
|
32
|
+
title = tTitle(title);
|
|
33
|
+
let fullTitle;
|
|
34
|
+
|
|
35
|
+
if (Setting.titleSuffix === false || Setting.titleSuffix === '') {
|
|
36
|
+
fullTitle = title ? `${title}` : '';
|
|
37
|
+
} else {
|
|
38
|
+
fullTitle = title ? `${title} - ${Setting.titleSuffix}` : Setting.titleSuffix;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (count) fullTitle = `(${count}条消息)${fullTitle}`;
|
|
42
|
+
window.document.title = fullTitle;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
function requestAnimation(task) {
|
|
46
|
+
if ('requestAnimationFrame' in window) {
|
|
47
|
+
return window.requestAnimationFrame(task);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
setTimeout(task, 16);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { requestAnimation };
|
|
54
|
+
|
|
55
|
+
export default util;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const log = {};
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description 返回这个样式的颜色值
|
|
5
|
+
* @param {String} type 样式名称 [ primary | success | warning | error | text ]
|
|
6
|
+
*/
|
|
7
|
+
function typeColor(type = 'default') {
|
|
8
|
+
let color = '';
|
|
9
|
+
switch (type) {
|
|
10
|
+
case 'default':
|
|
11
|
+
color = '#515a6e';
|
|
12
|
+
break;
|
|
13
|
+
case 'primary':
|
|
14
|
+
color = '#2d8cf0';
|
|
15
|
+
break;
|
|
16
|
+
case 'success':
|
|
17
|
+
color = '#19be6b';
|
|
18
|
+
break;
|
|
19
|
+
case 'warning':
|
|
20
|
+
color = '#ff9900';
|
|
21
|
+
break;
|
|
22
|
+
case 'error':
|
|
23
|
+
color = '#ed4014';
|
|
24
|
+
break;
|
|
25
|
+
default:
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
return color;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @description 打印一个 [ title | text ] 样式的信息
|
|
33
|
+
* @param {String} title title text
|
|
34
|
+
* @param {String} info info text
|
|
35
|
+
* @param {String} type style
|
|
36
|
+
*/
|
|
37
|
+
log.capsule = function (title, info, type = 'primary') {
|
|
38
|
+
console.log(
|
|
39
|
+
`%c ${title} %c ${info} %c`,
|
|
40
|
+
'background:#35495E; padding: 1px; border-radius: 3px 0 0 3px; color: #fff;',
|
|
41
|
+
`background:${typeColor(type)}; padding: 1px; border-radius: 0 3px 3px 0; color: #fff;`,
|
|
42
|
+
'background:transparent'
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @description 打印彩色文字
|
|
48
|
+
*/
|
|
49
|
+
log.colorful = function (textArr) {
|
|
50
|
+
console.log(`%c${textArr.map(t => t.text || '').join('%c')}`, ...textArr.map(t => `color: ${typeColor(t.type)};`));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @description 打印 default 样式的文字
|
|
55
|
+
*/
|
|
56
|
+
log.default = function (text) {
|
|
57
|
+
log.colorful([{ text }]);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @description 打印 primary 样式的文字
|
|
62
|
+
*/
|
|
63
|
+
log.primary = function (text) {
|
|
64
|
+
log.colorful([{ text, type: 'primary' }]);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @description 打印 success 样式的文字
|
|
69
|
+
*/
|
|
70
|
+
log.success = function (text) {
|
|
71
|
+
log.colorful([{ text, type: 'success' }]);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @description 打印 warning 样式的文字
|
|
76
|
+
*/
|
|
77
|
+
log.warning = function (text) {
|
|
78
|
+
log.colorful([{ text, type: 'warning' }]);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @description 打印 error 样式的文字
|
|
83
|
+
*/
|
|
84
|
+
log.error = function (text) {
|
|
85
|
+
log.colorful([{ text, type: 'error' }]);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export default log;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 生成水印
|
|
3
|
+
* */
|
|
4
|
+
export default function getWaterMarkCanvas(text, options) {
|
|
5
|
+
const canvas = document.createElement('canvas');
|
|
6
|
+
const ctx = canvas.getContext('2d');
|
|
7
|
+
const canvasWidth = 400;
|
|
8
|
+
const canvasHeight = 400;
|
|
9
|
+
canvas.width = canvasWidth;
|
|
10
|
+
canvas.height = canvasHeight;
|
|
11
|
+
ctx.textAlign = 'center';
|
|
12
|
+
ctx.textBaseline = 'bottom';
|
|
13
|
+
ctx.globalAlpha = options.globalAlpha || 0.1;
|
|
14
|
+
ctx.font = options.font || '20px Microsoft Yahei';
|
|
15
|
+
|
|
16
|
+
ctx.translate(canvasWidth / 2, canvasHeight / 2);
|
|
17
|
+
ctx.rotate(options.rotateAngle || -0.4);
|
|
18
|
+
|
|
19
|
+
ctx.translate((-canvasWidth / 2) * 1.2, (-canvasHeight / 2) * 1.2);
|
|
20
|
+
|
|
21
|
+
const waterMarkText = [];
|
|
22
|
+
const chunkWidth = options.chunkWidth || 400;
|
|
23
|
+
const chunkHeight = options.chunkHeight || 120;
|
|
24
|
+
const horizontalChunkCount = 0;
|
|
25
|
+
const verticalChunkCount = 1;
|
|
26
|
+
|
|
27
|
+
for (let j = 0, initY = chunkHeight / 2, indent = 0; j <= verticalChunkCount; j += 1) {
|
|
28
|
+
indent = parseInt(j % 2);
|
|
29
|
+
|
|
30
|
+
for (let i = 0, initX = chunkWidth / 2; i <= horizontalChunkCount; i += 1) {
|
|
31
|
+
waterMarkText.push({
|
|
32
|
+
text,
|
|
33
|
+
x: i * chunkWidth + indent * initX,
|
|
34
|
+
y: j * chunkHeight + initY
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
waterMarkText.forEach(item => {
|
|
40
|
+
ctx.fillText(item.text, item.x, item.y);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return ctx.canvas.toDataURL();
|
|
44
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// 菜单,顶栏
|
|
2
|
+
|
|
3
|
+
export default [
|
|
4
|
+
{
|
|
5
|
+
path: '/',
|
|
6
|
+
title: '首页',
|
|
7
|
+
icon: 'md-home',
|
|
8
|
+
hideSider: false, // 是否隐藏侧边栏
|
|
9
|
+
name: 'home', // 用 name 区分哪些二级菜单显示
|
|
10
|
+
auth: ['op', 'admin'] // 权限
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
path: '/log',
|
|
14
|
+
title: '日志',
|
|
15
|
+
icon: 'md-locate',
|
|
16
|
+
hideSider: true,
|
|
17
|
+
name: 'system',
|
|
18
|
+
auth: ['op', 'admin']
|
|
19
|
+
}
|
|
20
|
+
];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const pre = '/dashboard/';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
path: '/dashboard',
|
|
5
|
+
title: 'Dashboard',
|
|
6
|
+
header: 'home',
|
|
7
|
+
custom: 'i-icon-demo i-icon-demo-dashboard',
|
|
8
|
+
children: [
|
|
9
|
+
{
|
|
10
|
+
path: `${pre}console`,
|
|
11
|
+
title: '主控台'
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
path: `${pre}monitor`,
|
|
15
|
+
title: '监控页'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
path: `${pre}workplace`,
|
|
19
|
+
title: '工作台',
|
|
20
|
+
subtitle: 'Workplace'
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
};
|