Commit 981c80a1 authored by 前端-许佳敏's avatar 前端-许佳敏

权限修改

parent 7a9690b5
......@@ -9,7 +9,7 @@ import '@/global/styles/global.less'; // 导入全局样式
import 'antd/dist/antd.less'
import { isDev } from '@/constants'
import { setup } from '@formily/antd-components';
import { getRouters, getAuth, asyncRouter, setAuth, setRouters } from './utils/auth';
import { getRouters, getAuth, asyncRouter, setAuth, setRouters, removeAuth, removeRouters } from './utils/auth';
import { PublicApi } from './services/api';
setup()
......@@ -66,13 +66,20 @@ export function render(oldRender: Function) {
const authInfo = getAuth()
if (authInfo) {
PublicApi.getMemberLoginReget().then(res => {
const { data } = res
const { data, code } = res
if (code === 1000) {
setAuth({
memberId: data.memberId,
userId: data.userId,
token: data.token
})
setRouters(data.urls)
} else {
removeAuth()
removeRouters()
history.push('/user/login')
}
oldRender()
})
} else {
......@@ -89,22 +96,33 @@ export function render(oldRender: Function) {
*/
export function onRouteChange({ routes, matchedRoutes, location, action }) {
console.log('onRouteChange')
console.log(window.location.search)
if (isDev) {
return;
}
if (whiteLists.includes(location.pathname)) return;
const routeAuthUrls = getRouters()
// 是否登录
if (getAuth()) {
console.log(location)
console.log(matchedRoutes)
if (routeAuthUrls.includes(location.pathname)) {
const { query, pathname } = location
} else {
// return ;
// // 固定配置, 出现此参数说明需携带参数校验权限路由
// if (query.page_type && routeAuthUrls.find(authPath => {
// })) {
// return ;
// }
// console.log(query)
// 是否在路由权限列表里
if (routeAuthUrls.includes(pathname)) {
return ;
}
// 无权限访问时
history.replace('/memberCenter/noAuth')
}
} else {
history.replace('/user/login')
}
......
......@@ -330,6 +330,11 @@ export const getFieldType = (field) => {
}
}
export const getQueryStringParams = (url?: string) => {
const nowUrl = url || window.location.href
const splitUrl = nowUrl.split('?')
const searchParam = [1]
}
export default {
isArray,
isObject,
......
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