feat(proxy): 增加代理池演练并修复账号密码提取,发布 0.5.1
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
import { computed, nextTick, ref } from 'vue'
|
||||
import { useSettings, type RetryStage } from '@/composables/useSettings'
|
||||
import { useToast } from '@/composables/useToast'
|
||||
import { TestProxy, FetchProxy } from '@wails/go/app/App'
|
||||
import { TestProxy, FetchProxy, RunProxyDrill } from '@wails/go/app/App'
|
||||
import { types } from '@wails/go/models'
|
||||
|
||||
const { settings, loadSettings, saveSettings } = useSettings()
|
||||
const { showToast } = useToast()
|
||||
@@ -36,6 +37,9 @@ const formData = ref({
|
||||
const testingProxy = ref(false)
|
||||
const testProxyResult = ref<{ success?: boolean; text?: string; error?: string } | null>(null)
|
||||
const fetchingProxy = ref(false)
|
||||
const drillAccounts = ref(30)
|
||||
const drillRunning = ref(false)
|
||||
const drillResult = ref<types.ProxyDrillResult | null>(null)
|
||||
|
||||
const proxyOverviewTitle = computed(() => (
|
||||
formData.value.proxyEnabled ? '代理已启用' : '代理未启用'
|
||||
@@ -127,6 +131,32 @@ const handleFetchProxy = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleProxyDrill = async () => {
|
||||
if (!formData.value.proxyApi.trim()) {
|
||||
showToast('无法演练', '请先填写代理提取 API', 'error')
|
||||
return
|
||||
}
|
||||
drillRunning.value = true
|
||||
drillResult.value = null
|
||||
try {
|
||||
const saved = await saveSettings(formData.value)
|
||||
if (!saved) return
|
||||
const res = await RunProxyDrill(types.ProxyDrillRequest.createFrom({
|
||||
simulatedAccounts: drillAccounts.value
|
||||
}))
|
||||
drillResult.value = res
|
||||
if (res.success) {
|
||||
showToast('演练通过', `活动代理 ${res.healthyActive}/${res.activeCount},备用代理 ${res.healthyStandby}/${res.standbyCount}`, 'success', 5000)
|
||||
} else {
|
||||
showToast('演练未通过', res.error || '部分活动代理未通过业务请求验证', 'error', 6000)
|
||||
}
|
||||
} catch (e: any) {
|
||||
showToast('演练失败', e.message || String(e), 'error')
|
||||
} finally {
|
||||
drillRunning.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const open = async (section = '') => {
|
||||
await loadSettings()
|
||||
formData.value = {
|
||||
@@ -134,6 +164,7 @@ const open = async (section = '') => {
|
||||
retryStages: settings.value.retryStages.map(s => ({ ...s }))
|
||||
}
|
||||
testProxyResult.value = null
|
||||
drillResult.value = null
|
||||
visible.value = true
|
||||
if (section === 'proxy') {
|
||||
await nextTick()
|
||||
@@ -301,7 +332,7 @@ defineExpose({ open, close })
|
||||
</button>
|
||||
</div>
|
||||
<div class="form-hint">
|
||||
品赞会自动识别并请求当前分组所需数量;账号密码模式请生成带 mode=auth 的 API,账号密码会写入代理 URL。注意:账号密码授权仍需先将执行提取的本机 IP 加入品赞白名单,白名单只用于提取 API。
|
||||
品赞会自动识别并请求当前分组所需数量;账号密码模式请生成带 mode=auth 的 API,程序会自动改用 JSON 以取得每个代理的账号密码。账号密码授权仍需先将执行提取的本机 IP 加入品赞白名单,白名单只用于提取 API。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -312,7 +343,79 @@ defineExpose({ open, close })
|
||||
<span class="checkbox-text">定时抢购触发前 30 秒自动预取并校验代理</span>
|
||||
</label>
|
||||
<div class="form-hint">
|
||||
仅对定时抢购生效。按“每组账号数”提取对应数量,先测斗鱼时间接口再启用;立即抢购会在开始前同步准备代理。建议使用 10 分钟以上时长,覆盖抢购与最长 180 秒支付。
|
||||
仅对定时抢购生效。按“每组账号数”提取对应数量并校验;立即抢购会在开始前同步准备代理。建议使用 10 分钟以上时长,覆盖抢购与最长 180 秒支付。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="proxy-drill">
|
||||
<div class="proxy-drill-head">
|
||||
<div>
|
||||
<div class="proxy-drill-title">代理池演练</div>
|
||||
<div class="form-hint">
|
||||
手册活动使用只读商品接口,和平小店使用轻量接口兜底;不读取 CK,不锁单、不支付、不消耗账号积分。演练会先保存当前设置。
|
||||
</div>
|
||||
</div>
|
||||
<div class="proxy-drill-actions">
|
||||
<label class="proxy-drill-account">
|
||||
<span>模拟账号</span>
|
||||
<input
|
||||
v-model.number="drillAccounts"
|
||||
class="form-input"
|
||||
type="number"
|
||||
min="1"
|
||||
max="200"
|
||||
step="1"
|
||||
>
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-action primary"
|
||||
:disabled="drillRunning || !formData.proxyApi.trim()"
|
||||
@click="handleProxyDrill"
|
||||
>
|
||||
{{ drillRunning ? '演练中...' : '开始演练' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="drillResult" class="proxy-drill-result">
|
||||
<div class="proxy-drill-summary" :class="{ success: drillResult.success, error: !drillResult.success }">
|
||||
<strong>{{ drillResult.success ? '演练通过' : '演练未通过' }}</strong>
|
||||
<span>
|
||||
{{ drillResult.simulatedAccounts }} 账号 →
|
||||
{{ drillResult.activeCount }} 活动 + {{ drillResult.standbyCount }} 备用
|
||||
</span>
|
||||
<span>健康:{{ drillResult.healthyActive }}/{{ drillResult.activeCount }} 活动,{{ drillResult.healthyStandby }}/{{ drillResult.standbyCount }} 备用</span>
|
||||
<span>耗时 {{ drillResult.durationMs }}ms</span>
|
||||
</div>
|
||||
<div v-if="drillResult.error" class="proxy-drill-error">{{ drillResult.error }}</div>
|
||||
<div class="proxy-drill-endpoint" :title="drillResult.endpoint">
|
||||
探测接口:{{ drillResult.endpoint }}
|
||||
</div>
|
||||
|
||||
<div class="proxy-drill-list">
|
||||
<div
|
||||
v-for="item in drillResult.items"
|
||||
:key="`${item.role}-${item.group}`"
|
||||
class="proxy-drill-item"
|
||||
:class="{ healthy: item.requests > 0 && item.success === item.requests }"
|
||||
>
|
||||
<div class="proxy-drill-item-head">
|
||||
<span class="proxy-drill-role" :class="{ standby: item.role === '备用代理' }">
|
||||
{{ item.role }} {{ item.group }}
|
||||
</span>
|
||||
<strong>{{ item.success }}/{{ item.requests }} 成功</strong>
|
||||
</div>
|
||||
<div class="proxy-drill-proxy" :title="item.proxy">{{ item.ip || item.proxy }}<span v-if="item.region"> · {{ item.region }}</span></div>
|
||||
<div class="proxy-drill-metrics">
|
||||
<span>平均 {{ item.avgLatencyMs }}ms</span>
|
||||
<span>最慢 {{ item.maxLatencyMs }}ms</span>
|
||||
<span>流量 {{ item.bytes }}B</span>
|
||||
<span v-if="item.provider">{{ item.provider }}</span>
|
||||
</div>
|
||||
<div v-if="item.error" class="proxy-drill-item-error">{{ item.error }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1054,6 +1157,152 @@ defineExpose({ open, close })
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.proxy-drill {
|
||||
margin: 14px 0;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--accent-border);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--accent-soft);
|
||||
}
|
||||
|
||||
.proxy-drill-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.proxy-drill-title {
|
||||
margin-bottom: 4px;
|
||||
color: var(--text-strong);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.proxy-drill-actions {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.proxy-drill-account {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.proxy-drill-account .form-input {
|
||||
width: 88px;
|
||||
}
|
||||
|
||||
.proxy-drill-result {
|
||||
margin-top: 12px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid var(--accent-border);
|
||||
}
|
||||
|
||||
.proxy-drill-summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px 12px;
|
||||
flex-wrap: wrap;
|
||||
font-size: 11.5px;
|
||||
}
|
||||
|
||||
.proxy-drill-summary strong {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.proxy-drill-summary.success strong {
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.proxy-drill-summary.error strong,
|
||||
.proxy-drill-error,
|
||||
.proxy-drill-item-error {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.proxy-drill-error {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.proxy-drill-endpoint {
|
||||
margin-top: 8px;
|
||||
overflow: hidden;
|
||||
color: var(--muted);
|
||||
font-size: 10.5px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.proxy-drill-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.proxy-drill-item {
|
||||
padding: 9px 10px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
.proxy-drill-item.healthy {
|
||||
border-color: var(--success);
|
||||
}
|
||||
|
||||
.proxy-drill-item-head,
|
||||
.proxy-drill-metrics {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.proxy-drill-item-head {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.proxy-drill-role {
|
||||
color: var(--accent);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.proxy-drill-role.standby {
|
||||
color: var(--warning);
|
||||
}
|
||||
|
||||
.proxy-drill-proxy {
|
||||
margin-top: 5px;
|
||||
overflow: hidden;
|
||||
color: var(--text-strong);
|
||||
font-size: 11.5px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.proxy-drill-metrics {
|
||||
justify-content: flex-start;
|
||||
margin-top: 5px;
|
||||
color: var(--muted);
|
||||
font-size: 10.5px;
|
||||
}
|
||||
|
||||
.proxy-drill-item-error {
|
||||
margin-top: 5px;
|
||||
font-size: 10.5px;
|
||||
line-height: 1.4;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.proxy-config-area {
|
||||
margin-top: 14px;
|
||||
padding: 14px;
|
||||
|
||||
Reference in New Issue
Block a user