diff --git a/src/layout/components/AppMain.vue b/src/layout/components/AppMain.vue
index 4d4f6ee982bcd3b81b7e32acfdf9349d2fef9917..99d079079c37be7b08cc688ec35955323da31eae 100644
--- a/src/layout/components/AppMain.vue
+++ b/src/layout/components/AppMain.vue
@@ -19,14 +19,18 @@ export default {
diff --git a/src/layout/components/TagsView.vue b/src/layout/components/TagsView.vue
index d7d6f52ae559f51ebcc6d0b12588b18484b47dc8..8dbd8bbe26abcae5c79f1964e8c7dd9d6127c816 100644
--- a/src/layout/components/TagsView.vue
+++ b/src/layout/components/TagsView.vue
@@ -9,16 +9,21 @@
关闭其他
-
-
+
@@ -103,14 +108,38 @@ export default {
&-container {
position: relative;
height: 40px;
+ line-height: 40px;
+ overflow: hidden;
}
&-main {
- margin: 0 16px;
+ margin: 0 15px;
overflow: hidden;
user-select: none;
- ::v-deep .el-tabs__item.is-focus {
- outline: 0 none !important;
+ ::v-deep {
+ .el-tabs__header,
+ .el-tabs__nav {
+ margin-bottom: 0;
+ border: 0 none;
+ }
+
+ .el-tabs__item {
+ height: 30px;
+ line-height: 30px;
+ margin-left: 8px;
+ border: 1px solid #E4E7ED;
+ border-radius: 4px;
+ font-size: 12px;
+
+ &:first-child {
+ margin-left: 0;
+ border-left: 1px solid #E4E7ED;
+ }
+
+ &.is-active {
+ border-bottom-color: #E4E7ED;
+ }
+ }
}
}
diff --git a/src/router/index.js b/src/router/index.js
index 7829ca88ae93e5289454253ef8ec52278906ca81..13b3912733e5b471d7b63aae161bc5cb32cb55b5 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -55,6 +55,30 @@ export const constantRoutes = [
}]
},
+ {
+ path: '/name',
+ component: Layout,
+ redirect: '/dashboard',
+ children: [{
+ path: 'dashboard',
+ name: 'Dashboard',
+ component: () => import('@/views/dashboard/index'),
+ meta: { title: '仪表盘', icon: 'dashboard' }
+ }]
+ },
+
+ {
+ path: '/age',
+ component: Layout,
+ redirect: '/dashboard',
+ children: [{
+ path: 'dashboard',
+ name: 'Dashboard',
+ component: () => import('@/views/dashboard/index'),
+ meta: { title: '仪表盘', icon: 'dashboard' }
+ }]
+ },
+
// {
// path: '/example',
// component: Layout,
diff --git a/src/utils/logError.js b/src/utils/logError.js
new file mode 100644
index 0000000000000000000000000000000000000000..b191e3900efa011eeee5755e0d9fe09df2917be5
--- /dev/null
+++ b/src/utils/logError.js
@@ -0,0 +1,24 @@
+import { format } from 'core-js/fn/date'
+import { parseTime } from './index'
+import { Message } from 'element-ui'
+
+/**
+ * 统一输出错误信息
+ * @param {String} name 错误的类型
+ * @param {String} action 错误的动作描述
+ * @param {String} msg 错误描述
+ */
+export function logError(name, action, msg, notify = true) {
+ if (!name || !action) {
+ return console.error('必须传入 name 或 action 参数')
+ }
+
+ if (!msg) {
+ msg = '暂无提示信息,具体查看控制台'
+ }
+
+ const date = parseTime(Date.now())
+
+ console.error(date, name, action, msg)
+ notify && Message.error(msg)
+}
diff --git a/src/utils/request.js b/src/utils/request.js
index 884bb8710b15cf19ca393d7bf79769e7128f4145..6cc2c5209f6b8b455f8229c2e2290453bebfc54e 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -1,7 +1,8 @@
import axios from 'axios'
-import { MessageBox, Message } from 'element-ui'
+import { MessageBox } from 'element-ui'
import store from '@/store'
import { getToken } from '@/utils/auth'
+import { logError } from './logError'
// create an axios instance
const service = axios.create({
@@ -12,49 +13,30 @@ const service = axios.create({
// request interceptor
service.interceptors.request.use(
config => {
- // do something before request is sent
-
if (store.getters.token) {
- // let each request carry token
- // ['X-Token'] is a custom headers key
- // please modify it according to the actual situation
config.headers['X-Token'] = getToken()
}
return config
},
error => {
- // do something with request error
- console.log(error) // for debug
+ logError('api', '请求错误', error, false) // for debug
return Promise.reject(error)
}
)
// response interceptor
service.interceptors.response.use(
- /**
- * If you want to get http information such as headers or status
- * Please return response => response
- */
-
- /**
- * Determine the request status by custom code
- * Here is just an example
- * You can also judge the status by HTTP Status Code
- */
response => {
const res = response.data
- // if the custom code is not 20000, it is judged as an error.
+ // 如果自定义 code 不为 0,则认为此次请求有问题
if (res.code !== 0) {
- Message({
- message: res.message || 'Error',
- type: 'error',
- duration: 5 * 1000
- })
+ const { url } = response.config
+ logError('api', url, res.message)
// 401: Illegal token;
if (res.code === 401) {
- // to re-login
+ // 重新登陆
MessageBox.confirm('您的登陆状态已过期,是否要重新登陆', '退出确认', {
confirmButtonText: '重新登陆',
cancelButtonText: '取消',
@@ -71,12 +53,7 @@ service.interceptors.response.use(
}
},
error => {
- console.log('err' + error) // for debug
- Message({
- message: error.message,
- type: 'error',
- duration: 5 * 1000
- })
+ logError('api', '响应错误', error.message, false) // for debug
return Promise.reject(error)
}
)
diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue
index 5779ac6efa7af7434ea6f1d1fcd3d49f44d905c7..574a9652b5a83d77129b198f0421d01a7523ba27 100644
--- a/src/views/dashboard/index.vue
+++ b/src/views/dashboard/index.vue
@@ -19,9 +19,6 @@ export default {