Files
iot-device-management-frontend/apps/web-antd/src/views/system/oauth2/token/index.vue

99 lines
2.2 KiB
Vue
Raw Normal View History

2025-04-06 19:49:21 +08:00
<script lang="ts" setup>
2025-04-22 11:25:11 +08:00
import type {
OnActionClickParams,
VxeTableGridOptions,
} from '#/adapter/vxe-table';
2025-04-06 19:49:21 +08:00
import type { SystemOAuth2TokenApi } from '#/api/system/oauth2/token';
import { Page } from '@vben/common-ui';
2025-04-22 11:25:11 +08:00
2025-04-06 19:49:21 +08:00
import { message } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
2025-04-22 11:25:11 +08:00
import {
deleteOAuth2Token,
getOAuth2TokenPage,
} from '#/api/system/oauth2/token';
import { DocAlert } from '#/components/doc-alert';
import { $t } from '#/locales';
2025-04-06 19:49:21 +08:00
import { useGridColumns, useGridFormSchema } from './data';
/** 刷新表格 */
function onRefresh() {
gridApi.query();
}
/** 删除 OAuth2 令牌 */
2025-04-22 22:10:33 +08:00
async function onDelete(row: SystemOAuth2TokenApi.OAuth2Token) {
2025-04-06 19:49:21 +08:00
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', ['令牌']),
duration: 0,
key: 'action_process_msg',
});
try {
await deleteOAuth2Token(row.accessToken);
message.success({
content: $t('ui.actionMessage.operationSuccess'),
key: 'action_process_msg',
});
onRefresh();
2025-04-22 11:25:11 +08:00
} catch {
2025-04-06 19:49:21 +08:00
hideLoading();
}
}
/** 表格操作按钮的回调函数 */
function onActionClick({
code,
row,
2025-04-22 22:10:33 +08:00
}: OnActionClickParams<SystemOAuth2TokenApi.OAuth2Token>) {
2025-04-06 19:49:21 +08:00
switch (code) {
case 'delete': {
onDelete(row);
break;
}
}
}
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
2025-04-22 11:25:11 +08:00
schema: useGridFormSchema(),
2025-04-06 19:49:21 +08:00
},
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,
},
2025-04-22 22:10:33 +08:00
} as VxeTableGridOptions<SystemOAuth2TokenApi.OAuth2Token>,
2025-04-06 19:49:21 +08:00
});
</script>
<template>
<Page auto-content-height>
2025-04-22 11:25:11 +08:00
<DocAlert
title="OAuth 2.0SSO 单点登录)"
url="https://doc.iocoder.cn/oauth2/"
/>
2025-04-06 19:49:21 +08:00
<Grid table-title="令牌列表" />
</Page>
</template>