feat: 新增角色管理模块,优化API与交互体验
Some checks failed
Release pipeline / publish (push) Has been cancelled
Release pipeline / Always run job (push) Has been cancelled

1.  新增角色管理后台页面、路由与国际化文案
2.  重构API请求错误处理逻辑,统一拦截业务与HTTP错误
3.  新增确认弹窗组合式函数,区分取消与请求错误场景
4.  完善表格按钮权限与显示控制逻辑
5.  更新API参数规范与文档说明
6.  修复部分页面分页数据解析问题
This commit is contained in:
sheng
2026-05-28 19:16:05 +08:00
parent ba43de8f4b
commit a61036e5dc
14 changed files with 999 additions and 45 deletions

View File

@@ -0,0 +1,60 @@
/**
* $confirm + API 调用的标准包装 mixin
*
* 解决问题:$confirm 取消也会 reject和 API 失败混在同一个 catch 里无法区分
*
* 调用方无需 try/catch只需判断返回值
* - 返回 true → 用户取消,静默返回
* - 返回 false → action 已执行(成功或失败),拦截器已处理 Message
*
* @example
* import { confirmMixin } from '@/composables/useConfirmHandle'
* export default {
* mixins: [confirmMixin, i18nMixin('page.xxx')],
* methods: {
* async handleDelete (row) {
* const cancelled = await this.$confirmAction(
* { message: this.key('confirm_delete'), title: this.key('tip') },
* () => deleteApi({ id: row.id })
* )
* if (cancelled) return
* this.$message.success(this.$t(this.key('operation_success')))
* this.fetchData()
* }
* }
* }
*/
export const confirmMixin = {
methods: {
/**
* @param {Object} confirmOpts - { message, title, ...$confirm 其余参数 }
* @param {Function} action - 确认后执行的 async 函数
* @returns {Promise<boolean>} true = 已取消, false = 已执行
*/
async $confirmAction (confirmOpts, action) {
try {
await this.$confirm(
confirmOpts.message ? this.$t(confirmOpts.message) : '',
confirmOpts.title ? this.$t(confirmOpts.title) : '',
{
confirmButtonText: this.$t(confirmOpts.confirmButtonText || 'page.common.confirm'),
cancelButtonText: this.$t(confirmOpts.cancelButtonText || 'page.common.cancel'),
type: confirmOpts.type || 'warning',
closeOnClickModal: confirmOpts.closeOnClickModal !== false
}
)
} catch {
return true
}
try {
await action()
} catch {
// 拦截器已弹出 Message
}
return false
}
}
}
export default confirmMixin

View File

@@ -39,7 +39,8 @@ export function useTableButtons (options = {}, permissionCheck) {
auth: btn.auth,
confirm: btn.confirm || false,
onClick: btn.onClick,
hasPermission: btn.auth ? check(btn.auth) : true
hasPermission: btn.auth ? check(btn.auth) : true,
visible: btn.visible || (() => true)
}))
return { toolbarButtons, rowButtons }