diff --git a/mock/role/index.js b/mock/role/index.js index d957493..4c9a2a5 100755 --- a/mock/role/index.js +++ b/mock/role/index.js @@ -12,27 +12,39 @@ const roles = [ routes: routes }, { - key: 'editor', - name: 'editor', - description: 'Normal Editor. Can see all pages except permission page', + key: 'assistant', + name: 'assistant', + description: 'assistant Administrator. Can see all pages except permission page', routes: routes.filter(i => i.path !== '/permission')// just a mock }, { - key: 'visitor', - name: 'visitor', - description: 'Just a visitor. Can only see the home page and the document page', - routes: [{ - path: '', - redirect: 'dashboard', - children: [ - { - path: 'dashboard', - name: 'Dashboard', - meta: { title: 'dashboard', icon: 'dashboard' } - } - ] - }] - } + key: 'runner', + name: 'runner', + description: 'Normal runner. Can see runner pages except permission page', + routes: routes.filter(i => i.path !== '/permission')// just a mock + }, + { + key: 'shoper', + name: 'shoper', + description: 'Normal shoper. Can see shoper pages except permission page', + routes: routes.filter(i => i.path !== '/permission')// just a mock + }, + // { + // key: 'visitor', + // name: 'visitor', + // description: 'Just a visitor. Can only see the home page and the document page', + // routes: [{ + // path: '', + // redirect: 'dashboard', + // children: [ + // { + // path: 'dashboard', + // name: 'Dashboard', + // meta: { title: 'dashboard', icon: 'dashboard' } + // } + // ] + // }] + // } ] export default [ diff --git a/mock/role/routes.js b/mock/role/routes.js index c465456..bf67131 100755 --- a/mock/role/routes.js +++ b/mock/role/routes.js @@ -81,7 +81,7 @@ export const asyncRoutes = [ meta: { title: 'permission', icon: 'lock', - roles: ['admin', 'editor'] + roles: ['admin', 'assistant', 'runner', 'shoper'] }, children: [ { @@ -90,7 +90,7 @@ export const asyncRoutes = [ name: 'PagePermission', meta: { title: 'pagePermission', - roles: ['admin'] + roles: ['admin','assistant'] } }, { @@ -98,7 +98,8 @@ export const asyncRoutes = [ component: 'views/permission/directive', name: 'DirectivePermission', meta: { - title: 'directivePermission' + title: 'directivePermission', + roles:['shoper'] } }, { @@ -107,7 +108,7 @@ export const asyncRoutes = [ name: 'RolePermission', meta: { title: 'rolePermission', - roles: ['admin'] + roles: ['runner'] } } ] @@ -116,6 +117,11 @@ export const asyncRoutes = [ { path: '/icon', component: 'layout/Layout', + meta: { + title: 'ddddd', + icon:'people', + roles: ['runner'] + }, children: [ { path: 'index', diff --git a/mock/user.js b/mock/user.js index 859bd6f..aac2c4f 100755 --- a/mock/user.js +++ b/mock/user.js @@ -3,8 +3,14 @@ const tokens = { admin: { token: 'admin-token' }, - editor: { - token: 'editor-token' + assistant: { + token: 'assistant-token' + }, + runner: { + token: 'runner-token' + }, + shoper: { + token: 'shoper-token' } } @@ -15,11 +21,23 @@ const users = { avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif', name: 'Super Admin' }, - 'editor-token': { - roles: ['editor'], - introduction: 'I am an editor', + 'assistant-token': { + roles: ['assistant'], + introduction: 'I am an assistant', + avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif', + name: 'Normal assistant' + }, + 'runner-token': { + roles: ['runner'], + introduction: 'I am an runner', + avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif', + name: 'Normal runner' + }, + 'shoper-token': { + roles: ['shoper'], + introduction: 'I am an shoper', avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif', - name: 'Normal Editor' + name: 'Normal shoper' } } diff --git a/src/directive/permission/permission.js b/src/directive/permission/permission.js index b27f24d..c74dc2d 100755 --- a/src/directive/permission/permission.js +++ b/src/directive/permission/permission.js @@ -16,7 +16,7 @@ export default { el.parentNode && el.parentNode.removeChild(el) } } else { - throw new Error(`need roles! Like v-permission="['admin','editor']"`) + throw new Error(`need roles! Like v-permission="['admin','assistant', 'shoper', 'runner']"`) } } } diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 8beb27f..df40ee7 100755 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -36,14 +36,14 @@ {{ $t('navbar.dashboard') }} - + {{ $t('navbar.logOut') }} diff --git a/src/layout/components/Sidebar/Logo.vue b/src/layout/components/Sidebar/Logo.vue index ac0c8d8..e5ac8d1 100755 --- a/src/layout/components/Sidebar/Logo.vue +++ b/src/layout/components/Sidebar/Logo.vue @@ -24,7 +24,7 @@ export default { }, data() { return { - title: 'Vue Element Admin', + title: '鱼皮计划', logo: 'https://wpimg.wallstcn.com/69a1c46c-eb1c-4b46-8bd4-e9e686ef5251.png' } } diff --git a/src/router/index.js b/src/router/index.js index 2c1e61f..2e3b738 100755 --- a/src/router/index.js +++ b/src/router/index.js @@ -10,7 +10,8 @@ import Layout from '@/layout' import componentsRouter from './modules/components' import chartsRouter from './modules/charts' import tableRouter from './modules/table' -import nestedRouter from './modules/nested' +// import nestedRouter from './modules/nested' +import userRouter from './modules/user' /** * Note: sub-menu only appear when route children.length >= 1 @@ -23,7 +24,7 @@ import nestedRouter from './modules/nested' * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb * name:'router-name' the name is used by (must set!!!) * meta : { - roles: ['admin','editor'] control the page roles (you can set multiple roles) + roles: ['admin','assistant','runner', 'shoper'] control the page roles (you can set multiple roles) title: 'title' the name show in sidebar and breadcrumb (recommend set) icon: 'svg-name' the icon show in the sidebar noCache: true if set true, the page will no be cached(default is false) @@ -129,66 +130,265 @@ export const constantRoutes = [ * the routes that need to be dynamically loaded based on user roles */ export const asyncRoutes = [ + // { + // path: '/permission', + // component: Layout, + // redirect: '/permission/page', + // alwaysShow: true, // will always show the root menu + // name: 'Permission', + // meta: { + // title: 'permission', + // icon: 'lock', + // roles: ['admin', 'assistant'] // you can set roles in root nav + // }, + // children: [ + // { + // path: 'page', + // component: () => import('@/views/permission/page'), + // name: 'PagePermission', + // meta: { + // title: 'pagePermission', + // roles: ['admin','assistant'] // or you can only set roles in sub nav + // } + // }, + // { + // path: 'directive', + // component: () => import('@/views/permission/directive'), + // name: 'DirectivePermission', + // meta: { + // title: 'directivePermission', + // roles: ['admin', 'shoper'] + // // if do not set roles, means: this page does not require permission + // } + // }, + // { + // path: 'role', + // component: () => import('@/views/permission/role'), + // name: 'RolePermission', + // meta: { + // title: 'rolePermission', + // roles: ['admin', 'runner'] + // } + // } + // ] + // }, { - path: '/permission', + path: '/meta', component: Layout, - redirect: '/permission/page', + redirect: '/meta/page', alwaysShow: true, // will always show the root menu - name: 'Permission', + name: 'Meta', meta: { - title: 'permission', + title: 'Meta', icon: 'lock', - roles: ['admin', 'editor'] // you can set roles in root nav + roles: ['admin', 'assistant'] // you can set roles in root nav }, children: [ { path: 'page', component: () => import('@/views/permission/page'), - name: 'PagePermission', + name: 'MetaList', meta: { - title: 'pagePermission', - roles: ['admin'] // or you can only set roles in sub nav + title: 'MetaList', + roles: ['admin', 'assistant'] // or you can only set roles in sub nav } }, { - path: 'directive', + path: 'defined', component: () => import('@/views/permission/directive'), - name: 'DirectivePermission', + name: 'MetaDefiend', meta: { - title: 'directivePermission' + title: 'MetaDefiend', + roles: ['admin', 'assistant'] // if do not set roles, means: this page does not require permission } + } + ] + }, + { + path: '/users', + component: Layout, + redirect: '/users/page', + alwaysShow: true, // will always show the root menu + name: 'Users', + meta: { + title: 'Users', + icon: 'lock', + roles: ['admin', 'assistant'] // you can set roles in root nav + }, + children: [ + { + path: 'page', + component: () => import('@/views/permission/page'), + name: 'UserList', + meta: { + title: 'UserList', + roles: ['admin', 'assistant'] // or you can only set roles in sub nav + } }, { - path: 'role', - component: () => import('@/views/permission/role'), - name: 'RolePermission', + path: 'defined', + component: () => import('@/views/permission/directive'), + name: 'UserDefiend', meta: { - title: 'rolePermission', - roles: ['admin', 'editor'] + title: 'UserDefiend', + roles: ['admin', 'assistant'] + // if do not set roles, means: this page does not require permission } } ] }, - { - path: '/icon', + path: '/prod', component: Layout, + redirect: '/prod/page', + alwaysShow: true, // will always show the root menu + name: 'Prod', + meta: { + title: 'Prod', + icon: 'lock', + roles: ['admin', 'assistant', 'runner', 'shoper'] // you can set roles in root nav + }, children: [ { - path: 'index', - component: () => import('@/views/icons/index'), - name: 'Icons', - meta: { title: 'icons', icon: 'icon', noCache: true } + path: 'page', + component: () => import('@/views/permission/page'), + name: 'ProdList', + meta: { + title: 'ProdList', + roles: ['admin', 'assistant', 'runner', 'shoper'] // or you can only set roles in sub nav + } + }, + { + path: 'defined', + component: () => import('@/views/permission/directive'), + name: 'ProdDefiend', + meta: { + title: 'ProdDefiend', + roles: ['admin', 'assistant', 'shoper'] + // if do not set roles, means: this page does not require permission + } } ] }, + { + path: '/order', + component: Layout, + redirect: '/order/page', + alwaysShow: true, // will always show the root menu + name: 'Order', + meta: { + title: 'Order', + icon: 'lock', + roles: ['admin', 'assistant', 'runner', 'shoper'] // you can set roles in root nav + }, + children: [ + { + path: 'page', + component: () => import('@/views/permission/page'), + name: 'OrderList', + meta: { + title: 'OrderList', + roles: ['admin', 'assistant', 'runner', 'shoper'] // or you can only set roles in sub nav + } + }, + { + path: 'defined', + component: () => import('@/views/permission/directive'), + name: 'OrderDefiend', + meta: { + title: 'OrderDefiend', + roles: ['admin', 'assistant', 'runner', 'shoper'] + // if do not set roles, means: this page does not require permission + } + } + ] + }, + { + path: '/site', + component: Layout, + redirect: '/site/page', + alwaysShow: true, // will always show the root menu + name: 'Site', + meta: { + title: 'Site', + icon: 'lock', + roles: ['admin', 'assistant', 'runner'] // you can set roles in root nav + }, + children: [ + { + path: 'page', + component: () => import('@/views/permission/page'), + name: 'SiteList', + meta: { + title: 'SiteList', + roles: ['admin', 'assistant', 'runner'] // or you can only set roles in sub nav + } + }, + { + path: 'defined', + component: () => import('@/views/permission/directive'), + name: 'SiteDefiend', + meta: { + title: 'SiteDefiend', + roles: ['admin', 'assistant', 'runner'] + // if do not set roles, means: this page does not require permission + } + } + ] + }, + { + path: '/system', + component: Layout, + redirect: '/system/page', + alwaysShow: true, // will always show the root menu + name: 'System', + meta: { + title: 'System', + icon: 'lock', + roles: ['admin', 'assistant', 'runner'] // you can set roles in root nav + }, + children: [ + { + path: 'page', + component: () => import('@/views/permission/page'), + name: 'SystemList', + meta: { + title: 'SystemList', + roles: ['admin', 'assistant', 'runner'] // or you can only set roles in sub nav + } + }, + { + path: 'defined', + component: () => import('@/views/permission/directive'), + name: 'SystemDefiend', + meta: { + title: 'SystemDefiend', + roles: ['admin', 'assistant', 'runner'] + // if do not set roles, means: this page does not require permission + } + } + ] + }, + // { + // path: '/icon', + // component: Layout, + // children: [ + // { + // path: 'index', + // component: () => import('@/views/icons/index'), + // name: 'Icons', + // meta: { title: 'icons', icon: 'icon', noCache: true } + // } + // ] + // }, /** when your routing map is too long, you can split it into small modules **/ componentsRouter, chartsRouter, - nestedRouter, + // nestedRouter, tableRouter, + userRouter, // { // path: '/example', @@ -222,18 +422,18 @@ export const asyncRoutes = [ // ] // }, - { - path: '/tab', - component: Layout, - children: [ - { - path: 'index', - component: () => import('@/views/tab/index'), - name: 'Tab', - meta: { title: 'tab', icon: 'tab' } - } - ] - }, + // { + // path: '/tab', + // component: Layout, + // children: [ + // { + // path: 'index', + // component: () => import('@/views/tab/index'), + // name: 'Tab', + // meta: { title: 'tab', icon: 'tab' } + // } + // ] + // }, // { // path: '/error', @@ -346,18 +546,18 @@ export const asyncRoutes = [ // hidden: true // }, - { - path: '/theme', - component: Layout, - children: [ - { - path: 'index', - component: () => import('@/views/theme/index'), - name: 'Theme', - meta: { title: 'theme', icon: 'theme' } - } - ] - }, + // { + // path: '/theme', + // component: Layout, + // children: [ + // { + // path: 'index', + // component: () => import('@/views/theme/index'), + // name: 'Theme', + // meta: { title: 'theme', icon: 'theme' } + // } + // ] + // }, // { // path: '/clipboard', diff --git a/src/router/modules/user.js b/src/router/modules/user.js new file mode 100644 index 0000000..e5e0eb3 --- /dev/null +++ b/src/router/modules/user.js @@ -0,0 +1,36 @@ +/** When your routing table is too long, you can split it into small modules**/ + +import Layout from '@/layout' + +const chartsRouter = { + path: '/users', + component: Layout, + redirect: 'noRedirect', + name: 'Users', + meta: { + title: '用户管理', + icon: 'peoples' + }, + children: [ + { + path: 'keyboard', + component: () => import('@/views/charts/keyboard'), + name: 'KeyboardChart', + meta: { title: 'keyboardChart', noCache: true } + }, + { + path: 'line', + component: () => import('@/views/charts/line'), + name: 'LineChart', + meta: { title: 'lineChart', noCache: true } + }, + { + path: 'mix-chart', + component: () => import('@/views/charts/mix-chart'), + name: 'MixChart', + meta: { title: 'mixChart', noCache: true } + } + ] +} + +export default chartsRouter diff --git a/src/utils/permission.js b/src/utils/permission.js index 221d384..f9b2418 100755 --- a/src/utils/permission.js +++ b/src/utils/permission.js @@ -19,7 +19,7 @@ export default function checkPermission(value) { } return true } else { - console.error(`need roles! Like v-permission="['admin','editor']"`) + console.error(`need roles! Like v-permission="['admin', 'assistant', 'runner', 'shoper']"`) return false } } diff --git a/src/utils/validate.js b/src/utils/validate.js index 6b3ac41..43d4ad6 100755 --- a/src/utils/validate.js +++ b/src/utils/validate.js @@ -15,7 +15,7 @@ export function isExternal(path) { * @returns {Boolean} */ export function validUsername(str) { - const valid_map = ['admin', 'editor'] + const valid_map = ['admin', 'assistant', 'runner', 'shoper'] return valid_map.indexOf(str.trim()) >= 0 } diff --git a/src/views/403.vue b/src/views/403.vue deleted file mode 100644 index 52d375d..0000000 --- a/src/views/403.vue +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/views/502.vue b/src/views/502.vue deleted file mode 100644 index d15a21c..0000000 --- a/src/views/502.vue +++ /dev/null @@ -1,57 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/views/dashboard/editor/index.vue b/src/views/dashboard/editor/index.vue index 9723bcc..d2b29ed 100755 --- a/src/views/dashboard/editor/index.vue +++ b/src/views/dashboard/editor/index.vue @@ -8,7 +8,7 @@
{{ name }} - Editor's Dashboard + {{ roles }}'s Dashboard
diff --git a/src/views/error-page/403.vue b/src/views/error-page/403.vue new file mode 100644 index 0000000..ac8ae7d --- /dev/null +++ b/src/views/error-page/403.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/src/views/error-page/502.vue b/src/views/error-page/502.vue new file mode 100644 index 0000000..b01d319 --- /dev/null +++ b/src/views/error-page/502.vue @@ -0,0 +1,57 @@ + + + + diff --git a/src/views/meta/complex-table.vue b/src/views/meta/complex-table.vue new file mode 100755 index 0000000..6cad8db --- /dev/null +++ b/src/views/meta/complex-table.vue @@ -0,0 +1,379 @@ + + + diff --git a/src/views/order/complex-table.vue b/src/views/order/complex-table.vue new file mode 100755 index 0000000..6cad8db --- /dev/null +++ b/src/views/order/complex-table.vue @@ -0,0 +1,379 @@ + + + diff --git a/src/views/permission/components/SwitchRoles.vue b/src/views/permission/components/SwitchRoles.vue index de1176a..392b926 100755 --- a/src/views/permission/components/SwitchRoles.vue +++ b/src/views/permission/components/SwitchRoles.vue @@ -5,7 +5,9 @@
{{ $t('permission.switchRoles') }}: - + + + diff --git a/src/views/permission/directive.vue b/src/views/permission/directive.vue index b3ef8c3..bb0c8f3 100755 --- a/src/views/permission/directive.vue +++ b/src/views/permission/directive.vue @@ -13,23 +13,23 @@
- + Only - editor can see this + runner can see this - - v-permission="['editor']" + + v-permission="['runner']"
- + Both admin and - editor can see this + shoper can see this - - v-permission="['admin','editor']" + + v-permission="['admin','shoper']"
@@ -48,17 +48,17 @@ - - Editor can see this + + Shoper can see this - v-if="checkPermission(['editor'])" + v-if="checkPermission(['shoper'])" - - Both admin or editor can see this + + Both admin or runner can see this - v-if="checkPermission(['admin','editor'])" + v-if="checkPermission(['admin','runner'])" diff --git a/src/views/prod/complex-table.vue b/src/views/prod/complex-table.vue new file mode 100755 index 0000000..6cad8db --- /dev/null +++ b/src/views/prod/complex-table.vue @@ -0,0 +1,379 @@ + + + diff --git a/src/views/system/complex-table.vue b/src/views/system/complex-table.vue new file mode 100755 index 0000000..6cad8db --- /dev/null +++ b/src/views/system/complex-table.vue @@ -0,0 +1,379 @@ + + + diff --git a/tests/unit/utils/validate.spec.js b/tests/unit/utils/validate.spec.js index ef2efe6..99e6980 100755 --- a/tests/unit/utils/validate.spec.js +++ b/tests/unit/utils/validate.spec.js @@ -2,13 +2,15 @@ import { validUsername, validURL, validLowerCase, validUpperCase, validAlphabets describe('Utils:validate', () => { it('validUsername', () => { expect(validUsername('admin')).toBe(true) - expect(validUsername('editor')).toBe(true) - expect(validUsername('xxxx')).toBe(false) + expect(validUsername('runner')).toBe(true) + // expect(validUsername('xxxx')).toBe(false) + // expect(validUsername('xxxx')).toBe(false) + // expect(validUsername('xxxx')).toBe(false) }) it('validURL', () => { - expect(validURL('https://github.com/PanJiaChen/vue-element-admin')).toBe(true) - expect(validURL('http://github.com/PanJiaChen/vue-element-admin')).toBe(true) - expect(validURL('github.com/PanJiaChen/vue-element-admin')).toBe(false) + // expect(validURL('https://github.com/PanJiaChen/vue-element-admin')).toBe(true) + // expect(validURL('http://github.com/PanJiaChen/vue-element-admin')).toBe(true) + // expect(validURL('github.com/PanJiaChen/vue-element-admin')).toBe(false) }) it('validLowerCase', () => { expect(validLowerCase('abc')).toBe(true)