Skip to content

Commit 3dddfe2

Browse files
committed
wip
1 parent 878cba6 commit 3dddfe2

File tree

7 files changed

+44
-2
lines changed

7 files changed

+44
-2
lines changed

.umirc.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ export default defineConfig({
1919
{ path: '/index', component: '@/pages/Index/index' },
2020
],
2121
fastRefresh: {},
22+
// qiankun: {
23+
// master: {
24+
// apps:[]
25+
// }
26+
// }
2227
});

mock/microApp.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export default {
2+
// 微前端
3+
'GET /api/microApp/index': {
4+
component: "page",
5+
style: {
6+
height: '100vh',
7+
},
8+
body: {
9+
component: "layout",
10+
cache: true,
11+
body: {
12+
component: "microApp",
13+
name: 'app1'
14+
}
15+
}
16+
}
17+
}
18+

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"devDependencies": {
3535
"@types/react": "^17.0.0",
3636
"@types/react-dom": "^17.0.0",
37+
"@umijs/plugin-qiankun": "^2.26.0",
3738
"@umijs/test": "^3.4.7",
3839
"husky": "^4.3.0",
3940
"lint-staged": "^10.0.7",

public/config.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"initApi": "admin/login"
2+
"initApi": "admin/login",
3+
"apps": [
4+
{
5+
"name": "app1",
6+
"entry": "//www.baidu.com"
7+
}
8+
]
39
}

src/app.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,10 @@ export const request: RequestConfig = {
6767
}
6868
],
6969
};
70+
71+
// 从接口中获取子应用配置,export 出的 qiankun 变量是一个 promise
72+
export const qiankun = fetch('./config.json')
73+
.then(response => response.json())
74+
.then(response => ({
75+
apps: response.apps
76+
}))

src/components/Layout/RightContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const RightContent: React.FC<any> = (props) => {
1818
}
1919

2020
if (event.key === 'setting') {
21-
history.push({ pathname: '/index', query: { api:'admin/account/setting' } });
21+
history.push({ pathname: '/index', query: { api:'admin/account/setting-form' } });
2222
return;
2323
}
2424

src/components/Render.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Paragraph from '@/components/Typography/Paragraph';
2121
import Title from '@/components/Typography/Title';
2222
import Text from '@/components/Typography/Text';
2323
import { Space } from 'antd';
24+
import { MicroApp } from 'umi';
2425
import { dataMapping, tplEngine } from '@/utils/template';
2526

2627
const Render: React.FC<any> = (props:any) => {
@@ -123,6 +124,10 @@ const Render: React.FC<any> = (props:any) => {
123124
key: 'login',
124125
component: <Login {...body} callback={callback} data={data} />
125126
},
127+
// {
128+
// key: 'microApp',
129+
// component: <MicroApp {...body} callback={callback} data={data} />
130+
// },
126131
{
127132
key: 'tpl',
128133
component: <>{ tplEngine(body.body,data) }</>

0 commit comments

Comments
 (0)