fix: resolve OAuth2 error details in user management

This commit is contained in:
aslost
2026-08-25 14:27:11 +08:00
parent 20e0167543
commit 7c7c077744
4 changed files with 48 additions and 12 deletions
+1
View File
@@ -30,6 +30,7 @@ const en = {
change: 'Change',
changePwdBtn: 'Change',
username: 'Username',
trustLevel: 'Level',
password: 'Password',
delAccount: 'Delete Account',
delAccountMsg: 'This will permanently delete your account and data. It cannot be reactivated',
+1
View File
@@ -30,6 +30,7 @@ const zh = {
change: '修改',
changePwdBtn: '修改密码',
username: '用户名',
trustLevel: '等级',
password: '密码',
delAccount: '删除账户',
delAccountMsg: '此操作将永久删除您的账户及其所有数据,无法恢复',
+44 -11
View File
@@ -45,9 +45,19 @@
<el-table-column show-overflow-tooltip :tooltip-formatter="tableRowFormatter" :label="$t('tabEmailAddress')"
:min-width="emailWidth">
<template #default="props">
<div style="display: flex;gap: 5px">
<div style="display: flex;gap: 5px;align-items: center">
<div class="email-row">{{ props.row.email }}</div>
<el-tag type="warning" v-if="props.row.username">L</el-tag>
<template v-if="oauthPlatform(props.row)">
<el-avatar v-if="oauthPlatform(props.row).iconType === 'image'"
:src="oauthPlatform(props.row).icon"
:size="16"
class="oauth-platform-icon"/>
<Icon v-else
:icon="oauthPlatform(props.row).icon"
width="16"
height="16"
class="oauth-platform-icon"/>
</template>
</div>
</template>
</el-table-column>
@@ -229,12 +239,12 @@
</el-dialog>
<el-dialog class="account-dialog" v-model="detailsShow" :title="t('userDetails')" >
<div class="details">
<div v-if="userDetails.username"><span class="details-item-title">LinuxDo:</span>
<el-avatar :src="userDetails.avatar" :size="30" class="linuxdo-avatar" />
<span style="margin: 0 10px">用户名{{userDetails.username}}</span>
<span>
等级<el-tag type="success">{{userDetails.trustLevel}}</el-tag>
</span>
<div v-if="userDetails.platform || userDetails.username" class="oauth-details">
<el-avatar :src="userDetails.avatar" :size="30" class="oauth-avatar"/>
<span>{{ $t('username') }}{{ userDetails.username }}</span>
<span v-if="userDetails.trustLevel != null">
{{ $t('trustLevel') }}<el-tag type="success">{{ userDetails.trustLevel }}</el-tag>
</span>
</div>
<div v-if="!sendNumShow"><span
class="details-item-title">{{ $t('tabSent') }}:</span>{{ userDetails.sendEmailCount }}
@@ -398,6 +408,19 @@ const {t, locale} = useI18n();
const roleStore = useRoleStore()
const userStore = useUserStore()
const settingStore = useSettingStore()
const oauthPlatformMap = {
google: { key: 'google', label: 'Google', icon: 'devicon:google', iconType: 'iconify' },
github: { key: 'github', label: 'GitHub', icon: 'codicon:github-inverted', iconType: 'iconify' },
linuxdo: { key: 'linuxdo', label: 'LinuxDo', icon: '/image/linuxdo.webp', iconType: 'image' },
}
function oauthPlatform(row) {
if (row?.platform && oauthPlatformMap[row.platform]) {
return oauthPlatformMap[row.platform]
}
// 旧数据可能只有 username、无 platform
if (row?.username) return oauthPlatformMap.linuxdo
return null
}
const filteredValue = ['normal', 'del']
const filters = [{text: t('active'), value: 'normal'}, {text: t('deleted'), value: 'del'}]
const preserveExpanded = ref(false)
@@ -1152,9 +1175,19 @@ function adjustWidth() {
}
}
:deep(.linuxdo-avatar) {
position: relative !important;
top: 10px;
.oauth-details {
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
}
:deep(.oauth-avatar) {
flex-shrink: 0;
}
:deep(.oauth-platform-icon) {
flex-shrink: 0;
}
.account-pagination {
+2 -1
View File
@@ -153,7 +153,8 @@ const userService = {
username: oauth.username,
trustLevel: oauth.trustLevel,
avatar: oauth.avatar,
name: oauth.name
name: oauth.name,
platform: oauth.platform
}).from(user).leftJoin(oauth, eq(oauth.userId, user.userId))
.where(and(...conditions));