Browse Source

feat: 集成qiankun

dev-zw-big-model
zhaowei 6 months ago
parent
commit
1d3c41f62c
6 changed files with 80 additions and 1 deletions
  1. +15
    -0
      react-ui/config/config.ts
  2. +24
    -0
      react-ui/config/routes.ts
  3. +1
    -1
      react-ui/package.json
  4. +12
    -0
      react-ui/src/app.tsx
  5. +3
    -0
      react-ui/src/pages/Mixed/index.less
  6. +25
    -0
      react-ui/src/pages/Mixed/index.tsx

+ 15
- 0
react-ui/config/config.ts View File

@@ -159,4 +159,19 @@ export default defineConfig({
javascriptEnabled: true, javascriptEnabled: true,
}, },
valtio: {}, valtio: {},
qiankun: {
master: {
sandbox: true,
apps: [
{
name: 'app1',
entry: '//localhost:7001',
},
{
name: 'app2',
entry: '//localhost:3000',
},
],
},
},
}); });

+ 24
- 0
react-ui/config/routes.ts View File

@@ -596,6 +596,18 @@ export default [
}, },
], ],
}, },
{
name: 'mixed',
path: '/mixed',
routes: [
{
name: '父子页面混合',
path: '',
key: 'mixed',
component: './Mixed/index',
},
],
},
{ {
name: '算力积分', name: '算力积分',
path: '/points', path: '/points',
@@ -608,6 +620,18 @@ export default [
}, },
], ],
}, },
{
path: '/app1/*',
name: '子应用1',
microApp: 'app1',
layout: true,
},
{
path: '/app2/*',
name: '子应用2',
microApp: 'app2',
layout: true,
},
{ {
path: '*', path: '*',
layout: false, layout: false,


+ 1
- 1
react-ui/package.json View File

@@ -1,5 +1,5 @@
{ {
"name": "cl-model",
"name": "ci4s",
"version": "1.0.0", "version": "1.0.0",
"private": true, "private": true,
"description": "", "description": "",


+ 12
- 0
react-ui/src/app.tsx View File

@@ -4,6 +4,7 @@ import { type GlobalInitialState } from '@/types';
import { menuItemRender } from '@/utils/menuRender'; import { menuItemRender } from '@/utils/menuRender';
import type { Settings as LayoutSettings } from '@ant-design/pro-components'; import type { Settings as LayoutSettings } from '@ant-design/pro-components';
import { RuntimeConfig, history } from '@umijs/max'; import { RuntimeConfig, history } from '@umijs/max';
import { useState } from 'react';
import { RuntimeAntdConfig } from 'umi'; import { RuntimeAntdConfig } from 'umi';
import defaultSettings from '../config/defaultSettings'; import defaultSettings from '../config/defaultSettings';
import '../public/fonts/font.css'; import '../public/fonts/font.css';
@@ -172,6 +173,17 @@ export function render(oldRender: () => void) {
}); });
} }


export const useQiankunStateForSlave = () => {
const [globalState, setGlobalState] = useState<any>({
slogan: 'Hello MicroFrontend',
});

return {
globalState,
setGlobalState,
};
};

// 主题修改 // 主题修改
export const antd: RuntimeAntdConfig = (memo) => { export const antd: RuntimeAntdConfig = (memo) => {
memo.theme ??= {}; memo.theme ??= {};


+ 3
- 0
react-ui/src/pages/Mixed/index.less View File

@@ -0,0 +1,3 @@
.mixed {
height: 100%;
}

+ 25
- 0
react-ui/src/pages/Mixed/index.tsx View File

@@ -0,0 +1,25 @@
import { MicroAppWithMemoHistory } from '@umijs/max';
import { Tabs } from 'antd';
import styles from './index.less';

const Docs = () => {
const mirrorTabItems = [
{
key: '1',
label: '父页面',
children: <div style={{ width: '100%', height: '100%', border: 0 }}>Parent</div>,
},
{
key: '2',
label: '子页面',
children: <MicroAppWithMemoHistory name="app1" url="/app1/home"></MicroAppWithMemoHistory>,
},
];

return (
<div className={styles.mixed}>
<Tabs items={mirrorTabItems} />
</div>
);
};
export default Docs;

Loading…
Cancel
Save