index.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <ContentWrap>
  3. <!-- 列表 -->
  4. <XTable @register="registerTable">
  5. <template #actionbtns_default="{ row }">
  6. <!-- 操作:详情 -->
  7. <XTextButton preIcon="ep:view" :title="t('action.detail')" @click="handleDetail(row)" />
  8. <!-- 操作:登出 -->
  9. <XTextButton
  10. preIcon="ep:delete"
  11. :title="t('action.logout')"
  12. v-hasPermi="['system:oauth2-token:delete']"
  13. @click="handleForceLogout(row.accessToken)"
  14. />
  15. </template>
  16. </XTable>
  17. </ContentWrap>
  18. <XModal v-model="dialogVisible" :title="dialogTitle">
  19. <!-- 对话框(详情) -->
  20. <Descriptions :schema="allSchemas.detailSchema" :data="detailData" />
  21. <!-- 操作按钮 -->
  22. <template #footer>
  23. <XButton :title="t('dialog.close')" @click="dialogVisible = false" />
  24. </template>
  25. </XModal>
  26. </template>
  27. <script setup lang="ts" name="SystemTokenClient">
  28. import { allSchemas } from './token.data'
  29. import * as TokenApi from '@/api/system/oauth2/token'
  30. const { t } = useI18n() // 国际化
  31. const message = useMessage() // 消息弹窗
  32. // 列表相关的变量
  33. const [registerTable, { reload }] = useXTable({
  34. allSchemas: allSchemas,
  35. topActionSlots: false,
  36. getListApi: TokenApi.getAccessTokenPageApi
  37. })
  38. // ========== 详情相关 ==========
  39. const detailData = ref() // 详情 Ref
  40. const dialogVisible = ref(false) // 是否显示弹出层
  41. const dialogTitle = ref(t('action.detail')) // 弹出层标题
  42. // 详情
  43. const handleDetail = async (row: TokenApi.OAuth2TokenVO) => {
  44. // 设置数据
  45. detailData.value = row
  46. dialogVisible.value = true
  47. }
  48. // 强退操作
  49. const handleForceLogout = (accessToken: string) => {
  50. message
  51. .confirm('是否要强制退出用户')
  52. .then(async () => {
  53. await TokenApi.deleteAccessTokenApi(accessToken)
  54. message.success(t('common.success'))
  55. })
  56. .finally(async () => {
  57. // 刷新列表
  58. await reload()
  59. })
  60. }
  61. </script>