合并分支

This commit is contained in:
super
2026-05-31 09:28:48 +08:00
parent 9835831415
commit ea37d82d73
35 changed files with 200 additions and 7893 deletions

View File

@@ -34,7 +34,7 @@
v-model="secretStates[config.key].value"
class="secret-input"
type="password"
placeholder="请输入 Coze 接口密钥"
:placeholder="config.placeholder"
autocomplete="off"
spellcheck="false"
/>
@@ -96,21 +96,30 @@ const retentionOptions: Array<{ value: ApiSecretRetention; label: string }> = [
{ value: 'forever', label: '长期保留' },
]
const secretConfigs: Array<{ key: ApiSecretModuleKey; title: string; description: string }> = [
const secretConfigs: Array<{ key: ApiSecretModuleKey; title: string; description: string; placeholder: string }> = [
{
key: 'appearance-patent',
title: '外观专利密钥',
description: '仅用于外观专利检测。',
placeholder: '请输入 Coze 接口密钥',
},
{
key: 'appearance-patent-token',
title: '专利汇令牌',
description: '仅用于外观专利检测,非必填。',
placeholder: '请输入专利汇令牌,可留空',
},
{
key: 'similar-asin',
title: '货源查询密钥',
description: '仅用于货源查询。',
placeholder: '请输入 Coze 接口密钥',
},
]
const secretStates = ref<Record<ApiSecretModuleKey, SecretState>>({
'appearance-patent': emptySecretState(),
'appearance-patent-token': emptySecretState(),
'similar-asin': emptySecretState(),
})

View File

@@ -261,6 +261,10 @@ function effectiveCozeApiKey() {
return getStoredApiSecret('appearance-patent').trim()
}
function effectivePatentToken() {
return getStoredApiSecret('appearance-patent-token').trim()
}
function maskSecret(secret: string) {
if (!secret) return ''
if (secret.length <= 10) return '***'
@@ -274,6 +278,7 @@ function payloadForDisplay<T extends { data?: Record<string, unknown> }>(payload
? {
...payload.data,
api_key: maskSecret(String(payload.data.api_key || '')),
patent_token: maskSecret(String(payload.data.patent_token || '')),
}
: payload.data,
}
@@ -406,7 +411,7 @@ async function parseFiles() {
originalFilename: f.originalFilename,
relativePath: f.relativePath,
}))
const res = await parseAppearancePatent(files, effectiveAiPrompt(), effectiveCozeApiKey())
const res = await parseAppearancePatent(files, effectiveAiPrompt(), effectiveCozeApiKey(), effectivePatentToken())
parseResult.value = res
queuedTaskSummary.value = null
queuePayloadText.value = ''
@@ -445,6 +450,7 @@ async function pushToPythonQueue() {
taskId,
prompt: queueAiPrompt(),
api_key: effectiveCozeApiKey(),
patent_token: effectivePatentToken(),
sourceFileCount: currentParseResult.sourceFileCount || 0,
totalRows: currentParseResult.totalRows || 0,
acceptedRows: currentParseResult.acceptedRows || 0,

View File

@@ -1529,6 +1529,7 @@ export interface AppearancePatentParseVo {
export interface AppearancePatentParsedPayloadDto {
aiPrompt?: string;
apiKey?: string;
patentToken?: string;
sourceFiles?: UploadedFileRef[];
headers?: string[];
items?: AppearancePatentParsedRow[];
@@ -1590,16 +1591,17 @@ export interface AppearancePatentTaskBatchVo {
missingTaskIds?: number[];
}
export function parseAppearancePatent(files: UploadedFileRef[], aiPrompt: string, apiKey?: string) {
export function parseAppearancePatent(files: UploadedFileRef[], aiPrompt: string, apiKey?: string, patentToken?: string) {
return unwrapJavaResponse(
post<
JavaApiResponse<AppearancePatentParseVo>,
{ user_id: number; files: UploadedFileRef[]; ai_prompt: string; api_key?: string }
{ user_id: number; files: UploadedFileRef[]; ai_prompt: string; api_key?: string; patent_token?: string }
>(`${JAVA_API_PREFIX}/appearance-patent/parse`, {
user_id: getCurrentUserId(),
files,
ai_prompt: aiPrompt,
api_key: apiKey,
patent_token: patentToken,
}),
);
}

View File

@@ -1,4 +1,4 @@
export type ApiSecretModuleKey = 'appearance-patent' | 'similar-asin'
export type ApiSecretModuleKey = 'appearance-patent' | 'appearance-patent-token' | 'similar-asin'
export type ApiSecretRetention = 'session' | '1d' | '7d' | '30d' | 'forever'
@@ -19,7 +19,7 @@ export type ApiSecretSnapshot = {
const STORAGE_PREFIX = 'brand:api-secret'
const COMMON_SECRET_KEY = 'common'
const MODULE_SECRET_KEYS: ApiSecretModuleKey[] = ['appearance-patent', 'similar-asin']
const MODULE_SECRET_KEYS: ApiSecretModuleKey[] = ['appearance-patent', 'appearance-patent-token', 'similar-asin']
function currentUserStorageId() {
if (typeof window === 'undefined') return '0'
@@ -115,7 +115,7 @@ function clearLegacyStoredApiSecrets() {
function migrateCommonRecord(record: ApiSecretRecord) {
if (typeof window === 'undefined') return
const storage = record.retention === 'session' ? window.sessionStorage : window.localStorage
for (const moduleKey of MODULE_SECRET_KEYS) {
for (const moduleKey of ['appearance-patent', 'similar-asin'] satisfies ApiSecretModuleKey[]) {
if (!getLiveRecordFromKey(moduleKey)) {
storage.setItem(buildStorageKey(moduleKey), JSON.stringify(record))
}