diff --git a/config/config.ts b/config/config.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/actions/index.ts b/src/actions/index.ts index bdad3ea..745dca5 100644 --- a/src/actions/index.ts +++ b/src/actions/index.ts @@ -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({ + 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, + }; +} diff --git a/src/app.ts b/src/app.ts index b0fc1ca..c409ed9 100644 --- a/src/app.ts +++ b/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({ - slogan: 'qiankun father', - useLogin: false, - }); - - return { - globalState, - setGlobalState, - }; -} +export const useQiankunStateForSlave = useFatherAction; const hostname = location.hostname; diff --git a/src/assets/ai-video.png b/src/assets/ai-video.png deleted file mode 100644 index 99304b7..0000000 Binary files a/src/assets/ai-video.png and /dev/null differ diff --git a/src/pages/Access/index.tsx b/src/pages/demo/Access/index.tsx similarity index 100% rename from src/pages/Access/index.tsx rename to src/pages/demo/Access/index.tsx diff --git a/src/pages/Table/components/CreateForm.tsx b/src/pages/demo/Table/components/CreateForm.tsx similarity index 100% rename from src/pages/Table/components/CreateForm.tsx rename to src/pages/demo/Table/components/CreateForm.tsx diff --git a/src/pages/Table/components/UpdateForm.tsx b/src/pages/demo/Table/components/UpdateForm.tsx similarity index 100% rename from src/pages/Table/components/UpdateForm.tsx rename to src/pages/demo/Table/components/UpdateForm.tsx diff --git a/src/pages/Table/index.tsx b/src/pages/demo/Table/index.tsx similarity index 100% rename from src/pages/Table/index.tsx rename to src/pages/demo/Table/index.tsx diff --git a/src/pages/error/index.tsx b/src/pages/error/index.tsx index 08dfc6a..91db175 100644 --- a/src/pages/error/index.tsx +++ b/src/pages/error/index.tsx @@ -1,3 +1,4 @@ +import React from 'react'; export default function HomePage() { return ( @@ -5,4 +6,4 @@ export default function HomePage() {

error

); -} \ No newline at end of file +} diff --git a/src/pages/index.tsx b/src/pages/index.tsx index a762b65..214025a 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,8 +1,9 @@ +import React from 'react'; export default function HomePage() { return (
-

Yay! Welcome to umi!

+

welcome home !

); }