fix: 删除无效文件
This commit is contained in:
parent
6e32e2a23b
commit
ee25cb5e30
0
config/config.ts
Normal file
0
config/config.ts
Normal file
@ -1,20 +1,12 @@
|
|||||||
import { initGlobalState, MicroAppStateActions } from '@umijs/max';
|
import { useState } from 'react';
|
||||||
|
|
||||||
const state = {
|
export default function useQiankunStateForSlave() {
|
||||||
num: 1,
|
const [globalState, setGlobalState] = useState<any>({
|
||||||
};
|
fatherName: 'zhst',
|
||||||
|
});
|
||||||
|
|
||||||
// 初始化 state
|
return {
|
||||||
const actions: MicroAppStateActions = initGlobalState(state);
|
globalState,
|
||||||
|
setGlobalState,
|
||||||
actions.onGlobalStateChange((state, prev) => {
|
};
|
||||||
// state: 变更后的状态; prev 变更前的状态
|
}
|
||||||
console.log('主应用检测到state变更:', state, prev);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 你还可以定义一个获取state的方法下发到子应用
|
|
||||||
actions.getGlobalState = function () {
|
|
||||||
return state;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default actions;
|
|
||||||
|
14
src/app.ts
14
src/app.ts
@ -1,5 +1,5 @@
|
|||||||
import doRequest from '@/utils/request';
|
import doRequest from '@/utils/request';
|
||||||
import { useState } from 'react';
|
import useFatherAction from './actions';
|
||||||
|
|
||||||
// 运行时配置
|
// 运行时配置
|
||||||
export async function getInitialState(): Promise<{
|
export async function getInitialState(): Promise<{
|
||||||
@ -13,17 +13,7 @@ export async function getInitialState(): Promise<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 给子应用暴露的方法
|
// 给子应用暴露的方法
|
||||||
export function useQiankunStateForSlave() {
|
export const useQiankunStateForSlave = useFatherAction;
|
||||||
const [globalState, setGlobalState] = useState<any>({
|
|
||||||
slogan: 'qiankun father',
|
|
||||||
useLogin: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
globalState,
|
|
||||||
setGlobalState,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const hostname = location.hostname;
|
const hostname = location.hostname;
|
||||||
|
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 921 KiB |
@ -1,3 +1,4 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
export default function HomePage() {
|
export default function HomePage() {
|
||||||
return (
|
return (
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
export default function HomePage() {
|
export default function HomePage() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h2>Yay! Welcome to umi!</h2>
|
<h2>welcome home !</h2>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user