feat(user-secret): 代理设置只留账密,移除白名单与获取当前 IP 入口
青果改走 Authkey/Authpwd 直连隧道(不再要提取链接、模式锁账号密码), 极客同样去掉白名单区块与模式选择;useProxyWhitelist 随之删除。 后端 /client-ip 与白名单接口保留,供后续诊断用。
This commit is contained in:
@@ -84,7 +84,9 @@
|
||||
<div class="secret-card-desc">
|
||||
{{ proxyLocked
|
||||
? '代理由管理员统一配置并锁定,客户端不可修改或清空;如需变更请联系管理员。'
|
||||
: '供客户端任务连接代理服务,支持静态代理地址或代理服务商的提取链接。' }}
|
||||
: (proxyProvider === 'qingguo'
|
||||
? '青果用 Authkey / Authpwd 直连隧道代理,无需填写提取链接。'
|
||||
: '供客户端任务连接代理服务,支持静态代理地址或代理服务商的提取链接。') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -106,7 +108,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="proxy-field">
|
||||
<div v-if="proxyProvider !== 'qingguo'" class="proxy-field">
|
||||
<label class="field-label" for="proxy-url">代理地址</label>
|
||||
<input
|
||||
id="proxy-url"
|
||||
@@ -146,33 +148,13 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="proxy-plan-hint">
|
||||
青果通道提取返回的是隧道端点(如 tunpool-xxx.qg.net:16359),连接时要用这对账密做认证;只存在本机,不上报服务端。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="retention-block">
|
||||
<div class="field-label">代理模式</div>
|
||||
<div class="retention-options">
|
||||
<label
|
||||
v-for="option in proxyModeOptions"
|
||||
:key="option.value"
|
||||
class="retention-option"
|
||||
:class="{ 'retention-option--disabled': !proxyReady || busy || proxyLocked }"
|
||||
>
|
||||
<input
|
||||
v-model="proxyMode"
|
||||
type="radio"
|
||||
:value="option.value"
|
||||
:disabled="!proxyReady || busy || proxyLocked"
|
||||
@change="proxyDirty = true"
|
||||
/>
|
||||
<span>{{ option.label }}</span>
|
||||
</label>
|
||||
青果用 Authkey / Authpwd 直连隧道代理,无需提取链接;账密只存在本机,不上报服务端。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="proxySupported && proxyProvider === 'jikip'" class="retention-block">
|
||||
<div class="field-label">jikip 套餐信息(余量查询 / 白名单添加)</div>
|
||||
<div class="field-label">jikip 套餐信息(余量查询)
|
||||
</div>
|
||||
<div class="proxy-plan-row">
|
||||
<input
|
||||
v-model="proxyPlanId"
|
||||
@@ -224,59 +206,25 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="proxy-plan-hint">
|
||||
填写后,下方余量按你自己的 jikip 套餐查询;套餐 key 仅用于白名单添加,保存后只显示掩码,留空保存则保留已存值。套餐 ID / 用户 ID / key 在 jikip 后台「我的套餐」「账户信息」「套餐列表」查看。
|
||||
填写后,下方余量按你自己的 jikip 套餐查询;套餐 key 保存后只显示掩码,留空保存则保留已存值。套餐 ID / 用户 ID / key 在 jikip 后台「我的套餐」「账户信息」「套餐列表」查看。
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="proxySupported && proxyProvider === 'qingguo'" class="proxy-plan-hint">
|
||||
青果的账户余量与通道用量请到青果后台查看;本客户端目前只做青果提取链接的连通性检测。
|
||||
</div>
|
||||
|
||||
<div v-if="whitelistVisible" class="retention-block">
|
||||
<div class="field-label">白名单(把本机出口 IP 加到{{ whitelistProviderLabel }})</div>
|
||||
<div class="proxy-plan-row">
|
||||
<input
|
||||
v-model="whitelistIp"
|
||||
class="secret-input"
|
||||
type="text"
|
||||
placeholder="当前出口 IP,如 36.251.68.43"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
:disabled="whitelistAdding"
|
||||
@input="resetWhitelistStatus"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="check-btn"
|
||||
:disabled="whitelistFetching || whitelistAdding"
|
||||
@click="fetchCurrentIp"
|
||||
>
|
||||
{{ whitelistFetching ? '获取中...' : '获取当前 IP' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="secret-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="check-btn"
|
||||
:disabled="!whitelistReady || whitelistAdding"
|
||||
@click="addToWhitelist"
|
||||
>
|
||||
{{ whitelistAdding ? '加入中...' : '加入白名单' }}
|
||||
</button>
|
||||
<span v-if="whitelistStatusText" class="check-result" :class="whitelistResultClass">
|
||||
{{ whitelistStatusText }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="proxy-plan-hint">{{ whitelistHint }}</div>
|
||||
</div>
|
||||
|
||||
<div class="secret-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="check-btn"
|
||||
:disabled="!proxyReady || busy || proxyChecking"
|
||||
:disabled="!proxyReady || busy || proxyChecking || proxyProvider === 'qingguo'"
|
||||
@click="runProxyCheck"
|
||||
>
|
||||
{{ proxyChecking ? '检测中...' : (proxyUrl.trim() && proxyDirty ? '检测输入地址(未保存)' : '检测配置代理') }}
|
||||
{{ proxyChecking
|
||||
? '检测中...'
|
||||
: (proxyProvider === 'qingguo'
|
||||
? '青果账密直连,无需检测'
|
||||
: (proxyUrl.trim() && proxyDirty ? '检测输入地址(未保存)' : '检测配置代理')) }}
|
||||
</button>
|
||||
<span class="check-result" :class="proxyResultClass">
|
||||
{{ proxyStatusText }}
|
||||
@@ -331,7 +279,6 @@ import {
|
||||
putMyApiSecret,
|
||||
} from '@/shared/api/types/modules/user-secret'
|
||||
import { proxyUserId, readUserProxy, userProxyPatch } from '@/shared/utils/api-secret-proxy-config'
|
||||
import { useProxyWhitelist } from '@/shared/composables/useProxyWhitelist'
|
||||
import { useProxyBalance, useProxyPlan } from '@/shared/composables/useProxyPlan'
|
||||
import { createModuleView, type ModuleState } from '@/shared/utils/api-secret-module-view'
|
||||
|
||||
@@ -380,9 +327,6 @@ const proxyChecking = ref(false)
|
||||
const proxyCheckResult = ref<UserApiSecretCheckResult | null>(null)
|
||||
const proxyCheckError = ref('')
|
||||
|
||||
/** 套餐保存/清除后要清的白名单提示:套餐与白名单互相引用,用可变槽位解初始化顺序。 */
|
||||
const resetWhitelistSink: { fn: () => void } = { fn: () => {} }
|
||||
|
||||
const { balance, balanceLoading, balanceText, loadBalance } = useProxyBalance({ proxyProvider })
|
||||
const {
|
||||
proxyPlanId,
|
||||
@@ -397,42 +341,9 @@ const {
|
||||
loadProxyPlan,
|
||||
saveProxyPlanInfo,
|
||||
clearProxyPlanInfo,
|
||||
} = useProxyPlan({ proxyProvider, resetWhitelistStatus: () => resetWhitelistSink.fn(), loadBalance })
|
||||
} = useProxyPlan({ proxyProvider, resetWhitelistStatus: () => {}, loadBalance })
|
||||
|
||||
const whitelist = useProxyWhitelist({
|
||||
proxyReady,
|
||||
proxyProvider,
|
||||
proxyMode,
|
||||
proxyDirty,
|
||||
proxyUrl,
|
||||
proxyLocked,
|
||||
proxyPlanConfigured,
|
||||
proxyPlanKeyConfigured,
|
||||
syncProxyToServer,
|
||||
})
|
||||
const {
|
||||
whitelistIp,
|
||||
whitelistFetching,
|
||||
whitelistAdding,
|
||||
whitelistResult,
|
||||
whitelistError,
|
||||
whitelistVisible,
|
||||
whitelistProviderLabel,
|
||||
whitelistReady,
|
||||
whitelistHint,
|
||||
whitelistStatusText,
|
||||
whitelistResultClass,
|
||||
fetchCurrentIp,
|
||||
resetWhitelistStatus,
|
||||
addToWhitelist,
|
||||
} = whitelist
|
||||
resetWhitelistSink.fn = resetWhitelistStatus
|
||||
|
||||
const proxyPlaceholder = computed(() =>
|
||||
proxyProvider.value === 'qingguo'
|
||||
? 'https://overseas.proxy.qg.net/get?key=...&num=1&format=json'
|
||||
: 'https://api.jikip.com/ip-get?num=1&minute=3&key=... 或 http://user:pass@host:port',
|
||||
)
|
||||
const proxyPlaceholder = 'https://api.jikip.com/ip-get?num=1&minute=3&key=... 或 http://user:pass@host:port'
|
||||
|
||||
const proxyStatusText = computed(() => {
|
||||
if (proxyChecking.value) return '正在检测...'
|
||||
@@ -458,11 +369,11 @@ const proxyResultClass = computed(() => {
|
||||
function selectProxyProvider(provider: ProxyProviderKey) {
|
||||
if (proxyProvider.value === provider) return
|
||||
proxyProvider.value = provider
|
||||
// 青果只支持账号密码直连,模式随供应商锁死;切回极客再让用户自选
|
||||
if (provider === 'qingguo') proxyMode.value = 2
|
||||
proxyDirty.value = true
|
||||
proxyCheckResult.value = null
|
||||
proxyCheckError.value = ''
|
||||
whitelistResult.value = null
|
||||
whitelistError.value = ''
|
||||
}
|
||||
|
||||
|
||||
@@ -495,11 +406,6 @@ async function runProxyCheck() {
|
||||
}
|
||||
}
|
||||
|
||||
const proxyModeOptions: Array<{ value: ProxyMode; label: string }> = [
|
||||
{ value: 1, label: '白名单' },
|
||||
{ value: 2, label: '账号密码' },
|
||||
]
|
||||
|
||||
function ensureModuleState(moduleKey: string) {
|
||||
if (!moduleStates[moduleKey]) {
|
||||
moduleStates[moduleKey] = { input: '', checking: false, result: null, error: '', lastCheckSource: '' }
|
||||
@@ -621,6 +527,8 @@ async function loadProxyConfig() {
|
||||
proxyProvider.value = own.url
|
||||
? own.provider
|
||||
: normalizeProxyProvider(serverProxy.value?.channel ?? own.provider)
|
||||
// 青果只走账密认证,历史配置若停在白名单也强制拉回账号密码
|
||||
if (proxyProvider.value === 'qingguo') proxyMode.value = 2
|
||||
proxyReady.value = true
|
||||
} catch (error) {
|
||||
proxyLoadFailed.value = true
|
||||
@@ -695,11 +603,14 @@ async function saveAll(options: { requireAll?: boolean } = {}): Promise<boolean>
|
||||
if (props.showProxy && proxyReady.value && proxyDirty.value && !proxyLocked.value) {
|
||||
const api = getPywebviewApi()
|
||||
if (!api?.save_config) throw new Error('当前客户端未提供代理配置保存能力')
|
||||
const nextProxyUrl = proxyUrl.value.trim()
|
||||
// 青果走账密直连隧道,不保存提取链接;切回极客时输入框里的旧值仍在
|
||||
const tunnelMode = proxyProvider.value === 'qingguo'
|
||||
const nextProxyUrl = tunnelMode ? '' : proxyUrl.value.trim()
|
||||
const nextProxyMode = tunnelMode ? 2 : proxyMode.value
|
||||
await api.save_config(
|
||||
userProxyPatch(nextProxyUrl, proxyMode.value, proxyProvider.value, proxyAccount.value, proxyPassword.value) as DesktopConfigUpdate,
|
||||
userProxyPatch(nextProxyUrl, nextProxyMode, proxyProvider.value, proxyAccount.value, proxyPassword.value) as DesktopConfigUpdate,
|
||||
)
|
||||
proxyUrl.value = nextProxyUrl
|
||||
if (!tunnelMode) proxyUrl.value = nextProxyUrl
|
||||
proxyDirty.value = false
|
||||
// 同上:地址已保存,本地「未保存」的检测文案不再适用
|
||||
proxyCheckResult.value = null
|
||||
@@ -727,21 +638,8 @@ async function reload() {
|
||||
refreshSnapshots()
|
||||
}
|
||||
|
||||
watch(whitelistVisible, (visible) => {
|
||||
if (visible && !whitelistIp.value.trim()) {
|
||||
fetchCurrentIp()
|
||||
}
|
||||
})
|
||||
|
||||
watch(proxyMode, () => {
|
||||
whitelistResult.value = null
|
||||
whitelistError.value = ''
|
||||
})
|
||||
|
||||
watch(proxyProvider, (provider) => {
|
||||
whitelistResult.value = null
|
||||
whitelistError.value = ''
|
||||
// 切到极客时补拉套餐信息(含套餐 key 是否已配置),否则白名单按钮的可用态是旧的
|
||||
// 切到极客时补拉套餐信息(含套餐 key 是否已配置)
|
||||
if (provider === 'jikip' && proxySupported.value) {
|
||||
void loadProxyPlan()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user