diff --git a/frontend/src/admin/AdminLayout.vue b/frontend/src/admin/AdminLayout.vue index 30fb851..c26f8b5 100644 --- a/frontend/src/admin/AdminLayout.vue +++ b/frontend/src/admin/AdminLayout.vue @@ -1,5 +1,6 @@ + 后台 diff --git a/frontend/src/admin/PostsView.vue b/frontend/src/admin/PostsView.vue index b333d43..37b9b9c 100644 --- a/frontend/src/admin/PostsView.vue +++ b/frontend/src/admin/PostsView.vue @@ -1,5 +1,6 @@ diff --git a/frontend/src/admin/SettingsView.vue b/frontend/src/admin/SettingsView.vue index 91a6cb9..f7f3608 100644 --- a/frontend/src/admin/SettingsView.vue +++ b/frontend/src/admin/SettingsView.vue @@ -1,5 +1,6 @@ diff --git a/frontend/src/admin/ToastStack.vue b/frontend/src/admin/ToastStack.vue new file mode 100644 index 0000000..4545206 --- /dev/null +++ b/frontend/src/admin/ToastStack.vue @@ -0,0 +1,11 @@ + + + + + {{ t.text }} + + diff --git a/frontend/src/admin/toast.js b/frontend/src/admin/toast.js new file mode 100644 index 0000000..7879da4 --- /dev/null +++ b/frontend/src/admin/toast.js @@ -0,0 +1,47 @@ +import { reactive } from 'vue' + +// 后台共享的轻提示:所有视图的操作反馈(成功/失败/进度)从这里发, +// ToastStack.vue 负责渲染(挂在 AdminLayout 与 LoginView)。 +// EditorView 的上传/转存也走它——原先那套局部实现已并入。 +export const toasts = reactive([]) +let seq = 0 + +export function toast(text, type = 'info', ttl = 2600) { + const id = ++seq + toasts.push({ id, text, type }) + setTimeout(() => { + const i = toasts.findIndex((t) => t.id === id) + if (i >= 0) toasts.splice(i, 1) + }, ttl) + return id +} + +export function toastOk(text) { + return toast(text, 'ok', 2200) +} + +export function toastErr(text) { + return toast(text, 'err', 4200) +} + +// 更新一条已存在的 toast(上传进度用) +export function toastUpdate(id, text, type = 'info') { + const t = toasts.find((x) => x.id === id) + if (t) { + t.text = text + t.type = type + } +} + +// 标记成功并很快消失(进度条收尾) +export function toastDone(id, text) { + toastUpdate(id, text, 'ok') + const idx = toasts.findIndex((t) => t.id === id) + if (idx >= 0) { + const t = toasts[idx] + setTimeout(() => { + const i = toasts.indexOf(t) + if (i >= 0) toasts.splice(i, 1) + }, 1600) + } +}
后台