Commit a795fa7b14f6cb93eb6b5c2a8da425ed8ca6625d
1 parent
cf56a6c30f
Exists in
master
auto commit the code by alias command
Showing
13 changed files
with
59 additions
and
24 deletions
Show diff stats
.gitignore
package.json
| 1 | 1 | { |
| 2 | - "name": "vue-admin-template", | |
| 2 | + "name": "yp-plan", | |
| 3 | 3 | "version": "4.2.1", |
| 4 | 4 | "description": "A vue admin template with Element UI & axios & iconfont & permission control & lint", |
| 5 | - "author": "Pan <panfree23@gmail.com>", | |
| 5 | + "author": "XYT==admin@xiuyetang.com", | |
| 6 | 6 | "license": "MIT", |
| 7 | 7 | "scripts": { |
| 8 | 8 | "dev": "vue-cli-service serve", |
| ... | ... | @@ -16,11 +16,13 @@ |
| 16 | 16 | }, |
| 17 | 17 | "dependencies": { |
| 18 | 18 | "axios": "0.18.1", |
| 19 | + "echarts": "^4.7.0", | |
| 19 | 20 | "element-ui": "2.13.0", |
| 20 | 21 | "js-cookie": "2.2.0", |
| 21 | 22 | "normalize.css": "7.0.0", |
| 22 | 23 | "nprogress": "0.2.0", |
| 23 | 24 | "path-to-regexp": "2.4.0", |
| 25 | + "plop": "^2.6.0", | |
| 24 | 26 | "vue": "2.6.10", |
| 25 | 27 | "vue-router": "3.0.6", |
| 26 | 28 | "vuex": "3.1.0" | ... | ... |
src/App.vue
src/api/user.js
| 1 | 1 | import request from '@/utils/request' |
| 2 | 2 | |
| 3 | 3 | export function login(data) { |
| 4 | + console.log('login....', data) | |
| 4 | 5 | return request({ |
| 5 | 6 | url: '/vue-admin-template/user/login', |
| 6 | 7 | method: 'post', |
| ... | ... | @@ -9,6 +10,7 @@ export function login(data) { |
| 9 | 10 | } |
| 10 | 11 | |
| 11 | 12 | export function getInfo(token) { |
| 13 | + console.log('getInfo....', token) | |
| 12 | 14 | return request({ |
| 13 | 15 | url: '/vue-admin-template/user/info', |
| 14 | 16 | method: 'get', |
| ... | ... | @@ -17,6 +19,7 @@ export function getInfo(token) { |
| 17 | 19 | } |
| 18 | 20 | |
| 19 | 21 | export function logout() { |
| 22 | + console.log('logout....') | |
| 20 | 23 | return request({ |
| 21 | 24 | url: '/vue-admin-template/user/logout', |
| 22 | 25 | method: 'post' | ... | ... |
src/layout/components/AppMain.vue
src/layout/components/Navbar.vue
| ... | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 | <breadcrumb class="breadcrumb-container" /> |
| 6 | 6 | |
| 7 | 7 | <div class="right-menu"> |
| 8 | + 语言设置 | |
| 8 | 9 | <el-dropdown class="avatar-container" trigger="click"> |
| 9 | 10 | <div class="avatar-wrapper"> |
| 10 | 11 | <img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar"> |
| ... | ... | @@ -16,14 +17,19 @@ |
| 16 | 17 | Home |
| 17 | 18 | </el-dropdown-item> |
| 18 | 19 | </router-link> |
| 19 | - <a target="_blank" href="https://github.com/PanJiaChen/vue-admin-template/"> | |
| 20 | + <router-link to="/seting"> | |
| 21 | + <el-dropdown-item> | |
| 22 | + 个人设置 | |
| 23 | + </el-dropdown-item> | |
| 24 | + </router-link> | |
| 25 | + <!-- <a target="_blank" href="https://github.com/PanJiaChen/vue-admin-template/"> | |
| 20 | 26 | <el-dropdown-item>Github</el-dropdown-item> |
| 21 | - </a> | |
| 22 | - <a target="_blank" href="https://panjiachen.github.io/vue-element-admin-site/#/"> | |
| 27 | + </a> --> | |
| 28 | + <!-- <a target="_blank" href="https://panjiachen.github.io/vue-element-admin-site/#/"> | |
| 23 | 29 | <el-dropdown-item>Docs</el-dropdown-item> |
| 24 | - </a> | |
| 30 | + </a> --> | |
| 25 | 31 | <el-dropdown-item divided @click.native="logout"> |
| 26 | - <span style="display:block;">Log Out</span> | |
| 32 | + <span style="display:block;">退出系统</span> | |
| 27 | 33 | </el-dropdown-item> |
| 28 | 34 | </el-dropdown-menu> |
| 29 | 35 | </el-dropdown> | ... | ... |
src/layout/components/Sidebar/Logo.vue
src/main.js
| ... | ... | @@ -5,6 +5,7 @@ import 'normalize.css/normalize.css' // A modern alternative to CSS resets |
| 5 | 5 | import ElementUI from 'element-ui' |
| 6 | 6 | import 'element-ui/lib/theme-chalk/index.css' |
| 7 | 7 | import locale from 'element-ui/lib/locale/lang/en' // lang i18n |
| 8 | +// import local_zh from 'element-ui/lib/locale/lang/zh-CN' // 在node_module里面 | |
| 8 | 9 | |
| 9 | 10 | import '@/styles/index.scss' // global css |
| 10 | 11 | |
| ... | ... | @@ -31,7 +32,7 @@ if (process.env.NODE_ENV === 'production') { |
| 31 | 32 | // set ElementUI lang to EN |
| 32 | 33 | Vue.use(ElementUI, { locale }) |
| 33 | 34 | // 如果想要中文版 element-ui,按如下方式声明 |
| 34 | -// Vue.use(ElementUI) | |
| 35 | +// Vue.use(ElementUI, {local_zh}) | |
| 35 | 36 | |
| 36 | 37 | Vue.config.productionTip = false |
| 37 | 38 | ... | ... |
src/router/index.js
| ... | ... | @@ -51,7 +51,7 @@ export const constantRoutes = [ |
| 51 | 51 | path: 'dashboard', |
| 52 | 52 | name: 'Dashboard', |
| 53 | 53 | component: () => import('@/views/dashboard/index'), |
| 54 | - meta: { title: 'Dashboard', icon: 'dashboard' } | |
| 54 | + meta: { title: '标题-------dashboard', icon: 'dashboard' } | |
| 55 | 55 | }] |
| 56 | 56 | }, |
| 57 | 57 | |
| ... | ... | @@ -164,9 +164,11 @@ export const asyncRoutes = [ |
| 164 | 164 | } |
| 165 | 165 | ] |
| 166 | 166 | }, |
| 167 | - | |
| 168 | 167 | // 404 page must be placed at the end !!! |
| 169 | - { path: '*', redirect: '/404', hidden: true } | |
| 168 | + { | |
| 169 | + path: '*', | |
| 170 | + redirect: '/404' | |
| 171 | + } | |
| 170 | 172 | ] |
| 171 | 173 | |
| 172 | 174 | const createRouter = () => new Router({ | ... | ... |
src/settings.js
| 1 | 1 | module.exports = { |
| 2 | 2 | |
| 3 | - title: 'Vue Admin Template', | |
| 3 | + title: '鱼皮出海', | |
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * @type {boolean} true | false |
| 7 | 7 | * @description Whether fix the header |
| 8 | 8 | */ |
| 9 | - fixedHeader: false, | |
| 9 | + fixedHeader: true, | |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @type {boolean} true | false |
| 13 | 13 | * @description Whether show the logo in sidebar |
| 14 | 14 | */ |
| 15 | - sidebarLogo: false | |
| 15 | + sidebarLogo:true | |
| 16 | 16 | } | ... | ... |
src/utils/request.js
| ... | ... | @@ -4,6 +4,7 @@ import store from '@/store' |
| 4 | 4 | import { getToken } from '@/utils/auth' |
| 5 | 5 | |
| 6 | 6 | // create an axios instance |
| 7 | +// 创建axios实例 | |
| 7 | 8 | const service = axios.create({ |
| 8 | 9 | baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url |
| 9 | 10 | // withCredentials: true, // send cookies when cross-domain requests |
| ... | ... | @@ -11,11 +12,13 @@ const service = axios.create({ |
| 11 | 12 | }) |
| 12 | 13 | |
| 13 | 14 | // request interceptor |
| 15 | +// request拦截器 | |
| 14 | 16 | service.interceptors.request.use( |
| 15 | 17 | config => { |
| 16 | 18 | // do something before request is sent |
| 17 | - | |
| 19 | + console.log('do something before request is sent') | |
| 18 | 20 | if (store.getters.token) { |
| 21 | + console.log('[X-Token] is a custom headers key') | |
| 19 | 22 | // let each request carry token |
| 20 | 23 | // ['X-Token'] is a custom headers key |
| 21 | 24 | // please modify it according to the actual situation |
| ... | ... | @@ -24,6 +27,7 @@ service.interceptors.request.use( |
| 24 | 27 | return config |
| 25 | 28 | }, |
| 26 | 29 | error => { |
| 30 | + console.log('do something with request error') | |
| 27 | 31 | // do something with request error |
| 28 | 32 | console.log(error) // for debug |
| 29 | 33 | return Promise.reject(error) |
| ... | ... | @@ -31,6 +35,7 @@ service.interceptors.request.use( |
| 31 | 35 | ) |
| 32 | 36 | |
| 33 | 37 | // response interceptor |
| 38 | +// respone拦截器 | |
| 34 | 39 | service.interceptors.response.use( |
| 35 | 40 | /** |
| 36 | 41 | * If you want to get http information such as headers or status |
| ... | ... | @@ -44,7 +49,11 @@ service.interceptors.response.use( |
| 44 | 49 | */ |
| 45 | 50 | response => { |
| 46 | 51 | const res = response.data |
| 47 | - | |
| 52 | + /** | |
| 53 | + * 下面的注释为通过response自定义code来标示请求状态,当code返回如下情况为权限有问题,登出并返回到登录页 | |
| 54 | + * 如通过xmlhttprequest 状态码标识 逻辑可写在下面error中 | |
| 55 | + */ | |
| 56 | + console.log('if the custom code is not 20000, it is judged as an error.') | |
| 48 | 57 | // if the custom code is not 20000, it is judged as an error. |
| 49 | 58 | if (res.code !== 20000) { |
| 50 | 59 | Message({ |
| ... | ... | @@ -54,15 +63,19 @@ service.interceptors.response.use( |
| 54 | 63 | }) |
| 55 | 64 | |
| 56 | 65 | // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired; |
| 66 | + // 50008:非法的token; 50012:其他客户端登录了; 50014:Token 过期了; | |
| 57 | 67 | if (res.code === 50008 || res.code === 50012 || res.code === 50014) { |
| 58 | 68 | // to re-login |
| 59 | - MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', { | |
| 60 | - confirmButtonText: 'Re-Login', | |
| 61 | - cancelButtonText: 'Cancel', | |
| 69 | + // MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', { | |
| 70 | + MessageBox.confirm('你已被登出,可以取消继续留在该页面,或者重新登录', '确定登出', { | |
| 71 | + // confirmButtonText: 'Re-Login', | |
| 72 | + confirmButtonText: '重新登录', | |
| 73 | + // cancelButtonText: 'Cancel', | |
| 74 | + cancelButtonText: '取消', | |
| 62 | 75 | type: 'warning' |
| 63 | 76 | }).then(() => { |
| 64 | 77 | store.dispatch('user/resetToken').then(() => { |
| 65 | - location.reload() | |
| 78 | + location.reload()// 为了重新实例化vue-router对象 避免bug | |
| 66 | 79 | }) |
| 67 | 80 | }) |
| 68 | 81 | } | ... | ... |
src/views/dashboard/index.vue
| 1 | 1 | <template> |
| 2 | 2 | <div class="dashboard-container"> |
| 3 | - <div class="dashboard-text">name: {{ name }}</div> | |
| 4 | - <div class="dashboard-text">roles: <span v-for="role in roles" :key="role">{{ role }}</span></div> | |
| 3 | + <div class="dashboard-text">用户名: {{ name }}</div> | |
| 4 | + <div class="dashboard-text">角色: <span v-for="role in roles" :key="role">{{ role }}</span></div> | |
| 5 | 5 | </div> |
| 6 | 6 | </template> |
| 7 | 7 | |
| 8 | + | |
| 9 | + | |
| 8 | 10 | <script> |
| 9 | 11 | import { mapGetters } from 'vuex' |
| 12 | +import ElementUI from 'element-ui' | |
| 10 | 13 | |
| 11 | 14 | export default { |
| 12 | 15 | name: 'Dashboard', | ... | ... |
src/views/login/index.vue
| ... | ... | @@ -40,7 +40,7 @@ |
| 40 | 40 | <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" /> |
| 41 | 41 | </span> |
| 42 | 42 | </el-form-item> |
| 43 | - | |
| 43 | + <!-- <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin">reg</el-button> --> | |
| 44 | 44 | <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin">Login</el-button> |
| 45 | 45 | |
| 46 | 46 | <div class="tips"> | ... | ... |