feat(system): 完成前端系统管理(布局框架、三个管理页面、e2e)
- BasicLayout:侧边栏/顶栏/面包屑/移动端抽屉;菜单从路由表派生; 路由守卫新增 requiresAdmin 层(菜单隐藏 + 直连 URL 弹回) - 用户/角色/日志三个页面:分页请求序号防竞态、确认动作流抽 useConfirmAction、 时间范围配 default-time、日志详情按需懒加载并缓存 - 空 catch 统一改 handledError 显式声明;词表/选项常量集中(与后端对齐), 「停用」文案全站统一为「禁用」 - 品牌色提升为全局 token,Element Plus 主色指向赭金 - e2e:公共工具抽 common.py;系统管理 13 项(含详情懒加载脱敏断言), 管理员密码改 E2E_ADMIN_PASSWORD 环境变量;login_flow 8 项回归通过 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
1 parent
c83287819a
commit
8355e0cc7d
26 files changed
+2785
-180
No files matched your search
@@ -0,0 +1,52 @@
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
|
||||
import { handledError } from '@/utils/error'
|
||||
|
||||
/**
|
||||
* 「确认框 → 执行 → 成功提示 → 收尾刷新」动作流。
|
||||
*
|
||||
* 用户/角色两页的启用禁用、删除共四处结构逐行相同,收敛到这里:
|
||||
* 取消确认静默返回 false;接口失败由请求拦截器统一提示,此处仅兜底
|
||||
* 阻止 Promise 继续传播(handledError 显式标注,不写空 catch)。
|
||||
*/
|
||||
export function useConfirmAction() {
|
||||
/**
|
||||
* 弹出确认框并执行;返回是否真正执行成功(用户取消或执行失败均为 false)。
|
||||
*/
|
||||
async function confirmAndRun(options: {
|
||||
/** 确认框正文 */
|
||||
confirmText: string
|
||||
/** 确认框标题 */
|
||||
title?: string
|
||||
/** 确认按钮文案 */
|
||||
confirmButtonText?: string
|
||||
/** 执行成功后的全局提示 */
|
||||
successText: string
|
||||
/** 真正的业务动作 */
|
||||
run: () => Promise<unknown>
|
||||
/** 成功后的收尾(如刷新列表) */
|
||||
after?: () => Promise<void> | void
|
||||
}): Promise<boolean> {
|
||||
try {
|
||||
await ElMessageBox.confirm(options.confirmText, options.title ?? '操作确认', {
|
||||
type: 'warning',
|
||||
confirmButtonText: options.confirmButtonText ?? '确定',
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
} catch {
|
||||
return false // 用户取消,静默返回
|
||||
}
|
||||
|
||||
try {
|
||||
await options.run()
|
||||
ElMessage.success(options.successText)
|
||||
await options.after?.()
|
||||
return true
|
||||
} catch (error) {
|
||||
handledError(error) // 失败提示由请求拦截器统一完成
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return { confirmAndRun }
|
||||
}
|
||||
Reference in new issue
Block a user