rebuild(stage-10): deliver mentor and unified llm streaming

This commit is contained in:
leefer
2026-07-30 05:52:12 +08:00
parent 532f0cfc11
commit f1fa104641
62 changed files with 6880 additions and 7 deletions
+23 -1
View File
@@ -3,6 +3,7 @@ import { ref } from "vue";
export type DialogName = "profile" | "membership" | "password" | "search" | null;
export type Theme = "light" | "dark";
export type Confirmation = { title: string; message: string; confirmLabel: string };
const THEME_KEY = "xiaobai-theme";
@@ -20,8 +21,10 @@ export function applyTheme(theme: Theme): void {
export const useUiStore = defineStore("ui", () => {
const theme = ref<Theme>(preferredTheme());
const dialog = ref<DialogName>(null);
const confirmation = ref<Confirmation | null>(null);
const toast = ref("");
let toastTimer: ReturnType<typeof setTimeout> | undefined;
let confirmationResolve: ((value: boolean) => void) | undefined;
function setTheme(next: Theme): void {
theme.value = next;
@@ -34,6 +37,7 @@ export const useUiStore = defineStore("ui", () => {
}
function openDialog(name: Exclude<DialogName, null>): void {
resolveConfirmation(false);
dialog.value = name;
}
@@ -41,6 +45,21 @@ export const useUiStore = defineStore("ui", () => {
dialog.value = null;
}
function askConfirmation(value: Confirmation): Promise<boolean> {
resolveConfirmation(false);
dialog.value = null;
confirmation.value = value;
return new Promise((resolve) => {
confirmationResolve = resolve;
});
}
function resolveConfirmation(value: boolean): void {
confirmation.value = null;
confirmationResolve?.(value);
confirmationResolve = undefined;
}
function showToast(message: string): void {
toast.value = message;
if (toastTimer) clearTimeout(toastTimer);
@@ -49,5 +68,8 @@ export const useUiStore = defineStore("ui", () => {
}, 2200);
}
return { theme, dialog, toast, setTheme, toggleTheme, openDialog, closeDialog, showToast };
return {
theme, dialog, confirmation, toast, setTheme, toggleTheme, openDialog, closeDialog,
askConfirmation, resolveConfirmation, showToast,
};
});