fix(user-secret): 青果只用 Authkey/Authpwd,链接由前端拼并上报服务端
青果没有可填的提取链接(10-30 口径),但商标检测在服务端只认 proxy_url, 保存时又主动清空服务端记录 ⇒ 用户填了账密仍被判「未配置代理」。 - 新增 qingguo-link.ts(零依赖):由账密拼 overseas.proxy.qg.net/get 链接, Authkey/Authpwd 走 userinfo(隧道 Basic 认证没有第二个通道) - 保存时本地与服务端都用这条链接;已存账密的旧配置刷新后仍能读回 - 4 例纯函数用例钉住拼装规则与空 key 语义
This commit is contained in:
@@ -148,7 +148,9 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="proxy-plan-hint">
|
||||
青果用 Authkey / Authpwd 直连隧道代理,无需提取链接;账密只存在本机,不上报服务端。
|
||||
青果没有可填的提取链接:保存时用 Authkey / Authpwd 自动拼出
|
||||
<code>overseas.proxy.qg.net/get?key=…&format=json</code>(Basic 认证也带在同一条链接里),
|
||||
本地与后台密钥各存一份。服务端的商标检测用的就是这条链接,不填账密它会按「未配置代理」拦下任务。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -278,7 +280,12 @@ import {
|
||||
deleteMyApiSecret,
|
||||
putMyApiSecret,
|
||||
} from '@/shared/api/types/modules/user-secret'
|
||||
import { proxyUserId, readUserProxy, userProxyPatch } from '@/shared/utils/api-secret-proxy-config'
|
||||
import {
|
||||
composeQingguoLink,
|
||||
proxyUserId,
|
||||
readUserProxy,
|
||||
userProxyPatch,
|
||||
} from '@/shared/utils/api-secret-proxy-config'
|
||||
import { useProxyBalance, useProxyPlan } from '@/shared/composables/useProxyPlan'
|
||||
import { createModuleView, type ModuleState } from '@/shared/utils/api-secret-module-view'
|
||||
|
||||
@@ -605,7 +612,12 @@ async function saveAll(options: { requireAll?: boolean } = {}): Promise<boolean>
|
||||
if (!api?.save_config) throw new Error('当前客户端未提供代理配置保存能力')
|
||||
// 青果走账密直连隧道,不保存提取链接;切回极客时输入框里的旧值仍在
|
||||
const tunnelMode = proxyProvider.value === 'qingguo'
|
||||
const nextProxyUrl = tunnelMode ? '' : proxyUrl.value.trim()
|
||||
// 青果没有提取链接可填:由 Authkey/Authpwd 拼出来(2026-10-31 用户拍板)。
|
||||
// 本地与服务端用同一条链接——服务端商标检测(16890)只收得到 proxy_url,
|
||||
// 拼空串等于用户填了账密却仍被判「未配置代理」。
|
||||
const nextProxyUrl = tunnelMode
|
||||
? composeQingguoLink(proxyAccount.value, proxyPassword.value)
|
||||
: proxyUrl.value.trim()
|
||||
const nextProxyMode = tunnelMode ? 2 : proxyMode.value
|
||||
await api.save_config(
|
||||
userProxyPatch(nextProxyUrl, nextProxyMode, proxyProvider.value, proxyAccount.value, proxyPassword.value) as DesktopConfigUpdate,
|
||||
|
||||
@@ -27,7 +27,10 @@ export function readUserProxy(config: Record<string, unknown> | null | undefined
|
||||
const users = (config?.proxy_users ?? {}) as Record<string, unknown>
|
||||
const own = (users[uid] ?? {}) as Record<string, unknown>
|
||||
const ownUrl = typeof own.proxy_url === 'string' ? own.proxy_url.trim() : ''
|
||||
if (ownUrl) {
|
||||
// 青果只存账密时 proxy_url 是空串(2026-10-30 那版把链接去掉了),若只认 ownUrl,
|
||||
// 用户已填的 Authkey/Authpwd 会在刷新后「消失」、回退到全局代理。账密也算一份配置。
|
||||
const ownAccount = typeof own.proxy_account === 'string' ? own.proxy_account.trim() : ''
|
||||
if (ownUrl || ownAccount) {
|
||||
return {
|
||||
url: ownUrl,
|
||||
mode: Number(own.proxy_mode) === 2 ? 2 : 1,
|
||||
@@ -66,3 +69,9 @@ export function userProxyPatch(
|
||||
users[uid] = { proxy_url: nextProxyUrl, proxy_mode: nextProxyMode, proxy_provider: provider, ...credentials }
|
||||
return { proxy_users: users }
|
||||
}
|
||||
|
||||
/**
|
||||
* 青果链接拼装的唯一出处见 `./qingguo-link.ts`(零依赖模块,`node --test` 才能直接测它)。
|
||||
* 这里只做转出,避免调用方各记一条 URL 口径。
|
||||
*/
|
||||
export { QINGGUO_EXTRACT_URL, composeQingguoLink } from './qingguo-link'
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 青果提取链接的拼装(唯一出处)。
|
||||
*
|
||||
* 青果没有「提取链接」可给用户填:用户只给 Authkey / Authpwd,链接由这里拼
|
||||
* (2026-10-31 用户拍板)。口径:`https://overseas.proxy.qg.net/get?key=<Authkey>&format=json`。
|
||||
*
|
||||
* Authkey/Authpwd 额外放在 userinfo 里——青果返回的是隧道端点(`server: host:port`),
|
||||
* 连接它要做 Basic 认证,而服务端商标检测(16890)只收得到这一条 proxy_url,
|
||||
* 没有第二个传凭据的通道。空 Authkey 返回空串:没有 key 就没有可提取的东西,
|
||||
* 别拼一条必然失败的链接。
|
||||
*
|
||||
* ⚠ 本文件保持**零依赖**:`node --test` 不认 Vite 的 `@/` 别名,带别名的模块
|
||||
* 进不了 tests/*.test.ts,这条拼装规则就没法被用例钉住。
|
||||
*/
|
||||
export const QINGGUO_EXTRACT_URL = 'https://overseas.proxy.qg.net/get'
|
||||
|
||||
export function composeQingguoLink(account: string, password: string): string {
|
||||
const key = (account || '').trim()
|
||||
if (!key) return ''
|
||||
const userinfo = password
|
||||
? `${encodeURIComponent(key)}:${encodeURIComponent(password)}@`
|
||||
: ''
|
||||
const base = `${QINGGUO_EXTRACT_URL.replace('https://', `https://${userinfo}`)}`
|
||||
return `${base}?key=${encodeURIComponent(key)}&format=json`
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { composeQingguoLink, QINGGUO_EXTRACT_URL } from '../src/shared/utils/qingguo-link.ts'
|
||||
|
||||
/**
|
||||
* 青果没有「提取链接」可填,用户只给 Authkey/Authpwd,链接必须由前端拼出来
|
||||
* (2026-10-31 用户拍板)。拼不出来或拼错,用户就会在「填了账密」之后仍被
|
||||
* 商标检测的前置检查判成「未配置代理」——这正是 2026-10-31 用户报的那个问题。
|
||||
*/
|
||||
test('青果只有 Authkey 时拼出带 key 的提取链接', () => {
|
||||
const link = composeQingguoLink(' 40F79A90 ', '')
|
||||
assert.equal(link, `${QINGGUO_EXTRACT_URL}?key=40F79A90&format=json`)
|
||||
})
|
||||
|
||||
test('青果 Authkey+Authpwd 必须把账密放进 userinfo(隧道 Basic 认证没有第二个通道)', () => {
|
||||
const link = composeQingguoLink('40F79A90', 'Sec@ret:1')
|
||||
assert.ok(link.startsWith('https://40F79A90:Sec%40ret%3A1@overseas.proxy.qg.net/get?'), link)
|
||||
assert.ok(link.endsWith('&format=json'), link)
|
||||
})
|
||||
|
||||
test('没填 Authkey 就不拼链接(空串=没配置,不许拼一条必然失败的链接)', () => {
|
||||
assert.equal(composeQingguoLink('', 'pwd'), '')
|
||||
assert.equal(composeQingguoLink(' ', 'pwd'), '')
|
||||
})
|
||||
|
||||
test('key 里的特殊字符要编码,不能把查询串拼坏', () => {
|
||||
const link = composeQingguoLink('a&b=c', '')
|
||||
assert.ok(link.endsWith('?key=a%26b%3Dc&format=json'), link)
|
||||
})
|
||||
Reference in New Issue
Block a user