后台统一状态提示:共享 toast 模块(ToastStack 挂后台布局与登录页),登录成功/失败、文章/标签/作品/文件/评论/设置操作全部有反馈,替换掉原生 alert;编辑器局部 toast 并入共享实现

This commit is contained in:
Sakurasan
2026-09-28 23:52:16 +08:00
parent f7a2e83727
commit c84a383e5c
11 changed files with 96 additions and 45 deletions
+7 -6
View File
@@ -1,5 +1,6 @@
<script setup>
import { onMounted, ref } from 'vue'
import { toastOk, toastErr } from './toast'
import { adminApi } from '../api'
const projects = ref([])
@@ -40,7 +41,7 @@ onMounted(load)
async function create() {
if (!form.value.title.trim()) {
alert('请填写作品名称')
toastErr('请填写作品名称')
return
}
try {
@@ -56,7 +57,7 @@ async function create() {
form.value = blank()
await load()
} catch (e) {
alert(e.message || '创建失败')
toastErr(e.message || '创建失败')
}
}
@@ -81,7 +82,7 @@ function cancelEdit() {
async function saveEdit() {
if (!draft.value.title.trim()) {
alert('请填写作品名称')
toastErr('请填写作品名称')
return
}
try {
@@ -97,7 +98,7 @@ async function saveEdit() {
editing.value = null
await load()
} catch (e) {
alert(e.message || '保存失败')
toastErr(e.message || '保存失败')
}
}
@@ -107,7 +108,7 @@ async function toggleStatus(p) {
await adminApi.updateProject(p.id, { status: next })
await load()
} catch (e) {
alert(e.message || '更新失败')
toastErr(e.message || '更新失败')
}
}
@@ -117,7 +118,7 @@ async function remove(p) {
await adminApi.deleteProject(p.id)
await load()
} catch (e) {
alert(e.message || '删除失败')
toastErr(e.message || '删除失败')
}
}
</script>