feat: 优化架构
This commit is contained in:
25
src/services/ui/promptService.ts
Normal file
25
src/services/ui/promptService.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
export type PromptType = 'info' | 'success' | 'warning' | 'error';
|
||||
|
||||
export interface PromptPayload {
|
||||
title?: string;
|
||||
message: string;
|
||||
type?: PromptType;
|
||||
duration?: number;
|
||||
}
|
||||
|
||||
type PromptListener = (payload: PromptPayload) => void;
|
||||
|
||||
let promptListener: PromptListener | null = null;
|
||||
|
||||
export const bindPromptListener = (listener: PromptListener) => {
|
||||
promptListener = listener;
|
||||
return () => {
|
||||
if (promptListener === listener) {
|
||||
promptListener = null;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const showPrompt = (payload: PromptPayload) => {
|
||||
promptListener?.(payload);
|
||||
};
|
||||
Reference in New Issue
Block a user