Files
yudao-ui-admin-vben/apps/web-ele/src/views/system/oauth2/token/index.vue
lrl 38daaa2934 refactor: (web-ele)优化多个组件的删除操作和确认逻辑
- 将 ElMessageBox 替换为自定义 confirm 函数- 添加全局 loading 功能
- 优化错误处理和消息提示- 调整部分组件属性和样式
2025-08-01 13:56:55 +08:00

96 lines
2.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script lang="ts" setup>
import type {
OnActionClickParams,
VxeTableGridOptions,
} from '#/adapter/vxe-table';
import type { SystemOAuth2TokenApi } from '#/api/system/oauth2/token';
import { DocAlert, Page } from '@vben/common-ui';
import { ElLoading, ElMessage } from 'element-plus';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import {
deleteOAuth2Token,
getOAuth2TokenPage,
} from '#/api/system/oauth2/token';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
/** 刷新表格 */
function onRefresh() {
gridApi.query();
}
/** 删除 OAuth2 令牌 */
async function onDelete(row: SystemOAuth2TokenApi.OAuth2Token) {
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting', [row.accessToken]),
fullscreen: true,
});
try {
await deleteOAuth2Token(row.accessToken);
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.accessToken]));
onRefresh();
} finally {
loadingInstance.close();
}
}
/** 表格操作按钮的回调函数 */
function onActionClick({
code,
row,
}: OnActionClickParams<SystemOAuth2TokenApi.OAuth2Token>) {
switch (code) {
case 'delete': {
onDelete(row);
break;
}
}
}
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
},
gridOptions: {
columns: useGridColumns(onActionClick),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getOAuth2TokenPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<SystemOAuth2TokenApi.OAuth2Token>,
});
</script>
<template>
<Page auto-content-height>
<template #doc>
<DocAlert
title="OAuth 2.0SSO 单点登录)"
url="https://doc.iocoder.cn/oauth2/"
/>
</template>
<Grid table-title="令牌列表" />
</Page>
</template>