refactor: frontend TS migration + Tailwind4/daisyUI5 unify + BUILDPLATFORM docker build
- migrate frontend to TypeScript (vue-tsc strict in build), upgrade all deps to latest (Vite 8, Tailwind 4, daisyUI 5, Pinia 4, vue-router 5) - restructure frontend dirs (api/components/common/layouts/styles/types/views) - drop Element Plus, add daisyUI TagInput; main CSS 490KB->163KB, entry JS 618KB->1.3KB - rewrite Dockerfile(.cn): frontend/backend stages pinned to $BUILDPLATFORM, CGO_ENABLED=0 cross-compile, no QEMU in multi-arch builds; add .dockerignore - local dev: Vite /api proxy + make dev targets; go:embed all:dist with .gitkeep so backend runs without prior frontend build - fix latent bugs: Keys.vue users ref, Settings.vue undefined userStore, Login.vue Ref-as-error display, res.error misuse - add REFACTOR_PLAN.md (phased refactor log)
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { inject } from 'vue'
|
||||
import type { InjectionKey } from 'vue'
|
||||
|
||||
export type ToastType = 'info' | 'success' | 'error'
|
||||
|
||||
export type ToastMessage = {
|
||||
message: string
|
||||
type?: ToastType
|
||||
duration?: number
|
||||
}
|
||||
|
||||
export type ToastContext = {
|
||||
setToast: (message: string, type?: ToastType, duration?: number) => void
|
||||
}
|
||||
|
||||
export const ToastKey: InjectionKey<ToastContext> = Symbol('toast')
|
||||
|
||||
export function useToast(): ToastContext {
|
||||
const ctx = inject(ToastKey)
|
||||
if (!ctx) {
|
||||
throw new Error('ToastContext 未提供:请在 App 根组件 provide(ToastKey, ...)')
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
Reference in New Issue
Block a user