refactor(weknoracloud): enhance internationalization and UI feedback for credential management
- Updated the WeKnoraCloud settings and related components to utilize i18n for improved localization. - Replaced hardcoded strings with translation keys for better maintainability and user experience. - Enhanced user feedback messages for credential status, including configuration, expiration, and unconfiguration states. - Improved UI elements to guide users in managing WeKnoraCloud credentials effectively. This update streamlines the user interface and ensures consistent messaging across different languages.
This commit is contained in:
@@ -150,14 +150,13 @@
|
|||||||
<div v-if="wkcCredentialState === 'configured'" class="weknoracloud-hint weknoracloud-hint--ok">
|
<div v-if="wkcCredentialState === 'configured'" class="weknoracloud-hint weknoracloud-hint--ok">
|
||||||
<t-icon name="check-circle-filled" style="font-size: 16px; color: var(--td-success-color); flex-shrink: 0;" />
|
<t-icon name="check-circle-filled" style="font-size: 16px; color: var(--td-success-color); flex-shrink: 0;" />
|
||||||
<div>
|
<div>
|
||||||
WeKnoraCloud 凭证已配置。
|
{{ $t('settings.weknoraCloud.modelHintConfigured') }}
|
||||||
支持的模型可参考
|
|
||||||
<a
|
<a
|
||||||
href="https://developers.weixin.qq.com/doc/aispeech/knowledge/atomic_capability/atomic_interface.html"
|
href="https://developers.weixin.qq.com/doc/aispeech/knowledge/atomic_capability/atomic_interface.html"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
class="weknoracloud-hint-link"
|
class="weknoracloud-hint-link"
|
||||||
>接口文档</a>。
|
>{{ $t('settings.weknoraCloud.modelHintDocsLink') }}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -166,10 +165,10 @@
|
|||||||
<t-icon name="error-circle-filled" style="font-size: 16px; color: #f97316; flex-shrink: 0;" />
|
<t-icon name="error-circle-filled" style="font-size: 16px; color: #f97316; flex-shrink: 0;" />
|
||||||
<div style="flex: 1;">
|
<div style="flex: 1;">
|
||||||
<template v-if="wkcCredentialState === 'expired'">
|
<template v-if="wkcCredentialState === 'expired'">
|
||||||
WeKnoraCloud 凭证已失效,请重新配置。
|
{{ $t('settings.weknoraCloud.credentialExpired') }}
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
尚未配置 WeKnoraCloud 凭证,请先填写 APPID 和 APPSECRET。
|
{{ $t('settings.weknoraCloud.credentialUnconfigured') }}
|
||||||
</template>
|
</template>
|
||||||
<div style="margin-top: 8px;">
|
<div style="margin-top: 8px;">
|
||||||
<t-button
|
<t-button
|
||||||
@@ -179,7 +178,7 @@
|
|||||||
@click="goToWeKnoraCloudSettings"
|
@click="goToWeKnoraCloudSettings"
|
||||||
style="padding: 0; height: auto;"
|
style="padding: 0; height: auto;"
|
||||||
>
|
>
|
||||||
前往设置中配置
|
{{ $t('settings.weknoraCloud.goToSettings') }}
|
||||||
</t-button>
|
</t-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -188,7 +187,7 @@
|
|||||||
<!-- 加载中 -->
|
<!-- 加载中 -->
|
||||||
<div v-else class="weknoracloud-hint">
|
<div v-else class="weknoracloud-hint">
|
||||||
<t-icon name="loading" class="spinning" style="font-size: 16px; color: var(--td-text-color-placeholder); flex-shrink: 0;" />
|
<t-icon name="loading" class="spinning" style="font-size: 16px; color: var(--td-text-color-placeholder); flex-shrink: 0;" />
|
||||||
<span>正在检查凭证状态...</span>
|
<span>{{ $t('settings.weknoraCloud.checkingStatus') }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -579,6 +579,36 @@ export default {
|
|||||||
systemSettings: 'System Settings',
|
systemSettings: 'System Settings',
|
||||||
tenantInfo: 'Tenant Info',
|
tenantInfo: 'Tenant Info',
|
||||||
apiInfo: 'API Info',
|
apiInfo: 'API Info',
|
||||||
|
weknoraCloud: {
|
||||||
|
title: 'WeKnora Cloud',
|
||||||
|
description: 'Configure WeKnora Cloud APPID and APPSECRET credentials. Credentials are used for model services and document parsing engine.',
|
||||||
|
viewDocs: 'View Docs',
|
||||||
|
unconfigured: 'Credentials not configured. Please fill in APPID and APPSECRET.',
|
||||||
|
configured: 'Credentials configured and working.',
|
||||||
|
expired: 'WeKnora Cloud credentials expired',
|
||||||
|
expiredDefault: 'Encryption key changed after service restart. Saved credentials cannot be decrypted. Please re-enter credentials.',
|
||||||
|
reconfigure: 'Reconfigure',
|
||||||
|
appIdLabel: 'APPID',
|
||||||
|
appIdDesc: 'WeKnora Cloud application ID',
|
||||||
|
appIdPlaceholder: 'Enter APPID',
|
||||||
|
appSecretLabel: 'APPSECRET',
|
||||||
|
appSecretDesc: 'WeKnora Cloud application secret',
|
||||||
|
appSecretPlaceholder: 'Enter APPSECRET',
|
||||||
|
saveHint: 'Credentials will be validated and encrypted before saving.',
|
||||||
|
saveBtn: 'Save Credentials',
|
||||||
|
usageTitle: 'Usage Guide',
|
||||||
|
usageSteps: '1. Fill in and save APPID and APPSECRET on this page\n2. Model services: Go to Model Management, add a model with Remote API source, select WeKnoraCloud as provider\n3. Document parsing: Go to Knowledge Base Settings → Parser Engine, select WeKnora Cloud engine for desired file types',
|
||||||
|
fillRequired: 'Please fill in APPID and APPSECRET',
|
||||||
|
saveSuccess: 'Credentials saved successfully',
|
||||||
|
saveFailed: 'Failed to save credentials',
|
||||||
|
credentialConfigured: 'WeKnoraCloud credentials configured.',
|
||||||
|
credentialExpired: 'Credentials expired. Please reconfigure.',
|
||||||
|
credentialUnconfigured: 'WeKnoraCloud credentials not configured. Please set up APPID and APPSECRET first.',
|
||||||
|
checkingStatus: 'Checking credential status...',
|
||||||
|
goToSettings: 'Go to Settings',
|
||||||
|
modelHintConfigured: 'WeKnoraCloud credentials configured. See supported models in',
|
||||||
|
modelHintDocsLink: 'API docs',
|
||||||
|
},
|
||||||
system: 'System Settings',
|
system: 'System Settings',
|
||||||
systemConfig: 'System Configuration',
|
systemConfig: 'System Configuration',
|
||||||
knowledgeBaseSettings: 'Knowledge Base Settings',
|
knowledgeBaseSettings: 'Knowledge Base Settings',
|
||||||
@@ -3167,6 +3197,10 @@ export default {
|
|||||||
name: 'MinerU Cloud',
|
name: 'MinerU Cloud',
|
||||||
desc: 'MinerU Cloud API',
|
desc: 'MinerU Cloud API',
|
||||||
},
|
},
|
||||||
|
weknoracloud: {
|
||||||
|
name: 'WeKnora Cloud',
|
||||||
|
desc: 'Document parsing via WeKnora Cloud',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
supportedFormats: 'Supported formats',
|
supportedFormats: 'Supported formats',
|
||||||
|
|||||||
@@ -441,6 +441,36 @@ export default {
|
|||||||
systemSettings: "시스템 설정",
|
systemSettings: "시스템 설정",
|
||||||
tenantInfo: "테넌트 정보",
|
tenantInfo: "테넌트 정보",
|
||||||
apiInfo: "API 정보",
|
apiInfo: "API 정보",
|
||||||
|
weknoraCloud: {
|
||||||
|
title: 'WeKnora Cloud',
|
||||||
|
description: 'WeKnora Cloud APPID 및 APPSECRET 자격 증명을 설정합니다. 자격 증명은 모델 서비스와 문서 파싱 엔진에 사용됩니다.',
|
||||||
|
viewDocs: '문서 보기',
|
||||||
|
unconfigured: '자격 증명이 설정되지 않았습니다. APPID와 APPSECRET을 입력하세요.',
|
||||||
|
configured: '자격 증명이 설정되었으며 정상 작동 중입니다.',
|
||||||
|
expired: 'WeKnora Cloud 자격 증명 만료',
|
||||||
|
expiredDefault: '서비스 재시작 후 암호화 키가 변경되어 저장된 자격 증명을 복호화할 수 없습니다. 다시 입력하세요.',
|
||||||
|
reconfigure: '재설정',
|
||||||
|
appIdLabel: 'APPID',
|
||||||
|
appIdDesc: 'WeKnora Cloud 애플리케이션 ID',
|
||||||
|
appIdPlaceholder: 'APPID 입력',
|
||||||
|
appSecretLabel: 'APPSECRET',
|
||||||
|
appSecretDesc: 'WeKnora Cloud 애플리케이션 비밀키',
|
||||||
|
appSecretPlaceholder: 'APPSECRET 입력',
|
||||||
|
saveHint: '저장 전 서비스 연결 가능 여부를 확인하고 암호화하여 저장합니다.',
|
||||||
|
saveBtn: '자격 증명 저장',
|
||||||
|
usageTitle: '사용 가이드',
|
||||||
|
usageSteps: '1. 이 페이지에서 APPID와 APPSECRET을 입력하고 저장\n2. 모델 서비스: 모델 관리에서 Remote API 소스로 모델 추가, 공급자로 WeKnoraCloud 선택\n3. 문서 파싱: 지식 베이스 설정 → 파싱 엔진에서 해당 파일 유형에 WeKnora Cloud 엔진 선택',
|
||||||
|
fillRequired: 'APPID와 APPSECRET을 입력하세요',
|
||||||
|
saveSuccess: '자격 증명 저장 완료',
|
||||||
|
saveFailed: '자격 증명 저장 실패',
|
||||||
|
credentialConfigured: 'WeKnoraCloud 자격 증명이 설정되었습니다.',
|
||||||
|
credentialExpired: '자격 증명이 만료되었습니다. 재설정하세요.',
|
||||||
|
credentialUnconfigured: 'WeKnoraCloud 자격 증명이 설정되지 않았습니다. APPID와 APPSECRET을 먼저 설정하세요.',
|
||||||
|
checkingStatus: '자격 증명 상태 확인 중...',
|
||||||
|
goToSettings: '설정으로 이동',
|
||||||
|
modelHintConfigured: 'WeKnoraCloud 자격 증명이 설정되었습니다. 지원 모델은',
|
||||||
|
modelHintDocsLink: 'API 문서',
|
||||||
|
},
|
||||||
system: "시스템 설정",
|
system: "시스템 설정",
|
||||||
systemConfig: "시스템 구성",
|
systemConfig: "시스템 구성",
|
||||||
knowledgeBaseSettings: "지식베이스 설정",
|
knowledgeBaseSettings: "지식베이스 설정",
|
||||||
@@ -3222,6 +3252,10 @@ export default {
|
|||||||
name: 'MinerU Cloud',
|
name: 'MinerU Cloud',
|
||||||
desc: 'MinerU Cloud API',
|
desc: 'MinerU Cloud API',
|
||||||
},
|
},
|
||||||
|
weknoracloud: {
|
||||||
|
name: 'WeKnora Cloud',
|
||||||
|
desc: 'WeKnora Cloud를 통한 문서 파싱',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
supportedFormats: '지원 형식',
|
supportedFormats: '지원 형식',
|
||||||
|
|||||||
@@ -560,6 +560,36 @@ export default {
|
|||||||
systemSettings: 'Настройки системы',
|
systemSettings: 'Настройки системы',
|
||||||
tenantInfo: 'Информация о арендаторе',
|
tenantInfo: 'Информация о арендаторе',
|
||||||
apiInfo: 'Информация API',
|
apiInfo: 'Информация API',
|
||||||
|
weknoraCloud: {
|
||||||
|
title: 'WeKnora Cloud',
|
||||||
|
description: 'Настройте учётные данные APPID и APPSECRET для WeKnora Cloud. Данные используются для модельных сервисов и движка парсинга документов.',
|
||||||
|
viewDocs: 'Документация',
|
||||||
|
unconfigured: 'Учётные данные не настроены. Заполните APPID и APPSECRET.',
|
||||||
|
configured: 'Учётные данные настроены, статус в норме.',
|
||||||
|
expired: 'Учётные данные WeKnora Cloud истекли',
|
||||||
|
expiredDefault: 'Ключ шифрования изменился после перезапуска. Сохранённые данные не могут быть расшифрованы. Введите данные заново.',
|
||||||
|
reconfigure: 'Перенастроить',
|
||||||
|
appIdLabel: 'APPID',
|
||||||
|
appIdDesc: 'ID приложения WeKnora Cloud',
|
||||||
|
appIdPlaceholder: 'Введите APPID',
|
||||||
|
appSecretLabel: 'APPSECRET',
|
||||||
|
appSecretDesc: 'Секрет приложения WeKnora Cloud',
|
||||||
|
appSecretPlaceholder: 'Введите APPSECRET',
|
||||||
|
saveHint: 'Данные будут проверены и зашифрованы перед сохранением.',
|
||||||
|
saveBtn: 'Сохранить',
|
||||||
|
usageTitle: 'Инструкция',
|
||||||
|
usageSteps: '1. Заполните и сохраните APPID и APPSECRET\n2. Модели: перейдите в управление моделями, добавьте модель с источником Remote API, выберите WeKnoraCloud\n3. Парсинг документов: перейдите в настройки базы знаний → движок парсинга, выберите WeKnora Cloud для нужных типов файлов',
|
||||||
|
fillRequired: 'Заполните APPID и APPSECRET',
|
||||||
|
saveSuccess: 'Учётные данные сохранены',
|
||||||
|
saveFailed: 'Не удалось сохранить данные',
|
||||||
|
credentialConfigured: 'Учётные данные WeKnoraCloud настроены.',
|
||||||
|
credentialExpired: 'Данные истекли. Перенастройте.',
|
||||||
|
credentialUnconfigured: 'Учётные данные WeKnoraCloud не настроены. Заполните APPID и APPSECRET.',
|
||||||
|
checkingStatus: 'Проверка статуса...',
|
||||||
|
goToSettings: 'Перейти в настройки',
|
||||||
|
modelHintConfigured: 'Учётные данные WeKnoraCloud настроены. Поддерживаемые модели см. в',
|
||||||
|
modelHintDocsLink: 'документации API',
|
||||||
|
},
|
||||||
system: 'Настройки системы',
|
system: 'Настройки системы',
|
||||||
systemConfig: 'Системная конфигурация',
|
systemConfig: 'Системная конфигурация',
|
||||||
knowledgeBaseSettings: 'Настройки базы знаний',
|
knowledgeBaseSettings: 'Настройки базы знаний',
|
||||||
@@ -2837,6 +2867,10 @@ export default {
|
|||||||
name: 'MinerU Cloud',
|
name: 'MinerU Cloud',
|
||||||
desc: 'MinerU Cloud API',
|
desc: 'MinerU Cloud API',
|
||||||
},
|
},
|
||||||
|
weknoracloud: {
|
||||||
|
name: 'WeKnora Cloud',
|
||||||
|
desc: 'Парсинг документов через WeKnora Cloud',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
supportedFormats: 'Поддерживаемые форматы'
|
supportedFormats: 'Поддерживаемые форматы'
|
||||||
|
|||||||
@@ -438,6 +438,36 @@ export default {
|
|||||||
systemSettings: "系统设置",
|
systemSettings: "系统设置",
|
||||||
tenantInfo: "租户信息",
|
tenantInfo: "租户信息",
|
||||||
apiInfo: "API信息",
|
apiInfo: "API信息",
|
||||||
|
weknoraCloud: {
|
||||||
|
title: "WeKnora Cloud",
|
||||||
|
description: "配置 WeKnora Cloud 的 APPID 和 APPSECRET 凭证。凭证用于模型服务和文档解析引擎。",
|
||||||
|
viewDocs: "查看文档",
|
||||||
|
unconfigured: "尚未配置凭证,请填写 APPID 和 APPSECRET",
|
||||||
|
configured: "凭证已配置,状态正常",
|
||||||
|
expired: "WeKnora Cloud 凭证已失效",
|
||||||
|
expiredDefault: "服务重启后加密密钥已变更,已保存的凭证无法解密。请重新填写凭证。",
|
||||||
|
reconfigure: "重新配置",
|
||||||
|
appIdLabel: "APPID",
|
||||||
|
appIdDesc: "WeKnora Cloud 的应用 ID",
|
||||||
|
appIdPlaceholder: "请输入 APPID",
|
||||||
|
appSecretLabel: "APPSECRET",
|
||||||
|
appSecretDesc: "WeKnora Cloud 的应用密钥",
|
||||||
|
appSecretPlaceholder: "请输入 APPSECRET",
|
||||||
|
saveHint: "保存后将验证服务可达性并加密存储凭证",
|
||||||
|
saveBtn: "保存凭证",
|
||||||
|
usageTitle: "使用说明",
|
||||||
|
usageSteps: "1. 在此页面填写并保存 APPID 和 APPSECRET\n2. 模型服务:前往「模型管理」添加模型,选择 Remote API 来源,厂商选择「WeKnoraCloud」\n3. 文档解析:前往「知识库设置 → 解析引擎」,为对应文件类型选择「WeKnora Cloud」引擎",
|
||||||
|
fillRequired: "请填写 APPID 和 APPSECRET",
|
||||||
|
saveSuccess: "凭证保存成功",
|
||||||
|
saveFailed: "凭证保存失败",
|
||||||
|
credentialConfigured: "WeKnoraCloud 凭证已配置",
|
||||||
|
credentialExpired: "凭证已失效,请重新配置。",
|
||||||
|
credentialUnconfigured: "尚未配置 WeKnoraCloud 凭证,请先填写 APPID 和 APPSECRET。",
|
||||||
|
checkingStatus: "正在检查凭证状态...",
|
||||||
|
goToSettings: "前往设置中配置",
|
||||||
|
modelHintConfigured: "WeKnoraCloud 凭证已配置。支持的模型可参考",
|
||||||
|
modelHintDocsLink: "接口文档",
|
||||||
|
},
|
||||||
system: "系统设置",
|
system: "系统设置",
|
||||||
systemConfig: "系统配置",
|
systemConfig: "系统配置",
|
||||||
knowledgeBaseSettings: "知识库设置",
|
knowledgeBaseSettings: "知识库设置",
|
||||||
@@ -3165,6 +3195,10 @@ export default {
|
|||||||
name: "MinerU Cloud",
|
name: "MinerU Cloud",
|
||||||
desc: "MinerU Cloud API",
|
desc: "MinerU Cloud API",
|
||||||
},
|
},
|
||||||
|
weknoracloud: {
|
||||||
|
name: "WeKnora Cloud",
|
||||||
|
desc: "使用 WeKnora Cloud 进行文档解析",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
supportedFormats: "支持格式",
|
supportedFormats: "支持格式",
|
||||||
|
|||||||
@@ -93,14 +93,12 @@ import { storeToRefs } from 'pinia'
|
|||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
function getEngineDisplayName(engineName: string): string {
|
function getEngineDisplayName(engineName: string): string {
|
||||||
if (engineName === 'weknoracloud') return 'WeKnora Cloud'
|
|
||||||
const key = `kbSettings.parser.engines.${engineName}.name`
|
const key = `kbSettings.parser.engines.${engineName}.name`
|
||||||
const translated = t(key)
|
const translated = t(key)
|
||||||
return translated !== key ? translated : engineName
|
return translated !== key ? translated : engineName
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEngineDisplayDesc(engineName: string, fallback: string): string {
|
function getEngineDisplayDesc(engineName: string, fallback: string): string {
|
||||||
if (engineName === 'weknoracloud') return '使用 WeKnora Cloud 进行文档解析'
|
|
||||||
const key = `kbSettings.parser.engines.${engineName}.desc`
|
const key = `kbSettings.parser.engines.${engineName}.desc`
|
||||||
const translated = t(key)
|
const translated = t(key)
|
||||||
return translated !== key ? translated : fallback
|
return translated !== key ? translated : fallback
|
||||||
|
|||||||
@@ -97,17 +97,17 @@
|
|||||||
<template v-if="engine.Name === 'weknoracloud'">
|
<template v-if="engine.Name === 'weknoracloud'">
|
||||||
<div v-if="wkcState === 'configured'" class="wkc-status wkc-status--ok">
|
<div v-if="wkcState === 'configured'" class="wkc-status wkc-status--ok">
|
||||||
<t-icon name="check-circle" style="font-size: 15px; color: var(--td-success-color); flex-shrink: 0;" />
|
<t-icon name="check-circle" style="font-size: 15px; color: var(--td-success-color); flex-shrink: 0;" />
|
||||||
<span>WeKnoraCloud 凭证已配置</span>
|
<span>{{ $t('settings.weknoraCloud.credentialConfigured') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="wkcState === 'loading'" class="wkc-status">
|
<div v-else-if="wkcState === 'loading'" class="wkc-status">
|
||||||
<t-loading size="small" />
|
<t-loading size="small" />
|
||||||
<span>检查凭证状态...</span>
|
<span>{{ $t('settings.weknoraCloud.checkingStatus') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="wkc-status wkc-status--warn">
|
<div v-else class="wkc-status wkc-status--warn">
|
||||||
<t-icon name="error-circle" style="font-size: 15px; color: #f97316; flex-shrink: 0;" />
|
<t-icon name="error-circle" style="font-size: 15px; color: #f97316; flex-shrink: 0;" />
|
||||||
<div style="flex: 1;">
|
<div style="flex: 1;">
|
||||||
<span v-if="wkcState === 'expired'">凭证已失效,请重新配置。</span>
|
<span v-if="wkcState === 'expired'">{{ $t('settings.weknoraCloud.credentialExpired') }}</span>
|
||||||
<span v-else>尚未配置凭证。</span>
|
<span v-else>{{ $t('settings.weknoraCloud.unconfigured') }}</span>
|
||||||
<div style="margin-top: 6px;">
|
<div style="margin-top: 6px;">
|
||||||
<t-button
|
<t-button
|
||||||
variant="text"
|
variant="text"
|
||||||
@@ -115,7 +115,7 @@
|
|||||||
theme="primary"
|
theme="primary"
|
||||||
@click="goToWkcSettings"
|
@click="goToWkcSettings"
|
||||||
style="padding: 0; height: auto;"
|
style="padding: 0; height: auto;"
|
||||||
>前往设置中配置</t-button>
|
>{{ $t('settings.weknoraCloud.goToSettings') }}</t-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -310,16 +310,12 @@ function engineDocLabel(_name: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getEngineDisplayName(engineName: string): string {
|
function getEngineDisplayName(engineName: string): string {
|
||||||
// WeKnoraCloud 特殊处理
|
|
||||||
if (engineName === 'weknoracloud') return 'WeKnora Cloud'
|
|
||||||
const key = `kbSettings.parser.engines.${engineName}.name`
|
const key = `kbSettings.parser.engines.${engineName}.name`
|
||||||
const translated = t(key)
|
const translated = t(key)
|
||||||
return translated !== key ? translated : engineName
|
return translated !== key ? translated : engineName
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEngineDisplayDesc(engineName: string, fallback: string): string {
|
function getEngineDisplayDesc(engineName: string, fallback: string): string {
|
||||||
// WeKnoraCloud 特殊处理
|
|
||||||
if (engineName === 'weknoracloud') return '使用 WeKnora Cloud 进行文档解析,需先在「设置 → WeKnora Cloud」中配置凭证'
|
|
||||||
const key = `kbSettings.parser.engines.${engineName}.desc`
|
const key = `kbSettings.parser.engines.${engineName}.desc`
|
||||||
const translated = t(key)
|
const translated = t(key)
|
||||||
return translated !== key ? translated : fallback
|
return translated !== key ? translated : fallback
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="weknoracloud-settings">
|
<div class="weknoracloud-settings">
|
||||||
<div class="section-header">
|
<div class="section-header">
|
||||||
<h2>WeKnora Cloud</h2>
|
<h2>{{ $t('settings.weknoraCloud.title') }}</h2>
|
||||||
<p class="section-description">
|
<p class="section-description">{{ $t('settings.weknoraCloud.description') }}</p>
|
||||||
配置 WeKnora Cloud 的 APPID 和 APPSECRET 凭证。配置完成后,可在模型管理中添加模型时选择 WeKnoraCloud 作为厂商。
|
|
||||||
</p>
|
|
||||||
<a
|
<a
|
||||||
class="doc-link"
|
class="doc-link"
|
||||||
href="https://developers.weixin.qq.com/doc/aispeech/knowledge/atomic_capability/atomic_interface.html"
|
href="https://developers.weixin.qq.com/doc/aispeech/knowledge/atomic_capability/atomic_interface.html"
|
||||||
@@ -12,30 +10,29 @@
|
|||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
<t-icon name="link" style="font-size: 14px;" />
|
<t-icon name="link" style="font-size: 14px;" />
|
||||||
查看文档
|
{{ $t('settings.weknoraCloud.viewDocs') }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 状态区域 -->
|
|
||||||
<!-- 未配置 -->
|
<!-- 未配置 -->
|
||||||
<div v-if="credentialState === 'unconfigured'" class="credential-status unconfigured">
|
<div v-if="credentialState === 'unconfigured'" class="credential-status unconfigured">
|
||||||
<t-icon name="info-circle" style="font-size: 16px; flex-shrink: 0;" />
|
<t-icon name="info-circle" style="font-size: 16px; flex-shrink: 0;" />
|
||||||
<span>尚未配置凭证,请填写 APPID 和 APPSECRET</span>
|
<span>{{ $t('settings.weknoraCloud.unconfigured') }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 凭证失效 -->
|
<!-- 凭证失效 -->
|
||||||
<div v-else-if="credentialState === 'expired'" class="credential-warning">
|
<div v-else-if="credentialState === 'expired'" class="credential-warning">
|
||||||
<t-icon name="error-circle" style="font-size: 16px; color: #f97316; flex-shrink: 0; margin-top: 1px;" />
|
<t-icon name="error-circle" style="font-size: 16px; color: #f97316; flex-shrink: 0; margin-top: 1px;" />
|
||||||
<div class="warning-text">
|
<div class="warning-text">
|
||||||
<strong>WeKnora Cloud凭证已失效</strong><br />
|
<strong>{{ $t('settings.weknoraCloud.expired') }}</strong><br />
|
||||||
{{ reinitReason || '服务重启后加密密钥已变更,已保存的凭证无法解密。请重新填写凭证。' }}
|
{{ reinitReason || $t('settings.weknoraCloud.expiredDefault') }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 已配置正常 -->
|
<!-- 已配置正常 -->
|
||||||
<div v-else-if="credentialState === 'configured'" class="credential-status success">
|
<div v-else-if="credentialState === 'configured'" class="credential-status success">
|
||||||
<t-icon name="check-circle" style="font-size: 16px; color: var(--td-success-color); flex-shrink: 0;" />
|
<t-icon name="check-circle" style="font-size: 16px; color: var(--td-success-color); flex-shrink: 0;" />
|
||||||
<span class="status-text">凭证已配置,状态正常</span>
|
<span class="status-text">{{ $t('settings.weknoraCloud.configured') }}</span>
|
||||||
<t-button
|
<t-button
|
||||||
v-if="!formExpanded"
|
v-if="!formExpanded"
|
||||||
variant="text"
|
variant="text"
|
||||||
@@ -43,21 +40,21 @@
|
|||||||
theme="primary"
|
theme="primary"
|
||||||
@click="formExpanded = true"
|
@click="formExpanded = true"
|
||||||
>
|
>
|
||||||
重新配置
|
{{ $t('settings.weknoraCloud.reconfigure') }}
|
||||||
</t-button>
|
</t-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 配置表单(折叠控制) -->
|
<!-- 配置表单 -->
|
||||||
<div v-if="formExpanded" class="settings-group">
|
<div v-if="formExpanded" class="settings-group">
|
||||||
<div class="setting-row">
|
<div class="setting-row">
|
||||||
<div class="setting-info">
|
<div class="setting-info">
|
||||||
<label class="setting-label">APPID</label>
|
<label class="setting-label">{{ $t('settings.weknoraCloud.appIdLabel') }}</label>
|
||||||
<p class="setting-desc">WeKnora Cloud的应用 ID</p>
|
<p class="setting-desc">{{ $t('settings.weknoraCloud.appIdDesc') }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-control">
|
<div class="setting-control">
|
||||||
<t-input
|
<t-input
|
||||||
v-model="form.appId"
|
v-model="form.appId"
|
||||||
placeholder="请输入 APPID"
|
:placeholder="$t('settings.weknoraCloud.appIdPlaceholder')"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
style="width: 280px;"
|
style="width: 280px;"
|
||||||
/>
|
/>
|
||||||
@@ -66,14 +63,14 @@
|
|||||||
|
|
||||||
<div class="setting-row">
|
<div class="setting-row">
|
||||||
<div class="setting-info">
|
<div class="setting-info">
|
||||||
<label class="setting-label">APPSECRET</label>
|
<label class="setting-label">{{ $t('settings.weknoraCloud.appSecretLabel') }}</label>
|
||||||
<p class="setting-desc">WeKnora Cloud的应用密钥</p>
|
<p class="setting-desc">{{ $t('settings.weknoraCloud.appSecretDesc') }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-control">
|
<div class="setting-control">
|
||||||
<t-input
|
<t-input
|
||||||
v-model="form.appSecret"
|
v-model="form.appSecret"
|
||||||
type="password"
|
type="password"
|
||||||
placeholder="请输入 APPSECRET"
|
:placeholder="$t('settings.weknoraCloud.appSecretPlaceholder')"
|
||||||
autocomplete="new-password"
|
autocomplete="new-password"
|
||||||
style="width: 280px;"
|
style="width: 280px;"
|
||||||
/>
|
/>
|
||||||
@@ -82,7 +79,7 @@
|
|||||||
|
|
||||||
<div class="setting-row action-row">
|
<div class="setting-row action-row">
|
||||||
<div class="setting-info">
|
<div class="setting-info">
|
||||||
<p class="setting-desc">保存后将验证服务可达性并加密存储凭证</p>
|
<p class="setting-desc">{{ $t('settings.weknoraCloud.saveHint') }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-control">
|
<div class="setting-control">
|
||||||
<t-button
|
<t-button
|
||||||
@@ -91,7 +88,7 @@
|
|||||||
:disabled="!form.appId || !form.appSecret"
|
:disabled="!form.appId || !form.appSecret"
|
||||||
@click="handleSave"
|
@click="handleSave"
|
||||||
>
|
>
|
||||||
保存凭证
|
{{ $t('settings.weknoraCloud.saveBtn') }}
|
||||||
</t-button>
|
</t-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -99,13 +96,8 @@
|
|||||||
|
|
||||||
<!-- 使用说明 -->
|
<!-- 使用说明 -->
|
||||||
<div class="usage-hint">
|
<div class="usage-hint">
|
||||||
<p class="hint-title">使用说明</p>
|
<p class="hint-title">{{ $t('settings.weknoraCloud.usageTitle') }}</p>
|
||||||
<p class="hint-text">
|
<p class="hint-text" v-html="$t('settings.weknoraCloud.usageSteps').replace(/\n/g, '<br />')" />
|
||||||
1. 在此页面填写并保存 APPID 和 APPSECRET<br />
|
|
||||||
2. 前往「模型管理」添加模型,选择 Remote API 来源<br />
|
|
||||||
3. 在厂商下拉中选择「WeKnoraCloud」<br />
|
|
||||||
4. 填写模型名称后保存即可(Base URL 和认证信息会自动配置)
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -113,8 +105,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, computed, onMounted } from 'vue'
|
||||||
import { MessagePlugin } from 'tdesign-vue-next'
|
import { MessagePlugin } from 'tdesign-vue-next'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
import { saveWeKnoraCloudCredentials, getWeKnoraCloudStatus } from '@/api/model'
|
import { saveWeKnoraCloudCredentials, getWeKnoraCloudStatus } from '@/api/model'
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
const form = ref({ appId: '', appSecret: '' })
|
const form = ref({ appId: '', appSecret: '' })
|
||||||
const saving = ref(false)
|
const saving = ref(false)
|
||||||
const needsReinit = ref(false)
|
const needsReinit = ref(false)
|
||||||
@@ -122,7 +117,6 @@ const reinitReason = ref('')
|
|||||||
const hasCredentials = ref(false)
|
const hasCredentials = ref(false)
|
||||||
const formExpanded = ref(true)
|
const formExpanded = ref(true)
|
||||||
|
|
||||||
// 三态:unconfigured / configured / expired
|
|
||||||
const credentialState = computed(() => {
|
const credentialState = computed(() => {
|
||||||
if (needsReinit.value) return 'expired'
|
if (needsReinit.value) return 'expired'
|
||||||
if (hasCredentials.value) return 'configured'
|
if (hasCredentials.value) return 'configured'
|
||||||
@@ -131,7 +125,7 @@ const credentialState = computed(() => {
|
|||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!form.value.appId || !form.value.appSecret) {
|
if (!form.value.appId || !form.value.appSecret) {
|
||||||
MessagePlugin.warning('请填写 APPID 和 APPSECRET')
|
MessagePlugin.warning(t('settings.weknoraCloud.fillRequired'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
saving.value = true
|
saving.value = true
|
||||||
@@ -140,7 +134,7 @@ const handleSave = async () => {
|
|||||||
app_id: form.value.appId,
|
app_id: form.value.appId,
|
||||||
app_secret: form.value.appSecret,
|
app_secret: form.value.appSecret,
|
||||||
})
|
})
|
||||||
MessagePlugin.success('凭证保存成功')
|
MessagePlugin.success(t('settings.weknoraCloud.saveSuccess'))
|
||||||
form.value.appId = ''
|
form.value.appId = ''
|
||||||
form.value.appSecret = ''
|
form.value.appSecret = ''
|
||||||
needsReinit.value = false
|
needsReinit.value = false
|
||||||
@@ -148,7 +142,7 @@ const handleSave = async () => {
|
|||||||
hasCredentials.value = true
|
hasCredentials.value = true
|
||||||
formExpanded.value = false
|
formExpanded.value = false
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
MessagePlugin.error(err?.message || '凭证保存失败')
|
MessagePlugin.error(err?.message || t('settings.weknoraCloud.saveFailed'))
|
||||||
} finally {
|
} finally {
|
||||||
saving.value = false
|
saving.value = false
|
||||||
}
|
}
|
||||||
@@ -160,12 +154,11 @@ const checkStatus = async () => {
|
|||||||
needsReinit.value = status.needs_reinit
|
needsReinit.value = status.needs_reinit
|
||||||
reinitReason.value = status.reason || ''
|
reinitReason.value = status.reason || ''
|
||||||
hasCredentials.value = status.has_models && !status.needs_reinit
|
hasCredentials.value = status.has_models && !status.needs_reinit
|
||||||
// 已配置且未失效时默认收起表单
|
|
||||||
if (hasCredentials.value) {
|
if (hasCredentials.value) {
|
||||||
formExpanded.value = false
|
formExpanded.value = false
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// 静默失败
|
// silent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user