feat(proxy): 支持品赞分组代理与自动白名单

This commit is contained in:
yml
2026-11-19 23:42:56 +08:00
parent 61ea79c7c9
commit 44a5b6c883
24 changed files with 2253 additions and 315 deletions
@@ -22,7 +22,12 @@ const formData = ref({
proxyEnabled: false,
proxyUrl: '',
proxyApi: '',
autoFetchProxyOnSchedule: false
autoFetchProxyOnSchedule: false,
accountsPerProxy: 5,
proxyAutoWhitelist: false,
proxyWhitelistReplace: true,
proxyWhitelistPassword: '',
proxyWhitelistSignKey: ''
})
const testingProxy = ref(false)
@@ -73,7 +78,14 @@ const handleFetchProxy = async () => {
if (res.success && res.proxyUrl) {
formData.value.proxyUrl = res.proxyUrl
formData.value.proxyEnabled = true
showToast('提取成功', `已获取代理: ${res.proxyUrl} (${res.region || ''})`, 'success')
const expires = res.expiresAt
? new Date(res.expiresAt).toLocaleString()
: '未知'
showToast(
'提取成功',
`已获取代理: ${res.proxyUrl}${res.provider ? ' [' + res.provider + ']' : ''} (${res.region || ''},过期 ${expires})`,
'success'
)
// 自动触发一次连通性测速
handleTestProxy()
} else {
@@ -164,6 +176,21 @@ defineExpose({ open, close })
</div>
<div v-if="formData.proxyEnabled" class="proxy-config-area">
<div class="form-group">
<label class="form-label">每个代理账号数</label>
<input
v-model.number="formData.accountsPerProxy"
class="form-input"
type="number"
min="1"
max="100"
step="1"
>
<div class="form-hint">
例如填 5:30 个账号会稳定分成 6 组,每组使用独立代理连接池;定时抢购会按组分别提取并校验代理。
</div>
</div>
<!-- 静态/当前代理 -->
<div class="form-group">
<label class="form-label">当前代理地址 (IP:端口 或 隧道)</label>
@@ -194,13 +221,13 @@ defineExpose({ open, close })
<!-- 代理提取 API -->
<div class="form-group">
<label class="form-label">代理 API 提取链接 (星空/快代理/品赞等动态 IP)</label>
<label class="form-label">代理 API 提取链接 (品赞 / 通用动态 IP)</label>
<div class="input-with-button">
<input
v-model="formData.proxyApi"
class="form-input"
type="text"
placeholder="粘贴代理平台的提取 URL,例如 http://api2.xkdaili.com/tools/XApi.ashx?..."
placeholder="粘贴品赞 core-extract 或其它代理平台提取 URL"
>
<button
type="button"
@@ -212,17 +239,61 @@ defineExpose({ open, close })
<span v-else>🔄 提取并填入</span>
</button>
</div>
<div class="form-hint">支持返回 JSON 或纯文本格式的代理 API,点击后自动拉取并填入上方地址</div>
<div class="form-hint">
品赞会自动识别并请求当前分组所需数量;账号密码模式请生成带 mode=auth 的 API,账号密码会写入代理 URL。注意:账号密码授权仍需先将执行提取的本机 IP 加入品赞白名单,白名单只用于提取 API。
</div>
</div>
<!-- 定时抢购前自动拉取最新代理 -->
<div class="form-group">
<label class="checkbox-row">
<input v-model="formData.autoFetchProxyOnSchedule" type="checkbox">
<span class="checkbox-text">定时任务触发前 15 秒自动提取最新 IP</span>
<span class="checkbox-text">定时任务触发前 30 秒自动提取并校验分组 IP</span>
</label>
<div class="form-hint">适用于 3~5 分钟短效代理:定时抢购触发前自动刷新 IP,确保开抢时代理不过期且连接最新</div>
<div class="form-hint">
按“每组账号数”提取对应数量的代理,先测斗鱼时间接口再启用;建议使用 10 分钟以上时长,覆盖抢购与最长 180 秒支付。
</div>
</div>
<div class="form-group">
<label class="checkbox-row">
<input v-model="formData.proxyAutoWhitelist" type="checkbox">
<span class="checkbox-text">提取前自动添加本机公网 IP 白名单</span>
</label>
<div class="form-hint">
先探测一次提取,从品赞返回中读取它实际看到的来源 IP,再自动校验/添加白名单;需要填写品赞登录密码和账号安全页的签名密钥。
</div>
</div>
<template v-if="formData.proxyAutoWhitelist">
<div class="form-group">
<label class="form-label">品赞登录密码</label>
<input
v-model="formData.proxyWhitelistPassword"
class="form-input"
type="password"
autocomplete="off"
placeholder="仅用于本地生成白名单签名"
>
</div>
<div class="form-group">
<label class="form-label">白名单 AES 签名密钥</label>
<input
v-model="formData.proxyWhitelistSignKey"
class="form-input"
type="password"
autocomplete="off"
placeholder="品赞账号安全页显示的签名密钥"
>
<div class="form-hint">密钥保存在本实例配置中,不会写入日志。</div>
</div>
<div class="form-group">
<label class="checkbox-row">
<input v-model="formData.proxyWhitelistReplace" type="checkbox">
<span class="checkbox-text">白名单已满时替换最早添加的 IP</span>
</label>
</div>
</template>
</div>
</div>