|
|
@@ -1,7 +1,7 @@
|
|
|
/*
|
|
|
* @Author: your name
|
|
|
* @Date: 2022-01-06 15:25:39
|
|
|
- * @LastEditTime: 2025-05-13 16:44:15
|
|
|
+ * @LastEditTime: 2025-05-15 10:30:23
|
|
|
* @LastEditors: code4eat awesomedema@gmail.com
|
|
|
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
* @FilePath: /KC-MiddlePlatform/src/pages/platform/_layout.tsx
|
|
|
@@ -129,6 +129,7 @@ export default function Layout({ children, location, route, history, match, ...r
|
|
|
const [emptyPageContent, set_emptyPageContent] = useState('');
|
|
|
const [isShowPageMenu, set_isShowPageMenu] = useState(true);
|
|
|
const [isEmpty, set_isEmpty] = useState(false);
|
|
|
+ const [isThirdPartySystem, setIsThirdPartySystem] = useState(false);
|
|
|
|
|
|
const [collapsed, set_collapsed] = useState(false);
|
|
|
|
|
|
@@ -145,6 +146,9 @@ export default function Layout({ children, location, route, history, match, ...r
|
|
|
const [loading, setLoading] = useState(true);
|
|
|
const [dataLoaded, setDataLoaded] = useState(false);
|
|
|
|
|
|
+ // 用于记录上一次 isThirdPartySystem 状态
|
|
|
+ const prevIsThirdPartySystemRef = useRef(isThirdPartySystem);
|
|
|
+
|
|
|
const setEmptyPageContent = async (menuId: Key) => {
|
|
|
const menuItem = await getSpecifyMenuDetail(menuId);
|
|
|
if (menuItem.isSetupMenu) {
|
|
|
@@ -337,6 +341,42 @@ export default function Layout({ children, location, route, history, match, ...r
|
|
|
});
|
|
|
}, [dataLoaded, initialState]);
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ if (initialState?.currentSelectedSys) {
|
|
|
+ const { type, contentType } = initialState.currentSelectedSys;
|
|
|
+ setIsThirdPartySystem(type === 1 && contentType === 6);
|
|
|
+ }
|
|
|
+ }, [initialState?.currentSelectedSys]);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ // 只有从第三方系统切回中台时才处理
|
|
|
+ if (prevIsThirdPartySystemRef.current && !isThirdPartySystem) {
|
|
|
+ // 取当前选中的菜单 key
|
|
|
+ if (selectedKeys && selectedKeys.length > 0 && initialState?.menuData) {
|
|
|
+ // 递归查找菜单项
|
|
|
+ const findItemByKey = (tree: any[], key: string, keyName: string): any => {
|
|
|
+ for (const node of tree) {
|
|
|
+ if (node[`${keyName}`] === key) {
|
|
|
+ return node;
|
|
|
+ }
|
|
|
+ if (node.children) {
|
|
|
+ const result = findItemByKey(node.children, key, keyName);
|
|
|
+ if (result) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ };
|
|
|
+ const selectedMenu = findItemByKey(initialState.menuData, selectedKeys[0], 'key');
|
|
|
+ if (selectedMenu && selectedMenu.path && history.location.pathname !== selectedMenu.path) {
|
|
|
+ history.push(selectedMenu.path);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ prevIsThirdPartySystemRef.current = isThirdPartySystem;
|
|
|
+ }, [isThirdPartySystem]);
|
|
|
+
|
|
|
return (
|
|
|
<ProLayout
|
|
|
style={{
|
|
|
@@ -396,7 +436,7 @@ export default function Layout({ children, location, route, history, match, ...r
|
|
|
localStorage.setItem('openKeys', JSON.stringify(keys));
|
|
|
},
|
|
|
}}
|
|
|
- menu={(isShowPageMenu&&!noMenu)?{
|
|
|
+ menu={isShowPageMenu && !noMenu ? {
|
|
|
autoClose: false,
|
|
|
request: async () => {
|
|
|
if (initialState && initialState.currentSelectedSys) {
|
|
|
@@ -525,7 +565,7 @@ export default function Layout({ children, location, route, history, match, ...r
|
|
|
}
|
|
|
return [];
|
|
|
},
|
|
|
- }:false}
|
|
|
+ } : undefined}
|
|
|
menuRender={(props: any, defaultDom) => {
|
|
|
return (
|
|
|
<div style={isShowPageMenu && noMenu != 'true' ? {} : { display: 'inline-block', width: 0, overflow: 'hidden' }}>
|
|
|
@@ -566,7 +606,7 @@ export default function Layout({ children, location, route, history, match, ...r
|
|
|
{...moreConfig}
|
|
|
>
|
|
|
{isEmpty && <EmptyPage textContent={emptyPageContent} />}
|
|
|
- {!isEmpty && type != 1 && contentType != 6 && (
|
|
|
+ {!isEmpty && !isThirdPartySystem && (
|
|
|
<PageContainer
|
|
|
className="kcmpPageContainer"
|
|
|
header={{
|
|
|
@@ -586,8 +626,13 @@ export default function Layout({ children, location, route, history, match, ...r
|
|
|
</div>
|
|
|
</PageContainer>
|
|
|
)}
|
|
|
- {type == 1 && contentType == 6 && (
|
|
|
- <iframe id={'bi_iframe'} style={{ width: '100%', height: '100%', border: 'none' }} src={addTokenToUrl(url as string, token)} onLoad={() => adjustIframe()}></iframe>
|
|
|
+ {isThirdPartySystem && (
|
|
|
+ <iframe
|
|
|
+ id={'bi_iframe'}
|
|
|
+ style={{ width: '100%', height: '100%', border: 'none' }}
|
|
|
+ src={addTokenToUrl(url as string, token)}
|
|
|
+ onLoad={() => adjustIframe()}
|
|
|
+ />
|
|
|
)}
|
|
|
</ProLayout>
|
|
|
);
|