v0.1.0: 新增CK管理功能

功能:
- 新增CK管理页面,支持复验抢购结果和整理账号文件
- 复验功能:查询斗鱼真实兑换记录,统计已抢到/未抢到的账号
- 整理CK功能:分离已抢到的账号到新文件,原文件只保留未抢到的
- 导出文件名优化:使用中文商品名+日期时间格式(如:user_已抢到_雪国2号_20260626_150405.txt)
- 复用左侧商品选择,统一数据源

接口:
- VerifyAndExport: 复验并统计
- ExportAccountsWithProduct: 导出账号(自动命名)
- OrganizeAccounts: 整理账号文件

版本: 0.1.0
This commit is contained in:
yml2213
2026-06-26 12:40:41 +08:00
parent 96b5afb756
commit 7f5da30698
7 changed files with 854 additions and 18 deletions
+523
View File
@@ -0,0 +1,523 @@
<script setup lang="ts">
import { ref, computed } from 'vue'
import { useProducts } from '@/composables/useProducts'
import { useToast } from '@/composables/useToast'
const { selectedProductId, selectedProductName, selectedProduct } = useProducts()
const { showToast } = useToast()
const App = window.go.main.App
// 状态
const loading = ref(false)
const verifyResult = ref<any>(null)
const organizeResult = ref<any>(null)
// 时间范围(默认一年)
const timeRange = ref<'year' | 'custom'>('year')
const customStart = ref('')
const customEnd = ref('')
// 计算时间戳
const timeRangeMs = computed(() => {
const now = Date.now()
if (timeRange.value === 'year') {
return {
start: Math.floor((now - 365 * 24 * 60 * 60 * 1000) / 1000),
end: Math.floor(now / 1000)
}
}
return {
start: customStart.value ? Math.floor(new Date(customStart.value).getTime() / 1000) : 0,
end: customEnd.value ? Math.floor(new Date(customEnd.value).getTime() / 1000) : Math.floor(now / 1000)
}
})
// 复验
const handleVerify = async () => {
if (!selectedProductId.value) {
showToast('提示', '请先在左侧选择商品', 'warn')
return
}
loading.value = true
try {
const result = await App.VerifyAndExport(selectedProductId.value)
verifyResult.value = result
organizeResult.value = null
if (result.success) {
showToast('复验完成', `已抢到: ${result.hitCount}, 未抢到: ${result.missCount}`, 'success')
} else {
showToast('复验失败', result.error, 'error')
}
} catch (e: any) {
showToast('复验失败', e.message, 'error')
} finally {
loading.value = false
}
}
// 导出已抢到的CK
const exportHitAccounts = async () => {
if (!verifyResult.value?.hitAccounts?.length || !selectedProductId.value) {
showToast('提示', '没有可导出的账号', 'warn')
return
}
try {
const result = await App.ExportAccountsWithProduct(
verifyResult.value.hitAccounts,
selectedProductId.value,
selectedProductName.value || ''
)
if (result.success) {
showToast('导出成功', `已导出 ${result.count} 个账号到 ${result.filePath}`, 'success')
} else {
showToast('导出失败', result.error, 'error')
}
} catch (e: any) {
showToast('导出失败', e.message, 'error')
}
}
// 整理CK
const handleOrganize = async () => {
if (!selectedProductId.value) {
showToast('提示', '请先在左侧选择商品', 'warn')
return
}
loading.value = true
try {
const { start, end } = timeRangeMs.value
const result = await App.OrganizeAccounts(selectedProductId.value, selectedProductName.value, start, end)
organizeResult.value = result
verifyResult.value = null
if (result.success) {
showToast('整理完成', `已抢到: ${result.hitCount}, 未抢到: ${result.missCount}`, 'success')
} else {
showToast('整理失败', result.error, 'error')
}
} catch (e: any) {
showToast('整理失败', e.message, 'error')
} finally {
loading.value = false
}
}
</script>
<template>
<div class="ck-manager">
<div class="ck-header">
<h2>CK 管理</h2>
<p class="ck-desc">复验抢购结果、整理账号文件</p>
</div>
<!-- 当前选中商品 -->
<div class="ck-section">
<div class="section-title">当前商品</div>
<div class="selected-product">
<template v-if="selectedProductId">
<span class="product-name">{{ selectedProductName }}</span>
<span class="product-meta">{{ selectedProduct?.score }}积分</span>
</template>
<span v-else class="product-empty">请在左侧商品列表中选择商品</span>
</div>
</div>
<!-- 操作按钮 -->
<div class="ck-actions">
<button
class="btn btn-primary"
:disabled="loading || !selectedProductId"
@click="handleVerify"
>
{{ loading ? '查询中...' : '🔍 复验抢购结果' }}
</button>
<button
class="btn btn-success"
:disabled="loading || !selectedProductId"
@click="handleOrganize"
>
{{ loading ? '整理中...' : '📋 整理CK' }}
</button>
</div>
<!-- 时间范围(整理CK时使用) -->
<div class="ck-section">
<div class="section-title">时间范围</div>
<div class="time-range">
<label class="radio-label">
<input v-model="timeRange" type="radio" value="year">
<span>最近一年(默认)</span>
</label>
<label class="radio-label">
<input v-model="timeRange" type="radio" value="custom">
<span>自定义</span>
</label>
</div>
<div v-if="timeRange === 'custom'" class="custom-time">
<input v-model="customStart" type="date" class="form-input" placeholder="开始日期">
<span class="time-sep">至</span>
<input v-model="customEnd" type="date" class="form-input" placeholder="结束日期">
</div>
</div>
<!-- 复验结果 -->
<div v-if="verifyResult" class="ck-result">
<div class="result-header">
<span class="result-title">复验结果</span>
<button
v-if="verifyResult.hitAccounts?.length"
class="btn btn-compact btn-export"
@click="exportHitAccounts"
>
📥 导出已抢到CK
</button>
</div>
<div class="result-stats">
<div class="stat-item stat-success">
<span class="stat-label">已抢到</span>
<span class="stat-value">{{ verifyResult.hitCount }}</span>
</div>
<div class="stat-item stat-fail">
<span class="stat-label">未抢到</span>
<span class="stat-value">{{ verifyResult.missCount }}</span>
</div>
</div>
<div v-if="verifyResult.hitAccounts?.length" class="account-list">
<div class="list-title">已抢到的账号:</div>
<div class="list-items">
<span
v-for="name in verifyResult.hitAccounts"
:key="name"
class="account-tag hit"
>
{{ name }}
</span>
</div>
</div>
</div>
<!-- 整理结果 -->
<div v-if="organizeResult" class="ck-result">
<div class="result-header">
<span class="result-title">整理结果</span>
</div>
<div class="result-stats">
<div class="stat-item stat-success">
<span class="stat-label">已抢到</span>
<span class="stat-value">{{ organizeResult.hitCount }}</span>
</div>
<div class="stat-item stat-fail">
<span class="stat-label">未抢到</span>
<span class="stat-value">{{ organizeResult.missCount }}</span>
</div>
</div>
<div class="result-info">
<div v-if="organizeResult.hitCount > 0" class="info-item success">
✅ 已抢到的账号已导出到新文件
</div>
<div class="info-item">
📄 原文件已更新,只保留未抢到的账号
</div>
</div>
</div>
</div>
</template>
<style scoped>
.ck-manager {
padding: 20px;
max-width: 800px;
}
.ck-header {
margin-bottom: 24px;
}
.ck-header h2 {
font-size: 18px;
font-weight: 600;
color: var(--text-strong);
margin-bottom: 4px;
}
.ck-desc {
font-size: 13px;
color: var(--muted);
}
.ck-section {
margin-bottom: 20px;
}
.section-title {
font-size: 13px;
font-weight: 600;
color: var(--text-strong);
margin-bottom: 8px;
}
.selected-product {
display: flex;
align-items: center;
gap: 12px;
padding: 10px 14px;
background: var(--field);
border: 1px solid var(--line);
border-radius: var(--radius-sm);
min-height: 36px;
}
.selected-product.has-product {
border-color: var(--accent-border);
background: var(--accent-soft);
}
.product-name {
font-weight: 600;
color: var(--text-strong);
}
.product-meta {
font-size: 12px;
color: var(--muted);
}
.product-empty {
color: var(--muted);
font-size: 13px;
}
.form-input {
width: 100%;
height: 36px;
padding: 0 12px;
background: var(--field);
color: var(--text-strong);
border: 1px solid var(--line);
border-radius: var(--radius-sm);
font-size: 13px;
}
.form-input:focus {
outline: 0;
border-color: var(--accent);
box-shadow: var(--focus);
}
.ck-actions {
display: flex;
gap: 12px;
margin-bottom: 20px;
}
.btn {
height: 36px;
padding: 0 16px;
border: 1px solid var(--line);
border-radius: var(--radius-sm);
background: var(--surface-2);
color: var(--text);
cursor: pointer;
font-size: 13px;
font-weight: 500;
transition: .12s;
display: inline-flex;
align-items: center;
gap: 6px;
}
.btn:hover {
background: var(--surface-3);
border-color: var(--line-strong);
}
.btn:disabled {
opacity: 0.6;
cursor: not-allowed;
}
.btn-primary {
background: var(--accent);
border-color: var(--accent);
color: #fff;
}
.btn-primary:hover {
filter: brightness(1.08);
}
.btn-success {
background: var(--success);
border-color: var(--success);
color: #fff;
}
.btn-success:hover {
filter: brightness(1.08);
}
.btn-compact {
height: 28px;
font-size: 12px;
padding: 0 10px;
}
.btn-export {
background: var(--accent-soft);
color: var(--accent);
border-color: var(--accent-border);
}
.btn-export:hover {
background: var(--accent);
color: #fff;
}
.time-range {
display: flex;
gap: 16px;
margin-bottom: 8px;
}
.radio-label {
display: flex;
align-items: center;
gap: 6px;
cursor: pointer;
font-size: 13px;
}
.radio-label input {
cursor: pointer;
}
.custom-time {
display: flex;
align-items: center;
gap: 8px;
}
.custom-time .form-input {
width: auto;
flex: 1;
}
.time-sep {
color: var(--muted);
}
.ck-result {
background: var(--surface);
border: 1px solid var(--line);
border-radius: var(--radius);
padding: 16px;
margin-top: 20px;
}
.result-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
}
.result-title {
font-size: 14px;
font-weight: 600;
color: var(--text-strong);
}
.result-stats {
display: flex;
gap: 16px;
margin-bottom: 16px;
}
.stat-item {
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
padding: 12px 20px;
background: var(--field);
border-radius: var(--radius-sm);
border: 1px solid var(--line);
min-width: 80px;
}
.stat-label {
font-size: 11px;
color: var(--muted);
text-transform: uppercase;
}
.stat-value {
font-size: 24px;
font-weight: 700;
font-variant-numeric: tabular-nums;
}
.stat-success .stat-value {
color: var(--success);
}
.stat-fail .stat-value {
color: var(--muted);
}
.account-list {
margin-top: 12px;
}
.list-title {
font-size: 12px;
color: var(--muted);
margin-bottom: 8px;
}
.list-items {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.account-tag {
display: inline-block;
padding: 2px 8px;
border-radius: 999px;
font-size: 11px;
background: var(--surface-2);
color: var(--text);
border: 1px solid var(--line);
}
.account-tag.hit {
background: var(--success-soft);
color: var(--success);
border-color: var(--success);
}
.result-info {
display: flex;
flex-direction: column;
gap: 8px;
}
.info-item {
font-size: 13px;
color: var(--text);
}
.info-item.success {
color: var(--success);
}
</style>
+74 -15
View File
@@ -7,6 +7,7 @@ import ControlStrip from '@/components/console/ControlStrip.vue'
import AccountTable from '@/components/account/AccountTable.vue'
import LogPanel from '@/components/log/LogPanel.vue'
import SettingsModal from '@/components/modal/SettingsModal.vue'
import CKManager from '@/components/ck/CKManager.vue'
defineProps<{
serverTime: string
@@ -16,6 +17,7 @@ const { theme, toggleTheme } = useTheme()
const { runState, countdownSeconds, formatRemain } = useScheduler()
const settingsModalRef = ref<InstanceType<typeof SettingsModal> | null>(null)
const currentPage = ref<'console' | 'ck'>('console')
const openSettings = () => {
settingsModalRef.value?.open()
@@ -27,11 +29,23 @@ const openSettings = () => {
<!-- 顶部控制台头 -->
<header class="console-head">
<div class="headline">
<div>
<div class="headline-title">抢购控制台</div>
<div class="headline-meta">{{ runState }}</div>
<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>
</div>
<span v-if="countdownSeconds > 0" class="countdown-badge">
<span v-if="countdownSeconds > 0 && currentPage === 'console'" class="countdown-badge">
{{ formatRemain(countdownSeconds) }}
</span>
</div>
@@ -48,19 +62,29 @@ const openSettings = () => {
</div>
</header>
<!-- 状态指标 -->
<StatusGrid :server-time="serverTime" />
<!-- 抢购控制台页面 -->
<template v-if="currentPage === 'console'">
<!-- 状态指标 -->
<StatusGrid :server-time="serverTime" />
<!-- 操作条 -->
<ControlStrip />
<!-- 操作条 -->
<ControlStrip />
<!-- 工作区 -->
<section class="workspace">
<AccountTable />
<aside class="side-stack">
<LogPanel />
</aside>
</section>
<!-- 工作区 -->
<section class="workspace">
<AccountTable />
<aside class="side-stack">
<LogPanel />
</aside>
</section>
</template>
<!-- CK管理页面 -->
<template v-else-if="currentPage === 'ck'">
<section class="ck-page">
<CKManager />
</section>
</template>
</main>
<SettingsModal ref="settingsModalRef" />
@@ -99,6 +123,35 @@ const openSettings = () => {
letter-spacing: -.01em;
}
.nav-tabs {
display: flex;
gap: 4px;
}
.nav-tab {
height: 28px;
padding: 0 12px;
border-radius: var(--radius-sm);
border: 0;
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;
}
.headline-meta {
font-size: 12px;
color: var(--muted);
@@ -143,6 +196,12 @@ const openSettings = () => {
height: 100%;
}
.ck-page {
flex: 1;
overflow-y: auto;
min-height: 0;
}
@media (max-width: 1180px) {
.right {
overflow: visible;