forked from bai/curriculum-project-hub
feat(database): init database folder frontend and permission
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { writable } from "svelte/store";
|
||||
import type { MeResponse } from "./types.js";
|
||||
|
||||
/** 当前登录身份;null = 未登录(显示登录视图)。 */
|
||||
export const me = writable<MeResponse | null>(null);
|
||||
export const authChecked = writable(false);
|
||||
|
||||
export interface ToastItem {
|
||||
readonly id: number;
|
||||
readonly message: string;
|
||||
readonly kind: "info" | "err";
|
||||
}
|
||||
|
||||
let nextToastId = 1;
|
||||
export const toasts = writable<ToastItem[]>([]);
|
||||
|
||||
export function toast(message: string, kind: ToastItem["kind"] = "info"): void {
|
||||
const id = nextToastId++;
|
||||
toasts.update((list) => [...list, { id, message, kind }]);
|
||||
setTimeout(() => {
|
||||
toasts.update((list) => list.filter((t) => t.id !== id));
|
||||
}, 3600);
|
||||
}
|
||||
|
||||
export const toastOk = (m: string): void => toast(m, "info");
|
||||
export const toastErr = (m: string): void => toast(m, "err");
|
||||
Reference in New Issue
Block a user