From 3fe2a376dd2240a6578013238fa0285a4c09f95d Mon Sep 17 00:00:00 2001 From: Pan Date: Mon, 24 Apr 2017 17:34:04 +0800 Subject: [PATCH] refine --- README.md | 6 +++++ src/mock/login.js | 33 ++++++++++++++++----------- src/store/modules/user.js | 1 + src/utils/fetch.js | 2 +- src/views/dashboard/default/index.vue | 3 +-- src/views/dashboard/editor/index.vue | 8 +++---- src/views/dashboard/index.vue | 9 ++++---- src/views/login/index.vue | 10 ++++++-- 8 files changed, 46 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 54a79555..ebb5067a 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ vue+element+axios 的管理后台 [线上地址](http://panjiachen.github.io/vue ###功能 - [x] 登录/注销 - [x] 权限验证 +- [x] 侧边栏 +- [x] 面包屑 - [x] 富文本编辑器 - [x] Markdown编辑器 - [x] JSON编辑器 @@ -20,6 +22,10 @@ vue+element+axios 的管理后台 [线上地址](http://panjiachen.github.io/vue - [x] table example - [x] form example - [x] 多环境发布 +- [x] dashboard +- [x] 二次登录 +- [x] 动态侧边栏 + ###How to use? ```bash diff --git a/src/mock/login.js b/src/mock/login.js index e852929a..801ab6b1 100644 --- a/src/mock/login.js +++ b/src/mock/login.js @@ -26,23 +26,30 @@ const userMap = { export default { loginByEmail: config => { const { email } = config.params; - return new Promise(resolve => { - setTimeout(() => { - resolve([200, { - data: userMap[email.split('@')[0]] - }]); - }, 500); + return new Promise((resolve, reject) => { + if (userMap[email.split('@')[0]]) { + setTimeout(() => { + resolve([200, { + data: userMap[email.split('@')[0]] + }]); + }, 500); + } else { + reject('账号不正确') + } }) }, getInfo: config => { const { token } = config.params; - console.log(userMap[token]) - return new Promise(resolve => { - setTimeout(() => { - resolve([200, { - data: userMap[token] - }]); - }, 100); + return new Promise((resolve, reject) => { + if (userMap[token]) { + setTimeout(() => { + resolve([200, { + data: userMap[token] + }]); + }, 100); + } else { + reject('获取失败') + } }) }, logout: () => new Promise(resolve => { diff --git a/src/store/modules/user.js b/src/store/modules/user.js index b6130f19..5e1228c1 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -114,6 +114,7 @@ const user = { return new Promise((resolve, reject) => { logout(state.token).then(() => { commit('SET_TOKEN', ''); + commit('SET_ROLES', []); Cookies.remove('X-Ivanka-Token'); resolve(); }).catch(error => { diff --git a/src/utils/fetch.js b/src/utils/fetch.js index 9110f774..71cfc2d2 100644 --- a/src/utils/fetch.js +++ b/src/utils/fetch.js @@ -61,7 +61,7 @@ export function fetch(options) { }) .catch(error => { Message({ - message: '发生异常错误,请刷新页面重试,或联系程序员', + message: error, type: 'error', duration: 5 * 1000 }); diff --git a/src/views/dashboard/default/index.vue b/src/views/dashboard/default/index.vue index 97b05fa6..c0625b51 100644 --- a/src/views/dashboard/default/index.vue +++ b/src/views/dashboard/default/index.vue @@ -6,13 +6,12 @@
{{name}} - 赶紧把你们想要的快捷键报给产品锦鲤! + 普通编辑dashboard
- diff --git a/src/views/dashboard/editor/index.vue b/src/views/dashboard/editor/index.vue index d3ca0f42..53aaed38 100644 --- a/src/views/dashboard/editor/index.vue +++ b/src/views/dashboard/editor/index.vue @@ -27,12 +27,12 @@
- 组价 + 组件 图表 错误页面 - 错误日志 - 导出excel - 实时列表 + 导出excel + table + form
diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 7397932a..2e4ce06f 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -29,10 +29,11 @@ if (this.roles.indexOf('admin') >= 0) { return; } - const isEditor = this.roles.some(v => v.indexOf('editor') >= 0) - if (!isEditor) { - this.currentRole = 'DefaultDashboard'; - } + // const isEditor = this.roles.some(v => v.indexOf('editor') >= 0) + // if (!isEditor) { + // this.currentRole = 'DefaultDashboard'; + // } + this.currentRole = 'DefaultDashboard'; } } diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 6c38b3da..b0bd79fb 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -19,6 +19,8 @@ 登录 +
admin账号为:admin@wallstreetcn 密码随便填
+
editor账号:editor@wallstreetcn 密码随便填
忘记密码?(或首次登录) @@ -56,7 +58,7 @@ }; return { loginForm: { - email: '', + email: 'admin@wallstreetcn.com', password: '' }, loginRules: { @@ -125,7 +127,11 @@