fix(brand): 品牌检测补上传链+新增 /api/brand/run 端点+文件夹展开桥

- BrandBrandTab 对齐其它工具页:选文件/文件夹后先 upload_file_to_java 再提交(服务器可读路径),修复本地路径直传导致的「请先上传待处理文件/没有有效的xlsx文件路径」
- runBrandNow/createBrandTask 改为 files 契约(fileUrl=临时路径 localPath)+ 传 userId
- Java 新增 POST /api/brand/run(等价 /tasks 并返回待爬取数据),修复前端「立即运行」No static resource
- 选择文件夹改走新版桌面客户端桥 expand_brand_folder(本机展开);旧客户端提示改用文件多选
- 生产 .env 已另配 AIIMAGE_BRAND_CHECK_TOKEN(上游 16890 鉴权),非代码变更
This commit is contained in:
2026-09-08 13:18:23 +08:00
parent f2906e8d6f
commit 7b6f62f1bc
5 changed files with 86 additions and 32 deletions
@@ -1,4 +1,5 @@
import { requestDeleteJson, requestGetJson, requestPostJson } from '../../http.ts'
import type { UploadedFileRef } from '../../upload.ts'
function getCurrentUserId() {
const raw = typeof window === 'undefined' ? '' : window.localStorage.getItem('uid') || ''
@@ -82,12 +83,18 @@ export function expandBrandFolderRecursive(folder: string) {
return requestPostJson<BrandExpandFolderResponse>(`${API_PREFIX}/api/brand/expand-folder-recursive`, { folder })
}
export function runBrandNow(paths: string[], strategy: string) {
return requestPostJson<BrandTaskMutationResponse>(`${API_PREFIX}/api/brand/run`, { paths, strategy })
export function runBrandNow(files: UploadedFileRef[], strategy: string) {
return requestPostJson<BrandTaskMutationResponse>(
`${API_PREFIX}/api/brand/run?userId=${encodeURIComponent(String(getCurrentUserId()))}`,
{ files, strategy, taskType: 1 },
)
}
export function createBrandTask(paths: string[], strategy: string) {
return requestPostJson<BrandTaskMutationResponse>(`${API_PREFIX}/api/brand/tasks?userId=${encodeURIComponent(String(getCurrentUserId()))}`, { paths, strategy })
export function createBrandTask(files: UploadedFileRef[], strategy: string) {
return requestPostJson<BrandTaskMutationResponse>(
`${API_PREFIX}/api/brand/tasks?userId=${encodeURIComponent(String(getCurrentUserId()))}`,
{ files, strategy, taskType: 2 },
)
}
export function getBrandTasks() {
@@ -2,4 +2,6 @@ export interface UploadedFileRef {
fileKey: string;
originalFilename?: string;
relativePath?: string;
/** 服务器本地临时文件路径(Java 可读),品牌检测等模块用它作为源文件地址 */
fileUrl?: string;
}
@@ -86,6 +86,10 @@ export interface PywebviewApi {
select_folder?: () => Promise<string | null>;
select_brand_xlsx_files?: () => Promise<string[]>;
select_brand_folder?: () => Promise<string | null>;
/** 本机展开文件夹下的 xlsx 文件(供品牌检测"选择文件夹");新版桌面客户端提供 */
expand_brand_folder?: (
folder: string,
) => Promise<{ success: boolean; items?: Array<{ absolutePath: string; relativePath: string }>; error?: string }>;
upload_file_to_java?: (
filePath: string,
relativePath?: string,