diff --git a/src/main.js b/src/main.js index c65a2e84..9d6011c9 100644 --- a/src/main.js +++ b/src/main.js @@ -22,7 +22,6 @@ import '@/plugin/axios' import '@/mock/register' import pluginImport from '@/plugin/import' import pluginExport from '@/plugin/export' -import pluginLog from '@/plugin/log' import pluginOpen from '@/plugin/open' import router from './router' @@ -31,7 +30,6 @@ Vue.use(VCharts) Vue.use(contentmenu) Vue.use(pluginImport) Vue.use(pluginExport) -Vue.use(pluginLog) Vue.use(pluginOpen) Vue.use(vueJsonTreeView) diff --git a/src/plugin/axios/index.js b/src/plugin/axios/index.js index 2c9b5740..610ec6f5 100644 --- a/src/plugin/axios/index.js +++ b/src/plugin/axios/index.js @@ -1,6 +1,18 @@ import Vue from 'vue' import axios from 'axios' -// TODO: 做一些封装 +axios.interceptors.response.use(res => { + if (res.data.code !== undefined) { + if (res.data.code !== 0) { + return Promise.reject(res.data.msg) + } else { + return res.data.data + } + } else { + return res.data + } +}, err => { + return Promise.reject(err) +}) Vue.prototype.$axios = axios diff --git a/src/plugin/log/index.js b/src/plugin/log/index.js deleted file mode 100644 index 327a1322..00000000 --- a/src/plugin/log/index.js +++ /dev/null @@ -1,18 +0,0 @@ -export default { - install (Vue, options) { - // 打印log - // 如果只有一个参数 就只简单打印第一个参数 - // 如果有大于一个参数 第一个参数会当做是分组的名称 - Vue.prototype.$log = (arg1 = 'log', ...logs) => { - if (logs.length === 0) { - console.log(arg1) - } else { - console.group(arg1) - logs.forEach(e => { - console.log(e) - }) - console.groupEnd() - } - } - } -} diff --git a/src/router/index.js b/src/router/index.js index e643aa5f..39cf7d8b 100755 --- a/src/router/index.js +++ b/src/router/index.js @@ -20,7 +20,8 @@ router.beforeEach((to, from, next) => { if (to.matched.some(r => r.meta.requiresAuth)) { // 这里暂时将cookie里是否存有token作为验证是否登陆的条件 // 请根据自身业务需要修改 - if (Cookies.get('token')) { + const token = Cookies.get('token') + if (token && token !== 'undefined') { next() } else { // 没有登陆的时候跳转到登陆界面 diff --git a/src/assets/image/logo/w500.png.REMOVED.git-id b/src/views/core/login/image/logo.png.REMOVED.git-id similarity index 100% rename from src/assets/image/logo/w500.png.REMOVED.git-id rename to src/views/core/login/image/logo.png.REMOVED.git-id diff --git a/src/views/core/login/index.vue b/src/views/core/login/index.vue index 409b6319..ac3dc81f 100644 --- a/src/views/core/login/index.vue +++ b/src/views/core/login/index.vue @@ -4,7 +4,7 @@
+