f
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
CI / CI OK (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
CI / CI OK (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
This commit is contained in:
45
packages/@core/base/shared/src/global-state.ts
Normal file
45
packages/@core/base/shared/src/global-state.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 全局复用的变量、组件、配置,各个模块之间共享
|
||||
* 通过单例模式实现,单例必须注意不受请求影响,例如用户信息这些需要根据请求获取的。后续如果有ssr需求,也不会影响
|
||||
*/
|
||||
|
||||
interface ComponentsState {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface MessageState {
|
||||
copyPreferencesSuccess?: (title: string, content?: string) => void;
|
||||
}
|
||||
|
||||
export interface IGlobalSharedState {
|
||||
components: ComponentsState;
|
||||
message: MessageState;
|
||||
}
|
||||
|
||||
class GlobalShareState {
|
||||
#components: ComponentsState = {};
|
||||
#message: MessageState = {};
|
||||
|
||||
/**
|
||||
* 定义框架内部各个场景的消息提示
|
||||
*/
|
||||
public defineMessage({ copyPreferencesSuccess }: MessageState) {
|
||||
this.#message = {
|
||||
copyPreferencesSuccess,
|
||||
};
|
||||
}
|
||||
|
||||
public getComponents(): ComponentsState {
|
||||
return this.#components;
|
||||
}
|
||||
|
||||
public getMessage(): MessageState {
|
||||
return this.#message;
|
||||
}
|
||||
|
||||
public setComponents(value: ComponentsState) {
|
||||
this.#components = value;
|
||||
}
|
||||
}
|
||||
|
||||
export const globalShareState = new GlobalShareState();
|
||||
Reference in New Issue
Block a user