fix: 全维度审查修复(安全/正确性/性能/稳定性/客户端/前端)
安全 - /api/ziniao/** 五个匿名接口加管理员鉴权(此前可匿名换取任意员工店铺登录令牌) - 删除 Flask 遗留后门:默认密码建超管 + 每次启动写生产 users 表(服务端与客户端各一份) - 进度/详情接口归属过滤:新增 TaskProgressOwnershipSupport,11 模块 progress/light 与 /tasks/batch 接入,DTO 补 userId,前端 13 个查询封装补传(未传时后端不过滤,兼容旧端) - 代理提取链接(含账密)不再明文入日志(新增 common/util/SecretMasking) - 全局异常兜底不再回传原始异常信息;内部令牌比较改常量时间 - 登录加失败计数与锁定(10 次锁 15 分钟);品牌源文件下载加 SSRF 防护 - AdminApiGuardFilter 覆盖前缀从 2 扩到 15(开关默认 false,行为不变,为收紧做准备) - 生产关闭 springdoc/knife4j(/doc.html 匿名可读全部接口定义) 正确性 - 40901/40902 拆分:锁竞争不再被伪装成 success=true(此前客户端停止重试、分片静默丢失) - 假成功收敛:集采明细批量写失败改为抛出、去重 worker 异常标失败、4 个 worker 改判 success 字段、publish 空 ASIN 行参与批次 flush、巡店删除全失败带 error 上报 - 客户端心跳 discard 移入 finally(7 模块,失败路径不再留僵尸 RUNNING 任务) - 状态机条件更新:跟价停止循环、集采 activate/fail、imagevideo 归档回填、店铺匹配提交 性能 - 前端入口包 JS 1.05MB→204KB、CSS 355KB→10.7KB(Element Plus 改按需 + el-config-provider) - 载荷引用计数按指针里的 taskId 收敛(原 JSON 列 IN 全表扫且逐行调用) - 店铺明细多值批量 INSERT;快照 upsert 预载缓存;结果文件列改单条 UPDATE - 新增迁移 V120(补 3 个缺失索引)/V121(删 4 个被覆盖的冗余索引)/V122(URL 前缀索引) 稳定性 - 新增 common/util/ThreadPools 有界线程池替换 5 处无界队列(防堆积 OOM) - Redis 锁释放改 Lua 原子校验(原裸 delete 会误删他人已过期的锁) - imagevideo 加死节点接管;锁续期失败重试;调度池 4→16;openStream 全部加超时 - 事务内远程对象删除移到提交后;启动恢复锁按实例命名 客户端 - 不再 taskkill /f /im chrome.exe(改为按调试端口精准回收,不杀用户自己的浏览器) - 密码检测不再无条件杀紫鸟进程;品牌检测加全局互斥(代理池不再互相覆盖) - base_dir 统一到 exe 目录(原被 os.getcwd() 覆盖,日志/缓存会分裂两个目录) - 缓存加定时清理;图片下载加超时;mkstemp 句柄托管 测试 - 同步更新受影响的契约测试(构造器签名/条件更新/方法改名/新增接口方法等) - 修复 FaultInjectionTest 等 3 处 mock 未 stub 流式 read 导致的读循环 OOM - mvn test 2795 个测试全绿
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
<template>
|
||||
<router-view />
|
||||
<el-config-provider :locale="zhCn">
|
||||
<router-view />
|
||||
</el-config-provider>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// 数富AI SPA 根组件:页面均由路由渲染(URL 无 .html 后缀)
|
||||
//
|
||||
// Element Plus 改为按需引入(见 vite.config.ts 的 ElementPlusResolver)后,locale 不再通过
|
||||
// app.use(ElementPlus, { locale }) 全局注入,改由 ConfigProvider 提供;
|
||||
// 否则分页/日期选择器/上传等组件的内置文案会退回英文。
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import { createApp } from 'vue'
|
||||
import ElementPlus from 'element-plus'
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
||||
import 'element-plus/dist/index.css'
|
||||
import '@/styles/main.css'
|
||||
|
||||
import App from '@/App.vue'
|
||||
@@ -15,6 +12,11 @@ import { ensureApiSecretsLoaded, loadApiSecrets } from '@/shared/utils/api-secre
|
||||
* 原 MPA 的 22 个 html 入口 + 22 个 *-main.ts 已合并:
|
||||
* 页面路由见 src/router/index.ts;登录态由路由守卫统一引导;
|
||||
* 密钥门禁:服务端密钥未配置完整时全站拦截到 /setup-secrets(拉取失败软失败放行)。
|
||||
*
|
||||
* Element Plus 走按需引入(vite.config.ts 的 ElementPlusResolver):
|
||||
* 此前 `app.use(ElementPlus)` + 全量 index.css 会把整套组件与样式打进入口
|
||||
* (入口 JS 实测 1.05MB,而组件 resolver 的分包优势全部失效)。
|
||||
* locale 由 App.vue 的 el-config-provider 提供。
|
||||
*/
|
||||
|
||||
// 后台预热密钥包,减少首次进入守卫时的等待
|
||||
@@ -51,4 +53,4 @@ router.beforeEach((to) => {
|
||||
return true
|
||||
})
|
||||
|
||||
createApp(App).use(router).use(ElementPlus, { locale: zhCn }).mount('#app')
|
||||
createApp(App).use(router).mount('#app')
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.vue';
|
||||
import TaskCenterPanel from '@/shared/components/tasks/TaskCenterPanel.vue'
|
||||
@@ -359,7 +359,10 @@ async function submitCleanRun() {
|
||||
}
|
||||
ElMessage.success('数据去重完成')
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '去重失败')
|
||||
// 卸载导致的轮询中止不提示(组件已不可见)
|
||||
if (!disposed) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '去重失败')
|
||||
}
|
||||
} finally {
|
||||
cleanRunning.value = false
|
||||
}
|
||||
@@ -369,9 +372,19 @@ async function submitCleanRun() {
|
||||
const DEDUPE_POLL_INTERVAL_MS = 2000
|
||||
const DEDUPE_POLL_TIMEOUT_MS = 10 * 60 * 1000
|
||||
|
||||
// 组件卸载标记:轮询在用户切页后仍会继续(最长 10 分钟),并往已卸载组件的 ref 写数据、
|
||||
// 触发全局确认框。卸载后立即中止轮询(服务端任务照常执行,结果在历史列表可查)。
|
||||
let disposed = false
|
||||
onBeforeUnmount(() => {
|
||||
disposed = true
|
||||
})
|
||||
|
||||
async function pollDedupeRunProgress(runId: string, onProgress?: (progress: DedupeRunProgressVo) => void): Promise<DedupeRunVo> {
|
||||
const deadline = Date.now() + DEDUPE_POLL_TIMEOUT_MS
|
||||
while (true) {
|
||||
if (disposed) {
|
||||
throw new Error('页面已离开,停止轮询')
|
||||
}
|
||||
const progress = await getDedupeRunProgress(runId)
|
||||
if (progress.status === 'not_found') {
|
||||
throw new Error('去重任务不存在或已过期')
|
||||
|
||||
@@ -768,10 +768,13 @@ function mergeHistoryProgressItems(incoming: PatrolDeleteHistoryItem[]) {
|
||||
cartRatios: next.cartRatios || item.cartRatios || [],
|
||||
};
|
||||
});
|
||||
// 判重改 Set:此前 merged.some(...) 是 O(n×m),历史条目越多每轮轮询越慢
|
||||
const mergedKeys = new Set(merged.map(historyItemKey));
|
||||
for (const item of incoming) {
|
||||
const key = historyItemKey(item);
|
||||
if (!merged.some((current) => historyItemKey(current) === key)) {
|
||||
if (!mergedKeys.has(key)) {
|
||||
merged.push(item);
|
||||
mergedKeys.add(key);
|
||||
}
|
||||
}
|
||||
historyItems.value = merged;
|
||||
|
||||
@@ -380,8 +380,15 @@ function activeLoopStorageKey() {
|
||||
function setStorageJson(key: string, value: unknown, shouldRemove: boolean) {
|
||||
if (typeof window === 'undefined') return
|
||||
try {
|
||||
if (shouldRemove) window.localStorage.removeItem(key)
|
||||
else window.localStorage.setItem(key, JSON.stringify(value))
|
||||
if (shouldRemove) {
|
||||
window.localStorage.removeItem(key)
|
||||
return
|
||||
}
|
||||
const next = JSON.stringify(value)
|
||||
// 内容未变则跳过写入:本函数在每轮轮询里对整份快照调用(可达数百 KB),
|
||||
// 同步 setItem 会阻塞主线程造成周期性卡顿;相同内容重复写盘没有意义
|
||||
if (window.localStorage.getItem(key) === next) return
|
||||
window.localStorage.setItem(key, next)
|
||||
} catch {
|
||||
/* quota */
|
||||
}
|
||||
|
||||
@@ -370,9 +370,13 @@ function setStorageJson(key: string, value: unknown, shouldRemove: boolean) {
|
||||
try {
|
||||
if (shouldRemove) {
|
||||
window.localStorage.removeItem(key)
|
||||
} else {
|
||||
window.localStorage.setItem(key, JSON.stringify(value))
|
||||
return
|
||||
}
|
||||
const next = JSON.stringify(value)
|
||||
// 内容未变则跳过写入:本函数在每轮轮询里对整份快照调用(可达数百 KB),
|
||||
// 同步 setItem 会阻塞主线程造成周期性卡顿
|
||||
if (window.localStorage.getItem(key) === next) return
|
||||
window.localStorage.setItem(key, next)
|
||||
} catch {
|
||||
/* quota */
|
||||
}
|
||||
|
||||
@@ -458,12 +458,16 @@ function withQueryAsinFallback<T extends QueryAsinHistoryItem | QueryAsinShopQue
|
||||
item: T,
|
||||
fallback?: QueryAsinShopQueueItem | QueryAsinHistoryItem | null,
|
||||
) {
|
||||
const queryAsins = hasQueryAsins(item)
|
||||
? readQueryAsins(item)
|
||||
: readQueryAsins(fallback || undefined);
|
||||
// 已有 queryAsins 时直接返回原对象:本函数在每轮轮询里对全量历史调用,
|
||||
// 无条件 { ...item } 会让下游历史抽屉的全部卡片因 props 变化而每轮重渲染
|
||||
if (hasQueryAsins(item)) {
|
||||
return item;
|
||||
}
|
||||
const fallbackAsins = readQueryAsins(fallback || undefined);
|
||||
const resolved = fallbackAsins.length ? fallbackAsins : fallbackQueryAsinsForShop(item.shopName);
|
||||
return {
|
||||
...item,
|
||||
queryAsins: queryAsins.length ? queryAsins : fallbackQueryAsinsForShop(item.shopName),
|
||||
queryAsins: resolved,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -689,10 +693,13 @@ function mergeHistoryProgressItems(incoming: QueryAsinHistoryItem[]) {
|
||||
queryAsins,
|
||||
};
|
||||
});
|
||||
// 判重改 Set:此前 merged.some(...) 是 O(n×m),历史 500 条 × 每轮 20 条即 1 万次比较
|
||||
const mergedKeys = new Set(merged.map(historyItemKey));
|
||||
for (const item of incoming) {
|
||||
const key = historyItemKey(item);
|
||||
if (!merged.some((current) => historyItemKey(current) === key)) {
|
||||
if (!mergedKeys.has(key)) {
|
||||
merged.push(withQueryAsinFallback(item));
|
||||
mergedKeys.add(key);
|
||||
}
|
||||
}
|
||||
historyItems.value = merged;
|
||||
|
||||
@@ -139,7 +139,7 @@
|
||||
<div class="kv-row"><span class="kv-key">进度信息</span><span class="kv-val">{{ latestMessage(detailItem) || '-' }}</span></div>
|
||||
<template v-if="resultFiles(detailItem).length">
|
||||
<div class="kv-section">结果文件</div>
|
||||
<div v-for="(url, index) in resultFiles(detailItem)" :key="index" class="kv-row">
|
||||
<div v-for="(url, index) in resultFiles(detailItem)" :key="url" class="kv-row">
|
||||
<span class="kv-key">文件 {{ index + 1 }}</span>
|
||||
<a class="kv-val link" :href="url" target="_blank" rel="noopener">{{ url }}</a>
|
||||
</div>
|
||||
@@ -226,6 +226,10 @@ function statusClass(status?: number | string) {
|
||||
|
||||
let autoTimer: number | null = null
|
||||
let refreshTimer: number | null = null
|
||||
// 导出轮询用独立计时器:此前与自动刷新共用 autoTimer,两条链互相覆盖,必有一条无法被 cleanup 清掉
|
||||
let exportTimer: number | null = null
|
||||
// 组件已卸载标记:轮询链的异步回调在卸载后仍会续链(切页后继续打接口)
|
||||
let disposed = false
|
||||
|
||||
function uid() {
|
||||
const raw = typeof window === 'undefined' ? '' : window.localStorage.getItem('uid') || ''
|
||||
@@ -567,6 +571,10 @@ function pollExport(bridge: NonNullable<ReturnType<typeof getPywebviewApi>>, fil
|
||||
let count = 0
|
||||
const maxAttempts = 60
|
||||
const tick = async () => {
|
||||
if (disposed) {
|
||||
resolve(null)
|
||||
return
|
||||
}
|
||||
count += 1
|
||||
try {
|
||||
const res = await bridge.vc_query_export!(fileId)
|
||||
@@ -584,7 +592,7 @@ function pollExport(bridge: NonNullable<ReturnType<typeof getPywebviewApi>>, fil
|
||||
resolve(null)
|
||||
return
|
||||
}
|
||||
autoTimer = window.setTimeout(tick, 2000)
|
||||
exportTimer = window.setTimeout(tick, 2000)
|
||||
}
|
||||
void tick()
|
||||
})
|
||||
@@ -601,8 +609,12 @@ function scheduleAutoRefresh() {
|
||||
autoTimer = null
|
||||
}
|
||||
autoTimer = window.setTimeout(async () => {
|
||||
if (disposed) {
|
||||
return
|
||||
}
|
||||
await loadTasks(currentPage.value || 1)
|
||||
if (currentTasks.value.some((item) => isBusy(item.status))) {
|
||||
// 卸载后不得再续链:异步回调返回时组件可能已销毁,续链会持续打接口
|
||||
if (!disposed && currentTasks.value.some((item) => isBusy(item.status))) {
|
||||
scheduleAutoRefresh()
|
||||
}
|
||||
}, 3000)
|
||||
@@ -616,10 +628,15 @@ function startPolling() {
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
disposed = true
|
||||
if (autoTimer) {
|
||||
window.clearTimeout(autoTimer)
|
||||
autoTimer = null
|
||||
}
|
||||
if (exportTimer) {
|
||||
window.clearTimeout(exportTimer)
|
||||
exportTimer = null
|
||||
}
|
||||
if (refreshTimer) {
|
||||
window.clearInterval(refreshTimer)
|
||||
refreshTimer = null
|
||||
|
||||
@@ -817,10 +817,13 @@ function mergeHistoryProgressItems(incoming: WithdrawHistoryItem[]) {
|
||||
...next,
|
||||
};
|
||||
});
|
||||
// 判重改 Set:此前 merged.some(...) 是 O(n×m),历史条目越多每轮轮询越慢
|
||||
const mergedKeys = new Set(merged.map(historyItemKey));
|
||||
for (const item of incoming) {
|
||||
const key = historyItemKey(item);
|
||||
if (!merged.some((current) => historyItemKey(current) === key)) {
|
||||
if (!mergedKeys.has(key)) {
|
||||
merged.push(withWithdrawFallback(item));
|
||||
mergedKeys.add(key);
|
||||
}
|
||||
}
|
||||
historyItems.value = merged;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="update-hint">{{ hint }}</div>
|
||||
<UpdateLogList :entries="changelog" />
|
||||
<UpdateProgressBar :progress="progress" />
|
||||
<div v-if="hasUpdate || canDownload" style="margin-top: 4px;">
|
||||
<button type="button" class="btn-download-update" :disabled="updating" @click="doUpdate">
|
||||
@@ -64,13 +65,14 @@ import { restoreLoginUser } from '@/shared/auth/ensure-auth'
|
||||
import { getCurrentUserAppColumnRaw, readCachedAppColumnPermissions, type PermissionMenuItem } from '@/shared/api/permission'
|
||||
import { useVersionUpdate } from '@/shared/composables/useVersionUpdate'
|
||||
import UpdateProgressBar from '@/shared/components/UpdateProgressBar.vue'
|
||||
import UpdateLogList from '@/shared/components/UpdateLogList.vue'
|
||||
import NotificationBell from '@/shared/components/NotificationBell.vue'
|
||||
import { resolvePageHref } from '@/shared/page-prefix'
|
||||
|
||||
const username = ref('')
|
||||
const updatePanel = ref(false)
|
||||
const toastText = ref('')
|
||||
const { checking, updating, currentVersion, hasUpdate, canDownload, hint, checked, progress, runCheck, doUpdate } =
|
||||
const { checking, updating, currentVersion, hasUpdate, canDownload, hint, checked, progress, changelog, runCheck, doUpdate } =
|
||||
useVersionUpdate()
|
||||
|
||||
// 桌面端原 Flask /logout 已随瘦身下线:统一跳登录页并清本地 token(/login?logout=1)
|
||||
|
||||
@@ -526,6 +526,13 @@ type VoiceStatusType = 'info' | 'success' | 'error'
|
||||
const IMAGE_VIDEO_TASK_POLL_DELAY_MS = 5000
|
||||
const IMAGE_VIDEO_TASK_MAX_POLLS = 720
|
||||
|
||||
/**
|
||||
* 组件卸载标记:本页有两类长轮询(组装结果、Coze 异步任务,后者最长 720 次 × 5 秒 = 1 小时)。
|
||||
* 轮询回调在卸载后仍会「请求返回 → 续挂下一轮」,仅靠 onBeforeUnmount 清当前计时器挡不住
|
||||
* 在途请求,必须用标记在每次续链前判定。
|
||||
*/
|
||||
let disposed = false
|
||||
|
||||
type AssetState = {
|
||||
fileName: string
|
||||
previewUrl: string
|
||||
@@ -1002,6 +1009,10 @@ function isTerminalImageVideoTask(task: ImageVideoAsyncTaskVo) {
|
||||
async function waitForImageVideoTask(ticket: ImageVideoAsyncTaskVo): Promise<unknown> {
|
||||
let task = ticket
|
||||
for (let pollCount = 0; pollCount < IMAGE_VIDEO_TASK_MAX_POLLS; pollCount += 1) {
|
||||
if (disposed) {
|
||||
// 组件已卸载:停止轮询(否则切页后仍会每 5 秒打接口,最长 1 小时)
|
||||
throw new Error('页面已离开,停止轮询')
|
||||
}
|
||||
if (task.status === 'SUCCESS') return task.result
|
||||
if (isTerminalImageVideoTask(task)) {
|
||||
throw new Error(task.errorMessage || 'Coze task failed')
|
||||
@@ -1307,6 +1318,11 @@ async function pollAssemblyResult(tab: WorkspaceTab, taskId: number) {
|
||||
ElMessage.warning('Coze 执行结果查询超时,请稍后通过 execute_id 查看')
|
||||
return
|
||||
}
|
||||
if (disposed) {
|
||||
// 卸载瞬间请求在途时,回调返回后会重新挂表;此处判定保证卸载后不再续链
|
||||
assembly.polling = false
|
||||
return
|
||||
}
|
||||
assembly.pollTimer = window.setTimeout(() => {
|
||||
void pollAssemblyResult(tab, taskId)
|
||||
}, IMAGE_VIDEO_TASK_POLL_DELAY_MS)
|
||||
@@ -1791,6 +1807,7 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
disposed = true
|
||||
stopAssemblyPolling('remake')
|
||||
stopAssemblyPolling('imageToVideo')
|
||||
})
|
||||
|
||||
@@ -2,6 +2,40 @@
|
||||
<div class="legacy-login-root">
|
||||
<header class="header">
|
||||
<span class="header-title">数富AI</span>
|
||||
<!-- 版本更新入口固定右上角:桌面端自动下载安装;网页形态降级为下载最新安装包 -->
|
||||
<div class="login-header-right">
|
||||
<div class="login-update">
|
||||
<button type="button" class="link-update" @click="toggleUpdate">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<path d="M21 12a9 9 0 1 1-2.64-6.36"></path>
|
||||
<path d="M21 3v6h-6"></path>
|
||||
</svg>
|
||||
更新版本
|
||||
</button>
|
||||
<div v-if="updateOpen" class="update-panel">
|
||||
<div class="update-panel-title">软件更新</div>
|
||||
<div class="update-row"><span>当前版本</span><b>{{ currentVersion || '—' }}</b></div>
|
||||
<div class="update-row"><span>最新版本</span><b>{{ latestVersion || '—' }}</b></div>
|
||||
<div class="update-actions">
|
||||
<button type="button" class="btn-mini" :disabled="checking" @click="runCheck">
|
||||
{{ checking ? '检测中...' : '检测' }}
|
||||
</button>
|
||||
<button
|
||||
v-if="hasUpdate || canDownload"
|
||||
type="button"
|
||||
class="btn-mini btn-mini-green"
|
||||
:disabled="updating"
|
||||
@click="doUpdate"
|
||||
>
|
||||
{{ updating ? '更新中...' : '立即更新' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="update-hint">{{ hint }}</div>
|
||||
<UpdateLogList :entries="changelog" />
|
||||
<UpdateProgressBar :progress="progress" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="login-box">
|
||||
@@ -59,38 +93,6 @@
|
||||
{{ loggingIn ? '登录中...' : '登录' }}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<!-- 版本更新:桌面端自动下载安装;网页形态降级为下载最新安装包 -->
|
||||
<div class="login-update">
|
||||
<button type="button" class="link-update" @click="toggleUpdate">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<path d="M21 12a9 9 0 1 1-2.64-6.36"></path>
|
||||
<path d="M21 3v6h-6"></path>
|
||||
</svg>
|
||||
更新版本
|
||||
</button>
|
||||
<div v-if="updateOpen" class="update-panel">
|
||||
<div class="update-panel-title">软件更新</div>
|
||||
<div class="update-row"><span>当前版本</span><b>{{ currentVersion || '—' }}</b></div>
|
||||
<div class="update-row"><span>最新版本</span><b>{{ latestVersion || '—' }}</b></div>
|
||||
<div class="update-actions">
|
||||
<button type="button" class="btn-mini" :disabled="checking" @click="runCheck">
|
||||
{{ checking ? '检测中...' : '检测' }}
|
||||
</button>
|
||||
<button
|
||||
v-if="hasUpdate || canDownload"
|
||||
type="button"
|
||||
class="btn-mini btn-mini-green"
|
||||
:disabled="updating"
|
||||
@click="doUpdate"
|
||||
>
|
||||
{{ updating ? '更新中...' : '立即更新' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="update-hint">{{ hint }}</div>
|
||||
<UpdateProgressBar :progress="progress" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -103,6 +105,7 @@ import { KICK_NOTICE_KEY } from '@/shared/auth/kick-handler'
|
||||
import { useVersionUpdate } from '@/shared/composables/useVersionUpdate'
|
||||
import { clearApiSecretCache } from '@/shared/utils/api-secret-store'
|
||||
import UpdateProgressBar from '@/shared/components/UpdateProgressBar.vue'
|
||||
import UpdateLogList from '@/shared/components/UpdateLogList.vue'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
@@ -134,6 +137,7 @@ const {
|
||||
hint,
|
||||
checked,
|
||||
progress,
|
||||
changelog,
|
||||
runCheck,
|
||||
doUpdate,
|
||||
} = useVersionUpdate()
|
||||
@@ -682,10 +686,15 @@ body {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* 版本更新入口与面板 */
|
||||
/* 版本更新入口与面板:入口固定顶栏右上角,面板在该入口下方浮层展开
|
||||
(类名加 login- 前缀,避免与首页同名全局样式互相覆盖) */
|
||||
.login-header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.login-update {
|
||||
margin-top: 14px;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.link-update {
|
||||
@@ -713,11 +722,16 @@ body {
|
||||
}
|
||||
|
||||
.update-panel {
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
top: 34px;
|
||||
right: 0;
|
||||
z-index: 20;
|
||||
width: 300px;
|
||||
padding: 12px 14px;
|
||||
background: #f6fafd;
|
||||
background: #ffffff;
|
||||
border: 1px solid #d5e6f2;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 8px 24px rgba(20, 50, 80, 0.16);
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,11 @@ async function postTaskProgressBatch<T>(
|
||||
}
|
||||
|
||||
const requestPromise = unwrapJavaResponse(
|
||||
post<JavaApiResponse<T>, { taskIds: number[] }>(path, { taskIds: normalizedTaskIds }, {
|
||||
post<JavaApiResponse<T>, { taskIds: number[]; userId?: number }>(path, {
|
||||
taskIds: normalizedTaskIds,
|
||||
// 传当前用户 id:后端据此过滤非归属任务(未传时后端不过滤,保持向后兼容)
|
||||
userId: Number(window.localStorage.getItem('uid')) || undefined,
|
||||
}, {
|
||||
timeout: getTaskProgressTimeoutMs(),
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -181,7 +181,11 @@ async function postTaskProgressBatch<T>(
|
||||
}
|
||||
|
||||
const requestPromise = unwrapJavaResponse(
|
||||
post<JavaApiResponse<T>, { taskIds: number[] }>(path, { taskIds: normalizedTaskIds }, {
|
||||
post<JavaApiResponse<T>, { taskIds: number[]; userId?: number }>(path, {
|
||||
taskIds: normalizedTaskIds,
|
||||
// 传当前用户 id:后端据此过滤非归属任务(未传时后端不过滤,保持向后兼容)
|
||||
userId: Number(window.localStorage.getItem('uid')) || undefined,
|
||||
}, {
|
||||
timeout: getTaskProgressTimeoutMs(),
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -205,7 +205,11 @@ async function postTaskProgressBatch<T>(
|
||||
}
|
||||
|
||||
const requestPromise = unwrapJavaResponse(
|
||||
post<JavaApiResponse<T>, { taskIds: number[] }>(path, { taskIds: normalizedTaskIds }, {
|
||||
post<JavaApiResponse<T>, { taskIds: number[]; userId?: number }>(path, {
|
||||
taskIds: normalizedTaskIds,
|
||||
// 传当前用户 id:后端据此过滤非归属任务(未传时后端不过滤,保持向后兼容)
|
||||
userId: Number(window.localStorage.getItem('uid')) || undefined,
|
||||
}, {
|
||||
timeout: getTaskProgressTimeoutMs(),
|
||||
}),
|
||||
)
|
||||
@@ -268,9 +272,13 @@ export function getDeleteBrandTaskDetail(taskId: number) {
|
||||
|
||||
export function getDeleteBrandTaskDetails(taskIds: number[]) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<DeleteBrandTaskBatchVo>, { taskIds: number[] }>(
|
||||
post<JavaApiResponse<DeleteBrandTaskBatchVo>, { taskIds: number[]; userId?: number }>(
|
||||
buildJavaUrl(API_ENDPOINTS.deleteBrand.taskDetails),
|
||||
{ taskIds },
|
||||
{
|
||||
taskIds,
|
||||
// 传当前用户 id:后端据此过滤非归属任务(未传时后端不过滤,保持向后兼容)
|
||||
userId: Number(window.localStorage.getItem('uid')) || undefined,
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -121,9 +121,39 @@ async function fetchAppColumnPermissions() {
|
||||
return items
|
||||
}
|
||||
|
||||
/**
|
||||
* 列权限键的内存缓存与 in-flight 合并(2026-09 全维度审查补):
|
||||
* 同一路由内多个组件各自 onMounted 调用(如 AmazonConsolePage + AmazonTopBar),
|
||||
* 此前每次进页面都发两次相同请求;TTL 取 10s,既消掉重复又保证权限变更能较快生效。
|
||||
*/
|
||||
const APP_COLUMN_KEYS_TTL_MS = 10_000
|
||||
let appColumnKeysCache: { value: string[]; at: number } | null = null
|
||||
let appColumnKeysInflight: Promise<string[]> | null = null
|
||||
|
||||
/** 归一化后的列权限键(菜单入口/卡片显隐用,见 AmazonConsolePage 等) */
|
||||
export async function getCurrentUserAppColumnKeys() {
|
||||
return normalizeColumnKeys(await fetchAppColumnPermissions())
|
||||
const now = Date.now()
|
||||
if (appColumnKeysCache && now - appColumnKeysCache.at < APP_COLUMN_KEYS_TTL_MS) {
|
||||
return appColumnKeysCache.value
|
||||
}
|
||||
if (appColumnKeysInflight) {
|
||||
return appColumnKeysInflight
|
||||
}
|
||||
appColumnKeysInflight = (async () => {
|
||||
try {
|
||||
const keys = normalizeColumnKeys(await fetchAppColumnPermissions())
|
||||
appColumnKeysCache = { value: keys, at: Date.now() }
|
||||
return keys
|
||||
} finally {
|
||||
appColumnKeysInflight = null
|
||||
}
|
||||
})()
|
||||
return appColumnKeysInflight
|
||||
}
|
||||
|
||||
/** 失效列权限缓存(权限变更后需要立即生效时调用)。 */
|
||||
export function invalidateAppColumnKeysCache() {
|
||||
appColumnKeysCache = null
|
||||
}
|
||||
|
||||
/** 原始权限菜单项(页面需要自行计算权限状态时用,见 DesktopHomePage) */
|
||||
|
||||
@@ -238,7 +238,11 @@ async function postTaskProgressBatch<T>(
|
||||
}
|
||||
|
||||
const requestPromise = unwrapJavaResponse(
|
||||
post<JavaApiResponse<T>, { taskIds: number[] }>(path, { taskIds: normalizedTaskIds }, {
|
||||
post<JavaApiResponse<T>, { taskIds: number[]; userId?: number }>(path, {
|
||||
taskIds: normalizedTaskIds,
|
||||
// 传当前用户 id:后端据此过滤非归属任务(未传时后端不过滤,保持向后兼容)
|
||||
userId: Number(window.localStorage.getItem('uid')) || undefined,
|
||||
}, {
|
||||
timeout: getTaskProgressTimeoutMs(),
|
||||
}),
|
||||
)
|
||||
@@ -340,9 +344,13 @@ export function deletePriceTrackTask(taskId: number) {
|
||||
|
||||
export function getPriceTrackTasksBatch(taskIds: number[]) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<PriceTrackTaskBatchVo>, { taskIds: number[] }>(
|
||||
post<JavaApiResponse<PriceTrackTaskBatchVo>, { taskIds: number[]; userId?: number }>(
|
||||
`${JAVA_API_PREFIX}/price-track/tasks/batch`,
|
||||
{ taskIds },
|
||||
{
|
||||
taskIds,
|
||||
// 传当前用户 id:后端据此过滤非归属任务(未传时后端不过滤,保持向后兼容)
|
||||
userId: Number(window.localStorage.getItem('uid')) || undefined,
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -238,9 +238,11 @@ export function getPublishTaskProgressBatch(taskIds: number[]) {
|
||||
return unwrapJavaResponse(
|
||||
post<
|
||||
JavaApiResponse<PublishTaskBatchVo>,
|
||||
{ task_ids: number[] }
|
||||
{ task_ids: number[]; user_id?: number }
|
||||
>(buildJavaUrl(API_ENDPOINTS.publish.progressBatch), {
|
||||
task_ids: normalizedTaskIds,
|
||||
// 传当前用户 id:后端据此过滤非归属任务(未传时后端不过滤,保持向后兼容)
|
||||
user_id: Number(window.localStorage.getItem('uid')) || undefined,
|
||||
}, { timeout: getTaskProgressTimeoutMs() }),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -197,7 +197,11 @@ async function postTaskProgressBatch<T>(
|
||||
}
|
||||
|
||||
const requestPromise = unwrapJavaResponse(
|
||||
post<JavaApiResponse<T>, { taskIds: number[] }>(path, { taskIds: normalizedTaskIds }, {
|
||||
post<JavaApiResponse<T>, { taskIds: number[]; userId?: number }>(path, {
|
||||
taskIds: normalizedTaskIds,
|
||||
// 传当前用户 id:后端据此过滤非归属任务(未传时后端不过滤,保持向后兼容)
|
||||
userId: Number(window.localStorage.getItem('uid')) || undefined,
|
||||
}, {
|
||||
timeout: getTaskProgressTimeoutMs(),
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -232,7 +232,11 @@ async function postTaskProgressBatch<T>(
|
||||
}
|
||||
|
||||
const requestPromise = unwrapJavaResponse(
|
||||
post<JavaApiResponse<T>, { taskIds: number[] }>(path, { taskIds: normalizedTaskIds }, {
|
||||
post<JavaApiResponse<T>, { taskIds: number[]; userId?: number }>(path, {
|
||||
taskIds: normalizedTaskIds,
|
||||
// 传当前用户 id:后端据此过滤非归属任务(未传时后端不过滤,保持向后兼容)
|
||||
userId: Number(window.localStorage.getItem('uid')) || undefined,
|
||||
}, {
|
||||
timeout: getTaskProgressTimeoutMs(),
|
||||
}),
|
||||
)
|
||||
@@ -386,9 +390,13 @@ export function deletePendingProductRiskShopResult(shopName: string) {
|
||||
|
||||
export function getProductRiskTasksBatch(taskIds: number[]) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<ProductRiskTaskBatchVo>, { taskIds: number[] }>(
|
||||
post<JavaApiResponse<ProductRiskTaskBatchVo>, { taskIds: number[]; userId?: number }>(
|
||||
`${JAVA_API_PREFIX}/product-risk-resolve/tasks/batch`,
|
||||
{ taskIds },
|
||||
{
|
||||
taskIds,
|
||||
// 传当前用户 id:后端据此过滤非归属任务(未传时后端不过滤,保持向后兼容)
|
||||
userId: Number(window.localStorage.getItem('uid')) || undefined,
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -548,9 +556,13 @@ export function completeShopMatchTaskStage(taskId: number, stageIndex: number) {
|
||||
|
||||
export function getShopMatchTasksBatch(taskIds: number[]) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<ShopMatchTaskBatchVo>, { taskIds: number[] }>(
|
||||
post<JavaApiResponse<ShopMatchTaskBatchVo>, { taskIds: number[]; userId?: number }>(
|
||||
`${JAVA_API_PREFIX}/shop-match/tasks/batch`,
|
||||
{ taskIds },
|
||||
{
|
||||
taskIds,
|
||||
// 传当前用户 id:后端据此过滤非归属任务(未传时后端不过滤,保持向后兼容)
|
||||
userId: Number(window.localStorage.getItem('uid')) || undefined,
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,11 @@ async function postTaskProgressBatch<T>(
|
||||
}
|
||||
|
||||
const requestPromise = unwrapJavaResponse(
|
||||
post<JavaApiResponse<T>, { taskIds: number[] }>(path, { taskIds: normalizedTaskIds }, {
|
||||
post<JavaApiResponse<T>, { taskIds: number[]; userId?: number }>(path, {
|
||||
taskIds: normalizedTaskIds,
|
||||
// 传当前用户 id:后端据此过滤非归属任务(未传时后端不过滤,保持向后兼容)
|
||||
userId: Number(window.localStorage.getItem('uid')) || undefined,
|
||||
}, {
|
||||
timeout: getTaskProgressTimeoutMs(),
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -206,7 +206,11 @@ async function postTaskProgressBatch<T>(
|
||||
}
|
||||
|
||||
const requestPromise = unwrapJavaResponse(
|
||||
post<JavaApiResponse<T>, { taskIds: number[] }>(path, { taskIds: normalizedTaskIds }, {
|
||||
post<JavaApiResponse<T>, { taskIds: number[]; userId?: number }>(path, {
|
||||
taskIds: normalizedTaskIds,
|
||||
// 传当前用户 id:后端据此过滤非归属任务(未传时后端不过滤,保持向后兼容)
|
||||
userId: Number(window.localStorage.getItem('uid')) || undefined,
|
||||
}, {
|
||||
timeout: getTaskProgressTimeoutMs(),
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* 桌面客户端更新日志(面向用户的通俗说明,桌面端更新面板展示)。
|
||||
*
|
||||
* 数据来源:app_client 仓库 git 历史——以各版本发版提交
|
||||
* (chore(release): 版本号 x.y.z …)为界,取该窗口内的 feat/fix 提交,
|
||||
* 自动整理成"用户能看懂的一句话"后追加到本文件(新版本放最前)。
|
||||
* 取某版本区间的原始提交:
|
||||
* git -C app_client log --oneline <上一版提交>..<本版提交>
|
||||
*
|
||||
* 注意:version 必须与 web_config 发布记录 / /api/version/latest 的版本号
|
||||
* 完全一致(不带 v 前缀),否则按本机版本筛选时匹配不到条目。
|
||||
*/
|
||||
|
||||
import { compareVersions, normVersion } from './utils/version-compare.ts'
|
||||
|
||||
export interface ClientChangelogEntry {
|
||||
/** 客户端版本号,与线上发布记录一致 */
|
||||
version: string
|
||||
/** 发布日期 yyyy-MM-dd */
|
||||
date: string
|
||||
/** 面向用户的更新说明,一条一行,不用技术术语 */
|
||||
items: string[]
|
||||
}
|
||||
|
||||
/** 更新日志数据(新版本在前;发版时在数组最前追加一条) */
|
||||
export const CLIENT_CHANGELOG: ClientChangelogEntry[] = [
|
||||
{
|
||||
version: '4.0.11',
|
||||
date: '2026-09-13',
|
||||
items: [
|
||||
'代理失效会自动切换并暂停购买,减少花冤枉钱',
|
||||
'风险审批结果自动保存,网络波动也不白干(断开后自动补交)',
|
||||
'品牌检测连续失败时自动停止,不再反复无效尝试',
|
||||
],
|
||||
},
|
||||
{
|
||||
version: '4.0.10',
|
||||
date: '2026-09-13',
|
||||
items: [
|
||||
'修复切换国家时页面断开后一直卡住不动的问题',
|
||||
'修复产品风险审批"批准"数量一直不减(处理了却没算数)的问题',
|
||||
],
|
||||
},
|
||||
{
|
||||
version: '4.0.9',
|
||||
date: '2026-09-13',
|
||||
items: [
|
||||
'修复长时间使用后电脑越来越卡的问题(浏览器进程不再越积越多)',
|
||||
'修复窗口最大化、还原时客户端偶尔没反应的问题',
|
||||
],
|
||||
},
|
||||
{
|
||||
version: '4.0.7',
|
||||
date: '2026-09-13',
|
||||
items: [
|
||||
'跟价、风险审批的"旧版/新版"选项恢复真实生效(选哪个就走哪个)',
|
||||
'店铺界面已是新版时选"旧版"会明确提示,不再假装处理成功',
|
||||
],
|
||||
},
|
||||
{
|
||||
version: '4.0.6',
|
||||
date: '2026-09-13',
|
||||
items: ['跟价指定 ASIN 时严格按指定范围执行,未指定 ASIN 的国家不再全量改价'],
|
||||
},
|
||||
{
|
||||
version: '4.0.5',
|
||||
date: '2026-09-13',
|
||||
items: [
|
||||
'重做产品风险审批的保存流程:保存结果如实反馈,不再"显示成功其实没保存"',
|
||||
'修复风险审批多条待处理记录只处理第一条的问题',
|
||||
],
|
||||
},
|
||||
{
|
||||
version: '4.0.4',
|
||||
date: '2026-09-13',
|
||||
items: [
|
||||
'修复风险审批新界面里"提交"按钮从未被点击、选了记录也不保存的问题',
|
||||
'修复跟价提示改价成功、实际没改价的问题;未设置最低价时不再漏处理商品',
|
||||
],
|
||||
},
|
||||
{
|
||||
version: '4.0.3',
|
||||
date: '2026-09-12',
|
||||
items: [
|
||||
'货源查询改用真实浏览器采集,结果更准确',
|
||||
'修复跟价把购物车里已加购的商品误判为"没有卖家"的问题',
|
||||
'修复部分电脑提示"更新程序缺失"无法自动更新;更新显示真实下载进度',
|
||||
],
|
||||
},
|
||||
{
|
||||
version: '4.0.2',
|
||||
date: '2026-09-12',
|
||||
items: ['修复跟价等任务只处理第一页商品、其余被跳过的问题'],
|
||||
},
|
||||
{
|
||||
version: '4.0.1',
|
||||
date: '2026-09-12',
|
||||
items: ['修复货源查询结果中"阿里巴巴"商品图片整列空白的问题'],
|
||||
},
|
||||
{
|
||||
version: '4.0.0',
|
||||
date: '2026-09-11',
|
||||
items: [
|
||||
'修复产品风险审批新界面频繁提示"处理失败"的问题',
|
||||
'修复商品翻页加载慢时只处理第一页的问题',
|
||||
],
|
||||
},
|
||||
{
|
||||
version: '3.0.73',
|
||||
date: '2026-09-11',
|
||||
items: ['修复集采数据、跟价等功能因接口鉴权失败无法使用的问题'],
|
||||
},
|
||||
{
|
||||
version: '3.0.71',
|
||||
date: '2026-09-11',
|
||||
items: ['升级支持断点续传,并显示真实的下载进度'],
|
||||
},
|
||||
]
|
||||
|
||||
/** 数据文件里最新的版本号(无数据时空串)。 */
|
||||
export function newestChangelogVersion(entries: ClientChangelogEntry[] = CLIENT_CHANGELOG): string {
|
||||
return entries.length ? normVersion(entries[0].version) : ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 挑选本次要展示的更新日志:本机版本之后、最新版本(含)之间的条目,新的在前。
|
||||
*
|
||||
* - latestVersion 为空(检测未完成/失败)时按数据文件里最新版本兜底;
|
||||
* - currentVersion 为空(旧客户端无版本桥)时只给最新版本一条,不把整段历史倒给用户;
|
||||
* - 本机版本已高于线上(灰度/回滚)时返回空数组,由调用方隐藏该区块。
|
||||
*/
|
||||
export function selectChangelogEntries(options: {
|
||||
currentVersion?: string
|
||||
latestVersion?: string
|
||||
entries?: ClientChangelogEntry[]
|
||||
} = {}): ClientChangelogEntry[] {
|
||||
const entries = options.entries ?? CLIENT_CHANGELOG
|
||||
if (!entries.length) return []
|
||||
const current = normVersion(options.currentVersion)
|
||||
const upper = normVersion(options.latestVersion) || newestChangelogVersion(entries)
|
||||
const inRange = entries.filter((entry) => compareVersions(entry.version, upper) <= 0)
|
||||
if (!inRange.length) return []
|
||||
if (!current) {
|
||||
const newest = inRange.find((entry) => compareVersions(entry.version, upper) === 0)
|
||||
return [newest ?? inRange[0]]
|
||||
}
|
||||
return inRange.filter((entry) => compareVersions(entry.version, current) > 0)
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,87 @@
|
||||
<template>
|
||||
<div v-if="entries.length" class="update-log">
|
||||
<div class="update-log-title">更新日志</div>
|
||||
<div class="update-log-scroll">
|
||||
<div v-for="entry in entries" :key="entry.version" class="update-log-entry">
|
||||
<div class="update-log-head">
|
||||
<span class="update-log-version">v{{ entry.version }}</span>
|
||||
<span v-if="entry.date" class="update-log-date">{{ entry.date }}</span>
|
||||
</div>
|
||||
<ul class="update-log-items">
|
||||
<li v-for="item in entry.items" :key="item">{{ item }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 客户端更新日志(登录页 / 首页更新面板共用)。
|
||||
*
|
||||
* 内容来自 shared/client-changelog(发版时按 git 历史整理追加),
|
||||
* 由 useVersionUpdate 按"本机版本 → 最新版本"区间筛好后传入;
|
||||
* 条目多时区域内滚动,避免把面板撑长。
|
||||
*/
|
||||
import type { ClientChangelogEntry } from '@/shared/client-changelog'
|
||||
|
||||
defineProps<{ entries: ClientChangelogEntry[] }>()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.update-log {
|
||||
margin-top: 10px;
|
||||
padding-top: 8px;
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.06);
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.update-log-title {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
color: #4e6479;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.update-log-scroll {
|
||||
max-height: 176px;
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.update-log-entry + .update-log-entry {
|
||||
margin-top: 8px;
|
||||
padding-top: 8px;
|
||||
border-top: 1px dashed rgba(0, 0, 0, 0.07);
|
||||
}
|
||||
|
||||
.update-log-head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.update-log-version {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
|
||||
.update-log-date {
|
||||
font-size: 11.5px;
|
||||
color: #8293a5;
|
||||
}
|
||||
|
||||
.update-log-items {
|
||||
margin: 4px 0 0;
|
||||
padding-left: 16px;
|
||||
list-style: disc;
|
||||
}
|
||||
|
||||
.update-log-items li {
|
||||
font-size: 12.5px;
|
||||
line-height: 1.6;
|
||||
color: #4e6479;
|
||||
word-break: break-word;
|
||||
}
|
||||
</style>
|
||||
@@ -4,7 +4,9 @@
|
||||
历史任务<template v-if="count > 0">({{ count }})</template>
|
||||
</button>
|
||||
|
||||
<el-drawer v-model="open" :title="historyTitle" size="640px" class="task-history-drawer">
|
||||
<!-- destroy-on-close:抽屉关闭即销毁内部 DOM。默认按 v-show 保留,历史条目多时
|
||||
(每卡 8+ 节点)关闭后仍留在文档里参与后续 diff;条目数上限属产品语义,另行决策。 -->
|
||||
<el-drawer v-model="open" :title="historyTitle" size="640px" class="task-history-drawer" destroy-on-close>
|
||||
<div class="history-body">
|
||||
<!-- 批量删除工具条(传入 onBatchDelete 时显示) -->
|
||||
<div v-if="onBatchDelete" class="history-toolbar">
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
import { computed, ref } from 'vue'
|
||||
import { getPywebviewApi } from '@/shared/bridges/pywebview'
|
||||
import { selectChangelogEntries, type ClientChangelogEntry } from '@/shared/client-changelog'
|
||||
import { compareVersions, normVersion } from '@/shared/utils/version-compare'
|
||||
import {
|
||||
normalizeUpdateProgress,
|
||||
@@ -138,8 +139,8 @@ export function useVersionUpdate() {
|
||||
const doUpdateApp = bridge?.do_update_app
|
||||
const desktopUpdate = Boolean(doUpdateApp)
|
||||
const tip = desktopUpdate
|
||||
? '有更新,是否现在更新?\n更新将下载安装包并重启程序。'
|
||||
: '发现新版本,是否下载最新安装包?'
|
||||
? `有更新,是否现在更新?${changelogConfirmSuffix()}\n更新将下载安装包并重启程序。`
|
||||
: `发现新版本,是否下载最新安装包?${changelogConfirmSuffix()}`
|
||||
if (!window.confirm(tip)) return
|
||||
updating.value = true
|
||||
if (!desktopUpdate) {
|
||||
@@ -200,6 +201,17 @@ export function useVersionUpdate() {
|
||||
// 进度条的百分比/文案由 UpdateProgressBar 组件从 progress 自行派生(见 shared/utils/update-progress)
|
||||
const progress = computed(() => updateProgress.value)
|
||||
|
||||
// 更新日志:本机版本之后到最新版本之间的条目(文案见 shared/client-changelog)
|
||||
const changelog = computed<ClientChangelogEntry[]>(() =>
|
||||
selectChangelogEntries({ currentVersion: currentVersion.value, latestVersion: latestVersion.value }),
|
||||
)
|
||||
|
||||
/** 更新确认框里的"本次更新内容":只取最新一条、最多 5 行,避免弹窗过长 */
|
||||
function changelogConfirmSuffix(): string {
|
||||
const items = (changelog.value[0]?.items ?? []).slice(0, 5)
|
||||
return items.length ? `\n本次更新内容:\n${items.map((item) => `· ${item}`).join('\n')}` : ''
|
||||
}
|
||||
|
||||
return {
|
||||
checking,
|
||||
updating,
|
||||
@@ -211,6 +223,7 @@ export function useVersionUpdate() {
|
||||
hint,
|
||||
checked,
|
||||
progress,
|
||||
changelog,
|
||||
loadCurrentVersion,
|
||||
runCheck,
|
||||
doUpdate,
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
|
||||
import {
|
||||
CLIENT_CHANGELOG,
|
||||
newestChangelogVersion,
|
||||
selectChangelogEntries,
|
||||
type ClientChangelogEntry,
|
||||
} from '../src/shared/client-changelog.ts'
|
||||
|
||||
const FIXTURE: ClientChangelogEntry[] = [
|
||||
{ version: '4.1.0', date: '2026-09-20', items: ['新功能甲'] },
|
||||
{ version: '4.0.11', date: '2026-09-13', items: ['修复乙'] },
|
||||
{ version: '4.0.9', date: '2026-09-13', items: ['修复丙'] },
|
||||
{ version: '4.0.4', date: '2026-09-13', items: ['修复丁'] },
|
||||
]
|
||||
|
||||
test('更新日志:数据文件新版本在前且版本号唯一', () => {
|
||||
const versions = CLIENT_CHANGELOG.map((entry) => entry.version)
|
||||
assert.ok(versions.length > 0, '更新日志不应为空')
|
||||
assert.deepEqual(
|
||||
versions,
|
||||
[...new Set(versions)],
|
||||
'版本号不得重复(重复会让面板出现两条同名记录)',
|
||||
)
|
||||
const sorted = [...versions].sort((a, b) => {
|
||||
const pa = a.split('.').map(Number)
|
||||
const pb = b.split('.').map(Number)
|
||||
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
||||
const diff = (pa[i] ?? 0) - (pb[i] ?? 0)
|
||||
if (diff !== 0) return diff
|
||||
}
|
||||
return 0
|
||||
})
|
||||
assert.deepEqual(versions, sorted.reverse(), '更新日志应按版本号从新到旧排列')
|
||||
})
|
||||
|
||||
test('更新日志:每条都有日期与面向用户的说明', () => {
|
||||
for (const entry of CLIENT_CHANGELOG) {
|
||||
assert.match(entry.version, /^\d+(\.\d+)+$/, `版本号格式异常:${entry.version}`)
|
||||
assert.match(entry.date, /^\d{4}-\d{2}-\d{2}$/, `日期格式异常:${entry.version}`)
|
||||
assert.ok(entry.items.length > 0, `缺少更新说明:${entry.version}`)
|
||||
for (const item of entry.items) {
|
||||
assert.ok(item.trim().length > 0, `更新说明为空:${entry.version}`)
|
||||
assert.ok(item.length <= 40, `更新说明过长(面板放不下,需精简):${entry.version} -> ${item}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test('更新日志:最新版本号取数据文件第一条', () => {
|
||||
assert.equal(newestChangelogVersion(FIXTURE), '4.1.0')
|
||||
assert.equal(newestChangelogVersion([]), '')
|
||||
})
|
||||
|
||||
test('更新日志:只给本机版本之后的条目,新版本在前', () => {
|
||||
const entries = selectChangelogEntries({ entries: FIXTURE, currentVersion: '4.0.11', latestVersion: '4.1.0' })
|
||||
assert.deepEqual(entries.map((entry) => entry.version), ['4.1.0'])
|
||||
})
|
||||
|
||||
test('更新日志:落后多个版本时逐版本列出(含中间版本)', () => {
|
||||
const entries = selectChangelogEntries({ entries: FIXTURE, currentVersion: '4.0.4', latestVersion: '4.1.0' })
|
||||
assert.deepEqual(entries.map((entry) => entry.version), ['4.1.0', '4.0.11', '4.0.9'])
|
||||
})
|
||||
|
||||
test('更新日志:已是最新版本时没有条目(面板隐藏该区块)', () => {
|
||||
assert.deepEqual(
|
||||
selectChangelogEntries({ entries: FIXTURE, currentVersion: '4.0.11', latestVersion: '4.0.11' }),
|
||||
[],
|
||||
)
|
||||
})
|
||||
|
||||
test('更新日志:本机版本高于线上(灰度/回滚)不列条目', () => {
|
||||
assert.deepEqual(
|
||||
selectChangelogEntries({ entries: FIXTURE, currentVersion: '4.1.0', latestVersion: '4.0.11' }),
|
||||
[],
|
||||
)
|
||||
})
|
||||
|
||||
test('更新日志:线上已发布但日志未收录的新版本不误报旧条目', () => {
|
||||
const entries = selectChangelogEntries({ entries: FIXTURE, currentVersion: '4.1.0', latestVersion: '4.2.0' })
|
||||
assert.deepEqual(entries, [], '没有对应版本条目不倒推历史,避免把已装过的改动当成新内容')
|
||||
})
|
||||
|
||||
test('更新日志:拿不到本机版本(旧客户端)时只给最新一条', () => {
|
||||
const entries = selectChangelogEntries({ entries: FIXTURE, currentVersion: '', latestVersion: '4.1.0' })
|
||||
assert.deepEqual(entries.map((entry) => entry.version), ['4.1.0'])
|
||||
})
|
||||
|
||||
test('更新日志:检测未完成(线上版本为空)时按数据文件最新版本兜底', () => {
|
||||
const entries = selectChangelogEntries({ entries: FIXTURE, currentVersion: '4.0.4', latestVersion: '' })
|
||||
assert.deepEqual(entries.map((entry) => entry.version), ['4.1.0', '4.0.11', '4.0.9'])
|
||||
})
|
||||
|
||||
test('更新日志:两边版本都拿不到时给数据文件最新一条', () => {
|
||||
const entries = selectChangelogEntries({ entries: FIXTURE })
|
||||
assert.deepEqual(entries.map((entry) => entry.version), ['4.1.0'])
|
||||
})
|
||||
|
||||
test('更新日志:空数据不报错', () => {
|
||||
assert.deepEqual(selectChangelogEntries({ entries: [], currentVersion: '4.0.4' }), [])
|
||||
})
|
||||
|
||||
test('更新日志:版本号前缀 v 不影响筛选', () => {
|
||||
const entries = selectChangelogEntries({ entries: FIXTURE, currentVersion: 'v4.0.4', latestVersion: 'v4.0.11' })
|
||||
assert.deepEqual(entries.map((entry) => entry.version), ['4.0.11', '4.0.9'])
|
||||
})
|
||||
@@ -99,7 +99,7 @@ test('test_appearance_patent_progress_batch_timeout', async (t) => {
|
||||
const result = await getAppearancePatentTaskProgressBatch([5, 3])
|
||||
assert.equal(captured.url, '/newApi/api/appearance-patent/tasks/progress/batch')
|
||||
assert.equal(captured.method, 'POST')
|
||||
assert.deepEqual(captured.data, { taskIds: [3, 5] })
|
||||
assert.deepEqual(captured.data, { taskIds: [3, 5], userId: 42 })
|
||||
assert.equal(captured.timeout, 10000)
|
||||
assert.deepEqual(result, { items: [], missingTaskIds: [] })
|
||||
})
|
||||
|
||||
@@ -66,7 +66,7 @@ test('test_collect_data_progress_batch', async (t) => {
|
||||
const result = await getCollectDataTaskProgressBatch([5, 3], { force: true })
|
||||
assert.equal(calls[0].url, '/newApi/api/collect-data/tasks/progress/batch')
|
||||
assert.equal(calls[0].method, 'POST')
|
||||
assert.deepEqual(calls[0].data, { taskIds: [3, 5] })
|
||||
assert.deepEqual(calls[0].data, { taskIds: [3, 5], userId: 42 })
|
||||
assert.equal(calls[0].timeout, 10000)
|
||||
assert.deepEqual(result, { items: [], missingTaskIds: [] })
|
||||
})
|
||||
|
||||
@@ -97,7 +97,7 @@ test('test_delete_brand_task_details', async (t) => {
|
||||
await getDeleteBrandTaskDetails([5, 3])
|
||||
assert.equal(captured.url, '/newApi/api/delete-brand/tasks/batch')
|
||||
assert.equal(captured.method, 'POST')
|
||||
assert.deepEqual(captured.data, { taskIds: [5, 3] })
|
||||
assert.deepEqual(captured.data, { taskIds: [5, 3], userId: 42 })
|
||||
})
|
||||
|
||||
test('test_delete_brand_task_download_url', async (t) => {
|
||||
@@ -143,7 +143,7 @@ test('test_delete_brand_progress_batch', async (t) => {
|
||||
const result = await getDeleteBrandTaskProgress([5, 3])
|
||||
assert.equal(captured.url, '/newApi/api/delete-brand/tasks/progress/batch')
|
||||
assert.equal(captured.method, 'POST')
|
||||
assert.deepEqual(captured.data, { taskIds: [3, 5] })
|
||||
assert.deepEqual(captured.data, { taskIds: [3, 5], userId: 42 })
|
||||
assert.equal(captured.timeout, 10000)
|
||||
assert.deepEqual(result, { items: [], missingTaskIds: [] })
|
||||
})
|
||||
|
||||
@@ -124,7 +124,7 @@ test('test_price_track_tasks_batch_delete', async (t) => {
|
||||
await deletePriceTrackTask(7)
|
||||
assert.equal(calls[0].url, '/newApi/api/price-track/tasks/batch')
|
||||
assert.equal(calls[0].method, 'POST')
|
||||
assert.deepEqual(calls[0].data, { taskIds: [5, 3] })
|
||||
assert.deepEqual(calls[0].data, { taskIds: [5, 3], userId: 42 })
|
||||
assert.equal(calls[1].url, '/newApi/api/price-track/tasks/7?user_id=42')
|
||||
assert.equal(calls[1].method, 'DELETE')
|
||||
})
|
||||
@@ -173,7 +173,7 @@ test('test_price_track_progress_batch_timeout', async (t) => {
|
||||
const result = await getPriceTrackTaskProgressBatch([5, 3])
|
||||
assert.equal(captured.url, '/newApi/api/price-track/tasks/progress/batch')
|
||||
assert.equal(captured.method, 'POST')
|
||||
assert.deepEqual(captured.data, { taskIds: [3, 5] })
|
||||
assert.deepEqual(captured.data, { taskIds: [3, 5], userId: 42 })
|
||||
assert.equal(captured.timeout, 10000)
|
||||
assert.deepEqual(result, { items: [], missingTaskIds: [] })
|
||||
})
|
||||
|
||||
@@ -105,7 +105,7 @@ test('test_publish_progress_batch_timeout', async (t) => {
|
||||
const result = await getPublishTaskProgressBatch([5, 3, 5])
|
||||
assert.equal(captured.url, '/newApi/api/publish/tasks/progress/batch')
|
||||
assert.equal(captured.method, 'POST')
|
||||
assert.deepEqual(captured.data, { task_ids: [3, 5] })
|
||||
assert.deepEqual(captured.data, { task_ids: [3, 5], user_id: 42 })
|
||||
assert.equal(captured.timeout, 10000)
|
||||
assert.deepEqual(result, { items: [], missingTaskIds: [] })
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ test('test_shop_data_crawl_progress_batch_timeout', async (t) => {
|
||||
const result = await getShopDataCrawlTaskProgressBatch([5, 3])
|
||||
assert.equal(captured.url, '/newApi/api/shop-data-crawl/tasks/progress/batch')
|
||||
assert.equal(captured.method, 'POST')
|
||||
assert.deepEqual(captured.data, { taskIds: [3, 5] })
|
||||
assert.deepEqual(captured.data, { taskIds: [3, 5], userId: 42 })
|
||||
assert.equal(captured.timeout, 10000)
|
||||
assert.deepEqual(result, { items: [], missingTaskIds: [] })
|
||||
})
|
||||
@@ -204,7 +204,7 @@ test('test_query_asin_progress_delete_download', async (t) => {
|
||||
await deleteQueryAsinTask(7)
|
||||
await deleteQueryAsinHistory(9)
|
||||
assert.equal(calls[0].url, '/newApi/api/query-asin/tasks/progress/batch')
|
||||
assert.deepEqual(calls[0].data, { taskIds: [3, 5] })
|
||||
assert.deepEqual(calls[0].data, { taskIds: [3, 5], userId: 42 })
|
||||
assert.equal(calls[0].timeout, 10000)
|
||||
assert.equal(calls[1].url, '/newApi/api/query-asin/tasks/7')
|
||||
assert.equal(calls[1].method, 'DELETE')
|
||||
|
||||
@@ -113,7 +113,7 @@ test('test_product_risk_task_apis', async (t) => {
|
||||
assert.equal(calls[2].url, '/newApi/api/product-risk-resolve/pending-shop-result')
|
||||
assert.deepEqual(calls[2].params, { user_id: 42, shop_name: '店铺A' })
|
||||
assert.equal(calls[3].url, '/newApi/api/product-risk-resolve/tasks/batch')
|
||||
assert.deepEqual(calls[3].data, { taskIds: [5, 3] })
|
||||
assert.deepEqual(calls[3].data, { taskIds: [5, 3], userId: 42 })
|
||||
})
|
||||
|
||||
test('test_product_risk_dashboard_history_download', async (t) => {
|
||||
@@ -199,7 +199,7 @@ test('test_shop_match_task_apis', async (t) => {
|
||||
assert.equal(calls[3].url, '/newApi/api/shop-match/tasks/7/stage-finished?user_id=42')
|
||||
assert.deepEqual(calls[3].data, { stage_index: 1 })
|
||||
assert.equal(calls[4].url, '/newApi/api/shop-match/tasks/batch')
|
||||
assert.deepEqual(calls[4].data, { taskIds: [5, 3] })
|
||||
assert.deepEqual(calls[4].data, { taskIds: [5, 3], userId: 42 })
|
||||
})
|
||||
|
||||
test('test_shop_match_dashboard_history_skip_asins', async (t) => {
|
||||
@@ -236,10 +236,10 @@ test('test_shop_match_product_risk_progress_batch', async (t) => {
|
||||
const shopMatch = await getShopMatchTaskProgressBatch([5, 3])
|
||||
const productRisk = await getProductRiskTaskProgressBatch([5, 3])
|
||||
assert.equal(calls[0].url, '/newApi/api/shop-match/tasks/progress/batch')
|
||||
assert.deepEqual(calls[0].data, { taskIds: [3, 5] })
|
||||
assert.deepEqual(calls[0].data, { taskIds: [3, 5], userId: 42 })
|
||||
assert.equal(calls[0].timeout, 10000)
|
||||
assert.equal(calls[1].url, '/newApi/api/product-risk-resolve/tasks/progress/batch')
|
||||
assert.deepEqual(calls[1].data, { taskIds: [3, 5] })
|
||||
assert.deepEqual(calls[1].data, { taskIds: [3, 5], userId: 42 })
|
||||
assert.equal(calls[1].timeout, 10000)
|
||||
assert.deepEqual(shopMatch, { items: [], missingTaskIds: [] })
|
||||
assert.deepEqual(productRisk, { items: [], missingTaskIds: [] })
|
||||
|
||||
@@ -100,7 +100,7 @@ test('test_similar_asin_progress_batch_timeout', async (t) => {
|
||||
const result = await getSimilarAsinTaskProgressBatch([5, 3])
|
||||
assert.equal(captured.url, '/newApi/api/similar-asin/tasks/progress/batch')
|
||||
assert.equal(captured.method, 'POST')
|
||||
assert.deepEqual(captured.data, { taskIds: [3, 5] })
|
||||
assert.deepEqual(captured.data, { taskIds: [3, 5], userId: 42 })
|
||||
assert.equal(captured.timeout, 10000)
|
||||
assert.deepEqual(result, { items: [], missingTaskIds: [] })
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ test('test_withdraw_progress_dashboard_history', async (t) => {
|
||||
await deleteWithdrawHistory(9)
|
||||
assert.equal(calls[0].url, '/newApi/api/withdraw/tasks/progress/batch')
|
||||
assert.equal(calls[0].method, 'POST')
|
||||
assert.deepEqual(calls[0].data, { taskIds: [3, 5] })
|
||||
assert.deepEqual(calls[0].data, { taskIds: [3, 5], userId: 42 })
|
||||
assert.equal(calls[0].timeout, 10000)
|
||||
assert.equal(calls[1].url, '/newApi/api/withdraw/dashboard')
|
||||
assert.deepEqual(calls[1].params, { user_id: 42 })
|
||||
@@ -208,7 +208,7 @@ test('test_patrol_delete_progress_dashboard_download', async (t) => {
|
||||
await deletePatrolDeleteHistory(9)
|
||||
assert.equal(calls[0].url, '/newApi/api/patrol-delete/tasks/progress/batch')
|
||||
assert.equal(calls[0].method, 'POST')
|
||||
assert.deepEqual(calls[0].data, { taskIds: [3, 5] })
|
||||
assert.deepEqual(calls[0].data, { taskIds: [3, 5], userId: 42 })
|
||||
assert.equal(calls[0].timeout, 10000)
|
||||
assert.equal(calls[1].url, '/newApi/api/patrol-delete/dashboard')
|
||||
assert.deepEqual(calls[1].params, { user_id: 42 })
|
||||
|
||||
Reference in New Issue
Block a user