From 0da4e5e5a7a252521f77f1f97d6e453c7d343810 Mon Sep 17 00:00:00 2001 From: Pan Date: Tue, 16 May 2017 10:44:18 +0800 Subject: [PATCH] add tips --- src/main.js | 34 +++++++++++++++------------------- src/utils/fetch.js | 39 +++++++++++++++++++-------------------- 2 files changed, 34 insertions(+), 39 deletions(-) diff --git a/src/main.js b/src/main.js index 52468c9b..dc770eb5 100644 --- a/src/main.js +++ b/src/main.js @@ -6,31 +6,27 @@ import router from './router'; import store from './store'; import ElementUI from 'element-ui'; import 'element-ui/lib/theme-default/index.css'; -import 'assets/custom-theme/index.css'; // https://github.com/PanJiaChen/custom-element-theme -import NProgress from 'nprogress'; -import 'nprogress/nprogress.css'; -import 'normalize.css/normalize.css'; -import 'styles/index.scss'; -import 'components/Icon-svg/index'; -import 'assets/iconfont/iconfont'; -import * as filters from './filters'; -import Multiselect from 'vue-multiselect'; -import Sticky from 'components/Sticky'; -import 'vue-multiselect/dist/vue-multiselect.min.css'; -import vueWaves from './directive/waves'; -import vueSticky from './directive/sticky'; -import errLog from 'store/errLog'; -import './mock/index.js'; // 使用api请求时请将此行注释,不然将被mock拦截!! -// import './styles/mixin.scss'; -import permission from 'store/permission'; +import 'assets/custom-theme/index.css'; // 换肤版本element-ui css https://github.com/PanJiaChen/custom-element-theme +import NProgress from 'nprogress'; // Progress 进度条 +import 'nprogress/nprogress.css';// Progress 进度条 样式 +import 'normalize.css/normalize.css';// normalize.css 样式格式化 +import 'styles/index.scss'; // 全局自定义的css样式 +import 'components/Icon-svg/index'; // 封装的svg组件 +import 'assets/iconfont/iconfont'; // iconfont 具体图标见https://github.com/PanJiaChen/vue-element-admin/wiki +import * as filters from './filters'; // 全局vue filter +import Multiselect from 'vue-multiselect';// 使用的一个多选框组件,element-ui的select不能满足所有需求 +import 'vue-multiselect/dist/vue-multiselect.min.css';// 多选框组件css +import Sticky from 'components/Sticky'; // 粘性header组件 +import vueWaves from './directive/waves';// 水波纹指令 +import errLog from 'store/errLog';// error log组件 +import './mock/index.js'; // 该项目所有请求使用mockjs模拟 +import permission from 'store/permission'; // 权限控制 // register globally Vue.component('multiselect', Multiselect); Vue.component('Sticky', Sticky); Vue.use(ElementUI); Vue.use(vueWaves); -Vue.use(vueSticky); - // register global utility filters. Object.keys(filters).forEach(key => { diff --git a/src/utils/fetch.js b/src/utils/fetch.js index 1b917a1a..ab220140 100644 --- a/src/utils/fetch.js +++ b/src/utils/fetch.js @@ -26,27 +26,26 @@ service.interceptors.request.use(config => { // respone拦截器 service.interceptors.response.use( response => response + /** + * 下面的注释为通过response自定义code来标示请求状态,当code返回如下情况为权限有问题,登出并返回到登录页 + * 如通过htmlrequest 状态码标示 逻辑可写在下面error中 + */ - /** - /** - * 下面的注释为通过response自定义code来标示请求状态,当code返回如下情况为权限有问题,登出并返回到登录页 - * 如通过htmlrequest 状态码标示 逻辑可写在下面error中 - */ - // const code = response.data.code; - // // 50014:Token 过期了 50012:其他客户端登录了 50008:非法的token - // if (code === 50008 || code === 50014 || code === 50012) { - // Message({ - // message: res.message, - // type: 'error', - // duration: 5 * 1000 - // }); - // // 登出 - // store.dispatch('FedLogOut').then(() => { - // router.push({ path: '/login' }) - // }); - // } else { - // return response - // } + // const code = response.data.code; + // // 50014:Token 过期了 50012:其他客户端登录了 50008:非法的token + // if (code === 50008 || code === 50014 || code === 50012) { + // Message({ + // message: res.message, + // type: 'error', + // duration: 5 * 1000 + // }); + // // 登出 + // store.dispatch('FedLogOut').then(() => { + // router.push({ path: '/login' }) + // }); + // } else { + // return response + // } , error => { console.log('err' + error);// for debug