Files
crawler-plugin/frontend-vue/src/pages/jd/JdConsolePage.vue
T
huangzd1997 36e110d27c feat(jd): 首页一级入口「京东」+工作台两菜单,获取店铺数据一键采集带进度条
首页在亚马逊/视频右侧新增「京东」一级入口(恒显示),落地页 /jd-console 按亚马逊控制台样式做两张工具卡:获取店铺数据(可用)、商品上架(占位,点开只提示「暂未开通」)。

获取店铺数据改成一键:建单 → 推 jd-shop-collect-run 到本机队列 → 轮询服务端进度。进度只读两处真源——任务行状态 + scope 行合并写游标里的 itemsReceived/cursor.total(客户端抓列表第一页时把 total 写进游标),没有分母就退回不定态动画,不编造百分比;终态即停轮询。后端新增 GET /api/jd-collect/tasks/{taskId}/progress(按 taskId+userId 校归属)。

判据:JdCollectProgressQueryTest(5)、jd-console-tool-catalog.test.ts(5)、jd-console-pending-menu.mount(3)、jd-collect-progress.mount(6);catch 棘轮 blocks 314→315 按名登记(轮询 catch 非静默)。
2026-11-14 16:50:06 +08:00

463 lines
9.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="page-shell module-page jd-console">
<header class="jd-top">
<router-link class="home-back" :to="homeHref" title="返回首页">← 返回首页</router-link>
<div class="brand">
<span class="brand-logo">富</span>
<span class="brand-text">
<span class="brand-name">数富AI</span>
<span class="brand-sub">京东运营工具台</span>
</span>
</div>
<div class="top-right">
<NotificationBell />
<span class="admin-name">{{ username }}</span>
</div>
</header>
<main class="jd-body">
<section class="jd-hero">
<span class="hero-pill">店铺采集 · 商品上架</span>
<h1 class="hero-title">京东运营,一键开始</h1>
<p class="hero-sub">
获取店铺数据只需一次点击:本机客户端会自动打开已登录的京麦后台抓取商品,
实时回传进度并把数据导入后台「京东数据库」。商品上架正在建设中。
</p>
</section>
<header class="group-head">
<i class="group-dot"></i>
<span class="group-name">京东工具</span>
<span class="group-desc">采集与上架,两条主线</span>
<span class="group-count">{{ JD_TOOLS.length }} 个工具</span>
</header>
<div class="card-grid">
<template v-for="tool in JD_TOOLS" :key="tool.id">
<router-link
v-if="tool.href"
:to="tool.href"
class="tool-card"
>
<div class="tool-card-top">
<span class="tool-icon">
<svg viewBox="0 0 48 48" aria-hidden="true">
<rect x="10" y="8" width="28" height="24" />
<line x1="24" y1="14" x2="24" y2="36" />
<path class="fill" d="M19 33 L29 33 L24 38 Z" />
</svg>
</span>
<span v-if="tool.tag" class="tool-tag">{{ tool.tag }}</span>
</div>
<div class="tool-card-name">{{ tool.name }}</div>
<div class="tool-card-desc">{{ tool.desc }}</div>
<div class="tool-card-go">打开工具 →</div>
</router-link>
<button
v-else
type="button"
class="tool-card tool-card--pending"
@click="onPendingClick(tool)"
>
<div class="tool-card-top">
<span class="tool-icon tool-icon--pending">
<svg viewBox="0 0 48 48" aria-hidden="true">
<rect x="10" y="16" width="28" height="24" />
<line x1="24" y1="34" x2="24" y2="12" />
<path class="fill" d="M19 15 L29 15 L24 10 Z" />
</svg>
</span>
<span v-if="tool.tag" class="tool-tag">{{ tool.tag }}</span>
</div>
<div class="tool-card-name">{{ tool.name }}</div>
<div class="tool-card-desc">{{ tool.desc }}</div>
<div class="tool-card-go">暂未开通</div>
</button>
</template>
</div>
</main>
<div class="toast" :class="{ show: Boolean(toastText) }">{{ toastText }}</div>
</div>
</template>
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue'
import NotificationBell from '@/shared/components/NotificationBell.vue'
import { resolvePageHref } from '@/shared/page-prefix'
import { JD_TOOLS, type JdToolInfo } from '@/pages/jd/tool-catalog'
/** 返回桌面入口首页(亚马逊 / 京东 / 视频 一级入口) */
const homeHref = resolvePageHref('/new_web_source/home.html')
const username = ref('admin')
const toastText = ref('')
let toastTimer: number | undefined
function showToast(message: string) {
toastText.value = message
if (toastTimer) {
window.clearTimeout(toastTimer)
}
toastTimer = window.setTimeout(() => {
toastText.value = ''
toastTimer = undefined
}, 2500)
}
/** 占位菜单(商品上架):没有 href 的卡片点开只提示,不做任何请求。 */
function onPendingClick(tool: JdToolInfo) {
showToast(`${tool.name}暂未开通,敬请期待`)
}
onMounted(() => {
const localName = (window.localStorage.getItem('username') || '').trim()
if (localName) username.value = localName
})
onBeforeUnmount(() => {
if (toastTimer !== undefined) {
window.clearTimeout(toastTimer)
toastTimer = undefined
}
})
</script>
<style scoped>
.jd-console {
display: flex;
flex-direction: column;
min-height: 100vh;
background-color: #1a1f2e;
background-image: radial-gradient(rgba(45, 212, 191, 0.08) 1px, transparent 1px);
background-size: 48px 48px;
font-family: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "微软雅黑", sans-serif;
}
/* ===== 顶栏(同亚马逊工作台形状,品牌副标题换成京东) ===== */
.jd-top {
flex: 0 0 auto;
min-height: 64px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
padding: 0 28px;
background: #1a1f2e;
border-bottom: 1px solid #3e4a62;
}
.home-back {
flex-shrink: 0;
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 14px;
border: 1px solid #3e4a62;
border-radius: 6px;
color: #c8d2e2;
font-size: 13px;
text-decoration: none;
white-space: nowrap;
transition: all 0.2s;
}
.home-back:hover {
background: #2b3447;
color: #f5f8fc;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
flex-shrink: 0;
}
.brand-logo {
display: flex;
align-items: center;
justify-content: center;
width: 38px;
height: 38px;
border-radius: 8px;
background: #e1251b;
color: #fff;
font-size: 20px;
font-weight: 700;
box-shadow: 0 2px 8px rgba(225, 37, 27, 0.32);
}
.brand-text {
display: flex;
flex-direction: column;
line-height: 1.35;
}
.brand-name {
color: #f5f8fc;
font-size: 17px;
font-weight: 700;
white-space: nowrap;
}
.brand-sub {
color: #a0acbe;
font-size: 10px;
white-space: nowrap;
}
.top-right {
display: flex;
align-items: center;
gap: 14px;
flex-shrink: 0;
}
.admin-name {
color: #c8d2e2;
font-size: 13px;
font-weight: 700;
white-space: nowrap;
}
/* ===== 主体 ===== */
.jd-body {
flex: 1 1 auto;
min-height: 0;
overflow-y: auto;
padding: 14px 28px 28px;
}
.jd-hero {
max-width: 1440px;
margin: 0 auto 20px;
padding: 26px 30px;
border: 1px solid #3e4a62;
border-radius: 12px;
background: #232a3b;
}
.hero-pill {
display: inline-block;
margin-bottom: 12px;
padding: 4px 12px;
border: 1px solid rgba(225, 37, 27, 0.3);
border-radius: 20px;
background: #3a1a18;
color: #ff8a80;
font-size: 11px;
font-weight: 700;
}
.hero-title {
margin: 0 0 8px;
color: #f5f8fc;
font-size: 26px;
font-weight: 700;
}
.hero-sub {
max-width: 720px;
margin: 0;
color: #c8d2e2;
font-size: 12px;
line-height: 1.7;
}
.group-head {
max-width: 1440px;
margin: 0 auto 14px;
display: flex;
align-items: center;
gap: 10px;
}
.group-dot {
width: 10px;
height: 10px;
border-radius: 2px;
background: #e1251b;
}
.group-name {
color: #f5f8fc;
font-size: 18px;
font-weight: 700;
}
.group-desc {
color: #a0acbe;
font-size: 12px;
}
.group-count {
margin-left: auto;
color: #a0acbe;
font-size: 12px;
}
/* ===== 卡片墙(同亚马逊 tool-card 形状) ===== */
.card-grid {
max-width: 1440px;
margin: 0 auto 28px;
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 14px;
}
.tool-card {
display: flex;
flex-direction: column;
justify-content: space-between;
min-width: 0;
min-height: 165px;
padding: 16px;
border: 2px solid #2a3344;
border-radius: 10px;
background: #2b3447;
text-align: left;
text-decoration: none;
font: inherit;
cursor: pointer;
transition: all 0.2s;
}
.tool-card:hover {
background: #323d52;
border-color: #e1251b;
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.tool-card-top {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 12px;
}
.tool-icon {
display: flex;
align-items: center;
justify-content: center;
width: 46px;
height: 46px;
border-radius: 10px;
background: linear-gradient(180deg, #ff7a70, #e1251b);
}
.tool-icon svg {
width: 30px;
height: 30px;
fill: none;
stroke: #fff;
stroke-width: 3;
stroke-linecap: butt;
}
.tool-icon svg .fill {
fill: #fff;
stroke: none;
}
.tool-icon--pending {
background: linear-gradient(180deg, #6b778d, #4a5568);
}
.tool-tag {
padding: 2px 8px;
border-radius: 4px;
background: #3a1a18;
color: #ff8a80;
font-size: 10px;
font-weight: 700;
white-space: nowrap;
}
.tool-card:hover .tool-tag {
background: #e1251b;
color: #ffffff;
}
.tool-card-name {
margin-bottom: 6px;
color: #f5f8fc;
font-size: 15px;
font-weight: 700;
}
.tool-card-desc {
flex: 1;
color: #a0acbe;
font-size: 11px;
line-height: 1.5;
}
.tool-card-go {
margin-top: 12px;
color: #a0acbe;
font-size: 11px;
transition: color 0.2s;
}
.tool-card:hover .tool-card-go {
color: #ff8a80;
font-weight: 700;
}
.tool-card--pending {
cursor: default;
opacity: 0.6;
}
.tool-card--pending:hover {
border-color: #2a3344;
background: #2b3447;
transform: none;
box-shadow: none;
}
.tool-card--pending:hover .tool-card-go {
color: #a0acbe;
font-weight: 400;
}
/* ===== toast ===== */
.toast {
position: fixed;
bottom: 60px;
right: 30px;
z-index: 1000;
max-width: min(420px, calc(100vw - 60px));
padding: 12px 20px;
border-radius: 6px;
border-left: 4px solid #f59e0b;
background: #3d4a63;
color: #f5f8fc;
font-size: 13px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
opacity: 0;
pointer-events: none;
transition: opacity 0.3s;
}
.toast.show {
opacity: 1;
}
@media (max-width: 1100px) {
.card-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.jd-body {
padding: 14px 16px 24px;
}
}
</style>