feat: 新增 ele OAuth 2.0 模块

This commit is contained in:
puhui999
2025-05-12 00:00:28 +08:00
parent 822a0a151b
commit 3093489423
5 changed files with 708 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
<script lang="ts" setup>
import type {
OnActionClickParams,
VxeTableGridOptions,
} from '#/adapter/vxe-table';
import type { SystemOAuth2TokenApi } from '#/api/system/oauth2/token';
import { 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 { DocAlert } from '#/components/doc-alert';
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', ['令牌']),
fullscreen: true,
});
try {
await deleteOAuth2Token(row.accessToken);
ElMessage.success($t('ui.actionMessage.operationSuccess'));
onRefresh();
} catch {
// 异常处理
} 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: { code: 'query' },
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>