Commit afdf4eec authored by trumansdo's avatar trumansdo
Browse files

确定路由表应该由后端生成,前端应该存有一份路由名的映射关系

parent f2544d0e
...@@ -15,12 +15,26 @@ ...@@ -15,12 +15,26 @@
<artifactId>admin-core</artifactId> <artifactId>admin-core</artifactId>
<version>1.3.2</version> <version>1.3.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<version>8.0.17</version> <version>8.0.17</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>2.1.7.RELEASE</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -236,8 +236,7 @@ public class UserConsoleController { ...@@ -236,8 +236,7 @@ public class UserConsoleController {
/** /**
* 用户所有授权角色列表 * 用户所有授权角色列表
* *
* @param id * @param id 用户id
* 用户id
* @return * @return
*/ */
@PostMapping(MODEL + "/role/list.json") @PostMapping(MODEL + "/role/list.json")
...@@ -284,17 +283,17 @@ public class UserConsoleController { ...@@ -284,17 +283,17 @@ public class UserConsoleController {
@PostMapping(MODEL + "/excel/export.json") @PostMapping(MODEL + "/excel/export.json")
@Function("user.export") @Function("user.export")
@ResponseBody @ResponseBody
public JsonResult<String> export(HttpServletResponse response,UserQuery condtion) { public JsonResult<String> export(HttpServletResponse response, UserQuery condtion) {
String excelTemplate ="excelTemplates/admin/user/user_collection_template.xls"; String excelTemplate = "excelTemplates/admin/user/user_collection_template.xls";
PageQuery<CoreUser> page = condtion.getPageQuery(); PageQuery<CoreUser> page = condtion.getPageQuery();
//取出全部符合条件的 //取出全部符合条件的
page.setPageSize(Integer.MAX_VALUE); page.setPageSize(Integer.MAX_VALUE);
page.setPageNumber(1); page.setPageNumber(1);
page.setTotalRow(Integer.MAX_VALUE); page.setTotalRow(Integer.MAX_VALUE);
List<UserExcelExportData> users =userConsoleService.queryExcel(page); List<UserExcelExportData> users = userConsoleService.queryExcel(page);
try(InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(excelTemplate)) { try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(excelTemplate)) {
if(is==null) { if (is == null) {
throw new PlatformException("模板资源不存在:"+excelTemplate); throw new PlatformException("模板资源不存在:" + excelTemplate);
} }
FileItem item = fileService.createFileTemp("user_collection.xls"); FileItem item = fileService.createFileTemp("user_collection.xls");
OutputStream os = item.openOutpuStream(); OutputStream os = item.openOutpuStream();
...@@ -310,8 +309,4 @@ public class UserConsoleController { ...@@ -310,8 +309,4 @@ public class UserConsoleController {
} }
} }
...@@ -70,10 +70,10 @@ ...@@ -70,10 +70,10 @@
<groupId>com.zaxxer</groupId> <groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId> <artifactId>HikariCP</artifactId>
</dependency> </dependency>
<dependency> <!--<dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
</dependency> </dependency>-->
<!-- <dependency> <!-- <dependency>
<groupId>com.oracle</groupId> <groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId> <artifactId>ojdbc6</artifactId>
......
...@@ -64,8 +64,8 @@ public class CustomErrorController extends AbstractErrorController { ...@@ -64,8 +64,8 @@ public class CustomErrorController extends AbstractErrorController {
//后台打印日志信息方方便查错 //后台打印日志信息方方便查错
log.info(status+":"+message+filedErrors, cause); log.error(status+":"+message+filedErrors, cause);
log.info("requestPath"+":"+requestPath); log.error("requestPath"+":"+requestPath);
response.setStatus(status); response.setStatus(status);
......
...@@ -40,7 +40,7 @@ public class IndexController { ...@@ -40,7 +40,7 @@ public class IndexController {
@PostMapping("/login.do") @PostMapping("/user/login")
public ModelAndView login(String code, String password) { public ModelAndView login(String code, String password) {
UserLoginInfo info = userService.login(code, password); UserLoginInfo info = userService.login(code, password);
if (info == null) { if (info == null) {
......
# just a flag # just a flag
ENV = 'development' ENV = 'development'
# base api # base api 用于axios 配置中的baseURL,是服务器地址。
# 在这里是webpack-dev-server启动的地址,然后通过webpack-dev-server的proxy代理到我们的后台服务器
# 仅限开发环境,生产环境要用NGINX仅限代理
VUE_APP_BASE_API = '/dev-api' VUE_APP_BASE_API = '/dev-api'
VUE_APP_SERVER_HOST = 'http://127.0.0.1:9527/mock'
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable, # vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
# to control whether the babel-plugin-dynamic-import-node plugin is enabled. # to control whether the babel-plugin-dynamic-import-node plugin is enabled.
......
...@@ -2,12 +2,30 @@ module.exports = { ...@@ -2,12 +2,30 @@ module.exports = {
root: true, root: true,
env: { env: {
node: true browser: true,
node: true,
es6: true
}, },
extends: ['plugin:vue/essential', '@vue/prettier'], extends: [
// 各种eslint检查的规则 'plugin:vue/essential',
'plugin:prettier/recommended',
'eslint:recommended'
],
plugins: ['vue'],
// 各种eslint检查的规则
rules: { rules: {
'prettier/prettier': [
'off',
{
singleQuote: true,
trailingComma: 'none',
bracketSpacing: true,
jsxBracketSameLine: true,
parser: 'flow',
semi: false
}
],
'no-console': 'off', 'no-console': 'off',
'no-debugger': 'off', 'no-debugger': 'off',
'no-unused-vars': 'off', 'no-unused-vars': 'off',
...@@ -20,7 +38,50 @@ module.exports = { ...@@ -20,7 +38,50 @@ module.exports = {
allowTemplateLiterals: true allowTemplateLiterals: true
} }
], ],
'jsx-quotes': [2, 'prefer-single'] 'jsx-quotes': [2, 'prefer-single'],
// 缩进为2个空格
'vue/html-indent': [
'error',
2,
{
attribute: 1,
alignAttributesVertically: true,
ignores: []
}
],
'vue/max-attributes-per-line': [
2,
{
singleline: 10,
multiline: {
max: 1,
allowFirstLine: false
}
}
],
'vue/html-self-closing': 'off',
'vue/name-property-casing': ['error', 'PascalCase'],
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// 关闭检测函数名称和调用它的左括号之间的空格
// 'func-call-spacing': 'off',
// 缩进为2个空格
indent: ['error', 2],
// 关闭检测未使用的变量
'no-unused-vars': 'off',
// 对象展开时总是要添加逗号,一行时行末不需要逗号
// 'comma-dangle': ['error', 'always-multiline'],
// 关闭禁用无效标签
'no-tabs': 'off',
// 关闭空行检测
'no-multiple-empty-lines': 'off',
// 关闭模板字符串检测
'no-template-curly-in-string': 'off',
'no-console': 'off',
// 禁止添加分号
semi: ['error', 'never']
}, },
parserOptions: { parserOptions: {
...@@ -37,4 +98,4 @@ module.exports = { ...@@ -37,4 +98,4 @@ module.exports = {
], ],
extends: ['plugin:vue/essential', '@vue/prettier'] extends: ['plugin:vue/essential', '@vue/prettier']
}; }
...@@ -89,6 +89,8 @@ ...@@ -89,6 +89,8 @@
"eslint": "5.15.3", "eslint": "5.15.3",
"eslint-plugin-prettier": "^3.1.0", "eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-vue": "5.2.2", "eslint-plugin-vue": "5.2.2",
"eslint-config-prettier": "^6.1.0",
"prettier-eslint-cli": "^5.0.0",
"prettier": "^1.18.2", "prettier": "^1.18.2",
"html-webpack-plugin": "3.2.0", "html-webpack-plugin": "3.2.0",
"husky": "1.3.1", "husky": "1.3.1",
......
...@@ -38,7 +38,7 @@ router.beforeEach(async(to, from, next) => { ...@@ -38,7 +38,7 @@ router.beforeEach(async(to, from, next) => {
// generate accessible routes map based on roles // generate accessible routes map based on roles
const accessRoutes = await store.dispatch('permission/generateRoutes', roles) const accessRoutes = await store.dispatch('permission/generateRoutes', roles)
debugger
// dynamically add accessible routes // dynamically add accessible routes
router.addRoutes(accessRoutes) router.addRoutes(accessRoutes)
......
...@@ -3,389 +3,7 @@ import Router from 'vue-router' ...@@ -3,389 +3,7 @@ import Router from 'vue-router'
Vue.use(Router) Vue.use(Router)
/* Layout */ import constantRoutes from './route_map'
import Layout from '@/layout'
/* Router Modules */
import componentsRouter from './modules/components'
import chartsRouter from './modules/charts'
import tableRouter from './modules/table'
import nestedRouter from './modules/nested'
/**
* Note: sub-menu only appear when route children.length >= 1
* Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
*
* hidden: true if set true, item will not show in the sidebar(default is false)
* alwaysShow: true if set true, will always show the root menu
* if not set alwaysShow, when item has more than one children route,
* it will becomes nested mode, otherwise not show the root menu
* redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
* name:'router-name' the name is used by <keep-alive> (must set!!!)
* meta : {
roles: ['admin','editor'] 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)
affix: true if set true, the tag will affix in the tags-view
breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
}
*/
/**
* constantRoutes
* a base page that does not have permission requirements
* all roles can be accessed
*/
export const constantRoutes = [
{
path: '/redirect',
component: Layout,
hidden: true,
children: [
{
path: '/redirect/:path*',
component: () => import('@/views/redirect/index')
}
]
},
{
path: '/login',
component: () => import('@/views/login/index'),
hidden: true
},
{
path: '/auth-redirect',
component: () => import('@/views/login/auth-redirect'),
hidden: true
},
{
path: '/404',
component: () => import('@/views/error-page/404'),
hidden: true
},
{
path: '/401',
component: () => import('@/views/error-page/401'),
hidden: true
},
{
path: '/',
component: Layout,
redirect: '/dashboard',
children: [
{
path: 'dashboard',
component: () => import('@/views/dashboard/index'),
name: 'Dashboard',
meta: { title: 'Dashboard', icon: 'dashboard', affix: true }
}
]
},
{
path: '/documentation',
component: Layout,
children: [
{
path: 'index',
component: () => import('@/views/documentation/index'),
name: 'Documentation',
meta: { title: 'Documentation', icon: 'documentation', affix: true }
}
]
},
{
path: '/guide',
component: Layout,
redirect: '/guide/index',
children: [
{
path: 'index',
component: () => import('@/views/guide/index'),
name: 'Guide',
meta: { title: 'Guide', icon: 'guide', noCache: true }
}
]
},
{
path: '/profile',
component: Layout,
redirect: '/profile/index',
hidden: true,
children: [
{
path: 'index',
component: () => import('@/views/profile/index'),
name: 'Profile',
meta: { title: 'Profile', icon: 'user', noCache: true }
}
]
}
]
/**
* asyncRoutes
* 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', 'editor'] // you can set roles in root nav
},
children: [
{
path: 'page',
component: () => import('@/views/permission/page'),
name: 'PagePermission',
meta: {
title: 'Page Permission',
roles: ['admin'] // or you can only set roles in sub nav
}
},
{
path: 'directive',
component: () => import('@/views/permission/directive'),
name: 'DirectivePermission',
meta: {
title: 'Directive Permission'
// if do not set roles, means: this page does not require permission
}
},
{
path: 'role',
component: () => import('@/views/permission/role'),
name: 'RolePermission',
meta: {
title: 'Role Permission',
roles: ['admin']
}
}
]
},
{
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,
tableRouter,
{
path: '/example',
component: Layout,
redirect: '/example/list',
name: 'Example',
meta: {
title: 'Example',
icon: 'example'
},
children: [
{
path: 'create',
component: () => import('@/views/example/create'),
name: 'CreateArticle',
meta: { title: 'Create Article', icon: 'edit' }
},
{
path: 'edit/:id(\\d+)',
component: () => import('@/views/example/edit'),
name: 'EditArticle',
meta: { title: 'Edit Article', noCache: true, activeMenu: '/example/list' },
hidden: true
},
{
path: 'list',
component: () => import('@/views/example/list'),
name: 'ArticleList',
meta: { title: 'Article List', icon: 'list' }
}
]
},
{
path: '/tab',
component: Layout,
children: [
{
path: 'index',
component: () => import('@/views/tab/index'),
name: 'Tab',
meta: { title: 'Tab', icon: 'tab' }
}
]
},
{
path: '/error',
component: Layout,
redirect: 'noRedirect',
name: 'ErrorPages',
meta: {
title: 'Error Pages',
icon: '404'
},
children: [
{
path: '401',
component: () => import('@/views/error-page/401'),
name: 'Page401',
meta: { title: '401', noCache: true }
},
{
path: '404',
component: () => import('@/views/error-page/404'),
name: 'Page404',
meta: { title: '404', noCache: true }
}
]
},
{
path: '/error-log',
component: Layout,
children: [
{
path: 'log',
component: () => import('@/views/error-log/index'),
name: 'ErrorLog',
meta: { title: 'Error Log', icon: 'bug' }
}
]
},
{
path: '/excel',
component: Layout,
redirect: '/excel/export-excel',
name: 'Excel',
meta: {
title: 'Excel',
icon: 'excel'
},
children: [
{
path: 'export-excel',
component: () => import('@/views/excel/export-excel'),
name: 'ExportExcel',
meta: { title: 'Export Excel' }
},
{
path: 'export-selected-excel',
component: () => import('@/views/excel/select-excel'),
name: 'SelectExcel',
meta: { title: 'Export Selected' }
},
{
path: 'export-merge-header',
component: () => import('@/views/excel/merge-header'),
name: 'MergeHeader',
meta: { title: 'Merge Header' }
},
{
path: 'upload-excel',
component: () => import('@/views/excel/upload-excel'),
name: 'UploadExcel',
meta: { title: 'Upload Excel' }
}
]
},
{
path: '/zip',
component: Layout,
redirect: '/zip/download',
alwaysShow: true,
name: 'Zip',
meta: { title: 'Zip', icon: 'zip' },
children: [
{
path: 'download',
component: () => import('@/views/zip/index'),
name: 'ExportZip',
meta: { title: 'Export Zip' }
}
]
},
{
path: '/pdf',
component: Layout,
redirect: '/pdf/index',
children: [
{
path: 'index',
component: () => import('@/views/pdf/index'),
name: 'PDF',
meta: { title: 'PDF', icon: 'pdf' }
}
]
},
{
path: '/pdf/download',
component: () => import('@/views/pdf/download'),
hidden: true
},
{
path: '/theme',
component: Layout,
children: [
{
path: 'index',
component: () => import('@/views/theme/index'),
name: 'Theme',
meta: { title: 'Theme', icon: 'theme' }
}
]
},
{
path: '/clipboard',
component: Layout,
children: [
{
path: 'index',
component: () => import('@/views/clipboard/index'),
name: 'ClipboardDemo',
meta: { title: 'Clipboard', icon: 'clipboard' }
}
]
},
{
path: 'external-link',
component: Layout,
children: [
{
path: 'https://github.com/PanJiaChen/vue-element-admin',
meta: { title: 'External Link', icon: 'link' }
}
]
},
// 404 page must be placed at the end !!!
{ path: '*', redirect: '/404', hidden: true }
]
const createRouter = () => new Router({ const createRouter = () => new Router({
// mode: 'history', // require service support // mode: 'history', // require service support
......
/*
路由映射表,由路由名映射确定。
需要大改菜单表
*/
/* Layout */
import Layout from '@/layout'
/* Router Modules */
import componentsRouter from './modules/components'
import chartsRouter from './modules/charts'
import tableRouter from './modules/table'
import nestedRouter from './modules/nested'
/**
* Note: sub-menu only appear when route children.length >= 1
* Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
*
* hidden: true if set true, item will not show in the sidebar(default is false)
* alwaysShow: true if set true, will always show the root menu
* if not set alwaysShow, when item has more than one children route,
* it will becomes nested mode, otherwise not show the root menu
* redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
* name:'router-name' the name is used by <keep-alive> (must set!!!)
* meta : {
roles: ['admin','editor'] 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)
affix: true if set true, the tag will affix in the tags-view
breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
}
*/
/**
* constantRoutes
* a base page that does not have permission requirements
* all roles can be accessed
*/
export const constantRoutes = [
{
path: '/redirect',
component: Layout,
hidden: true,
children: [
{
path: '/redirect/:path*',
component: () => import('@/views/redirect/index')
}
]
},
{
path: '/login',
component: () => import('@/views/login/index'),
hidden: true
},
{
path: '/auth-redirect',
component: () => import('@/views/login/auth-redirect'),
hidden: true
},
{
path: '/404',
component: () => import('@/views/error-page/404'),
hidden: true
},
{
path: '/401',
component: () => import('@/views/error-page/401'),
hidden: true
},
{
path: '/',
component: Layout,
redirect: '/dashboard',
children: [
{
path: 'dashboard',
component: () => import('@/views/dashboard/index'),
name: 'Dashboard',
meta: { title: 'Dashboard', icon: 'dashboard', affix: true }
}
]
},
{
path: '/documentation',
component: Layout,
children: [
{
path: 'index',
component: () => import('@/views/documentation/index'),
name: 'Documentation',
meta: { title: 'Documentation', icon: 'documentation', affix: false }
}
]
},
{
path: '/guide',
component: Layout,
redirect: '/guide/index',
children: [
{
path: 'index',
component: () => import('@/views/guide/index'),
name: 'Guide',
meta: { title: 'Guide', icon: 'guide', noCache: true }
}
]
},
{
path: '/profile',
component: Layout,
redirect: '/profile/index',
hidden: true,
children: [
{
path: 'index',
component: () => import('@/views/profile/index'),
name: 'Profile',
meta: { title: 'Profile', icon: 'user', noCache: true }
}
]
}
]
/**
* asyncRoutes
* 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', 'editor'] // you can set roles in root nav
},
children: [
{
path: 'page',
component: () => import('@/views/permission/page'),
name: 'PagePermission',
meta: {
title: 'Page Permission',
roles: ['admin'] // or you can only set roles in sub nav
}
},
{
path: 'directive',
component: () => import('@/views/permission/directive'),
name: 'DirectivePermission',
meta: {
title: 'Directive Permission'
// if do not set roles, means: this page does not require permission
}
},
{
path: 'role',
component: () => import('@/views/permission/role'),
name: 'RolePermission',
meta: {
title: 'Role Permission',
roles: ['admin']
}
}
]
},
{
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,
tableRouter,
{
path: '/example',
component: Layout,
redirect: '/example/list',
name: 'Example',
meta: {
title: 'Example',
icon: 'example'
},
children: [
{
path: 'create',
component: () => import('@/views/example/create'),
name: 'CreateArticle',
meta: { title: 'Create Article', icon: 'edit' }
},
{
path: 'edit/:id(\\d+)',
component: () => import('@/views/example/edit'),
name: 'EditArticle',
meta: { title: 'Edit Article', noCache: true, activeMenu: '/example/list' },
hidden: true
},
{
path: 'list',
component: () => import('@/views/example/list'),
name: 'ArticleList',
meta: { title: 'Article List', icon: 'list' }
}
]
},
{
path: '/tab',
component: Layout,
children: [
{
path: 'index',
component: () => import('@/views/tab/index'),
name: 'Tab',
meta: { title: 'Tab', icon: 'tab' }
}
]
},
{
path: '/error',
component: Layout,
redirect: 'noRedirect',
name: 'ErrorPages',
meta: {
title: 'Error Pages',
icon: '404'
},
children: [
{
path: '401',
component: () => import('@/views/error-page/401'),
name: 'Page401',
meta: { title: '401', noCache: true }
},
{
path: '404',
component: () => import('@/views/error-page/404'),
name: 'Page404',
meta: { title: '404', noCache: true }
}
]
},
{
path: '/error-log',
component: Layout,
children: [
{
path: 'log',
component: () => import('@/views/error-log/index'),
name: 'ErrorLog',
meta: { title: 'Error Log', icon: 'bug' }
}
]
},
{
path: '/excel',
component: Layout,
redirect: '/excel/export-excel',
name: 'Excel',
meta: {
title: 'Excel',
icon: 'excel'
},
children: [
{
path: 'export-excel',
component: () => import('@/views/excel/export-excel'),
name: 'ExportExcel',
meta: { title: 'Export Excel' }
},
{
path: 'export-selected-excel',
component: () => import('@/views/excel/select-excel'),
name: 'SelectExcel',
meta: { title: 'Export Selected' }
},
{
path: 'export-merge-header',
component: () => import('@/views/excel/merge-header'),
name: 'MergeHeader',
meta: { title: 'Merge Header' }
},
{
path: 'upload-excel',
component: () => import('@/views/excel/upload-excel'),
name: 'UploadExcel',
meta: { title: 'Upload Excel' }
}
]
},
{
path: '/zip',
component: Layout,
redirect: '/zip/download',
alwaysShow: true,
name: 'Zip',
meta: { title: 'Zip', icon: 'zip' },
children: [
{
path: 'download',
component: () => import('@/views/zip/index'),
name: 'ExportZip',
meta: { title: 'Export Zip' }
}
]
},
{
path: '/pdf',
component: Layout,
redirect: '/pdf/index',
children: [
{
path: 'index',
component: () => import('@/views/pdf/index'),
name: 'PDF',
meta: { title: 'PDF', icon: 'pdf' }
}
]
},
{
path: '/pdf/download',
component: () => import('@/views/pdf/download'),
hidden: true
},
{
path: '/theme',
component: Layout,
children: [
{
path: 'index',
component: () => import('@/views/theme/index'),
name: 'Theme',
meta: { title: 'Theme', icon: 'theme' }
}
]
},
{
path: '/clipboard',
component: Layout,
children: [
{
path: 'index',
component: () => import('@/views/clipboard/index'),
name: 'ClipboardDemo',
meta: { title: 'Clipboard', icon: 'clipboard' }
}
]
},
{
path: 'external-link',
component: Layout,
children: [
{
path: 'https://github.com/PanJiaChen/vue-element-admin',
meta: { title: 'External Link', icon: 'link' }
}
]
},
// 404 page must be placed at the end !!!
{ path: '*', redirect: '/404', hidden: true }
]
import { asyncRoutes, constantRoutes } from '@/router' import { constantRoutes } from '@/router'
import { getRoutes } from '@/api/role'
/** /**
* Use meta.role to determine if the current user has permission * Use meta.role to determine if the current user has permission
...@@ -48,16 +49,21 @@ const mutations = { ...@@ -48,16 +49,21 @@ const mutations = {
const actions = { const actions = {
generateRoutes({ commit }, roles) { generateRoutes({ commit }, roles) {
return new Promise(resolve => { return new Promise((resolve, reject) => {
let accessedRoutes getRoutes()
if (roles.includes('admin')) { .then(response => {
accessedRoutes = asyncRoutes || [] let accessedRoutes,
} else { asyncRoutes = response.data
accessedRoutes = filterAsyncRoutes(asyncRoutes, roles) accessedRoutes = filterAsyncRoutes(asyncRoutes, roles)
} debugger
commit('SET_ROUTES', accessedRoutes) commit('SET_ROUTES', accessedRoutes)
resolve(accessedRoutes) resolve(accessedRoutes)
}) })
.catch(error => {
reject(error)
})
})
} }
} }
......
...@@ -33,12 +33,14 @@ const actions = { ...@@ -33,12 +33,14 @@ const actions = {
login({ commit }, userInfo) { login({ commit }, userInfo) {
const { username, password } = userInfo const { username, password } = userInfo
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
login({ username: username.trim(), password: password }).then(response => { login({ username: username.trim(), password: password })
.then(response => {
const { data } = response const { data } = response
commit('SET_TOKEN', data.token) commit('SET_TOKEN', data.token)
setToken(data.token) setToken(data.token)
resolve() resolve()
}).catch(error => { })
.catch(error => {
reject(error) reject(error)
}) })
}) })
...@@ -47,7 +49,8 @@ const actions = { ...@@ -47,7 +49,8 @@ const actions = {
// get user info // get user info
getInfo({ commit, state }) { getInfo({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getInfo(state.token).then(response => { getInfo(state.token)
.then(response => {
const { data } = response const { data } = response
if (!data) { if (!data) {
...@@ -66,7 +69,8 @@ const actions = { ...@@ -66,7 +69,8 @@ const actions = {
commit('SET_AVATAR', avatar) commit('SET_AVATAR', avatar)
commit('SET_INTRODUCTION', introduction) commit('SET_INTRODUCTION', introduction)
resolve(data) resolve(data)
}).catch(error => { })
.catch(error => {
reject(error) reject(error)
}) })
}) })
...@@ -75,13 +79,15 @@ const actions = { ...@@ -75,13 +79,15 @@ const actions = {
// user logout // user logout
logout({ commit, state }) { logout({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
logout(state.token).then(() => { logout(state.token)
.then(() => {
commit('SET_TOKEN', '') commit('SET_TOKEN', '')
commit('SET_ROLES', []) commit('SET_ROLES', [])
removeToken() removeToken()
resetRouter() resetRouter()
resolve() resolve()
}).catch(error => { })
.catch(error => {
reject(error) reject(error)
}) })
}) })
...@@ -110,7 +116,9 @@ const actions = { ...@@ -110,7 +116,9 @@ const actions = {
resetRouter() resetRouter()
// generate accessible routes map based on roles // generate accessible routes map based on roles
const accessRoutes = await dispatch('permission/generateRoutes', roles, { root: true }) const accessRoutes = await dispatch('permission/generateRoutes', roles, {
root: true
})
// dynamically add accessible routes // dynamically add accessible routes
router.addRoutes(accessRoutes) router.addRoutes(accessRoutes)
......
...@@ -3,9 +3,6 @@ import { MessageBox, Message } from 'element-ui' ...@@ -3,9 +3,6 @@ import { MessageBox, Message } from 'element-ui'
import store from '@/store' import store from '@/store'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
const axiosUrl =
process.env.NODE_ENV === 'development' ? 'localhost:8080' : 'localhost' // request host
// create an axios instance // create an axios instance
const service = axios.create({ const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
......
<template> <template>
<div class="login-container"> <div class="login-container">
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" autocomplete="on" label-position="left"> <el-form
ref="loginForm"
:model="loginForm"
:rules="loginRules"
class="login-form"
autocomplete="on"
label-position="left"
>
<div class="title-container"> <div class="title-container">
<h3 class="title">用户登录</h3> <h3 class="title">用户登录</h3>
</div> </div>
...@@ -21,7 +27,12 @@ ...@@ -21,7 +27,12 @@
/> />
</el-form-item> </el-form-item>
<el-tooltip v-model="capsTooltip" content="Caps lock is On" placement="right" manual> <el-tooltip
v-model="capsTooltip"
content="Caps lock is On"
placement="right"
manual
>
<el-form-item prop="password"> <el-form-item prop="password">
<span class="svg-container"> <span class="svg-container">
<svg-icon icon-class="password" /> <svg-icon icon-class="password" />
...@@ -40,18 +51,31 @@ ...@@ -40,18 +51,31 @@
@keyup.enter.native="handleLogin" @keyup.enter.native="handleLogin"
/> />
<span class="show-pwd" @click="showPwd"> <span class="show-pwd" @click="showPwd">
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" /> <svg-icon
:icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"
/>
</span> </span>
</el-form-item> </el-form-item>
</el-tooltip> </el-tooltip>
<el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin">Login</el-button> <el-button
:loading="loading"
type="primary"
style="width:100%;margin-bottom:30px;"
@click.native.prevent="handleLogin"
>
Login
</el-button>
<div style="position:relative"> <div style="position:relative">
<div class="tips"> <div class="tips">
<span /> <span />
</div> </div>
<el-button class="thirdparty-button" type="primary" @click="showDialog=true"> <el-button
class="thirdparty-button"
type="primary"
@click="showDialog = true"
>
Or connect with Or connect with
</el-button> </el-button>
</div> </div>
...@@ -59,9 +83,9 @@ ...@@ -59,9 +83,9 @@
<el-dialog title="Or connect with" :visible.sync="showDialog"> <el-dialog title="Or connect with" :visible.sync="showDialog">
本地环境无法模拟,请合并到线上环境再测试!! 本地环境无法模拟,请合并到线上环境再测试!!
<br> <br />
<br> <br />
<br> <br />
<social-sign /> <social-sign />
</el-dialog> </el-dialog>
</div> </div>
...@@ -95,8 +119,12 @@ export default { ...@@ -95,8 +119,12 @@ export default {
password: '111111' password: '111111'
}, },
loginRules: { loginRules: {
username: [{ required: true, trigger: 'blur', validator: validateUsername }], username: [
password: [{ required: true, trigger: 'blur', validator: validatePassword }] { required: true, trigger: 'blur', validator: validateUsername }
],
password: [
{ required: true, trigger: 'blur', validator: validatePassword }
]
}, },
passwordType: 'password', passwordType: 'password',
capsTooltip: false, capsTooltip: false,
...@@ -134,7 +162,10 @@ export default { ...@@ -134,7 +162,10 @@ export default {
methods: { methods: {
checkCapslock({ shiftKey, key } = {}) { checkCapslock({ shiftKey, key } = {}) {
if (key && key.length === 1) { if (key && key.length === 1) {
if (shiftKey && (key >= 'a' && key <= 'z') || !shiftKey && (key >= 'A' && key <= 'Z')) { if (
(shiftKey && (key >= 'a' && key <= 'z')) ||
(!shiftKey && (key >= 'A' && key <= 'Z'))
) {
this.capsTooltip = true this.capsTooltip = true
} else { } else {
this.capsTooltip = false this.capsTooltip = false
...@@ -158,9 +189,13 @@ export default { ...@@ -158,9 +189,13 @@ export default {
this.$refs.loginForm.validate(valid => { this.$refs.loginForm.validate(valid => {
if (valid) { if (valid) {
this.loading = true this.loading = true
this.$store.dispatch('user/login', this.loginForm) this.$store
.dispatch('user/login', this.loginForm)
.then(() => { .then(() => {
this.$router.push({ path: this.redirect || '/', query: this.otherQuery }) this.$router.push({
path: this.redirect || '/',
query: this.otherQuery
})
this.loading = false this.loading = false
}) })
.catch(() => { .catch(() => {
...@@ -206,8 +241,8 @@ export default { ...@@ -206,8 +241,8 @@ export default {
/* 修复input 背景不协调 和光标变色 */ /* 修复input 背景不协调 和光标变色 */
/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */ /* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
$bg:#283443; $bg: #283443;
$light_gray:#fff; $light_gray: #fff;
$cursor: #fff; $cursor: #fff;
@supports (-webkit-mask: none) and (not (cater-color: $cursor)) { @supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
...@@ -250,9 +285,9 @@ $cursor: #fff; ...@@ -250,9 +285,9 @@ $cursor: #fff;
</style> </style>
<style lang="scss" scoped> <style lang="scss" scoped>
$bg:#2d3a4b; $bg: #2d3a4b;
$dark_gray:#889aa4; $dark_gray: #889aa4;
$light_gray:#eee; $light_gray: #eee;
.login-container { .login-container {
min-height: 100%; min-height: 100%;
......
...@@ -31,7 +31,7 @@ module.exports = { ...@@ -31,7 +31,7 @@ module.exports = {
productionSourceMap: false, productionSourceMap: false,
devServer: { devServer: {
port: port, port: port,
open: true, open: false,
overlay: { overlay: {
warnings: false, warnings: false,
errors: true errors: true
...@@ -40,7 +40,7 @@ module.exports = { ...@@ -40,7 +40,7 @@ module.exports = {
// change xxx-api/login => mock/login // change xxx-api/login => mock/login
// detail: https://cli.vuejs.org/config/#devserver-proxy // detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {
target: `http://127.0.0.1:${port}/mock`, target: process.env.VUE_APP_SERVER_HOST,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: '' ['^' + process.env.VUE_APP_BASE_API]: ''
......
...@@ -47,20 +47,6 @@ ...@@ -47,20 +47,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId> <artifactId>spring-boot-starter-quartz</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment