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

修复登录后访问登录相关页面报错

parent d52978ce
......@@ -16,9 +16,13 @@ import queryString from 'query-string';
setup();
let extraRoutes: never[] = [];
// 与用户登录相关路由
const userLoginLists = [
'/login',
]
const whiteLists = [
'/',
'/login',
...userLoginLists,
'/noAuth'
]
/**
......@@ -84,12 +88,16 @@ export function onRouteChange({ routes, matchedRoutes, location, action }) {
return;
}
if (whiteLists.includes(location.pathname)) return;
const routeAuthUrls = getRouters()
// 是否登录
if (getAuth()) {
const { query, pathname } = location
const routeAuthUrls = getRouters()
if (userLoginLists.includes(pathname)) {
// 当登录过, 并且尝试访问登录相关页面, 需重定向到首页
history.replace('/memberCenter/home')
return ;
}
// 固定配置, 出现此参数说明需携带参数校验权限路由
if (query.page_type && routeAuthUrls.find(authPath => {
const parseUrl = queryString.parseUrl(authPath)
......@@ -107,7 +115,13 @@ export function onRouteChange({ routes, matchedRoutes, location, action }) {
// 无权限访问时
history.replace('/noAuth')
} else {
history.replace('/login')
// 未登录
if (whiteLists.includes(location.pathname)) {
// 访问路由在白名单里
} else {
history.replace('/login')
}
}
}
......
......@@ -15,12 +15,13 @@ const ModalTable:React.FC<ModalTableProps> = (props) => {
const { width = 704,modalTitle, confirm, cancel, visible, currentRef, ...resetTable } = props
const selfRef = currentRef || useRef<any>({})
useEffect(() => {
if (!visible) {
if (visible) {
// 重新开启时需reload接口
selfRef.current.reload && selfRef.current.reload()
} else {
selfRef.current.resetField && selfRef.current.resetField({
validate: false
})
// 重新开启时需reload接口
selfRef.current.reload && selfRef.current.reload()
}
}, [visible, selfRef.current])
return (
......
......@@ -67,7 +67,7 @@ export const createTreeActions = () => {
setSelectKeys(){},
setExpandedKeys(){},
getParentPath(id){return ''},
getParent(id){return null}
getParent(id){console.log('not init');return null}
}
return actions
}
......@@ -205,6 +205,7 @@ const TabTree:React.FC<TabTreeProps> = (props) => {
}
selfActions.getParent = (id) => {
console.log(id)
const reductData = treeReduction(treeData)
const targetInfo = reductData[id]
const parentInfo = reductData[targetInfo.parentId]
......
......@@ -114,6 +114,7 @@ export const useTreeTabs = (options: useTreeTabOptions = {}) => {
const toolsRender = {
addNode(node) {
const activeParentId = treeActions && treeActions.getParent(node.key || node.id)?.id
console.log(activeParentId)
setNodeRecord({
...node,
parentId: activeParentId, // 添加同级的时候 使用上一级的id作为parentId
......
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