| 12345678910111213141516171819202122232425262728293031323334353637 |
- /**
- * 全站级会话提示:角色/主体变化后跨页面告知一次。
- *
- * 场景:主账号转交会把转出方降为 `opsSub`,`NavAllowed` 随即把当前页换成落地页;
- * 点内提示随组件卸载而丢失,因此提示挂在 `AppShell` 上(路由切换不丢)。
- * ⛔ 当业务结果提示用:普通保存成功仍走各页 `useSaveNotice`。
- */
- let message: string | null = null;
- const listeners = new Set<() => void>();
- function emit() {
- for (const listener of listeners) listener();
- }
- export function notifySessionNotice(text: string) {
- const next = text.trim();
- if (!next) return;
- message = next;
- emit();
- }
- export function dismissSessionNotice() {
- if (message === null) return;
- message = null;
- emit();
- }
- export function subscribeSessionNotice(listener: () => void) {
- listeners.add(listener);
- return () => {
- listeners.delete(listener);
- };
- }
- export function getSessionNotice(): string | null {
- return message;
- }
|