upload
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>美团酒店任务看板</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
Generated
+2529
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "hotel-dashboard",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vue-tsc -b && vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fontsource/zcool-kuaile": "^5.3.0",
|
||||
"@fontsource/zcool-qingke-huangyou": "^5.3.0",
|
||||
"@vueuse/motion": "^3.0.3",
|
||||
"axios": "^1.19.0",
|
||||
"dayjs": "^1.11.21",
|
||||
"echarts": "^6.1.0",
|
||||
"element-plus": "^2.14.4",
|
||||
"lucide-vue-next": "^1.0.0",
|
||||
"pinia": "^4.0.2",
|
||||
"vue": "^3.5.40",
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.13.3",
|
||||
"@vitejs/plugin-vue": "^6.0.8",
|
||||
"@vue/tsconfig": "^0.9.1",
|
||||
"typescript": "~6.0.2",
|
||||
"vite": "^8.2.0",
|
||||
"vue-tsc": "^3.3.8"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<!-- 手绘涂鸦风 favicon:便签纸 + 黄色高亮 + 红色手绘勾 -->
|
||||
<path d="M10 8 C 22 5, 42 6, 54 9 C 60 11, 60 14, 60 18 L 60 46 C 60 52, 56 58, 48 59 C 36 61, 18 60, 12 57 C 6 55, 5 50, 5 44 L 5 18 C 5 12, 8 9, 10 8 Z" fill="#fffdf5" stroke="#33302a" stroke-width="3.5" stroke-linejoin="round"/>
|
||||
<path d="M16 41 L 48 41" stroke="#ffcf4d" stroke-width="9" stroke-linecap="round" opacity="0.85"/>
|
||||
<path d="M20 34 C 24 40, 26 42, 30 44 C 36 38, 42 28, 46 22" fill="none" stroke="#e0402c" stroke-width="5" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 617 B |
@@ -0,0 +1,24 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<symbol id="bluesky-icon" viewBox="0 0 16 17">
|
||||
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
|
||||
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
|
||||
</symbol>
|
||||
<symbol id="discord-icon" viewBox="0 0 20 19">
|
||||
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
|
||||
</symbol>
|
||||
<symbol id="documentation-icon" viewBox="0 0 21 20">
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
|
||||
</symbol>
|
||||
<symbol id="github-icon" viewBox="0 0 19 19">
|
||||
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
|
||||
</symbol>
|
||||
<symbol id="social-icon" viewBox="0 0 20 20">
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
|
||||
</symbol>
|
||||
<symbol id="x-icon" viewBox="0 0 19 19">
|
||||
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
|
||||
</symbol>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
@@ -0,0 +1,94 @@
|
||||
<script setup lang="ts">
|
||||
/** 应用外壳:顶栏 + 两页切换(账号池 / 查询)+ 自动刷新(不再展示健康度条) */
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import FilterBar from './components/FilterBar.vue'
|
||||
import NavTabs, { type NavKey } from './components/NavTabs.vue'
|
||||
import AccountsView from './views/AccountsView.vue'
|
||||
import QueryView from './views/QueryView.vue'
|
||||
import api from './api'
|
||||
import { useAutoRefresh } from './composables/useAutoRefresh'
|
||||
import { useHotelStore } from './stores/hotel'
|
||||
|
||||
const store = useHotelStore()
|
||||
const { autoRefresh, tick } = storeToRefs(store)
|
||||
|
||||
const activeTab = ref<NavKey>('accounts')
|
||||
const bootError = ref('')
|
||||
|
||||
const views: Record<NavKey, unknown> = {
|
||||
accounts: AccountsView,
|
||||
query: QueryView,
|
||||
}
|
||||
const currentView = computed(() => views[activeTab.value])
|
||||
|
||||
const { refreshNow } = useAutoRefresh(15000, autoRefresh, tick)
|
||||
|
||||
async function pingBackend() {
|
||||
try {
|
||||
const h = await api.health()
|
||||
bootError.value =
|
||||
h.db_main === 'up' && h.db_headers === 'up' ? '' : `数据库未连通(主库 ${h.db_main} / 抓包库 ${h.db_headers})`
|
||||
} catch (e) {
|
||||
bootError.value = `后端不可用:${(e as Error).message}`
|
||||
}
|
||||
}
|
||||
|
||||
watch(tick, pingBackend)
|
||||
|
||||
onMounted(async () => {
|
||||
await store.loadMeta()
|
||||
await pingBackend()
|
||||
|
||||
const mq = window.matchMedia('(prefers-reduced-motion: reduce)')
|
||||
const apply = () => document.documentElement.classList.toggle('reduced-motion', mq.matches)
|
||||
apply()
|
||||
mq.addEventListener('change', apply)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="app">
|
||||
<FilterBar @refresh="refreshNow">
|
||||
<template #nav>
|
||||
<NavTabs v-model="activeTab" />
|
||||
</template>
|
||||
</FilterBar>
|
||||
|
||||
<div v-if="bootError" class="app__error">{{ bootError }}</div>
|
||||
|
||||
<main class="app__main">
|
||||
<KeepAlive>
|
||||
<component :is="currentView" :key="activeTab" />
|
||||
</KeepAlive>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.app {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
min-height: 560px;
|
||||
background: var(--bg-page);
|
||||
}
|
||||
.app__main {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
width: 100%;
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
padding: 14px 24px 18px;
|
||||
}
|
||||
.app__error {
|
||||
max-width: 1400px;
|
||||
margin: 8px auto 0;
|
||||
padding: 8px 14px;
|
||||
font-size: 13px;
|
||||
color: var(--accent);
|
||||
background: rgba(224, 64, 44, 0.08);
|
||||
border: 1px solid var(--accent);
|
||||
border-radius: var(--radius-element);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,99 @@
|
||||
/** Axios 封装:统一解包 {code,msg,data},code!=0 或网络错误统一抛 Error(msg) */
|
||||
import axios from 'axios'
|
||||
import type {
|
||||
AccountItem,
|
||||
AccountStatsItem,
|
||||
AlertsData,
|
||||
AuditItem,
|
||||
CityFailures,
|
||||
CityStatsItem,
|
||||
CollectorStatus,
|
||||
MetaData,
|
||||
OverviewData,
|
||||
PageData,
|
||||
PlatformAllData,
|
||||
PlatformStats,
|
||||
RecordDetail,
|
||||
RecordItem,
|
||||
RiskData,
|
||||
TaskItem,
|
||||
TrendItem,
|
||||
} from './types'
|
||||
|
||||
const http = axios.create({ baseURL: '/api', timeout: 30000 })
|
||||
|
||||
http.interceptors.response.use(
|
||||
(res) => {
|
||||
const body = res.data
|
||||
if (body && typeof body.code === 'number' && body.code !== 0) {
|
||||
return Promise.reject(new Error(body.msg || '请求失败'))
|
||||
}
|
||||
return body?.data
|
||||
},
|
||||
(err) => {
|
||||
const msg = err?.response?.data?.msg || err?.message || '网络错误'
|
||||
return Promise.reject(new Error(msg))
|
||||
},
|
||||
)
|
||||
|
||||
export interface AccountQuery {
|
||||
date?: string
|
||||
city?: string
|
||||
status?: string[]
|
||||
keyword?: string
|
||||
page?: number
|
||||
size?: number
|
||||
sort?: string
|
||||
order?: 'asc' | 'desc'
|
||||
}
|
||||
|
||||
export const api = {
|
||||
health: () => http.get<never, { db_main: string; db_headers: string; log_dir: string; log_writable: boolean }>('/health'),
|
||||
meta: () => http.get<never, MetaData>('/hotel/meta'),
|
||||
overview: (date?: string) => http.get<never, OverviewData>('/hotel/overview', { params: { date } }),
|
||||
trend: (days = 7, end?: string) => http.get<never, { items: TrendItem[] }>('/hotel/trend', { params: { days, end } }),
|
||||
|
||||
accounts: (q: AccountQuery) =>
|
||||
http.get<never, PageData<AccountItem>>('/hotel/accounts', {
|
||||
params: { ...q, status: q.status?.length ? q.status : undefined },
|
||||
paramsSerializer: { indexes: null },
|
||||
}),
|
||||
changeCity: (id: number, city: string) =>
|
||||
http.post<never, { id: number; old_city: string | null; new_city: string; mode: 'add' | 'change'; prox_cleared: boolean; is_ok_reset: boolean; proxy_ips_in_city: number; audit_ok: boolean }>(
|
||||
`/hotel/accounts/${id}/city`,
|
||||
{ city },
|
||||
),
|
||||
resetAccount: (id: number) =>
|
||||
http.post<never, { id: number; old_is_ok: number | null; new_is_ok: null; audit_ok: boolean }>(`/hotel/accounts/${id}/reset`, {}),
|
||||
|
||||
statsAccount: (date?: string) => http.get<never, { date: string; logs_available: boolean; items: AccountStatsItem[] }>('/hotel/stats/account', { params: { date } }),
|
||||
statsCity: (date?: string, top?: number) =>
|
||||
http.get<never, { date: string; logs_available: boolean; items: CityStatsItem[] }>('/hotel/stats/city', { params: { date, top } }),
|
||||
|
||||
tasks: (params: { start?: string; end?: string; city?: string; keyword?: string; page?: number; size?: number }) =>
|
||||
http.get<never, PageData<TaskItem>>('/hotel/tasks', { params }),
|
||||
records: (params: { start?: string; end?: string; city?: string; keyword?: string; page?: number; size?: number }) =>
|
||||
http.get<never, PageData<RecordItem>>('/hotel/records', { params }),
|
||||
recordDetail: (id: number) => http.get<never, RecordDetail>(`/hotel/records/${id}`),
|
||||
|
||||
alerts: (date?: string) => http.get<never, AlertsData>('/hotel/alerts', { params: { date } }),
|
||||
|
||||
platformStats: (params: { date?: string; city?: string }) =>
|
||||
http.get<never, PlatformAllData | { date: string; ok: boolean; items: PlatformStats[] }>('/hotel/platform/stats', { params }),
|
||||
|
||||
/** 所选日期各城市明细 + 昨日成功率(高危筛查;平台只保留今天/昨天) */
|
||||
platformRisk: (params: { date?: string; days?: number }) =>
|
||||
http.get<never, RiskData>('/hotel/platform/risk', { params, timeout: 180000 }),
|
||||
|
||||
/** 当天拿任务失败的城市(改/加城市时要把它们藏起来) */
|
||||
cityFailures: (date?: string) => http.get<never, CityFailures>('/hotel/stats/failures', { params: { date } }),
|
||||
|
||||
/** 采集端(酒店详情.py):状态 / 启动 / 停止 */
|
||||
collectorStatus: () => http.get<never, CollectorStatus>('/hotel/collector/status'),
|
||||
startCollector: () => http.post<never, CollectorStatus>('/hotel/collector/start', {}, { timeout: 60000 }),
|
||||
stopCollector: () => http.post<never, CollectorStatus>('/hotel/collector/stop', {}, { timeout: 60000 }),
|
||||
|
||||
audit: (limit = 50) => http.get<never, { items: AuditItem[]; count: number }>('/hotel/audit', { params: { limit } }),
|
||||
}
|
||||
|
||||
export default api
|
||||
@@ -0,0 +1,351 @@
|
||||
/** 接口数据类型(与 backend/app/routers 的响应一一对应) */
|
||||
|
||||
export interface ApiEnvelope<T> {
|
||||
code: number
|
||||
msg: string
|
||||
data: T
|
||||
}
|
||||
|
||||
export interface MetaCity {
|
||||
city: string
|
||||
proxy_ips: number
|
||||
accounts: number
|
||||
city_id: string | null
|
||||
legal: boolean
|
||||
}
|
||||
|
||||
export interface IsOkMeta {
|
||||
text: string
|
||||
tone: 'ok' | 'danger' | 'warn' | 'muted'
|
||||
}
|
||||
|
||||
export interface MetaData {
|
||||
cities: MetaCity[]
|
||||
legal_cities: string[]
|
||||
is_ok_dict: Record<string, IsOkMeta>
|
||||
platform_available: boolean
|
||||
}
|
||||
|
||||
export interface PoolStats {
|
||||
total: number
|
||||
available: number
|
||||
s403: number
|
||||
s401: number
|
||||
s418: number
|
||||
s0: number
|
||||
s6: number
|
||||
other: number
|
||||
others_all: number
|
||||
available_rate: number | null
|
||||
}
|
||||
|
||||
export interface TodayAgg {
|
||||
fetch_task: number
|
||||
upload_ok: number
|
||||
upload_fail: number
|
||||
fetch_empty: number
|
||||
exception: number
|
||||
success_rate: number | null
|
||||
active_accounts: number
|
||||
last_event_at: string | null
|
||||
}
|
||||
|
||||
export interface PlatformStats {
|
||||
ok: boolean
|
||||
date: string
|
||||
city?: string | null
|
||||
success?: number | null
|
||||
reject?: number | null
|
||||
remain?: number | null
|
||||
timeout?: number | null
|
||||
cancel?: number | null
|
||||
error?: string | null
|
||||
}
|
||||
|
||||
export interface OverviewData {
|
||||
date: string
|
||||
pool: PoolStats
|
||||
today: TodayAgg
|
||||
logs_available: boolean
|
||||
db_today: { hotel_task: number; hotel_json: number }
|
||||
platform: PlatformStats
|
||||
}
|
||||
|
||||
export interface TrendItem {
|
||||
date: string
|
||||
fetch_task: number
|
||||
upload_ok: number
|
||||
fetch_empty: number
|
||||
logs: boolean
|
||||
}
|
||||
|
||||
export interface AccountToday {
|
||||
fetch_task: number
|
||||
upload_ok: number
|
||||
upload_fail: number
|
||||
fetch_empty: number
|
||||
}
|
||||
|
||||
export interface AccountItem {
|
||||
// ── hotel_hd 原始列(页面 1 直接展示)──
|
||||
id: number
|
||||
is_ok: number | null
|
||||
req_count: number
|
||||
current_count: number
|
||||
prox_raw: string | null
|
||||
city: string | null
|
||||
mt_traceid: string | null
|
||||
created_at: string | null
|
||||
updated_at: string | null
|
||||
// ── 辅助字段 ──
|
||||
dfpid_tail: string | null
|
||||
has_prox: boolean
|
||||
prox_ip: string | null
|
||||
status_text: string
|
||||
status_tone: 'ok' | 'danger' | 'warn' | 'muted'
|
||||
today: AccountToday
|
||||
ip: string | null
|
||||
channel: string | null
|
||||
}
|
||||
|
||||
export interface PageData<T> {
|
||||
total: number
|
||||
page: number
|
||||
size: number
|
||||
items: T[]
|
||||
logs_available?: boolean
|
||||
date?: string
|
||||
}
|
||||
|
||||
export interface AccountStatsItem {
|
||||
hd_id: number
|
||||
dfpid_tail: string | null
|
||||
city: string | null
|
||||
fetch_task: number
|
||||
upload_ok: number
|
||||
upload_fail: number
|
||||
fetch_empty: number
|
||||
exception: number
|
||||
last_event_at: string | null
|
||||
req_count: number
|
||||
current_count: number
|
||||
}
|
||||
|
||||
export interface CityStatsItem {
|
||||
city: string
|
||||
accounts: number
|
||||
proxy_ips: number
|
||||
fetch_task: number
|
||||
upload_ok: number
|
||||
upload_fail: number
|
||||
fetch_empty: number
|
||||
exception: number
|
||||
last_event_at: string | null
|
||||
}
|
||||
|
||||
export interface TaskItem {
|
||||
id: number
|
||||
hotel_id: string
|
||||
city_id: string
|
||||
hotel_name: string
|
||||
city_name: string | null
|
||||
check_in_date: string | null
|
||||
check_out_date: string | null
|
||||
unique_id: string | null
|
||||
hotel_star: string | null
|
||||
selected_city: string | null
|
||||
area_type: string | null
|
||||
area_name: string | null
|
||||
created_at: string | null
|
||||
updated_at: string | null
|
||||
}
|
||||
|
||||
export interface RecordItem {
|
||||
id: number
|
||||
poi_id: string | null
|
||||
city_id: number | null
|
||||
hotel_name: string | null
|
||||
city_name: string | null
|
||||
check_in_date: string | null
|
||||
check_out_date: string | null
|
||||
create_at: string | null
|
||||
}
|
||||
|
||||
export interface RoomItem {
|
||||
room_name: string
|
||||
goods_name: string
|
||||
price: number | null
|
||||
origin_price: number | null
|
||||
inventory: number | null
|
||||
tag: string | null
|
||||
payment: string | null
|
||||
goods_id: number | null
|
||||
promotion: string | null
|
||||
}
|
||||
|
||||
export interface RecordDetail {
|
||||
id: number
|
||||
hotel: {
|
||||
poi_id: string | null
|
||||
city_id: number | null
|
||||
hotel_name: string | null
|
||||
city_name: string | null
|
||||
check_in_date: string | null
|
||||
check_out_date: string | null
|
||||
create_at: string | null
|
||||
json_size: number
|
||||
}
|
||||
parse_ok: boolean
|
||||
structure: string | null
|
||||
error: string | null
|
||||
rooms: RoomItem[]
|
||||
min_price: number | null
|
||||
raw_preview: string
|
||||
raw_truncated: boolean
|
||||
}
|
||||
|
||||
export interface EmptyFetchItem {
|
||||
ts: string | null
|
||||
hd_id: number | null
|
||||
dfpid_tail: string | null
|
||||
bind_city: string | null
|
||||
target_city: string | null
|
||||
code: number | null
|
||||
message: string | null
|
||||
}
|
||||
|
||||
export interface StaleAccount {
|
||||
hd_id: number
|
||||
dfpid_tail: string | null
|
||||
city: string | null
|
||||
updated_at: string | null
|
||||
hours: number
|
||||
}
|
||||
|
||||
export interface BlockedAccount {
|
||||
hd_id: number
|
||||
dfpid_tail: string | null
|
||||
city: string | null
|
||||
is_ok: number | null
|
||||
status_text: string
|
||||
status_tone: 'ok' | 'danger' | 'warn' | 'muted'
|
||||
updated_at: string | null
|
||||
}
|
||||
|
||||
export interface AlertsData {
|
||||
date: string
|
||||
logs_available: boolean
|
||||
empty_fetch: EmptyFetchItem[]
|
||||
stale: StaleAccount[]
|
||||
blocked: BlockedAccount[]
|
||||
counts: { empty_fetch: number; stale: number; blocked: number }
|
||||
}
|
||||
|
||||
export interface PlatformCityItem {
|
||||
city: string
|
||||
success: number | null
|
||||
reject: number | null
|
||||
remain: number | null
|
||||
timeout: number | null
|
||||
ok?: boolean
|
||||
error?: string | null
|
||||
}
|
||||
|
||||
/** /api/hotel/platform/risk 的单城结果:所选日(today_*)+ 昨日(hist_*) */
|
||||
export interface RiskItem {
|
||||
city: string
|
||||
hist_success: number
|
||||
hist_reject: number
|
||||
hist_total: number
|
||||
hist_rate: number | null
|
||||
hist_days_with_data: number
|
||||
today_success: number | null
|
||||
today_reject: number | null
|
||||
today_rate: number | null
|
||||
today_remain: number | null
|
||||
today_timeout: number | null
|
||||
today_total: number
|
||||
today_abnormal: boolean
|
||||
empty_fetch_count: number
|
||||
risk_rate: number | null
|
||||
risk_basis: 'window' | 'no_window_data'
|
||||
high_risk: boolean
|
||||
}
|
||||
|
||||
/** 可用账号(is_ok IS NULL),用于计算手上包的剩余产能 */
|
||||
export interface AvailablePackage {
|
||||
id: number
|
||||
city: string | null
|
||||
current_count: number
|
||||
}
|
||||
|
||||
export interface RiskData {
|
||||
/** 所选日期(后端实际查询的基准日) */
|
||||
date: string
|
||||
/** 平台接口是否可用(与"0 条完成"区分) */
|
||||
platform_ok: boolean
|
||||
/** 该日期平台是否有统计(平台只保留今天/昨天,更早日期为 false) */
|
||||
has_data: boolean
|
||||
/** 参考窗口:days=1 → start=end=昨日 */
|
||||
window: { start: string; end: string; days: number; exclude_today: boolean }
|
||||
threshold: number
|
||||
min_sample: number
|
||||
abnormal_min_sample: number
|
||||
high_risk: RiskItem[]
|
||||
abnormal: RiskItem[]
|
||||
items: RiskItem[]
|
||||
logs_available: boolean
|
||||
empty_fetch_total: number
|
||||
available_packages: AvailablePackage[]
|
||||
counts: {
|
||||
cities: number
|
||||
high_risk: number
|
||||
abnormal: number
|
||||
empty_fetch_cities: number
|
||||
available_packages: number
|
||||
}
|
||||
}
|
||||
|
||||
export interface PlatformAllData {
|
||||
date: string
|
||||
ok: boolean
|
||||
items: PlatformCityItem[]
|
||||
summary: { success: number | null; reject: number | null; remain: number | null; timeout: number | null; cities: number }
|
||||
failed: string[]
|
||||
}
|
||||
|
||||
/** /api/hotel/collector/status —— 采集端(酒店详情.py)运行状态 */
|
||||
export interface CollectorStatus {
|
||||
running: boolean
|
||||
pid: number | null
|
||||
/** api=看板启动的,manual=控制台启动的(靠 pid 文件识别) */
|
||||
source: 'api' | 'manual' | null
|
||||
started_at: string | null
|
||||
uptime_seconds: number | null
|
||||
dir: string
|
||||
script: string
|
||||
python: string
|
||||
log_file: string
|
||||
log_tail: string[]
|
||||
}
|
||||
|
||||
/** /api/hotel/stats/failures —— 当天拿任务失败(fetch_empty)的城市 */
|
||||
export interface CityFailures {
|
||||
date: string
|
||||
logs_available: boolean
|
||||
items: { city: string; fetch_empty: number; exception: number; last_event_at: string | null }[]
|
||||
cities: string[]
|
||||
}
|
||||
|
||||
export interface AuditItem {
|
||||
ts: string
|
||||
action: string
|
||||
hd_id: number
|
||||
dfpid_tail: string | null
|
||||
old_city: string | null
|
||||
new_city: string | null
|
||||
old_is_ok: number | null
|
||||
new_is_ok: number | null
|
||||
operator: string | null
|
||||
result: string
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<script setup lang="ts">
|
||||
/** ECharts 封装:自动 resize / 统一主题 / 空态 / 平滑过渡 */
|
||||
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import * as echarts from 'echarts'
|
||||
import type { EChartsOption } from 'echarts'
|
||||
|
||||
const props = withDefaults(defineProps<{ option: EChartsOption; height?: string; empty?: boolean }>(), {
|
||||
height: '300px',
|
||||
empty: false,
|
||||
})
|
||||
|
||||
const emit = defineEmits<{ chartClick: [params: { name?: string }] }>()
|
||||
|
||||
const el = ref<HTMLElement>()
|
||||
let chart: echarts.ECharts | null = null
|
||||
let ro: ResizeObserver | null = null
|
||||
|
||||
function render() {
|
||||
if (!chart) return
|
||||
// merge 模式(默认):数据刷新时新旧 diff 平滑过渡(柱生长/收缩)
|
||||
chart.setOption(props.option, { notMerge: false })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (!el.value) return
|
||||
chart = echarts.init(el.value)
|
||||
ro = new ResizeObserver(() => chart?.resize())
|
||||
ro.observe(el.value)
|
||||
chart.on('click', (params: { name?: string }) => emit('chartClick', { name: params.name }))
|
||||
render()
|
||||
})
|
||||
|
||||
watch(() => props.option, render, { deep: true })
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
ro?.disconnect()
|
||||
chart?.dispose()
|
||||
chart = null
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="relative w-full">
|
||||
<div ref="el" class="w-full transition-opacity duration-300" :class="empty ? 'opacity-0' : 'opacity-100'" :style="{ height }" />
|
||||
<div v-if="empty" class="absolute inset-0 flex items-center justify-center text-sm text-[var(--text-weak)]">
|
||||
暂无数据
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,233 @@
|
||||
<script setup lang="ts">
|
||||
/** 改绑定城市弹窗:选择合法城市 → 二次确认(明确提示会清空代理) */
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import api from '../api'
|
||||
import type { AccountItem } from '../api/types'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
account: AccountItem | null
|
||||
legalCities: string[]
|
||||
ipCount: (city: string) => number
|
||||
}>()
|
||||
const emit = defineEmits<{ 'update:modelValue': [boolean]; submitted: [number] }>()
|
||||
|
||||
const city = ref('')
|
||||
const submitting = ref(false)
|
||||
/** 今日拿任务失败的城市:默认不展示(绑过去也领不到任务),可手动展开 */
|
||||
const failedCities = ref<string[]>([])
|
||||
const showFailed = ref(false)
|
||||
const failuresLoaded = ref(false)
|
||||
|
||||
/** 新包(is_ok=NULL 且未绑城市)→ 添加城市;否则是改城市 */
|
||||
const isAdd = computed(() => !!props.account && props.account.is_ok === null && !props.account.city)
|
||||
const dialogTitle = computed(() => (isAdd.value ? '添加城市(新包)' : '改绑定城市'))
|
||||
const confirmText = computed(() => (isAdd.value ? '确认添加' : '确认修改'))
|
||||
|
||||
async function loadFailures() {
|
||||
try {
|
||||
const res = await api.cityFailures()
|
||||
failedCities.value = res.cities ?? []
|
||||
} catch {
|
||||
failedCities.value = [] // 日志读不到就当没有失败城市,不挡住正常操作
|
||||
} finally {
|
||||
failuresLoaded.value = true
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(open) => {
|
||||
if (!open) return
|
||||
city.value = ''
|
||||
showFailed.value = false
|
||||
void loadFailures()
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
const currentIp = computed(() => (city.value ? props.ipCount(city.value) : null))
|
||||
const sameCity = computed(() => !!city.value && city.value === props.account?.city)
|
||||
const disabled = computed(() => !city.value || submitting.value || sameCity.value || (currentIp.value ?? 0) <= 0)
|
||||
|
||||
const sortedCities = computed(() =>
|
||||
[...props.legalCities].sort((a, b) => {
|
||||
const diff = props.ipCount(b) - props.ipCount(a)
|
||||
return diff !== 0 ? diff : a.localeCompare(b, 'zh-CN')
|
||||
}),
|
||||
)
|
||||
|
||||
const failedSet = computed(() => new Set(failedCities.value))
|
||||
/** 下拉里实际可选的城:默认剔除"今日拿任务失败"的城市 */
|
||||
const selectableCities = computed(() =>
|
||||
showFailed.value ? sortedCities.value : sortedCities.value.filter((c) => !failedSet.value.has(c)),
|
||||
)
|
||||
const hiddenCount = computed(() => sortedCities.value.filter((c) => failedSet.value.has(c)).length)
|
||||
const allHidden = computed(() => failuresLoaded.value && sortedCities.value.length > 0 && selectableCities.value.length === 0)
|
||||
|
||||
async function submit() {
|
||||
if (!props.account || disabled.value) return
|
||||
submitting.value = true
|
||||
try {
|
||||
const res = await api.changeCity(props.account.id, city.value)
|
||||
const verb = res.mode === 'add' ? '已添加城市' : '城市已改为'
|
||||
ElMessage.success(`#${res.id} ${verb} ${res.new_city},代理已清空(该城 ${res.proxy_ips_in_city} 个 IP)`)
|
||||
emit('submitted', res.id)
|
||||
emit('update:modelValue', false)
|
||||
} catch (e) {
|
||||
ElMessage.error((e as Error).message)
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="modelValue"
|
||||
:title="dialogTitle"
|
||||
width="520px"
|
||||
:close-on-click-modal="false"
|
||||
append-to-body
|
||||
@update:model-value="emit('update:modelValue', $event)"
|
||||
>
|
||||
<div class="dlg">
|
||||
<div class="dlg__row">
|
||||
<span class="dlg__k">账号</span>
|
||||
<span class="dlg__v">#{{ account?.id }} <code>{{ account?.dfpid_tail }}</code></span>
|
||||
</div>
|
||||
<div class="dlg__row">
|
||||
<span class="dlg__k">当前城市</span>
|
||||
<span class="dlg__v">{{ account?.city || '未绑定' }}</span>
|
||||
</div>
|
||||
<div class="dlg__row">
|
||||
<span class="dlg__k">当前代理</span>
|
||||
<span class="dlg__v">{{ account?.has_prox ? account?.prox_ip || '有' : '无' }}</span>
|
||||
</div>
|
||||
<div class="dlg__row">
|
||||
<span class="dlg__k">当前次数</span>
|
||||
<span class="dlg__v">req_count {{ account?.req_count ?? 0 }} / current_count {{ account?.current_count ?? 0 }}</span>
|
||||
</div>
|
||||
<div class="dlg__row">
|
||||
<span class="dlg__k">新城市</span>
|
||||
<select v-model="city" class="dlg__select" :disabled="allHidden">
|
||||
<option value="" disabled>
|
||||
{{ allHidden ? '今日所有城市都拿任务失败,暂无可选城市' : '请选择(仅列代理池已有 IP 的城市)' }}
|
||||
</option>
|
||||
<option v-for="c in selectableCities" :key="c" :value="c">{{ c }}({{ ipCount(c) }} 个 IP)</option>
|
||||
</select>
|
||||
</div>
|
||||
<p v-if="hiddenCount > 0" class="dlg__hint dlg__hint--info">
|
||||
今日拿任务失败的 {{ hiddenCount }} 个城市{{ showFailed ? '(已显示)' : '已隐藏' }},当前
|
||||
{{ selectableCities.length }} 个可选
|
||||
<button class="dlg__link" type="button" @click="showFailed = !showFailed">
|
||||
{{ showFailed ? '隐藏它们' : '显示全部' }}
|
||||
</button>
|
||||
</p>
|
||||
<p v-if="allHidden" class="dlg__hint dlg__hint--warn">
|
||||
今日所有城市都拿任务失败,绑过去也领不到任务;可以先在任务平台确认城市是否恢复了。
|
||||
</p>
|
||||
<p v-if="sameCity" class="dlg__hint dlg__hint--warn">与当前城市相同,无需修改</p>
|
||||
<p v-else-if="city && (currentIp ?? 0) <= 0" class="dlg__hint dlg__hint--warn">该城市暂无可用代理,不能切换</p>
|
||||
<p v-if="isAdd" class="dlg__warn">⚠ 该包还没有绑定城市。提交后会把它设为所选城市、代理置空(prox = NULL),采集脚本下次运行即可按该城市领取任务并自动补同城 IP。</p>
|
||||
<p v-else class="dlg__warn">⚠ 提交后会把该账号代理置空(prox = NULL)、并把状态重置为可用(is_ok = NULL);current_count 保留不变。采集脚本下次运行时会按新城市自动补同城 IP。</p>
|
||||
</div>
|
||||
<template #footer>
|
||||
<button class="btn" type="button" @click="emit('update:modelValue', false)">取消</button>
|
||||
<button class="btn btn--primary" type="button" :disabled="disabled" @click="submit">
|
||||
{{ submitting ? '提交中…' : confirmText }}
|
||||
</button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.dlg__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 5px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
.dlg__k {
|
||||
width: 84px;
|
||||
color: var(--text-weak);
|
||||
font-size: 13px;
|
||||
text-align: right;
|
||||
flex: none;
|
||||
}
|
||||
.dlg__v {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.dlg__v code {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.dlg__select {
|
||||
flex: 1;
|
||||
height: 32px;
|
||||
padding: 0 8px;
|
||||
font-size: 13px;
|
||||
color: var(--text-primary);
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-element);
|
||||
}
|
||||
.dlg__select:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.dlg__hint {
|
||||
margin: 6px 0 0 94px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.dlg__hint--warn {
|
||||
color: #d9a424;
|
||||
}
|
||||
.dlg__hint--info {
|
||||
margin-left: 0;
|
||||
color: var(--text-weak);
|
||||
}
|
||||
.dlg__link {
|
||||
margin-left: 6px;
|
||||
padding: 0;
|
||||
font-size: 12px;
|
||||
color: var(--accent);
|
||||
background: none;
|
||||
border: none;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
.dlg__warn {
|
||||
margin: 12px 0 0;
|
||||
padding: 8px 10px;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
color: var(--text-secondary);
|
||||
background: var(--accent-bg);
|
||||
border-left: 3px solid var(--accent);
|
||||
}
|
||||
.btn {
|
||||
margin-left: 8px;
|
||||
height: 32px;
|
||||
padding: 0 14px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 13px;
|
||||
color: var(--text-primary);
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--radius-element);
|
||||
cursor: pointer;
|
||||
}
|
||||
.btn--primary {
|
||||
color: #fff;
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.btn:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,139 @@
|
||||
<script setup lang="ts">
|
||||
/** 采集端(酒店详情.py)启动 / 停止按钮:轮询状态 + 二次确认 + 悬浮看日志尾 */
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import api from '../api'
|
||||
import type { CollectorStatus } from '../api/types'
|
||||
|
||||
const status = ref<CollectorStatus | null>(null)
|
||||
const busy = ref(false)
|
||||
const error = ref('')
|
||||
let timer: number | null = null
|
||||
|
||||
const running = computed(() => status.value?.running ?? false)
|
||||
const label = computed(() => (running.value ? '停止采集' : '启动采集'))
|
||||
|
||||
async function refresh() {
|
||||
try {
|
||||
status.value = await api.collectorStatus()
|
||||
error.value = ''
|
||||
} catch (e) {
|
||||
error.value = (e as Error).message
|
||||
}
|
||||
}
|
||||
|
||||
const tip = computed(() => {
|
||||
const s = status.value
|
||||
if (!s) return error.value || '正在读取采集状态…'
|
||||
if (!s.running) return `酒店详情.py 未运行${error.value ? '(状态读取失败:' + error.value + ')' : ''}`
|
||||
const up = s.uptime_seconds ?? 0
|
||||
const h = Math.floor(up / 3600)
|
||||
const m = Math.floor((up % 3600) / 60)
|
||||
const who = s.source === 'manual' ? '控制台启动' : '看板启动'
|
||||
const tailText = (s.log_tail ?? []).slice(-6).join('\n')
|
||||
return `pid ${s.pid} · 已运行 ${h}h${m}m · ${who}\n${s.dir}\\${s.script}\n\n最后日志:\n${tailText || '(暂无)'}`
|
||||
})
|
||||
|
||||
async function toggle() {
|
||||
if (busy.value) return
|
||||
const isRunning = running.value
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
isRunning
|
||||
? `将停止采集进程(pid ${status.value?.pid}),采集会中断。确定停止?`
|
||||
: '将在后台启动 酒店详情.py(窗口隐藏,输出写入 logs/collector.out.log)。确定启动?',
|
||||
isRunning ? '停止采集' : '启动采集',
|
||||
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' },
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
busy.value = true
|
||||
try {
|
||||
const next = isRunning ? await api.stopCollector() : await api.startCollector()
|
||||
status.value = next
|
||||
ElMessage.success(isRunning ? '采集已停止' : `采集已启动(pid ${next.pid})`)
|
||||
} catch (e) {
|
||||
ElMessage.error((e as Error).message)
|
||||
await refresh()
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void refresh()
|
||||
timer = window.setInterval(() => {
|
||||
if (!document.hidden) void refresh()
|
||||
}, 10000)
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
if (timer !== null) window.clearInterval(timer)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button
|
||||
class="collector"
|
||||
:class="{ 'collector--on': running }"
|
||||
type="button"
|
||||
:disabled="busy"
|
||||
:title="tip"
|
||||
@click="toggle"
|
||||
>
|
||||
<i class="collector__dot" />
|
||||
{{ busy ? '处理中…' : label }}
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.collector {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
height: 32px;
|
||||
padding: 0 12px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 13px;
|
||||
color: var(--text-primary);
|
||||
white-space: nowrap;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--radius-element);
|
||||
cursor: pointer;
|
||||
transition: transform 0.12s, box-shadow 0.2s, color 0.15s, border-color 0.15s;
|
||||
}
|
||||
.collector:hover {
|
||||
box-shadow: 2px 2px 0 rgba(51, 48, 42, 0.16);
|
||||
}
|
||||
.collector:active {
|
||||
transform: scale(0.96);
|
||||
}
|
||||
.collector:disabled {
|
||||
opacity: 0.55;
|
||||
cursor: progress;
|
||||
}
|
||||
.collector__dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--text-faint);
|
||||
}
|
||||
.collector--on {
|
||||
color: var(--marker-green);
|
||||
border-color: var(--marker-green);
|
||||
}
|
||||
.collector--on .collector__dot {
|
||||
background: var(--marker-green);
|
||||
animation: collector-pulse 1.6s ease-in-out infinite;
|
||||
}
|
||||
@keyframes collector-pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.3;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,99 @@
|
||||
<script setup lang="ts">
|
||||
/** 顶栏:标题 + 导航 + 自动刷新开关 + 刷新按钮 + 实时时钟(日期等筛选放到具体页面内) */
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import CollectorButton from './CollectorButton.vue'
|
||||
import { useHotelStore } from '../stores/hotel'
|
||||
|
||||
const emit = defineEmits<{ refresh: [] }>()
|
||||
const store = useHotelStore()
|
||||
const { autoRefresh } = storeToRefs(store)
|
||||
|
||||
const now = ref('')
|
||||
let timer: number | null = null
|
||||
const clock = () => {
|
||||
const d = new Date()
|
||||
const p = (n: number) => String(n).padStart(2, '0')
|
||||
now.value = `${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
clock()
|
||||
timer = window.setInterval(clock, 1000)
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
if (timer !== null) window.clearInterval(timer)
|
||||
})
|
||||
|
||||
const refreshLabel = computed(() => (autoRefresh.value ? '⟳ 自动 15s' : '⟳ 已暂停'))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<header class="bar">
|
||||
<div class="bar__row">
|
||||
<h1 class="bar__title">美团酒店任务看板</h1>
|
||||
<slot name="nav" />
|
||||
<div class="bar__spacer" />
|
||||
<CollectorButton />
|
||||
<button class="bar__btn" type="button" :class="{ 'bar__btn--off': !autoRefresh }" @click="autoRefresh = !autoRefresh">
|
||||
{{ refreshLabel }}
|
||||
</button>
|
||||
<button class="bar__btn" type="button" @click="emit('refresh')">刷新</button>
|
||||
<span class="bar__clock">{{ now }}</span>
|
||||
</div>
|
||||
</header>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.bar {
|
||||
border-bottom: 2px solid var(--border-strong);
|
||||
background: var(--bg-page);
|
||||
}
|
||||
.bar__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
padding: 14px 24px;
|
||||
}
|
||||
.bar__title {
|
||||
font-family: var(--font-display);
|
||||
font-size: 25px;
|
||||
line-height: 1.2;
|
||||
color: var(--text-primary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.bar__spacer {
|
||||
flex: 1;
|
||||
}
|
||||
.bar__btn {
|
||||
height: 32px;
|
||||
padding: 0 14px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 13px;
|
||||
color: var(--accent);
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--radius-element);
|
||||
cursor: pointer;
|
||||
transition: transform 0.12s, box-shadow 0.2s;
|
||||
}
|
||||
.bar__btn:hover {
|
||||
box-shadow: 2px 2px 0 rgba(224, 64, 44, 0.18);
|
||||
}
|
||||
.bar__btn:active {
|
||||
transform: scale(0.95);
|
||||
}
|
||||
.bar__btn--off {
|
||||
color: var(--text-weak);
|
||||
border-color: var(--border-color);
|
||||
}
|
||||
.bar__clock {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 14px;
|
||||
color: var(--text-secondary);
|
||||
min-width: 70px;
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,66 @@
|
||||
<script setup lang="ts">
|
||||
/** KPI 卡:数值 + 副标题,可点击下钻 */
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
label: string
|
||||
value: string | number
|
||||
sub?: string
|
||||
tone?: 'default' | 'ok' | 'danger' | 'warn'
|
||||
clickable?: boolean
|
||||
}>(),
|
||||
{ sub: '', tone: 'default', clickable: false },
|
||||
)
|
||||
const emit = defineEmits<{ click: [] }>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="kpi" :class="[`kpi--${tone}`, { 'kpi--clickable': clickable }]" @click="clickable && emit('click')">
|
||||
<div class="kpi__value">{{ value }}</div>
|
||||
<div class="kpi__label">{{ label }}</div>
|
||||
<div v-if="sub" class="kpi__sub">{{ sub }}</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.kpi {
|
||||
padding: 12px 14px;
|
||||
background: var(--bg-card);
|
||||
border: 1.5px solid var(--border-strong);
|
||||
border-radius: var(--radius-card);
|
||||
box-shadow: var(--shadow-card);
|
||||
transition: box-shadow 0.2s, transform 0.2s;
|
||||
}
|
||||
.kpi--clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
.kpi--clickable:hover {
|
||||
box-shadow: var(--shadow-raised);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
.kpi__value {
|
||||
font-family: var(--font-display);
|
||||
font-size: 28px;
|
||||
line-height: 1.15;
|
||||
color: var(--text-primary);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.kpi--ok .kpi__value {
|
||||
color: var(--marker-green);
|
||||
}
|
||||
.kpi--danger .kpi__value {
|
||||
color: var(--marker-red);
|
||||
}
|
||||
.kpi--warn .kpi__value {
|
||||
color: #d9a424;
|
||||
}
|
||||
.kpi__label {
|
||||
margin-top: 2px;
|
||||
font-size: 13px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.kpi__sub {
|
||||
margin-top: 2px;
|
||||
font-size: 11px;
|
||||
color: var(--text-weak);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
/** 入场动画容器:上滑淡入 + 弹簧果冻(错峰由 delay 控制) */
|
||||
import { enterBlock } from '../composables/useMotion'
|
||||
|
||||
withDefaults(defineProps<{ delay?: number }>(), { delay: 0 })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Motion v-bind="enterBlock(delay)">
|
||||
<slot />
|
||||
</Motion>
|
||||
</template>
|
||||
@@ -0,0 +1,63 @@
|
||||
<script setup lang="ts">
|
||||
/** 两个页签:账号池(hotel_hd 前 10 条)/ 查询(平台 getStats,参考 查询.py) */
|
||||
export type NavKey = 'accounts' | 'query'
|
||||
|
||||
const props = defineProps<{ modelValue: NavKey }>()
|
||||
const emit = defineEmits<{ 'update:modelValue': [NavKey] }>()
|
||||
|
||||
const tabs: { key: NavKey; label: string }[] = [
|
||||
{ key: 'accounts', label: '账号池' },
|
||||
{ key: 'query', label: '查询' },
|
||||
]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<nav class="nav">
|
||||
<button
|
||||
v-for="tab in tabs"
|
||||
:key="tab.key"
|
||||
class="nav__item"
|
||||
:class="{ 'nav__item--active': props.modelValue === tab.key }"
|
||||
type="button"
|
||||
@click="emit('update:modelValue', tab.key)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</button>
|
||||
</nav>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.nav {
|
||||
display: flex;
|
||||
gap: 18px;
|
||||
align-items: flex-end;
|
||||
}
|
||||
.nav__item {
|
||||
position: relative;
|
||||
padding: 4px 2px 6px;
|
||||
font-family: var(--font-display);
|
||||
font-size: 17px;
|
||||
color: var(--text-secondary);
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: color 0.18s;
|
||||
}
|
||||
.nav__item:hover {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.nav__item--active {
|
||||
color: var(--accent);
|
||||
}
|
||||
.nav__item--active::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: -2px;
|
||||
right: -2px;
|
||||
bottom: 0;
|
||||
height: 2px;
|
||||
background: var(--accent);
|
||||
border-radius: 2px;
|
||||
transform: rotate(-0.6deg);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
/** is_ok 状态标签:颜色 + 图标 + 文案三通道(色盲可辨) */
|
||||
import { computed } from 'vue'
|
||||
import type { Tone } from '../composables/hotelStatus'
|
||||
import { statusStyle } from '../composables/hotelStatus'
|
||||
|
||||
const props = defineProps<{ isOk: number | null; text: string; tone: Tone }>()
|
||||
const style = computed(() => statusStyle(props.isOk, props.text, props.tone))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span class="tag" :style="{ color: style.color, background: style.bg, borderColor: style.color }">
|
||||
<span class="tag__icon">{{ style.icon }}</span>{{ style.text }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
padding: 1px 7px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
border: 1px solid currentColor;
|
||||
border-radius: var(--radius-pill);
|
||||
transform: rotate(-0.8deg);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.tag__icon {
|
||||
font-size: 11px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,28 @@
|
||||
/** ECharts 统一主题 token —— 编辑杂志风:纯单色灰阶、细线、无装饰 */
|
||||
|
||||
export const chartTheme = {
|
||||
font: "system-ui, 'PingFang SC', 'Microsoft YaHei', sans-serif",
|
||||
textColor: 'rgba(28, 28, 28, 0.40)', // 轴文字
|
||||
gridline: 'rgba(28, 28, 28, 0.08)', // 发丝网格
|
||||
axis: 'rgba(28, 28, 28, 0.15)', // 轴线
|
||||
ink: '#1c1c1c', // 主墨(实心系列)
|
||||
grayStrong: 'rgba(28, 28, 28, 0.55)', // 次级系列
|
||||
gray: 'rgba(28, 28, 28, 0.15)', // 浅色系列(未完成)
|
||||
surface: '#f9f8f6',
|
||||
}
|
||||
|
||||
export const baseGrid = { left: 8, right: 16, top: 36, bottom: 4, containLabel: true }
|
||||
|
||||
export const baseAxisLabel = {
|
||||
color: 'rgba(28, 28, 28, 0.40)',
|
||||
fontSize: 12,
|
||||
fontFamily: chartTheme.font,
|
||||
}
|
||||
|
||||
export const baseTooltip = {
|
||||
backgroundColor: '#ffffff',
|
||||
borderColor: 'rgba(28, 28, 28, 0.15)',
|
||||
borderWidth: 1,
|
||||
textStyle: { color: '#1c1c1c', fontSize: 12, fontFamily: chartTheme.font },
|
||||
extraCssText: 'border-radius:0; box-shadow:none;',
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/** is_ok 状态 → 文案 / 颜色 / 图标 的唯一映射处(对应 docs/02 2.2) */
|
||||
|
||||
export type Tone = 'ok' | 'danger' | 'warn' | 'muted'
|
||||
|
||||
export interface StatusStyle {
|
||||
text: string
|
||||
tone: Tone
|
||||
color: string
|
||||
bg: string
|
||||
icon: string
|
||||
}
|
||||
|
||||
const TONE_MAP: Record<Tone, { color: string; bg: string }> = {
|
||||
ok: { color: 'var(--marker-green)', bg: 'rgba(60, 154, 95, 0.08)' },
|
||||
danger: { color: 'var(--marker-red)', bg: 'rgba(224, 64, 44, 0.06)' },
|
||||
warn: { color: '#d9a424', bg: 'rgba(217, 164, 36, 0.06)' },
|
||||
muted: { color: 'var(--text-weak)', bg: 'rgba(51, 48, 42, 0.06)' },
|
||||
}
|
||||
|
||||
const ICONS: Record<string, string> = {
|
||||
NULL: '✓',
|
||||
'403': '⚑',
|
||||
'401': '⚿',
|
||||
'418': '⚡',
|
||||
'0': '!',
|
||||
'6': '?',
|
||||
}
|
||||
|
||||
export function statusStyle(isOk: number | null, text: string, tone: Tone): StatusStyle {
|
||||
const key = isOk === null ? 'NULL' : String(isOk)
|
||||
const palette = TONE_MAP[tone] ?? TONE_MAP.muted
|
||||
return {
|
||||
text,
|
||||
tone,
|
||||
color: palette.color,
|
||||
bg: palette.bg,
|
||||
icon: ICONS[key] ?? '?',
|
||||
}
|
||||
}
|
||||
|
||||
/** 行底色(保证 red=死了 / orange=可疑 / green=能动 / grey=不清楚) */
|
||||
export function rowTint(isOk: number | null): string {
|
||||
if (isOk === null) return 'rgba(60, 154, 95, 0.05)'
|
||||
if (isOk === 403 || isOk === 0) return 'rgba(224, 64, 44, 0.05)'
|
||||
if (isOk === 401 || isOk === 418) return 'rgba(217, 164, 36, 0.05)'
|
||||
return 'rgba(51, 48, 42, 0.04)'
|
||||
}
|
||||
|
||||
export function fmtNumber(v: number | null | undefined): string {
|
||||
if (v === null || v === undefined || Number.isNaN(v)) return '—'
|
||||
return v.toLocaleString('zh-CN')
|
||||
}
|
||||
|
||||
export function fmtPercent(v: number | null | undefined): string {
|
||||
if (v === null || v === undefined || Number.isNaN(v)) return '—'
|
||||
return `${v.toFixed(1)}%`
|
||||
}
|
||||
|
||||
export function fmtMoney(v: number | null | undefined): string {
|
||||
if (v === null || v === undefined || Number.isNaN(v)) return '—'
|
||||
return `¥${v.toFixed(2)}`
|
||||
}
|
||||
|
||||
export function fmtTime(v: string | null | undefined): string {
|
||||
if (!v) return '—'
|
||||
return v.length > 16 ? v.slice(5, 16) : v
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/** 自动刷新:每 intervalMs 递增一次 tick;页面隐藏时暂停,回到前台立即刷新一次。
|
||||
*
|
||||
* tick 必须由调用方传入(通常是 Pinia store 里的 tick),这样"定时刷新"和"手动刷新按钮"
|
||||
* 递增的是同一个 ref —— 否则页面 watch 不到,自动刷新会静默失效。
|
||||
*/
|
||||
import { onBeforeUnmount, onMounted, ref, watch, type Ref } from 'vue'
|
||||
|
||||
export function useAutoRefresh(intervalMs = 15000, enabled: Ref<boolean> = ref(true), tick: Ref<number> = ref(0)) {
|
||||
let timer: number | null = null
|
||||
|
||||
const clear = () => {
|
||||
if (timer !== null) {
|
||||
window.clearInterval(timer)
|
||||
timer = null
|
||||
}
|
||||
}
|
||||
|
||||
const start = () => {
|
||||
clear()
|
||||
if (!enabled.value) return
|
||||
timer = window.setInterval(() => {
|
||||
if (!document.hidden) tick.value += 1
|
||||
}, intervalMs)
|
||||
}
|
||||
|
||||
const onVisible = () => {
|
||||
if (!document.hidden) {
|
||||
tick.value += 1
|
||||
start()
|
||||
} else {
|
||||
clear()
|
||||
}
|
||||
}
|
||||
|
||||
watch(enabled, start)
|
||||
|
||||
onMounted(() => {
|
||||
start()
|
||||
document.addEventListener('visibilitychange', onVisible)
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
clear()
|
||||
document.removeEventListener('visibilitychange', onVisible)
|
||||
})
|
||||
|
||||
return { tick, refreshNow: () => (tick.value += 1) }
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/** KPI 数字滚动(easeOutCubic,值变化时从旧值平滑过渡) */
|
||||
|
||||
import { ref, watch, type Ref } from 'vue'
|
||||
|
||||
export function useCountUp(target: Ref<number>, duration = 1200) {
|
||||
const display = ref(0)
|
||||
let raf = 0
|
||||
|
||||
function animate(from: number, to: number) {
|
||||
cancelAnimationFrame(raf)
|
||||
const start = performance.now()
|
||||
const step = (t: number) => {
|
||||
const p = Math.min((t - start) / duration, 1)
|
||||
const e = 1 - Math.pow(1 - p, 3) // easeOutCubic
|
||||
display.value = from + (to - from) * e
|
||||
if (p < 1) raf = requestAnimationFrame(step)
|
||||
}
|
||||
raf = requestAnimationFrame(step)
|
||||
}
|
||||
|
||||
watch(target, (to, from) => animate(from ?? 0, to), { immediate: true })
|
||||
return display
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/** 锁一屏高度工具:动态测量导航高度 + main 实际内边距,精确锁定视口高度(页面不滚动) */
|
||||
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
export function useLockedHeight() {
|
||||
const navH = ref(65)
|
||||
const mainPad = ref(48 + 96)
|
||||
onMounted(() => {
|
||||
const h = document.querySelector('header')
|
||||
if (h) navH.value = h.offsetHeight
|
||||
const m = document.querySelector('main')
|
||||
if (m) {
|
||||
const cs = getComputedStyle(m)
|
||||
mainPad.value = (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0)
|
||||
}
|
||||
})
|
||||
return computed(() => `calc(100vh - ${navH.value + mainPad.value}px)`)
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/** 动效预设 —— 编辑杂志风(《设计风格.md》):克制、无弹性曲线(禁 bounce/elastic)
|
||||
* 入场:淡入 + 8px 上移,easeOut;hover/按压交给 CSS(transition-colors / active:scale-95)
|
||||
*/
|
||||
|
||||
function reduced(): boolean {
|
||||
return (
|
||||
typeof window !== 'undefined' &&
|
||||
typeof window.matchMedia === 'function' &&
|
||||
window.matchMedia('(prefers-reduced-motion: reduce)').matches
|
||||
)
|
||||
}
|
||||
|
||||
/** 区块/卡片入场:淡入 + 8px 上移(克制,非弹性) */
|
||||
export const enterBlock = (delay = 0) =>
|
||||
reduced()
|
||||
? { initial: { opacity: 0 }, enter: { opacity: 1, transition: { duration: 0 } } }
|
||||
: {
|
||||
initial: { opacity: 0, y: 8 },
|
||||
enter: { opacity: 1, y: 0, transition: { duration: 0.5, ease: 'easeOut', delay } },
|
||||
}
|
||||
|
||||
/** 弹窗入场:淡入 + 8px 上移 */
|
||||
export const enterDialog = reduced()
|
||||
? { initial: { opacity: 0 }, enter: { opacity: 1, transition: { duration: 0 } } }
|
||||
: {
|
||||
initial: { opacity: 0, y: 8 },
|
||||
enter: { opacity: 1, y: 0, transition: { duration: 0.35, ease: 'easeOut' } },
|
||||
}
|
||||
|
||||
/** 移动端抽屉:右侧滑入(保留,桌面不启用) */
|
||||
export const enterDrawer = reduced()
|
||||
? { initial: {}, enter: { transition: { duration: 0 } }, leave: { transition: { duration: 0 } } }
|
||||
: {
|
||||
initial: { x: '100%' },
|
||||
enter: { x: 0, transition: { duration: 0.35, ease: 'easeOut' } },
|
||||
leave: { x: '100%', transition: { duration: 0.35, ease: 'easeOut' } },
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import ElementPlus from 'element-plus'
|
||||
import { MotionPlugin } from '@vueuse/motion'
|
||||
import 'element-plus/dist/index.css'
|
||||
import '@fontsource/zcool-kuaile' // 手写标题字体(本地打包)
|
||||
import '@fontsource/zcool-qingke-huangyou' // 手写标签字体
|
||||
import './style.css'
|
||||
import App from './App.vue'
|
||||
|
||||
const app = createApp(App)
|
||||
app.use(createPinia())
|
||||
app.use(ElementPlus)
|
||||
app.use(MotionPlugin)
|
||||
app.mount('#app')
|
||||
@@ -0,0 +1,65 @@
|
||||
/** 全局状态:meta 缓存(城市白名单/代理 IP 数)、自动刷新开关、刷新信号 */
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, ref } from 'vue'
|
||||
import api from '../api'
|
||||
import type { MetaData, MetaCity } from '../api/types'
|
||||
|
||||
const META_TTL = 5 * 60 * 1000
|
||||
|
||||
export const useHotelStore = defineStore('hotel', () => {
|
||||
const autoRefresh = ref(true)
|
||||
|
||||
const meta = ref<MetaData | null>(null)
|
||||
const metaAt = ref(0)
|
||||
const metaLoading = ref(false)
|
||||
const metaError = ref('')
|
||||
|
||||
/** 刷新信号:定时器与「刷新」按钮都递增它,各页面 watch 后静默重取 */
|
||||
const tick = ref(0)
|
||||
const bumpTick = () => {
|
||||
tick.value += 1
|
||||
}
|
||||
|
||||
const cities = computed<MetaCity[]>(() => meta.value?.cities ?? [])
|
||||
const legalCities = computed<string[]>(() => meta.value?.legal_cities ?? [])
|
||||
const cityOptions = computed(() => cities.value.filter((c) => c.legal || c.accounts > 0))
|
||||
|
||||
async function loadMeta(force = false) {
|
||||
if (!force && meta.value && Date.now() - metaAt.value < META_TTL) return meta.value
|
||||
metaLoading.value = true
|
||||
metaError.value = ''
|
||||
try {
|
||||
meta.value = await api.meta()
|
||||
metaAt.value = Date.now()
|
||||
} catch (e) {
|
||||
metaError.value = (e as Error).message
|
||||
} finally {
|
||||
metaLoading.value = false
|
||||
}
|
||||
return meta.value
|
||||
}
|
||||
|
||||
function cityIpCount(name: string): number {
|
||||
return cities.value.find((c) => c.city === name)?.proxy_ips ?? 0
|
||||
}
|
||||
|
||||
function cityCityId(name: string): string | null {
|
||||
return cities.value.find((c) => c.city === name)?.city_id ?? null
|
||||
}
|
||||
|
||||
return {
|
||||
autoRefresh,
|
||||
meta,
|
||||
metaAt,
|
||||
metaLoading,
|
||||
metaError,
|
||||
tick,
|
||||
bumpTick,
|
||||
cities,
|
||||
legalCities,
|
||||
cityOptions,
|
||||
loadMeta,
|
||||
cityIpCount,
|
||||
cityCityId,
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
/* 自研工具类(由 Tailwind CLI 一次性生成并固化,见 src/styles/utilities.css 头部注释;
|
||||
模板类名与此文件一一对应,新增类时需重新生成或手写补充) */
|
||||
@import './styles/utilities.css';
|
||||
@import './styles/tokens.css';
|
||||
@import './styles/sketch.css';
|
||||
@@ -0,0 +1,226 @@
|
||||
/* ═══════════════════════════════════════════════════════════
|
||||
手绘涂鸦风 专用样式层(叠加在 tokens.css 之上,须在其后引入)
|
||||
纸纹网格 / 抖动圆角卡片 / 马克笔高亮 / 标题涂鸦下划线 / Element Plus 皮肤
|
||||
只加类不改布局:sketch-card(卡片) sketch-panel(大面板) sketch-btn(按钮)
|
||||
sketch-tag(状态标签) sketch-header(顶栏) marker-highlight(数字高亮)
|
||||
═══════════════════════════════════════════════════════════ */
|
||||
|
||||
/* ── 素描纸纹理:淡方格(数学本)── */
|
||||
body {
|
||||
background-image:
|
||||
linear-gradient(rgba(51, 48, 42, 0.045) 1px, transparent 1px),
|
||||
linear-gradient(90deg, rgba(51, 48, 42, 0.045) 1px, transparent 1px);
|
||||
background-size: 28px 28px;
|
||||
}
|
||||
|
||||
/* ── 手绘抖动圆角常量 ── */
|
||||
:root {
|
||||
--radius-rough-sm: 255px 15px 225px 15px / 15px 225px 15px 255px; /* 按钮/标签 */
|
||||
--radius-rough-md: 14px 5px 16px 6px / 6px 15px 5px 17px; /* 卡片 */
|
||||
--radius-rough-panel: 10px 4px 12px 5px / 5px 11px 4px 13px; /* 大面板 */
|
||||
--stroke-ring: 0 0 0 1.5px var(--border-strong); /* 手绘描边环 */
|
||||
}
|
||||
|
||||
/* ── 卡片(KPI 四卡 / 时段卡 / 错误框):便签纸 + 墨描边 + 贴纸阴影 + 微倾 ── */
|
||||
.sketch-card {
|
||||
background: var(--bg-card);
|
||||
border-color: var(--border-strong);
|
||||
border-radius: var(--radius-rough-md);
|
||||
box-shadow: var(--stroke-ring), var(--shadow-card);
|
||||
transition: box-shadow 0.2s ease, border-color 0.2s ease, rotate 0.2s ease;
|
||||
}
|
||||
.sketch-card:nth-child(odd) {
|
||||
rotate: -0.6deg;
|
||||
}
|
||||
.sketch-card:nth-child(even) {
|
||||
rotate: 0.5deg;
|
||||
}
|
||||
.sketch-card:hover {
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 1.6px var(--accent), 4px 4px 0 rgba(224, 64, 44, 0.22);
|
||||
rotate: 0deg; /* 拿起便签:悬停摆正 */
|
||||
}
|
||||
|
||||
/* ── 大面板(任务/用户管理表格容器):倾角更小,避免锁屏滚动区边缘裁切 ── */
|
||||
.sketch-panel {
|
||||
background: var(--bg-card);
|
||||
border-color: var(--border-strong);
|
||||
border-radius: var(--radius-rough-panel);
|
||||
box-shadow: var(--stroke-ring), var(--shadow-card);
|
||||
transition: box-shadow 0.2s ease, border-color 0.2s ease, rotate 0.2s ease;
|
||||
}
|
||||
.sketch-panel:nth-child(odd) {
|
||||
rotate: 0.25deg;
|
||||
}
|
||||
.sketch-panel:nth-child(even) {
|
||||
rotate: -0.2deg;
|
||||
}
|
||||
.sketch-panel:hover {
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 1.6px var(--accent), 4px 4px 0 rgba(224, 64, 44, 0.2);
|
||||
rotate: 0deg;
|
||||
}
|
||||
|
||||
/* ── 按钮(导出等描边按钮):手绘药丸角 + 红色描边悬停 ── */
|
||||
.sketch-btn {
|
||||
background: var(--bg-card);
|
||||
border-color: var(--border-strong);
|
||||
border-radius: var(--radius-rough-sm);
|
||||
box-shadow: 2px 2px 0 rgba(51, 48, 42, 0.14);
|
||||
transition: box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
|
||||
}
|
||||
.sketch-btn:hover {
|
||||
background: var(--accent-bg);
|
||||
border-color: var(--accent);
|
||||
box-shadow: 2px 2px 0 rgba(224, 64, 44, 0.3);
|
||||
}
|
||||
.sketch-btn:disabled {
|
||||
opacity: 0.55;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* ── 状态标签:贴纸感(细描边 + 微倾)── */
|
||||
.sketch-tag {
|
||||
border: 1px solid currentColor;
|
||||
border-radius: var(--radius-rough-sm);
|
||||
box-shadow: 1.5px 1.5px 0 rgba(51, 48, 42, 0.1);
|
||||
rotate: -1deg;
|
||||
}
|
||||
|
||||
/* ── 数字荧光笔高亮:斜切黄色马克笔横带 ── */
|
||||
.marker-highlight {
|
||||
background-image: linear-gradient(99deg, transparent 0.5%, var(--highlighter) 2.5%, var(--highlighter) 97.5%, transparent 99.5%);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0 68%;
|
||||
background-size: 100% 42%;
|
||||
}
|
||||
|
||||
/* ── 大标题(h1.font-display):手写体 + 微倾 + 红色涂鸦下划线 + 圈重点 ── */
|
||||
h1.font-display {
|
||||
position: relative;
|
||||
width: fit-content;
|
||||
rotate: -0.6deg;
|
||||
}
|
||||
h1.font-display::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: -0.08em;
|
||||
right: -0.08em;
|
||||
bottom: -0.04em;
|
||||
height: 0.34em;
|
||||
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='12' viewBox='0 0 96 12' preserveAspectRatio='none'%3E%3Cpath d='M2 8 C 8 3, 14 3, 20 8 S 32 13, 38 8 S 50 3, 56 8 S 68 13, 74 8 S 86 3, 94 8' fill='none' stroke='%23e0402c' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") bottom left / 100% 100% no-repeat;
|
||||
}
|
||||
h1.font-display::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
right: -1.15em;
|
||||
top: -0.18em;
|
||||
width: 0.72em;
|
||||
height: 0.72em;
|
||||
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M12.5 3 C 17 2.5, 21 5.5, 21.5 10 C 22 15, 18.5 20, 13.5 20.5 C 8.5 21, 4 18, 3.5 13 C 3 8.5, 6 3.5, 10 3.2 C 11 3.1, 12 3.2, 12.5 3 Z' fill='none' stroke='%233e6cb5' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
|
||||
}
|
||||
/* 二级标题:轻微手写倾角 */
|
||||
h2.font-display {
|
||||
rotate: -0.4deg;
|
||||
}
|
||||
|
||||
/* ── 顶栏:墨色手绘波浪底边 ── */
|
||||
.sketch-header::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: -3px;
|
||||
height: 7px;
|
||||
pointer-events: none;
|
||||
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='7' viewBox='0 0 56 7' preserveAspectRatio='none'%3E%3Cpath d='M0 4 C 4 1.5, 8 1.5, 12 4 S 20 6.5, 24 4 S 32 1.5, 36 4 S 44 6.5, 48 4 S 54 1.5, 56 3' fill='none' stroke='%2333302a' stroke-width='1.8' stroke-linecap='round' stroke-opacity='0.55'/%3E%3C/svg%3E") repeat-x bottom / 56px 7px;
|
||||
}
|
||||
|
||||
/* ══════════════ Element Plus 涂鸦皮肤 ══════════════ */
|
||||
|
||||
/* 输入框/下拉/日期:便签纸 + 抖动角 + 红色马克笔聚焦 */
|
||||
.el-input__wrapper,
|
||||
.el-select__wrapper {
|
||||
background: var(--bg-card);
|
||||
border-radius: var(--radius-rough-sm);
|
||||
box-shadow: 0 0 0 1.4px var(--border-color) inset;
|
||||
transition: box-shadow 0.15s ease, background-color 0.15s ease;
|
||||
}
|
||||
.el-input__wrapper:hover,
|
||||
.el-select__wrapper:hover {
|
||||
box-shadow: 0 0 0 1.4px var(--border-strong) inset;
|
||||
}
|
||||
.el-input__wrapper.is-focus,
|
||||
.el-select__wrapper.is-focused {
|
||||
background: var(--bg-card);
|
||||
box-shadow: 0 0 0 1.8px var(--accent) inset, 2px 2px 0 rgba(224, 64, 44, 0.18);
|
||||
}
|
||||
|
||||
/* 下拉/日期弹层:手账卡片 */
|
||||
.el-popper.is-light {
|
||||
background: var(--bg-card);
|
||||
border-color: var(--border-strong);
|
||||
border-radius: var(--radius-rough-panel);
|
||||
box-shadow: var(--shadow-card);
|
||||
}
|
||||
.el-popper.is-light .el-select-dropdown__item.is-selected {
|
||||
color: var(--accent);
|
||||
}
|
||||
.el-popper.is-light .el-select-dropdown__item.is-hovering {
|
||||
background: var(--accent-bg);
|
||||
}
|
||||
|
||||
/* 日期面板:今天/选中/悬停 = 马克笔 */
|
||||
.el-date-table td.today .el-date-table-cell__text {
|
||||
color: var(--accent);
|
||||
}
|
||||
.el-date-table td.current .el-date-table-cell__text {
|
||||
background-color: var(--accent);
|
||||
color: #fff;
|
||||
border-radius: var(--radius-rough-sm);
|
||||
}
|
||||
.el-date-table td.available:hover .el-date-table-cell__text {
|
||||
background-color: var(--accent-bg);
|
||||
}
|
||||
|
||||
/* 弹窗:便签卡 + 波浪分隔线 + 手写标题 */
|
||||
.el-dialog {
|
||||
background: var(--bg-card);
|
||||
border: 1.6px solid var(--border-strong);
|
||||
border-radius: var(--radius-rough-panel);
|
||||
box-shadow: 6px 6px 0 rgba(51, 48, 42, 0.16);
|
||||
}
|
||||
.el-dialog__title {
|
||||
font-family: var(--font-display);
|
||||
font-weight: 400;
|
||||
}
|
||||
.el-dialog__header {
|
||||
border-bottom: 1.5px dashed rgba(51, 48, 42, 0.25);
|
||||
padding-bottom: 14px;
|
||||
}
|
||||
|
||||
/* 表格:纸面行 + 黄色马克笔悬停行 */
|
||||
.el-table {
|
||||
--el-table-bg-color: transparent;
|
||||
--el-table-tr-bg-color: transparent;
|
||||
--el-table-header-bg-color: rgba(51, 48, 42, 0.045);
|
||||
--el-table-header-text-color: var(--text-secondary);
|
||||
--el-table-border-color: rgba(51, 48, 42, 0.14);
|
||||
--el-table-row-hover-bg-color: rgba(255, 205, 64, 0.1);
|
||||
--el-table-text-color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* 分页:红色马克笔当前页 */
|
||||
.el-pagination .el-pager li.is-active {
|
||||
color: var(--accent);
|
||||
}
|
||||
.el-pagination .el-pager li:hover,
|
||||
.el-pagination button:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
/* 滚动条:墨色细条 */
|
||||
.el-scrollbar__thumb {
|
||||
background-color: rgba(51, 48, 42, 0.28);
|
||||
border-radius: 0;
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
/* ═══════════════════════════════════════════════════════════
|
||||
设计 token —— 手绘涂鸦风·彩色马克笔(《设计风格.md》)
|
||||
素描纸底 / 墨色线条 / 红黄蓝绿马克笔点缀 / 手写字体 / 抖动边框 / 硬偏移阴影
|
||||
★ 变量名与旧 Editorial 体系一一对应,禁止改名(组件模板按名引用)
|
||||
涂鸦专用样式(纸纹、sketch-card 等类、Element Plus 皮肤)在 styles/sketch.css
|
||||
═══════════════════════════════════════════════════════════ */
|
||||
|
||||
:root {
|
||||
/* ── 表面层次(素描纸 + 便签纸)── */
|
||||
--bg-page: #fbf7ec; /* 页面:暖米素描纸(网格纹理在 sketch.css) */
|
||||
--bg-card: #fffdf5; /* 卡片:略亮的便签纸 */
|
||||
--bg-hover: rgba(51, 48, 42, 0.05);
|
||||
--bg-muted: rgba(51, 48, 42, 0.06);
|
||||
|
||||
/* ── 线条(墨线)── */
|
||||
--border-color: rgba(51, 48, 42, 0.28);
|
||||
--border-strong: #33302a;
|
||||
|
||||
/* ── 文字阶梯(暖墨色透明度层次)── */
|
||||
--text-primary: #33302a;
|
||||
--text-secondary: rgba(51, 48, 42, 0.62);
|
||||
--text-weak: rgba(51, 48, 42, 0.42);
|
||||
--text-faint: rgba(51, 48, 42, 0.26);
|
||||
|
||||
/* ── 强调:红色马克笔 ── */
|
||||
--accent: #e0402c;
|
||||
--accent-bg: rgba(224, 64, 44, 0.09);
|
||||
|
||||
/* ── 马克笔四色 ── */
|
||||
--marker-red: #e0402c;
|
||||
--marker-yellow: #ffcf4d; /* 荧光笔高亮 */
|
||||
--marker-blue: #3e6cb5;
|
||||
--marker-green: #3c9a5f;
|
||||
--highlighter: rgba(255, 205, 64, 0.52); /* 数字高亮带(半透明) */
|
||||
|
||||
/* ── 状态(马克笔色 + 浅色底,图标/文字双通道)── */
|
||||
--status-done: var(--marker-green); /* 已完成 */
|
||||
--status-in-progress: var(--marker-blue); /* 进行中 */
|
||||
--status-pending: #8f8877; /* 待领取 */
|
||||
--status-abnormal: var(--marker-red); /* 异常:红色 + ⚠ 图标 */
|
||||
--status-done-bg: rgba(60, 154, 95, 0.12);
|
||||
--status-in-progress-bg: rgba(62, 108, 181, 0.10);
|
||||
--status-pending-bg: rgba(143, 136, 119, 0.14);
|
||||
--status-abnormal-bg: rgba(224, 64, 44, 0.10);
|
||||
|
||||
/* ── 硬偏移阴影(手绘贴纸感,禁止模糊阴影)── */
|
||||
--shadow-card: 3px 3px 0 rgba(51, 48, 42, 0.14);
|
||||
--shadow-raised: 5px 5px 0 rgba(51, 48, 42, 0.18);
|
||||
|
||||
/* ── 抖动圆角(手绘描边,半径值刻意不对称)── */
|
||||
--radius-card: 14px 5px 16px 6px / 6px 15px 5px 17px;
|
||||
--radius-element: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
||||
--radius-pill: 36px 10px 30px 12px / 12px 34px 10px 38px;
|
||||
|
||||
/* ── 字体:中文手写标题 + 手写标签 + 无衬线正文(fontsource 本地打包)── */
|
||||
--font-display: 'ZCOOL KuaiLe', Georgia, 'Times New Roman', 'Noto Serif SC', 'Songti SC', SimSun, serif;
|
||||
--font-body: system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
||||
--font-mono: 'ZCOOL QingKe HuangYou', 'SF Mono', 'Cascadia Mono', Consolas, monospace;
|
||||
|
||||
/* ── Element Plus 主题覆盖(马克笔配色)── */
|
||||
--el-color-primary: #e0402c;
|
||||
--el-color-primary-light-3: #e86a56;
|
||||
--el-color-primary-light-5: #ed9487;
|
||||
--el-color-primary-light-7: #f4bdb5;
|
||||
--el-color-primary-light-8: #f7ccc5;
|
||||
--el-color-primary-light-9: #fbe8e3;
|
||||
--el-color-primary-dark-2: #b33322;
|
||||
--el-color-success: #3c9a5f;
|
||||
--el-color-warning: #d9a424;
|
||||
--el-color-danger: #e0402c;
|
||||
--el-color-error: #e0402c;
|
||||
--el-border-radius-base: 0px;
|
||||
--el-border-radius-small: 0px;
|
||||
--el-border-color: rgba(51, 48, 42, 0.24);
|
||||
--el-border-color-light: rgba(51, 48, 42, 0.18);
|
||||
--el-border-color-lighter: rgba(51, 48, 42, 0.12);
|
||||
--el-border-color-extra-light: rgba(51, 48, 42, 0.08);
|
||||
--el-fill-color-blank: #fffdf5;
|
||||
--el-fill-color-light: rgba(51, 48, 42, 0.06);
|
||||
--el-bg-color: #fbf7ec;
|
||||
--el-bg-color-overlay: #fffdf5;
|
||||
--el-text-color-primary: #33302a;
|
||||
--el-text-color-regular: rgba(51, 48, 42, 0.62);
|
||||
--el-text-color-secondary: rgba(51, 48, 42, 0.48);
|
||||
--el-text-color-placeholder: rgba(51, 48, 42, 0.38);
|
||||
--el-text-color-disabled: rgba(51, 48, 42, 0.28);
|
||||
--el-box-shadow-light: 3px 3px 0 rgba(51, 48, 42, 0.14);
|
||||
--el-box-shadow: 4px 4px 0 rgba(51, 48, 42, 0.16);
|
||||
--el-mask-color: rgba(251, 247, 236, 0.72);
|
||||
--el-pagination-active-color: #e0402c;
|
||||
--el-switch-off-color: rgba(51, 48, 42, 0.22);
|
||||
--el-font-family: var(--font-body);
|
||||
}
|
||||
|
||||
body {
|
||||
background: var(--bg-page);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-body);
|
||||
line-height: 1.6;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
/* 手写标题 */
|
||||
.font-display {
|
||||
font-family: var(--font-display);
|
||||
}
|
||||
|
||||
/* 手写标签(原等宽点缀位,换成中文手写体) */
|
||||
.font-mono {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
/* 数字对齐:表格列 */
|
||||
.tabular-nums {
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* hover 下划线动画(墨线,保留原结构) */
|
||||
.hover-underline {
|
||||
position: relative;
|
||||
}
|
||||
.hover-underline::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: -2px;
|
||||
width: 100%;
|
||||
height: 2px;
|
||||
background: var(--text-primary);
|
||||
transform: scaleX(0);
|
||||
transform-origin: left;
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
.hover-underline:hover::after {
|
||||
transform: scaleX(1);
|
||||
}
|
||||
|
||||
/* ── 弹窗过渡(手绘风:柔和上移 + 轻微缩放 + 淡入,无弹性)── */
|
||||
.dialog-fade-enter-active {
|
||||
transition: opacity 0.35s ease-out, transform 0.35s ease-out;
|
||||
}
|
||||
.dialog-fade-leave-active {
|
||||
transition: opacity 0.2s ease-in, transform 0.2s ease-in;
|
||||
}
|
||||
.dialog-fade-enter-from {
|
||||
opacity: 0;
|
||||
transform: translateY(16px) scale(0.98);
|
||||
}
|
||||
.dialog-fade-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(8px) scale(0.99);
|
||||
}
|
||||
|
||||
/* 系统"减少动态效果"开启:关闭全部过渡与动画 */
|
||||
.reduced-motion *,
|
||||
.reduced-motion *::before,
|
||||
.reduced-motion *::after {
|
||||
transition: none !important;
|
||||
animation: none !important;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,257 @@
|
||||
<script setup lang="ts">
|
||||
/** 页面 1:hotel_hd 原始数据展示(前 10 条)+ 可操作(改城市 / 重置 is_ok) */
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import api from '../api'
|
||||
import type { AccountItem } from '../api/types'
|
||||
import ChangeCityDialog from '../components/ChangeCityDialog.vue'
|
||||
import { rowTint } from '../composables/hotelStatus'
|
||||
import { useHotelStore } from '../stores/hotel'
|
||||
|
||||
const store = useHotelStore()
|
||||
const { tick } = storeToRefs(store)
|
||||
|
||||
const LIMIT = 15
|
||||
const items = ref<AccountItem[]>([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
|
||||
async function load(silent = false) {
|
||||
if (!silent) loading.value = true
|
||||
try {
|
||||
const res = await api.accounts({ page: 1, size: LIMIT, sort: 'updated_at', order: 'desc' })
|
||||
items.value = res.items
|
||||
total.value = res.total
|
||||
} catch (e) {
|
||||
ElMessage.error((e as Error).message)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const rowStyle = (scope: { row: AccountItem }) => ({ background: rowTint(scope.row.is_ok) })
|
||||
|
||||
/** is_ok 原值展示:NULL 用灰色文字,其余带状态色 */
|
||||
function isOkText(v: number | null): string {
|
||||
return v === null ? 'NULL' : String(v)
|
||||
}
|
||||
function isOkClass(row: AccountItem): string {
|
||||
return `isok isok--${row.status_tone}`
|
||||
}
|
||||
|
||||
const cityDialog = ref(false)
|
||||
const activeAccount = ref<AccountItem | null>(null)
|
||||
|
||||
/** 全新包:is_ok=NULL 且还没有绑定城市 —— 这种包要“添加城市”而不是“改城市” */
|
||||
function isNewPackage(row: AccountItem): boolean {
|
||||
return row.is_ok === null && !row.city
|
||||
}
|
||||
/** 可操作城市绑定:is_ok=0(异常包) 或 全新包 */
|
||||
function canBindCity(row: AccountItem): boolean {
|
||||
return row.is_ok === 0 || isNewPackage(row)
|
||||
}
|
||||
|
||||
function openCity(row: AccountItem) {
|
||||
if (!canBindCity(row)) return
|
||||
activeAccount.value = row
|
||||
cityDialog.value = true
|
||||
}
|
||||
function afterWrite() {
|
||||
load(true)
|
||||
}
|
||||
|
||||
const todayLine = computed(() => `最新 ${LIMIT} 条(按 updated_at 倒序,共 ${total.value} 条)`)
|
||||
|
||||
watch(tick, () => load(true))
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="page">
|
||||
<div class="page__bar">
|
||||
<span class="page__title">hotel_hd</span>
|
||||
<span class="page__note">{{ todayLine }}</span>
|
||||
<span class="page__note">req_count = 包使用的总次数 · current_count = 当前城市的使用次数</span>
|
||||
<span class="page__spacer" />
|
||||
<button class="btn" type="button" @click="load()">刷新</button>
|
||||
</div>
|
||||
|
||||
<div class="page__table">
|
||||
<el-table v-loading="loading" :data="items" height="100%" size="default" border :row-style="rowStyle">
|
||||
<el-table-column prop="id" label="id" width="86" fixed />
|
||||
<el-table-column label="is_ok" width="96">
|
||||
<template #default="{ row }">
|
||||
<span :class="isOkClass(row)" :title="row.status_text">{{ isOkText(row.is_ok) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="req_count" label="req_count" width="104" align="right">
|
||||
<template #default="{ row }"><span class="mono">{{ row.req_count }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="current_count" label="current_count" width="132" align="right">
|
||||
<template #default="{ row }"><span class="mono">{{ row.current_count }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="prox" min-width="300" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<code class="prox">{{ row.prox_raw || 'NULL' }}</code>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="city" label="city" width="102">
|
||||
<template #default="{ row }">{{ row.city || 'NULL' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="mt_traceid" width="200" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<code class="mono">{{ row.mt_traceid || 'NULL' }}</code>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="updated_at" label="updated_at" width="152">
|
||||
<template #default="{ row }"><span class="mono">{{ row.updated_at || '—' }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<button
|
||||
class="op"
|
||||
type="button"
|
||||
:disabled="!canBindCity(row)"
|
||||
:title="canBindCity(row)
|
||||
? (isNewPackage(row) ? '新包:添加城市后会按该城市跑起来' : '改城市:会清空代理并把状态重置为可用')
|
||||
: `只有 is_ok=0(异常包)或 is_ok=NULL 且未绑城市(新包)才能操作,当前 is_ok=${row.is_ok === null ? 'NULL' : row.is_ok} city=${row.city || 'NULL'}`"
|
||||
@click="openCity(row)"
|
||||
>
|
||||
{{ isNewPackage(row) ? '添加城市' : '改城市' }}
|
||||
</button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<template #empty>
|
||||
<div class="empty">hotel_hd 没有数据</div>
|
||||
</template>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<p class="page__foot">
|
||||
提示:prox 为代理原始 JSON(含代理账号密码,仅本机内网使用)。只有 <b>is_ok=0(异常包)</b> 可以「改城市」(会清 prox 并把 is_ok 重置为 NULL),<b>is_ok=NULL 且未绑城市的新包</b> 可以「添加城市」让包跑起来;两种情况 current_count 都保留不变。
|
||||
</p>
|
||||
|
||||
<ChangeCityDialog
|
||||
v-model="cityDialog"
|
||||
:account="activeAccount"
|
||||
:legal-cities="store.legalCities"
|
||||
:ip-count="store.cityIpCount"
|
||||
@submitted="afterWrite"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
height: 100%;
|
||||
}
|
||||
.page__bar {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 14px;
|
||||
padding: 8px 12px;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-element);
|
||||
}
|
||||
.page__title {
|
||||
font-family: var(--font-display);
|
||||
font-size: 17px;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.page__note {
|
||||
font-size: 13px;
|
||||
color: var(--text-weak);
|
||||
}
|
||||
.page__spacer {
|
||||
flex: 1;
|
||||
}
|
||||
.btn {
|
||||
height: 28px;
|
||||
padding: 0 12px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
color: var(--accent);
|
||||
background: var(--bg-page);
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--radius-element);
|
||||
cursor: pointer;
|
||||
}
|
||||
.page__table {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 6px;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-card);
|
||||
overflow: hidden;
|
||||
}
|
||||
.page__table :deep(.el-table__row) {
|
||||
height: 46px;
|
||||
}
|
||||
.page__table :deep(.el-table .cell) {
|
||||
font-size: 14px;
|
||||
}
|
||||
.page__table :deep(.el-table th.el-table__cell) {
|
||||
font-size: 13px;
|
||||
}
|
||||
.page__foot {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
color: var(--text-weak);
|
||||
}
|
||||
.mono {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 13px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.prox {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.isok {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.isok--ok {
|
||||
color: var(--marker-green);
|
||||
}
|
||||
.isok--danger {
|
||||
color: var(--marker-red);
|
||||
}
|
||||
.isok--warn {
|
||||
color: #d9a424;
|
||||
}
|
||||
.isok--muted {
|
||||
color: var(--text-weak);
|
||||
}
|
||||
.op {
|
||||
margin-right: 6px;
|
||||
padding: 2px 9px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 13px;
|
||||
color: var(--accent);
|
||||
background: none;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-pill);
|
||||
cursor: pointer;
|
||||
}
|
||||
.op:hover {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.op:disabled {
|
||||
color: var(--text-faint);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.empty {
|
||||
padding: 24px;
|
||||
font-size: 13px;
|
||||
color: var(--text-weak);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,751 @@
|
||||
<script setup lang="ts">
|
||||
/** 页面 2:查询(参考 查询.py)——左右结构:左=汇总+高危城市,右=所选日期明细表
|
||||
* 日期选择决定"所选日"的 success/reject;高危对照口径 = 昨日(所选日前一天) */
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import api from '../api'
|
||||
import type { RiskData, RiskItem } from '../api/types'
|
||||
import { fmtNumber } from '../composables/hotelStatus'
|
||||
import { useHotelStore } from '../stores/hotel'
|
||||
|
||||
function today(): string {
|
||||
const d = new Date()
|
||||
const p = (n: number) => String(n).padStart(2, '0')
|
||||
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}`
|
||||
}
|
||||
|
||||
/** 高危对照口径 = 昨日(所选日期的前一天):
|
||||
* 平台 getStats 只保留最近两天(今天/昨天),"近 5 天成功率"拿不到数据,已下线 */
|
||||
const RISK_DAYS = 1
|
||||
|
||||
const day = ref(today())
|
||||
const loading = ref(false) // 首次/手动查询:显示遮罩
|
||||
const refreshing = ref(false) // 自动静默更新:不闪遮罩
|
||||
const data = ref<RiskData | null>(null)
|
||||
const queriedAt = ref('')
|
||||
|
||||
const store = useHotelStore()
|
||||
const { autoRefresh, tick } = storeToRefs(store)
|
||||
|
||||
let inflight = false
|
||||
let lastFetch = 0
|
||||
/** 自动静默更新的最小间隔(避免 15s 全局 tick 把接口打太频) */
|
||||
const AUTO_MIN_INTERVAL = 20000
|
||||
const prevAbnormal = ref<number | null>(null)
|
||||
|
||||
const highRisk = computed<RiskItem[]>(() => data.value?.high_risk ?? [])
|
||||
const abnormal = computed<RiskItem[]>(() => data.value?.abnormal ?? [])
|
||||
const allItems = computed<RiskItem[]>(() => data.value?.items ?? [])
|
||||
|
||||
/** 表格:异常置顶,其余按所选日成功条数降序 */
|
||||
const tableRows = computed<RiskItem[]>(() =>
|
||||
[...allItems.value].sort((a, b) => {
|
||||
if (a.today_abnormal !== b.today_abnormal) return a.today_abnormal ? -1 : 1
|
||||
return (b.today_success ?? -1) - (a.today_success ?? -1)
|
||||
}),
|
||||
)
|
||||
|
||||
const successTotal = computed(() => allItems.value.reduce((s, i) => s + (i.today_success ?? 0), 0))
|
||||
const rejectTotal = computed(() => allItems.value.reduce((s, i) => s + (i.today_reject ?? 0), 0))
|
||||
|
||||
// ── 任务进度:每天任务量 / 单包产能 → 还剩多少条、还需多少包 ──
|
||||
const targetPerDay = ref(1000) // 每天任务量(可在页面改)
|
||||
const perPackage = ref(48) // 一个包约可完成条数(可在页面改)
|
||||
const doneCount = computed(() => successTotal.value)
|
||||
const remainingCount = computed(() => Math.max(0, targetPerDay.value - doneCount.value))
|
||||
|
||||
/** 现有可用包(is_ok IS NULL)每个按满产能 perPackage 算,减去已跑的 current_count 就是它还能贡献的条数 */
|
||||
const availablePackages = computed(() => data.value?.available_packages ?? [])
|
||||
const packageCapacityLeft = computed(() =>
|
||||
availablePackages.value.reduce((sum, p) => sum + Math.max(0, perPackage.value - (p.current_count ?? 0)), 0),
|
||||
)
|
||||
/** 扣掉现有包产能后,真正还需要新包补的条数 */
|
||||
const needAfterPackages = computed(() => Math.max(0, remainingCount.value - packageCapacityLeft.value))
|
||||
const packagesNeeded = computed(() => {
|
||||
const per = perPackage.value
|
||||
if (needAfterPackages.value <= 0 || !per || per <= 0) return 0
|
||||
return Math.ceil(needAfterPackages.value / per)
|
||||
})
|
||||
const progressPercent = computed(() => {
|
||||
const t = targetPerDay.value
|
||||
if (!t || t <= 0) return 0
|
||||
return Math.min(100, Math.round((doneCount.value / t) * 1000) / 10)
|
||||
})
|
||||
|
||||
const rate = computed(() => {
|
||||
const s = successTotal.value
|
||||
const r = rejectTotal.value
|
||||
return s + r > 0 ? `${((s / (s + r)) * 100).toFixed(1)}%` : '—'
|
||||
})
|
||||
/** 平台是否可用 / 所选日期平台是否有统计(都和"0 条完成"是两回事) */
|
||||
const platformOk = computed(() => data.value?.platform_ok ?? true)
|
||||
const hasData = computed(() => data.value?.has_data ?? true)
|
||||
/** 表格里的"该日"= 后端真正返回的日期(与日期选择框联动) */
|
||||
const viewedDate = computed(() => data.value?.date ?? day.value)
|
||||
/** 昨日(参考窗口)日期文本 */
|
||||
const yesterdayText = computed(() => {
|
||||
const w = data.value?.window
|
||||
if (!w) return '—'
|
||||
return w.start === w.end ? w.start : `${w.start} ~ ${w.end}`
|
||||
})
|
||||
|
||||
function rateText(v: number | null): string {
|
||||
return v === null ? '—' : `${v.toFixed(1)}%`
|
||||
}
|
||||
|
||||
const rowStyle = (scope: { row: RiskItem }) => ({
|
||||
background: scope.row.today_abnormal ? 'rgba(224, 64, 44, 0.07)' : undefined,
|
||||
})
|
||||
|
||||
async function run(silent = false) {
|
||||
if (!day.value) {
|
||||
if (!silent) ElMessage.warning('请选择日期')
|
||||
return
|
||||
}
|
||||
if (inflight) return // 防重入,避免请求堆积
|
||||
inflight = true
|
||||
lastFetch = Date.now()
|
||||
if (silent) refreshing.value = true
|
||||
else loading.value = true
|
||||
try {
|
||||
const res = await api.platformRisk({ date: day.value, days: RISK_DAYS })
|
||||
data.value = res
|
||||
queriedAt.value = new Date().toLocaleTimeString('zh-CN')
|
||||
|
||||
const grew = prevAbnormal.value !== null && res.counts.abnormal > prevAbnormal.value
|
||||
prevAbnormal.value = res.counts.abnormal
|
||||
|
||||
// 自动更新时只在“异常城市变多”才弹提示,避免每 20 秒刷一次消息
|
||||
if (!silent || grew) {
|
||||
if (!res.platform_ok) {
|
||||
ElMessage.error('平台接口不可用,该日期数据为空(请检查网络或平台状态)')
|
||||
} else if (!res.has_data) {
|
||||
ElMessage.warning(`平台没有 ${res.date} 的统计:getStats 只保留最近两天(今天 / 昨天)`)
|
||||
}
|
||||
if (res.counts.abnormal) {
|
||||
ElMessage.error(
|
||||
`${res.date} 有 ${res.counts.abnormal} 个城市异常(样本 > ${res.abnormal_min_sample} 条且成功率 0%):` +
|
||||
res.abnormal.map((i) => i.city).join('、'),
|
||||
)
|
||||
}
|
||||
if (res.counts.high_risk) {
|
||||
ElMessage.warning(
|
||||
`昨日(${res.window.start})有 ${res.counts.high_risk} 个高危城市:` +
|
||||
res.high_risk.map((i) => `${i.city} ${rateText(i.hist_rate)}`).join('、'),
|
||||
)
|
||||
}
|
||||
if (res.logs_available && res.empty_fetch_total) {
|
||||
ElMessage.info(
|
||||
`该日有 ${res.empty_fetch_total} 次拿任务失败(get_one_task 返回 False),涉及 ${res.counts.empty_fetch_cities} 个城市`,
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (!silent) ElMessage.error((e as Error).message)
|
||||
} finally {
|
||||
inflight = false
|
||||
loading.value = false
|
||||
refreshing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 自动更新:跟随顶栏自动刷新开关(页面隐藏时 store 那边会暂停)
|
||||
watch(tick, () => {
|
||||
if (Date.now() - lastFetch < AUTO_MIN_INTERVAL) return
|
||||
run(true)
|
||||
})
|
||||
// 改日期立即重查
|
||||
watch(day, () => run())
|
||||
|
||||
onMounted(() => run())
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="page">
|
||||
<div class="page__bar">
|
||||
<label class="field">
|
||||
<span class="field__label">日期</span>
|
||||
<input v-model="day" class="field__input" type="date" />
|
||||
</label>
|
||||
<button v-if="day !== today()" class="btn" type="button" @click="day = today()">回到今天</button>
|
||||
<button class="btn btn--primary" type="button" :disabled="loading || refreshing" @click="run()">
|
||||
{{ loading ? '查询中…' : refreshing ? '更新中…' : '立即刷新' }}
|
||||
</button>
|
||||
<span class="auto-hint">
|
||||
<i class="dot" :class="{ 'dot--on': autoRefresh, 'dot--busy': refreshing }" />
|
||||
{{ autoRefresh ? '自动更新中(约 20 秒一次)' : '自动更新已暂停' }}
|
||||
<template v-if="queriedAt"> · 上次 {{ queriedAt }}</template>
|
||||
</span>
|
||||
<span v-if="data && !platformOk" class="page__warn">平台接口不可用</span>
|
||||
<span v-else-if="data && !hasData" class="page__warn">该日期平台无统计</span>
|
||||
<span class="page__note">
|
||||
正在查看 {{ viewedDate }};高危对照 = 昨日({{ yesterdayText }})。平台只保留最近两天。
|
||||
</span>
|
||||
<span class="page__spacer" />
|
||||
</div>
|
||||
|
||||
<div class="page__body">
|
||||
<!-- 左栏:任务进度 + 汇总 + 高危城市 -->
|
||||
<aside class="side">
|
||||
<div class="progress-card">
|
||||
<div class="progress-card__head">
|
||||
<span class="panel__title">任务进度</span>
|
||||
<span class="progress-card__spacer" />
|
||||
<label class="mini">
|
||||
每天任务量
|
||||
<input v-model.number="targetPerDay" class="mini__input" type="number" min="0" step="100" />
|
||||
</label>
|
||||
<label class="mini">
|
||||
单包产出
|
||||
<input v-model.number="perPackage" class="mini__input" type="number" min="1" step="1" />
|
||||
</label>
|
||||
</div>
|
||||
<div class="progress-card__nums">
|
||||
<div class="pn">
|
||||
<span class="pn__label">已完成</span>
|
||||
<b class="pn__num pn__num--ok">{{ fmtNumber(doneCount) }}</b>
|
||||
</div>
|
||||
<div class="pn">
|
||||
<span class="pn__label">还剩</span>
|
||||
<b class="pn__num pn__num--danger">{{ fmtNumber(remainingCount) }} 条</b>
|
||||
</div>
|
||||
<div class="pn">
|
||||
<span class="pn__label">现有包可补</span>
|
||||
<b class="pn__num pn__num--warn">{{ fmtNumber(packageCapacityLeft) }} 条</b>
|
||||
</div>
|
||||
<div class="pn">
|
||||
<span class="pn__label">还需新包</span>
|
||||
<b class="pn__num pn__num--danger">{{ fmtNumber(packagesNeeded) }} 个</b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="track"><i class="track__bar" :style="{ width: progressPercent + '%' }" /></div>
|
||||
<p class="progress-card__note">
|
||||
已完成 {{ fmtNumber(doneCount) }} / {{ fmtNumber(targetPerDay) }} 条({{ progressPercent.toFixed(1) }}%)
|
||||
· 还剩 {{ fmtNumber(remainingCount) }} 条
|
||||
· 现有可用包 {{ availablePackages.length }} 个(没跑满 {{ fmtNumber(perPackage) }} 的按 {{ fmtNumber(perPackage) }} 算)合计可补
|
||||
{{ fmtNumber(packageCapacityLeft) }} 条
|
||||
→ 还差 {{ fmtNumber(needAfterPackages) }} 条 → 需新包
|
||||
<b>{{ fmtNumber(packagesNeeded) }}</b> 个
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="stats">
|
||||
<div class="stat">
|
||||
<span class="stat__label">所选日成功条数</span>
|
||||
<b class="stat__num stat__num--ok">{{ fmtNumber(successTotal) }}</b>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<span class="stat__label">所选日失败条数</span>
|
||||
<b class="stat__num stat__num--danger">{{ fmtNumber(rejectTotal) }}</b>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<span class="stat__label">所选日成功率</span>
|
||||
<b class="stat__num">{{ rate }}</b>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<span class="stat__label">城市数</span>
|
||||
<b class="stat__num">{{ data?.counts.cities ?? 0 }}</b>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<span class="stat__label">所选日异常</span>
|
||||
<b class="stat__num" :class="abnormal.length ? 'stat__num--danger' : 'stat__num--ok'">
|
||||
{{ abnormal.length }}
|
||||
</b>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<span class="stat__label">高危(昨日)</span>
|
||||
<b class="stat__num" :class="highRisk.length ? 'stat__num--danger' : 'stat__num--ok'">
|
||||
{{ highRisk.length }}
|
||||
</b>
|
||||
</div>
|
||||
<div class="stat stat--wide">
|
||||
<span class="stat__label">拿任务失败城市</span>
|
||||
<b class="stat__num" :class="data?.counts.empty_fetch_cities ? 'stat__num--warn' : ''">
|
||||
{{ data?.logs_available ? data?.counts.empty_fetch_cities ?? 0 : '—' }}
|
||||
</b>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel__head">
|
||||
<span class="panel__title">高危城市</span>
|
||||
<span class="panel__spacer" />
|
||||
<span class="panel__count" :class="{ 'panel__count--zero': !highRisk.length }">
|
||||
{{ highRisk.length }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="panel__note">
|
||||
昨日({{ yesterdayText }})成功率 < {{ data?.threshold ?? 75 }}%,样本 ≥
|
||||
{{ data?.min_sample ?? 5 }}
|
||||
</p>
|
||||
<div v-if="!highRisk.length" class="panel__empty">
|
||||
{{ loading ? '查询中…' : '昨日没有高危城市 👍' }}
|
||||
</div>
|
||||
<div v-else class="risk-grid">
|
||||
<div v-for="row in highRisk" :key="row.city" class="risk-item">
|
||||
<span class="risk-item__city">{{ row.city }}</span>
|
||||
<span class="risk-item__rate">{{ rateText(row.hist_rate) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<!-- 右栏:当日明细表(占满全高) -->
|
||||
<div class="page__table">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="tableRows"
|
||||
height="100%"
|
||||
size="default"
|
||||
border
|
||||
:row-style="rowStyle"
|
||||
>
|
||||
<el-table-column label="城市" width="200" fixed>
|
||||
<template #default="{ row }">
|
||||
<span class="city">{{ row.city }}</span>
|
||||
<span
|
||||
v-if="row.empty_fetch_count > 0"
|
||||
class="tag-empty"
|
||||
:title="`该日拿任务失败 ${row.empty_fetch_count} 次(领任务失败 / 城市不匹配,明细见 logs/run_*.jsonl 的 fetch_empty)`"
|
||||
>
|
||||
拿任务失败 {{ row.empty_fetch_count }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="`${viewedDate} success`" min-width="160" align="right">
|
||||
<template #default="{ row }"><span class="mono">{{ fmtNumber(row.today_success) }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="`${viewedDate} reject`" min-width="160" align="right">
|
||||
<template #default="{ row }">
|
||||
<span class="mono" :class="{ danger: (row.today_reject ?? 0) > 0 }">{{ fmtNumber(row.today_reject) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="`${viewedDate} 成功率`" min-width="150" align="right">
|
||||
<template #default="{ row }">
|
||||
<span class="mono" :class="{ danger: row.today_abnormal }">{{ rateText(row.today_rate) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="昨日成功率" min-width="150" align="right">
|
||||
<template #default="{ row }">
|
||||
<span class="mono" :class="{ danger: row.high_risk }">{{ rateText(row.hist_rate) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="判定" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.today_abnormal" class="badge badge--abnormal">异常</span>
|
||||
<span v-else-if="row.high_risk" class="badge">高危</span>
|
||||
<span v-else-if="row.hist_total === 0 && row.today_rate !== null" class="weak">仅所选日</span>
|
||||
<span v-else class="weak">—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<template #empty>
|
||||
<div class="empty">点击「查询」拉取数据</div>
|
||||
</template>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="page__foot">
|
||||
成功率 = success ÷ (success + reject);<b>异常</b> = 所选日样本 > {{ data?.abnormal_min_sample ?? 5 }} 条且成功率 0%;
|
||||
<b>高危</b> = 昨日样本 ≥ {{ data?.min_sample ?? 5 }} 条且成功率 < {{ data?.threshold ?? 75 }}%(平台只保留今天/昨天,
|
||||
5 天窗口拿不到数据,已改为昨日口径);<b>还需新包</b> = ⌈(每天任务量 − 所选日 success − 现有可用包剩余产能) ÷ 单包产出⌉,其中可用包产能按"没跑满单包产出的按满额算,再减去 current_count"(参数可在左栏直接改);
|
||||
<b>拿任务失败</b> 徽标来自埋点 <code>fetch_empty</code>。
|
||||
</p>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
display: grid;
|
||||
grid-template-rows: auto minmax(0, 1fr) auto;
|
||||
gap: 10px;
|
||||
height: 100%;
|
||||
}
|
||||
.page__bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 8px 12px;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-element);
|
||||
}
|
||||
.field {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.field__label {
|
||||
font-size: 12px;
|
||||
color: var(--text-weak);
|
||||
}
|
||||
.field__input {
|
||||
height: 28px;
|
||||
padding: 0 8px;
|
||||
font-size: 13px;
|
||||
color: var(--text-primary);
|
||||
background: var(--bg-page);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-element);
|
||||
}
|
||||
.field__input:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.btn {
|
||||
height: 28px;
|
||||
padding: 0 14px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
color: var(--text-primary);
|
||||
background: var(--bg-page);
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--radius-element);
|
||||
cursor: pointer;
|
||||
}
|
||||
.btn--primary {
|
||||
color: #fff;
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.btn:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: progress;
|
||||
}
|
||||
.page__note {
|
||||
font-size: 12px;
|
||||
color: var(--text-weak);
|
||||
}
|
||||
.page__warn {
|
||||
padding: 1px 8px;
|
||||
font-size: 12px;
|
||||
color: #9a6b00;
|
||||
background: rgba(217, 164, 36, 0.18);
|
||||
border: 1px solid rgba(217, 164, 36, 0.5);
|
||||
border-radius: 6px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.auto-hint {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.dot {
|
||||
display: inline-block;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--text-faint);
|
||||
}
|
||||
.dot--on {
|
||||
background: var(--marker-green);
|
||||
}
|
||||
.dot--busy {
|
||||
background: var(--marker-yellow);
|
||||
}
|
||||
.page__spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* ── 左右结构 ── */
|
||||
.page__body {
|
||||
display: grid;
|
||||
grid-template-columns: 372px minmax(0, 1fr);
|
||||
gap: 12px;
|
||||
min-height: 0;
|
||||
}
|
||||
.side {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
/* ── 任务进度卡 ── */
|
||||
.progress-card {
|
||||
flex: none;
|
||||
padding: 9px 12px 10px;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-strong);
|
||||
border-left: 4px solid var(--accent);
|
||||
border-radius: var(--radius-card);
|
||||
box-shadow: var(--shadow-card);
|
||||
}
|
||||
.progress-card__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.progress-card__spacer {
|
||||
flex: 1;
|
||||
}
|
||||
.mini {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 11px;
|
||||
color: var(--text-weak);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.mini__input {
|
||||
width: 62px;
|
||||
height: 24px;
|
||||
padding: 0 5px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
color: var(--text-primary);
|
||||
background: var(--bg-page);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-element);
|
||||
}
|
||||
.mini__input:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.progress-card__nums {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 18px;
|
||||
margin: 8px 0 6px;
|
||||
}
|
||||
.pn {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
}
|
||||
.pn__label {
|
||||
font-size: 11px;
|
||||
color: var(--text-weak);
|
||||
}
|
||||
.pn__num {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 21px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.pn__num--ok {
|
||||
color: var(--marker-green);
|
||||
}
|
||||
.pn__num--danger {
|
||||
color: var(--marker-red);
|
||||
}
|
||||
.track {
|
||||
position: relative;
|
||||
height: 12px;
|
||||
background: var(--bg-muted);
|
||||
border-radius: 7px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.track__bar {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
background: var(--marker-green);
|
||||
border-radius: 7px;
|
||||
transition: width 0.35s ease-out;
|
||||
}
|
||||
.progress-card__note {
|
||||
margin: 7px 0 0;
|
||||
font-size: 11px;
|
||||
line-height: 1.6;
|
||||
color: var(--text-weak);
|
||||
}
|
||||
.progress-card__note b {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 13px;
|
||||
color: var(--marker-red);
|
||||
}
|
||||
.stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
flex: none;
|
||||
}
|
||||
.stat {
|
||||
padding: 8px 10px;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-color);
|
||||
border-left: 3px solid var(--accent);
|
||||
border-radius: var(--radius-element);
|
||||
}
|
||||
.stat--wide {
|
||||
grid-column: span 2;
|
||||
}
|
||||
.stat__label {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
color: var(--text-weak);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.stat__num {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 23px;
|
||||
color: var(--text-primary);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.stat__num--ok {
|
||||
color: var(--marker-green);
|
||||
}
|
||||
.stat__num--danger {
|
||||
color: var(--marker-red);
|
||||
}
|
||||
.stat__num--warn {
|
||||
color: #d9a424;
|
||||
}
|
||||
|
||||
/* 高危城市面板(只有城市 + 概率) */
|
||||
.panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 8px 10px;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-card);
|
||||
}
|
||||
.panel__head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
}
|
||||
.panel__title {
|
||||
font-family: var(--font-display);
|
||||
font-size: 16px;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.panel__spacer {
|
||||
flex: 1;
|
||||
}
|
||||
.panel__count {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 17px;
|
||||
color: var(--marker-red);
|
||||
}
|
||||
.panel__count--zero {
|
||||
color: var(--marker-green);
|
||||
}
|
||||
.panel__note {
|
||||
margin: 2px 0 6px;
|
||||
font-size: 11px;
|
||||
line-height: 1.5;
|
||||
color: var(--text-weak);
|
||||
}
|
||||
.panel__empty {
|
||||
padding: 12px 2px;
|
||||
font-size: 13px;
|
||||
color: var(--text-weak);
|
||||
}
|
||||
.risk-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
||||
gap: 6px;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.risk-item {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 6px;
|
||||
padding: 6px 9px;
|
||||
background: rgba(224, 64, 44, 0.06);
|
||||
border: 1px solid rgba(224, 64, 44, 0.35);
|
||||
border-radius: var(--radius-element);
|
||||
}
|
||||
.risk-item__city {
|
||||
font-size: 16px;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.risk-item__rate {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 19px;
|
||||
font-weight: 600;
|
||||
color: var(--marker-red);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* 右栏表格:占满全高,行更高、字更大 */
|
||||
.page__table {
|
||||
min-height: 0;
|
||||
padding: 6px;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-card);
|
||||
overflow: hidden;
|
||||
}
|
||||
.page__table :deep(.el-table__row) {
|
||||
height: 54px;
|
||||
}
|
||||
.page__table :deep(.el-table .cell) {
|
||||
font-size: 16px;
|
||||
}
|
||||
.page__table :deep(.el-table th.el-table__cell) {
|
||||
font-size: 14px;
|
||||
}
|
||||
.page__foot {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
color: var(--text-weak);
|
||||
}
|
||||
.page__foot code {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.city {
|
||||
font-size: 17px;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.tag-empty {
|
||||
margin-left: 6px;
|
||||
padding: 0 5px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 10px;
|
||||
color: #9a6b00;
|
||||
background: rgba(217, 164, 36, 0.18);
|
||||
border: 1px solid rgba(217, 164, 36, 0.5);
|
||||
border-radius: 6px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.badge {
|
||||
padding: 1px 9px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 13px;
|
||||
color: #fff;
|
||||
background: var(--marker-red);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.badge--abnormal {
|
||||
background: #b3261e;
|
||||
box-shadow: 0 0 0 2px rgba(179, 38, 30, 0.18);
|
||||
}
|
||||
.mono {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 16px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.ok {
|
||||
color: var(--marker-green);
|
||||
}
|
||||
.danger {
|
||||
color: var(--marker-red);
|
||||
}
|
||||
.weak {
|
||||
font-size: 15px;
|
||||
color: var(--text-weak);
|
||||
}
|
||||
.empty {
|
||||
padding: 24px;
|
||||
font-size: 13px;
|
||||
color: var(--text-weak);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"types": ["vite/client"],
|
||||
"allowArbitraryExtensions": true,
|
||||
|
||||
/* Linting */
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"target": "es2023",
|
||||
"lib": ["ES2023"],
|
||||
"types": ["node"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"module": "nodenext",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
// 美团酒店任务看板:前端 5175,后端 8011(避开出行任务面板的 5174/8010)
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
server: {
|
||||
port: 5175,
|
||||
strictPort: true,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://127.0.0.1:8011',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
preview: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://127.0.0.1:8011',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user