feat(collect-channel): 专利与货源建单加「本单采集方式」单选框
执行方不再由全局开关定(后端 7469c710 起读 biz_file_task.collect_channel),
两个工具页建单时逐单选本机/线上,默认选中项取 /api/collect-routing 的模块默认。
- localCollectEnabled 改为从所选通道派生的 computed:启动分支、按钮文案、提示语
与建单入参同源,不再两处各判各的。
- 建完单即锁定单选框:通道在解析建单那一刻就写进任务行,事后再改只会被建单值覆盖,
界面会出现「选着线上、点启动却推本机」的假象。
- 货源查询 Tab 原本两条提示语都在讲「后台自动分批检测」(本机分支文案写错),
随本次一并改正。
- parse API 的 collect_channel 为可选参数:不传就不带这个键,服务端按模块默认兜,
新增两条用例把「传/不传」两种载荷形状钉住。
This commit is contained in:
@@ -17,6 +17,16 @@
|
|||||||
<textarea v-model="aiPrompt" class="prompt-input" rows="8" placeholder="选填:填写后会作为额外要求一并提交给检测" />
|
<textarea v-model="aiPrompt" class="prompt-input" rows="8" placeholder="选填:填写后会作为额外要求一并提交给检测" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="channel-row">
|
||||||
|
<span class="channel-title">本单采集方式</span>
|
||||||
|
<label class="channel-opt">
|
||||||
|
<input v-model="collectChannel" type="radio" value="LOCAL" :disabled="channelLocked" /> 本机采集
|
||||||
|
</label>
|
||||||
|
<label class="channel-opt">
|
||||||
|
<input v-model="collectChannel" type="radio" value="ONLINE" :disabled="channelLocked" /> 线上采集
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="run-row">
|
<div class="run-row">
|
||||||
<button type="button" class="btn-run" :disabled="parsing || !uploadedFiles.length" @click="parseFiles">
|
<button type="button" class="btn-run" :disabled="parsing || !uploadedFiles.length" @click="parseFiles">
|
||||||
{{ parsing ? '解析中...' : '解析并创建任务' }}
|
{{ parsing ? '解析中...' : '解析并创建任务' }}
|
||||||
@@ -26,9 +36,11 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<p class="loading-msg">
|
<p class="loading-msg">
|
||||||
{{ localCollectEnabled
|
{{ channelLocked
|
||||||
? '启动后任务推送到本机客户端采集,进度显示在右侧任务区,完成后可下载结果。'
|
? '本单通道已随任务登记,改方式请重新解析创建。'
|
||||||
: '提交后系统自动分批检测,进度显示在右侧任务区,完成后可下载结果。' }}
|
: (localCollectEnabled
|
||||||
|
? '启动后任务推送到本机客户端采集,进度显示在右侧任务区,完成后可下载结果。'
|
||||||
|
: '提交后系统自动分批检测,进度显示在右侧任务区,完成后可下载结果。') }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div v-if="visibleTaskSummary" class="parse-card">
|
<div v-if="visibleTaskSummary" class="parse-card">
|
||||||
@@ -98,7 +110,7 @@ import {
|
|||||||
type AppearancePatentParsedPayloadDto,
|
type AppearancePatentParsedPayloadDto,
|
||||||
type UploadedFileRef,
|
type UploadedFileRef,
|
||||||
} from '@/shared/api/java-modules'
|
} from '@/shared/api/java-modules'
|
||||||
import { getCollectRouting } from '@/shared/api/types/modules/collect-routing'
|
import { getCollectRouting, type CollectChannel } from '@/shared/api/types/modules/collect-routing'
|
||||||
import { getPywebviewApi } from '@/shared/bridges/pywebview'
|
import { getPywebviewApi } from '@/shared/bridges/pywebview'
|
||||||
import { useExcelFileUpload } from '@/shared/composables/useExcelFileUpload'
|
import { useExcelFileUpload } from '@/shared/composables/useExcelFileUpload'
|
||||||
import {
|
import {
|
||||||
@@ -144,11 +156,18 @@ const aiPrompt = ref('')
|
|||||||
const parsing = ref(false)
|
const parsing = ref(false)
|
||||||
const pushing = ref(false)
|
const pushing = ref(false)
|
||||||
/**
|
/**
|
||||||
* 本地采集开关(服务端 aiimage.collect-routing.local-enabled,默认开)。
|
* 这一单的采集执行通道(V183 建单时单选,随 /parse 交服务端落 biz_file_task.collect_channel)。
|
||||||
* 先按「本地」渲染,取不到配置也不改口:真正兜底在服务端——开关关着时 activate 会明确拒绝,
|
* 默认值取服务端「模块默认」(getCollectRouting),取不到就按本机渲染:真正兜底在服务端——
|
||||||
* 页面最多多报一次错,不会把任务推给不该跑本地的机器。
|
* 选了线上的单子 activate 会明确拒绝,页面最多多报一次错,不会把任务推给不该跑本地的机器。
|
||||||
*/
|
*/
|
||||||
const localCollectEnabled = ref(true)
|
const collectChannel = ref<CollectChannel>('LOCAL')
|
||||||
|
/** 派生量:模板与启动分支沿用「本机通道」这一读法,避免两处各判各的。 */
|
||||||
|
const localCollectEnabled = computed(() => collectChannel.value === 'LOCAL')
|
||||||
|
/**
|
||||||
|
* 通道在「解析建单」那一刻就写进任务行了,之后再改单选框只会被建单值覆盖,
|
||||||
|
* 界面就会出现「选着线上、点启动却推本机」的假象——所以建完单即锁定。
|
||||||
|
*/
|
||||||
|
const channelLocked = computed(() => parsing.value || pushing.value || Boolean(parseResult.value?.taskId))
|
||||||
|
|
||||||
/** 结果行版本跟踪(审查 F5 后续):版本未变的任务跳过行明细拉取 */
|
/** 结果行版本跟踪(审查 F5 后续):版本未变的任务跳过行明细拉取 */
|
||||||
const rowsVersionTracker = createRowsVersionTracker()
|
const rowsVersionTracker = createRowsVersionTracker()
|
||||||
@@ -445,7 +464,7 @@ async function parseFiles() {
|
|||||||
originalFilename: f.originalFilename,
|
originalFilename: f.originalFilename,
|
||||||
relativePath: f.relativePath,
|
relativePath: f.relativePath,
|
||||||
}))
|
}))
|
||||||
const res = await parseAppearancePatent(files, effectiveAiPrompt(), effectiveLlmApiKey())
|
const res = await parseAppearancePatent(files, effectiveAiPrompt(), effectiveLlmApiKey(), collectChannel.value)
|
||||||
// 本模块按主 ID 分组执行,没有分组就没有可跑的批次,一并拦下
|
// 本模块按主 ID 分组执行,没有分组就没有可跑的批次,一并拦下
|
||||||
const guard = checkParseResult(res, {
|
const guard = checkParseResult(res, {
|
||||||
requireGroups: true,
|
requireGroups: true,
|
||||||
@@ -577,13 +596,13 @@ const { batchDeleteHistory, deleteTaskRecord, downloadResult } = board
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
board.loadPollingIds()
|
board.loadPollingIds()
|
||||||
// 本地采集开关:读不到就按「本地」渲染,服务端 activate 会兜底拒绝,不至于误推给后台
|
// 单选框默认选中项取服务端模块默认;读不到就按本机,服务端 activate 会兜底拒绝
|
||||||
getCollectRouting()
|
getCollectRouting()
|
||||||
.then((routing) => {
|
.then((routing) => {
|
||||||
localCollectEnabled.value = routing.appearancePatentLocal !== false
|
collectChannel.value = routing.appearancePatentLocal !== false ? 'LOCAL' : 'ONLINE'
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.warn('[appearance-patent] 读取本地采集开关失败,按本地采集处理', error)
|
console.warn('[appearance-patent] 读取采集通道默认值失败,按本机采集处理', error)
|
||||||
})
|
})
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
board.loadDashboard().catch(() => undefined),
|
board.loadDashboard().catch(() => undefined),
|
||||||
@@ -609,6 +628,10 @@ onUnmounted(() => {
|
|||||||
.link { color: #6ea8fe; text-decoration: none; }
|
.link { color: #6ea8fe; text-decoration: none; }
|
||||||
.link:hover { color: #9fc5ff; }
|
.link:hover { color: #9fc5ff; }
|
||||||
.run-row { display: flex; gap: 10px; flex-wrap: wrap; }
|
.run-row { display: flex; gap: 10px; flex-wrap: wrap; }
|
||||||
|
.channel-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; color: #a0acbe; font-size: 12px; }
|
||||||
|
.channel-title { color: #5e6878; }
|
||||||
|
.channel-opt { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
|
||||||
|
.channel-opt:has(input:disabled) { opacity: .55; cursor: not-allowed; }
|
||||||
.btn-run, .btn-delete, .download { border: none; cursor: pointer; border-radius: 7px; }
|
.btn-run, .btn-delete, .download { border: none; cursor: pointer; border-radius: 7px; }
|
||||||
.btn-run { padding: 10px 18px; color: #f5f8fc; background: #3498db; font-weight: 600; }
|
.btn-run { padding: 10px 18px; color: #f5f8fc; background: #3498db; font-weight: 600; }
|
||||||
.btn-queue { background: #27ae60; }
|
.btn-queue { background: #27ae60; }
|
||||||
|
|||||||
@@ -54,6 +54,16 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="channel-row">
|
||||||
|
<span class="channel-title">本单采集方式</span>
|
||||||
|
<label class="channel-opt">
|
||||||
|
<input v-model="collectChannel" type="radio" value="LOCAL" :disabled="channelLocked" /> 本机采集
|
||||||
|
</label>
|
||||||
|
<label class="channel-opt">
|
||||||
|
<input v-model="collectChannel" type="radio" value="ONLINE" :disabled="channelLocked" /> 线上采集
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="run-row">
|
<div class="run-row">
|
||||||
<button type="button" class="btn-run" :disabled="parsing || !uploadedFiles.length" @click="parseFiles">
|
<button type="button" class="btn-run" :disabled="parsing || !uploadedFiles.length" @click="parseFiles">
|
||||||
{{ parsing ? '解析中...' : '解析并创建任务' }}
|
{{ parsing ? '解析中...' : '解析并创建任务' }}
|
||||||
@@ -64,9 +74,11 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<p class="loading-msg">
|
<p class="loading-msg">
|
||||||
{{ localCollectEnabled
|
{{ channelLocked
|
||||||
? '提交后系统自动分批检测,进度显示在右侧任务区,完成后可下载结果。'
|
? '本单通道已随任务登记,改方式请重新解析创建。'
|
||||||
: '提交后由后台自动分批检测,进度显示在右侧任务区,完成后可下载结果。' }}
|
: (localCollectEnabled
|
||||||
|
? '启动后任务推送到本机客户端采集,进度显示在右侧任务区,完成后可下载结果。'
|
||||||
|
: '提交后由后台自动分批检测,进度显示在右侧任务区,完成后可下载结果。') }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div v-if="visibleTaskSummary" class="parse-card">
|
<div v-if="visibleTaskSummary" class="parse-card">
|
||||||
@@ -150,7 +162,7 @@ import {
|
|||||||
checkQueuePayload,
|
checkQueuePayload,
|
||||||
} from '@/shared/dispatch-guard'
|
} from '@/shared/dispatch-guard'
|
||||||
import { passGuard } from '@/shared/dispatch-guard-ui'
|
import { passGuard } from '@/shared/dispatch-guard-ui'
|
||||||
import { getCollectRouting } from '@/shared/api/types/modules/collect-routing'
|
import { getCollectRouting, type CollectChannel } from '@/shared/api/types/modules/collect-routing'
|
||||||
import { formatDateTime } from '@/shared/utils/datetime'
|
import { formatDateTime } from '@/shared/utils/datetime'
|
||||||
import { isCompletedTask, resultBuildFailed, taskStatusClass, taskStatusText } from '@/shared/utils/task-status-text'
|
import { isCompletedTask, resultBuildFailed, taskStatusClass, taskStatusText } from '@/shared/utils/task-status-text'
|
||||||
import { getStoredApiSecret } from '@/shared/utils/api-secret-store'
|
import { getStoredApiSecret } from '@/shared/utils/api-secret-store'
|
||||||
@@ -188,10 +200,18 @@ const queuedTaskSummary = ref<TaskSummary | null>(null)
|
|||||||
const parsing = ref(false)
|
const parsing = ref(false)
|
||||||
const pushing = ref(false)
|
const pushing = ref(false)
|
||||||
/**
|
/**
|
||||||
* 本地采集开关(服务端 aiimage.collect-routing.local-enabled,默认开)。
|
* 这一单的采集执行通道(V183 建单时单选,随 /parse 交服务端落 biz_file_task.collect_channel)。
|
||||||
* 先按「本地」渲染,取不到配置也不改口:服务端 activate 在开关关着时会明确拒绝。
|
* 默认值取服务端「模块默认」(getCollectRouting),取不到就按本机渲染:
|
||||||
|
* 服务端 activate 在通道不是本机时会明确拒绝,不会把任务推给不该跑本地的机器。
|
||||||
*/
|
*/
|
||||||
const localCollectEnabled = ref(true)
|
const collectChannel = ref<CollectChannel>('LOCAL')
|
||||||
|
/** 派生量:模板与启动分支沿用「本机通道」这一读法,避免两处各判各的。 */
|
||||||
|
const localCollectEnabled = computed(() => collectChannel.value === 'LOCAL')
|
||||||
|
/**
|
||||||
|
* 通道在「解析建单」那一刻就写进任务行了,之后再改单选框只会被建单值覆盖,
|
||||||
|
* 界面就会出现「选着线上、点启动却推本机」的假象——所以建完单即锁定。
|
||||||
|
*/
|
||||||
|
const channelLocked = computed(() => parsing.value || pushing.value || Boolean(parseResult.value?.taskId))
|
||||||
const imgSwitch = ref(false)
|
const imgSwitch = ref(false)
|
||||||
const categorySwitch = ref(false)
|
const categorySwitch = ref(false)
|
||||||
const alipriceUsername = ref('')
|
const alipriceUsername = ref('')
|
||||||
@@ -501,7 +521,7 @@ async function parseFiles() {
|
|||||||
originalFilename: f.originalFilename,
|
originalFilename: f.originalFilename,
|
||||||
relativePath: f.relativePath,
|
relativePath: f.relativePath,
|
||||||
}))
|
}))
|
||||||
const res = await parseSimilarAsin(files, effectiveLlmApiKey(), imgSwitch.value, categorySwitch.value)
|
const res = await parseSimilarAsin(files, effectiveLlmApiKey(), imgSwitch.value, categorySwitch.value, collectChannel.value)
|
||||||
// 0 有效行的任务推给 Python 只会一直停在 RUNNING,这里拦下来不写入 parseResult
|
// 0 有效行的任务推给 Python 只会一直停在 RUNNING,这里拦下来不写入 parseResult
|
||||||
const guard = checkParseResult(res, { requiredColumnsHint: 'id / ASIN / 国家' })
|
const guard = checkParseResult(res, { requiredColumnsHint: 'id / ASIN / 国家' })
|
||||||
if (!(await passGuard(guard))) {
|
if (!(await passGuard(guard))) {
|
||||||
@@ -682,13 +702,13 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
window.addEventListener('pywebviewready', pywebviewReadyHandler)
|
window.addEventListener('pywebviewready', pywebviewReadyHandler)
|
||||||
}
|
}
|
||||||
// 本地采集开关:读不到就按「本地」渲染,服务端 activate 会兜底拒绝,不至于误推给后台
|
// 单选框默认选中项取服务端模块默认;读不到就按本机,服务端 activate 会兜底拒绝
|
||||||
getCollectRouting()
|
getCollectRouting()
|
||||||
.then((routing) => {
|
.then((routing) => {
|
||||||
localCollectEnabled.value = routing.similarAsinLocal !== false
|
collectChannel.value = routing.similarAsinLocal !== false ? 'LOCAL' : 'ONLINE'
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.warn('[similar-asin] 读取本地采集开关失败,按本地采集处理', error)
|
console.warn('[similar-asin] 读取采集通道默认值失败,按本机采集处理', error)
|
||||||
})
|
})
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
board.loadDashboard().catch(() => undefined),
|
board.loadDashboard().catch(() => undefined),
|
||||||
@@ -882,6 +902,32 @@ onUnmounted(() => {
|
|||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.channel-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 14px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
color: #a0acbe;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-title {
|
||||||
|
color: #5e6878;
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-opt {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-opt:has(input:disabled) {
|
||||||
|
opacity: .55;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
.btn-run,
|
.btn-run,
|
||||||
.btn-delete,
|
.btn-delete,
|
||||||
.download {
|
.download {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { getJavaDownloadUrl } from '../../download-url.ts'
|
|||||||
import { getTaskProgressCacheTtlMs, getTaskProgressTimeoutMs } from '../../../task-progress-config.ts'
|
import { getTaskProgressCacheTtlMs, getTaskProgressTimeoutMs } from '../../../task-progress-config.ts'
|
||||||
import { createTaskProgressRequestCache } from '../../../task-progress-request-cache.ts'
|
import { createTaskProgressRequestCache } from '../../../task-progress-request-cache.ts'
|
||||||
import type { UploadedFileRef } from '../upload.ts'
|
import type { UploadedFileRef } from '../upload.ts'
|
||||||
|
import type { CollectChannel } from './collect-routing.ts'
|
||||||
import { API_ENDPOINTS } from '../../endpoints.ts'
|
import { API_ENDPOINTS } from '../../endpoints.ts'
|
||||||
|
|
||||||
export interface AppearancePatentParsedRow {
|
export interface AppearancePatentParsedRow {
|
||||||
@@ -176,16 +177,29 @@ async function postTaskProgressBatch<T>(
|
|||||||
return requestPromise;
|
return requestPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseAppearancePatent(files: UploadedFileRef[], aiPrompt: string, apiKey?: string) {
|
export function parseAppearancePatent(
|
||||||
|
files: UploadedFileRef[],
|
||||||
|
aiPrompt: string,
|
||||||
|
apiKey?: string,
|
||||||
|
collectChannel?: CollectChannel,
|
||||||
|
) {
|
||||||
return unwrapJavaResponse(
|
return unwrapJavaResponse(
|
||||||
post<
|
post<
|
||||||
JavaApiResponse<AppearancePatentParseVo>,
|
JavaApiResponse<AppearancePatentParseVo>,
|
||||||
{ user_id: number; files: UploadedFileRef[]; ai_prompt: string; api_key?: string }
|
{
|
||||||
|
user_id: number;
|
||||||
|
files: UploadedFileRef[];
|
||||||
|
ai_prompt: string;
|
||||||
|
api_key?: string;
|
||||||
|
collect_channel?: CollectChannel;
|
||||||
|
}
|
||||||
>(buildJavaUrl(API_ENDPOINTS.appearancePatent.parse), {
|
>(buildJavaUrl(API_ENDPOINTS.appearancePatent.parse), {
|
||||||
user_id: getCurrentUserId(),
|
user_id: getCurrentUserId(),
|
||||||
files,
|
files,
|
||||||
ai_prompt: aiPrompt,
|
ai_prompt: aiPrompt,
|
||||||
api_key: apiKey,
|
api_key: apiKey,
|
||||||
|
// 不传就不带这个键:服务端按「未登记通道」兜到模块默认,未升级前端的行为一字不变
|
||||||
|
...(collectChannel ? { collect_channel: collectChannel } : {}),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,17 @@ import { buildJavaUrl } from '../../url.ts'
|
|||||||
import { API_ENDPOINTS } from '../../endpoints.ts'
|
import { API_ENDPOINTS } from '../../endpoints.ts'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 专利/货源的本地采集开关(服务端唯一真源,前端只读)。
|
* 这一单的采集执行通道:本机客户端采(LOCAL)还是 Linux/外机 Windows 采(ONLINE)。
|
||||||
|
* 建单时随 `/parse` 的 `collect_channel` 交服务端(V183 `biz_file_task.collect_channel`)。
|
||||||
|
*/
|
||||||
|
export type CollectChannel = 'LOCAL' | 'ONLINE';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 各模块「这一单没登记通道」时的默认执行方(服务端真源,前端只读)。
|
||||||
*
|
*
|
||||||
* 开着=页面把任务推本机客户端队列;关着=只建单、等 Linux 后台认领。
|
* 2026-10-31 起执行方由建单时的单选框逐单决定,本接口只用来决定单选框默认选中哪一项:
|
||||||
* 每次进页面现取,不做模块级缓存:运维改开关后用户刷新页面就该看到新口径,
|
* true=默认本机(页面把任务推本机客户端队列),false=默认线上(只建单,等 Linux 后台认领)。
|
||||||
|
* 每次进页面现取,不做模块级缓存:运维改默认后用户刷新页面就该看到新口径,
|
||||||
* 一次小 GET 不值得换一个「改了没生效」的排查成本。
|
* 一次小 GET 不值得换一个「改了没生效」的排查成本。
|
||||||
*/
|
*/
|
||||||
export interface CollectRoutingVo {
|
export interface CollectRoutingVo {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { getJavaDownloadUrl } from '../../download-url.ts'
|
|||||||
import { getTaskProgressCacheTtlMs, getTaskProgressTimeoutMs } from '../../../task-progress-config.ts'
|
import { getTaskProgressCacheTtlMs, getTaskProgressTimeoutMs } from '../../../task-progress-config.ts'
|
||||||
import { createTaskProgressRequestCache } from '../../../task-progress-request-cache.ts'
|
import { createTaskProgressRequestCache } from '../../../task-progress-request-cache.ts'
|
||||||
import type { UploadedFileRef } from '../upload.ts'
|
import type { UploadedFileRef } from '../upload.ts'
|
||||||
|
import type { CollectChannel } from './collect-routing.ts'
|
||||||
import { API_ENDPOINTS } from '../../endpoints.ts'
|
import { API_ENDPOINTS } from '../../endpoints.ts'
|
||||||
|
|
||||||
export interface SimilarAsinParsedRow {
|
export interface SimilarAsinParsedRow {
|
||||||
@@ -173,6 +174,7 @@ export function parseSimilarAsin(
|
|||||||
apiKey?: string,
|
apiKey?: string,
|
||||||
imgSwitch = false,
|
imgSwitch = false,
|
||||||
categorySwitch = false,
|
categorySwitch = false,
|
||||||
|
collectChannel?: CollectChannel,
|
||||||
) {
|
) {
|
||||||
return unwrapJavaResponse(
|
return unwrapJavaResponse(
|
||||||
post<
|
post<
|
||||||
@@ -183,6 +185,7 @@ export function parseSimilarAsin(
|
|||||||
api_key?: string;
|
api_key?: string;
|
||||||
img_switch: boolean;
|
img_switch: boolean;
|
||||||
category_switch: boolean;
|
category_switch: boolean;
|
||||||
|
collect_channel?: CollectChannel;
|
||||||
}
|
}
|
||||||
>(buildJavaUrl(API_ENDPOINTS.similarAsin.parse), {
|
>(buildJavaUrl(API_ENDPOINTS.similarAsin.parse), {
|
||||||
user_id: getCurrentUserId(),
|
user_id: getCurrentUserId(),
|
||||||
@@ -190,6 +193,8 @@ export function parseSimilarAsin(
|
|||||||
api_key: apiKey,
|
api_key: apiKey,
|
||||||
img_switch: imgSwitch,
|
img_switch: imgSwitch,
|
||||||
category_switch: categorySwitch,
|
category_switch: categorySwitch,
|
||||||
|
// 不传就不带这个键:服务端按「未登记通道」兜到模块默认,未升级前端的行为一字不变
|
||||||
|
...(collectChannel ? { collect_channel: collectChannel } : {}),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,23 @@ test('test_appearance_patent_parse_url_payload', async (t) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('test_appearance_patent_parse_carries_collect_channel', async (t) => {
|
||||||
|
setupWindow()
|
||||||
|
const bodies: unknown[] = []
|
||||||
|
mockRequest(t, (config) => {
|
||||||
|
bodies.push(config.data)
|
||||||
|
return okResponse({ taskId: 1, totalRows: 1, acceptedRows: 1, droppedRows: 0, items: [] })
|
||||||
|
})
|
||||||
|
|
||||||
|
await parseAppearancePatent([{ fileKey: 'k1' }], '请识别', 'api-1', 'ONLINE')
|
||||||
|
await parseAppearancePatent([{ fileKey: 'k1' }], '请识别', 'api-1')
|
||||||
|
|
||||||
|
const picked = bodies[0] as Record<string, unknown>
|
||||||
|
assert.equal(picked.collect_channel, 'ONLINE', '界面选了线上就必须随建单交出去')
|
||||||
|
const legacy = bodies[1] as Record<string, unknown>
|
||||||
|
assert.ok(!('collect_channel' in legacy), '不选就不带这个键,服务端按模块默认兜(未升级前端行为不变)')
|
||||||
|
})
|
||||||
|
|
||||||
test('test_appearance_patent_dashboard_history', async (t) => {
|
test('test_appearance_patent_dashboard_history', async (t) => {
|
||||||
setupWindow()
|
setupWindow()
|
||||||
const calls: { url?: string; params?: Record<string, unknown> }[] = []
|
const calls: { url?: string; params?: Record<string, unknown> }[] = []
|
||||||
|
|||||||
@@ -65,6 +65,23 @@ test('test_similar_asin_parse_defaults', async (t) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('test_similar_asin_parse_carries_collect_channel', async (t) => {
|
||||||
|
setupWindow()
|
||||||
|
const bodies: unknown[] = []
|
||||||
|
mockRequest(t, (config) => {
|
||||||
|
bodies.push(config.data)
|
||||||
|
return okResponse({ taskId: 1, totalRows: 1, acceptedRows: 1, droppedRows: 0, items: [] })
|
||||||
|
})
|
||||||
|
|
||||||
|
await parseSimilarAsin([{ fileKey: 'k1' }], 'api-key-1', false, false, 'LOCAL')
|
||||||
|
await parseSimilarAsin([{ fileKey: 'k1' }])
|
||||||
|
|
||||||
|
const picked = bodies[0] as Record<string, unknown>
|
||||||
|
assert.equal(picked.collect_channel, 'LOCAL', '界面单选的本机通道要随建单交出去,Linux 侧才不会被兜底窗口抢走')
|
||||||
|
const legacy = bodies[1] as Record<string, unknown>
|
||||||
|
assert.ok(!('collect_channel' in legacy), '不选就不带这个键,服务端按模块默认兜(未升级前端行为不变)')
|
||||||
|
})
|
||||||
|
|
||||||
test('test_similar_asin_dashboard', async (t) => {
|
test('test_similar_asin_dashboard', async (t) => {
|
||||||
setupWindow()
|
setupWindow()
|
||||||
let captured: { url?: string; params?: Record<string, unknown> } = {}
|
let captured: { url?: string; params?: Record<string, unknown> } = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user