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 = {
|
||||
num: 1,
|
||||
};
|
||||
export default function useQiankunStateForSlave() {
|
||||
const [globalState, setGlobalState] = useState<any>({
|
||||
fatherName: 'zhst',
|
||||
});
|
||||
|
||||
// 初始化 state
|
||||
const actions: MicroAppStateActions = initGlobalState(state);
|
||||
|
||||
actions.onGlobalStateChange((state, prev) => {
|
||||
// state: 变更后的状态; prev 变更前的状态
|
||||
console.log('主应用检测到state变更:', state, prev);
|
||||
});
|
||||
|
||||
// 你还可以定义一个获取state的方法下发到子应用
|
||||
actions.getGlobalState = function () {
|
||||
return state;
|
||||
};
|
||||
|
||||
export default actions;
|
||||
return {
|
||||
globalState,
|
||||
setGlobalState,
|
||||
};
|
||||
}
|
||||
|
14
src/app.ts
14
src/app.ts
@ -1,5 +1,5 @@
|
||||
import doRequest from '@/utils/request';
|
||||
import { useState } from 'react';
|
||||
import useFatherAction from './actions';
|
||||
|
||||
// 运行时配置
|
||||
export async function getInitialState(): Promise<{
|
||||
@ -13,17 +13,7 @@ export async function getInitialState(): Promise<{
|
||||
}
|
||||
|
||||
// 给子应用暴露的方法
|
||||
export function useQiankunStateForSlave() {
|
||||
const [globalState, setGlobalState] = useState<any>({
|
||||
slogan: 'qiankun father',
|
||||
useLogin: false,
|
||||
});
|
||||
|
||||
return {
|
||||
globalState,
|
||||
setGlobalState,
|
||||
};
|
||||
}
|
||||
export const useQiankunStateForSlave = useFatherAction;
|
||||
|
||||
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() {
|
||||
return (
|
||||
|
@ -1,8 +1,9 @@
|
||||
import React from 'react';
|
||||
|
||||
export default function HomePage() {
|
||||
return (
|
||||
<div>
|
||||
<h2>Yay! Welcome to umi!</h2>
|
||||
<h2>welcome home !</h2>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user