fix(frontend): support cookie_bundle candidate in AuthCaptureDialog and refreshAuth
This commit is contained in:
@@ -540,6 +540,10 @@ async function refreshAuth() {
|
||||
const res = await customPagesApi.refreshAuth(page.value.id)
|
||||
if (res.data.success) {
|
||||
ElMessage.success(res.data.message || '凭证已刷新')
|
||||
// 宽松验证模式:凭证已写入但 API 调用失败时后端会返回 warning
|
||||
if (res.data.warning) {
|
||||
ElMessage.warning(res.data.warning)
|
||||
}
|
||||
} else {
|
||||
ElMessage.warning(res.data.message || '刷新失败')
|
||||
}
|
||||
|
||||
@@ -463,11 +463,28 @@ function openAuthCapture() {
|
||||
authCaptureVisible.value = true
|
||||
}
|
||||
|
||||
function handleAuthCaptureSelect(candidate: { type: string; value: string; cookie_name?: string; cookie_value?: string; new_api_user?: string }) {
|
||||
function handleAuthCaptureSelect(candidate: {
|
||||
type: string
|
||||
value: string
|
||||
cookie_name?: string
|
||||
cookie_value?: string
|
||||
cookie_count?: number
|
||||
cookie_names?: string[]
|
||||
new_api_user?: string
|
||||
}) {
|
||||
if (candidate.type === 'bearer_token') {
|
||||
form.value.auth_type = 'bearer'
|
||||
form.value.auth_config.token = candidate.value
|
||||
ElMessage.success('已填入 Bearer Token')
|
||||
} else if (candidate.type === 'cookie_bundle') {
|
||||
// 完整 cookie 组:value 已是完整 "name1=v1; name2=v2" 字符串
|
||||
form.value.auth_type = 'cookie'
|
||||
form.value.auth_config.cookie_string = candidate.value
|
||||
if (candidate.new_api_user) {
|
||||
form.value.auth_config.new_api_user = candidate.new_api_user
|
||||
}
|
||||
const countLabel = candidate.cookie_count ? `(${candidate.cookie_count} 个 cookie)` : ''
|
||||
ElMessage.success(`已填入完整 Cookie 组${countLabel}`)
|
||||
} else if (candidate.type === 'cookie') {
|
||||
form.value.auth_type = 'cookie'
|
||||
form.value.auth_config.cookie_string = candidate.cookie_name && candidate.cookie_value
|
||||
|
||||
Reference in New Issue
Block a user