feat: 补充提交

develop
donghao 11 months ago
parent d6950afaea
commit 8c79571e1b

@ -1,8 +1,11 @@
<!--
* @Author: donghao donghao@supervision.ltd
* @Date: 2023-11-01 13:56:33
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-03-29 17:59:03
* @FilePath: \general-ai-platform-web\.eslintrc.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
module.exports = {
extends: [require.resolve('@umijs/lint/dist/config/eslint')],
globals: {
page: true,
REACT_APP_ENV: true,
SERVER_HOST: true,
},
};

@ -44,12 +44,9 @@ export default [
},
],
},
{
path: '/system',
name: 'system',
routes: [
{
name: 'api-list',

@ -8,4 +8,4 @@
"@/*": ["./src/*"]
}
}
}
}

@ -46,6 +46,8 @@ export async function getInitialState(): Promise<{
if (location.pathname !== loginPath && localStorage.getItem('access')) {
const currentUser = await fetchUserInfo();
const menus = await postMenuGetMenu();
console.log('app_menus', menus.data.routes);
if (getLocale() === 'zh-CN') {
let localData = getAllRouteNameTile(menus.data.routes, '');
let localRes: any = {};
@ -88,7 +90,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
src: SERVER_HOST + initialState?.currentUser?.avatarUrl,
title: <AvatarName />,
render: (_, avatarChildren) => {
console.log(avatarChildren,'111111111')
console.log(avatarChildren,'avatarProps')
return <AvatarDropdown menu={true}>{avatarChildren}</AvatarDropdown>;
},
},
@ -118,14 +120,18 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
userId: initialState?.currentUser?.id,
},
request: async () => {
// console.log(initialState?.menuData,'initialState_menuData')
console.log(initialState?.menuData,'initialState_menuData')
return initialState?.menuData || [];
},
},
// headerRender: () => <>导航栏</>,
// menuRender: () => <></>,
footerRender: () => <Footer />,
onPageChange: () => {
const { location } = history;
// 如果没有登录,重定向到 login
console.log(location.pathname,'location_pathname')
if (!initialState?.currentUser && location.pathname !== loginPath) {
history.push(loginPath);
}

@ -1,8 +1,8 @@
/*
* @Author: zhoux zhouxia@supervision.ltd
* @Date: 2023-11-14 15:49:36
* @LastEditors: zhoux zhouxia@supervision.ltd
* @LastEditTime: 2023-12-11 10:30:54
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-04-10 11:21:37
* @FilePath: \general-ai-platform-web\src\components\TableActionCard\index.tsx
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
@ -12,7 +12,7 @@ import { Dropdown } from 'antd';
import React from 'react';
//TODO 表单的操作按钮集合 key的报错未解决
type actionsProps = {
export type actionsProps = {
key: string;
renderDom: any;
}

@ -1,21 +1,18 @@
import { history } from '@umijs/max';
import { Dropdown, Tabs } from 'antd';
import { useCallback, useMemo } from 'react';
import { history } from '@umijs/max';
import { KeepAliveTab, useKeepAliveTabs } from './useKeepAliveTabs';
import type { ItemType, MenuInfo } from 'rc-menu/lib/interface';
import { KeepAliveTabContext } from './context';
import { KeepAliveTab, useKeepAliveTabs } from './useKeepAliveTabs';
enum OperationType {
REFRESH = 'refresh',
CLOSE = 'close',
CLOSEOTHER = 'close-other',
}
type MenuItemType = ItemType & { key: OperationType } | null;
type MenuItemType = (ItemType & { key: OperationType }) | null;
const KeepAliveLayout = () => {
const {
keepAliveTabs,
activeTabRoutePath,
@ -26,78 +23,91 @@ const KeepAliveLayout = () => {
onShow,
} = useKeepAliveTabs();
const menuItems: MenuItemType[] = useMemo(() => [
{
label: '刷新',
key: OperationType.REFRESH,
},
keepAliveTabs.length <= 1 ? null : {
label: '关闭',
key: OperationType.CLOSE,
},
keepAliveTabs.length <= 1 ? null : {
label: '关闭其他',
key: OperationType.CLOSEOTHER,
},
].filter(o => o), [keepAliveTabs]);
const menuClick = useCallback(({ key, domEvent }: MenuInfo, tab: KeepAliveTab) => {
domEvent.stopPropagation();
const menuItems: MenuItemType[] = useMemo(
() =>
[
{
label: '刷新',
key: OperationType.REFRESH,
},
keepAliveTabs.length <= 1
? null
: {
label: '关闭',
key: OperationType.CLOSE,
},
keepAliveTabs.length <= 1
? null
: {
label: '关闭其他',
key: OperationType.CLOSEOTHER,
},
].filter((o) => o),
[keepAliveTabs],
);
if (key === OperationType.REFRESH) {
refreshTab(tab.routePath);
} else if (key === OperationType.CLOSE) {
closeTab(tab.routePath);
} else if (key === OperationType.CLOSEOTHER) {
closeOtherTab(tab.routePath);
}
}, [closeOtherTab, closeTab, refreshTab]);
const menuClick = useCallback(
({ key, domEvent }: MenuInfo, tab: KeepAliveTab) => {
domEvent.stopPropagation();
if (key === OperationType.REFRESH) {
refreshTab(tab.routePath);
} else if (key === OperationType.CLOSE) {
closeTab(tab.routePath);
} else if (key === OperationType.CLOSEOTHER) {
closeOtherTab(tab.routePath);
}
},
[closeOtherTab, closeTab, refreshTab],
);
const renderTabTitle = useCallback((tab: KeepAliveTab) => {
return (
<Dropdown
menu={{ items: menuItems, onClick: (e) => menuClick(e, tab) }}
trigger={['contextMenu']}
>
<div style={{ margin: '-12px 0', padding: '12px 0' }}>
{/*{tab.icon}*/}
{tab.title}
</div>
</Dropdown>
)
}, [menuItems]);
const renderTabTitle = useCallback(
(tab: KeepAliveTab) => {
return (
<Dropdown
menu={{ items: menuItems, onClick: (e) => menuClick(e, tab) }}
trigger={['contextMenu']}
>
<div style={{ margin: '-12px 0', padding: '12px 0' }}>
{/*{tab.icon}*/}
{tab.title}
</div>
</Dropdown>
);
},
[menuItems],
);
const tabItems = useMemo(() => {
let finalKeepAliveTabs = keepAliveTabs
let finalKeepAliveTabs = keepAliveTabs;
// .filter(item => !item?.isHideTab)
return finalKeepAliveTabs.map(tab => {
console.log(tab,'tabItems')
return finalKeepAliveTabs.map((tab) => {
console.log(tab, 'tabItems');
// TODO 未找到合适办法只去除tab标题栏位保留页面内容
return {
key: tab.routePath,
label: renderTabTitle(tab),
children: (
<div
key={tab.key}
style={{ height: 'calc(100vh - 112px)', overflow: 'auto' }}
>
<div key={tab.key} style={{ height: 'calc(100vh - 112px)', overflow: 'auto' }}>
{tab.children}
</div>
),
// style: {display: 'none'},
closable: keepAliveTabs.length > 1,
forceRender: true
}
})
forceRender: true,
};
});
}, [keepAliveTabs]);
const onTabsChange = useCallback((tabRoutePath: string) => {
const curTab = keepAliveTabs.find(o => o.routePath === tabRoutePath);
if (curTab) {
history.push(curTab?.pathname);
}
}, [keepAliveTabs]);
const onTabsChange = useCallback(
(tabRoutePath: string) => {
const curTab = keepAliveTabs.find((o) => o.routePath === tabRoutePath);
if (curTab) {
history.push(curTab?.pathname);
}
},
[keepAliveTabs],
);
const onTabEdit = (
targetKey: React.MouseEvent | React.KeyboardEvent | string,
@ -116,23 +126,23 @@ const KeepAliveLayout = () => {
onHidden,
onShow,
}),
[closeTab, closeOtherTab, refreshTab, onHidden, onShow]
[closeTab, closeOtherTab, refreshTab, onHidden, onShow],
);
return (
<KeepAliveTabContext.Provider value={keepAliveContextValue}>
<div>
<Tabs
type="editable-card"
items={tabItems}
activeKey={activeTabRoutePath}
onChange={onTabsChange}
className='keep-alive-tabs'
className="keep-alive-tabs"
hideAdd
animated={false}
onEdit={onTabEdit}
/>
</KeepAliveTabContext.Provider>
)
}
</div>
);
};
export default KeepAliveLayout;

8
src/typings.d.ts vendored

@ -1,3 +1,11 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2023-11-01 13:56:33
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-03-29 16:51:11
* @FilePath: \general-ai-platform-web\src\typings.d.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
declare module 'slash2';
declare module '*.css';
declare module '*.less';

@ -1,7 +1,6 @@
{
"compilerOptions": {
"forceConsistentCasingInFileNames": false,
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
@ -20,7 +19,6 @@
"@@/*": ["./src/.umi/*"],
"@@test/*": ["./src/.umi-test/*"],
"@umijs/max": ["./src/.umijs/max"],
}
},
"include": ["./**/*.d.ts", "./**/*.ts", "./**/*.tsx", "src/utils/storage.js"]

Loading…
Cancel
Save