fix(frontend): support cookie_bundle candidate in AuthCaptureDialog and refreshAuth
This commit is contained in:
@@ -169,9 +169,11 @@ function sameCandidate(a: AuthCaptureCandidate, b: AuthCaptureCandidate): boolea
|
||||
}
|
||||
|
||||
function resolveCandidateValue(candidate: AuthCaptureCandidate): string {
|
||||
return candidate.type === 'cookie'
|
||||
? (candidate.cookie_value || candidate.value || '')
|
||||
: (candidate.value || '')
|
||||
// cookie_bundle.value 已是完整 cookie 字符串;cookie.value 是 "name=value" 格式
|
||||
if (candidate.type === 'cookie') {
|
||||
return candidate.cookie_value || candidate.value || ''
|
||||
}
|
||||
return candidate.value || ''
|
||||
}
|
||||
|
||||
function resolveNewApiUser(rawResult: AuthCaptureResult, candidate: AuthCaptureCandidate): string | undefined {
|
||||
@@ -203,9 +205,13 @@ function resolveNewApiUser(rawResult: AuthCaptureResult, candidate: AuthCaptureC
|
||||
|
||||
function defaultCandidateIndex(candidates: AuthCaptureCandidate[]): number {
|
||||
if (candidates.length === 0) return -1
|
||||
const sessionCookie = candidates.findIndex((candidate) => candidate.type === 'cookie' && candidate.cookie_name === 'session')
|
||||
// 优先选完整 cookie bundle(包含 cf_clearance 等完整组合)
|
||||
const bundle = candidates.findIndex((c) => c.type === 'cookie_bundle')
|
||||
if (bundle >= 0) return bundle
|
||||
// 其次选 session cookie
|
||||
const sessionCookie = candidates.findIndex((c) => c.type === 'cookie' && c.cookie_name === 'session')
|
||||
if (sessionCookie >= 0) return sessionCookie
|
||||
const anyCookie = candidates.findIndex((candidate) => candidate.type === 'cookie')
|
||||
const anyCookie = candidates.findIndex((c) => c.type === 'cookie')
|
||||
if (anyCookie >= 0) return anyCookie
|
||||
return candidates.length === 1 ? 0 : -1
|
||||
}
|
||||
@@ -504,7 +510,13 @@ onUnmounted(() => {
|
||||
// ——— Helpers ———
|
||||
|
||||
function badgeLabel(type: string): string {
|
||||
return { bearer_token: 'Bearer', cookie: 'Cookie', api_key: 'API Key', credential: 'Key' }[type] || type
|
||||
return {
|
||||
bearer_token: 'Bearer',
|
||||
cookie: 'Cookie',
|
||||
cookie_bundle: '完整Cookie',
|
||||
api_key: 'API Key',
|
||||
credential: 'Key',
|
||||
}[type] || type
|
||||
}
|
||||
function confClass(s: number): string {
|
||||
return s >= 80 ? 'conf-high' : s >= 50 ? 'conf-mid' : 'conf-low'
|
||||
@@ -571,6 +583,7 @@ function maskValue(v: string): string {
|
||||
}
|
||||
.candidate-badge.bearer_token { background: #e6f7ff; color: #1890ff; }
|
||||
.candidate-badge.cookie { background: #fff7e6; color: #d48806; }
|
||||
.candidate-badge.cookie_bundle { background: #fff0d4; color: #b35c00; font-weight: 700; }
|
||||
.candidate-badge.api_key { background: #f0f5ff; color: #2f54eb; }
|
||||
.candidate-badge.credential { background: #f6ffed; color: #52c41a; }
|
||||
.candidate-label { font-size: 0.82rem; color: var(--el-text-color-secondary); }
|
||||
|
||||
Reference in New Issue
Block a user