zhou zhou
2 天以前 50e95b985a72fcec4a93a2470e9efdfb2620148a
rsf-design/src/views/system/user-login/index.vue
@@ -27,15 +27,17 @@
  import { fetchGetUserLoginList } from '@/api/system-manage'
  import { useTable } from '@/hooks/core/useTable'
  import { ElTag } from 'element-plus'
  import { useI18n } from 'vue-i18n'
  import { createUserLoginApiParams, userLoginPaginationKey } from './userLoginTable.config'
  defineOptions({ name: 'UserLogin' })
  const { t } = useI18n()
  const LOGIN_TYPE_MAP = {
    0: { label: '登录成功', type: 'success' },
    1: { label: '登录失败', type: 'danger' },
    2: { label: '退出登录', type: 'info' },
    3: { label: 'token 续签', type: 'warning' }
    0: { labelKey: 'pages.system.userLogin.types.loginSuccess', type: 'success' },
    1: { labelKey: 'pages.system.userLogin.types.loginFailed', type: 'danger' },
    2: { labelKey: 'pages.system.userLogin.types.logout', type: 'info' },
    3: { labelKey: 'pages.system.userLogin.types.tokenRenew', type: 'warning' }
  }
  const initialSearchForm = {
@@ -49,41 +51,41 @@
  const searchItems = computed(() => [
    {
      label: 'Token',
      label: t('pages.system.userLogin.search.token'),
      key: 'token',
      type: 'input',
      props: {
        placeholder: '请输入 token',
        placeholder: t('pages.system.userLogin.search.tokenPlaceholder'),
        clearable: true
      }
    },
    {
      label: 'IP',
      label: t('pages.system.userLogin.search.ip'),
      key: 'ip',
      type: 'input',
      props: {
        placeholder: '请输入 IP',
        placeholder: t('pages.system.userLogin.search.ipPlaceholder'),
        clearable: true
      }
    },
    {
      label: '系统',
      label: t('pages.system.userLogin.search.system'),
      key: 'system',
      type: 'input',
      props: {
        placeholder: '请输入系统标识',
        placeholder: t('pages.system.userLogin.search.systemPlaceholder'),
        clearable: true
      }
    },
    {
      label: '类型',
      label: t('pages.system.userLogin.search.type'),
      key: 'type',
      type: 'select',
      props: {
        placeholder: '请选择类型',
        placeholder: t('pages.system.userLogin.search.typePlaceholder'),
        clearable: true,
        options: Object.entries(LOGIN_TYPE_MAP).map(([value, item]) => ({
          label: item.label,
          label: t(item.labelKey),
          value: Number(value)
        }))
      }
@@ -93,7 +95,7 @@
  const getLoginTypeConfig = (type) => {
    return (
      LOGIN_TYPE_MAP[type] || {
        label: type ?? '-',
        label: type ?? t('common.placeholder.empty'),
        type: 'info'
      }
    )
@@ -121,32 +123,32 @@
      apiParams: createUserLoginApiParams(searchForm.value),
      paginationKey: userLoginPaginationKey,
      columnsFactory: () => [
        { type: 'index', width: 60, label: '序号' },
        { prop: 'id', label: 'ID', minWidth: 90 },
        { type: 'index', width: 60, label: t('table.index') },
        { prop: 'id', label: t('table.id'), minWidth: 90 },
        {
          prop: 'userDisplayName',
          label: '用户',
          label: t('pages.system.userLogin.table.user'),
          minWidth: 140,
          formatter: (row) => getUserDisplayName(row)
        },
        { prop: 'token', label: 'Token', minWidth: 260, showOverflowTooltip: true },
        { prop: 'ip', label: 'IP', minWidth: 140 },
        { prop: 'token', label: t('pages.system.userLogin.table.token'), minWidth: 260, showOverflowTooltip: true },
        { prop: 'ip', label: t('pages.system.userLogin.table.ip'), minWidth: 140 },
        {
          prop: 'type',
          label: '类型',
          label: t('pages.system.userLogin.search.type'),
          width: 120,
          formatter: (row) => {
            const config = getLoginTypeConfig(row.type)
            return h(ElTag, { type: config.type }, () => config.label)
            return h(ElTag, { type: config.type }, () => config.labelKey ? t(config.labelKey) : config.label)
          }
        },
        { prop: 'system', label: '系统', minWidth: 140 },
        { prop: 'system', label: t('pages.system.userLogin.table.system'), minWidth: 140 },
        {
          prop: 'createTime',
          label: '创建时间',
          label: t('table.createTime'),
          minWidth: 180,
          sortable: true,
          formatter: (row) => row.createTime$ || row.createTime || '-'
          formatter: (row) => row.createTime$ || row.createTime || t('common.placeholder.empty')
        }
      ]
    }