From 6af5adaf0d90cda6df390c93710df01122439018 Mon Sep 17 00:00:00 2001 From: Sendya <18x@loacg.com> Date: Sat, 8 Dec 2018 18:14:06 +0800 Subject: [PATCH 01/47] feat: add permission select all --- src/api/manage.js | 9 + src/utils/permissions.js | 8 + src/views/list/RoleList.vue | 434 +++++++++++---------------- src/views/list/modules/RoleModal.vue | 169 +++++++++++ 4 files changed, 365 insertions(+), 255 deletions(-) create mode 100644 src/utils/permissions.js create mode 100644 src/views/list/modules/RoleModal.vue diff --git a/src/api/manage.js b/src/api/manage.js index 808e914e41..4ac4bd8b7d 100644 --- a/src/api/manage.js +++ b/src/api/manage.js @@ -5,6 +5,7 @@ const api = { role: '/role', service: '/service', permission: '/permission', + permissionNoPager: '/permission/no-pager', } export default api @@ -33,6 +34,14 @@ export function getServiceList(parameter) { }) } +export function getPermissions(parameter) { + return axios({ + url: api.permissionNoPager, + method: 'get', + params: parameter + }) +} + // id == 0 add post // id != 0 update put export function saveService(parameter) { diff --git a/src/utils/permissions.js b/src/utils/permissions.js new file mode 100644 index 0000000000..e4b60bcd12 --- /dev/null +++ b/src/utils/permissions.js @@ -0,0 +1,8 @@ +export function actionToObject(json) { + try { + return JSON.parse(json) + } catch (e) { + console.log('err', e.message) + } + return [] +} \ No newline at end of file diff --git a/src/views/list/RoleList.vue b/src/views/list/RoleList.vue index 8fa5f53135..a4e991c8e3 100644 --- a/src/views/list/RoleList.vue +++ b/src/views/list/RoleList.vue @@ -1,256 +1,180 @@ - - - \ No newline at end of file diff --git a/src/views/list/modules/RoleModal.vue b/src/views/list/modules/RoleModal.vue new file mode 100644 index 0000000000..df46df430a --- /dev/null +++ b/src/views/list/modules/RoleModal.vue @@ -0,0 +1,169 @@ + + + + + \ No newline at end of file From 829ef5ff1945b3fdb2570341c6f4e80ee9d834f2 Mon Sep 17 00:00:00 2001 From: sendya <18x@loacg.com> Date: Sat, 8 Dec 2018 22:43:21 +0800 Subject: [PATCH 02/47] fix: demo role-list optimization --- src/views/list/RoleList.vue | 10 +- src/views/list/modules/RoleModal.vue | 175 ++++++++++++++++----------- 2 files changed, 110 insertions(+), 75 deletions(-) diff --git a/src/views/list/RoleList.vue b/src/views/list/RoleList.vue index a4e991c8e3..78bd40b64a 100644 --- a/src/views/list/RoleList.vue +++ b/src/views/list/RoleList.vue @@ -12,8 +12,8 @@ 全部 - 关闭 - 运行中 + 正常 + 禁用 @@ -28,6 +28,7 @@ - + @@ -152,7 +153,8 @@ this.visible = true }, handleOk () { - + // 新增/修改 成功时,重载列表 + this.$refs.table.refresh() }, onChange (selectedRowKeys, selectedRows) { this.selectedRowKeys = selectedRowKeys diff --git a/src/views/list/modules/RoleModal.vue b/src/views/list/modules/RoleModal.vue index df46df430a..6340b7560a 100644 --- a/src/views/list/modules/RoleModal.vue +++ b/src/views/list/modules/RoleModal.vue @@ -7,76 +7,73 @@ @ok="handleOk" @cancel="handleCancel" > - - - - - - - - - - - - - 正常 - 禁用 - - - - - - - - - - - - - {{ permission.name }}: - - - - 全选 - - - - - - - + + + + + + + + + + + + + + 正常 + 禁用 + + + + + + + + + + + + + {{ permission.name }}: + + + + 全选 + + + + + + + + @@ -115,20 +112,56 @@ this.mdl = Object.assign({}, record) this.visible = true + // 有权限表,处理勾选 + if (this.mdl.permissions && this.permissions) { + // 先处理要勾选的权限结构 + const permissionsAction = {} + this.mdl.permissions.forEach(permission => { + permissionsAction[permission.permissionId] = permission.actionEntitySet.map(entity => entity.action) + }) + // 把权限表遍历一遍,设定要勾选的权限 action + this.permissions.forEach(permission => { + permission.selected = permissionsAction[permission.id] + }) + } + + this.$nextTick(() => { + this.form.setFieldsValue( _.pick(this.mdl, 'id', 'name', 'status', 'describe')) + }) console.log('this.mdl', this.mdl) + }, close () { this.$emit('close') + this.visible = false }, handleOk () { + const _this = this + // 触发表单验证 this.form.validateFields((err, values) => { + // 验证表单没错误 if (!err) { console.log('form values', values) + + _this.confirmLoading = true + // 模拟后端请求 2000 毫秒延迟 + new Promise((resolve) => { + setTimeout(() => resolve(), 2000) + }).then(() => { + // Do something + _this.$message.success('保存成功') + _this.$emit('ok') + }).catch(() => { + // Do something + }).finally(() => { + _this.confirmLoading = false + _this.close() + }) } }) }, handleCancel () { - + this.close() }, onChangeCheck (permission) { permission.indeterminate = !!permission.selected.length && (permission.selected.length < permission.actionsOptions.length) From 9f4210dba51e1aafbbdeed35992309d7909d0001 Mon Sep 17 00:00:00 2001 From: sendya <18x@loacg.com> Date: Sun, 9 Dec 2018 00:12:30 +0800 Subject: [PATCH 03/47] fix: lodash.pick --- package.json | 3 ++- src/views/list/modules/RoleModal.vue | 3 ++- yarn.lock | 7 ++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7b4556f0ef..aae08c6bbb 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "enquire.js": "^2.1.6", "js-cookie": "^2.2.0", "lodash.get": "^4.4.2", + "lodash.pick": "^4.4.0", "md5": "^2.2.1", "nprogress": "^0.2.0", "viser-vue": "^2.3.3", @@ -86,4 +87,4 @@ "last 2 versions", "not ie <= 8" ] -} \ No newline at end of file +} diff --git a/src/views/list/modules/RoleModal.vue b/src/views/list/modules/RoleModal.vue index 6340b7560a..936fe6dd16 100644 --- a/src/views/list/modules/RoleModal.vue +++ b/src/views/list/modules/RoleModal.vue @@ -80,6 +80,7 @@ + + \ No newline at end of file diff --git a/src/components/AvatarList/List.vue b/src/components/AvatarList/List.vue new file mode 100644 index 0000000000..78fb5e3ec1 --- /dev/null +++ b/src/components/AvatarList/List.vue @@ -0,0 +1,51 @@ + + + + + \ No newline at end of file diff --git a/src/components/AvatarList/index.js b/src/components/AvatarList/index.js new file mode 100644 index 0000000000..9b9c872df8 --- /dev/null +++ b/src/components/AvatarList/index.js @@ -0,0 +1,3 @@ +import AvatarList from './List' + +export default AvatarList \ No newline at end of file diff --git a/src/components/AvatarList/index.less b/src/components/AvatarList/index.less new file mode 100644 index 0000000000..84f98c119a --- /dev/null +++ b/src/components/AvatarList/index.less @@ -0,0 +1,56 @@ +@import "../index"; + +@avatar-list-prefix-cls: ~"@{ant-pro-prefix}-avatar-list"; +@avatar-list-item-prefix-cls: ~"@{ant-pro-prefix}-avatar-list-item"; + +.@{avatar-list-prefix-cls} { + display: inline-block; + + ul { + display: inline-block; + margin-left: 8px; + font-size: 0; + } +} + +.@{avatar-list-item-prefix-cls} { + display: inline-block; + font-size: @font-size-base; + margin-left: -8px; + width: @avatar-size-base; + height: @avatar-size-base; + + :global { + .ant-avatar { + border: 1px solid #fff; + } + } + + .large { + width: @avatar-size-lg; + height: @avatar-size-lg; + } + + .small { + width: @avatar-size-sm; + height: @avatar-size-sm; + } + + .mini { + width: 20px; + height: 20px; + + :global { + .ant-avatar { + width: 20px; + height: 20px; + line-height: 20px; + + .ant-avatar-string { + font-size: 12px; + line-height: 18px; + } + } + } + } +} \ No newline at end of file diff --git a/src/components/Trend/Trend.vue b/src/components/Trend/Trend.vue new file mode 100644 index 0000000000..4cc885385b --- /dev/null +++ b/src/components/Trend/Trend.vue @@ -0,0 +1,41 @@ + + + + + \ No newline at end of file diff --git a/src/components/Trend/index.js b/src/components/Trend/index.js new file mode 100644 index 0000000000..761366d5f9 --- /dev/null +++ b/src/components/Trend/index.js @@ -0,0 +1,3 @@ +import Trend from './Trend.vue' + +export default Trend \ No newline at end of file diff --git a/src/components/Trend/index.less b/src/components/Trend/index.less new file mode 100644 index 0000000000..8a3d24cfb5 --- /dev/null +++ b/src/components/Trend/index.less @@ -0,0 +1,42 @@ +@import "../index"; + +@trend-prefix-cls: ~"@{ant-pro-prefix}-trend"; + +.@{trend-prefix-cls} { + display: inline-block; + font-size: @font-size-base; + line-height: 22px; + + .up, + .down { + margin-left: 4px; + position: relative; + top: 1px; + + i { + font-size: 12px; + transform: scale(0.83); + } + } + + .item-text { + display: inline-block; + margin-left: 8px; + color: rgba(0,0,0,.85); + } + + .up { + color: @red-6; + } + .down { + color: @green-6; + top: -1px; + } + + &.reverse-color .up { + color: @green-6; + } + &.reverse-color .down { + color: @red-6; + } +} \ No newline at end of file diff --git a/src/components/index.less b/src/components/index.less new file mode 100644 index 0000000000..d8c97bbdb4 --- /dev/null +++ b/src/components/index.less @@ -0,0 +1,4 @@ +@import "~ant-design-vue/lib/style/index"; + +// The prefix to use on all css classes from ant-pro. +@ant-pro-prefix : ant-pro; \ No newline at end of file diff --git a/src/config/router.config.js b/src/config/router.config.js index 79aaa887e7..1175ae7aa7 100644 --- a/src/config/router.config.js +++ b/src/config/router.config.js @@ -1,4 +1,4 @@ -import { UserLayout, BasicLayout, RouteView, PageView } from '@/components/layouts' +import { UserLayout, BasicLayout, RouteView, BlankLayout, PageView } from '@/components/layouts' export const asyncRouterMap = [ @@ -313,6 +313,19 @@ export const constantRouterMap = [ ] }, + { + path: '/test', + component: BlankLayout, + redirect: '/test/home', + children: [ + { + path: 'home', + name: 'TestHome', + component: () => import('@/views/Home') + } + ] + }, + { path: '/404', component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404') diff --git a/src/views/Home.vue b/src/views/Home.vue index 8bd6c57f30..0f49f40eb9 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -1,18 +1,74 @@ + + diff --git a/src/views/dashboard/Analysis.vue b/src/views/dashboard/Analysis.vue index cf6ee63837..1c048b739b 100644 --- a/src/views/dashboard/Analysis.vue +++ b/src/views/dashboard/Analysis.vue @@ -7,8 +7,14 @@
- - + + 周同比 + 12% + + + 日同比 + 11% +
@@ -141,7 +147,7 @@ import MiniProgress from '@/components/chart/MiniProgress' import RankList from '@/components/chart/RankList' import Bar from '@/components/chart/Bar' - import Trend from '@/components/chart/Trend' + import Trend from '@/components/Trend' const rankList = [] for (let i = 0; i < 7; i++) { From f729bbf266d3f894e5b1e2e8d8e24993846be393 Mon Sep 17 00:00:00 2001 From: Sendya <18x@loacg.com> Date: Tue, 11 Dec 2018 02:10:37 +0800 Subject: [PATCH 05/47] feat: avatar list --- src/components/AvatarList/Item.vue | 40 +++++++++++++++++------ src/components/AvatarList/List.vue | 48 ++++++++++++++++++++++------ src/components/AvatarList/index.js | 1 + src/components/AvatarList/index.less | 14 +++++--- src/views/Home.vue | 28 ++++++++++++++-- 5 files changed, 105 insertions(+), 26 deletions(-) diff --git a/src/components/AvatarList/Item.vue b/src/components/AvatarList/Item.vue index 290ee78f24..b25799ebb6 100644 --- a/src/components/AvatarList/Item.vue +++ b/src/components/AvatarList/Item.vue @@ -1,13 +1,29 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/src/components/AvatarList/List.vue b/src/components/AvatarList/List.vue index 78fb5e3ec1..8fada5dc71 100644 --- a/src/components/AvatarList/List.vue +++ b/src/components/AvatarList/List.vue @@ -1,26 +1,38 @@ - \ No newline at end of file diff --git a/src/components/AvatarList/index.js b/src/components/AvatarList/index.js index 9b9c872df8..9621de657c 100644 --- a/src/components/AvatarList/index.js +++ b/src/components/AvatarList/index.js @@ -1,3 +1,4 @@ import AvatarList from './List' +import "./index.less" export default AvatarList \ No newline at end of file diff --git a/src/components/AvatarList/index.less b/src/components/AvatarList/index.less index 84f98c119a..9ce073fd14 100644 --- a/src/components/AvatarList/index.less +++ b/src/components/AvatarList/index.less @@ -7,8 +7,10 @@ display: inline-block; ul { + list-style: none; display: inline-block; - margin-left: 8px; + padding: 0; + margin: 0 0 0 8px; font-size: 0; } } @@ -23,20 +25,21 @@ :global { .ant-avatar { border: 1px solid #fff; + cursor: pointer; } } - .large { + &.large { width: @avatar-size-lg; height: @avatar-size-lg; } - .small { + &.small { width: @avatar-size-sm; height: @avatar-size-sm; } - .mini { + &.mini { width: 20px; height: 20px; @@ -53,4 +56,5 @@ } } } -} \ No newline at end of file +} + diff --git a/src/views/Home.vue b/src/views/Home.vue index 0f49f40eb9..210cb64b94 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -43,8 +43,27 @@ - 例子 + AvatarList + + + + + + + + + + + + + + + + + + + @@ -52,11 +71,16 @@ // @ is an alias to /src import Trend from '@/components/Trend' + import AvatarList from '@/components/AvatarList' + + const AvatarListItem = AvatarList.AvatarItem export default { name: 'Home', components: { - Trend + Trend, + AvatarList, + AvatarListItem } } From a1dbdf6dfcd7ad6971503fe4a41e8d9245bf7c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lady=20=C2=B7=20Lady?= Date: Tue, 11 Dec 2018 15:12:34 +0800 Subject: [PATCH 06/47] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=8E=E5=AE=98?= =?UTF-8?q?=E7=BD=91=E6=A0=B7=E5=BC=8F=E4=B8=8D=E5=90=8C=E6=AD=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/result/Error.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/result/Error.vue b/src/views/result/Error.vue index a7b8b4022a..634c4b6eea 100644 --- a/src/views/result/Error.vue +++ b/src/views/result/Error.vue @@ -1,6 +1,6 @@ @@ -72,15 +83,27 @@ import Trend from '@/components/Trend' import AvatarList from '@/components/AvatarList' + import CountDown from '@/components/CountDown/CountDown' const AvatarListItem = AvatarList.AvatarItem export default { name: 'Home', components: { + CountDown, Trend, AvatarList, AvatarListItem + }, + data () { + return { + targetTime: new Date().getTime() + 3900000 + } + }, + methods: { + onEndHandle () { + this.$message.success('CountDown callback!!!') + } } } @@ -89,10 +112,11 @@ .home { width: 900px; margin: 0 auto; + padding: 25px 0; } .home > .banner { text-align: center; - padding-top: 25px; + padding: 25px 0; margin: 25px 0; } From fae2b933af5deb6d00b56941334c35ad917ebc2b Mon Sep 17 00:00:00 2001 From: Sendya <18x@loacg.com> Date: Wed, 12 Dec 2018 01:09:31 +0800 Subject: [PATCH 08/47] feat: add NumberInfo, Ellipsis components --- src/components/Ellipsis/Ellipsis.vue | 63 ++++++++++++++++++++++++ src/components/Ellipsis/index.js | 3 ++ src/components/NumberInfo/NumberInfo.vue | 54 ++++++++++++++++++++ src/components/NumberInfo/index.js | 3 ++ src/components/NumberInfo/index.less | 55 +++++++++++++++++++++ src/components/_util/StringUtil.js | 25 ++++++++++ src/views/Home.vue | 55 ++++++++++++++++++--- 7 files changed, 251 insertions(+), 7 deletions(-) create mode 100644 src/components/Ellipsis/Ellipsis.vue create mode 100644 src/components/Ellipsis/index.js create mode 100644 src/components/NumberInfo/NumberInfo.vue create mode 100644 src/components/NumberInfo/index.js create mode 100644 src/components/NumberInfo/index.less create mode 100644 src/components/_util/StringUtil.js diff --git a/src/components/Ellipsis/Ellipsis.vue b/src/components/Ellipsis/Ellipsis.vue new file mode 100644 index 0000000000..5fb14c2bb6 --- /dev/null +++ b/src/components/Ellipsis/Ellipsis.vue @@ -0,0 +1,63 @@ + \ No newline at end of file diff --git a/src/components/Ellipsis/index.js b/src/components/Ellipsis/index.js new file mode 100644 index 0000000000..d257156b3a --- /dev/null +++ b/src/components/Ellipsis/index.js @@ -0,0 +1,3 @@ +import Ellipsis from './Ellipsis' + +export default Ellipsis \ No newline at end of file diff --git a/src/components/NumberInfo/NumberInfo.vue b/src/components/NumberInfo/NumberInfo.vue new file mode 100644 index 0000000000..81508780b9 --- /dev/null +++ b/src/components/NumberInfo/NumberInfo.vue @@ -0,0 +1,54 @@ + + + + + \ No newline at end of file diff --git a/src/components/NumberInfo/index.js b/src/components/NumberInfo/index.js new file mode 100644 index 0000000000..a471501ab7 --- /dev/null +++ b/src/components/NumberInfo/index.js @@ -0,0 +1,3 @@ +import NumberInfo from './NumberInfo' + +export default NumberInfo \ No newline at end of file diff --git a/src/components/NumberInfo/index.less b/src/components/NumberInfo/index.less new file mode 100644 index 0000000000..719113da96 --- /dev/null +++ b/src/components/NumberInfo/index.less @@ -0,0 +1,55 @@ +@import "../index"; + +@numberInfo-prefix-cls: ~"@{ant-pro-prefix}-number-info"; + +.@{numberInfo-prefix-cls} { + + .ant-pro-number-info-subtitle { + color: @text-color-secondary; + font-size: @font-size-base; + height: 22px; + line-height: 22px; + overflow: hidden; + text-overflow: ellipsis; + word-break: break-all; + white-space: nowrap; + } + + .number-info-value { + margin-top: 4px; + font-size: 0; + overflow: hidden; + text-overflow: ellipsis; + word-break: break-all; + white-space: nowrap; + + & > span { + color: @heading-color; + display: inline-block; + line-height: 32px; + height: 32px; + font-size: 24px; + margin-right: 32px; + } + + .sub-total { + color: @text-color-secondary; + font-size: @font-size-lg; + vertical-align: top; + margin-right: 0; + i { + font-size: 12px; + transform: scale(0.82); + margin-left: 4px; + } + :global { + .anticon-caret-up { + color: @red-6; + } + .anticon-caret-down { + color: @green-6; + } + } + } + } +} \ No newline at end of file diff --git a/src/components/_util/StringUtil.js b/src/components/_util/StringUtil.js new file mode 100644 index 0000000000..29aed19bc7 --- /dev/null +++ b/src/components/_util/StringUtil.js @@ -0,0 +1,25 @@ + +export const getStrFullLength = (str = '') => + str.split('').reduce((pre, cur) => { + const charCode = cur.charCodeAt(0) + if (charCode >= 0 && charCode <= 128) { + return pre + 1 + } + return pre + 2 + }, 0) + +export const cutStrByFullLength = (str = '', maxLength) => { + let showLength = 0 + return str.split('').reduce((pre, cur) => { + const charCode = cur.charCodeAt(0) + if (charCode >= 0 && charCode <= 128) { + showLength += 1 + } else { + showLength += 2 + } + if (showLength <= maxLength) { + return pre + cur + } + return pre + }, '') +} \ No newline at end of file diff --git a/src/views/Home.vue b/src/views/Home.vue index 469f2a7d38..c9cab99cc1 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -2,7 +2,7 @@

@@ -30,7 +30,7 @@ 颜色反转 - + 工资 @@ -43,9 +43,10 @@ - AvatarList +

# AvatarList 组件

- + AvatarList + @@ -66,14 +67,44 @@ - CountDown +

# CountDown 组件

- + CountDown + + + + + + + + +

# Ellipsis 组件

+ + Ellipsis + + + There were injuries alleged in three cases in 2015, and a + fourth incident in September, according to the safety recall report. After meeting with US regulators in October, the firm decided to issue a voluntary recall. + + + +

# NumberInfo 组件

+ + NumberInfo + +
@@ -84,12 +115,16 @@ import Trend from '@/components/Trend' import AvatarList from '@/components/AvatarList' import CountDown from '@/components/CountDown/CountDown' + import Ellipsis from '@/components/Ellipsis' + import NumberInfo from '@/components/NumberInfo' const AvatarListItem = AvatarList.AvatarItem export default { name: 'Home', components: { + NumberInfo, + Ellipsis, CountDown, Trend, AvatarList, @@ -103,6 +138,12 @@ methods: { onEndHandle () { this.$message.success('CountDown callback!!!') + }, + onEndHandle2 () { + this.$notification.open({ + message: 'Notification Title', + description: 'This is the content of the notification. This is the content of the notification. This is the content of the notification.', + }); } } } From c6d28921048b5201c5af3ec3686ff5c2ee2aba6a Mon Sep 17 00:00:00 2001 From: Sendya <18x@loacg.com> Date: Wed, 12 Dec 2018 01:27:23 +0800 Subject: [PATCH 09/47] fix: #26 toastr --- README.md | 2 +- src/views/user/Login.vue | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6e1f9dae07..7ebdbb9708 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ yarn run lint - [Table 重封装组件](https://github.com/sendya/ant-design-pro-vue/blob/master/src/components/table/README.md) -- [ANTD 默认配置项](https://github.com/sendya/ant-design-pro-vue/blob/master/src/defaultConfig.js) +- [ANTD 默认配置项](https://github.com/sendya/ant-design-pro-vue/blob/master/src/defaultSettings.js) - 其他待补充... diff --git a/src/views/user/Login.vue b/src/views/user/Login.vue index f3f1eec5ee..5495f80458 100644 --- a/src/views/user/Login.vue +++ b/src/views/user/Login.vue @@ -244,7 +244,10 @@ loginSuccess () { this.loginBtn = false this.$router.push({ name: "dashboard" }) - this.$message.success(timeFix() + ',欢迎回来', 3) + this.$notification.success({ + message: '欢迎', + description: `${timeFix()},欢迎回来`, + }); }, requestFailed (err) { this.$notification[ 'error' ]({ From 2fae05400542a8a6c9f8d661ca10206ba3adc8cc Mon Sep 17 00:00:00 2001 From: Sendya <18x@loacg.com> Date: Wed, 12 Dec 2018 09:23:07 +0800 Subject: [PATCH 10/47] fix: analysis trend comp --- src/views/dashboard/Analysis.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/views/dashboard/Analysis.vue b/src/views/dashboard/Analysis.vue index 1c048b739b..d13d3e81e4 100644 --- a/src/views/dashboard/Analysis.vue +++ b/src/views/dashboard/Analysis.vue @@ -50,8 +50,14 @@ From aac0b9416fe45e0088057a8f9b123cfce2675e67 Mon Sep 17 00:00:00 2001 From: Sendya <18x@loacg.com> Date: Fri, 14 Dec 2018 13:58:01 +0800 Subject: [PATCH 11/47] feat: add action check --- src/main.js | 2 + src/utils/helper/permission.js | 53 +++ src/views/list/TableList.vue | 606 +++++++++++++++++---------------- 3 files changed, 359 insertions(+), 302 deletions(-) create mode 100644 src/utils/helper/permission.js diff --git a/src/main.js b/src/main.js index 759781d266..9489c264d8 100644 --- a/src/main.js +++ b/src/main.js @@ -12,6 +12,7 @@ import 'ant-design-vue/dist/antd.less'; // or 'ant-design-vue/dist/antd.less' import '@/permission' // permission control import '@/utils/filter' // base filter +import PermissionHelper from '@/utils/helper/permission' import { ACCESS_TOKEN, @@ -33,6 +34,7 @@ Vue.use(Storage, config.storageOptions) Vue.use(Antd) Vue.use(VueAxios, router) Vue.use(Viser) +Vue.use(PermissionHelper) new Vue({ router, diff --git a/src/utils/helper/permission.js b/src/utils/helper/permission.js new file mode 100644 index 0000000000..599669bbac --- /dev/null +++ b/src/utils/helper/permission.js @@ -0,0 +1,53 @@ +const PERMISSION_ENUM = { + 'add': { key: 'add', label: '新增' }, + 'delete': { key: 'delete', label: '删除' }, + 'edit': { key: 'edit', label: '修改' }, + 'query': { key: 'query', label: '查询' }, + 'get': { key: 'get', label: '详情' }, + 'enable': { key: 'enable', label: '启用' }, + 'disable': { key: 'disable', label: '禁用' }, + 'import': { key: 'import', label: '导入' }, + 'export': { key: 'import', label: '导入' }, +}; + +function plugin(Vue) { + + if (plugin.installed) { + return; + } + + !Vue.prototype.$auth && Object.defineProperties(Vue.prototype, { + $auth: { + get() { + const _this = this; + return (permissions) => { + let [permission, action] = permissions.split('.'); + const permissionList = _this.$store.getters.roles.permissions; + permissionList.find((val) => { + return val.permissionId === permission + }).actionList.findIndex((val) => { + return val === action + }); + return false + } + } + } + }); + + !Vue.prototype.$enum && Object.defineProperties(Vue.prototype, { + $enum: { + get() { + // const _this = this; + return (val) => { + let result = PERMISSION_ENUM; + val && val.split('.').forEach(v => { + result = result && result[v] || null + }); + return result + } + } + } + }); +} + +export default plugin \ No newline at end of file diff --git a/src/views/list/TableList.vue b/src/views/list/TableList.vue index f17859e515..bb73ccb680 100644 --- a/src/views/list/TableList.vue +++ b/src/views/list/TableList.vue @@ -1,303 +1,305 @@ - - - \ No newline at end of file From c602be38a7b7176337a23e8e058ef8a985bc5c5a Mon Sep 17 00:00:00 2001 From: Sendya <18x@loacg.com> Date: Fri, 14 Dec 2018 16:22:33 +0800 Subject: [PATCH 12/47] feat: add Role page --- src/config/router.config.js | 15 +++ src/views/role/RoleList.vue | 193 ++++++++++++++++++++++++++++++++++++ 2 files changed, 208 insertions(+) create mode 100644 src/views/role/RoleList.vue diff --git a/src/config/router.config.js b/src/config/router.config.js index 1175ae7aa7..b7a8f01791 100644 --- a/src/config/router.config.js +++ b/src/config/router.config.js @@ -169,6 +169,21 @@ export const asyncRouterMap = [ } ] }, + { + path: '/system', + name: 'system', + component: RouteView, + redirect: '/system/role', + meta: { title: '系统管理', icon: 'setting', permission: [ 'table' ] }, + children: [ + { + path: '/system/role', + name: 'SystemRole', + component: () => import('@/views/role/RoleList'), + meta: { title: '角色列表', permission: [ 'table' ]} + } + ] + }, // result { diff --git a/src/views/role/RoleList.vue b/src/views/role/RoleList.vue new file mode 100644 index 0000000000..c82d3ad3a2 --- /dev/null +++ b/src/views/role/RoleList.vue @@ -0,0 +1,193 @@ + + + + + \ No newline at end of file From e0f997583e76fcaa46a129a1831ae3447f83b8e6 Mon Sep 17 00:00:00 2001 From: musnow <775130834@qq.com> Date: Sat, 15 Dec 2018 16:08:59 +0800 Subject: [PATCH 13/47] add new rule --- package.json | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index aae08c6bbb..4bb0f2de80 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,29 @@ "vue/no-use-v-if-with-v-for": 0, "vue/html-closing-bracket-newline": 0, "vue/no-parsing-error": 0, - "no-console": 0 + "no-console": 0, + "quotes": [ + 2, + "single", + { + "avoidEscape": true, + "allowTemplateLiterals": true + } + ], + "semi": [ + 2, + "never", + { + "beforeStatementContinuationChars": "never" + } + ], + "no-delete-var": 2, + "prefer-const": [ + 2, + { + "ignoreReadBeforeAssign": false + } + ] } }, "postcss": { From 45e9fe4b5d4af683bf58575da9dbe41c8c29b1a2 Mon Sep 17 00:00:00 2001 From: musnow <775130834@qq.com> Date: Sat, 15 Dec 2018 16:28:41 +0800 Subject: [PATCH 14/47] fix style for eslint --- src/App.vue | 2 +- src/components/AvatarList/Item.vue | 2 +- src/components/AvatarList/List.vue | 2 +- src/components/AvatarList/index.js | 2 +- src/components/ChartCard.vue | 2 +- src/components/CountDown/CountDown.vue | 22 +- src/components/Ellipsis/Ellipsis.vue | 4 +- src/components/Trend/Trend.vue | 2 +- src/components/chart/Bar.vue | 2 +- src/components/chart/Liquid.vue | 2 +- src/components/chart/MiniArea.vue | 2 +- src/components/chart/MiniBar.vue | 2 +- src/components/chart/MiniProgress.vue | 2 +- src/components/chart/RankList.vue | 2 +- src/components/chart/TransferBar.vue | 2 +- src/components/chart/Trend.vue | 6 +- src/components/layouts/BasicLayout.vue | 2 +- src/components/layouts/BlankLayout.vue | 2 +- src/components/layouts/PageView.vue | 2 +- src/components/layouts/RouteView.vue | 2 +- src/components/layouts/UserLayout.vue | 4 +- src/components/menu/SideMenu.vue | 4 +- src/components/menu/index.js | 16 +- src/components/page/GlobalFooter.vue | 2 +- src/components/page/GlobalHeader.vue | 4 +- src/components/page/GlobalLayout.vue | 2 +- src/components/page/PageHeader.vue | 4 +- src/components/page/PageLayout.vue | 2 +- src/components/page/SHeaderNotice.vue | 2 +- src/components/setting/SettingDrawer.vue | 4 +- src/components/setting/SettingItem.vue | 2 +- src/components/table/StandardTable.vue | 24 +- src/components/table/index.js | 66 +-- src/components/tools/DetailList.vue | 2 +- src/components/tools/FooterToolBar.vue | 2 +- src/components/tools/HeadInfo.vue | 2 +- src/components/tools/HeaderNotice.vue | 2 +- src/components/tools/Logo.vue | 2 +- src/components/tools/TwoStepCaptcha.vue | 6 +- src/components/tools/UserMenu.vue | 8 +- src/components/tools/setting.js | 58 +-- src/main.js | 6 +- src/store/modules/app.js | 2 +- src/store/modules/permission.js | 5 +- src/store/modules/user.js | 10 +- src/utils/auth.js | 2 +- src/utils/axios.js | 18 +- src/utils/filter.js | 6 +- src/utils/mixin.js | 2 +- src/utils/request.js | 6 +- src/utils/storage.js | 26 +- src/utils/util.js | 4 +- src/views/404.vue | 2 +- src/views/Home.vue | 2 +- src/views/account/center/Index.vue | 4 +- src/views/account/center/page/App.vue | 2 +- src/views/account/center/page/Article.vue | 2 +- src/views/account/center/page/Project.vue | 2 +- src/views/account/settings/AvatarModal.vue | 16 +- src/views/account/settings/Custom.vue | 4 +- src/views/account/settings/Index.vue | 4 +- src/views/account/settings/Security.vue | 10 +- src/views/dashboard/Analysis.vue | 6 +- src/views/dashboard/Monitor.vue | 2 +- src/views/dashboard/Workplace.vue | 10 +- src/views/exception/ExceptionPage.vue | 2 +- src/views/form/advancedForm/AdvancedForm.vue | 8 +- .../form/advancedForm/RepositoryForm.vue | 2 +- src/views/form/advancedForm/TaskForm.vue | 2 +- src/views/form/stepForm/Step1.vue | 2 +- src/views/form/stepForm/Step2.vue | 4 +- src/views/form/stepForm/Step3.vue | 2 +- src/views/form/stepForm/StepForm.vue | 2 +- src/views/list/CardList.vue | 2 +- src/views/list/PermissionList.vue | 4 +- src/views/list/RoleList.vue | 2 +- src/views/list/StandardList.vue | 2 +- src/views/list/TableInnerEditList.vue | 12 +- src/views/list/TableList.vue | 8 +- src/views/list/UserList.vue | 2 +- src/views/list/modules/RoleModal.vue | 4 +- src/views/list/search/SearchLayout.vue | 2 +- src/views/profile/advanced/Advanced.vue | 2 +- src/views/profile/basic/Index.vue | 2 +- src/views/result/Error.vue | 2 +- src/views/result/Result.vue | 2 +- src/views/result/Success.vue | 2 +- src/views/user/Login.vue | 422 +++++++++--------- src/views/user/Register.vue | 44 +- src/views/user/RegisterResult.vue | 6 +- 90 files changed, 498 insertions(+), 483 deletions(-) diff --git a/src/App.vue b/src/App.vue index 747ca31e99..fbb6a746dc 100644 --- a/src/App.vue +++ b/src/App.vue @@ -16,7 +16,7 @@ } }, created () { - let that = this + const that = this enquireScreen(deviceType => { // tablet if (deviceType === 0) { diff --git a/src/components/AvatarList/Item.vue b/src/components/AvatarList/Item.vue index f79429500f..30442fc232 100644 --- a/src/components/AvatarList/Item.vue +++ b/src/components/AvatarList/Item.vue @@ -11,7 +11,7 @@ import Tooltip from 'ant-design-vue/es/tooltip' export default { - name: "AvatarItem", + name: 'AvatarItem', components: { Avatar, Tooltip diff --git a/src/components/AvatarList/List.vue b/src/components/AvatarList/List.vue index fb3412c8b2..039f19f272 100644 --- a/src/components/AvatarList/List.vue +++ b/src/components/AvatarList/List.vue @@ -23,7 +23,7 @@ export default { AvatarItem, - name: "AvatarList", + name: 'AvatarList', components: { Avatar, AvatarItem diff --git a/src/components/AvatarList/index.js b/src/components/AvatarList/index.js index 9621de657c..52f8b31767 100644 --- a/src/components/AvatarList/index.js +++ b/src/components/AvatarList/index.js @@ -1,4 +1,4 @@ import AvatarList from './List' -import "./index.less" +import './index.less' export default AvatarList \ No newline at end of file diff --git a/src/components/ChartCard.vue b/src/components/ChartCard.vue index 8acb150d6f..42c57b4ab5 100644 --- a/src/components/ChartCard.vue +++ b/src/components/ChartCard.vue @@ -24,7 +24,7 @@ diff --git a/src/components/layouts/PageView.vue b/src/components/layouts/PageView.vue index dc3ae085b3..e34504380a 100644 --- a/src/components/layouts/PageView.vue +++ b/src/components/layouts/PageView.vue @@ -13,7 +13,7 @@ import RouteView from './RouteView' export default { - name: "PageContent", + name: 'PageContent', components: { RouteView, PageLayout diff --git a/src/components/layouts/RouteView.vue b/src/components/layouts/RouteView.vue index 6e99e6301b..46c78b4d5e 100644 --- a/src/components/layouts/RouteView.vue +++ b/src/components/layouts/RouteView.vue @@ -7,7 +7,7 @@ diff --git a/src/components/page/GlobalHeader.vue b/src/components/page/GlobalHeader.vue index e271facfe2..40376ace72 100644 --- a/src/components/page/GlobalHeader.vue +++ b/src/components/page/GlobalHeader.vue @@ -46,7 +46,7 @@ import { mixin } from '@/utils/mixin.js' export default { - name: "GlobalHeader", + name: 'GlobalHeader', components: { UserMenu, SMenu, @@ -90,7 +90,7 @@ methods: { handleScroll () { if (this.autoHideHeader) { - let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop + const scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop if (scrollTop > 100) { this.headerBarFixed = true } else { diff --git a/src/components/page/GlobalLayout.vue b/src/components/page/GlobalLayout.vue index 3095dca37d..ec1d57c925 100644 --- a/src/components/page/GlobalLayout.vue +++ b/src/components/page/GlobalLayout.vue @@ -83,7 +83,7 @@ import { mixin, mixinDevice } from '@/utils/mixin.js' export default { - name: "GlobalLayout", + name: 'GlobalLayout', components: { SideMenu, GlobalHeader, diff --git a/src/components/page/PageHeader.vue b/src/components/page/PageHeader.vue index 596650f108..6936fb0e25 100644 --- a/src/components/page/PageHeader.vue +++ b/src/components/page/PageHeader.vue @@ -44,9 +44,9 @@ import Breadcrumb from '@/components/tools/Breadcrumb' export default { - name: "PageHeader", + name: 'PageHeader', components: { - "s-breadcrumb": Breadcrumb + 's-breadcrumb': Breadcrumb }, props: { title: { diff --git a/src/components/page/PageLayout.vue b/src/components/page/PageLayout.vue index 1434e53a5d..430ce8f3a0 100644 --- a/src/components/page/PageLayout.vue +++ b/src/components/page/PageLayout.vue @@ -40,7 +40,7 @@ import PageHeader from './PageHeader' export default { - name: "LayoutContent", + name: 'LayoutContent', components: { PageHeader }, diff --git a/src/components/page/SHeaderNotice.vue b/src/components/page/SHeaderNotice.vue index 622636adfe..07f704d3b6 100644 --- a/src/components/page/SHeaderNotice.vue +++ b/src/components/page/SHeaderNotice.vue @@ -19,7 +19,7 @@ diff --git a/src/components/tools/HeadInfo.vue b/src/components/tools/HeadInfo.vue index c9fd462d46..f09b027bd7 100644 --- a/src/components/tools/HeadInfo.vue +++ b/src/components/tools/HeadInfo.vue @@ -8,7 +8,7 @@ \ No newline at end of file diff --git a/src/views/user/Register.vue b/src/views/user/Register.vue index af968a220a..e6ad323971 100644 --- a/src/views/user/Register.vue +++ b/src/views/user/Register.vue @@ -111,7 +111,7 @@ 3: '#52c41a', } export default { - name: "Register", + name: 'Register', components: { }, mixins: [mixinDevice], @@ -175,7 +175,7 @@ }, handlePasswordCheck (rule, value, callback) { - let password = this.form.getFieldValue('password') + const password = this.form.getFieldValue('password') console.log('value', value) if (value === undefined) { callback(new Error('请输入密码')) @@ -197,7 +197,7 @@ handlePasswordInputClick () { if (!this.isMobile()) { this.state.passwordLevelChecked = true - return; + return } this.state.passwordLevelChecked = false }, @@ -212,48 +212,48 @@ getCaptcha(e) { e.preventDefault() - let that = this + const that = this this.form.validateFields(['mobile'], {force: true}, (err, values) => { if (!err) { - this.state.smsSendBtn = true; + this.state.smsSendBtn = true - let interval = window.setInterval(() => { + const interval = window.setInterval(() => { if (that.state.time-- <= 0) { - that.state.time = 60; - that.state.smsSendBtn = false; - window.clearInterval(interval); + that.state.time = 60 + that.state.smsSendBtn = false + window.clearInterval(interval) } - }, 1000); + }, 1000) - const hide = this.$message.loading('验证码发送中..', 0); + const hide = this.$message.loading('验证码发送中..', 0) getSmsCaptcha({mobile: values.mobile}).then(res => { - setTimeout(hide, 2500); + setTimeout(hide, 2500) this.$notification['success']({ message: '提示', description: '验证码获取成功,您的验证码为:' + res.result.captcha, duration: 8 }) }).catch(err => { - setTimeout(hide, 1); - clearInterval(interval); - that.state.time = 60; - that.state.smsSendBtn = false; - this.requestFailed(err); - }); + setTimeout(hide, 1) + clearInterval(interval) + that.state.time = 60 + that.state.smsSendBtn = false + this.requestFailed(err) + }) } } - ); + ) }, requestFailed(err) { this.$notification['error']({ message: '错误', - description: ((err.response || {}).data || {}).message || "请求出现错误,请稍后再试", + description: ((err.response || {}).data || {}).message || '请求出现错误,请稍后再试', duration: 4, - }); - this.registerBtn = false; + }) + this.registerBtn = false }, }, watch: { diff --git a/src/views/user/RegisterResult.vue b/src/views/user/RegisterResult.vue index e471f19218..db48304458 100644 --- a/src/views/user/RegisterResult.vue +++ b/src/views/user/RegisterResult.vue @@ -17,7 +17,7 @@ import Result from '@/views/result/Result' export default { - name: "RegisterResult", + name: 'RegisterResult', components: { Result }, @@ -29,8 +29,8 @@ }, computed: { email () { - let v = this.form && this.form.email || 'xxx' - let title = `你的账户:${v} 注册成功` + const v = this.form && this.form.email || 'xxx' + const title = `你的账户:${v} 注册成功` return title } }, From 0b6fbe669b590e912a5d8a6627abbeb0a51bafcc Mon Sep 17 00:00:00 2001 From: musnow <775130834@qq.com> Date: Sat, 15 Dec 2018 16:33:47 +0800 Subject: [PATCH 15/47] update interceptor white list --- src/permission.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/permission.js b/src/permission.js index cc386fae27..82c2d611ab 100644 --- a/src/permission.js +++ b/src/permission.js @@ -9,7 +9,7 @@ import { ACCESS_TOKEN } from '@/store/mutation-types' NProgress.configure({ showSpinner: false }) // NProgress Configuration -const whiteList = ['/user/login', '/user/register', '/user/register-result'] // no redirect whitelist +const whiteList = ['login', 'register', 'registerResult'] // no redirect whitelist router.beforeEach((to, from, next) => { NProgress.start() // start progress bar @@ -53,7 +53,7 @@ router.beforeEach((to, from, next) => { } } } else { - if (whiteList.indexOf(to.path) !== -1) { + if (whiteList.includes(to.name)) { // 在免登录白名单,直接进入 next() } else { From 55d26ac596695b3c76bd2b8b269861855752b0d9 Mon Sep 17 00:00:00 2001 From: musnow <775130834@qq.com> Date: Sat, 15 Dec 2018 16:56:20 +0800 Subject: [PATCH 16/47] update indexOf rewrite to includes --- src/components/menu/index.js | 90 +++----- src/store/modules/permission.js | 10 +- src/views/account/center/Index.vue | 356 +++++++++++++++-------------- 3 files changed, 223 insertions(+), 233 deletions(-) diff --git a/src/components/menu/index.js b/src/components/menu/index.js index d00459a306..2b185143ff 100644 --- a/src/components/menu/index.js +++ b/src/components/menu/index.js @@ -26,7 +26,7 @@ export default { default: false } }, - data () { + data() { return { openKeys: [], selectedKeys: [], @@ -34,17 +34,17 @@ export default { } }, computed: { - rootSubmenuKeys: (vm) => { + rootSubmenuKeys: vm => { const keys = [] vm.menu.forEach(item => keys.push(item.path)) return keys } }, - created () { + created() { this.updateMenu() }, watch: { - collapsed (val) { + collapsed(val) { if (val) { this.cachedOpenKeys = this.openKeys this.openKeys = [] @@ -52,94 +52,79 @@ export default { this.openKeys = this.cachedOpenKeys } }, - '$route': function () { + $route: function() { this.updateMenu() } }, methods: { - renderIcon: function (h, icon) { - return icon === 'none' || icon === undefined ? null - : h(Icon, { props: { type: icon !== undefined ? icon : '' } }) + renderIcon: function(h, icon) { + return icon === 'none' || icon === undefined ? null : h(Icon, { props: { type: icon !== undefined ? icon : '' } }) }, - renderMenuItem: function (h, menu, pIndex, index) { - return h(Item, { key: menu.path ? menu.path : 'item_' + pIndex + '_' + index }, - [ - h( - 'router-link', - { attrs: { to: { name: menu.name } } }, - [ - this.renderIcon(h, menu.meta.icon), - h('span', [ menu.meta.title ]) - ] - ) - ] - ) + renderMenuItem: function(h, menu, pIndex, index) { + return h(Item, { key: menu.path ? menu.path : 'item_' + pIndex + '_' + index }, [ + h('router-link', { attrs: { to: { name: menu.name } } }, [ + this.renderIcon(h, menu.meta.icon), + h('span', [menu.meta.title]) + ]) + ]) }, - renderSubMenu: function (h, menu, pIndex, index) { + renderSubMenu: function(h, menu, pIndex, index) { const this2_ = this - const subItem = [ h('span', - { slot: 'title' }, - [ - this.renderIcon(h, menu.meta.icon), - h('span', [ menu.meta.title ]) - ] - ) ] + const subItem = [h('span', { slot: 'title' }, [this.renderIcon(h, menu.meta.icon), h('span', [menu.meta.title])])] const itemArr = [] const pIndex_ = pIndex + '_' + index if (!menu.alwaysShow) { - menu.children.forEach(function (item, i) { + menu.children.forEach(function(item, i) { itemArr.push(this2_.renderItem(h, item, pIndex_, i)) }) } - return h( - SubMenu, - { key: menu.path ? menu.path : 'submenu_' + pIndex + '_' + index }, - subItem.concat(itemArr) - ) + return h(SubMenu, { key: menu.path ? menu.path : 'submenu_' + pIndex + '_' + index }, subItem.concat(itemArr)) }, - renderItem: function (h, menu, pIndex, index) { + renderItem: function(h, menu, pIndex, index) { if (!menu.hidden) { - return menu.children && !menu.alwaysShow ? this.renderSubMenu(h, menu, pIndex, index) : this.renderMenuItem(h, menu, pIndex, index) + return menu.children && !menu.alwaysShow + ? this.renderSubMenu(h, menu, pIndex, index) + : this.renderMenuItem(h, menu, pIndex, index) } }, - renderMenu: function (h, menuTree) { + renderMenu: function(h, menuTree) { const this2_ = this const menuArr = [] - menuTree.forEach(function (menu, i) { + menuTree.forEach(function(menu, i) { if (!menu.hidden) { menuArr.push(this2_.renderItem(h, menu, '0', i)) } }) return menuArr }, - onOpenChange (openKeys) { - const latestOpenKey = openKeys.find(key => this.openKeys.indexOf(key) === -1) - if (this.rootSubmenuKeys.indexOf(latestOpenKey) === -1) { + onOpenChange(openKeys) { + const latestOpenKey = openKeys.find(key => !this.openKeys.includes(key)) + if (!this.rootSubmenuKeys.includes(latestOpenKey)) { this.openKeys = openKeys } else { - this.openKeys = latestOpenKey ? [ latestOpenKey ] : [] + this.openKeys = latestOpenKey ? [latestOpenKey] : [] } }, - updateMenu () { + updateMenu() { const routes = this.$route.matched.concat() if (routes.length >= 4 && this.$route.meta.hidden) { routes.pop() - this.selectedKeys = [ routes[2].path ] + this.selectedKeys = [routes[2].path] } else { - this.selectedKeys = [ routes.pop().path ] + this.selectedKeys = [routes.pop().path] } const openKeys = [] if (this.mode === 'inline') { - routes.forEach((item) => { + routes.forEach(item => { openKeys.push(item.path) }) } - this.collapsed ? this.cachedOpenKeys = openKeys : this.openKeys = openKeys + this.collapsed ? (this.cachedOpenKeys = openKeys) : (this.openKeys = openKeys) } }, - render (h) { + render(h) { return h( Menu, { @@ -151,12 +136,13 @@ export default { }, on: { openChange: this.onOpenChange, - select: (obj) => { + select: obj => { this.selectedKeys = obj.selectedKeys this.$emit('select', obj) } } - }, this.renderMenu(h, this.menu) + }, + this.renderMenu(h, this.menu) ) } -} \ No newline at end of file +} diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js index b9b5af80fa..c192ae300b 100644 --- a/src/store/modules/permission.js +++ b/src/store/modules/permission.js @@ -9,10 +9,10 @@ import { asyncRouterMap, constantRouterMap } from '@/config/router.config' */ function hasPermission(permission, route) { if (route.meta && route.meta.permission) { - let flag = -1 + let flag = false for (let i = 0, len = permission.length; i < len; i++) { - flag = route.meta.permission.indexOf(permission[i]) - if (flag >= 0) { + flag = route.meta.permission.includes(permission[i]) + if (flag) { return true } } @@ -31,7 +31,7 @@ function hasPermission(permission, route) { // eslint-disable-next-line function hasRole(roles, route) { if (route.meta && route.meta.roles) { - return route.meta.roles.indexOf(roles.id) + return route.meta.roles.includes(roles.id) } else { return true } @@ -73,4 +73,4 @@ const permission = { } } -export default permission \ No newline at end of file +export default permission diff --git a/src/views/account/center/Index.vue b/src/views/account/center/Index.vue index 9921a7ca5d..578d5d6b31 100644 --- a/src/views/account/center/Index.vue +++ b/src/views/account/center/Index.vue @@ -1,12 +1,11 @@ \ No newline at end of file From 550a714adcf010126ba2860f3dffd2eb3486c108 Mon Sep 17 00:00:00 2001 From: Sendya <18x@loacg.com> Date: Sun, 16 Dec 2018 17:50:23 +0800 Subject: [PATCH 17/47] update README.mdd --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ebdbb9708..f345178cac 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,21 @@ yarn run lint } } ``` - +- 按需加载 修改文件 `babel.config.js` 并且引入 `babel-plugin-import` 开发依赖 +```ecmascript 6 +module.exports = { + presets: [ + '@vue/app' + ], + plugins: [ + [ "import", { + "libraryName": "ant-design-vue", + "libraryDirectory": "es", + "style": "css" + } ] + ] +} +``` 附属文档 From 6f39b55d3255876823c4c8805b0ed347f7520e38 Mon Sep 17 00:00:00 2001 From: Sendya <18x@loacg.com> Date: Tue, 18 Dec 2018 22:42:52 +0800 Subject: [PATCH 18/47] fix: update RoleList2 --- src/config/router.config.js | 689 ++++++++++++++++----------------- src/utils/helper/permission.js | 20 +- src/views/role/RoleList.vue | 352 ++++++++--------- 3 files changed, 510 insertions(+), 551 deletions(-) diff --git a/src/config/router.config.js b/src/config/router.config.js index b7a8f01791..f2efc17ff8 100644 --- a/src/config/router.config.js +++ b/src/config/router.config.js @@ -1,349 +1,340 @@ -import { UserLayout, BasicLayout, RouteView, BlankLayout, PageView } from '@/components/layouts' - -export const asyncRouterMap = [ - - { - path: '/', - name: 'index', - component: BasicLayout, - meta: { title: '首页' }, - redirect: '/dashboard/workplace', - children: [ - // dashboard - { - path: '/dashboard', - name: 'dashboard', - redirect: '/dashboard/workplace', - component: RouteView, - meta: { title: '仪表盘', icon: 'dashboard', permission: [ 'dashboard' ] }, - children: [ - { - path: '/dashboard/analysis', - name: 'Analysis', - component: () => import('@/views/dashboard/Analysis'), - meta: { title: '分析页', permission: [ 'dashboard' ] } - }, - { - path: '/dashboard/monitor', - name: 'Monitor', - hidden: true, - component: () => import('@/views/dashboard/Monitor'), - meta: { title: '监控页', permission: [ 'dashboard' ] } - }, - { - path: '/dashboard/workplace', - name: 'Workplace', - component: () => import('@/views/dashboard/Workplace'), - meta: { title: '工作台', permission: [ 'dashboard' ] } - } - ] - }, - - // forms - { - path: '/form', - redirect: '/form/basic-form', - component: PageView, - meta: { title: '表单页', icon: 'form', permission: [ 'form' ] }, - children: [ - { - path: '/form/base-form', - name: 'BaseForm', - component: () => import('@/views/form/BasicForm'), - meta: { title: '基础表单', permission: [ 'form' ] } - }, - { - path: '/form/step-form', - name: 'StepForm', - component: () => import('@/views/form/stepForm/StepForm'), - meta: { title: '分步表单', permission: [ 'form' ] } - }, - { - path: '/form/advanced-form', - name: 'AdvanceForm', - component: () => import('@/views/form/advancedForm/AdvancedForm'), - meta: { title: '高级表单', permission: [ 'form' ] } - } - ] - }, - - // list - { - path: '/list', - name: 'list', - component: PageView, - redirect: '/list/query-list', - meta: { title: '列表页', icon: 'table', permission: [ 'table' ] }, - children: [ - { - path: '/list/query-list', - name: 'QueryList', - component: () => import('@/views/list/TableList'), - meta: { title: '查询表格', permission: [ 'table' ] } - }, - { - path: '/list/edit-table', - name: 'EditList', - component: () => import('@/views/list/TableInnerEditList'), - meta: { title: '内联编辑表格', permission: [ 'table' ] } - }, - { - path: '/list/user-list', - name: 'UserList', - component: () => import('@/views/list/UserList'), - meta: { title: '用户列表', permission: [ 'table' ] } - }, - { - path: '/list/role-list', - name: 'RoleList', - component: () => import('@/views/list/RoleList'), - meta: { title: '角色列表', permission: [ 'table' ] } - }, - { - path: '/list/permission-list', - name: 'PermissionList', - component: () => import('@/views/list/PermissionList'), - meta: { title: '权限列表', permission: [ 'table' ] } - }, - { - path: '/list/basic-list', - name: 'BasicList', - component: () => import('@/views/list/StandardList'), - meta: { title: '标准列表', permission: [ 'table' ] } - }, - { - path: '/list/card', - name: 'CardList', - component: () => import('@/views/list/CardList'), - meta: { title: '卡片列表', permission: [ 'table' ] } - }, - { - path: '/list/search', - name: 'SearchList', - component: () => import('@/views/list/search/SearchLayout'), - redirect: '/list/search/article', - meta: { title: '搜索列表', permission: [ 'table' ] }, - children: [ - { - path: '/list/search/article', - name: 'SearchArticles', - component: () => import('../views/list/TableList'), - meta: { title: '搜索列表(文章)', permission: [ 'table' ] } - }, - { - path: '/list/search/project', - name: 'SearchProjects', - component: () => import('../views/list/TableList'), - meta: { title: '搜索列表(项目)', permission: [ 'table' ] } - }, - { - path: '/list/search/application', - name: 'SearchApplications', - component: () => import('../views/list/TableList'), - meta: { title: '搜索列表(应用)', permission: [ 'table' ] } - }, - ] - }, - ] - }, - - // profile - { - path: '/profile', - name: 'profile', - component: RouteView, - redirect: '/profile/basic', - meta: { title: '详情页', icon: 'profile', permission: [ 'profile' ] }, - children: [ - { - path: '/profile/basic', - name: 'ProfileBasic', - component: () => import('@/views/profile/basic/Index'), - meta: { title: '基础详情页', permission: [ 'profile' ] } - }, - { - path: '/profile/advanced', - name: 'ProfileAdvanced', - component: () => import('@/views/profile/advanced/Advanced'), - meta: { title: '高级详情页', permission: [ 'profile' ] } - } - ] - }, - { - path: '/system', - name: 'system', - component: RouteView, - redirect: '/system/role', - meta: { title: '系统管理', icon: 'setting', permission: [ 'table' ] }, - children: [ - { - path: '/system/role', - name: 'SystemRole', - component: () => import('@/views/role/RoleList'), - meta: { title: '角色列表', permission: [ 'table' ]} - } - ] - }, - - // result - { - path: '/result', - name: 'result', - component: PageView, - redirect: '/result/success', - meta: { title: '结果页', icon: 'check-circle-o', permission: [ 'result' ] }, - children: [ - { - path: '/result/success', - name: 'ResultSuccess', - component: () => import(/* webpackChunkName: "result" */ '@/views/result/Success'), - meta: { title: '成功', hiddenHeaderContent: true, permission: [ 'result' ] } - }, - { - path: '/result/fail', - name: 'ResultFail', - component: () => import(/* webpackChunkName: "result" */ '@/views/result/Error'), - meta: { title: '失败', hiddenHeaderContent: true, permission: [ 'result' ] } - } - ] - }, - - // Exception - { - path: '/exception', - name: 'exception', - component: RouteView, - redirect: '/exception/403', - meta: { title: '异常页', icon: 'warning', permission: [ 'exception' ] }, - children: [ - { - path: '/exception/403', - name: 'Exception403', - component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/403'), - meta: { title: '403', permission: [ 'exception' ] } - }, - { - path: '/exception/404', - name: 'Exception404', - component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404'), - meta: { title: '404', permission: [ 'exception' ] } - }, - { - path: '/exception/500', - name: 'Exception500', - component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/500'), - meta: { title: '500', permission: [ 'exception' ] } - } - ] - }, - - // account - { - path: '/account', - component: RouteView, - name: 'account', - meta: { title: '个人页', icon: 'user', keepAlive: true, permission: [ 'user' ] }, - children: [ - { - path: '/account/center', - name: 'center', - component: () => import('@/views/account/center/Index'), - meta: { title: '个人中心', keepAlive: true, permission: [ 'user' ] } - }, - { - path: '/account/settings', - name: 'settings', - component: () => import('@/views/account/settings/Index'), - meta: { title: '个人设置', hideHeader: true, keepAlive: true, permission: [ 'user' ] }, - redirect: '/account/settings/base', - alwaysShow: true, - children: [ - { - path: '/account/settings/base', - name: 'BaseSettings', - component: () => import('@/views/account/settings/BaseSetting'), - meta: { title: '基本设置', hidden: true, keepAlive: true, permission: [ 'user' ] } - }, - { - path: '/account/settings/security', - name: 'SecuritySettings', - component: () => import('@/views/account/settings/Security'), - meta: { title: '安全设置', hidden: true, keepAlive: true, permission: [ 'user' ] } - }, - { - path: '/account/settings/custom', - name: 'CustomSettings', - component: () => import('@/views/account/settings/Custom'), - meta: { title: '个性化设置', hidden: true, keepAlive: true, permission: [ 'user' ] } - }, - { - path: '/account/settings/binding', - name: 'BindingSettings', - component: () => import('@/views/account/settings/Binding'), - meta: { title: '账户绑定', hidden: true, keepAlive: true, permission: [ 'user' ] } - }, - { - path: '/account/settings/notification', - name: 'NotificationSettings', - component: () => import('@/views/account/settings/Notification'), - meta: { title: '新消息通知', hidden: true, keepAlive: true, permission: [ 'user' ] } - }, - ] - }, - ] - } - ] - }, - { - path: '*', redirect: '/404', hidden: true - } -] - -/** - * 基础路由 - * @type { *[] } - */ -export const constantRouterMap = [ - { - path: '/user', - component: UserLayout, - redirect: '/user/login', - hidden: true, - children: [ - { - path: 'login', - name: 'login', - component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login') - }, - { - path: 'register', - name: 'register', - component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register') - }, - { - path: 'register-result', - name: 'registerResult', - component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult') - } - ] - }, - - { - path: '/test', - component: BlankLayout, - redirect: '/test/home', - children: [ - { - path: 'home', - name: 'TestHome', - component: () => import('@/views/Home') - } - ] - }, - - { - path: '/404', - component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404') - }, - -] +import { UserLayout, BasicLayout, RouteView, BlankLayout, PageView } from '@/components/layouts' + +export const asyncRouterMap = [ + + { + path: '/', + name: 'index', + component: BasicLayout, + meta: { title: '首页' }, + redirect: '/dashboard/workplace', + children: [ + // dashboard + { + path: '/dashboard', + name: 'dashboard', + redirect: '/dashboard/workplace', + component: RouteView, + meta: { title: '仪表盘', icon: 'dashboard', permission: [ 'dashboard' ] }, + children: [ + { + path: '/dashboard/analysis', + name: 'Analysis', + component: () => import('@/views/dashboard/Analysis'), + meta: { title: '分析页', permission: [ 'dashboard' ] } + }, + { + path: '/dashboard/monitor', + name: 'Monitor', + hidden: true, + component: () => import('@/views/dashboard/Monitor'), + meta: { title: '监控页', permission: [ 'dashboard' ] } + }, + { + path: '/dashboard/workplace', + name: 'Workplace', + component: () => import('@/views/dashboard/Workplace'), + meta: { title: '工作台', permission: [ 'dashboard' ] } + } + ] + }, + + // forms + { + path: '/form', + redirect: '/form/basic-form', + component: PageView, + meta: { title: '表单页', icon: 'form', permission: [ 'form' ] }, + children: [ + { + path: '/form/base-form', + name: 'BaseForm', + component: () => import('@/views/form/BasicForm'), + meta: { title: '基础表单', permission: [ 'form' ] } + }, + { + path: '/form/step-form', + name: 'StepForm', + component: () => import('@/views/form/stepForm/StepForm'), + meta: { title: '分步表单', permission: [ 'form' ] } + }, + { + path: '/form/advanced-form', + name: 'AdvanceForm', + component: () => import('@/views/form/advancedForm/AdvancedForm'), + meta: { title: '高级表单', permission: [ 'form' ] } + } + ] + }, + + // list + { + path: '/list', + name: 'list', + component: PageView, + redirect: '/list/query-list', + meta: { title: '列表页', icon: 'table', permission: [ 'table' ] }, + children: [ + { + path: '/list/query-list', + name: 'QueryList', + component: () => import('@/views/list/TableList'), + meta: { title: '查询表格', permission: [ 'table' ] } + }, + { + path: '/list/edit-table', + name: 'EditList', + component: () => import('@/views/list/TableInnerEditList'), + meta: { title: '内联编辑表格', permission: [ 'table' ] } + }, + { + path: '/list/user-list', + name: 'UserList', + component: () => import('@/views/list/UserList'), + meta: { title: '用户列表', permission: [ 'table' ] } + }, + { + path: '/list/role-list', + name: 'RoleList', + component: () => import('@/views/list/RoleList'), + meta: { title: '角色列表', permission: [ 'table' ] } + }, + { + path: '/list/system-role', + name: 'SystemRole', + component: () => import('@/views/role/RoleList'), + meta: { title: '角色列表2', permission: [ 'table' ]} + }, + { + path: '/list/permission-list', + name: 'PermissionList', + component: () => import('@/views/list/PermissionList'), + meta: { title: '权限列表', permission: [ 'table' ] } + }, + { + path: '/list/basic-list', + name: 'BasicList', + component: () => import('@/views/list/StandardList'), + meta: { title: '标准列表', permission: [ 'table' ] } + }, + { + path: '/list/card', + name: 'CardList', + component: () => import('@/views/list/CardList'), + meta: { title: '卡片列表', permission: [ 'table' ] } + }, + { + path: '/list/search', + name: 'SearchList', + component: () => import('@/views/list/search/SearchLayout'), + redirect: '/list/search/article', + meta: { title: '搜索列表', permission: [ 'table' ] }, + children: [ + { + path: '/list/search/article', + name: 'SearchArticles', + component: () => import('../views/list/TableList'), + meta: { title: '搜索列表(文章)', permission: [ 'table' ] } + }, + { + path: '/list/search/project', + name: 'SearchProjects', + component: () => import('../views/list/TableList'), + meta: { title: '搜索列表(项目)', permission: [ 'table' ] } + }, + { + path: '/list/search/application', + name: 'SearchApplications', + component: () => import('../views/list/TableList'), + meta: { title: '搜索列表(应用)', permission: [ 'table' ] } + }, + ] + }, + ] + }, + + // profile + { + path: '/profile', + name: 'profile', + component: RouteView, + redirect: '/profile/basic', + meta: { title: '详情页', icon: 'profile', permission: [ 'profile' ] }, + children: [ + { + path: '/profile/basic', + name: 'ProfileBasic', + component: () => import('@/views/profile/basic/Index'), + meta: { title: '基础详情页', permission: [ 'profile' ] } + }, + { + path: '/profile/advanced', + name: 'ProfileAdvanced', + component: () => import('@/views/profile/advanced/Advanced'), + meta: { title: '高级详情页', permission: [ 'profile' ] } + } + ] + }, + + // result + { + path: '/result', + name: 'result', + component: PageView, + redirect: '/result/success', + meta: { title: '结果页', icon: 'check-circle-o', permission: [ 'result' ] }, + children: [ + { + path: '/result/success', + name: 'ResultSuccess', + component: () => import(/* webpackChunkName: "result" */ '@/views/result/Success'), + meta: { title: '成功', hiddenHeaderContent: true, permission: [ 'result' ] } + }, + { + path: '/result/fail', + name: 'ResultFail', + component: () => import(/* webpackChunkName: "result" */ '@/views/result/Error'), + meta: { title: '失败', hiddenHeaderContent: true, permission: [ 'result' ] } + } + ] + }, + + // Exception + { + path: '/exception', + name: 'exception', + component: RouteView, + redirect: '/exception/403', + meta: { title: '异常页', icon: 'warning', permission: [ 'exception' ] }, + children: [ + { + path: '/exception/403', + name: 'Exception403', + component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/403'), + meta: { title: '403', permission: [ 'exception' ] } + }, + { + path: '/exception/404', + name: 'Exception404', + component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404'), + meta: { title: '404', permission: [ 'exception' ] } + }, + { + path: '/exception/500', + name: 'Exception500', + component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/500'), + meta: { title: '500', permission: [ 'exception' ] } + } + ] + }, + + // account + { + path: '/account', + component: RouteView, + name: 'account', + meta: { title: '个人页', icon: 'user', keepAlive: true, permission: [ 'user' ] }, + children: [ + { + path: '/account/center', + name: 'center', + component: () => import('@/views/account/center/Index'), + meta: { title: '个人中心', keepAlive: true, permission: [ 'user' ] } + }, + { + path: '/account/settings', + name: 'settings', + component: () => import('@/views/account/settings/Index'), + meta: { title: '个人设置', hideHeader: true, keepAlive: true, permission: [ 'user' ] }, + redirect: '/account/settings/base', + alwaysShow: true, + children: [ + { + path: '/account/settings/base', + name: 'BaseSettings', + component: () => import('@/views/account/settings/BaseSetting'), + meta: { title: '基本设置', hidden: true, keepAlive: true, permission: [ 'user' ] } + }, + { + path: '/account/settings/security', + name: 'SecuritySettings', + component: () => import('@/views/account/settings/Security'), + meta: { title: '安全设置', hidden: true, keepAlive: true, permission: [ 'user' ] } + }, + { + path: '/account/settings/custom', + name: 'CustomSettings', + component: () => import('@/views/account/settings/Custom'), + meta: { title: '个性化设置', hidden: true, keepAlive: true, permission: [ 'user' ] } + }, + { + path: '/account/settings/binding', + name: 'BindingSettings', + component: () => import('@/views/account/settings/Binding'), + meta: { title: '账户绑定', hidden: true, keepAlive: true, permission: [ 'user' ] } + }, + { + path: '/account/settings/notification', + name: 'NotificationSettings', + component: () => import('@/views/account/settings/Notification'), + meta: { title: '新消息通知', hidden: true, keepAlive: true, permission: [ 'user' ] } + }, + ] + }, + ] + } + ] + }, + { + path: '*', redirect: '/404', hidden: true + } +] + +/** + * 基础路由 + * @type { *[] } + */ +export const constantRouterMap = [ + { + path: '/user', + component: UserLayout, + redirect: '/user/login', + hidden: true, + children: [ + { + path: 'login', + name: 'login', + component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login') + }, + { + path: 'register', + name: 'register', + component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register') + }, + { + path: 'register-result', + name: 'registerResult', + component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult') + } + ] + }, + + { + path: '/test', + component: BlankLayout, + redirect: '/test/home', + children: [ + { + path: 'home', + name: 'TestHome', + component: () => import('@/views/Home') + } + ] + }, + + { + path: '/404', + component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404') + }, + +] diff --git a/src/utils/helper/permission.js b/src/utils/helper/permission.js index 599669bbac..1714a95c3c 100644 --- a/src/utils/helper/permission.js +++ b/src/utils/helper/permission.js @@ -8,46 +8,46 @@ const PERMISSION_ENUM = { 'disable': { key: 'disable', label: '禁用' }, 'import': { key: 'import', label: '导入' }, 'export': { key: 'import', label: '导入' }, -}; +} function plugin(Vue) { if (plugin.installed) { - return; + return } !Vue.prototype.$auth && Object.defineProperties(Vue.prototype, { $auth: { get() { - const _this = this; + const _this = this return (permissions) => { - let [permission, action] = permissions.split('.'); - const permissionList = _this.$store.getters.roles.permissions; + const [permission, action] = permissions.split('.') + const permissionList = _this.$store.getters.roles.permissions permissionList.find((val) => { return val.permissionId === permission }).actionList.findIndex((val) => { return val === action - }); + }) return false } } } - }); + }) !Vue.prototype.$enum && Object.defineProperties(Vue.prototype, { $enum: { get() { // const _this = this; return (val) => { - let result = PERMISSION_ENUM; + let result = PERMISSION_ENUM val && val.split('.').forEach(v => { result = result && result[v] || null - }); + }) return result } } } - }); + }) } export default plugin \ No newline at end of file diff --git a/src/views/role/RoleList.vue b/src/views/role/RoleList.vue index c82d3ad3a2..3878a77d33 100644 --- a/src/views/role/RoleList.vue +++ b/src/views/role/RoleList.vue @@ -1,193 +1,161 @@ - - - - - \ No newline at end of file From f56ca8b4c1a8174b3bd66c0d0ec2e9ea9d9304a6 Mon Sep 17 00:00:00 2001 From: Sendya <18x@loacg.com> Date: Wed, 19 Dec 2018 09:47:33 +0800 Subject: [PATCH 19/47] update antd-vue 1.2.1 --- package.json | 2 +- src/App.vue | 3 ++ src/components/page/GlobalHeader.vue | 6 ++-- yarn.lock | 41 +++++++++++++++++++++++++--- 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 4bb0f2de80..f06eeb06ad 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ }, "dependencies": { "@antv/data-set": "^0.10.1", - "ant-design-vue": "^1.1.10", + "ant-design-vue": "^1.2.1", "axios": "^0.18.0", "dayjs": "^1.7.5", "enquire.js": "^2.1.6", diff --git a/src/App.vue b/src/App.vue index fbb6a746dc..d0752dc46c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -8,15 +8,18 @@ - - \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 00f54b774c..c7e7939afc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1386,7 +1386,7 @@ ant-design-palettes@^1.1.3: dependencies: tinycolor2 "^1.4.1" -ant-design-vue@^1.2.1: +ant-design-vue@~1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/ant-design-vue/-/ant-design-vue-1.2.1.tgz#ce71c62c6c8080372b07718df0fb405ff1863680" integrity sha512-boOtRgMIVi3c6E4EOwrF1bn3KFvpfJv75RLa0tTCZCe7ghmlN+WF0QeJPaL+LaY8dUbO8xJXiuNutzLEKNhZKQ== From 526c4cf1bcae8e1a59ab24e1fd8ac389b0e2505f Mon Sep 17 00:00:00 2001 From: Sendya <18x@loacg.com> Date: Wed, 19 Dec 2018 23:10:50 +0800 Subject: [PATCH 21/47] chore: cleanup --- src/components/menu/index.js | 4 +--- src/views/account/settings/AvatarModal.vue | 8 +++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/menu/index.js b/src/components/menu/index.js index dd68cb8a49..51cba826be 100644 --- a/src/components/menu/index.js +++ b/src/components/menu/index.js @@ -44,7 +44,6 @@ export default { this.updateMenu() }, watch: { - /* collapsed(val) { if (val) { this.cachedOpenKeys = this.openKeys.concat() @@ -53,7 +52,6 @@ export default { this.openKeys = this.cachedOpenKeys } }, - */ $route: function() { this.updateMenu() } @@ -134,7 +132,7 @@ export default { props: { theme: this.$props.theme, mode: this.$props.mode, - // openKeys: this.openKeys, + openKeys: this.openKeys, selectedKeys: this.selectedKeys }, on: { diff --git a/src/views/account/settings/AvatarModal.vue b/src/views/account/settings/AvatarModal.vue index b018fcaec2..202cdfbe44 100644 --- a/src/views/account/settings/AvatarModal.vue +++ b/src/views/account/settings/AvatarModal.vue @@ -1,5 +1,11 @@ diff --git a/src/components/setting/SettingDrawer.vue b/src/components/setting/SettingDrawer.vue index f442f7673e..04f69cad0f 100644 --- a/src/components/setting/SettingDrawer.vue +++ b/src/components/setting/SettingDrawer.vue @@ -1,11 +1,12 @@ + \ No newline at end of file + diff --git a/src/config/router.config.js b/src/config/router.config.js index f2efc17ff8..9fb499fd28 100644 --- a/src/config/router.config.js +++ b/src/config/router.config.js @@ -1,340 +1,341 @@ -import { UserLayout, BasicLayout, RouteView, BlankLayout, PageView } from '@/components/layouts' - -export const asyncRouterMap = [ - - { - path: '/', - name: 'index', - component: BasicLayout, - meta: { title: '首页' }, - redirect: '/dashboard/workplace', - children: [ - // dashboard - { - path: '/dashboard', - name: 'dashboard', - redirect: '/dashboard/workplace', - component: RouteView, - meta: { title: '仪表盘', icon: 'dashboard', permission: [ 'dashboard' ] }, - children: [ - { - path: '/dashboard/analysis', - name: 'Analysis', - component: () => import('@/views/dashboard/Analysis'), - meta: { title: '分析页', permission: [ 'dashboard' ] } - }, - { - path: '/dashboard/monitor', - name: 'Monitor', - hidden: true, - component: () => import('@/views/dashboard/Monitor'), - meta: { title: '监控页', permission: [ 'dashboard' ] } - }, - { - path: '/dashboard/workplace', - name: 'Workplace', - component: () => import('@/views/dashboard/Workplace'), - meta: { title: '工作台', permission: [ 'dashboard' ] } - } - ] - }, - - // forms - { - path: '/form', - redirect: '/form/basic-form', - component: PageView, - meta: { title: '表单页', icon: 'form', permission: [ 'form' ] }, - children: [ - { - path: '/form/base-form', - name: 'BaseForm', - component: () => import('@/views/form/BasicForm'), - meta: { title: '基础表单', permission: [ 'form' ] } - }, - { - path: '/form/step-form', - name: 'StepForm', - component: () => import('@/views/form/stepForm/StepForm'), - meta: { title: '分步表单', permission: [ 'form' ] } - }, - { - path: '/form/advanced-form', - name: 'AdvanceForm', - component: () => import('@/views/form/advancedForm/AdvancedForm'), - meta: { title: '高级表单', permission: [ 'form' ] } - } - ] - }, - - // list - { - path: '/list', - name: 'list', - component: PageView, - redirect: '/list/query-list', - meta: { title: '列表页', icon: 'table', permission: [ 'table' ] }, - children: [ - { - path: '/list/query-list', - name: 'QueryList', - component: () => import('@/views/list/TableList'), - meta: { title: '查询表格', permission: [ 'table' ] } - }, - { - path: '/list/edit-table', - name: 'EditList', - component: () => import('@/views/list/TableInnerEditList'), - meta: { title: '内联编辑表格', permission: [ 'table' ] } - }, - { - path: '/list/user-list', - name: 'UserList', - component: () => import('@/views/list/UserList'), - meta: { title: '用户列表', permission: [ 'table' ] } - }, - { - path: '/list/role-list', - name: 'RoleList', - component: () => import('@/views/list/RoleList'), - meta: { title: '角色列表', permission: [ 'table' ] } - }, - { - path: '/list/system-role', - name: 'SystemRole', - component: () => import('@/views/role/RoleList'), - meta: { title: '角色列表2', permission: [ 'table' ]} - }, - { - path: '/list/permission-list', - name: 'PermissionList', - component: () => import('@/views/list/PermissionList'), - meta: { title: '权限列表', permission: [ 'table' ] } - }, - { - path: '/list/basic-list', - name: 'BasicList', - component: () => import('@/views/list/StandardList'), - meta: { title: '标准列表', permission: [ 'table' ] } - }, - { - path: '/list/card', - name: 'CardList', - component: () => import('@/views/list/CardList'), - meta: { title: '卡片列表', permission: [ 'table' ] } - }, - { - path: '/list/search', - name: 'SearchList', - component: () => import('@/views/list/search/SearchLayout'), - redirect: '/list/search/article', - meta: { title: '搜索列表', permission: [ 'table' ] }, - children: [ - { - path: '/list/search/article', - name: 'SearchArticles', - component: () => import('../views/list/TableList'), - meta: { title: '搜索列表(文章)', permission: [ 'table' ] } - }, - { - path: '/list/search/project', - name: 'SearchProjects', - component: () => import('../views/list/TableList'), - meta: { title: '搜索列表(项目)', permission: [ 'table' ] } - }, - { - path: '/list/search/application', - name: 'SearchApplications', - component: () => import('../views/list/TableList'), - meta: { title: '搜索列表(应用)', permission: [ 'table' ] } - }, - ] - }, - ] - }, - - // profile - { - path: '/profile', - name: 'profile', - component: RouteView, - redirect: '/profile/basic', - meta: { title: '详情页', icon: 'profile', permission: [ 'profile' ] }, - children: [ - { - path: '/profile/basic', - name: 'ProfileBasic', - component: () => import('@/views/profile/basic/Index'), - meta: { title: '基础详情页', permission: [ 'profile' ] } - }, - { - path: '/profile/advanced', - name: 'ProfileAdvanced', - component: () => import('@/views/profile/advanced/Advanced'), - meta: { title: '高级详情页', permission: [ 'profile' ] } - } - ] - }, - - // result - { - path: '/result', - name: 'result', - component: PageView, - redirect: '/result/success', - meta: { title: '结果页', icon: 'check-circle-o', permission: [ 'result' ] }, - children: [ - { - path: '/result/success', - name: 'ResultSuccess', - component: () => import(/* webpackChunkName: "result" */ '@/views/result/Success'), - meta: { title: '成功', hiddenHeaderContent: true, permission: [ 'result' ] } - }, - { - path: '/result/fail', - name: 'ResultFail', - component: () => import(/* webpackChunkName: "result" */ '@/views/result/Error'), - meta: { title: '失败', hiddenHeaderContent: true, permission: [ 'result' ] } - } - ] - }, - - // Exception - { - path: '/exception', - name: 'exception', - component: RouteView, - redirect: '/exception/403', - meta: { title: '异常页', icon: 'warning', permission: [ 'exception' ] }, - children: [ - { - path: '/exception/403', - name: 'Exception403', - component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/403'), - meta: { title: '403', permission: [ 'exception' ] } - }, - { - path: '/exception/404', - name: 'Exception404', - component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404'), - meta: { title: '404', permission: [ 'exception' ] } - }, - { - path: '/exception/500', - name: 'Exception500', - component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/500'), - meta: { title: '500', permission: [ 'exception' ] } - } - ] - }, - - // account - { - path: '/account', - component: RouteView, - name: 'account', - meta: { title: '个人页', icon: 'user', keepAlive: true, permission: [ 'user' ] }, - children: [ - { - path: '/account/center', - name: 'center', - component: () => import('@/views/account/center/Index'), - meta: { title: '个人中心', keepAlive: true, permission: [ 'user' ] } - }, - { - path: '/account/settings', - name: 'settings', - component: () => import('@/views/account/settings/Index'), - meta: { title: '个人设置', hideHeader: true, keepAlive: true, permission: [ 'user' ] }, - redirect: '/account/settings/base', - alwaysShow: true, - children: [ - { - path: '/account/settings/base', - name: 'BaseSettings', - component: () => import('@/views/account/settings/BaseSetting'), - meta: { title: '基本设置', hidden: true, keepAlive: true, permission: [ 'user' ] } - }, - { - path: '/account/settings/security', - name: 'SecuritySettings', - component: () => import('@/views/account/settings/Security'), - meta: { title: '安全设置', hidden: true, keepAlive: true, permission: [ 'user' ] } - }, - { - path: '/account/settings/custom', - name: 'CustomSettings', - component: () => import('@/views/account/settings/Custom'), - meta: { title: '个性化设置', hidden: true, keepAlive: true, permission: [ 'user' ] } - }, - { - path: '/account/settings/binding', - name: 'BindingSettings', - component: () => import('@/views/account/settings/Binding'), - meta: { title: '账户绑定', hidden: true, keepAlive: true, permission: [ 'user' ] } - }, - { - path: '/account/settings/notification', - name: 'NotificationSettings', - component: () => import('@/views/account/settings/Notification'), - meta: { title: '新消息通知', hidden: true, keepAlive: true, permission: [ 'user' ] } - }, - ] - }, - ] - } - ] - }, - { - path: '*', redirect: '/404', hidden: true - } -] - -/** - * 基础路由 - * @type { *[] } - */ -export const constantRouterMap = [ - { - path: '/user', - component: UserLayout, - redirect: '/user/login', - hidden: true, - children: [ - { - path: 'login', - name: 'login', - component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login') - }, - { - path: 'register', - name: 'register', - component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register') - }, - { - path: 'register-result', - name: 'registerResult', - component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult') - } - ] - }, - - { - path: '/test', - component: BlankLayout, - redirect: '/test/home', - children: [ - { - path: 'home', - name: 'TestHome', - component: () => import('@/views/Home') - } - ] - }, - - { - path: '/404', - component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404') - }, - -] +// eslint-disable-next-line +import { UserLayout, BasicLayout, RouteView, BlankLayout, PageView } from '@/components/layouts' + +export const asyncRouterMap = [ + + { + path: '/', + name: 'index', + component: BasicLayout, + meta: { title: '首页' }, + redirect: '/dashboard/workplace', + children: [ + // dashboard + { + path: '/dashboard', + name: 'dashboard', + redirect: '/dashboard/workplace', + component: RouteView, + meta: { title: '仪表盘', icon: 'dashboard', permission: [ 'dashboard' ] }, + children: [ + { + path: '/dashboard/analysis', + name: 'Analysis', + component: () => import('@/views/dashboard/Analysis'), + meta: { title: '分析页', permission: [ 'dashboard' ] } + }, + { + path: '/dashboard/monitor', + name: 'Monitor', + hidden: true, + component: () => import('@/views/dashboard/Monitor'), + meta: { title: '监控页', permission: [ 'dashboard' ] } + }, + { + path: '/dashboard/workplace', + name: 'Workplace', + component: () => import('@/views/dashboard/Workplace'), + meta: { title: '工作台', permission: [ 'dashboard' ] } + } + ] + }, + + // forms + { + path: '/form', + redirect: '/form/basic-form', + component: PageView, + meta: { title: '表单页', icon: 'form', permission: [ 'form' ] }, + children: [ + { + path: '/form/base-form', + name: 'BaseForm', + component: () => import('@/views/form/BasicForm'), + meta: { title: '基础表单', permission: [ 'form' ] } + }, + { + path: '/form/step-form', + name: 'StepForm', + component: () => import('@/views/form/stepForm/StepForm'), + meta: { title: '分步表单', permission: [ 'form' ] } + }, + { + path: '/form/advanced-form', + name: 'AdvanceForm', + component: () => import('@/views/form/advancedForm/AdvancedForm'), + meta: { title: '高级表单', permission: [ 'form' ] } + } + ] + }, + + // list + { + path: '/list', + name: 'list', + component: PageView, + redirect: '/list/query-list', + meta: { title: '列表页', icon: 'table', permission: [ 'table' ] }, + children: [ + { + path: '/list/query-list', + name: 'QueryList', + component: () => import('@/views/list/TableList'), + meta: { title: '查询表格', permission: [ 'table' ] } + }, + { + path: '/list/edit-table', + name: 'EditList', + component: () => import('@/views/list/TableInnerEditList'), + meta: { title: '内联编辑表格', permission: [ 'table' ] } + }, + { + path: '/list/user-list', + name: 'UserList', + component: () => import('@/views/list/UserList'), + meta: { title: '用户列表', permission: [ 'table' ] } + }, + { + path: '/list/role-list', + name: 'RoleList', + component: () => import('@/views/list/RoleList'), + meta: { title: '角色列表', permission: [ 'table' ] } + }, + { + path: '/list/system-role', + name: 'SystemRole', + component: () => import('@/views/role/RoleList'), + meta: { title: '角色列表2', permission: [ 'table' ]} + }, + { + path: '/list/permission-list', + name: 'PermissionList', + component: () => import('@/views/list/PermissionList'), + meta: { title: '权限列表', permission: [ 'table' ] } + }, + { + path: '/list/basic-list', + name: 'BasicList', + component: () => import('@/views/list/StandardList'), + meta: { title: '标准列表', permission: [ 'table' ] } + }, + { + path: '/list/card', + name: 'CardList', + component: () => import('@/views/list/CardList'), + meta: { title: '卡片列表', permission: [ 'table' ] } + }, + { + path: '/list/search', + name: 'SearchList', + component: () => import('@/views/list/search/SearchLayout'), + redirect: '/list/search/article', + meta: { title: '搜索列表', permission: [ 'table' ] }, + children: [ + { + path: '/list/search/article', + name: 'SearchArticles', + component: () => import('../views/list/TableList'), + meta: { title: '搜索列表(文章)', permission: [ 'table' ] } + }, + { + path: '/list/search/project', + name: 'SearchProjects', + component: () => import('../views/list/TableList'), + meta: { title: '搜索列表(项目)', permission: [ 'table' ] } + }, + { + path: '/list/search/application', + name: 'SearchApplications', + component: () => import('../views/list/TableList'), + meta: { title: '搜索列表(应用)', permission: [ 'table' ] } + }, + ] + }, + ] + }, + + // profile + { + path: '/profile', + name: 'profile', + component: RouteView, + redirect: '/profile/basic', + meta: { title: '详情页', icon: 'profile', permission: [ 'profile' ] }, + children: [ + { + path: '/profile/basic', + name: 'ProfileBasic', + component: () => import('@/views/profile/basic/Index'), + meta: { title: '基础详情页', permission: [ 'profile' ] } + }, + { + path: '/profile/advanced', + name: 'ProfileAdvanced', + component: () => import('@/views/profile/advanced/Advanced'), + meta: { title: '高级详情页', permission: [ 'profile' ] } + } + ] + }, + + // result + { + path: '/result', + name: 'result', + component: PageView, + redirect: '/result/success', + meta: { title: '结果页', icon: 'check-circle-o', permission: [ 'result' ] }, + children: [ + { + path: '/result/success', + name: 'ResultSuccess', + component: () => import(/* webpackChunkName: "result" */ '@/views/result/Success'), + meta: { title: '成功', hiddenHeaderContent: true, permission: [ 'result' ] } + }, + { + path: '/result/fail', + name: 'ResultFail', + component: () => import(/* webpackChunkName: "result" */ '@/views/result/Error'), + meta: { title: '失败', hiddenHeaderContent: true, permission: [ 'result' ] } + } + ] + }, + + // Exception + { + path: '/exception', + name: 'exception', + component: RouteView, + redirect: '/exception/403', + meta: { title: '异常页', icon: 'warning', permission: [ 'exception' ] }, + children: [ + { + path: '/exception/403', + name: 'Exception403', + component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/403'), + meta: { title: '403', permission: [ 'exception' ] } + }, + { + path: '/exception/404', + name: 'Exception404', + component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404'), + meta: { title: '404', permission: [ 'exception' ] } + }, + { + path: '/exception/500', + name: 'Exception500', + component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/500'), + meta: { title: '500', permission: [ 'exception' ] } + } + ] + }, + + // account + { + path: '/account', + component: RouteView, + name: 'account', + meta: { title: '个人页', icon: 'user', keepAlive: true, permission: [ 'user' ] }, + children: [ + { + path: '/account/center', + name: 'center', + component: () => import('@/views/account/center/Index'), + meta: { title: '个人中心', keepAlive: true, permission: [ 'user' ] } + }, + { + path: '/account/settings', + name: 'settings', + component: () => import('@/views/account/settings/Index'), + meta: { title: '个人设置', hideHeader: true, keepAlive: true, permission: [ 'user' ] }, + redirect: '/account/settings/base', + alwaysShow: true, + children: [ + { + path: '/account/settings/base', + name: 'BaseSettings', + component: () => import('@/views/account/settings/BaseSetting'), + meta: { title: '基本设置', hidden: true, keepAlive: true, permission: [ 'user' ] } + }, + { + path: '/account/settings/security', + name: 'SecuritySettings', + component: () => import('@/views/account/settings/Security'), + meta: { title: '安全设置', hidden: true, keepAlive: true, permission: [ 'user' ] } + }, + { + path: '/account/settings/custom', + name: 'CustomSettings', + component: () => import('@/views/account/settings/Custom'), + meta: { title: '个性化设置', hidden: true, keepAlive: true, permission: [ 'user' ] } + }, + { + path: '/account/settings/binding', + name: 'BindingSettings', + component: () => import('@/views/account/settings/Binding'), + meta: { title: '账户绑定', hidden: true, keepAlive: true, permission: [ 'user' ] } + }, + { + path: '/account/settings/notification', + name: 'NotificationSettings', + component: () => import('@/views/account/settings/Notification'), + meta: { title: '新消息通知', hidden: true, keepAlive: true, permission: [ 'user' ] } + }, + ] + }, + ] + } + ] + }, + { + path: '*', redirect: '/404', hidden: true + } +] + +/** + * 基础路由 + * @type { *[] } + */ +export const constantRouterMap = [ + { + path: '/user', + component: UserLayout, + redirect: '/user/login', + hidden: true, + children: [ + { + path: 'login', + name: 'login', + component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login') + }, + { + path: 'register', + name: 'register', + component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register') + }, + { + path: 'register-result', + name: 'registerResult', + component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult') + } + ] + }, + + { + path: '/test', + component: BlankLayout, + redirect: '/test/home', + children: [ + { + path: 'home', + name: 'TestHome', + component: () => import('@/views/Home') + } + ] + }, + + { + path: '/404', + component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404') + }, + +] From 47c90ae42f36b639cb9e35e01acc541b9f7d44b2 Mon Sep 17 00:00:00 2001 From: Xuz Date: Wed, 2 Jan 2019 18:26:42 +0800 Subject: [PATCH 35/47] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20IE=20=E4=B8=8B?= =?UTF-8?q?=E5=B7=A6=E8=BE=B9=E8=8F=9C=E5=8D=95=E9=AB=98=E5=BA=A6=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=EF=BC=8CPageView=20=E6=97=A0=E5=9B=BE?= =?UTF-8?q?=E5=83=8F=E5=86=85=E5=AE=B9=E6=97=B6=E9=A1=B5=E9=9D=A2=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E4=B8=8D=E6=AD=A3=E7=A1=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/layouts/PageView.vue | 2 +- src/components/page/GlobalLayout.vue | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/layouts/PageView.vue b/src/components/layouts/PageView.vue index e34504380a..eaf7f44977 100644 --- a/src/components/layouts/PageView.vue +++ b/src/components/layouts/PageView.vue @@ -1,7 +1,7 @@