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 非静默)。
This commit is contained in:
@@ -63,6 +63,15 @@
|
||||
:class="{ disabled: !videoHref }"
|
||||
data-column-key="wb"
|
||||
>视频</router-link>
|
||||
|
||||
<!-- 京东入口:一级入口,不挂在亚马逊/视频的权限树里(京东工具台自带两个菜单,
|
||||
权限收口在工具台内部;入口恒显示,避免账号还没配京东菜单时入口凭空消失)。 -->
|
||||
<router-link
|
||||
:to="jdHref"
|
||||
class="entrance-btn jd"
|
||||
:class="{ disabled: !jdHref }"
|
||||
data-column-key="jd"
|
||||
>京东</router-link>
|
||||
</div>
|
||||
|
||||
<div class="toast" :class="{ show: Boolean(toastText) }">{{ toastText }}</div>
|
||||
@@ -115,6 +124,8 @@ const permissionUnavailable = ref(false)
|
||||
|
||||
const amazonHref = computed(() => resolvePageHref('/new_web_source/amazon-console.html'))
|
||||
const videoHref = computed(() => resolvePageHref('/new_web_source/image-video.html'))
|
||||
/** 京东工作台(两个菜单:获取店铺数据 / 商品上架,见 pages/jd/tool-catalog.ts) */
|
||||
const jdHref = computed(() => resolvePageHref('/new_web_source/jd-console.html'))
|
||||
|
||||
const canShow = computed(() =>
|
||||
permissionUnavailable.value ? { amazon: true, video: true } : permissionState.value,
|
||||
|
||||
@@ -1,40 +1,157 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref } from 'vue'
|
||||
import { createJdCollectTask, type JdListTab } from '../../shared/api/types/modules/jd-collect.ts'
|
||||
import { getPywebviewApi } from '../../shared/bridges/pywebview.ts'
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import {
|
||||
createJdCollectTask,
|
||||
fetchJdCollectProgress,
|
||||
type JdCollectProgressVo,
|
||||
type JdListTab,
|
||||
} from '@/shared/api/types/modules/jd-collect'
|
||||
import { getPywebviewApi } from '@/shared/bridges/pywebview'
|
||||
import { resolvePageHref } from '@/shared/page-prefix'
|
||||
import { isTerminalTaskStatus } from '@/shared/utils/task-terminal'
|
||||
import NotificationBell from '@/shared/components/NotificationBell.vue'
|
||||
|
||||
/** 京东店铺商品采集建单页(v1.4 AC-1,蓝图 §3.2)。
|
||||
/** 京东「获取店铺数据」(v1.5):一键建单 → 推送本机客户端 → 轮询服务端进度。
|
||||
*
|
||||
* 建单后把 `jd-shop-collect-run` 载荷推进本机客户端队列(v1.4 Phase 6.1 修 P0-1:
|
||||
* 只建单不推送会让任务永久停在 PENDING——兜底拉取是补救不是主链)。data 键集与
|
||||
* 客户端 jd_base.process_task 读取契约同键;推送失败不回滚建单,任务可由服务端
|
||||
* 兜底拉取(TaskClientPullService 白名单含 JD_SHOP_COLLECT)认领。
|
||||
* 三个真源与三条边界(照 v1.4 已落地的采集契约,不另造流程):
|
||||
* 1. 建单走后端 `/api/jd-collect/tasks`(通道恒 LOCAL,服务端落 PENDING);
|
||||
* 2. 建单成功把 `jd-shop-collect-run` 载荷推进本机客户端队列——只建单不推送会让任务
|
||||
* 卡在 PENDING 等兜底拉取(v1.4 Phase 6.1 P0-1 的教训);推送失败不回滚建单;
|
||||
* 3. 进度只读服务端(`/tasks/{taskId}/progress`):任务状态 + 合并写游标里的
|
||||
* itemsReceived/total。`total` 缺失时进度条走不定态,不编造百分比。
|
||||
*/
|
||||
|
||||
const form = reactive({
|
||||
shopName: '',
|
||||
onsale: true,
|
||||
offsale: false,
|
||||
maxProducts: 0,
|
||||
type ProgressStatus = 'PENDING' | 'RUNNING' | 'SUCCESS' | 'FAILED'
|
||||
type ProgressPhase = 'idle' | 'running' | 'done' | 'failed'
|
||||
|
||||
const POLL_INTERVAL_MS = 2000
|
||||
/** 一小时还没终态就停轮询(任务本身有 stale 兜底,页面不该无限烧请求)。 */
|
||||
const POLL_TIMEOUT_MS = 60 * 60 * 1000
|
||||
|
||||
const homeHref = resolvePageHref('/new_web_source/home.html')
|
||||
const backHref = resolvePageHref('/new_web_source/jd-console.html')
|
||||
|
||||
const username = ref('admin')
|
||||
const shopName = ref('')
|
||||
const submitting = ref(false)
|
||||
const taskId = ref<number | null>(null)
|
||||
const progress = ref<JdCollectProgressVo | null>(null)
|
||||
const phase = ref<ProgressPhase>('idle')
|
||||
const errorMessage = ref('')
|
||||
const successMessage = ref('')
|
||||
|
||||
let pollTimer: number | undefined
|
||||
let pollStartedAt = 0
|
||||
let pollFailures = 0
|
||||
|
||||
const statusText = computed(() => {
|
||||
const status = progress.value?.status
|
||||
if (phase.value === 'done') return '获取完成'
|
||||
if (phase.value === 'failed') return '获取失败'
|
||||
switch (status) {
|
||||
case 'PENDING':
|
||||
return '等待本机客户端领取任务…'
|
||||
case 'RUNNING':
|
||||
return '正在获取店铺数据…'
|
||||
case 'SUCCESS':
|
||||
return '获取完成'
|
||||
case 'FAILED':
|
||||
return '获取失败'
|
||||
default:
|
||||
return '已提交,正在确认任务状态…'
|
||||
}
|
||||
})
|
||||
|
||||
const submitting = ref(false)
|
||||
const successMessage = ref('')
|
||||
const errorMessage = ref('')
|
||||
const itemsReceived = computed(() => progress.value?.itemsReceived ?? 0)
|
||||
const totalCount = computed(() => {
|
||||
const total = progress.value?.total
|
||||
return typeof total === 'number' && total > 0 ? total : null
|
||||
})
|
||||
|
||||
function buildListTabs(): JdListTab[] {
|
||||
const tabs: JdListTab[] = []
|
||||
if (form.onsale) tabs.push('ONSALE')
|
||||
if (form.offsale) tabs.push('OFFSALE')
|
||||
return tabs
|
||||
/** 百分比:终态 100;有 total 按已落库商品数算(封顶 99 直到服务端落 SUCCESS)。 */
|
||||
const percent = computed<number | null>(() => {
|
||||
if (phase.value === 'done') return 100
|
||||
const total = totalCount.value
|
||||
if (!total) return null
|
||||
const done = Math.min(itemsReceived.value, total)
|
||||
return Math.max(0, Math.min(99, Math.round((done * 100) / total)))
|
||||
})
|
||||
|
||||
const percentText = computed(() => (percent.value === null ? '' : `${percent.value}%`))
|
||||
|
||||
const progressMeta = computed(() => {
|
||||
const vo = progress.value
|
||||
if (!vo) return ''
|
||||
const parts: string[] = [`已采集 ${itemsReceived.value} 个商品`]
|
||||
if (totalCount.value) {
|
||||
parts.push(`共 ${totalCount.value} 个`)
|
||||
}
|
||||
if (typeof vo.page === 'number' && vo.page > 0) {
|
||||
parts.push(`第 ${vo.page} 页`)
|
||||
}
|
||||
if (typeof vo.batches === 'number' && vo.batches > 0) {
|
||||
parts.push(`已回传 ${vo.batches} 批`)
|
||||
}
|
||||
return parts.join(' · ')
|
||||
})
|
||||
|
||||
const isRunning = computed(() => phase.value === 'running' || submitting.value)
|
||||
|
||||
function stopPolling() {
|
||||
if (pollTimer !== undefined) {
|
||||
window.clearTimeout(pollTimer)
|
||||
pollTimer = undefined
|
||||
}
|
||||
}
|
||||
|
||||
function applyTerminal(vo: JdCollectProgressVo) {
|
||||
stopPolling()
|
||||
// 终态集合走共享词表(shared/utils/task-terminal,含 COMPLETED≡SUCCESS);
|
||||
// 只有明确 FAILED 才当失败,其余终态都按完成展示——窄集合是六页踩过的坑。
|
||||
if (vo.status !== 'FAILED') {
|
||||
phase.value = 'done'
|
||||
successMessage.value = `获取完成:共采集 ${vo.itemsReceived ?? 0} 个商品,` +
|
||||
'已导入后台「京东数据库」。'
|
||||
return
|
||||
}
|
||||
phase.value = 'failed'
|
||||
errorMessage.value = vo.message?.trim()
|
||||
|| '获取失败:没有拿到失败原因,请到客户端任务列表查看详情'
|
||||
}
|
||||
|
||||
async function pollProgress(id: number) {
|
||||
try {
|
||||
const vo = await fetchJdCollectProgress(id)
|
||||
progress.value = vo
|
||||
pollFailures = 0
|
||||
if (isTerminalTaskStatus(vo.status)) {
|
||||
applyTerminal(vo)
|
||||
return
|
||||
}
|
||||
} catch (err) {
|
||||
pollFailures += 1
|
||||
// 单次失败不打断轮询(网络抖动/切页);连续失败 5 次才把进度条挂上提示,
|
||||
// 异常原文只留 console(英文原文不进界面)。
|
||||
console.error('[jd-collect] 进度查询失败', err)
|
||||
if (pollFailures >= 5) {
|
||||
errorMessage.value = '进度查询连续失败,请检查网络;任务本身仍在客户端执行'
|
||||
}
|
||||
}
|
||||
if (Date.now() - pollStartedAt > POLL_TIMEOUT_MS) {
|
||||
stopPolling()
|
||||
errorMessage.value = '进度查询超时,请到客户端任务列表查看采集结果'
|
||||
return
|
||||
}
|
||||
pollTimer = window.setTimeout(() => {
|
||||
void pollProgress(id)
|
||||
}, POLL_INTERVAL_MS)
|
||||
}
|
||||
|
||||
/** 建单成功后推送本机队列;返回 null 表示环境无队列能力(浏览器预览),返回 string 表示失败原因。 */
|
||||
async function pushToClientQueue(
|
||||
taskId: number,
|
||||
shopName: string,
|
||||
id: number,
|
||||
shop: string,
|
||||
tabs: JdListTab[],
|
||||
maxProducts: number,
|
||||
): Promise<string | null> {
|
||||
const api = getPywebviewApi()
|
||||
if (!api?.enqueue_json) {
|
||||
@@ -43,7 +160,7 @@ async function pushToClientQueue(
|
||||
const payload = {
|
||||
type: 'jd-shop-collect-run',
|
||||
ts: Date.now(),
|
||||
data: { taskId, shopName, listTabs: tabs, maxProducts },
|
||||
data: { taskId: id, shopName: shop, listTabs: tabs, maxProducts: 0 },
|
||||
}
|
||||
const pushResult = await api.enqueue_json(payload)
|
||||
if (pushResult?.success) {
|
||||
@@ -56,191 +173,448 @@ async function pushToClientQueue(
|
||||
return '推送本机队列失败,任务将由客户端兜底拉取认领'
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
async function startCollect() {
|
||||
if (isRunning.value) return
|
||||
stopPolling()
|
||||
errorMessage.value = ''
|
||||
successMessage.value = ''
|
||||
const tabs = buildListTabs()
|
||||
if (!form.shopName.trim()) {
|
||||
errorMessage.value = '请填写要采集的京东店铺名称'
|
||||
return
|
||||
}
|
||||
if (!tabs.length) {
|
||||
errorMessage.value = '请至少勾选一个商品页签(在售中 / 已下架)'
|
||||
return
|
||||
}
|
||||
progress.value = null
|
||||
phase.value = 'running'
|
||||
submitting.value = true
|
||||
const shop = shopName.value.trim() || '京麦后台'
|
||||
const tabs: JdListTab[] = ['ONSALE', 'OFFSALE']
|
||||
try {
|
||||
const vo = await createJdCollectTask(form.shopName.trim(), tabs, form.maxProducts)
|
||||
const vo = await createJdCollectTask(shop, tabs, 0)
|
||||
taskId.value = vo.taskId
|
||||
let pushNote = ''
|
||||
try {
|
||||
const pushError = await pushToClientQueue(
|
||||
vo.taskId, form.shopName.trim(), tabs, form.maxProducts)
|
||||
if (pushError) {
|
||||
pushNote = ` ${pushError}`
|
||||
}
|
||||
const pushError = await pushToClientQueue(vo.taskId, shop, tabs)
|
||||
if (pushError) pushNote = ` ${pushError}`
|
||||
} catch (pushErr) {
|
||||
// 推送自身异常不回滚建单:任务可由服务端兜底拉取认领。
|
||||
// 异常原文(多为英文)不进界面——首条语句写界面文案(状态写入,扫描器口径非静默),
|
||||
// console 只作留链。
|
||||
pushNote = ' 推送本机队列失败,任务将由服务端兜底派发给本机客户端执行'
|
||||
console.error('[jd-collect] 推送本机队列失败', pushErr)
|
||||
}
|
||||
successMessage.value = `建单成功:任务号 ${vo.taskId}${vo.taskNo ? `(${vo.taskNo})` : ''}。` +
|
||||
'任务由本机客户端执行,请保持客户端在线并已登录京麦;采集进度在客户端任务列表查看,' +
|
||||
'落库数据到后台「京东数据库」菜单查询。' + pushNote
|
||||
if (pushNote) {
|
||||
errorMessage.value = pushNote.trim()
|
||||
}
|
||||
pollStartedAt = Date.now()
|
||||
pollFailures = 0
|
||||
void pollProgress(vo.taskId)
|
||||
} catch (err) {
|
||||
phase.value = 'failed'
|
||||
errorMessage.value = err instanceof Error ? err.message : '建单失败,请稍后重试'
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const localName = (window.localStorage.getItem('username') || '').trim()
|
||||
if (localName) username.value = localName
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stopPolling()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="jd-collect-page">
|
||||
<div class="jd-collect-panel">
|
||||
<h2>京东采集</h2>
|
||||
<p class="jd-collect-desc">
|
||||
采集京东店铺商品(列表 + 详情全部属性 + 图片),同步到后台「京东数据库」。
|
||||
任务由本机客户端执行:提交后请保持客户端在线,并确保已在客户端登录京麦。
|
||||
</p>
|
||||
<div class="page-shell module-page jd-collect-page">
|
||||
<header class="jd-top">
|
||||
<router-link class="home-back" :to="homeHref" title="返回首页">← 返回首页</router-link>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="jd-shop-name">京东店铺名称</label>
|
||||
<input
|
||||
id="jd-shop-name"
|
||||
v-model="form.shopName"
|
||||
type="text"
|
||||
placeholder="填写京麦后台显示的店铺名称"
|
||||
:disabled="submitting"
|
||||
/>
|
||||
<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="form-group">
|
||||
<label>采集商品页签</label>
|
||||
<div class="tab-checks">
|
||||
<label class="tab-check">
|
||||
<input v-model="form.onsale" type="checkbox" :disabled="submitting" />
|
||||
在售中
|
||||
</label>
|
||||
<label class="tab-check">
|
||||
<input v-model="form.offsale" type="checkbox" :disabled="submitting" />
|
||||
已下架
|
||||
</label>
|
||||
</div>
|
||||
<div class="top-right">
|
||||
<NotificationBell />
|
||||
<span class="admin-name">{{ username }}</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="jd-max-products">采集商品数上限(0 = 不限制)</label>
|
||||
<input
|
||||
id="jd-max-products"
|
||||
v-model.number="form.maxProducts"
|
||||
type="number"
|
||||
min="0"
|
||||
:disabled="submitting"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button class="jd-submit" type="button" :disabled="submitting" @click="submit">
|
||||
{{ submitting ? '提交中…' : '开始采集' }}
|
||||
</button>
|
||||
|
||||
<p v-if="successMessage" class="jd-feedback success">{{ successMessage }}</p>
|
||||
<p v-if="errorMessage" class="jd-feedback error">{{ errorMessage }}</p>
|
||||
<div class="tool-head">
|
||||
<router-link class="tool-head__back" :to="backHref">← 返回京东工具台</router-link>
|
||||
<span class="tool-head__title">获取店铺数据</span>
|
||||
<span class="tool-head__desc">
|
||||
一键抓取已登录京麦后台的店铺商品(列表 + 详情全部属性 + 图片),导入后台「京东数据库」。
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<main class="jd-body">
|
||||
<div class="collect-card">
|
||||
<div class="form-group">
|
||||
<label for="jd-shop-name">店铺名称(可选)</label>
|
||||
<input
|
||||
id="jd-shop-name"
|
||||
v-model="shopName"
|
||||
type="text"
|
||||
placeholder="留空按「京麦后台」记录;填了便于在后台「京东数据库」区分店铺"
|
||||
:disabled="isRunning"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button class="collect-btn" type="button" :disabled="isRunning" @click="startCollect">
|
||||
{{ isRunning ? '获取中…' : '一键获取店铺数据' }}
|
||||
</button>
|
||||
|
||||
<p class="collect-hint">
|
||||
点击后本机客户端会自动打开已登录的京麦后台采集商品,请保持客户端在线且京麦已登录;
|
||||
采集到的数据会实时回传并导入后台。
|
||||
</p>
|
||||
|
||||
<section v-if="taskId" class="progress-block">
|
||||
<div class="progress-head">
|
||||
<span class="progress-status">{{ statusText }}</span>
|
||||
<span v-if="percentText" class="progress-percent">{{ percentText }}</span>
|
||||
</div>
|
||||
<div class="progress-track">
|
||||
<div
|
||||
class="progress-fill"
|
||||
:class="{ 'progress-fill--indeterminate': percent === null && phase === 'running' }"
|
||||
:style="percent === null ? undefined : { width: `${percent}%` }"
|
||||
></div>
|
||||
</div>
|
||||
<div v-if="progressMeta" class="progress-meta">{{ progressMeta }}</div>
|
||||
</section>
|
||||
|
||||
<p v-if="successMessage" class="feedback success">{{ successMessage }}</p>
|
||||
<p v-if="errorMessage" class="feedback error">{{ errorMessage }}</p>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.jd-collect-page {
|
||||
padding: 24px;
|
||||
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;
|
||||
}
|
||||
|
||||
.tool-head {
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 20px;
|
||||
min-height: 62px;
|
||||
padding: 10px 34px;
|
||||
background: #1a1f2e;
|
||||
}
|
||||
|
||||
.tool-head__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;
|
||||
}
|
||||
|
||||
.tool-head__back:hover {
|
||||
background: #2b3447;
|
||||
color: #f5f8fc;
|
||||
}
|
||||
|
||||
.tool-head__title {
|
||||
flex-shrink: 0;
|
||||
color: #f5f8fc;
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.tool-head__desc {
|
||||
min-width: 0;
|
||||
max-width: 760px;
|
||||
color: #a0acbe;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.jd-body {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
padding: 4px 34px 40px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
/* 卡片按内容高度收口:flex 默认 stretch 会把它拉到整屏,空白比内容还长 */
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.jd-collect-panel {
|
||||
.collect-card {
|
||||
width: 100%;
|
||||
max-width: 560px;
|
||||
background: #fff;
|
||||
border: 1px solid #e5e7eb;
|
||||
max-width: 720px;
|
||||
padding: 26px 28px;
|
||||
border: 1px solid #3e4a62;
|
||||
border-radius: 12px;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.jd-collect-desc {
|
||||
color: #6b7280;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
margin: 8px 0 20px;
|
||||
background: #232a3b;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 16px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
color: #c8d2e2;
|
||||
font-size: 13px;
|
||||
color: #374151;
|
||||
margin-bottom: 6px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.form-group input[type='text'],
|
||||
.form-group input[type='number'] {
|
||||
.form-group input[type='text'] {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #d1d5db;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #3e4a62;
|
||||
border-radius: 8px;
|
||||
padding: 8px 10px;
|
||||
background: #1a1f2e;
|
||||
color: #f5f8fc;
|
||||
font-size: 14px;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
.tab-checks {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
.form-group input[type='text']:focus {
|
||||
border-color: #e1251b;
|
||||
}
|
||||
|
||||
.tab-check {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 14px;
|
||||
color: #374151;
|
||||
margin-bottom: 0;
|
||||
.form-group input[type='text']::placeholder {
|
||||
color: #6b778d;
|
||||
}
|
||||
|
||||
.jd-submit {
|
||||
.collect-btn {
|
||||
width: 100%;
|
||||
background: #2dd4bf;
|
||||
color: #062a26;
|
||||
padding: 13px 0;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
padding: 10px 0;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
background: linear-gradient(135deg, #ff5a4f, #e1251b);
|
||||
color: #ffffff;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 16px rgba(225, 37, 27, 0.32);
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.jd-submit:disabled {
|
||||
.collect-btn:hover:not(:disabled) {
|
||||
filter: brightness(1.1);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.collect-btn:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.jd-feedback {
|
||||
margin-top: 16px;
|
||||
.collect-hint {
|
||||
margin: 12px 0 0;
|
||||
color: #a0acbe;
|
||||
font-size: 12px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
/* ===== 进度条 ===== */
|
||||
.progress-block {
|
||||
margin-top: 22px;
|
||||
padding: 16px 18px;
|
||||
border: 1px solid #3e4a62;
|
||||
border-radius: 10px;
|
||||
background: #1f2637;
|
||||
}
|
||||
|
||||
.progress-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.progress-status {
|
||||
color: #f5f8fc;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.progress-percent {
|
||||
color: #ff8a80;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.progress-track {
|
||||
position: relative;
|
||||
height: 12px;
|
||||
overflow: hidden;
|
||||
border-radius: 999px;
|
||||
background: #11161f;
|
||||
border: 1px solid #2a3344;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
height: 100%;
|
||||
width: 0;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(90deg, #ff7a70, #e1251b);
|
||||
transition: width 0.4s ease;
|
||||
}
|
||||
|
||||
/* 没有 total(客户端还没抓到列表首页)时走不定态:不编造百分比 */
|
||||
.progress-fill--indeterminate {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 40%;
|
||||
animation: jd-progress-indeterminate 1.2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes jd-progress-indeterminate {
|
||||
0% {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
100% {
|
||||
transform: translateX(250%);
|
||||
}
|
||||
}
|
||||
|
||||
.progress-meta {
|
||||
margin-top: 10px;
|
||||
color: #a0acbe;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.feedback {
|
||||
margin: 16px 0 0;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
.jd-feedback.success {
|
||||
background: #ecfdf5;
|
||||
color: #047857;
|
||||
.feedback.success {
|
||||
background: rgba(16, 185, 129, 0.12);
|
||||
color: #6ee7b7;
|
||||
}
|
||||
|
||||
.jd-feedback.error {
|
||||
background: #fef2f2;
|
||||
color: #b91c1c;
|
||||
.feedback.error {
|
||||
background: rgba(248, 113, 113, 0.12);
|
||||
color: #fca5a5;
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.tool-head {
|
||||
padding: 10px 16px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.jd-body {
|
||||
padding: 4px 16px 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,462 @@
|
||||
<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>
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 京东运营工具台 · 工具目录
|
||||
*
|
||||
* 一级入口在桌面首页(与「亚马逊 / 视频」并列,见 DesktopHomePage),进来后是这两个菜单:
|
||||
* 1. 获取店铺数据:一键抓已登录京麦后台的店铺商品(列表 + 详情 + 图片),落后台「京东数据库」;
|
||||
* 2. 商品上架:功能未落地,先按"假菜单"占位(点击提示暂未开通),不发 href。
|
||||
*
|
||||
* 卡片形状照亚马逊工具台(tool-catalog.ts)的 ToolInfo,样式复用同一套深色卡片墙。
|
||||
*/
|
||||
|
||||
export type JdToolInfo = {
|
||||
/** 工具 id */
|
||||
id: string
|
||||
/** 菜单名称 */
|
||||
name: string
|
||||
/** 卡片一句话描述 */
|
||||
desc: string
|
||||
/** 角标文字(无则不显示) */
|
||||
tag?: string
|
||||
/** 功能页地址;未提供表示暂未开通(占位菜单) */
|
||||
href?: string
|
||||
}
|
||||
|
||||
export const JD_TOOLS: ReadonlyArray<JdToolInfo> = [
|
||||
{
|
||||
id: 'jd-collect',
|
||||
name: '获取店铺数据',
|
||||
desc: '一键抓取已登录京麦后台的店铺商品(列表 + 详情全部属性 + 图片),导入后台「京东数据库」',
|
||||
tag: '核心',
|
||||
href: '/jd-collect',
|
||||
},
|
||||
{
|
||||
id: 'jd-publish',
|
||||
name: '商品上架',
|
||||
desc: '把京东数据库里的商品批量上架到京麦店铺(建设中,敬请期待)',
|
||||
tag: '规划中',
|
||||
},
|
||||
]
|
||||
|
||||
export const JD_TOOL_MAP: ReadonlyMap<string, JdToolInfo> = new Map(
|
||||
JD_TOOLS.map((tool) => [tool.id, tool] as const),
|
||||
)
|
||||
@@ -67,6 +67,12 @@ const routes = [
|
||||
name: 'appearance-patent',
|
||||
component: () => import('@/pages/brand/components/BrandAppearancePatentTab.vue'),
|
||||
},
|
||||
// ---- 京东运营工具台(首页一级入口「京东」的落地页)----
|
||||
{
|
||||
path: '/jd-console',
|
||||
name: 'jd-console',
|
||||
component: () => import('@/pages/jd/JdConsolePage.vue'),
|
||||
},
|
||||
{
|
||||
path: '/jd-collect',
|
||||
name: 'jd-collect',
|
||||
|
||||
@@ -207,6 +207,8 @@ export const API_ENDPOINTS = {
|
||||
/** 京东店铺商品采集(v1.4):建单走 LOCAL 通道,由本机客户端在已登录京麦的窗口内执行。 */
|
||||
jdCollect: {
|
||||
create: '/api/jd-collect/tasks',
|
||||
/** 采集进度(用户端「获取店铺数据」进度条数据源) */
|
||||
progress: '/api/jd-collect/tasks/{taskId}/progress',
|
||||
heartbeat: '/api/jd-collect/tasks/{taskId}/heartbeat',
|
||||
chunk: '/api/jd-collect/tasks/{taskId}/chunk',
|
||||
},
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { post, type JavaApiResponse, unwrapJavaResponse } from '../../http.ts'
|
||||
import { get, post, type JavaApiResponse, unwrapJavaResponse } from '../../http.ts'
|
||||
import { buildJavaUrl } from '../../url.ts'
|
||||
import { getCurrentUserId } from '../../user.ts'
|
||||
import { API_ENDPOINTS } from '../../endpoints.ts'
|
||||
import { getTaskProgressTimeoutMs } from '../../../task-progress-config.ts'
|
||||
|
||||
/** 京东店铺采集建单回执(蓝图 §3.2):任务落 PENDING、执行通道固定 LOCAL,由本机客户端领取执行。 */
|
||||
export interface JdCollectTaskVo {
|
||||
@@ -17,6 +18,35 @@ export type JdListTab = 'ONSALE' | 'OFFSALE'
|
||||
* 建单(v1.4 AC-1):选择店铺 + 商品 Tab + 采集范围。未选店铺 / 未登记京麦登录态时
|
||||
* 服务端按蓝图 §3.2 拒绝并返回点名文案(业务码信封,unwrapJavaResponse 抛出)。
|
||||
*/
|
||||
/**
|
||||
* 采集进度回执(v1.5「获取店铺数据」进度条)。
|
||||
*
|
||||
* `total` 只在客户端抓过列表首页、把 total 写进合并写游标之后才有值;为 null 时页面
|
||||
* 用不定态进度条,不编造百分比。`itemsReceived` 是服务端已落库的商品数(慢一拍于客户端
|
||||
* 本地计数,这是它诚实的代价——界面不该拿本地内存数冒充后台进度)。
|
||||
*/
|
||||
export interface JdCollectProgressVo {
|
||||
taskId: number;
|
||||
status: string;
|
||||
itemsReceived: number | null;
|
||||
total: number | null;
|
||||
page: number | null;
|
||||
listTab: string | null;
|
||||
batches: number | null;
|
||||
message: string | null;
|
||||
updatedAt: string | null;
|
||||
}
|
||||
|
||||
/** 轮询采集进度:uid 与建单同口径(会话身份),任务 owner 不一致服务端直接拒。 */
|
||||
export function fetchJdCollectProgress(taskId: number) {
|
||||
const path = buildJavaUrl(API_ENDPOINTS.jdCollect.progress.replace('{taskId}', String(taskId)))
|
||||
const query = `?user_id=${encodeURIComponent(String(getCurrentUserId()))}`
|
||||
return unwrapJavaResponse(get<JavaApiResponse<JdCollectProgressVo>>(path + query, {
|
||||
// 进度请求按短超时:轮询里一次挂住会把进度条一起冻住(同 progress/light 口径)。
|
||||
timeout: getTaskProgressTimeoutMs(),
|
||||
}))
|
||||
}
|
||||
|
||||
export function createJdCollectTask(shopName: string, listTabs: JdListTab[], maxProducts = 0) {
|
||||
return unwrapJavaResponse(post<JavaApiResponse<JdCollectTaskVo>, Record<string, unknown>>(
|
||||
buildJavaUrl(API_ENDPOINTS.jdCollect.create),
|
||||
|
||||
Reference in New Issue
Block a user