fix(admin-spa): 完善账户管理代理信息显示功能

- 修复账户列表中代理信息显示,支持用户名密码部分隐藏
- 修复编辑账户时自动勾选代理设置并正确显示代理信息
- 改进代理密码输入框使用密码类型
- 将 admin-spa/dist 目录加入 .gitignore 并从版本控制中移除

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
shaw
2025-07-29 15:48:16 +08:00
parent 5795e8cdef
commit ff6a361720
35 changed files with 67 additions and 179 deletions

View File

@@ -434,6 +434,28 @@ const show = ref(true)
const oauthStep = ref(1)
const loading = ref(false)
// 初始化代理配置
const initProxyConfig = () => {
if (props.account?.proxy && props.account.proxy.host && props.account.proxy.port) {
return {
enabled: true,
type: props.account.proxy.type || 'socks5',
host: props.account.proxy.host,
port: props.account.proxy.port,
username: props.account.proxy.username || '',
password: props.account.proxy.password || ''
}
}
return {
enabled: false,
type: 'socks5',
host: '',
port: '',
username: '',
password: ''
}
}
// 表单数据
const form = ref({
platform: props.account?.platform || 'claude',
@@ -444,14 +466,7 @@ const form = ref({
projectId: props.account?.projectId || '',
accessToken: '',
refreshToken: '',
proxy: props.account?.proxy || {
enabled: false,
type: 'socks5',
host: '',
port: '',
username: '',
password: ''
}
proxy: initProxyConfig()
})
// 表单验证错误
@@ -737,6 +752,25 @@ watch(() => form.value.accessToken, () => {
// 监听账户变化,更新表单
watch(() => props.account, (newAccount) => {
if (newAccount) {
// 重新初始化代理配置
const proxyConfig = newAccount.proxy && newAccount.proxy.host && newAccount.proxy.port
? {
enabled: true,
type: newAccount.proxy.type || 'socks5',
host: newAccount.proxy.host,
port: newAccount.proxy.port,
username: newAccount.proxy.username || '',
password: newAccount.proxy.password || ''
}
: {
enabled: false,
type: 'socks5',
host: '',
port: '',
username: '',
password: ''
}
form.value = {
platform: newAccount.platform,
addType: 'oauth',
@@ -746,14 +780,7 @@ watch(() => props.account, (newAccount) => {
projectId: newAccount.projectId || '',
accessToken: '',
refreshToken: '',
proxy: newAccount.proxy || {
enabled: false,
type: 'socks5',
host: '',
port: '',
username: '',
password: ''
}
proxy: proxyConfig
}
}
}, { immediate: true })

View File

@@ -130,8 +130,8 @@
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
<div v-if="account.proxy" class="text-xs bg-blue-50 px-2 py-1 rounded">
{{ account.proxy.type }}://{{ account.proxy.host }}:{{ account.proxy.port }}
<div v-if="formatProxyDisplay(account.proxy)" class="text-xs bg-blue-50 px-2 py-1 rounded font-mono">
{{ formatProxyDisplay(account.proxy) }}
</div>
<div v-else class="text-gray-400">无代理</div>
</td>
@@ -403,6 +403,24 @@ const loadApiKeys = async () => {
}
}
// 格式化代理信息显示
const formatProxyDisplay = (proxy) => {
if (!proxy || !proxy.host || !proxy.port) return null
let display = `${proxy.type}://${proxy.host}:${proxy.port}`
// 如果有用户名密码,添加认证信息(部分隐藏)
if (proxy.username) {
const maskedUsername = proxy.username.length > 2
? proxy.username[0] + '***' + proxy.username[proxy.username.length - 1]
: '***'
const maskedPassword = proxy.password ? '****' : ''
display = `${proxy.type}://${maskedUsername}:${maskedPassword}@${proxy.host}:${proxy.port}`
}
return display
}
// 格式化会话窗口时间
const formatSessionWindow = (windowStart, windowEnd) => {
if (!windowStart || !windowEnd) return '--'