优化和平小店兑换记录查询

This commit is contained in:
yml2213
2026-08-09 12:54:37 +08:00
parent 8919d020c5
commit 1cd94c0179
7 changed files with 396 additions and 842 deletions
+30 -245
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { ref } from 'vue'
import { useTheme } from '@/composables/useTheme'
import { useScheduler } from '@/composables/useScheduler'
import StatusGrid from '@/components/console/StatusGrid.vue'
@@ -19,157 +19,44 @@ const { runState, countdownSeconds, formatRemain } = useScheduler()
const settingsModalRef = ref<InstanceType<typeof SettingsModal> | null>(null)
const currentPage = ref<'console' | 'ck' | 'exchange'>('console')
const workspaceRef = ref<HTMLElement | null>(null)
const resizingWorkspace = ref(false)
const compactViewport = ref(false)
const storedWorkspaceRatio = Number(localStorage.getItem('accountPanelRatio'))
const accountPanelRatio = ref(
Number.isFinite(storedWorkspaceRatio) && storedWorkspaceRatio >= 0.55 && storedWorkspaceRatio <= 0.84
? storedWorkspaceRatio
: 0.76
)
const workspaceStyle = computed(() => ({
gridTemplateColumns: compactViewport.value
? '1fr'
: `minmax(0, ${accountPanelRatio.value}fr) 8px minmax(260px, ${1 - accountPanelRatio.value}fr)`
}))
const openSettings = () => {
settingsModalRef.value?.open()
}
const updateWorkspaceRatio = (clientX: number) => {
const workspace = workspaceRef.value
if (!workspace) return
const rect = workspace.getBoundingClientRect()
const next = (clientX - rect.left) / rect.width
accountPanelRatio.value = Math.max(0.55, Math.min(0.84, next))
}
const startWorkspaceResize = (event: PointerEvent) => {
if (window.matchMedia('(max-width: 1180px)').matches) return
resizingWorkspace.value = true
updateWorkspaceRatio(event.clientX)
document.body.classList.add('resizing-columns')
window.addEventListener('pointermove', handleWorkspacePointerMove)
window.addEventListener('pointerup', stopWorkspaceResize, { once: true })
}
const handleWorkspacePointerMove = (event: PointerEvent) => {
if (resizingWorkspace.value) updateWorkspaceRatio(event.clientX)
}
const stopWorkspaceResize = () => {
if (!resizingWorkspace.value) return
resizingWorkspace.value = false
localStorage.setItem('accountPanelRatio', String(accountPanelRatio.value))
document.body.classList.remove('resizing-columns')
window.removeEventListener('pointermove', handleWorkspacePointerMove)
}
const updateCompactViewport = () => {
compactViewport.value = window.matchMedia('(max-width: 1180px)').matches
}
onMounted(() => {
updateCompactViewport()
window.addEventListener('resize', updateCompactViewport)
window.addEventListener('pointerup', stopWorkspaceResize)
})
onUnmounted(() => {
stopWorkspaceResize()
window.removeEventListener('resize', updateCompactViewport)
window.removeEventListener('pointerup', stopWorkspaceResize)
})
</script>
<template>
<main class="right">
<!-- 顶部控制台头 -->
<header class="console-head">
<div class="headline">
<div class="nav-tabs">
<button
class="nav-tab"
:class="{ active: currentPage === 'console' }"
@click="currentPage = 'console'"
>
抢购控制台
</button>
<button
class="nav-tab"
:class="{ active: currentPage === 'ck' }"
@click="currentPage = 'ck'"
>
CK 管理
</button>
<button
class="nav-tab"
:class="{ active: currentPage === 'exchange' }"
@click="currentPage = 'exchange'"
>
兑换记录
</button>
<button class="nav-tab" :class="{ active: currentPage === 'console' }" @click="currentPage = 'console'">抢购控制台</button>
<button class="nav-tab" :class="{ active: currentPage === 'ck' }" @click="currentPage = 'ck'">CK 管理</button>
<button class="nav-tab" :class="{ active: currentPage === 'exchange' }" @click="currentPage = 'exchange'">兑换记录</button>
</div>
<span
v-if="currentPage === 'console'"
class="run-state"
:class="{ active: runState !== '等待操作' }"
:title="runState"
>
{{ runState }}
</span>
<span v-if="countdownSeconds > 0 && currentPage === 'console'" class="countdown-badge">
{{ formatRemain(countdownSeconds) }}
</span>
<span v-if="currentPage === 'console'" class="run-state" :class="{ active: runState !== '等待操作' }" :title="runState">{{ runState }}</span>
<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="btn btn-ghost icon-btn theme-toggle"
:title="theme === 'light' ? '切换到暗色' : '切换到亮色'"
:aria-label="theme === 'light' ? '切换到暗色' : '切换到亮色'"
@click="toggleTheme"
>
{{ theme === 'light' ? '☀' : '☾' }}
</button>
<button class="btn btn-ghost icon-btn theme-toggle" :title="theme === 'light' ? '切换到暗色' : '切换到亮色'" :aria-label="theme === 'light' ? '切换到暗色' : '切换到亮色'" @click="toggleTheme">{{ theme === 'light' ? '☀' : '☾' }}</button>
</div>
</header>
<!-- 抢购控制台页面 -->
<template v-if="currentPage === 'console'">
<!-- 状态指标 -->
<StatusGrid :server-time="serverTime" />
<!-- 操作条 -->
<ControlStrip />
<!-- 工作区 -->
<section ref="workspaceRef" class="workspace" :class="{ resizing: resizingWorkspace }" :style="workspaceStyle">
<section class="console-workspace">
<AccountTable />
<div
class="workspace-resizer"
role="separator"
aria-label="调整账号表和日志宽度"
@pointerdown="startWorkspaceResize"
></div>
<aside class="side-stack">
<LogPanel />
</aside>
</section>
<LogPanel />
</template>
<!-- CK管理页面 -->
<template v-else-if="currentPage === 'ck'">
<section class="ck-page">
<CKManager />
</section>
<section class="page-body"><CKManager /></section>
</template>
<!-- 兑换记录页面 -->
<template v-else-if="currentPage === 'exchange'">
<template v-else>
<ExchangeRecords />
</template>
</main>
@@ -196,152 +83,50 @@ onUnmounted(() => {
gap: 16px;
}
.headline {
display: flex;
align-items: center;
gap: 14px;
min-width: 0;
}
.headline-title {
font-size: 15px;
font-weight: 600;
color: var(--text-strong);
letter-spacing: -.01em;
}
.nav-tabs {
display: flex;
gap: 4px;
}
.headline, .top-actions, .nav-tabs { display: flex; align-items: center; }
.headline { gap: 14px; min-width: 0; }
.top-actions { gap: 6px; }
.nav-tabs { gap: 4px; }
.nav-tab {
height: 28px;
padding: 0 12px;
border-radius: var(--radius-sm);
border: 0;
border-radius: var(--radius-sm);
background: transparent;
color: var(--muted);
cursor: pointer;
font-size: 13px;
font-weight: 500;
transition: .12s;
}
.nav-tab:hover { color: var(--text-strong); background: var(--surface-2); }
.nav-tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-tab:hover {
color: var(--text-strong);
background: var(--surface-2);
}
.nav-tab.active {
background: var(--accent-soft);
color: var(--accent);
font-weight: 600;
}
.headline-meta {
font-size: 12px;
color: var(--muted);
margin-top: 2px;
}
.run-state {
max-width: 220px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: var(--muted);
background: var(--surface-2);
border: 1px solid var(--line);
border-radius: 999px;
padding: 4px 10px;
font-size: 12px;
font-weight: 500;
}
.run-state.active {
color: var(--accent);
background: var(--accent-soft);
border-color: var(--accent-border);
}
.top-actions {
display: flex;
align-items: center;
gap: 6px;
}
.countdown-badge {
.run-state, .countdown-badge {
display: inline-flex;
align-items: center;
padding: 4px 10px;
border: 1px solid var(--line);
border-radius: 999px;
background: var(--danger-soft);
color: var(--danger);
border: 1px solid var(--danger);
font-weight: 600;
font-size: 12px;
font-variant-numeric: tabular-nums;
font-weight: 500;
white-space: nowrap;
}
.run-state { max-width: 220px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); background: var(--surface-2); }
.run-state.active { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-border); }
.countdown-badge { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); font-variant-numeric: tabular-nums; }
.workspace {
display: grid;
grid-template-columns: minmax(0, 1fr) 8px minmax(260px, 1fr);
gap: 14px;
padding: 14px 20px 20px;
align-items: stretch;
.console-workspace {
flex: 1;
min-height: 0;
overflow: hidden;
padding: 14px 20px;
}
.workspace-resizer {
width: 8px;
min-height: 100%;
border-radius: 4px;
cursor: col-resize;
transition: background-color .12s ease;
}
.workspace-resizer:hover,
.workspace.resizing .workspace-resizer {
background: var(--accent-border);
}
:global(body.resizing-columns),
:global(body.resizing-columns *) {
cursor: col-resize !important;
user-select: none;
}
.side-stack {
display: flex;
flex-direction: column;
gap: 14px;
min-height: 0;
height: 100%;
}
.ck-page {
flex: 1;
overflow-y: auto;
min-height: 0;
}
.page-body { flex: 1; min-height: 0; overflow-y: auto; }
@media (max-width: 1180px) {
.right {
overflow: visible;
min-height: auto;
}
.workspace {
grid-template-columns: 1fr;
padding: 14px;
overflow: visible;
}
.workspace-resizer {
display: none;
}
.right { overflow: visible; min-height: auto; }
.console-workspace { min-height: 520px; padding: 14px; }
}
</style>