admin的数据库文件补全,修复uvue中的数据库接入bug

This commit is contained in:
comlibmb
2026-02-25 10:02:50 +08:00
parent 5d00e3d74e
commit dc8f899610
40 changed files with 1629 additions and 625 deletions

View File

@@ -207,27 +207,42 @@ function handleEdit(item: ArticleCategory) {
async function toggleStatus(item: ArticleCategory) {
const targetStatus = item.status === 1 ? 0 : 1
const ok = await setArticleCategoryStatus(item.id, targetStatus)
if (ok) {
item.status = targetStatus
uni.showToast({ title: '状态已更新' })
} else {
uni.showToast({ title: '操作失败', icon: 'none' })
try {
const resId = await saveArticleCategory(
item.id,
item.name,
item.icon,
item.sort,
targetStatus
)
if (resId != null) {
item.status = targetStatus
uni.showToast({ title: '状态已更新' })
}
} catch (e: any) {
const errMsg = e?.message || '操作失败'
uni.showToast({ title: errMsg, icon: 'none' })
}
}
async function handleDelete(item: ArticleCategory) {
uni.showModal({
title: '提示',
content: `确定要删除分类 "${item.name}" 吗?`,
title: '删除确认',
content: `确定要删除分类 "${item.name}" 吗?\n\n⚠ 警告:该操作将同时删除该分类下的所有文章!`,
confirmText: '确认删除',
confirmColor: '#ed4014',
success: async (res) => {
if (res.confirm) {
const ok = await deleteArticleCategory(item.id)
if (ok) {
uni.showToast({ title: '删除成功' })
loadData()
} else {
uni.showToast({ title: '删除失败', icon: 'none' })
try {
const ok = await deleteArticleCategory(item.id)
if (ok) {
uni.showToast({ title: '删除成功' })
loadData()
}
} catch (e: any) {
// 显示后端抛出的具体错误信息(如权限不足)
const errMsg = e?.message || '删除失败'
uni.showToast({ title: errMsg, icon: 'none', duration: 3000 })
}
}
}