Commit a1426b66 by 无尘

fix: 修改接口 header 参数

parent 4ccab745
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* @Author: 无尘 * @Author: 无尘
* @Date: 2020-07-31 11:41:34 * @Date: 2020-07-31 11:41:34
* @LastEditors: 无尘 * @LastEditors: 无尘
* @LastEditTime: 2020-09-21 11:40:56 * @LastEditTime: 2020-09-21 11:45:37
*/ */
import { request } from './request.js'; import { request } from './request.js';
import axios from 'axios'; import axios from 'axios';
...@@ -69,12 +69,18 @@ function intercept(to, from, next) { ...@@ -69,12 +69,18 @@ function intercept(to, from, next) {
}); });
// 有权限访问 // 有权限访问
if (hasPerm) { if (hasPerm) {
Object.assign(axios.defaults.headers.common, {
route: to.path.replace(/^\//, '')
});
return next(); return next();
}; };
// 无权限访问 // 无权限访问
if (projectRoutes.some(el => el == to.path) || accessPath.length == 0) { if (projectRoutes.some(el => el == to.path) || accessPath.length == 0) {
next('/gic-error'); next('/gic-error');
} else { } else {
Object.assign(axios.defaults.headers.common, {
route: accessPath[0].replace(/^\//, '')
});
next(accessPath[0]); next(accessPath[0]);
} }
} }
...@@ -87,7 +93,7 @@ function itemPerm(itemPermCode) { ...@@ -87,7 +93,7 @@ function itemPerm(itemPermCode) {
let permission = function(config) { let permission = function(config) {
const { projectPath, whiteRoute, router, routes, createApp } = config; const { projectPath, whiteRoute, router, routes, createApp } = config;
window.addEventListener('load', async function() { window.onload = async function() {
// 获取菜单数据 // 获取菜单数据
// 获取权限数据 // 获取权限数据
const path = window.location.href; const path = window.location.href;
...@@ -109,7 +115,7 @@ let permission = function(config) { ...@@ -109,7 +115,7 @@ let permission = function(config) {
router.beforeEach(intercept); router.beforeEach(intercept);
// 创建vue实例,渲染页面 // 创建vue实例,渲染页面
if (typeof createApp == 'function') createApp(); if (typeof createApp == 'function') createApp();
}); };
}; };
export { permission, itemPerm }; export { permission, itemPerm };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment