Unverified Commit 2ae3943f authored by yqwoe's avatar yqwoe Committed by GitHub

fix: Fix some front-end issues (#3038)

parent d3877d95
...@@ -42,7 +42,13 @@ export default [ ...@@ -42,7 +42,13 @@ export default [
}, },
{ {
path: '/', path: '/',
redirect: '/datastudio' redirect: '/redirect',
},
{
path: '/redirect',
component: './Other/Redirect',
layout: false,
hideInMenu: true,
}, },
// { // {
// path: '/home', // path: '/home',
......
...@@ -37,6 +37,7 @@ import { FullScreenProvider } from './hooks/useEditor'; ...@@ -37,6 +37,7 @@ import { FullScreenProvider } from './hooks/useEditor';
import { errorConfig } from './requestErrorConfig'; import { errorConfig } from './requestErrorConfig';
import { getDataByParamsReturnResult } from './services/BusinessCrud'; import { getDataByParamsReturnResult } from './services/BusinessCrud';
import { API } from './services/data'; import { API } from './services/data';
import Redirect from './pages/Other/Redirect';
// const isDev = process.env.NODE_ENV === "development"; // const isDev = process.env.NODE_ENV === "development";
const loginPath = API_CONSTANTS.LOGIN_PATH; const loginPath = API_CONSTANTS.LOGIN_PATH;
...@@ -208,7 +209,7 @@ export const dva = { ...@@ -208,7 +209,7 @@ export const dva = {
* 动态修改默认跳转路由 * 动态修改默认跳转路由
*/ */
const patch = (oldRoutes: any, routes: SysMenu[]) => { const patch = (oldRoutes: any, routes: SysMenu[]) => {
oldRoutes[1].routes = oldRoutes[1].routes.map( oldRoutes[1].routes = oldRoutes[1]?.routes?.map(
(route: { routes: { path: any; element: JSX.Element }[]; path: string }) => { (route: { routes: { path: any; element: JSX.Element }[]; path: string }) => {
if (route.routes?.length) { if (route.routes?.length) {
const redirect = routes?.filter((r) => r.path.startsWith(route.path)); const redirect = routes?.filter((r) => r.path.startsWith(route.path));
...@@ -230,7 +231,9 @@ const patch = (oldRoutes: any, routes: SysMenu[]) => { ...@@ -230,7 +231,9 @@ const patch = (oldRoutes: any, routes: SysMenu[]) => {
*/ */
export function patchClientRoutes({ routes }: { routes: SysMenu[] }) { export function patchClientRoutes({ routes }: { routes: SysMenu[] }) {
// 根据 extraRoutes 对 routes 做一些修改 // 根据 extraRoutes 对 routes 做一些修改
if(extraRoutes.length){
patch(routes, extraRoutes); patch(routes, extraRoutes);
}
} }
/*** /***
......
...@@ -116,6 +116,35 @@ const AssignMenu: React.FC<AssignMenuProps> = (props) => { ...@@ -116,6 +116,35 @@ const AssignMenu: React.FC<AssignMenuProps> = (props) => {
setRoleAssignMenu((prevState) => ({ ...prevState, selectValue: selectKeys })); setRoleAssignMenu((prevState) => ({ ...prevState, selectValue: selectKeys }));
}; };
const treeData = buildMenuTree(
sortTreeData(roleAssignMenu.menuTreeData.menus),
roleAssignMenu.searchValue
);
const treeToArray = (list, newArr = []) => {
list.forEach((item) => {
const { children } = item;
if (children) {
if (children.length) {
newArr.push(item);
return treeToArray(children, newArr);
}
}
newArr.push(item);
});
return newArr;
};
const filterHalfKeys: any = useCallback(
(keys) => {
const treeArray = treeToArray(treeData);
return keys.filter((key) =>
treeArray.some((tree) => tree.value == key && !tree.isLeaf)
);
},
[treeData]
);
return ( return (
<Drawer <Drawer
title={l('role.assignMenu', '', { roleName: values.roleName })} title={l('role.assignMenu', '', { roleName: values.roleName })}
...@@ -137,16 +166,15 @@ const AssignMenu: React.FC<AssignMenuProps> = (props) => { ...@@ -137,16 +166,15 @@ const AssignMenu: React.FC<AssignMenuProps> = (props) => {
<Spin spinning={roleAssignMenu.loading}> <Spin spinning={roleAssignMenu.loading}>
<DirectoryTree <DirectoryTree
selectable selectable
defaultCheckedKeys={[...roleAssignMenu.menuTreeData.selectedMenuIds]} defaultCheckedKeys={filterHalfKeys(roleAssignMenu.menuTreeData.selectedMenuIds)}
checkable checkable
defaultExpandAll defaultExpandAll
onCheck={(keys) => onCheck(keys)} onCheck={(keys, e) => {
onCheck(keys?.concat(e.halfCheckedKeys));
}}
multiple={true} multiple={true}
className={'treeList'} className={'treeList'}
treeData={buildMenuTree( treeData={treeData}
sortTreeData(roleAssignMenu.menuTreeData.menus),
roleAssignMenu.searchValue
)}
/> />
</Spin> </Spin>
</> </>
......
...@@ -159,7 +159,7 @@ const JobTree: React.FC<TreeProps & connect> = (props) => { ...@@ -159,7 +159,7 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
selectedKeys={selectKey} selectedKeys={selectKey}
onExpand={onExpand} onExpand={onExpand}
treeData={data} treeData={data}
autoExpandParent={autoExpandParent} // autoExpandParent={autoExpandParent}
/> />
) : ( ) : (
<Empty <Empty
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { SysMenu } from '@/types/AuthCenter/data';
import { Navigate, useModel } from 'umi';
const Redirect = () => {
const { initialState, _ } = useModel('@@initialState');
console.log(initialState);
const filterMenus = (menus: SysMenu[]) => {
return menus?.filter((menu) => menu.type !== 'F');
};
let extraRoutes = filterMenus(initialState?.currentUser?.menuList);
if (initialState?.currentUser?.user?.superAdminFlag) {
return <Navigate to='/datastudio' />;
}
return <Navigate to={extraRoutes[0]?.path} />;
};
export default Redirect;
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