feat: 完善代理池与抢购链路,发布 0.5.0
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useTheme } from '@/composables/useTheme'
|
||||
import { useScheduler } from '@/composables/useScheduler'
|
||||
import { useSettings } from '@/composables/useSettings'
|
||||
import StatusGrid from '@/components/console/StatusGrid.vue'
|
||||
import ControlStrip from '@/components/console/ControlStrip.vue'
|
||||
import AccountTable from '@/components/account/AccountTable.vue'
|
||||
@@ -16,13 +17,44 @@ defineProps<{
|
||||
|
||||
const { theme, toggleTheme } = useTheme()
|
||||
const { runState, countdownSeconds, formatRemain } = useScheduler()
|
||||
const { settings, loadSettings } = useSettings()
|
||||
|
||||
const settingsModalRef = ref<InstanceType<typeof SettingsModal> | null>(null)
|
||||
const currentPage = ref<'console' | 'ck' | 'exchange'>('console')
|
||||
|
||||
const openSettings = () => {
|
||||
settingsModalRef.value?.open()
|
||||
const proxyAutoFetchReady = computed(() => (
|
||||
settings.value.proxyEnabled
|
||||
&& settings.value.autoFetchProxyOnSchedule
|
||||
&& !!settings.value.proxyApi.trim()
|
||||
))
|
||||
|
||||
const proxyNeedsApi = computed(() => (
|
||||
settings.value.proxyEnabled
|
||||
&& settings.value.autoFetchProxyOnSchedule
|
||||
&& !settings.value.proxyApi.trim()
|
||||
))
|
||||
|
||||
const proxySummary = computed(() => {
|
||||
if (!settings.value.proxyEnabled) return '代理未启用'
|
||||
const size = settings.value.accountsPerProxy || 5
|
||||
const spare = settings.value.proxySparePercent || 25
|
||||
if (!settings.value.autoFetchProxyOnSchedule) return `代理 · ${size}号/组 · 备用${spare}%`
|
||||
if (!settings.value.proxyApi.trim()) return `代理 · ${size}号/组 · 缺少 API`
|
||||
return `代理 · ${size}号/组 · 备用${spare}% · 预取`
|
||||
})
|
||||
|
||||
const proxyTitle = computed(() => {
|
||||
if (!settings.value.proxyEnabled) return '代理尚未启用,点击配置'
|
||||
if (proxyNeedsApi.value) return '已开启定时预取,但缺少代理提取 API;点击配置'
|
||||
if (proxyAutoFetchReady.value) return '定时抢购触发前 30 秒自动提取并校验代理;点击查看设置'
|
||||
return '代理已启用,点击打开代理设置'
|
||||
})
|
||||
|
||||
const openSettings = (section = '') => {
|
||||
settingsModalRef.value?.open(section)
|
||||
}
|
||||
|
||||
onMounted(loadSettings)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -38,7 +70,22 @@ const openSettings = () => {
|
||||
<span v-if="countdownSeconds > 0 && currentPage === 'console'" class="countdown-badge">{{ formatRemain(countdownSeconds) }}</span>
|
||||
</div>
|
||||
<div class="top-actions">
|
||||
<button class="btn btn-ghost icon-btn" title="设置" aria-label="设置" @click="openSettings">⚙</button>
|
||||
<button
|
||||
class="proxy-quick"
|
||||
:class="{
|
||||
active: settings.proxyEnabled,
|
||||
scheduled: proxyAutoFetchReady,
|
||||
warning: proxyNeedsApi
|
||||
}"
|
||||
:title="proxyTitle"
|
||||
@click="openSettings('proxy')"
|
||||
>
|
||||
{{ proxySummary }}
|
||||
</button>
|
||||
<button class="btn btn-ghost settings-button" title="设置" aria-label="设置" @click="openSettings()">
|
||||
<span aria-hidden="true">⚙</span>
|
||||
<span>设置</span>
|
||||
</button>
|
||||
<button class="btn btn-ghost icon-btn theme-toggle" :title="theme === 'light' ? '切换到暗色' : '切换到亮色'" :aria-label="theme === 'light' ? '切换到暗色' : '切换到亮色'" @click="toggleTheme">{{ theme === 'light' ? '☀' : '☾' }}</button>
|
||||
</div>
|
||||
</header>
|
||||
@@ -88,6 +135,50 @@ const openSettings = () => {
|
||||
.top-actions { gap: 6px; }
|
||||
.nav-tabs { gap: 4px; }
|
||||
|
||||
.proxy-quick {
|
||||
height: 30px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 999px;
|
||||
background: var(--surface-2);
|
||||
color: var(--muted);
|
||||
cursor: pointer;
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.proxy-quick:hover {
|
||||
border-color: var(--accent-border);
|
||||
color: var(--text-strong);
|
||||
}
|
||||
|
||||
.proxy-quick.active {
|
||||
color: var(--success);
|
||||
border-color: var(--success);
|
||||
background: var(--success-soft);
|
||||
}
|
||||
|
||||
.proxy-quick.scheduled {
|
||||
color: var(--accent);
|
||||
border-color: var(--accent-border);
|
||||
background: var(--accent-soft);
|
||||
}
|
||||
|
||||
.proxy-quick.warning {
|
||||
color: var(--warning);
|
||||
border-color: var(--warning);
|
||||
background: var(--warning-soft);
|
||||
}
|
||||
|
||||
.settings-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
height: 30px;
|
||||
padding: 0 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.nav-tab {
|
||||
height: 28px;
|
||||
padding: 0 12px;
|
||||
@@ -129,4 +220,10 @@ const openSettings = () => {
|
||||
.right { overflow: visible; min-height: auto; }
|
||||
.console-workspace { min-height: 520px; padding: 14px; }
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.console-head { flex-wrap: wrap; }
|
||||
.top-actions { width: 100%; justify-content: flex-end; }
|
||||
.proxy-quick { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user