feat: introduce WeKnora Lite edition with lightweight configuration and deployment

- Added a new `.env.lite.example` file for the Lite version, providing a minimal configuration template.
- Updated `.env.example` to remove deprecated variables and include new Docreader settings.
- Enhanced Docker configurations to support the Lite version, including a new Dockerfile for the Docreader service.
- Introduced a Makefile target for building and running the Lite version, along with packaging capabilities.
- Created GitHub workflows for building and releasing Lite binaries, including Homebrew formula support.
- Implemented a new service file for managing the Lite version as a system service.

This update enables a streamlined, single-binary deployment of WeKnora, reducing external dependencies and simplifying setup.
This commit is contained in:
wizardchen
2026-02-28 13:22:07 +08:00
committed by lyingbug
parent 5241dbc39e
commit 397689d2f3
140 changed files with 13365 additions and 5413 deletions
+3 -14
View File
@@ -82,24 +82,13 @@ export interface KBModelConfigRequest {
chunkSize: number
chunkOverlap: number
separators: string[]
parserEngineRules?: { file_types: string[]; engine: string }[]
}
multimodal: {
enabled: boolean
storageType?: 'cos' | 'minio'
cos?: {
secretId: string
secretKey: string
region: string
bucketName: string
appId: string
pathPrefix: string
}
minio?: {
bucketName: string
useSSL: boolean
pathPrefix: string
}
}
/** 存储引擎选择:"local" | "minio" | "cos",影响文档上传与文档内图片存储 */
storageProvider?: string
nodeExtract: {
enabled: boolean
text: string
+4
View File
@@ -106,6 +106,10 @@ export function downKnowledgeDetails(id: string) {
return getDown(`/api/v1/knowledge/${id}/download`);
}
export function previewKnowledgeFile(id: string) {
return getDown(`/api/v1/knowledge/${id}/preview`);
}
/** @param idsQueryString - query string with ids (e.g. ids=xxx&ids=yyy) */
export function batchQueryKnowledge(idsQueryString: string, kbId?: string, agentId?: string) {
let qs = idsQueryString;
+114 -1
View File
@@ -1,7 +1,8 @@
import { get, put } from '@/utils/request'
import { get, post, put } from '@/utils/request'
export interface SystemInfo {
version: string
edition?: string
commit_id?: string
build_time?: string
go_version?: string
@@ -110,3 +111,115 @@ export interface ListMinioBucketsResponse {
export function listMinioBuckets(): Promise<{ data: ListMinioBucketsResponse }> {
return get('/api/v1/system/minio/buckets')
}
export interface ParserEngineInfo {
Name: string
Description: string
FileTypes: string[]
Available?: boolean
UnavailableReason?: string
}
/** 解析引擎配置(引擎相关存租户;docreader 地址由环境变量配置) */
export interface ParserEngineConfig {
docreader_addr?: string
docreader_transport?: string
mineru_endpoint?: string
mineru_api_key?: string
mineru_api_base_url?: string
// MinerU 自建参数
mineru_model?: string
mineru_enable_formula?: boolean | null
mineru_enable_table?: boolean | null
mineru_enable_ocr?: boolean | null
mineru_language?: string
// MinerU 云 API 参数
mineru_cloud_model?: string
mineru_cloud_enable_formula?: boolean | null
mineru_cloud_enable_table?: boolean | null
mineru_cloud_enable_ocr?: boolean | null
mineru_cloud_language?: string
}
export interface ParserEnginesResponse {
data: ParserEngineInfo[]
docreader_addr?: string
/** 连接方式:grpc | http,由服务端环境/配置决定 */
docreader_transport?: string
connected?: boolean
}
export function getParserEngines(): Promise<ParserEnginesResponse> {
return get('/api/v1/system/parser-engines')
}
/** 使用当前填写的参数检测引擎可用性(不保存),用于填写新参数后即时测试 */
export function checkParserEngines(config: ParserEngineConfig): Promise<ParserEnginesResponse> {
return post('/api/v1/system/parser-engines/check', config)
}
export function getParserEngineConfig(): Promise<{ data: ParserEngineConfig }> {
return get('/api/v1/tenants/kv/parser-engine-config')
}
export function updateParserEngineConfig(config: ParserEngineConfig): Promise<{ data: ParserEngineConfig }> {
return put('/api/v1/tenants/kv/parser-engine-config', config)
}
export function reconnectDocReader(addr: string): Promise<ParserEnginesResponse & { msg?: string }> {
return post('/api/v1/system/docreader/reconnect', { addr })
}
// ---- 存储引擎配置(租户级,供文档/图片存储与 docreader 使用) ----
export interface StorageEngineConfig {
default_provider: string // "local" | "minio" | "cos"
local?: { path_prefix: string }
minio?: { mode: string; endpoint: string; access_key_id: string; secret_access_key: string; bucket_name: string; use_ssl: boolean; path_prefix: string }
cos?: {
secret_id: string
secret_key: string
region: string
bucket_name: string
app_id: string
path_prefix: string
}
}
export interface StorageEngineStatusItem {
name: string
available: boolean
description: string
}
export interface GetStorageEngineStatusResponse {
engines: StorageEngineStatusItem[]
minio_env_available: boolean
}
export function getStorageEngineConfig(): Promise<{ data: StorageEngineConfig }> {
return get('/api/v1/tenants/kv/storage-engine-config')
}
export function updateStorageEngineConfig(config: StorageEngineConfig): Promise<{ data: StorageEngineConfig }> {
return put('/api/v1/tenants/kv/storage-engine-config', config)
}
export function getStorageEngineStatus(): Promise<{ data: GetStorageEngineStatusResponse }> {
return get('/api/v1/system/storage-engine-status')
}
export interface StorageCheckRequest {
provider: string // "minio" | "cos"
minio?: StorageEngineConfig['minio']
cos?: StorageEngineConfig['cos']
}
export interface StorageCheckResponse {
ok: boolean
message: string
}
export function checkStorageEngine(req: StorageCheckRequest): Promise<{ data: StorageCheckResponse }> {
return post('/api/v1/system/storage-engine-check', req)
}
+3 -3
View File
@@ -1,5 +1,5 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z" fill="#000000" fill-opacity=".9" stroke="#000000" stroke-opacity=".9" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M15.5 4L15.8 5.2C15.85 5.45 16.05 5.65 16.3 5.7L17.5 6L16.3 6.3C16.05 6.35 15.85 6.55 15.8 6.8L15.5 8L15.2 6.8C15.15 6.55 14.95 6.35 14.7 6.3L13.5 6L14.7 5.7C14.95 5.65 15.15 5.45 15.2 5.2L15.5 4Z" fill="#000000" fill-opacity=".9" stroke="#000000" stroke-opacity=".9" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M4.5 13L4.8 14.2C4.85 14.45 5.05 14.65 5.3 14.7L6.5 15L5.3 15.3C5.05 15.35 4.85 15.55 4.8 15.8L4.5 17L4.2 15.8C4.15 15.55 3.95 15.35 3.7 15.3L2.5 15L3.7 14.7C3.95 14.65 4.15 14.45 4.2 14.2L4.5 13Z" fill="#000000" fill-opacity=".9" stroke="#000000" stroke-opacity=".9" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z" fill="#000000" fill-opacity=".6" stroke="#000000" stroke-opacity=".6" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M15.5 4L15.8 5.2C15.85 5.45 16.05 5.65 16.3 5.7L17.5 6L16.3 6.3C16.05 6.35 15.85 6.55 15.8 6.8L15.5 8L15.2 6.8C15.15 6.55 14.95 6.35 14.7 6.3L13.5 6L14.7 5.7C14.95 5.65 15.15 5.45 15.2 5.2L15.5 4Z" fill="#000000" fill-opacity=".6" stroke="#000000" stroke-opacity=".6" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M4.5 13L4.8 14.2C4.85 14.45 5.05 14.65 5.3 14.7L6.5 15L5.3 15.3C5.05 15.35 4.85 15.55 4.8 15.8L4.5 17L4.2 15.8C4.15 15.55 3.95 15.35 3.7 15.3L2.5 15L3.7 14.7C3.95 14.65 4.15 14.45 4.2 14.2L4.5 13Z" fill="#000000" fill-opacity=".6" stroke="#000000" stroke-opacity=".6" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -1,3 +1,3 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 10C8.8 7.5 7.8 3.8 4.8 3.8C2.2 3.8 0.8 6.8 0.8 10C0.8 13.2 2.2 16.2 4.8 16.2C7.8 16.2 8.8 12.5 10 10C11.2 7.5 12.5 5.5 14.5 5.5C16.5 5.5 18 7.5 18 10C18 12.5 16.5 14.5 14.5 14.5C12.5 14.5 11.2 12.5 10 10Z" stroke="#8A8A8A" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
<path d="M10 10C8.8 7.5 7.8 3.8 4.8 3.8C2.2 3.8 0.8 6.8 0.8 10C0.8 13.2 2.2 16.2 4.8 16.2C7.8 16.2 8.8 12.5 10 10C11.2 7.5 12.5 5.5 14.5 5.5C16.5 5.5 18 7.5 18 10C18 12.5 16.5 14.5 14.5 14.5C12.5 14.5 11.2 12.5 10 10Z" stroke="#000000" stroke-opacity=".4" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
</svg>

Before

Width:  |  Height:  |  Size: 421 B

After

Width:  |  Height:  |  Size: 441 B

+1 -1
View File
@@ -1,3 +1,3 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 10C8.8 7.5 7.8 3.8 4.8 3.8C2.2 3.8 0.8 6.8 0.8 10C0.8 13.2 2.2 16.2 4.8 16.2C7.8 16.2 8.8 12.5 10 10C11.2 7.5 12.5 5.5 14.5 5.5C16.5 5.5 18 7.5 18 10C18 12.5 16.5 14.5 14.5 14.5C12.5 14.5 11.2 12.5 10 10Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
<path d="M10 10C8.8 7.5 7.8 3.8 4.8 3.8C2.2 3.8 0.8 6.8 0.8 10C0.8 13.2 2.2 16.2 4.8 16.2C7.8 16.2 8.8 12.5 10 10C11.2 7.5 12.5 5.5 14.5 5.5C16.5 5.5 18 7.5 18 10C18 12.5 16.5 14.5 14.5 14.5C12.5 14.5 11.2 12.5 10 10Z" stroke="#000000" stroke-opacity=".6" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
</svg>

Before

Width:  |  Height:  |  Size: 426 B

After

Width:  |  Height:  |  Size: 441 B

+1 -1
View File
@@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" class="45o4l8wsy__design-iconfont" width="128" height="128">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" width="20" height="20">
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.875 2.5C1.875 2.15483 2.15482 1.875 2.5 1.875H17.5C17.8451 1.875 18.125 2.15483 18.125 2.5V13.75C18.125 14.0951 17.8451 14.375 17.5 14.375H9.04274L6.10514 17.9001C5.93669 18.1023 5.65965 18.1773 5.41224 18.0876C5.16481 17.9981 5 17.7631 5 17.5V14.375H2.5C2.15482 14.375 1.875 14.0951 1.875 13.75V2.5ZM3.125 3.125V13.125H5.625C5.97017 13.125 6.25 13.4049 6.25 13.75V15.7738L8.26986 13.3499C8.38861 13.2074 8.56451 13.125 8.75 13.125H16.875V3.125H3.125Z" fill="#07C05F" fill-opacity=".9"></path>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.375 5H10.625V8.44961L13.5154 10.762L12.7346 11.738L9.375 9.05039V5Z" fill="#07C05F" fill-opacity=".9"></path>
</svg>

Before

Width:  |  Height:  |  Size: 851 B

After

Width:  |  Height:  |  Size: 814 B

+1 -1
View File
@@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" class="45o4l8wsy__design-iconfont" width="128" height="128">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" width="20" height="20">
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.875 2.5C1.875 2.15483 2.15482 1.875 2.5 1.875H17.5C17.8451 1.875 18.125 2.15483 18.125 2.5V13.75C18.125 14.0951 17.8451 14.375 17.5 14.375H9.04274L6.10514 17.9001C5.93669 18.1023 5.65965 18.1773 5.41224 18.0876C5.16481 17.9981 5 17.7631 5 17.5V14.375H2.5C2.15482 14.375 1.875 14.0951 1.875 13.75V2.5ZM3.125 3.125V13.125H5.625C5.97017 13.125 6.25 13.4049 6.25 13.75V15.7738L8.26986 13.3499C8.38861 13.2074 8.56451 13.125 8.75 13.125H16.875V3.125H3.125Z" fill="#737373" fill-opacity=".9"></path>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.375 5H10.625V8.44961L13.5154 10.762L12.7346 11.738L9.375 9.05039V5Z" fill="#737373" fill-opacity=".9"></path>
</svg>

Before

Width:  |  Height:  |  Size: 851 B

After

Width:  |  Height:  |  Size: 814 B

+3 -3
View File
@@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" class="45o4l8wsy__design-iconfont" width="128" height="128">
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.875 2.5C1.875 2.15483 2.15482 1.875 2.5 1.875H17.5C17.8451 1.875 18.125 2.15483 18.125 2.5V13.75C18.125 14.0951 17.8451 14.375 17.5 14.375H9.04274L6.10514 17.9001C5.93669 18.1023 5.65965 18.1773 5.41224 18.0876C5.16481 17.9981 5 17.7631 5 17.5V14.375H2.5C2.15482 14.375 1.875 14.0951 1.875 13.75V2.5ZM3.125 3.125V13.125H5.625C5.97017 13.125 6.25 13.4049 6.25 13.75V15.7738L8.26986 13.3499C8.38861 13.2074 8.56451 13.125 8.75 13.125H16.875V3.125H3.125Z" fill="#000000" fill-opacity=".9"></path>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.375 5H10.625V8.44961L13.5154 10.762L12.7346 11.738L9.375 9.05039V5Z" fill="#000000" fill-opacity=".9"></path>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" width="20" height="20">
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.875 2.5C1.875 2.15483 2.15482 1.875 2.5 1.875H17.5C17.8451 1.875 18.125 2.15483 18.125 2.5V13.75C18.125 14.0951 17.8451 14.375 17.5 14.375H9.04274L6.10514 17.9001C5.93669 18.1023 5.65965 18.1773 5.41224 18.0876C5.16481 17.9981 5 17.7631 5 17.5V14.375H2.5C2.15482 14.375 1.875 14.0951 1.875 13.75V2.5ZM3.125 3.125V13.125H5.625C5.97017 13.125 6.25 13.4049 6.25 13.75V15.7738L8.26986 13.3499C8.38861 13.2074 8.56451 13.125 8.75 13.125H16.875V3.125H3.125Z" fill="#000000" fill-opacity=".6"></path>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.375 5H10.625V8.44961L13.5154 10.762L12.7346 11.738L9.375 9.05039V5Z" fill="#000000" fill-opacity=".6"></path>
</svg>

Before

Width:  |  Height:  |  Size: 851 B

After

Width:  |  Height:  |  Size: 814 B

+2 -2
View File
@@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" class="cvw0hqhj9__design-iconfont" width="128" height="128">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.17736 1.28207C9.32257 1.23367 9.4805 1.24024 9.6212 1.30054L18.3713 5.05054C18.5619 5.13222 18.6995 5.30316 18.7388 5.50681C18.778 5.71045 18.7136 5.9203 18.567 6.06694C18.5138 6.12012 18.4366 6.24314 18.3744 6.46076C18.3146 6.66994 18.2812 6.92361 18.2812 7.1875C18.2812 7.45139 18.3146 7.70506 18.3744 7.91424C18.4366 8.13186 18.5138 8.25487 18.567 8.30806C18.811 8.55214 18.811 8.94786 18.567 9.19194C18.5138 9.24512 18.4366 9.36814 18.3744 9.58576C18.3146 9.79494 18.2812 10.0486 18.2812 10.3125C18.2812 10.5764 18.3146 10.8301 18.3744 11.0392C18.4366 11.2569 18.5138 11.3799 18.567 11.4331C18.811 11.6771 18.811 12.0729 18.567 12.3169C18.5138 12.3701 18.4366 12.4931 18.3744 12.7108C18.3146 12.92 18.2812 13.1736 18.2812 13.4375C18.2812 13.7014 18.3146 13.955 18.3744 14.1642C18.4366 14.3819 18.5138 14.5049 18.567 14.558C18.709 14.7001 18.7741 14.9017 18.7419 15.1001C18.7097 15.2984 18.5843 15.4691 18.4045 15.559L12.1545 18.684C11.9886 18.767 11.7944 18.772 11.6245 18.6976L1.62449 14.3226C1.397 14.2231 1.25 13.9983 1.25 13.75V4.375C1.25 4.10599 1.42215 3.86715 1.67736 3.78207L9.17736 1.28207ZM2.5 5.33064L10.9868 9.04362C10.9627 9.10997 10.9413 9.1765 10.9225 9.24236C10.826 9.58006 10.7812 9.95139 10.7812 10.3125C10.7812 10.6736 10.826 11.0449 10.9225 11.3826C10.9694 11.5469 11.0321 11.7153 11.1153 11.875C11.0321 12.0347 10.9694 12.2031 10.9225 12.3674C10.826 12.705 10.7812 13.0764 10.7812 13.4375C10.7812 13.7986 10.826 14.17 10.9225 14.5076C10.9694 14.6719 11.0321 14.8403 11.1153 15C11.0321 15.1597 10.9694 15.3281 10.9225 15.4924C10.826 15.83 10.7812 16.2014 10.7812 16.5625C10.7812 16.6986 10.7876 16.8361 10.8007 16.9728L2.5 13.3413V5.33064ZM12.1275 17.3C12.1265 17.2964 12.1254 17.2929 12.1244 17.2892C12.0646 17.08 12.0312 16.8264 12.0312 16.5625C12.0312 16.2986 12.0646 16.045 12.1244 15.8358C12.1695 15.6779 12.2225 15.5697 12.2686 15.502L17.0432 13.1146C17.0351 13.2224 17.0312 13.3304 17.0312 13.4375C17.0312 13.7986 17.076 14.17 17.1725 14.5076C17.1944 14.5844 17.2198 14.662 17.249 14.7393L12.1275 17.3ZM17.249 11.6142L12.1275 14.175C12.1265 14.1714 12.1254 14.1679 12.1244 14.1642C12.0646 13.955 12.0312 13.7014 12.0312 13.4375C12.0312 13.1736 12.0646 12.92 12.1244 12.7108C12.1695 12.5529 12.2225 12.4447 12.2686 12.377L17.0432 9.98965C17.0351 10.0974 17.0312 10.2054 17.0312 10.3125C17.0312 10.6736 17.076 11.0449 17.1725 11.3826C17.1944 11.4594 17.2198 11.537 17.249 11.6142ZM17.249 8.48921L12.1275 11.05C12.1265 11.0464 12.1254 11.0428 12.1244 11.0392C12.0646 10.8301 12.0312 10.5764 12.0312 10.3125C12.0312 10.0486 12.0646 9.79494 12.1244 9.58576C12.1695 9.42785 12.2225 9.31975 12.2686 9.252L17.0432 6.86465C17.0351 6.9724 17.0312 7.0804 17.0312 7.1875C17.0312 7.54861 17.076 7.91994 17.1725 8.25764C17.1944 8.33437 17.2198 8.412 17.249 8.48921ZM16.6402 5.66864L9.34721 2.54307L3.61469 4.45391L11.8573 8.06006L16.6402 5.66864Z" fill="#07C05F"></path>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" width="20" height="20">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.17736 1.28207C9.32257 1.23367 9.4805 1.24024 9.6212 1.30054L18.3713 5.05054C18.5619 5.13222 18.6995 5.30316 18.7388 5.50681C18.778 5.71045 18.7136 5.9203 18.567 6.06694C18.5138 6.12012 18.4366 6.24314 18.3744 6.46076C18.3146 6.66994 18.2812 6.92361 18.2812 7.1875C18.2812 7.45139 18.3146 7.70506 18.3744 7.91424C18.4366 8.13186 18.5138 8.25487 18.567 8.30806C18.811 8.55214 18.811 8.94786 18.567 9.19194C18.5138 9.24512 18.4366 9.36814 18.3744 9.58576C18.3146 9.79494 18.2812 10.0486 18.2812 10.3125C18.2812 10.5764 18.3146 10.8301 18.3744 11.0392C18.4366 11.2569 18.5138 11.3799 18.567 11.4331C18.811 11.6771 18.811 12.0729 18.567 12.3169C18.5138 12.3701 18.4366 12.4931 18.3744 12.7108C18.3146 12.92 18.2812 13.1736 18.2812 13.4375C18.2812 13.7014 18.3146 13.955 18.3744 14.1642C18.4366 14.3819 18.5138 14.5049 18.567 14.558C18.709 14.7001 18.7741 14.9017 18.7419 15.1001C18.7097 15.2984 18.5843 15.4691 18.4045 15.559L12.1545 18.684C11.9886 18.767 11.7944 18.772 11.6245 18.6976L1.62449 14.3226C1.397 14.2231 1.25 13.9983 1.25 13.75V4.375C1.25 4.10599 1.42215 3.86715 1.67736 3.78207L9.17736 1.28207ZM2.5 5.33064L10.9868 9.04362C10.9627 9.10997 10.9413 9.1765 10.9225 9.24236C10.826 9.58006 10.7812 9.95139 10.7812 10.3125C10.7812 10.6736 10.826 11.0449 10.9225 11.3826C10.9694 11.5469 11.0321 11.7153 11.1153 11.875C11.0321 12.0347 10.9694 12.2031 10.9225 12.3674C10.826 12.705 10.7812 13.0764 10.7812 13.4375C10.7812 13.7986 10.826 14.17 10.9225 14.5076C10.9694 14.6719 11.0321 14.8403 11.1153 15C11.0321 15.1597 10.9694 15.3281 10.9225 15.4924C10.826 15.83 10.7812 16.2014 10.7812 16.5625C10.7812 16.6986 10.7876 16.8361 10.8007 16.9728L2.5 13.3413V5.33064ZM12.1275 17.3C12.1265 17.2964 12.1254 17.2929 12.1244 17.2892C12.0646 17.08 12.0312 16.8264 12.0312 16.5625C12.0312 16.2986 12.0646 16.045 12.1244 15.8358C12.1695 15.6779 12.2225 15.5697 12.2686 15.502L17.0432 13.1146C17.0351 13.2224 17.0312 13.3304 17.0312 13.4375C17.0312 13.7986 17.076 14.17 17.1725 14.5076C17.1944 14.5844 17.2198 14.662 17.249 14.7393L12.1275 17.3ZM17.249 11.6142L12.1275 14.175C12.1265 14.1714 12.1254 14.1679 12.1244 14.1642C12.0646 13.955 12.0312 13.7014 12.0312 13.4375C12.0312 13.1736 12.0646 12.92 12.1244 12.7108C12.1695 12.5529 12.2225 12.4447 12.2686 12.377L17.0432 9.98965C17.0351 10.0974 17.0312 10.2054 17.0312 10.3125C17.0312 10.6736 17.076 11.0449 17.1725 11.3826C17.1944 11.4594 17.2198 11.537 17.249 11.6142ZM17.249 8.48921L12.1275 11.05C12.1265 11.0464 12.1254 11.0428 12.1244 11.0392C12.0646 10.8301 12.0312 10.5764 12.0312 10.3125C12.0312 10.0486 12.0646 9.79494 12.1244 9.58576C12.1695 9.42785 12.2225 9.31975 12.2686 9.252L17.0432 6.86465C17.0351 6.9724 17.0312 7.0804 17.0312 7.1875C17.0312 7.54861 17.076 7.91994 17.1725 8.25764C17.1944 8.33437 17.2198 8.412 17.249 8.48921ZM16.6402 5.66864L9.34721 2.54307L3.61469 4.45391L11.8573 8.06006L16.6402 5.66864Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.3"/>
</svg>

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

+2 -2
View File
@@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" class="cvw0hqhj9__design-iconfont" width="128" height="128">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.17736 1.28207C9.32257 1.23367 9.4805 1.24024 9.6212 1.30054L18.3713 5.05054C18.5619 5.13222 18.6995 5.30316 18.7388 5.50681C18.778 5.71045 18.7136 5.9203 18.567 6.06694C18.5138 6.12012 18.4366 6.24314 18.3744 6.46076C18.3146 6.66994 18.2812 6.92361 18.2812 7.1875C18.2812 7.45139 18.3146 7.70506 18.3744 7.91424C18.4366 8.13186 18.5138 8.25487 18.567 8.30806C18.811 8.55214 18.811 8.94786 18.567 9.19194C18.5138 9.24512 18.4366 9.36814 18.3744 9.58576C18.3146 9.79494 18.2812 10.0486 18.2812 10.3125C18.2812 10.5764 18.3146 10.8301 18.3744 11.0392C18.4366 11.2569 18.5138 11.3799 18.567 11.4331C18.811 11.6771 18.811 12.0729 18.567 12.3169C18.5138 12.3701 18.4366 12.4931 18.3744 12.7108C18.3146 12.92 18.2812 13.1736 18.2812 13.4375C18.2812 13.7014 18.3146 13.955 18.3744 14.1642C18.4366 14.3819 18.5138 14.5049 18.567 14.558C18.709 14.7001 18.7741 14.9017 18.7419 15.1001C18.7097 15.2984 18.5843 15.4691 18.4045 15.559L12.1545 18.684C11.9886 18.767 11.7944 18.772 11.6245 18.6976L1.62449 14.3226C1.397 14.2231 1.25 13.9983 1.25 13.75V4.375C1.25 4.10599 1.42215 3.86715 1.67736 3.78207L9.17736 1.28207ZM2.5 5.33064L10.9868 9.04362C10.9627 9.10997 10.9413 9.1765 10.9225 9.24236C10.826 9.58006 10.7812 9.95139 10.7812 10.3125C10.7812 10.6736 10.826 11.0449 10.9225 11.3826C10.9694 11.5469 11.0321 11.7153 11.1153 11.875C11.0321 12.0347 10.9694 12.2031 10.9225 12.3674C10.826 12.705 10.7812 13.0764 10.7812 13.4375C10.7812 13.7986 10.826 14.17 10.9225 14.5076C10.9694 14.6719 11.0321 14.8403 11.1153 15C11.0321 15.1597 10.9694 15.3281 10.9225 15.4924C10.826 15.83 10.7812 16.2014 10.7812 16.5625C10.7812 16.6986 10.7876 16.8361 10.8007 16.9728L2.5 13.3413V5.33064ZM12.1275 17.3C12.1265 17.2964 12.1254 17.2929 12.1244 17.2892C12.0646 17.08 12.0312 16.8264 12.0312 16.5625C12.0312 16.2986 12.0646 16.045 12.1244 15.8358C12.1695 15.6779 12.2225 15.5697 12.2686 15.502L17.0432 13.1146C17.0351 13.2224 17.0312 13.3304 17.0312 13.4375C17.0312 13.7986 17.076 14.17 17.1725 14.5076C17.1944 14.5844 17.2198 14.662 17.249 14.7393L12.1275 17.3ZM17.249 11.6142L12.1275 14.175C12.1265 14.1714 12.1254 14.1679 12.1244 14.1642C12.0646 13.955 12.0312 13.7014 12.0312 13.4375C12.0312 13.1736 12.0646 12.92 12.1244 12.7108C12.1695 12.5529 12.2225 12.4447 12.2686 12.377L17.0432 9.98965C17.0351 10.0974 17.0312 10.2054 17.0312 10.3125C17.0312 10.6736 17.076 11.0449 17.1725 11.3826C17.1944 11.4594 17.2198 11.537 17.249 11.6142ZM17.249 8.48921L12.1275 11.05C12.1265 11.0464 12.1254 11.0428 12.1244 11.0392C12.0646 10.8301 12.0312 10.5764 12.0312 10.3125C12.0312 10.0486 12.0646 9.79494 12.1244 9.58576C12.1695 9.42785 12.2225 9.31975 12.2686 9.252L17.0432 6.86465C17.0351 6.9724 17.0312 7.0804 17.0312 7.1875C17.0312 7.54861 17.076 7.91994 17.1725 8.25764C17.1944 8.33437 17.2198 8.412 17.249 8.48921ZM16.6402 5.66864L9.34721 2.54307L3.61469 4.45391L11.8573 8.06006L16.6402 5.66864Z" fill="#717171"></path>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" width="20" height="20">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.17736 1.28207C9.32257 1.23367 9.4805 1.24024 9.6212 1.30054L18.3713 5.05054C18.5619 5.13222 18.6995 5.30316 18.7388 5.50681C18.778 5.71045 18.7136 5.9203 18.567 6.06694C18.5138 6.12012 18.4366 6.24314 18.3744 6.46076C18.3146 6.66994 18.2812 6.92361 18.2812 7.1875C18.2812 7.45139 18.3146 7.70506 18.3744 7.91424C18.4366 8.13186 18.5138 8.25487 18.567 8.30806C18.811 8.55214 18.811 8.94786 18.567 9.19194C18.5138 9.24512 18.4366 9.36814 18.3744 9.58576C18.3146 9.79494 18.2812 10.0486 18.2812 10.3125C18.2812 10.5764 18.3146 10.8301 18.3744 11.0392C18.4366 11.2569 18.5138 11.3799 18.567 11.4331C18.811 11.6771 18.811 12.0729 18.567 12.3169C18.5138 12.3701 18.4366 12.4931 18.3744 12.7108C18.3146 12.92 18.2812 13.1736 18.2812 13.4375C18.2812 13.7014 18.3146 13.955 18.3744 14.1642C18.4366 14.3819 18.5138 14.5049 18.567 14.558C18.709 14.7001 18.7741 14.9017 18.7419 15.1001C18.7097 15.2984 18.5843 15.4691 18.4045 15.559L12.1545 18.684C11.9886 18.767 11.7944 18.772 11.6245 18.6976L1.62449 14.3226C1.397 14.2231 1.25 13.9983 1.25 13.75V4.375C1.25 4.10599 1.42215 3.86715 1.67736 3.78207L9.17736 1.28207ZM2.5 5.33064L10.9868 9.04362C10.9627 9.10997 10.9413 9.1765 10.9225 9.24236C10.826 9.58006 10.7812 9.95139 10.7812 10.3125C10.7812 10.6736 10.826 11.0449 10.9225 11.3826C10.9694 11.5469 11.0321 11.7153 11.1153 11.875C11.0321 12.0347 10.9694 12.2031 10.9225 12.3674C10.826 12.705 10.7812 13.0764 10.7812 13.4375C10.7812 13.7986 10.826 14.17 10.9225 14.5076C10.9694 14.6719 11.0321 14.8403 11.1153 15C11.0321 15.1597 10.9694 15.3281 10.9225 15.4924C10.826 15.83 10.7812 16.2014 10.7812 16.5625C10.7812 16.6986 10.7876 16.8361 10.8007 16.9728L2.5 13.3413V5.33064ZM12.1275 17.3C12.1265 17.2964 12.1254 17.2929 12.1244 17.2892C12.0646 17.08 12.0312 16.8264 12.0312 16.5625C12.0312 16.2986 12.0646 16.045 12.1244 15.8358C12.1695 15.6779 12.2225 15.5697 12.2686 15.502L17.0432 13.1146C17.0351 13.2224 17.0312 13.3304 17.0312 13.4375C17.0312 13.7986 17.076 14.17 17.1725 14.5076C17.1944 14.5844 17.2198 14.662 17.249 14.7393L12.1275 17.3ZM17.249 11.6142L12.1275 14.175C12.1265 14.1714 12.1254 14.1679 12.1244 14.1642C12.0646 13.955 12.0312 13.7014 12.0312 13.4375C12.0312 13.1736 12.0646 12.92 12.1244 12.7108C12.1695 12.5529 12.2225 12.4447 12.2686 12.377L17.0432 9.98965C17.0351 10.0974 17.0312 10.2054 17.0312 10.3125C17.0312 10.6736 17.076 11.0449 17.1725 11.3826C17.1944 11.4594 17.2198 11.537 17.249 11.6142ZM17.249 8.48921L12.1275 11.05C12.1265 11.0464 12.1254 11.0428 12.1244 11.0392C12.0646 10.8301 12.0312 10.5764 12.0312 10.3125C12.0312 10.0486 12.0646 9.79494 12.1244 9.58576C12.1695 9.42785 12.2225 9.31975 12.2686 9.252L17.0432 6.86465C17.0351 6.9724 17.0312 7.0804 17.0312 7.1875C17.0312 7.54861 17.076 7.91994 17.1725 8.25764C17.1944 8.33437 17.2198 8.412 17.249 8.48921ZM16.6402 5.66864L9.34721 2.54307L3.61469 4.45391L11.8573 8.06006L16.6402 5.66864Z" fill="#000000" fill-opacity=".6" stroke="#000000" stroke-opacity=".6" stroke-width="0.3"/>
</svg>

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

+3 -3
View File
@@ -97,6 +97,9 @@ const agentKBSelectionMode = computed(() => {
return currentAgentConfig.value?.kb_selection_mode || 'all';
});
// 共享智能体下的知识库列表(来自 listKnowledgeBases(agent_id)),用于已选知识库展示与 org 角标
const sharedAgentKbList = ref<Array<{ id: string; name: string; type?: string; knowledge_count?: number; chunk_count?: number }>>([]);
// 当智能体改变时,模型、网络搜索、可@知识库列表均跟随新智能体配置
// 知识库:用新智能体配置的列表替换当前选中,使已选与可@列表一致(含共享智能体)
watch([selectedAgentId, agentKnowledgeBases, agentKBSelectionMode], ([newAgentId, newAgentKbs, newKbMode], [oldAgentId]) => {
@@ -205,9 +208,6 @@ const sharedAgentOrgName = computed(() => {
return shared?.org_name || shared?.shared_by_username || '';
});
// 共享智能体下的知识库列表(来自 listKnowledgeBases(agent_id)),用于已选知识库展示与 org 角标
const sharedAgentKbList = ref<Array<{ id: string; name: string; type?: string; knowledge_count?: number; chunk_count?: number }>>([]);
const props = defineProps({
isReplying: {
type: Boolean,
+50 -25
View File
@@ -10,6 +10,7 @@ import { MessagePlugin, DialogPlugin } from "tdesign-vue-next";
import { sanitizeHTML, safeMarkdownToHTML, createSafeImage, isValidImageURL } from '@/utils/security';
import { openMermaidFullscreen } from '@/utils/mermaidViewer';
import { useI18n } from 'vue-i18n';
import DocumentPreview from '@/components/document-preview.vue';
const { t } = useI18n();
@@ -57,10 +58,9 @@ let doc = null;
let down = ref()
let mdContentWrap = ref()
let url = ref('')
// 视图模式:chunks / original / merged
const viewMode = ref<'chunks' | 'original' | 'merged'>('merged');
const originalContent = ref<string>('');
const loadingOriginal = ref(false);
// 视图模式:chunks / merged / preview
// file 类型默认「预览」,URL / 手动创建 默认「全文」
const viewMode = ref<'chunks' | 'merged' | 'preview'>('merged');
// 合并后的文档内容
const mergedContent = ref<string>('');
@@ -212,6 +212,31 @@ watch(() => props.details?.md, (newChunks) => {
}
}, { immediate: true, deep: true });
const previewSupportedTypes = new Set([
'pdf', 'docx', 'pptx', 'ppt', 'xlsx', 'xls', 'csv',
'jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff', 'svg',
'txt', 'md', 'markdown', 'json', 'xml', 'html', 'css', 'js', 'ts',
'py', 'java', 'go', 'cpp', 'c', 'h', 'sh', 'yaml', 'yml',
'ini', 'conf', 'log', 'sql', 'rs', 'rb', 'php', 'swift', 'kt',
'scala', 'r', 'lua', 'pl', 'toml',
]);
const canPreview = (): boolean => {
if (props.details?.type !== 'file') return false;
const ft = props.details?.file_type?.toLowerCase();
return !!ft && previewSupportedTypes.has(ft);
};
// 当文档详情加载完成时,file 类型自动切换到「预览」
watch(() => props.details?.id, (newId) => {
if (!newId) return;
if (props.details?.type === 'file' && canPreview()) {
viewMode.value = 'preview';
} else {
viewMode.value = 'merged';
}
});
const isTextFile = (fileType?: string): boolean => {
if (!fileType) return false;
const textTypes = ['txt', 'md', 'markdown', 'json', 'xml', 'html', 'css', 'js', 'ts', 'py', 'java', 'go', 'cpp', 'c', 'h', 'sh', 'yaml', 'yml', 'ini', 'conf', 'log'];
@@ -222,25 +247,6 @@ const isMarkdownFile = (fileType?: string): boolean => {
const markdownTypes = ['md', 'markdown'];
return markdownTypes.includes(fileType.toLowerCase());
};
const loadOriginalContent = async () => {
if (!props.details.id || !props.details.type || props.details.type !== 'file') return;
const fileType = props.details.file_type?.toLowerCase();
if (!isTextFile(fileType)) {
MessagePlugin.warning(t('knowledgeBase.originalFileNotSupported') || '该文件类型不支持原文件展示,请下载查看');
return;
}
loadingOriginal.value = true;
try {
const blob = await downKnowledgeDetails(props.details.id);
const text = await blob.text();
originalContent.value = text;
} catch (error: any) {
console.error('Failed to load original content:', error);
MessagePlugin.error(error?.message || t('knowledgeBase.loadOriginalFailed') || '加载原文件内容失败');
} finally {
loadingOriginal.value = false;
}
};
watch(() => props.details.md, (newVal) => {
nextTick(async () => {
const images = mdContentWrap.value.querySelectorAll('img.markdown-image');
@@ -346,7 +352,6 @@ const handleClose = () => {
emit("closeDoc", false);
doc.scrollTop = 0;
viewMode.value = 'merged';
originalContent.value = '';
};
// 获取显示标题
@@ -622,6 +627,17 @@ const handleDetailsScroll = () => {
<span class="time"> {{ getTimeLabel() }}:{{ details.time }} </span>
<div class="view-mode-buttons">
<t-button
v-if="canPreview()"
size="small"
:variant="viewMode === 'preview' ? 'base' : 'outline'"
:theme="viewMode === 'preview' ? 'primary' : 'default'"
@click="viewMode = 'preview'"
class="view-mode-btn"
>
{{ $t('preview.tab') || '预览' }}
</t-button>
<t-button
v-if="!canPreview()"
size="small"
:variant="viewMode === 'merged' ? 'base' : 'outline'"
:theme="viewMode === 'merged' ? 'primary' : 'default'"
@@ -639,7 +655,6 @@ const handleDetailsScroll = () => {
>
{{ $t('knowledgeBase.viewChunks') || '分块' }}
</t-button>
</div>
</div>
</div>
@@ -709,6 +724,16 @@ const handleDetailsScroll = () => {
</div>
</div>
<!-- 文档预览视图 -->
<div v-else-if="viewMode === 'preview'">
<DocumentPreview
:knowledgeId="details.id"
:fileType="details.file_type"
:fileName="details.title"
:active="viewMode === 'preview'"
/>
</div>
<template #footer>
<t-button @click="handleClose">{{ $t('common.confirm') }}</t-button>
<t-button theme="default" @click="handleClose">{{ $t('common.cancel') }}</t-button>
@@ -0,0 +1,625 @@
// @ts-nocheck
<script setup lang="ts">
import { ref, shallowRef, watch, onUnmounted, nextTick, defineAsyncComponent } from 'vue';
import { previewKnowledgeFile } from '@/api/knowledge-base/index';
import { MessagePlugin } from 'tdesign-vue-next';
import hljs from 'highlight.js';
import 'highlight.js/styles/github.css';
import { useI18n } from 'vue-i18n';
const VueOfficePptx = defineAsyncComponent(() => import('@vue-office/pptx'));
const { t } = useI18n();
const props = defineProps<{
knowledgeId: string;
fileType: string;
fileName: string;
active: boolean;
}>();
const loading = ref(false);
const error = ref('');
const previewType = ref<'pdf' | 'docx' | 'image' | 'excel' | 'text' | 'markdown' | 'pptx' | 'unsupported'>('unsupported');
const blobUrl = ref('');
const textContent = ref('');
const highlightedCode = ref('');
const markdownHtml = ref('');
const excelHtml = ref('');
const pptxData = shallowRef<ArrayBuffer | null>(null);
const docxContainer = ref<HTMLElement | null>(null);
const imageNaturalWidth = ref(0);
const imageNaturalHeight = ref(0);
let loadedForId = '';
const fileTypeMap: Record<string, typeof previewType.value> = {};
['pdf'].forEach(t => fileTypeMap[t] = 'pdf');
['docx'].forEach(t => fileTypeMap[t] = 'docx');
['pptx', 'ppt'].forEach(t => fileTypeMap[t] = 'pptx');
['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff', 'svg'].forEach(t => fileTypeMap[t] = 'image');
['xlsx', 'xls', 'csv'].forEach(t => fileTypeMap[t] = 'excel');
['md', 'markdown'].forEach(t => fileTypeMap[t] = 'markdown');
['txt', 'json', 'xml', 'html', 'css', 'js', 'ts', 'py', 'java', 'go',
'cpp', 'c', 'h', 'sh', 'yaml', 'yml', 'ini', 'conf', 'log', 'sql', 'rs', 'rb', 'php',
'swift', 'kt', 'scala', 'r', 'lua', 'pl', 'toml'].forEach(t => fileTypeMap[t] = 'text');
const mimeTypeMap: Record<string, string> = {
pdf: 'application/pdf',
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
doc: 'application/msword',
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
ppt: 'application/vnd.ms-powerpoint',
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
xls: 'application/vnd.ms-excel',
csv: 'text/csv',
jpg: 'image/jpeg', jpeg: 'image/jpeg',
png: 'image/png', gif: 'image/gif', bmp: 'image/bmp',
webp: 'image/webp', tiff: 'image/tiff', svg: 'image/svg+xml',
txt: 'text/plain', md: 'text/markdown', markdown: 'text/markdown',
json: 'application/json', xml: 'application/xml',
html: 'text/html', css: 'text/css',
js: 'text/javascript', ts: 'text/typescript',
py: 'text/x-python', java: 'text/x-java', go: 'text/x-go',
};
function getMimeType(ft: string): string {
return mimeTypeMap[ft?.toLowerCase()] || 'application/octet-stream';
}
function ensureBlobType(blob: Blob, ft: string): Blob {
const expected = getMimeType(ft);
if (blob.type === expected) return blob;
return new Blob([blob], { type: expected });
}
const langMap: Record<string, string> = {
js: 'javascript', ts: 'typescript', py: 'python', rb: 'ruby',
sh: 'bash', yml: 'yaml', md: 'markdown', rs: 'rust',
kt: 'kotlin', pl: 'perl', conf: 'ini', log: 'plaintext',
};
function resolvePreviewType(ft: string): typeof previewType.value {
return fileTypeMap[ft?.toLowerCase()] || 'unsupported';
}
function getHighlightLang(ft: string): string {
const lower = ft?.toLowerCase() || '';
return langMap[lower] || lower;
}
async function renderDocx(blob: Blob) {
const { renderAsync } = await import('docx-preview');
if (docxContainer.value) {
docxContainer.value.innerHTML = '';
await renderAsync(blob, docxContainer.value, undefined, {
className: 'docx-preview-wrapper',
inWrapper: true,
ignoreWidth: false,
ignoreHeight: false,
ignoreFonts: false,
breakPages: true,
ignoreLastRenderedPageBreak: true,
experimental: false,
trimXmlDeclaration: true,
useBase64URL: true,
});
}
}
function isValidUTF8(bytes: Uint8Array): boolean {
for (let i = 0; i < bytes.length;) {
const b = bytes[i];
let remaining = 0;
if (b <= 0x7F) { remaining = 0; }
else if ((b & 0xE0) === 0xC0) { remaining = 1; }
else if ((b & 0xF0) === 0xE0) { remaining = 2; }
else if ((b & 0xF8) === 0xF0) { remaining = 3; }
else { return false; }
if (i + remaining >= bytes.length) return false;
for (let j = 1; j <= remaining; j++) {
if ((bytes[i + j] & 0xC0) !== 0x80) return false;
}
i += 1 + remaining;
}
return true;
}
function decodeCSVBlob(arrayBuffer: ArrayBuffer): string {
const bytes = new Uint8Array(arrayBuffer);
if (bytes[0] === 0xEF && bytes[1] === 0xBB && bytes[2] === 0xBF) {
return new TextDecoder('utf-8').decode(bytes);
}
if (isValidUTF8(bytes)) {
return new TextDecoder('utf-8').decode(bytes);
}
return new TextDecoder('gbk').decode(bytes);
}
async function renderExcel(blob: Blob, fileType?: string) {
const XLSX = await import('xlsx');
const arrayBuffer = await blob.arrayBuffer();
let workbook;
if (fileType?.toLowerCase() === 'csv') {
const csvText = decodeCSVBlob(arrayBuffer);
workbook = XLSX.read(csvText, { type: 'string' });
} else {
workbook = XLSX.read(arrayBuffer, { type: 'array' });
}
let html = '';
workbook.SheetNames.forEach((name, sheetIdx) => {
const sheet = workbook.Sheets[name];
const sheetHtml = XLSX.utils.sheet_to_html(sheet, { id: `sheet-${sheetIdx}` });
html += `<div class="excel-sheet">`;
if (workbook.SheetNames.length > 1) {
html += `<div class="excel-sheet-name">${name}</div>`;
}
html += sheetHtml;
html += `</div>`;
});
excelHtml.value = html;
}
async function renderText(blob: Blob, fileType: string) {
const text = await blob.text();
textContent.value = text;
const lang = getHighlightLang(fileType);
if (lang && hljs.getLanguage(lang)) {
try {
highlightedCode.value = hljs.highlight(text, { language: lang }).value;
return;
} catch { /* fallthrough */ }
}
const auto = hljs.highlightAuto(text);
highlightedCode.value = auto.value;
}
async function renderMarkdown(blob: Blob) {
const { marked } = await import('marked');
const text = await blob.text();
marked.use({
breaks: true,
gfm: true,
});
const renderer = new marked.Renderer();
renderer.code = function (code, infostring) {
const lang = (infostring || '').trim();
let highlighted = '';
if (lang && hljs.getLanguage(lang)) {
try { highlighted = hljs.highlight(code, { language: lang }).value; }
catch { highlighted = hljs.highlightAuto(code).value; }
} else {
highlighted = hljs.highlightAuto(code).value;
}
return `<pre><code class="hljs">${highlighted}</code></pre>`;
};
marked.use({ renderer });
markdownHtml.value = marked.parse(text);
}
function onImageLoad(e: Event) {
const img = e.target as HTMLImageElement;
imageNaturalWidth.value = img.naturalWidth;
imageNaturalHeight.value = img.naturalHeight;
}
async function loadPreview() {
const id = props.knowledgeId;
const ft = props.fileType;
if (!id || !ft) return;
if (loadedForId === id) return;
cleanup();
loading.value = true;
error.value = '';
previewType.value = resolvePreviewType(ft);
if (previewType.value === 'unsupported') {
loading.value = false;
return;
}
try {
const rawBlob = await previewKnowledgeFile(id);
const blob = ensureBlobType(rawBlob, ft);
loadedForId = id;
loading.value = false;
await nextTick();
switch (previewType.value) {
case 'pdf': {
blobUrl.value = URL.createObjectURL(blob);
break;
}
case 'image': {
blobUrl.value = URL.createObjectURL(blob);
break;
}
case 'docx': {
await renderDocx(blob);
break;
}
case 'excel': {
await renderExcel(blob, ft);
break;
}
case 'text': {
await renderText(blob, ft);
break;
}
case 'markdown': {
await renderMarkdown(blob);
break;
}
case 'pptx': {
pptxData.value = await blob.arrayBuffer();
break;
}
}
} catch (err: any) {
console.error('Document preview failed:', err);
error.value = err?.message || t('preview.loadFailed');
} finally {
loading.value = false;
}
}
function cleanup() {
if (blobUrl.value) {
URL.revokeObjectURL(blobUrl.value);
blobUrl.value = '';
}
textContent.value = '';
highlightedCode.value = '';
markdownHtml.value = '';
excelHtml.value = '';
pptxData.value = null;
imageNaturalWidth.value = 0;
imageNaturalHeight.value = 0;
loadedForId = '';
if (docxContainer.value) {
docxContainer.value.innerHTML = '';
}
}
watch(
() => [props.active, props.knowledgeId],
([active]) => {
if (active && props.knowledgeId) {
loadPreview();
}
},
{ immediate: true }
);
onUnmounted(() => {
cleanup();
});
</script>
<template>
<div class="document-preview">
<!-- Loading -->
<div v-if="loading" class="preview-loading">
<t-loading size="large" />
<span class="loading-text">{{ $t('preview.loading') }}</span>
</div>
<!-- Error -->
<div v-else-if="error" class="preview-error">
<t-icon name="error-circle" size="48px" />
<p>{{ error }}</p>
<t-button theme="primary" size="small" @click="loadedForId = ''; loadPreview()">
{{ $t('preview.retry') }}
</t-button>
</div>
<!-- Unsupported -->
<div v-else-if="previewType === 'unsupported'" class="preview-unsupported">
<t-icon name="file-unknown" size="48px" />
<p>{{ $t('preview.unsupported') }}</p>
<p class="unsupported-hint">{{ $t('preview.unsupportedHint') }}</p>
</div>
<!-- PDF -->
<div v-else-if="previewType === 'pdf' && blobUrl" class="preview-pdf">
<iframe :src="blobUrl" class="pdf-iframe" />
</div>
<!-- Image -->
<div v-else-if="previewType === 'image' && blobUrl" class="preview-image">
<div class="image-wrapper">
<img :src="blobUrl" :alt="fileName" @load="onImageLoad" />
<div v-if="imageNaturalWidth" class="image-info">
{{ imageNaturalWidth }} × {{ imageNaturalHeight }} px
</div>
</div>
</div>
<!-- DOCX -->
<div v-else-if="previewType === 'docx'" class="preview-docx">
<div ref="docxContainer" class="docx-container" />
</div>
<!-- PPTX -->
<div v-else-if="previewType === 'pptx' && pptxData" class="preview-pptx">
<vue-office-pptx :src="pptxData" @rendered="() => {}" @error="(e: any) => { error = e?.message || $t('preview.loadFailed'); }" />
</div>
<!-- Excel -->
<div v-else-if="previewType === 'excel' && excelHtml" class="preview-excel">
<div class="excel-container" v-html="excelHtml" />
</div>
<!-- Markdown -->
<div v-else-if="previewType === 'markdown' && markdownHtml" class="preview-markdown">
<div class="markdown-body" v-html="markdownHtml" />
</div>
<!-- Text / Code -->
<div v-else-if="previewType === 'text' && highlightedCode" class="preview-text">
<pre class="code-preview"><code class="hljs" v-html="highlightedCode"></code></pre>
</div>
</div>
</template>
<style scoped lang="less">
// ── Design tokens ──
@border-color: #e7e7e7;
@border-radius: 6px;
@bg-white: #fff;
@bg-subtle: #f6f8fa;
@bg-muted: #f9fafb;
@text-primary: #1d2129;
@text-secondary: #000000a6;
@text-tertiary: #00000066;
@text-disabled: #00000040;
@accent: #07c05f;
@accent-hover: #059669;
@accent-bg: #f0fdf4;
@accent-bg-hover: #e6f7ed;
@error-color: #e34d59;
@table-border: #e7e7e7;
@preview-max-h: calc(100vh - 200px);
@transition: all 0.2s ease;
// ── Shared container mixin ──
.preview-container() {
border: 1px solid @border-color;
border-radius: @border-radius;
overflow: auto;
max-height: @preview-max-h;
background: @bg-white;
}
.document-preview {
min-height: 200px;
}
// ── States ──
.preview-loading {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60px 20px;
gap: 16px;
.loading-text { color: @text-tertiary; font-size: 14px; }
}
.preview-error {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60px 20px;
gap: 12px;
color: @error-color;
p { margin: 0; font-size: 14px; color: @text-secondary; }
}
.preview-unsupported {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60px 20px;
gap: 12px;
color: @text-disabled;
p { margin: 0; font-size: 14px; color: @text-secondary; }
.unsupported-hint { font-size: 12px; color: @text-tertiary; }
}
// ── PDF ──
.preview-pdf {
width: 100%;
height: @preview-max-h;
min-height: 500px;
.pdf-iframe {
width: 100%;
height: 100%;
border: none;
border-radius: @border-radius;
}
}
// ── Image ──
.preview-image {
display: flex;
justify-content: center;
padding: 20px 0;
.image-wrapper {
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
img {
max-width: 100%;
max-height: calc(100vh - 280px);
border-radius: @border-radius;
box-shadow: 0 2px 12px rgba(7, 192, 95, 0.08);
object-fit: contain;
}
.image-info { font-size: 12px; color: @text-tertiary; }
}
}
// ── Markdown ──
.preview-markdown {
.preview-container();
padding: 20px 24px;
}
// ── DOCX ──
.preview-docx {
.docx-container { .preview-container(); }
}
// ── PPTX ──
.preview-pptx {
height: @preview-max-h;
min-height: 500px;
border: 1px solid @border-color;
border-radius: @border-radius;
overflow: hidden;
background: @bg-subtle;
}
// ── Excel ──
.preview-excel {
.excel-container { .preview-container(); }
}
// ── Text / Code ──
.preview-text {
.code-preview {
.preview-container();
margin: 0;
padding: 16px;
background: @bg-subtle;
font-size: 13px;
line-height: 1.6;
code {
white-space: pre;
word-wrap: normal;
display: block;
background: transparent;
}
}
}
// ── Deep styles (v-html / third-party components) ──
// Shared table mixin for v-html content
.preview-table() {
width: 100%;
border-collapse: collapse;
font-size: 13px;
th, td {
border: 1px solid @table-border;
padding: 6px 12px;
text-align: left;
}
th {
background: @accent-bg;
font-weight: 600;
color: @text-primary;
}
tr:hover td {
background: @accent-bg;
transition: @transition;
}
}
:deep(.markdown-body) {
font-size: 14px;
line-height: 1.7;
color: @text-primary;
word-break: break-word;
h1, h2, h3, h4, h5, h6 {
margin-top: 20px;
margin-bottom: 10px;
font-weight: 600;
line-height: 1.4;
}
h1 { font-size: 24px; border-bottom: 1px solid @border-color; padding-bottom: 8px; }
h2 { font-size: 20px; border-bottom: 1px solid @border-color; padding-bottom: 6px; }
h3 { font-size: 17px; }
p { margin: 8px 0; }
blockquote {
margin: 12px 0;
padding: 8px 16px;
border-left: 4px solid @accent;
background: @bg-subtle;
color: #57606a;
}
ul, ol { padding-left: 24px; margin: 8px 0; }
li { margin: 4px 0; }
table { .preview-table(); margin: 12px 0; }
pre {
margin: 12px 0;
padding: 14px;
background: @bg-subtle;
border-radius: @border-radius;
overflow: auto;
font-size: 13px;
line-height: 1.5;
code { background: transparent; padding: 0; }
}
code {
background: #eff1f3;
padding: 2px 6px;
border-radius: 3px;
font-size: 0.9em;
}
img { max-width: 100%; border-radius: 4px; }
hr { border: none; border-top: 1px solid @border-color; margin: 20px 0; }
a { color: @accent; text-decoration: none; &:hover { color: @accent-hover; text-decoration: underline; } }
strong { font-weight: 600; }
}
:deep(.docx-preview-wrapper) {
padding: 20px;
}
:deep(.vue-office-pptx) {
width: 100%;
height: 100%;
}
:deep(.vue-office-pptx-main) {
width: 100%;
height: 100%;
}
:deep(.excel-sheet) {
padding: 0;
.excel-sheet-name {
position: sticky;
top: 0;
background: @accent-bg;
padding: 8px 16px;
font-weight: 600;
font-size: 13px;
color: @text-primary;
border-bottom: 1px solid @border-color;
z-index: 1;
}
table {
.preview-table();
th, td {
white-space: nowrap;
max-width: 300px;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
</style>
+27 -6
View File
@@ -2,6 +2,7 @@
<div class="aside_box">
<div class="logo_box" @click="router.push('/platform/knowledge-bases')" style="cursor: pointer;">
<img class="logo" src="@/assets/img/weknora.png" alt="">
<span v-if="isLiteEdition" class="lite-badge">Lite</span>
</div>
<!-- 租户选择器:仅在用户可切换租户时显示 -->
@@ -80,6 +81,7 @@ import UserMenu from '@/components/UserMenu.vue';
import TenantSelector from '@/components/TenantSelector.vue';
import BatchManageDialog from '@/components/BatchManageDialog.vue';
import { useI18n } from 'vue-i18n';
import { getSystemInfo } from '@/api/system';
const { t } = useI18n();
const usemenuStore = useMenuStore();
@@ -100,6 +102,7 @@ const hasMore = computed(() => currentPage.value < totalPages.value);
type MenuItem = { title: string; icon: string; path: string; childrenPath?: string; children?: any[] };
const { menuArr } = storeToRefs(usemenuStore);
let activeSubmenu = ref<string>('');
const isLiteEdition = ref(false);
// 批量管理状态
const batchManageVisible = ref(false);
@@ -380,6 +383,10 @@ onMounted(async () => {
if (route.params.chatid) {
currentSecondpath.value = `chat/${route.params.chatid}`;
}
getSystemInfo().then(res => {
isLiteEdition.value = res.data?.edition === 'lite'
}).catch(() => {})
// 初始化知识库信息
const kbId = (route.params as any)?.kbId as string
@@ -593,6 +600,19 @@ const mouseleaveMenu = (path: string) => {
height: auto;
margin-left: 24px;
}
.lite-badge {
margin-left: 4px;
padding: 1px 6px;
font-size: 11px;
font-weight: 600;
line-height: 18px;
color: #07c05f;
background: #07c05f1a;
border: 1px solid #07c05f40;
border-radius: 4px;
letter-spacing: 0.5px;
user-select: none;
}
}
.logo_img {
@@ -699,6 +719,8 @@ const mouseleaveMenu = (path: string) => {
padding: 13px 8px 13px 16px;
box-sizing: border-box;
margin-bottom: 4px;
border-radius: 4px;
transition: background-color 0.2s ease;
.menu_item-box {
display: flex;
@@ -707,12 +729,11 @@ const mouseleaveMenu = (path: string) => {
&:hover {
border-radius: 4px;
background: #30323605;
color: #00000099;
background: rgba(0, 0, 0, 0.04);
.menu_icon,
.menu_title {
color: #00000099;
color: #000000b3;
}
}
}
@@ -812,12 +833,12 @@ const mouseleaveMenu = (path: string) => {
}
&:hover {
background: #30323605;
color: #00000099;
background: rgba(0, 0, 0, 0.04);
color: #000000b3;
border-radius: 3px;
.menu-more {
color: #00000099;
color: #000000b3;
}
.menu-more-wrap {
+17
View File
@@ -97,6 +97,8 @@ export default {
imagesFilteredNoVLM: 'Filtered {count} image files (VLM not enabled)',
invalidFilesFiltered: 'Filtered {count} unsupported files',
unsupportedFileType: 'Unsupported file type',
unsupportedTypesHint: 'Some document types ({types}) have no available parser engine and cannot be processed',
goToParserSettings: 'Configure',
failedFilesList: 'Failed files:',
andMoreFiles: '...and {count} more files',
duplicateFilesSkipped: '{count} duplicate files skipped',
@@ -504,6 +506,7 @@ export default {
webSearchConfig: 'Web Search',
enableMemory: 'Enable Memory',
enableMemoryDesc: 'When enabled, the system will record your conversation history and automatically recall relevant content in future conversations to provide more personalized answers.',
storageEngine: 'Storage Engine',
mcpService: 'MCP Service',
systemSettings: 'System Settings',
tenantInfo: 'Tenant Info',
@@ -1216,6 +1219,7 @@ export default {
basic: 'Basic Information',
models: 'Model Configuration',
chunking: 'Chunking Settings',
storage: 'Storage Engine',
advanced: 'Advanced Settings',
faq: 'FAQ Settings',
graph: 'Knowledge Graph',
@@ -1503,6 +1507,11 @@ export default {
deepThoughtCompleted: 'Deep thinking completed',
deepThoughtAlt: 'Deep thinking finished',
referencesTitle: 'Referenced {count} related item(s)',
referencesDocCount: 'Referenced {count} document(s)',
referencesDocAndWebCount: 'Referenced {docCount} document(s) and {webCount} web page(s)',
referenceChunkCount: '{count} chunk(s)',
chunkLabel: 'Chunk {index}:',
navigateToDocument: 'View document details',
referenceIconAlt: 'Reference materials icon',
chunkIdLabel: 'Chunk ID:',
documentIdLabel: 'Document ID:',
@@ -2698,4 +2707,12 @@ export default {
sharedAgents: ' agents',
},
},
preview: {
tab: 'Preview',
loading: 'Loading document preview...',
loadFailed: 'Failed to load document preview',
retry: 'Retry',
unsupported: 'This file type does not support online preview',
unsupportedHint: 'Please download and open with a local application',
},
}
+15
View File
@@ -96,6 +96,8 @@ export default {
imagesFilteredNoVLM: "{count}개 이미지 파일 필터링됨(VLM 미활성화)",
invalidFilesFiltered: "{count}개 지원되지 않는 파일 필터링됨",
unsupportedFileType: "지원되지 않는 파일 형식",
unsupportedTypesHint: "일부 문서 유형({types})에 사용 가능한 파서 엔진이 없어 처리할 수 없습니다",
goToParserSettings: "설정으로 이동",
failedFilesList: "실패한 파일 목록:",
andMoreFiles: "...외 {count}개 파일",
duplicateFilesSkipped: "{count}개 중복 파일 무시됨",
@@ -273,6 +275,11 @@ export default {
deepThoughtCompleted: "심층 분석 완료",
deepThoughtAlt: "심층 분석 완료",
referencesTitle: "{count}개의 관련 내용 참조",
referencesDocCount: "{count}개 문서 참조",
referencesDocAndWebCount: "{docCount}개 문서와 {webCount}개 웹페이지 참조",
referenceChunkCount: "{count}개 청크",
chunkLabel: "청크 {index}:",
navigateToDocument: "문서 상세 보기",
referenceIconAlt: "참조 내용 아이콘",
chunkIdLabel: "청크 ID:",
documentIdLabel: "문서 ID:",
@@ -2777,4 +2784,12 @@ export default {
sharedAgents: "에이전트",
},
},
preview: {
tab: '미리보기',
loading: '문서 미리보기 로딩 중...',
loadFailed: '문서 미리보기 로드 실패',
retry: '재시도',
unsupported: '이 파일 유형은 온라인 미리보기를 지원하지 않습니다',
unsupportedHint: '파일을 다운로드하여 로컬 앱으로 열어주세요',
},
};
+16 -1
View File
@@ -77,6 +77,8 @@ export default {
imagesFilteredNoVLM: 'Отфильтровано {count} изображений (VLM не включен)',
invalidFilesFiltered: 'Отфильтровано {count} неподдерживаемых файлов',
unsupportedFileType: 'Неподдерживаемый тип файла',
unsupportedTypesHint: 'Некоторые типы документов ({types}) не имеют доступного парсера и не могут быть обработаны',
goToParserSettings: 'Настроить',
failedFilesList: 'Неудавшиеся файлы:',
andMoreFiles: '...и ещё {count} файлов',
duplicateFilesSkipped: 'Пропущено {count} повторяющихся файлов',
@@ -1331,6 +1333,11 @@ export default {
unableToGetKnowledgeBaseId: 'Невозможно получить ID базы знаний',
summaryInProgress: 'Идёт подготовка ответа…',
referencesTitle: 'Использовано {count} связанного материала',
referencesDocCount: 'Использовано {count} документ(ов)',
referencesDocAndWebCount: 'Использовано {docCount} документ(ов) и {webCount} веб-страниц(ы)',
referenceChunkCount: '{count} фрагмент(ов)',
chunkLabel: 'Фрагмент {index}:',
navigateToDocument: 'Просмотр документа',
referenceIconAlt: 'Иконка ссылок на материалы',
chunkIdLabel: 'ID фрагмента:',
documentIdLabel: 'ID документа:',
@@ -1841,5 +1848,13 @@ export default {
stopSuccess: 'Генерация остановлена',
stopFailed: 'Не удалось остановить. Попробуйте ещё раз.'
}
}
},
preview: {
tab: 'Предпросмотр',
loading: 'Загрузка предпросмотра документа...',
loadFailed: 'Не удалось загрузить предпросмотр документа',
retry: 'Повторить',
unsupported: 'Этот тип файла не поддерживает онлайн-просмотр',
unsupportedHint: 'Скачайте файл и откройте локально',
},
}
+17
View File
@@ -96,6 +96,8 @@ export default {
imagesFilteredNoVLM: "已过滤 {count} 个图片文件(未启用VLM)",
invalidFilesFiltered: "已过滤 {count} 个不支持的文件",
unsupportedFileType: "不支持的文件格式",
unsupportedTypesHint: "部分文档类型({types})暂无可用解析引擎,上传后将无法解析",
goToParserSettings: "前往配置",
failedFilesList: "失败文件列表:",
andMoreFiles: "...及其他 {count} 个文件",
duplicateFilesSkipped: "已忽略 {count} 个重复文件",
@@ -270,6 +272,11 @@ export default {
deepThoughtCompleted: "已深度思考",
deepThoughtAlt: "深度思考完成",
referencesTitle: "参考了{count}个相关内容",
referencesDocCount: "引用了{count}篇文档",
referencesDocAndWebCount: "引用了{docCount}篇文档和{webCount}条网页",
referenceChunkCount: "{count}个片段",
chunkLabel: "片段{index}:",
navigateToDocument: "查看文档详情",
referenceIconAlt: "参考内容图标",
chunkIdLabel: "片段ID:",
documentIdLabel: "文档ID:",
@@ -346,6 +353,7 @@ export default {
webSearchConfig: "网络搜索",
enableMemory: "开启记忆功能",
enableMemoryDesc: "开启后,系统将记录您的对话历史,并在后续对话中自动回忆相关内容,提供更个性化的回答。",
storageEngine: "存储引擎",
mcpService: "MCP服务",
systemSettings: "系统设置",
tenantInfo: "租户信息",
@@ -1612,6 +1620,7 @@ export default {
basic: "基本信息",
models: "模型配置",
chunking: "分块设置",
storage: "存储引擎",
advanced: "高级设置",
faq: "FAQ 设置",
graph: "知识图谱",
@@ -2703,4 +2712,12 @@ export default {
sharedAgents: "个智能体",
},
},
preview: {
tab: "预览",
loading: "正在加载文档预览...",
loadFailed: "加载文档预览失败",
retry: "重试",
unsupported: "该文件类型暂不支持在线预览",
unsupportedHint: "请下载文件后使用本地应用查看",
},
};
+17 -17
View File
@@ -39,29 +39,29 @@ export function formatStringDate(date: any) {
year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second
);
}
export function kbFileTypeVerification(file: any, silent = false) {
let validTypes = ["pdf", "txt", "md", "docx", "doc", "jpg", "jpeg", "png", "csv", "xlsx", "xls"];
let type = file.name.substring(file.name.lastIndexOf(".") + 1);
if (!validTypes.includes(type)) {
const DEFAULT_VALID_TYPES = new Set(["pdf", "txt", "md", "docx", "doc", "pptx", "ppt", "jpg", "jpeg", "png", "csv", "xlsx", "xls"]);
/**
* Returns true when the file should be **rejected**.
* @param validTypes - override the default extension whitelist with a dynamic set (e.g. from engine registry).
*/
export function kbFileTypeVerification(file: any, silent = false, validTypes?: Set<string> | string[]) {
const allowed = validTypes
? (validTypes instanceof Set ? validTypes : new Set(validTypes))
: DEFAULT_VALID_TYPES;
const type = file.name.substring(file.name.lastIndexOf(".") + 1).toLowerCase();
if (!allowed.has(type)) {
if (!silent) {
MessagePlugin.error("文件类型错误!");
MessagePlugin.error("不支持的文件类型!");
}
return true;
}
if (
(type == "pdf" || type == "docx" || type == "doc") &&
file.size > MAX_FILE_SIZE_BYTES
) {
if (file.size > MAX_FILE_SIZE_BYTES) {
if (!silent) {
MessagePlugin.error(`pdf/doc文件不能超过${MAX_FILE_SIZE_MB}M!`);
MessagePlugin.error(`文件大小不能超过 ${MAX_FILE_SIZE_MB}M!`);
}
return true;
}
if ((type == "txt" || type == "md") && file.size > MAX_FILE_SIZE_BYTES) {
if (!silent) {
MessagePlugin.error(`txt/md文件不能超过${MAX_FILE_SIZE_MB}M!`);
}
return true;
}
return false
return false;
}
+5 -1
View File
@@ -140,10 +140,14 @@ export function isValidURL(url: string): boolean {
if (!url || typeof url !== 'string') {
return false;
}
// 允许以 / 开头的站内相对路径(如本地存储 /files/images/xxx.jpg)
if (url.startsWith('/') && !url.startsWith('//')) {
return true;
}
try {
const urlObj = new URL(url);
// 只允许 http 和 https 协议
return ['http:', 'https:'].includes(urlObj.protocol);
} catch {
return false;
@@ -890,7 +890,7 @@
</div>
<div class="setting-control">
<div class="slider-wrapper">
<t-slider v-model="formData.config.keyword_threshold" :min="0" :max="1" :step="0.05" />
<t-slider v-model="formData.config.keyword_threshold" :min="0" :max="1" :step="0.01" />
<span class="slider-value">{{ formData.config.keyword_threshold?.toFixed(2) }}</span>
</div>
</div>
@@ -904,7 +904,7 @@
</div>
<div class="setting-control">
<div class="slider-wrapper">
<t-slider v-model="formData.config.vector_threshold" :min="0" :max="1" :step="0.05" />
<t-slider v-model="formData.config.vector_threshold" :min="0" :max="1" :step="0.01" />
<span class="slider-value">{{ formData.config.vector_threshold?.toFixed(2) }}</span>
</div>
</div>
@@ -929,7 +929,7 @@
</div>
<div class="setting-control">
<div class="slider-wrapper">
<t-slider v-model="formData.config.rerank_threshold" :min="0" :max="1" :step="0.05" />
<t-slider v-model="formData.config.rerank_threshold" :min="0" :max="1" :step="0.01" />
<span class="slider-value">{{ formData.config.rerank_threshold?.toFixed(2) }}</span>
</div>
</div>
+233 -54
View File
@@ -3,48 +3,71 @@
<div class="refer_header" @click="referBoxSwitch" v-if="session.knowledge_references && session.knowledge_references.length">
<div class="refer_title">
<img src="@/assets/img/ziliao.svg" :alt="$t('chat.referenceIconAlt')" />
<span>{{ $t('chat.referencesTitle', { count: session.knowledge_references?.length ?? 0 }) }}</span>
<span>{{ headerText }}</span>
</div>
<div class="refer_show_icon">
<t-icon :name="showReferBox ? 'chevron-up' : 'chevron-down'" />
</div>
</div>
<div class="refer_box" v-show="showReferBox">
<div v-for="(item, index) in session.knowledge_references" :key="index">
<!-- Web search references: show URL and make it clickable -->
<template v-if="item.chunk_type === 'web_search'">
<a
:href="getWebSearchUrl(item)"
target="_blank"
rel="noopener noreferrer"
class="doc doc-web"
@click.stop
>
{{ session.knowledge_references.length < 2 ? getWebSearchDisplayText(item) : `${index + 1}.${getWebSearchDisplayText(item)}` }}
</a>
</template>
<!-- Regular knowledge references: show title with popup -->
<template v-else>
<t-popup overlayClassName="refer-to-layer" placement="bottom-left" width="400" :showArrow="false"
trigger="click">
<template #content>
<ContentPopup :content="safeProcessContent(item.content)" :is-html="true" />
</template>
<span class="doc">
{{ session.knowledge_references.length < 2 ? item.knowledge_title : `${index +
1}.${item.knowledge_title}` }} </span>
</t-popup>
</template>
<!-- Web search references (ungrouped) -->
<div v-for="(item, index) in webSearchRefs" :key="'web-' + index">
<a
:href="getWebSearchUrl(item)"
target="_blank"
rel="noopener noreferrer"
class="doc doc-web"
@click.stop
>
{{ webSearchRefs.length < 2 ? getWebSearchDisplayText(item) : `${index + 1}. ${getWebSearchDisplayText(item)}` }}
</a>
</div>
<!-- Knowledge references grouped by document -->
<div v-for="(group, gIdx) in groupedKnowledgeRefs" :key="'grp-' + gIdx" class="doc-group">
<div class="doc-group-header" @click="toggleGroup(group.key)">
<div class="doc-group-left">
<t-icon :name="expandedGroups[group.key] ? 'chevron-down' : 'chevron-right'" size="14px" class="doc-group-arrow" />
<t-icon name="file" size="14px" class="doc-group-icon" />
<span class="doc-group-title" :title="group.title">{{ group.title }}</span>
<span class="doc-group-count">{{ $t('chat.referenceChunkCount', { count: group.chunks.length }) }}</span>
</div>
<div class="doc-group-actions" v-if="group.knowledgeBaseId" @click.stop>
<t-tooltip :content="$t('chat.navigateToDocument')">
<span class="doc-group-navigate" @click="navigateToDocument(group)">
<t-icon name="jump" size="14px" />
</span>
</t-tooltip>
</div>
</div>
<div class="doc-group-chunks" v-show="expandedGroups[group.key]">
<div v-for="(chunk, cIdx) in group.chunks" :key="'chunk-' + cIdx" class="doc-chunk-item">
<t-popup overlayClassName="refer-to-layer" placement="bottom-left" width="400" :showArrow="false" trigger="click">
<template #content>
<ContentPopup :content="safeProcessContent(chunk.content)" :is-html="true" />
</template>
<span class="doc-chunk-text">
<span class="doc-chunk-index">{{ $t('chat.chunkLabel', { index: cIdx + 1 }) }}</span>
{{ truncateContent(chunk.content, 80) }}
</span>
</t-popup>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { onMounted, defineProps, computed, ref, reactive } from "vue";
import { defineProps, computed, ref, reactive } from "vue";
import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { sanitizeHTML } from '@/utils/security';
import ContentPopup from './tool-results/ContentPopup.vue';
const router = useRouter();
const { t } = useI18n();
const props = defineProps({
// 必填项
content: {
type: String,
required: false
@@ -54,22 +77,88 @@ const props = defineProps({
required: false
}
});
const showReferBox = ref(false);
const expandedGroups = reactive({});
const referBoxSwitch = () => {
showReferBox.value = !showReferBox.value;
};
// 安全地处理内容
const toggleGroup = (key) => {
expandedGroups[key] = !expandedGroups[key];
};
const webSearchRefs = computed(() => {
if (!props.session?.knowledge_references) return [];
return props.session.knowledge_references.filter(item => item.chunk_type === 'web_search');
});
const knowledgeRefs = computed(() => {
if (!props.session?.knowledge_references) return [];
return props.session.knowledge_references.filter(item => item.chunk_type !== 'web_search');
});
const groupedKnowledgeRefs = computed(() => {
const refs = knowledgeRefs.value;
if (!refs.length) return [];
const groupMap = new Map();
for (const item of refs) {
const key = item.knowledge_id || item.knowledge_title || item.id;
if (!groupMap.has(key)) {
groupMap.set(key, {
key,
title: item.knowledge_title || item.knowledge_filename || key,
knowledgeId: item.knowledge_id,
knowledgeBaseId: item.knowledge_base_id,
chunks: [],
});
}
groupMap.get(key).chunks.push(item);
}
return Array.from(groupMap.values());
});
const headerText = computed(() => {
const total = props.session?.knowledge_references?.length ?? 0;
const docCount = groupedKnowledgeRefs.value.length;
const webCount = webSearchRefs.value.length;
if (docCount > 0 && webCount > 0) {
return t('chat.referencesDocAndWebCount', { docCount, webCount });
}
if (docCount > 0) {
return t('chat.referencesDocCount', { count: docCount });
}
return t('chat.referencesTitle', { count: total });
});
const safeProcessContent = (content) => {
if (!content) return '';
// 先进行安全清理,然后处理换行
const sanitized = sanitizeHTML(content);
return sanitized.replace(/\n/g, '<br/>');
};
// 获取 web_search 类型的 URL
const truncateContent = (content, maxLen) => {
if (!content) return '';
const text = content.replace(/\n/g, ' ').trim();
if (text.length <= maxLen) return text;
return text.slice(0, maxLen) + '...';
};
const navigateToDocument = (group) => {
if (!group.knowledgeBaseId) return;
const query = {};
if (group.knowledgeId) {
query.knowledge_id = group.knowledgeId;
}
router.push({
path: `/platform/knowledge-bases/${group.knowledgeBaseId}`,
query
});
};
const getWebSearchUrl = (item) => {
// 优先使用 metadata.url,其次使用 id(如果 id 是 URL)
if (item.metadata?.url) {
return item.metadata.url;
}
@@ -79,16 +168,13 @@ const getWebSearchUrl = (item) => {
return '#';
};
// 获取 web_search 类型的显示文本
const getWebSearchDisplayText = (item) => {
// 优先使用 knowledge_title,其次使用 metadata.title,最后使用 URL 的域名
if (item.knowledge_title) {
return item.knowledge_title;
}
if (item.metadata?.title) {
return item.metadata.title;
}
// 如果都没有,使用 URL 的域名部分
const url = getWebSearchUrl(item);
if (url && url !== '#') {
try {
@@ -100,7 +186,6 @@ const getWebSearchDisplayText = (item) => {
}
return 'Web Search Result';
};
</script>
<style lang="less" scoped>
.refer {
@@ -155,23 +240,12 @@ const getWebSearchDisplayText = (item) => {
}
.refer_box {
padding: 4px 14px 4px 14px;
padding: 4px 14px 8px 14px;
flex-direction: column;
border-top: 1px solid #f0f0f0;
}
}
.doc_content {
max-height: 400px;
overflow: auto;
font-size: 14px;
color: #000000e6;
line-height: 23px;
text-align: justify;
border: 1px solid #07c05f33;
padding: 8px;
}
.doc {
text-decoration: none;
color: #07c05f;
@@ -185,28 +259,133 @@ const getWebSearchDisplayText = (item) => {
padding: 2px 0;
transition: all 0.2s ease;
border-bottom: 1px solid transparent;
&:hover {
border-bottom-color: #07c05f;
}
&.doc-web {
// Web search links can be longer, allow wrapping if needed
white-space: normal;
word-break: break-all;
&:hover {
text-decoration: underline;
}
}
}
.doc-group {
margin-top: 4px;
.doc-group-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 4px 4px;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.15s ease;
&:hover {
background-color: rgba(7, 192, 95, 0.04);
}
.doc-group-left {
display: flex;
align-items: center;
min-width: 0;
flex: 1;
}
.doc-group-arrow {
color: #999;
flex-shrink: 0;
margin-right: 2px;
}
.doc-group-icon {
color: #07c05f;
flex-shrink: 0;
margin-right: 6px;
}
.doc-group-title {
color: #333;
font-weight: 500;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 200px;
}
.doc-group-count {
color: #999;
font-size: 11px;
margin-left: 6px;
white-space: nowrap;
flex-shrink: 0;
}
.doc-group-actions {
flex-shrink: 0;
margin-left: 8px;
}
.doc-group-navigate {
display: inline-flex;
align-items: center;
justify-content: center;
width: 22px;
height: 22px;
border-radius: 4px;
color: #07c05f;
cursor: pointer;
transition: all 0.15s ease;
&:hover {
background-color: rgba(7, 192, 95, 0.1);
}
}
}
.doc-group-chunks {
padding-left: 22px;
}
}
.doc-chunk-item {
.doc-chunk-text {
display: block;
color: #666;
font-size: 12px;
line-height: 18px;
padding: 3px 6px;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.15s ease;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
&:hover {
background-color: rgba(7, 192, 95, 0.04);
color: #07c05f;
}
.doc-chunk-index {
color: #999;
font-size: 11px;
margin-right: 4px;
}
}
}
</style>
<style>
.refer-to-layer {
width: 400px;
max-width: 500px;
.t-popup__content {
max-height: 400px;
max-width: 500px;
@@ -216,4 +395,4 @@ const getWebSearchDisplayText = (item) => {
word-break: break-word;
}
}
</style>
</style>
+141 -18
View File
@@ -31,6 +31,7 @@ import {
import FAQEntryManager from './components/FAQEntryManager.vue';
import { useI18n } from 'vue-i18n';
import { formatStringDate, kbFileTypeVerification } from '@/utils';
import { getParserEngines, type ParserEngineInfo } from '@/api/system';
const route = useRoute();
const { t } = useI18n();
const kbId = computed(() => (route.params as any).kbId as string || '');
@@ -40,6 +41,62 @@ const folderUploadInputRef = ref<HTMLInputElement | null>(null);
const uploading = ref(false);
const kbLoading = ref(false);
const isFAQ = computed(() => (kbInfo.value?.type || '') === 'faq');
const parserEngines = ref<ParserEngineInfo[]>([]);
const supportedFileTypes = computed<Set<string>>(() => {
const engines = parserEngines.value
if (!engines.length) return new Set<string>()
const rules: { file_types: string[]; engine: string }[] =
kbInfo.value?.chunking_config?.parser_engine_rules || []
const ruleMap = new Map<string, string>()
for (const r of rules) {
for (const ft of r.file_types) ruleMap.set(ft, r.engine)
}
const available = new Set<string>()
const availableEngineNames = new Set(
engines.filter(e => e.Available !== false).map(e => e.Name)
)
for (const engine of engines) {
for (const ft of engine.FileTypes || []) {
if (available.has(ft)) continue
const explicitEngine = ruleMap.get(ft)
if (explicitEngine) {
if (availableEngineNames.has(explicitEngine)) available.add(ft)
} else {
if (engine.Available !== false) available.add(ft)
}
}
}
return available
})
const acceptFileTypes = computed(() =>
[...supportedFileTypes.value].map(t => '.' + t).join(',')
)
const unsupportedFileTypes = computed<string[]>(() => {
const engines = parserEngines.value
if (!engines.length) return []
const allTypes = new Set<string>()
for (const engine of engines) {
for (const ft of engine.FileTypes || []) allTypes.add(ft)
}
const supported = supportedFileTypes.value
return [...allTypes].filter(ft => !supported.has(ft)).sort()
})
const goToParserSettings = () => {
if (kbId.value) {
uiStore.openKBSettings(kbId.value, 'parser')
}
}
// Permission control: check if current user owns this KB or has edit/manage permission
const isOwner = computed(() => {
@@ -121,6 +178,8 @@ const fileTypeOptions = computed(() => [
{ content: 'PDF', value: 'pdf' },
{ content: 'DOCX', value: 'docx' },
{ content: 'DOC', value: 'doc' },
{ content: 'PPTX', value: 'pptx' },
{ content: 'PPT', value: 'ppt' },
{ content: 'TXT', value: 'txt' },
{ content: 'MD', value: 'md' },
{ content: 'URL', value: 'url' },
@@ -564,15 +623,35 @@ const handleOpenURLImportDialog = (event: CustomEvent) => {
}
};
// Auto-open document detail when navigated with ?knowledge_id=xxx
const pendingKnowledgeId = ref<string | null>(
(route.query.knowledge_id as string) || null
);
const tryAutoOpenDocument = () => {
if (!pendingKnowledgeId.value || !cardList.value?.length) return;
const targetId = pendingKnowledgeId.value;
pendingKnowledgeId.value = null;
const card = cardList.value.find((c: KnowledgeCard) => c.id === targetId);
if (card) {
nextTick(() => openCardDetails(card));
} else {
nextTick(() => {
openCardDetails({ id: targetId } as KnowledgeCard);
});
}
};
onMounted(() => {
loadKnowledgeBaseInfo(kbId.value);
loadKnowledgeList();
// Load shared knowledge bases to get permission info
orgStore.fetchSharedKnowledgeBases();
// 监听文件上传事件
getParserEngines()
.then(res => { parserEngines.value = res?.data || [] })
.catch(() => { parserEngines.value = [] })
window.addEventListener('knowledgeFileUploaded', handleFileUploaded as EventListener);
// 监听URL导入对话框打开事件
window.addEventListener('openURLImportDialog', handleOpenURLImportDialog as EventListener);
});
@@ -582,6 +661,12 @@ onUnmounted(() => {
});
watch(() => cardList.value, (newValue) => {
if (isFAQ.value) return;
// Auto-open document if navigated with ?knowledge_id=xxx
if (pendingKnowledgeId.value && newValue?.length) {
tryAutoOpenDocument();
}
let analyzeList = [];
// Filter items that need polling: parsing in progress OR summary generation in progress
analyzeList = newValue.filter(item => {
@@ -780,21 +865,29 @@ const handleDocumentUpload = async (event: Event) => {
return;
}
// 过滤有效文件
const dynamicTypes = supportedFileTypes.value.size > 0 ? supportedFileTypes.value : undefined
const validFiles: File[] = [];
let skippedCount = 0;
for (let i = 0; i < files.length; i++) {
const file = files[i];
if (!kbFileTypeVerification(file, files.length > 1)) {
if (!kbFileTypeVerification(file, files.length > 1, dynamicTypes)) {
validFiles.push(file);
} else {
skippedCount++;
}
}
if (validFiles.length === 0) {
if (skippedCount > 0) {
MessagePlugin.warning(`所选文件类型暂无可用解析引擎,已全部跳过`);
}
resetUploadInput();
return;
}
if (skippedCount > 0) {
MessagePlugin.warning(`${skippedCount} 个文件因无可用解析引擎被跳过`);
}
// 批量上传
let successCount = 0;
let failCount = 0;
const totalCount = validFiles.length;
@@ -871,10 +964,9 @@ const handleFolderUpload = async (event: Event) => {
return;
}
// 检查是否启用了VLM
const vlmEnabled = kbInfo.value?.vlm_config?.enabled || false;
const dynamicTypes = supportedFileTypes.value.size > 0 ? supportedFileTypes.value : undefined
// 过滤有效文件
const validFiles: File[] = [];
let hiddenFileCount = 0;
let imageFilteredCount = 0;
@@ -883,7 +975,6 @@ const handleFolderUpload = async (event: Event) => {
const file = files[i];
const relativePath = (file as any).webkitRelativePath || file.name;
// 1. 过滤隐藏文件和隐藏文件夹
const pathParts = relativePath.split('/');
const hasHiddenComponent = pathParts.some((part: string) => part.startsWith('.'));
if (hasHiddenComponent) {
@@ -891,7 +982,6 @@ const handleFolderUpload = async (event: Event) => {
continue;
}
// 2. 如果未启用VLM,过滤图片文件
if (!vlmEnabled) {
const fileExt = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase();
const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
@@ -901,8 +991,7 @@ const handleFolderUpload = async (event: Event) => {
}
}
// 3. 文件类型验证
if (!kbFileTypeVerification(file, true)) {
if (!kbFileTypeVerification(file, true, dynamicTypes)) {
validFiles.push(file);
}
}
@@ -1111,9 +1200,8 @@ const delCardConfirm = () => {
// 处理知识库编辑成功后的回调
const handleKBEditorSuccess = (kbIdValue: string) => {
// 如果编辑的是当前知识库,刷新文件列表
if (kbIdValue === kbId.value) {
loadKnowledgeFiles(kbIdValue);
loadKnowledgeBaseInfo(kbIdValue);
}
};
@@ -1226,6 +1314,11 @@ async function createNewSession(value: string): Promise<void> {
</t-tooltip>
</div>
<p class="document-subtitle">{{ $t('knowledgeEditor.document.subtitle') }}</p>
<p v-if="unsupportedFileTypes.length" class="parser-hint" @click="goToParserSettings">
<t-icon name="info-circle" class="parser-hint-icon" />
<span>{{ $t('knowledgeBase.unsupportedTypesHint', { types: unsupportedFileTypes.map(t => '.' + t).join('、') }) }}</span>
<span class="parser-hint-link">{{ $t('knowledgeBase.goToParserSettings') }} →</span>
</p>
</div>
</div>
@@ -1233,7 +1326,7 @@ async function createNewSession(value: string): Promise<void> {
ref="uploadInputRef"
type="file"
class="document-upload-input"
accept=".pdf,.docx,.doc,.txt,.md,.jpg,.jpeg,.png,.csv,.xlsx,.xls"
:accept="acceptFileTypes || '.pdf,.docx,.doc,.txt,.md,.jpg,.jpeg,.png,.csv,.xlsx,.xls,.pptx,.ppt'"
multiple
@change="handleDocumentUpload"
/>
@@ -2197,7 +2290,7 @@ async function createNewSession(value: string): Promise<void> {
background: transparent;
border: none;
&:hover {
color: #4e5969;
color: #07C05F;
background: #f2f3f5;
}
}
@@ -2212,7 +2305,7 @@ async function createNewSession(value: string): Promise<void> {
&:hover,
&:focus,
&.t-is-focused {
border-color: #4080ff;
border-color: #07C05F;
background-color: #fff;
}
}
@@ -2226,7 +2319,7 @@ async function createNewSession(value: string): Promise<void> {
&:hover,
&.t-is-focused {
border-color: #4080ff;
border-color: #07C05F;
background-color: #fff;
}
}
@@ -2375,6 +2468,36 @@ async function createNewSession(value: string): Promise<void> {
line-height: 20px;
}
.parser-hint {
display: flex;
align-items: center;
gap: 4px;
margin: 2px 0 0;
color: #b08000;
font-size: 12px;
line-height: 1.4;
cursor: pointer;
transition: color 0.15s ease;
&:hover {
color: #8a6300;
.parser-hint-link {
text-decoration: underline;
}
}
.parser-hint-icon {
font-size: 12px;
flex-shrink: 0;
}
.parser-hint-link {
color: #07C05F;
margin-left: 2px;
white-space: nowrap;
}
}
}
@@ -119,6 +119,22 @@
</div>
</div>
<!-- 解析引擎 -->
<div v-if="!isFAQ && formData" v-show="currentSection === 'parser'" class="section">
<KBParserSettings
:parser-engine-rules="formData.chunkingConfig.parserEngineRules"
@update:parser-engine-rules="handleParserEngineRulesUpdate"
/>
</div>
<!-- 存储引擎 -->
<div v-if="!isFAQ && formData" v-show="currentSection === 'storage'" class="section">
<KBStorageSettings
:storage-provider="formData.storageProvider"
@update:storage-provider="handleStorageProviderUpdate"
/>
</div>
<!-- 分块设置 -->
<div v-if="!isFAQ" v-show="currentSection === 'chunking'" class="section">
<KBChunkingSettings
@@ -182,6 +198,8 @@ import { updateKBConfig, type KBModelConfigRequest } from '@/api/initialization'
import { listModels } from '@/api/model'
import { useUIStore } from '@/stores/ui'
import KBModelConfig from './settings/KBModelConfig.vue'
import KBParserSettings from './settings/KBParserSettings.vue'
import KBStorageSettings from './settings/KBStorageSettings.vue'
import KBChunkingSettings from './settings/KBChunkingSettings.vue'
import KBAdvancedSettings from './settings/KBAdvancedSettings.vue'
import GraphSettings from './settings/GraphSettings.vue'
@@ -220,6 +238,8 @@ const navItems = computed(() => {
items.push({ key: 'faq', icon: 'help-circle', label: t('knowledgeEditor.sidebar.faq') })
} else {
items.push(
{ key: 'parser', icon: 'file-search', label: '解析引擎' },
{ key: 'storage', icon: 'cloud', label: t('knowledgeEditor.sidebar.storage') },
{ key: 'chunking', icon: 'file-copy', label: t('knowledgeEditor.sidebar.chunking') },
{ key: 'graph', icon: 'chart-bubble', label: t('knowledgeEditor.sidebar.graph') },
{ key: 'advanced', icon: 'setting', label: t('knowledgeEditor.sidebar.advanced') }
@@ -274,25 +294,13 @@ const initFormData = (type: 'document' | 'faq' = 'document') => {
chunkingConfig: {
chunkSize: 512,
chunkOverlap: 100,
separators: ['\n\n', '\n', '。', '!', '?', ';', ';']
separators: ['\n\n', '\n', '。', '!', '?', ';', ';'],
parserEngineRules: undefined as any
},
storageProvider: 'local' as string,
multimodalConfig: {
enabled: false,
storageType: 'minio' as 'minio' | 'cos',
vllmModelId: '',
minio: {
bucketName: '',
useSSL: false,
pathPrefix: ''
},
cos: {
secretId: '',
secretKey: '',
region: '',
bucketName: '',
appId: '',
pathPrefix: ''
}
vllmModelId: ''
},
nodeExtractConfig: {
enabled: false,
@@ -363,25 +371,13 @@ const loadKBData = async () => {
chunkingConfig: {
chunkSize: kb.chunking_config?.chunk_size || 512,
chunkOverlap: kb.chunking_config?.chunk_overlap || 100,
separators: kb.chunking_config?.separators || ['\n\n', '\n', '。', '!', '?', ';', ';']
separators: kb.chunking_config?.separators || ['\n\n', '\n', '。', '!', '?', ';', ';'],
parserEngineRules: kb.chunking_config?.parser_engine_rules || undefined
},
storageProvider: (kb.cos_config?.provider || 'local') as string,
multimodalConfig: {
enabled: !!(kb.vlm_config?.enabled || (kb.cos_config?.provider && kb.cos_config?.bucket_name)),
storageType: (kb.cos_config?.provider || 'minio') as 'minio' | 'cos',
vllmModelId: kb.vlm_config?.model_id || '',
minio: {
bucketName: kb.cos_config?.bucket_name || '',
useSSL: kb.cos_config?.use_ssl || false,
pathPrefix: kb.cos_config?.path_prefix || ''
},
cos: {
secretId: kb.cos_config?.secret_id || '',
secretKey: kb.cos_config?.secret_key || '',
region: kb.cos_config?.region || '',
bucketName: kb.cos_config?.bucket_name || '',
appId: kb.cos_config?.app_id || '',
pathPrefix: kb.cos_config?.path_prefix || ''
}
enabled: !!kb.vlm_config?.enabled,
vllmModelId: kb.vlm_config?.model_id || ''
},
nodeExtractConfig: {
enabled: kb.extract_config?.enabled || false,
@@ -420,12 +416,24 @@ const handleChunkingConfigUpdate = (config: any) => {
}
}
const handleParserEngineRulesUpdate = (rules: any[]) => {
if (formData.value) {
formData.value.chunkingConfig.parserEngineRules = rules?.length ? rules : undefined
}
}
const handleMultimodalUpdate = (config: any) => {
if (formData.value) {
formData.value.multimodalConfig = { ...config }
}
}
const handleStorageProviderUpdate = (value: string) => {
if (formData.value) {
formData.value.storageProvider = value || 'local'
}
}
const handleQuestionGenerationUpdate = (config: any) => {
if (formData.value) {
formData.value.questionGenerationConfig = { ...config }
@@ -493,7 +501,10 @@ const buildSubmitData = () => {
chunk_size: formData.value.chunkingConfig.chunkSize,
chunk_overlap: formData.value.chunkingConfig.chunkOverlap,
separators: formData.value.chunkingConfig.separators,
enable_multimodal: formData.value.multimodalConfig.enabled
enable_multimodal: formData.value.multimodalConfig.enabled,
...(formData.value.chunkingConfig.parserEngineRules?.length
? { parser_engine_rules: formData.value.chunkingConfig.parserEngineRules }
: {})
},
embedding_model_id: formData.value.modelConfig.embeddingModelId,
summary_model_id: formData.value.modelConfig.llmModelId
@@ -507,26 +518,9 @@ const buildSubmitData = () => {
: ''
}
if (formData.value.multimodalConfig.enabled) {
const storageType = formData.value.multimodalConfig.storageType
if (storageType === 'minio') {
data.cos_config = {
provider: 'minio',
bucket_name: formData.value.multimodalConfig.minio.bucketName,
use_ssl: formData.value.multimodalConfig.minio.useSSL,
path_prefix: formData.value.multimodalConfig.minio.pathPrefix || undefined
}
} else {
data.cos_config = {
provider: 'cos',
secret_id: formData.value.multimodalConfig.cos.secretId,
secret_key: formData.value.multimodalConfig.cos.secretKey,
region: formData.value.multimodalConfig.cos.region,
bucket_name: formData.value.multimodalConfig.cos.bucketName,
app_id: formData.value.multimodalConfig.cos.appId,
path_prefix: formData.value.multimodalConfig.cos.pathPrefix || undefined
}
}
// 存储引擎:仅传 provider,参数从全局设置读取
data.cos_config = {
provider: formData.value.storageProvider || 'local'
}
// 添加知识图谱配置
@@ -599,7 +593,7 @@ const handleSubmit = async () => {
config: updateConfig
})
// 2. 更新完整配置(模型、分块、多模态、知识图谱等)
// 2. 更新完整配置(模型、分块、多模态、存储引擎、知识图谱等)
const config: KBModelConfigRequest = {
llmModelId: data.summary_model_id,
embeddingModelId: data.embedding_model_id,
@@ -607,25 +601,13 @@ const handleSubmit = async () => {
documentSplitting: {
chunkSize: data.chunking_config.chunk_size,
chunkOverlap: data.chunking_config.chunk_overlap,
separators: data.chunking_config.separators
separators: data.chunking_config.separators,
parserEngineRules: data.chunking_config.parser_engine_rules || undefined
},
multimodal: {
enabled: !!data.cos_config || !!data.vlm_config?.enabled,
storageType: data.cos_config?.provider || 'minio',
cos: data.cos_config?.provider === 'cos' ? {
secretId: data.cos_config.secret_id,
secretKey: data.cos_config.secret_key,
region: data.cos_config.region,
bucketName: data.cos_config.bucket_name,
appId: data.cos_config.app_id,
pathPrefix: data.cos_config.path_prefix || ''
} : undefined,
minio: data.cos_config?.provider === 'minio' ? {
bucketName: data.cos_config.bucket_name,
useSSL: data.cos_config.use_ssl || false,
pathPrefix: data.cos_config.path_prefix || ''
} : undefined
enabled: !!data.vlm_config?.enabled
},
storageProvider: data.cos_config?.provider || 'local',
nodeExtract: {
enabled: data.extract_config?.enabled || false,
text: data.extract_config?.text || '',
@@ -42,7 +42,7 @@
</div>
</div>
<!-- Multimodal feature -->
<!-- Multimodal feature:仅选择多模态模型,存储引擎在「存储引擎」页配置 -->
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.label') }}</label>
@@ -57,9 +57,8 @@
</div>
</div>
<!-- Multimodal storage configuration -->
<!-- 多模态开启时仅配置 VLLM 模型 -->
<div v-if="localMultimodal.enabled" class="subsection">
<!-- VLLM model -->
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.vllmLabel') }} <span class="required">*</span></label>
@@ -77,206 +76,6 @@
/>
</div>
</div>
<div class="subsection-header">
<h4>{{ $t('knowledgeEditor.advanced.multimodal.storageTitle') }} <span class="required">*</span></h4>
</div>
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.storageTypeLabel') }} <span class="required">*</span></label>
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.storageTypeDescription') }}</p>
<!-- Warning message when MinIO is not enabled -->
<t-alert
v-if="!isMinioEnabled"
theme="warning"
:message="$t('knowledgeEditor.advanced.multimodal.minioDisabledWarning')"
style="margin-top: 8px;"
/>
</div>
<div class="setting-control">
<t-radio-group v-model="localMultimodal.storageType" @change="handleStorageTypeChange">
<t-radio value="minio" :disabled="!isMinioEnabled">
{{ $t('knowledgeEditor.advanced.multimodal.storageTypeOptions.minio') }}
</t-radio>
<t-radio value="cos">{{ $t('knowledgeEditor.advanced.multimodal.storageTypeOptions.cos') }}</t-radio>
</t-radio-group>
</div>
</div>
<!-- MinIO configuration -->
<div v-if="localMultimodal.storageType === 'minio'" class="storage-config">
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.minio.bucketLabel') }} <span class="required">*</span></label>
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.minio.bucketDescription') }}</p>
<p class="hint">{{ $t('knowledgeEditor.advanced.multimodal.minio.bucketHint') }}</p>
</div>
<div class="setting-control bucket-control">
<t-select
v-model="localMultimodal.minio.bucketName"
:placeholder="$t('knowledgeEditor.advanced.multimodal.minio.bucketPlaceholder')"
:loading="loadingBuckets"
filterable
creatable
@change="handleConfigChange"
@focus="loadMinioBuckets"
style="width: 280px;"
>
<t-option
v-for="bucket in minioBuckets"
:key="bucket.name"
:value="bucket.name"
:label="bucket.name"
>
<div class="bucket-option">
<span class="bucket-name">{{ bucket.name }}</span>
<t-tag
:theme="bucket.policy === 'public' ? 'success' : bucket.policy === 'private' ? 'default' : 'warning'"
size="small"
variant="light"
>
{{ $t(`knowledgeEditor.advanced.multimodal.minio.policyLabels.${bucket.policy}`) }}
</t-tag>
</div>
</t-option>
</t-select>
<t-button
theme="default"
variant="outline"
size="small"
:loading="loadingBuckets"
@click="loadMinioBuckets"
style="margin-left: 8px;"
>
<template #icon><refresh-icon /></template>
</t-button>
</div>
</div>
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.minio.useSslLabel') }}</label>
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.minio.useSslDescription') }}</p>
</div>
<div class="setting-control">
<t-switch
v-model="localMultimodal.minio.useSSL"
@change="handleConfigChange"
size="large"
/>
</div>
</div>
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.minio.pathPrefixLabel') }}</label>
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.minio.pathPrefixDescription') }}</p>
</div>
<div class="setting-control">
<t-input
v-model="localMultimodal.minio.pathPrefix"
:placeholder="$t('knowledgeEditor.advanced.multimodal.minio.pathPrefixPlaceholder')"
@change="handleConfigChange"
style="width: 280px;"
/>
</div>
</div>
</div>
<!-- COS configuration -->
<div v-if="localMultimodal.storageType === 'cos'" class="storage-config">
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.cos.secretIdLabel') }} <span class="required">*</span></label>
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.cos.secretIdDescription') }}</p>
</div>
<div class="setting-control">
<t-input
v-model="localMultimodal.cos.secretId"
:placeholder="$t('knowledgeEditor.advanced.multimodal.cos.secretIdPlaceholder')"
@change="handleConfigChange"
style="width: 280px;"
/>
</div>
</div>
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.cos.secretKeyLabel') }} <span class="required">*</span></label>
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.cos.secretKeyDescription') }}</p>
</div>
<div class="setting-control">
<t-input
v-model="localMultimodal.cos.secretKey"
type="password"
:placeholder="$t('knowledgeEditor.advanced.multimodal.cos.secretKeyPlaceholder')"
@change="handleConfigChange"
style="width: 280px;"
/>
</div>
</div>
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.cos.regionLabel') }} <span class="required">*</span></label>
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.cos.regionDescription') }}</p>
</div>
<div class="setting-control">
<t-input
v-model="localMultimodal.cos.region"
:placeholder="$t('knowledgeEditor.advanced.multimodal.cos.regionPlaceholder')"
@change="handleConfigChange"
style="width: 280px;"
/>
</div>
</div>
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.cos.bucketLabel') }} <span class="required">*</span></label>
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.cos.bucketDescription') }}</p>
</div>
<div class="setting-control">
<t-input
v-model="localMultimodal.cos.bucketName"
:placeholder="$t('knowledgeEditor.advanced.multimodal.cos.bucketPlaceholder')"
@change="handleConfigChange"
style="width: 280px;"
/>
</div>
</div>
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.cos.appIdLabel') }} <span class="required">*</span></label>
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.cos.appIdDescription') }}</p>
</div>
<div class="setting-control">
<t-input
v-model="localMultimodal.cos.appId"
:placeholder="$t('knowledgeEditor.advanced.multimodal.cos.appIdPlaceholder')"
@change="handleConfigChange"
style="width: 280px;"
/>
</div>
</div>
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.cos.pathPrefixLabel') }}</label>
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.cos.pathPrefixDescription') }}</p>
</div>
<div class="setting-control">
<t-input
v-model="localMultimodal.cos.pathPrefix"
:placeholder="$t('knowledgeEditor.advanced.multimodal.cos.pathPrefixPlaceholder')"
@change="handleConfigChange"
style="width: 280px;"
/>
</div>
</div>
</div>
</div>
</div>
@@ -284,31 +83,15 @@
</template>
<script setup lang="ts">
import { ref, watch, onMounted } from 'vue'
import { RefreshIcon } from 'tdesign-icons-vue-next'
import { ref, watch } from 'vue'
import ModelSelector from '@/components/ModelSelector.vue'
import { useUIStore } from '@/stores/ui'
import { getSystemInfo, listMinioBuckets, type MinioBucketInfo } from '@/api/system'
const uiStore = useUIStore()
interface MultimodalConfig {
enabled: boolean
storageType: 'minio' | 'cos'
vllmModelId?: string
minio: {
bucketName: string
useSSL: boolean
pathPrefix: string
}
cos: {
secretId: string
secretKey: string
region: string
bucketName: string
appId: string
pathPrefix: string
}
}
interface QuestionGenerationConfig {
@@ -335,58 +118,7 @@ const localQuestionGeneration = ref<QuestionGenerationConfig>(
)
const vllmSelectorRef = ref()
const isMinioEnabled = ref(false)
const minioBuckets = ref<MinioBucketInfo[]>([])
const loadingBuckets = ref(false)
// Load MinIO buckets
const loadMinioBuckets = async () => {
if (!isMinioEnabled.value || loadingBuckets.value) return
loadingBuckets.value = true
try {
const response = await listMinioBuckets()
if (response.data?.buckets) {
minioBuckets.value = response.data.buckets
}
} catch (error) {
console.error('Failed to load MinIO buckets:', error)
} finally {
loadingBuckets.value = false
}
}
// Check system status on mount
onMounted(async () => {
try {
const systemInfo = await getSystemInfo()
// Check MinIO status
isMinioEnabled.value = systemInfo.data?.minio_enabled === true
// If MinIO is not enabled and storage type is minio, switch to cos
if (!isMinioEnabled.value && localMultimodal.value.storageType === 'minio') {
localMultimodal.value.storageType = 'cos'
emit('update:multimodal', localMultimodal.value)
}
// Load MinIO buckets if enabled
if (isMinioEnabled.value) {
loadMinioBuckets()
}
} catch (error) {
console.error('Failed to fetch system info:', error)
// Default to disabled if we can't fetch the info
isMinioEnabled.value = false
// If MinIO status unknown and storage type is minio, switch to cos
if (localMultimodal.value.storageType === 'minio') {
localMultimodal.value.storageType = 'cos'
emit('update:multimodal', localMultimodal.value)
}
}
})
// Watch for prop changes
watch(() => props.multimodal, (newVal) => {
localMultimodal.value = { ...newVal }
}, { deep: true })
@@ -397,7 +129,6 @@ watch(() => props.questionGeneration, (newVal) => {
}
}, { deep: true })
// Handle question generation toggle
const handleQuestionGenerationToggle = () => {
if (!localQuestionGeneration.value.enabled) {
localQuestionGeneration.value.questionCount = 3
@@ -405,59 +136,25 @@ const handleQuestionGenerationToggle = () => {
emit('update:questionGeneration', localQuestionGeneration.value)
}
// Handle question generation config change
const handleQuestionGenerationChange = () => {
emit('update:questionGeneration', localQuestionGeneration.value)
}
// Handle multimodal toggle
const handleMultimodalToggle = () => {
// Reset related configuration when multimodal is disabled
if (!localMultimodal.value.enabled) {
localMultimodal.value.vllmModelId = ''
localMultimodal.value.minio = {
bucketName: '',
useSSL: false,
pathPrefix: ''
}
localMultimodal.value.cos = {
secretId: '',
secretKey: '',
region: '',
bucketName: '',
appId: '',
pathPrefix: ''
}
}
emit('update:multimodal', localMultimodal.value)
}
// Handle storage type change
const handleStorageTypeChange = () => {
// Prevent switching to minio if it's not enabled
if (localMultimodal.value.storageType === 'minio' && !isMinioEnabled.value) {
localMultimodal.value.storageType = 'cos'
}
emit('update:multimodal', localMultimodal.value)
}
// Handle VLLM model change
const handleVLLMChange = (modelId: string) => {
localMultimodal.value.vllmModelId = modelId
emit('update:multimodal', localMultimodal.value)
}
// Navigate to model management when adding models
const handleAddModel = (subSection: string) => {
uiStore.openSettings('models', subSection)
}
// Handle configuration change
const handleConfigChange = () => {
emit('update:multimodal', localMultimodal.value)
}
// The allModels prop keeps model options in sync
</script>
<style lang="less" scoped>
@@ -546,104 +243,11 @@ const handleConfigChange = () => {
position: relative;
}
.subsection-header {
margin: 16px 0 8px 0;
&:first-child {
margin-top: 0;
}
h4 {
font-size: 15px;
font-weight: 600;
color: #333333;
margin: 0;
padding-left: 8px;
border-left: 2px solid #07C05F;
.required {
color: #e34d59;
margin-left: 4px;
}
}
}
.required {
color: #e34d59;
margin-left: 2px;
font-weight: 500;
}
.storage-config {
margin-top: 8px;
}
.bucket-control {
display: flex;
align-items: center;
}
.bucket-option {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
.bucket-name {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.config-item {
background: #ffffff;
border: 1px solid #e5e7eb;
border-radius: 6px;
padding: 16px;
margin-bottom: 12px;
}
.config-item-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 1px solid #f0f0f0;
}
.config-item-title {
font-size: 14px;
font-weight: 600;
color: #333333;
}
.config-item-body {
display: flex;
flex-direction: column;
gap: 12px;
}
.config-field {
display: flex;
flex-direction: column;
gap: 6px;
label {
font-size: 13px;
font-weight: 500;
color: #555555;
}
}
.subsection-desc {
font-size: 13px;
color: #666666;
margin: 4px 0 8px 8px;
line-height: 1.5;
}
</style>
@@ -77,10 +77,16 @@
import { ref, watch, computed } from 'vue'
import { useI18n } from 'vue-i18n'
interface ParserEngineRule {
file_types: string[]
engine: string
}
interface ChunkingConfig {
chunkSize: number
chunkOverlap: number
separators: string[]
parserEngineRules?: ParserEngineRule[]
}
interface Props {
@@ -98,7 +104,6 @@ const localChunkOverlap = ref(props.config.chunkOverlap)
const localSeparators = ref([...props.config.separators])
const { t } = useI18n()
// Separator options
const separatorOptions = computed(() => [
{ label: t('knowledgeEditor.chunking.separators.doubleNewline'), value: '\n\n' },
{ label: t('knowledgeEditor.chunking.separators.singleNewline'), value: '\n' },
@@ -110,34 +115,22 @@ const separatorOptions = computed(() => [
{ label: t('knowledgeEditor.chunking.separators.space'), value: ' ' }
])
// Watch for prop changes
watch(() => props.config, (newConfig) => {
localChunkSize.value = newConfig.chunkSize
localChunkOverlap.value = newConfig.chunkOverlap
localSeparators.value = [...newConfig.separators]
}, { deep: true })
// Handle chunk size change
const handleChunkSizeChange = () => {
emitUpdate()
}
const handleChunkSizeChange = () => { emitUpdate() }
const handleChunkOverlapChange = () => { emitUpdate() }
const handleSeparatorsChange = () => { emitUpdate() }
// Handle chunk overlap change
const handleChunkOverlapChange = () => {
emitUpdate()
}
// Handle separator change
const handleSeparatorsChange = () => {
emitUpdate()
}
// Emit update event
const emitUpdate = () => {
emit('update:config', {
chunkSize: localChunkSize.value,
chunkOverlap: localChunkOverlap.value,
separators: localSeparators.value
separators: localSeparators.value,
parserEngineRules: props.config.parserEngineRules
})
}
</script>
@@ -228,4 +221,3 @@ const emitUpdate = () => {
text-align: right;
}
</style>
@@ -0,0 +1,456 @@
<template>
<div class="kb-parser-settings">
<div class="section-header">
<h2>解析引擎</h2>
<p class="section-description">为不同文件类型选择文档解析引擎。未配置的文件类型将使用内置解析引擎。</p>
</div>
<div v-if="loading" class="loading-inline">
<t-loading size="small" />
<span>加载中...</span>
</div>
<div v-else-if="fileTypeGroups.length === 0" class="empty-hint">
<p>暂无可用解析引擎,或文档解析服务未配置。</p>
</div>
<div v-else class="settings-group">
<div
v-for="group in fileTypeGroups"
:key="group.key"
class="setting-row"
>
<div class="setting-info">
<label class="group-label">
<t-icon :name="group.icon" class="group-icon" />
{{ group.label }}
</label>
<div class="ext-tags">
<span v-for="ext in group.extensions" :key="ext" class="ext-tag">.{{ ext }}</span>
</div>
</div>
<div class="setting-control">
<t-select
:value="getEngineForGroup(group.extensions) || undefined"
@change="(val: string) => handleEngineChange(group.extensions, val)"
style="width: 280px;"
:status="hasAvailableEngine(group.extensions) ? 'default' : 'warning'"
placeholder="无可用引擎"
>
<t-option
v-for="opt in getEngineOptions(group.extensions)"
:key="opt.value"
:value="opt.value"
:label="opt.selectLabel"
:disabled="opt.disabled"
>
<t-tooltip
:content="`支持格式: ${opt.fileTypes.map(t => '.' + t).join(' ')}`"
placement="left"
:show-arrow="false"
>
<div class="engine-option">
<div class="engine-option-top">
<span class="engine-option-name">{{ opt.value }}</span>
<t-tag
v-if="opt.isDefault"
theme="primary"
variant="light"
size="small"
>默认</t-tag>
<t-tag
v-if="opt.disabled"
theme="danger"
variant="light"
size="small"
>不可用</t-tag>
</div>
<div class="engine-option-desc">{{ opt.desc }}</div>
<div v-if="opt.disabled && opt.reason" class="engine-option-reason">
{{ opt.reason }}
<a class="go-settings" @click.stop.prevent="goToParserSettings">去设置 →</a>
</div>
</div>
</t-tooltip>
</t-option>
</t-select>
<div v-if="!hasAvailableEngine(group.extensions)" class="no-engine-warning">
<a class="go-settings" @click.prevent="goToParserSettings">前往配置 →</a>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, watch, computed, onMounted, onUnmounted } from 'vue'
import { getParserEngines, type ParserEngineInfo } from '@/api/system'
import { useUIStore } from '@/stores/ui'
import { storeToRefs } from 'pinia'
export interface ParserEngineRule {
file_types: string[]
engine: string
}
interface EngineOption {
value: string
selectLabel: string
desc: string
fileTypes: string[]
disabled: boolean
isDefault: boolean
reason?: string
}
interface Props {
parserEngineRules?: ParserEngineRule[]
}
const props = withDefaults(defineProps<Props>(), {
parserEngineRules: () => []
})
const emit = defineEmits<{
'update:parserEngineRules': [value: ParserEngineRule[]]
}>()
const uiStore = useUIStore()
const localEngineRules = ref<ParserEngineRule[]>([...props.parserEngineRules])
const parserEngines = ref<ParserEngineInfo[]>([])
const loading = ref(true)
const allFileTypes = computed(() => {
const s = new Set<string>()
for (const engine of parserEngines.value) {
for (const ft of engine.FileTypes || []) {
s.add(ft)
}
}
return s
})
const fileTypeGroups = computed(() => {
const ft = allFileTypes.value
const groups: { key: string; label: string; icon: string; extensions: string[] }[] = []
const pdfExts = ['pdf'].filter(e => ft.has(e))
const officeExts = ['docx', 'doc'].filter(e => ft.has(e))
const pptExts = ['pptx', 'ppt'].filter(e => ft.has(e))
const excelExts = ['xlsx', 'xls'].filter(e => ft.has(e))
const csvExts = ['csv'].filter(e => ft.has(e))
const mdExts = ['md', 'markdown'].filter(e => ft.has(e))
const txtExts = ['txt'].filter(e => ft.has(e))
const imageExts = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff', 'webp'].filter(e => ft.has(e))
if (pdfExts.length) groups.push({ key: 'pdf', label: 'PDF 文档', icon: 'file-pdf', extensions: pdfExts })
if (officeExts.length) groups.push({ key: 'office', label: 'Word 文档', icon: 'file-word', extensions: officeExts })
if (pptExts.length) groups.push({ key: 'ppt', label: '演示文稿', icon: 'file-powerpoint', extensions: pptExts })
if (excelExts.length) groups.push({ key: 'excel', label: 'Excel 表格', icon: 'file-excel', extensions: excelExts })
if (csvExts.length) groups.push({ key: 'csv', label: 'CSV 文件', icon: 'file-excel', extensions: csvExts })
if (mdExts.length) groups.push({ key: 'markdown', label: 'Markdown', icon: 'file-code', extensions: mdExts })
if (txtExts.length) groups.push({ key: 'text', label: '纯文本', icon: 'file', extensions: txtExts })
if (imageExts.length) groups.push({ key: 'image', label: '图片', icon: 'image', extensions: imageExts })
return groups
})
function getEngineOptions(extensions: string[]): EngineOption[] {
const raw: { name: string; desc: string; fileTypes: string[]; available: boolean; reason: string }[] = []
for (const engine of parserEngines.value) {
const supports = extensions.some(ext => (engine.FileTypes || []).includes(ext))
if (supports) {
raw.push({
name: engine.Name,
desc: engine.Description || engine.Name,
fileTypes: engine.FileTypes || [],
available: engine.Available !== false,
reason: engine.UnavailableReason || '',
})
}
}
const defaultName = raw.find(e => e.available)?.name ?? ''
return raw.map(e => ({
value: e.name,
selectLabel: `${e.name} — ${e.desc}`,
desc: e.desc,
fileTypes: e.fileTypes,
disabled: !e.available,
isDefault: defaultName !== '' && e.name === defaultName,
reason: e.reason,
}))
}
function hasAvailableEngine(extensions: string[]): boolean {
return getEngineOptions(extensions).some(opt => !opt.disabled)
}
function getDefaultEngine(extensions: string[]): string {
const opts = getEngineOptions(extensions)
return opts.find(o => o.isDefault)?.value ?? ''
}
function getEngineForGroup(extensions: string[]): string {
for (const rule of localEngineRules.value) {
if (rule.file_types.some(ft => extensions.includes(ft))) {
return rule.engine
}
}
return getDefaultEngine(extensions)
}
function handleEngineChange(extensions: string[], engine: string) {
const otherRules = localEngineRules.value.filter(
r => !r.file_types.some(ft => extensions.includes(ft))
)
if (engine) {
otherRules.push({ file_types: [...extensions], engine })
}
localEngineRules.value = otherRules
emit('update:parserEngineRules', buildCompleteRules())
}
function buildCompleteRules(): ParserEngineRule[] {
const rules: ParserEngineRule[] = []
for (const group of fileTypeGroups.value) {
const engine = getEngineForGroup(group.extensions)
if (engine) {
rules.push({ file_types: [...group.extensions], engine })
}
}
return rules
}
function goToParserSettings() {
uiStore.openSettings('parser')
}
async function loadEngines() {
loading.value = true
try {
const resp = await getParserEngines()
if (resp?.data && Array.isArray(resp.data)) {
parserEngines.value = resp.data
}
} catch {
parserEngines.value = []
} finally {
loading.value = false
ensureCompleteRules()
}
}
function ensureCompleteRules() {
if (!parserEngines.value.length) return
const complete = buildCompleteRules()
if (complete.length && complete.length > localEngineRules.value.length) {
localEngineRules.value = complete
emit('update:parserEngineRules', complete)
}
}
onMounted(loadEngines)
const { showSettingsModal } = storeToRefs(uiStore)
watch(showSettingsModal, (open, wasOpen) => {
if (wasOpen && !open) {
loadEngines()
}
})
watch(() => props.parserEngineRules, (v) => {
localEngineRules.value = v?.length ? [...v] : []
}, { deep: true })
</script>
<style lang="less" scoped>
.kb-parser-settings {
width: 100%;
}
.section-header {
margin-bottom: 32px;
h2 {
font-size: 20px;
font-weight: 600;
color: #333;
margin: 0 0 8px 0;
}
.section-description {
font-size: 14px;
color: #666;
margin: 0;
line-height: 1.5;
}
}
.loading-inline {
display: flex;
align-items: center;
gap: 8px;
padding: 16px 0;
}
.empty-hint {
padding: 24px 0;
color: #666;
}
.settings-group {
display: flex;
flex-direction: column;
gap: 0;
}
.setting-row {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 20px 0;
border-bottom: 1px solid #e5e7eb;
&:last-child {
border-bottom: none;
}
}
.setting-info {
flex: 1;
max-width: 65%;
padding-right: 24px;
.group-label {
display: flex;
align-items: center;
gap: 6px;
}
.group-icon {
font-size: 18px;
color: #555;
flex-shrink: 0;
}
label {
font-size: 15px;
font-weight: 500;
color: #333;
display: block;
margin-bottom: 4px;
}
.ext-tags {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 6px;
}
.ext-tag {
display: inline-block;
font-size: 12px;
line-height: 1;
color: #555;
background: #f3f4f6;
padding: 3px 8px;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.desc {
font-size: 13px;
color: #666;
margin: 0;
line-height: 1.5;
}
}
.setting-control {
flex-shrink: 0;
min-width: 280px;
display: flex;
flex-direction: column;
align-items: flex-end;
}
.no-engine-warning {
display: flex;
align-items: center;
gap: 4px;
margin-top: 8px;
font-size: 12px;
color: #e37318;
line-height: 1.4;
.go-settings {
color: #07C05F;
cursor: pointer;
white-space: nowrap;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
}
// ---- 下拉选项样式 ----
.engine-option {
display: flex;
flex-direction: column;
gap: 3px;
padding: 3px 0;
}
.engine-option-top {
display: flex;
align-items: center;
gap: 6px;
}
.engine-option-name {
font-size: 13px;
font-weight: 600;
color: #333;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.engine-option-desc {
font-size: 12px;
color: #888;
line-height: 1.4;
}
.engine-option-reason {
font-size: 12px;
color: #e34d59;
line-height: 1.4;
.go-settings {
color: #07C05F;
cursor: pointer;
margin-left: 4px;
font-size: 12px;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
}
</style>
<style lang="less">
.t-select__dropdown .t-select-option {
height: auto;
align-items: flex-start;
padding-top: 6px;
padding-bottom: 6px;
}
.t-select__dropdown .t-select-option__content {
white-space: normal;
}
</style>
@@ -0,0 +1,244 @@
<template>
<div class="kb-storage-settings">
<div class="section-header">
<h2>存储引擎</h2>
<p class="section-description">
选择文件存储引擎,影响文档上传存储和文档中图片的存储方式。参数在全局设置中配置。
</p>
</div>
<div v-if="loading" class="loading-inline">
<t-loading size="small" />
<span>加载中...</span>
</div>
<div v-else class="settings-group">
<div class="setting-row">
<div class="setting-info">
<label>存储引擎</label>
<p class="desc">选择该知识库使用的存储引擎,需在全局设置中已配置对应引擎。</p>
</div>
<div class="setting-control">
<t-select
v-model="localProvider"
size="medium"
placeholder="请选择存储引擎"
style="width: 100%; min-width: 220px;"
@change="handleChange"
>
<t-option
v-for="opt in engineOptions"
:key="opt.value"
:value="opt.value"
:label="opt.label"
:disabled="opt.disabled"
>
<span class="select-option">
<span>{{ opt.label }}</span>
<t-tag v-if="opt.disabled" theme="warning" variant="light" size="small">未配置</t-tag>
<t-tag v-else-if="opt.available === false" theme="danger" variant="light" size="small">不可用</t-tag>
</span>
</t-option>
</t-select>
<p v-if="selectedOption?.desc" class="option-hint">{{ selectedOption.desc }}</p>
<a v-if="showGoSettings" href="javascript:void(0)" class="go-settings" @click.prevent="goToStorageSettings">去全局设置中配置</a>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, computed, watch, onMounted } from 'vue'
import { getStorageEngineConfig, getStorageEngineStatus, type StorageEngineStatusItem } from '@/api/system'
import { useUIStore } from '@/stores/ui'
const props = defineProps<{
storageProvider: string
}>()
const emit = defineEmits<{
'update:storageProvider': [value: string]
}>()
const uiStore = useUIStore()
const localProvider = ref(props.storageProvider || 'local')
const loading = ref(true)
const engineStatus = ref<StorageEngineStatusItem[]>([])
const defaultProvider = ref('local')
const hasAnyConfig = ref(false)
const engineOptions = computed(() => {
const statusMap: Record<string, boolean> = {}
for (const e of engineStatus.value) {
statusMap[e.name] = e.available
}
return [
{
value: 'local',
label: 'Local(本地存储)',
desc: '仅适合单机部署,简单轻量',
available: statusMap.local !== false,
disabled: false,
},
{
value: 'minio',
label: 'MinIO',
desc: 'S3 兼容,适合内网或私有云',
available: statusMap.minio,
disabled: statusMap.minio === false,
},
{
value: 'cos',
label: '腾讯云 COS',
desc: '公有云部署,支持 CDN 加速',
available: statusMap.cos,
disabled: statusMap.cos === false,
},
]
})
const showGoSettings = computed(() =>
engineOptions.value.some(o => o.disabled)
)
const selectedOption = computed(() =>
engineOptions.value.find(o => o.value === localProvider.value)
)
function handleChange() {
emit('update:storageProvider', localProvider.value)
}
function goToStorageSettings() {
uiStore.closeKBEditor?.()
uiStore.openSettings?.('storage')
}
async function load() {
loading.value = true
try {
const [configRes, statusRes] = await Promise.all([
getStorageEngineConfig(),
getStorageEngineStatus(),
])
const engines = statusRes?.data?.engines ?? []
engineStatus.value = engines
defaultProvider.value = configRes?.data?.default_provider || 'local'
const d = configRes?.data
hasAnyConfig.value = !!(d?.local?.path_prefix || d?.minio?.bucket_name || d?.cos?.bucket_name)
if (!localProvider.value || localProvider.value === '') {
localProvider.value = defaultProvider.value
emit('update:storageProvider', localProvider.value)
}
} catch {
engineStatus.value = []
} finally {
loading.value = false
}
}
watch(() => props.storageProvider, (v) => {
localProvider.value = v || defaultProvider.value || 'local'
}, { immediate: true })
onMounted(load)
</script>
<style lang="less" scoped>
.kb-storage-settings {
width: 100%;
}
.section-header {
margin-bottom: 32px;
h2 {
font-size: 20px;
font-weight: 600;
color: #333;
margin: 0 0 8px 0;
}
.section-description {
font-size: 14px;
color: #666;
margin: 0;
line-height: 1.5;
}
}
.loading-inline {
display: flex;
align-items: center;
gap: 8px;
padding: 16px 0;
}
.settings-group {
display: flex;
flex-direction: column;
}
.setting-row {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 20px 0;
border-bottom: 1px solid #e5e7eb;
}
.setting-info {
flex: 1;
max-width: 65%;
padding-right: 24px;
label {
font-size: 15px;
font-weight: 500;
color: #333;
display: block;
margin-bottom: 4px;
}
.desc {
font-size: 13px;
color: #666;
margin: 0;
line-height: 1.5;
}
}
.setting-control {
flex-shrink: 0;
min-width: 280px;
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 6px;
}
.select-option {
display: inline-flex;
align-items: center;
gap: 8px;
}
.option-hint {
font-size: 12px;
color: #999;
margin: 0;
line-height: 1.4;
}
.go-settings {
font-size: 13px;
color: var(--td-brand-color, #0052d9);
margin-top: 8px;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
</style>
+1 -1
View File
@@ -3,7 +3,7 @@
<Menu></Menu>
<RouterView />
<div class="upload-mask" v-show="ismask">
<input type="file" style="display: none" ref="uploadInput" accept=".pdf,.docx,.doc,.txt,.md,.jpg,.jpeg,.png,.csv,.xls,.xlsx" />
<input type="file" style="display: none" ref="uploadInput" accept=".pdf,.docx,.doc,.pptx,.ppt,.txt,.md,.jpg,.jpeg,.png,.csv,.xls,.xlsx" />
<UploadMask></UploadMask>
</div>
<!-- 全局设置模态框,供所有 platform 子路由使用 -->
@@ -0,0 +1,610 @@
<template>
<div class="parser-engine-settings">
<div class="section-header">
<h2>解析引擎</h2>
<p class="section-description">
文档解析引擎状态及配置。此处设置优先于服务端环境变量,留空则使用环境变量默认值。
</p>
</div>
<div v-if="loading" class="loading-state">
<t-loading size="small" />
<span>加载中...</span>
</div>
<div v-else-if="error" class="error-inline">
<t-alert theme="error" :message="error">
<template #operation>
<t-button size="small" @click="loadAll">重试</t-button>
</template>
</t-alert>
</div>
<template v-else>
<!-- 引擎列表 -->
<div class="engine-section">
<div v-if="engines.length === 0" class="empty-state">
<p class="empty-text">未检测到解析引擎,请确认 DocReader 服务正常运行。</p>
</div>
<div v-else class="engine-grid">
<!-- DocReader 未连接时显示占位卡片 -->
<div v-if="!hasBuiltinEngine" class="engine-card unavailable">
<div class="card-header">
<span class="card-name">builtin</span>
<t-tag theme="danger" variant="light" size="small">未连接</t-tag>
</div>
<p class="card-desc">DocReader 内置解析引擎(docx/pdf/xlsx 等复杂格式)</p>
<div class="docreader-inline">
<div class="status-line">
<t-tag theme="danger" variant="light" size="small">未连接</t-tag>
<t-tag theme="default" variant="light" size="small">{{ docreaderTransport === 'http' ? 'HTTP' : 'gRPC' }}</t-tag>
<span v-if="docreaderAddrEnv" class="env-hint">当前: {{ docreaderAddrEnv }}</span>
</div>
<p class="desc docreader-desc">
修改请设置环境变量 <code>DOCREADER_ADDR</code>、<code>DOCREADER_TRANSPORT</code>(grpc/http),重启服务生效。
</p>
</div>
</div>
<div
v-for="engine in sortedEngines"
:key="engine.Name"
:class="['engine-card', { unavailable: !engine.Available }]"
>
<div class="card-header">
<span class="card-name">{{ engine.Name }}</span>
<t-tag v-if="engine.Available" theme="success" variant="light" size="small">可用</t-tag>
<t-tooltip v-else-if="engine.UnavailableReason" :content="engine.UnavailableReason" placement="top">
<t-tag theme="danger" variant="light" size="small" class="tag-with-tooltip">不可用</t-tag>
</t-tooltip>
<t-tag v-else theme="danger" variant="light" size="small">不可用</t-tag>
<a
v-if="engineDocLink(engine.Name)"
:href="engineDocLink(engine.Name)"
target="_blank"
rel="noopener noreferrer"
class="card-doc-link"
>{{ engineDocLabel(engine.Name) }} ↗</a>
</div>
<p class="card-desc">{{ engine.Description }}</p>
<!-- builtin 引擎:内嵌 DocReader 连接信息 -->
<div v-if="engine.Name === 'builtin'" class="docreader-inline">
<div class="status-line">
<t-tag v-if="connected" theme="success" variant="light" size="small">已连接</t-tag>
<t-tag v-else theme="danger" variant="light" size="small">未连接</t-tag>
<t-tag theme="default" variant="light" size="small">{{ docreaderTransport === 'http' ? 'HTTP' : 'gRPC' }}</t-tag>
<span v-if="docreaderAddrEnv" class="env-hint">当前: {{ docreaderAddrEnv }}</span>
</div>
<p class="desc docreader-desc">
修改请设置环境变量 <code>DOCREADER_ADDR</code>、<code>DOCREADER_TRANSPORT</code>(grpc/http),重启服务生效。
</p>
</div>
<div class="card-types">
<t-tag
v-for="ft in (engine.FileTypes || [])"
:key="ft"
size="small"
variant="light"
theme="default"
>{{ ft }}</t-tag>
</div>
<!-- mineru 自建配置 -->
<div v-if="engine.Name === 'mineru'" class="card-config">
<div class="config-item">
<label>自建端点</label>
<t-input
v-model="config.mineru_endpoint"
size="small"
placeholder="如 https://your-mineru.example.com"
clearable
/>
</div>
<div class="config-item">
<label>Backend</label>
<t-select v-model="config.mineru_model" size="small" placeholder="默认 pipeline" clearable>
<t-option value="pipeline" label="pipeline" />
<t-option value="vlm-auto-engine" label="vlm-auto-engine" />
<t-option value="vlm-http-client" label="vlm-http-client" />
<t-option value="hybrid-auto-engine" label="hybrid-auto-engine" />
<t-option value="hybrid-http-client" label="hybrid-http-client" />
</t-select>
</div>
<div class="config-toggles">
<t-checkbox v-model="config.mineru_enable_formula">公式识别</t-checkbox>
<t-checkbox v-model="config.mineru_enable_table">表格识别</t-checkbox>
<t-checkbox v-model="config.mineru_enable_ocr">OCR</t-checkbox>
</div>
<div class="config-item">
<label>语言</label>
<t-input
v-model="config.mineru_language"
size="small"
placeholder="如 ch、en、ja(默认 ch)"
clearable
/>
</div>
</div>
<!-- mineru_cloud 云 API 配置 -->
<div v-if="engine.Name === 'mineru_cloud'" class="card-config">
<div class="config-item">
<label>API Key</label>
<t-input
v-model="config.mineru_api_key"
size="small"
type="password"
placeholder="MinerU 云服务 API Key"
clearable
/>
</div>
<div class="config-item">
<label>API 地址</label>
<t-input
v-model="config.mineru_api_base_url"
size="small"
placeholder="如 https://api.mineru.net"
clearable
/>
</div>
<div class="config-item">
<label>Model Version</label>
<t-select v-model="config.mineru_cloud_model" size="small" placeholder="默认 pipeline" clearable>
<t-option value="pipeline" label="pipeline" />
<t-option value="vlm" label="vlm(视觉语言模型)" />
<t-option value="MinerU-HTML" label="MinerU-HTML(HTML 解析)" />
</t-select>
</div>
<div class="config-toggles">
<t-checkbox v-model="config.mineru_cloud_enable_formula">公式识别</t-checkbox>
<t-checkbox v-model="config.mineru_cloud_enable_table">表格识别</t-checkbox>
<t-checkbox v-model="config.mineru_cloud_enable_ocr">OCR</t-checkbox>
</div>
<div class="config-item">
<label>语言</label>
<t-input
v-model="config.mineru_cloud_language"
size="small"
placeholder="如 ch、en、ja(默认 ch)"
clearable
/>
</div>
</div>
</div>
</div>
</div>
<!-- 检测与保存 -->
<div class="save-bar">
<t-button theme="default" variant="outline" :loading="checking" @click="onCheck">
使用当前参数检测
</t-button>
<t-button theme="primary" :loading="saving" @click="onSave">保存配置</t-button>
<span v-if="checkMessage" class="save-msg hint">{{ checkMessage }}</span>
<span v-else-if="saveMessage" :class="['save-msg', saveSuccess ? 'success' : 'error']">
{{ saveMessage }}
</span>
</div>
</template>
</div>
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import {
getParserEngines,
getParserEngineConfig,
updateParserEngineConfig,
checkParserEngines,
type ParserEngineInfo,
type ParserEngineConfig,
} from '@/api/system'
const CONFIGURABLE_ENGINES = new Set(['mineru', 'mineru_cloud'])
/** 各解析引擎的项目/官方文档地址 */
const ENGINE_DOC_LINKS: Record<string, { url: string; label: string }> = {
markitdown: { url: 'https://github.com/microsoft/markitdown', label: 'Markitdown 文档' },
mineru: { url: 'https://github.com/opendatalab/MinerU', label: 'MinerU 文档' },
mineru_cloud: { url: 'https://mineru.net/apiManage/docs', label: 'MinerU 文档' },
}
/** 解析引擎配置默认值(与 DocReader/Python 侧一致) */
const DEFAULT_PARSER_CONFIG: ParserEngineConfig = {
docreader_addr: '',
docreader_transport: 'grpc',
mineru_endpoint: '',
mineru_api_key: '',
mineru_api_base_url: 'https://mineru.net/api/v4',
mineru_model: 'pipeline',
mineru_enable_formula: true,
mineru_enable_table: true,
mineru_enable_ocr: true,
mineru_language: 'ch',
mineru_cloud_model: 'pipeline',
mineru_cloud_enable_formula: true,
mineru_cloud_enable_table: true,
mineru_cloud_enable_ocr: true,
mineru_cloud_language: 'ch',
}
const engines = ref<ParserEngineInfo[]>([])
const docreaderAddrEnv = ref('')
const docreaderTransport = ref<'grpc' | 'http'>('grpc')
const connected = ref(false)
const loading = ref(true)
const error = ref('')
const config = ref<ParserEngineConfig>({ ...DEFAULT_PARSER_CONFIG })
const saving = ref(false)
const saveMessage = ref('')
const saveSuccess = ref(false)
const checking = ref(false)
const checkMessage = ref('')
const hasBuiltinEngine = computed(() => engines.value.some(e => e.Name === 'builtin'))
/** 固定展示顺序,未列出的引擎排在末尾按名称排序 */
const ENGINE_ORDER: Record<string, number> = {
builtin: 0,
simple: 1,
markitdown: 2,
mineru: 3,
mineru_cloud: 4,
}
const sortedEngines = computed(() => {
return [...engines.value].sort((a, b) => {
const oa = ENGINE_ORDER[a.Name] ?? 100
const ob = ENGINE_ORDER[b.Name] ?? 100
if (oa !== ob) return oa - ob
return a.Name.localeCompare(b.Name)
})
})
function hasConfigFields(engineName: string): boolean {
return CONFIGURABLE_ENGINES.has(engineName)
}
function engineDocLink(name: string): string | undefined {
return ENGINE_DOC_LINKS[name]?.url
}
function engineDocLabel(name: string): string {
return ENGINE_DOC_LINKS[name]?.label ?? '文档'
}
async function loadEngines() {
try {
const res = await getParserEngines()
engines.value = res?.data ?? []
docreaderAddrEnv.value = res?.docreader_addr ?? ''
const t = (res?.docreader_transport ?? 'grpc').toLowerCase()
docreaderTransport.value = t === 'http' ? 'http' : 'grpc'
connected.value = res?.connected ?? (engines.value.length > 0)
} catch (e: any) {
error.value = e?.message || '加载解析引擎列表失败'
engines.value = []
connected.value = false
}
}
async function loadConfig() {
try {
const res = await getParserEngineConfig()
const data = res?.data
config.value = {
docreader_addr: data?.docreader_addr ?? DEFAULT_PARSER_CONFIG.docreader_addr ?? '',
docreader_transport: data?.docreader_transport ?? DEFAULT_PARSER_CONFIG.docreader_transport ?? 'grpc',
mineru_endpoint: data?.mineru_endpoint ?? DEFAULT_PARSER_CONFIG.mineru_endpoint ?? '',
mineru_api_key: data?.mineru_api_key ?? DEFAULT_PARSER_CONFIG.mineru_api_key ?? '',
mineru_api_base_url: data?.mineru_api_base_url ?? DEFAULT_PARSER_CONFIG.mineru_api_base_url ?? '',
mineru_model: data?.mineru_model ?? DEFAULT_PARSER_CONFIG.mineru_model ?? '',
mineru_enable_formula: data?.mineru_enable_formula ?? DEFAULT_PARSER_CONFIG.mineru_enable_formula ?? true,
mineru_enable_table: data?.mineru_enable_table ?? DEFAULT_PARSER_CONFIG.mineru_enable_table ?? true,
mineru_enable_ocr: data?.mineru_enable_ocr ?? DEFAULT_PARSER_CONFIG.mineru_enable_ocr ?? true,
mineru_language: data?.mineru_language ?? DEFAULT_PARSER_CONFIG.mineru_language ?? 'ch',
mineru_cloud_model: data?.mineru_cloud_model ?? DEFAULT_PARSER_CONFIG.mineru_cloud_model ?? '',
mineru_cloud_enable_formula: data?.mineru_cloud_enable_formula ?? DEFAULT_PARSER_CONFIG.mineru_cloud_enable_formula ?? true,
mineru_cloud_enable_table: data?.mineru_cloud_enable_table ?? DEFAULT_PARSER_CONFIG.mineru_cloud_enable_table ?? true,
mineru_cloud_enable_ocr: data?.mineru_cloud_enable_ocr ?? DEFAULT_PARSER_CONFIG.mineru_cloud_enable_ocr ?? true,
mineru_cloud_language: data?.mineru_cloud_language ?? DEFAULT_PARSER_CONFIG.mineru_cloud_language ?? 'ch',
}
} catch {
config.value = { ...DEFAULT_PARSER_CONFIG }
}
}
async function loadAll() {
loading.value = true
error.value = ''
await Promise.all([loadEngines(), loadConfig()])
loading.value = false
}
function buildConfigPayload(): ParserEngineConfig {
return {
docreader_addr: config.value.docreader_addr?.trim() ?? '',
docreader_transport: (config.value.docreader_transport ?? 'grpc').trim() || 'grpc',
mineru_endpoint: config.value.mineru_endpoint?.trim() ?? '',
mineru_api_key: config.value.mineru_api_key?.trim() ?? '',
mineru_api_base_url: config.value.mineru_api_base_url?.trim() ?? '',
mineru_model: config.value.mineru_model?.trim() ?? '',
mineru_enable_formula: config.value.mineru_enable_formula,
mineru_enable_table: config.value.mineru_enable_table,
mineru_enable_ocr: config.value.mineru_enable_ocr,
mineru_language: config.value.mineru_language?.trim() ?? '',
mineru_cloud_model: config.value.mineru_cloud_model?.trim() ?? '',
mineru_cloud_enable_formula: config.value.mineru_cloud_enable_formula,
mineru_cloud_enable_table: config.value.mineru_cloud_enable_table,
mineru_cloud_enable_ocr: config.value.mineru_cloud_enable_ocr,
mineru_cloud_language: config.value.mineru_cloud_language?.trim() ?? '',
}
}
async function onCheck() {
if (!connected) {
checkMessage.value = '请先确保 DocReader 服务已通过环境变量配置并已连接'
return
}
checking.value = true
checkMessage.value = ''
try {
const res = await checkParserEngines(buildConfigPayload())
engines.value = res?.data ?? []
checkMessage.value = '已使用当前填写参数检测,上方状态已更新'
setTimeout(() => { checkMessage.value = '' }, 3000)
} catch (e: any) {
checkMessage.value = e?.message || '检测失败'
} finally {
checking.value = false
}
}
async function onSave() {
saving.value = true
saveMessage.value = ''
try {
await updateParserEngineConfig(buildConfigPayload())
saveSuccess.value = true
saveMessage.value = '保存成功'
loadEngines()
} catch (e: any) {
saveSuccess.value = false
saveMessage.value = e?.message || '保存失败'
} finally {
saving.value = false
}
}
onMounted(loadAll)
</script>
<style lang="less" scoped>
.parser-engine-settings {
width: 100%;
}
// ---- 页面标题 ----
.section-header {
margin-bottom: 32px;
h2 {
font-size: 20px;
font-weight: 600;
color: #333;
margin: 0 0 8px 0;
}
.section-description {
font-size: 14px;
color: #666;
margin: 0;
line-height: 1.5;
}
}
// ---- 加载 / 错误 ----
.loading-state {
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
padding: 48px 0;
color: #999;
font-size: 14px;
}
.error-inline {
padding: 16px 0;
}
.docreader-inline {
padding: 10px 12px;
background: #f7f8fa;
border-radius: 6px;
.status-line {
margin-bottom: 6px;
}
}
.docreader-desc {
margin: 0;
font-size: 12px;
color: #888;
line-height: 1.6;
code {
padding: 1px 5px;
font-size: 11px;
background: #eee;
border-radius: 3px;
}
}
.card-doc-link {
margin-left: auto;
font-size: 12px;
color: #999;
text-decoration: none;
white-space: nowrap;
&:hover {
color: var(--td-brand-color, #0052d9);
}
}
.status-line {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.env-hint {
font-size: 12px;
color: #999;
}
// ---- 引擎列表 ----
.engine-section {
margin-top: 0;
}
.engine-grid {
columns: 2;
column-gap: 12px;
@media (max-width: 860px) {
columns: 1;
}
}
.engine-card {
break-inside: avoid;
margin-bottom: 12px;
padding: 16px;
border: 1px solid #e5e7eb;
border-radius: 8px;
background: #fff;
transition: border-color 0.2s;
display: flex;
flex-direction: column;
gap: 8px;
&:hover {
border-color: #c0c4cc;
}
&.unavailable {
background: #fafafa;
}
}
.card-header {
display: flex;
align-items: center;
gap: 8px;
}
.card-name {
font-size: 15px;
font-weight: 600;
color: #333;
font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
}
.card-desc {
font-size: 13px;
color: #666;
margin: 0;
line-height: 1.5;
}
.card-types {
display: flex;
flex-wrap: wrap;
gap: 4px;
}
.card-reason {
font-size: 12px;
color: #e34d59;
margin: 0;
}
// ---- 卡片内配置区 ----
.card-config {
margin-top: 4px;
padding-top: 12px;
border-top: 1px dashed #e5e7eb;
display: flex;
flex-direction: column;
gap: 10px;
}
.config-item {
display: flex;
flex-direction: column;
gap: 4px;
label {
font-size: 12px;
font-weight: 500;
color: #555;
}
}
.config-toggles {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
// ---- 空状态 ----
.empty-state {
padding: 48px 0;
text-align: center;
.empty-text {
font-size: 14px;
color: #999;
margin: 0;
}
}
// ---- 保存栏 ----
.save-bar {
display: flex;
align-items: center;
gap: 12px;
margin-top: 24px;
padding-top: 24px;
border-top: 1px solid #e5e7eb;
}
.save-msg {
font-size: 13px;
&.success {
color: #52c41a;
}
&.error {
color: #ff4d4f;
}
&.hint {
color: #666;
}
}
.tag-with-tooltip {
cursor: help;
}
</style>
+14
View File
@@ -94,6 +94,16 @@
<WebSearchSettings />
</div>
<!-- 解析引擎 -->
<div v-if="currentSection === 'parser'" class="section">
<ParserEngineSettings />
</div>
<!-- 存储引擎 -->
<div v-if="currentSection === 'storage'" class="section">
<StorageEngineSettings />
</div>
<!-- 系统信息 -->
<div v-if="currentSection === 'system'" class="section">
<SystemInfo />
@@ -135,6 +145,8 @@ import ModelSettings from './ModelSettings.vue'
import OllamaSettings from './OllamaSettings.vue'
import McpSettings from './McpSettings.vue'
import WebSearchSettings from './WebSearchSettings.vue'
import ParserEngineSettings from './ParserEngineSettings.vue'
import StorageEngineSettings from './StorageEngineSettings.vue'
const route = useRoute()
const router = useRouter()
@@ -160,6 +172,8 @@ const navItems = computed(() => [
},
{ key: 'ollama', icon: 'server', label: 'Ollama' },
{ key: 'websearch', icon: 'search', label: t('settings.webSearchConfig') },
{ key: 'parser', icon: 'file-search', label: '解析引擎' },
{ key: 'storage', icon: 'cloud', label: t('settings.storageEngine') },
{ key: 'mcp', icon: 'tools', label: t('settings.mcpService') },
{ key: 'system', icon: 'info-circle', label: t('settings.systemSettings') },
{ key: 'tenant', icon: 'user-circle', label: t('settings.tenantInfo') },
@@ -0,0 +1,739 @@
<template>
<div class="storage-engine-settings">
<div class="section-header">
<h2>存储引擎</h2>
<p class="section-description">
配置文档与图片的存储方式。此处设置各引擎参数,知识库中仅选择使用哪个引擎。存储引擎会影响文档上传存储以及文档内图片的存储。
</p>
</div>
<div v-if="loading" class="loading-state">
<t-loading size="small" />
<span>加载中...</span>
</div>
<div v-else-if="error" class="error-inline">
<t-alert theme="error" :message="error">
<template #operation>
<t-button size="small" @click="loadAll">重试</t-button>
</template>
</t-alert>
</div>
<template v-else>
<div class="engine-section">
<div class="section-title-row">
<div class="section-title-info">
<h3>引擎配置</h3>
<p>为每种存储引擎配置参数,知识库创建或编辑时选择使用哪个引擎。</p>
</div>
</div>
<div class="engine-list">
<!-- Local -->
<div class="engine-block">
<div class="block-header">
<span class="block-name">Local(本地存储)</span>
<t-tag theme="success" variant="light" size="small">可用</t-tag>
</div>
<p class="block-desc">使用服务器本地文件系统存储文件,仅适合单机部署。</p>
<div class="block-config">
<div class="config-item">
<label>路径前缀(可选)</label>
<t-input
v-model="config.local.path_prefix"
size="small"
placeholder="如 weknora/images"
clearable
/>
</div>
</div>
</div>
<!-- MinIO -->
<div class="engine-block">
<div class="block-header">
<span class="block-name">MinIO</span>
<t-tag v-if="minioAvailable" theme="success" variant="light" size="small">可用</t-tag>
<t-tag v-else theme="default" variant="light" size="small">需要配置</t-tag>
</div>
<p class="block-desc">S3 兼容的自托管对象存储,适合内网和私有云部署。</p>
<div class="minio-mode-tabs">
<div
:class="['mode-tab', { active: config.minio.mode !== 'remote' }]"
@click="config.minio.mode = 'docker'"
>
<span class="tab-label">Docker 部署</span>
<t-tag v-if="minioEnvAvailable" theme="success" variant="light" size="small">已检测</t-tag>
<t-tag v-else theme="default" variant="light" size="small">未检测到</t-tag>
</div>
<div
:class="['mode-tab', { active: config.minio.mode === 'remote' }]"
@click="config.minio.mode = 'remote'"
>
<span class="tab-label">远程 MinIO</span>
</div>
</div>
<!-- Docker mode -->
<div v-if="config.minio.mode !== 'remote'" class="minio-mode-content">
<p v-if="minioEnvAvailable" class="mode-hint success">
已检测到 Docker 部署的 MinIO 环境变量,连接信息(Endpoint、Access Key)由环境变量提供,无需手动填写。
</p>
<p v-else class="mode-hint warning">
未检测到 MinIO 环境变量(MINIO_ENDPOINT、MINIO_ACCESS_KEY_ID、MINIO_SECRET_ACCESS_KEY),请确认 Docker Compose 配置正确。
</p>
<div class="block-config">
<div class="config-item">
<label>Bucket 名称</label>
<t-select
v-model="config.minio.bucket_name"
size="small"
filterable
creatable
placeholder="选择或输入 Bucket"
:loading="loadingBuckets"
:disabled="!minioEnvAvailable"
@focus="loadMinioBuckets"
style="width: 100%;"
>
<t-option
v-for="b in minioBuckets"
:key="b.name"
:value="b.name"
:label="b.name"
/>
</t-select>
</div>
<div class="config-item config-item--inline">
<label>Use SSL</label>
<t-switch v-model="config.minio.use_ssl" size="small" />
</div>
<div class="config-item">
<label>路径前缀(可选)</label>
<t-input
v-model="config.minio.path_prefix"
size="small"
placeholder="如 weknora"
clearable
/>
</div>
</div>
<div v-if="minioEnvAvailable" class="check-bar">
<t-button size="small" variant="outline" :loading="checkingMinio" @click="onCheckMinio">测试连接</t-button>
<span v-if="minioCheckResult" :class="['check-msg', minioCheckResult.ok ? 'success' : 'error']">
{{ minioCheckResult.message }}
</span>
</div>
</div>
<!-- Remote mode -->
<div v-else class="minio-mode-content">
<p class="mode-hint">连接到远程 MinIO 服务,需要手动填写连接信息。</p>
<div class="block-config">
<div class="config-item">
<label>Endpoint</label>
<t-input
v-model="config.minio.endpoint"
size="small"
placeholder="如 minio.example.com:9000"
clearable
/>
</div>
<div class="config-item">
<label>Access Key ID</label>
<t-input
v-model="config.minio.access_key_id"
size="small"
placeholder="MinIO Access Key"
clearable
/>
</div>
<div class="config-item">
<label>Secret Access Key</label>
<t-input
v-model="config.minio.secret_access_key"
size="small"
type="password"
placeholder="MinIO Secret Key"
clearable
/>
</div>
<div class="config-item">
<label>Bucket 名称</label>
<t-input
v-model="config.minio.bucket_name"
size="small"
placeholder="存储桶名称"
clearable
/>
</div>
<div class="config-item config-item--inline">
<label>Use SSL</label>
<t-switch v-model="config.minio.use_ssl" size="small" />
</div>
<div class="config-item">
<label>路径前缀(可选)</label>
<t-input
v-model="config.minio.path_prefix"
size="small"
placeholder="如 weknora"
clearable
/>
</div>
</div>
<div class="check-bar">
<t-button size="small" variant="outline" :loading="checkingMinio" @click="onCheckMinio">测试连接</t-button>
<span v-if="minioCheckResult" :class="['check-msg', minioCheckResult.ok ? 'success' : 'error']">
{{ minioCheckResult.message }}
</span>
</div>
</div>
</div>
<!-- COS -->
<div class="engine-block">
<div class="block-header">
<span class="block-name">腾讯云 COS</span>
<t-tag theme="success" variant="light" size="small">可配置</t-tag>
</div>
<p class="block-desc">腾讯云对象存储服务,适合公有云部署,支持 CDN 加速。</p>
<div class="block-config">
<div class="config-item">
<label>Secret ID</label>
<t-input
v-model="config.cos.secret_id"
size="small"
placeholder="腾讯云 API 密钥 SecretId"
clearable
/>
</div>
<div class="config-item">
<label>Secret Key</label>
<t-input
v-model="config.cos.secret_key"
size="small"
type="password"
placeholder="腾讯云 API 密钥 SecretKey"
clearable
/>
</div>
<div class="config-item">
<label>Region</label>
<t-input
v-model="config.cos.region"
size="small"
placeholder="如 ap-guangzhou"
clearable
/>
</div>
<div class="config-item">
<label>Bucket 名称</label>
<t-input
v-model="config.cos.bucket_name"
size="small"
placeholder="存储桶名称"
clearable
/>
</div>
<div class="config-item">
<label>App ID</label>
<t-input
v-model="config.cos.app_id"
size="small"
placeholder="腾讯云账号 AppID"
clearable
/>
</div>
<div class="config-item">
<label>路径前缀(可选)</label>
<t-input
v-model="config.cos.path_prefix"
size="small"
placeholder="如 weknora"
clearable
/>
</div>
</div>
<div class="check-bar">
<t-button size="small" variant="outline" :loading="checkingCos" @click="onCheckCos">测试连接</t-button>
<span v-if="cosCheckResult" :class="['check-msg', cosCheckResult.ok ? 'success' : 'error']">
{{ cosCheckResult.message }}
</span>
</div>
</div>
</div>
</div>
<div class="default-and-save">
<div class="default-row">
<label>默认引擎</label>
<t-select
v-model="config.default_provider"
size="small"
style="width: 200px;"
>
<t-option value="local" label="Local(本地)" />
<t-option value="minio" label="MinIO" />
<t-option value="cos" label="腾讯云 COS" />
</t-select>
<span class="hint">新建知识库时默认选用的存储引擎</span>
</div>
<div class="save-bar">
<t-button theme="primary" :loading="saving" @click="onSave">保存配置</t-button>
<span v-if="saveMessage" :class="['save-msg', saveSuccess ? 'success' : 'error']">
{{ saveMessage }}
</span>
</div>
</div>
</template>
</div>
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import {
getStorageEngineConfig,
updateStorageEngineConfig,
getStorageEngineStatus,
listMinioBuckets,
checkStorageEngine,
type StorageEngineConfig,
type MinioBucketInfo,
} from '@/api/system'
const defaultConfig = (): StorageEngineConfig => ({
default_provider: 'local',
local: { path_prefix: '' },
minio: { mode: 'docker', endpoint: '', access_key_id: '', secret_access_key: '', bucket_name: '', use_ssl: false, path_prefix: '' },
cos: {
secret_id: '',
secret_key: '',
region: '',
bucket_name: '',
app_id: '',
path_prefix: '',
},
})
const loading = ref(true)
const error = ref('')
const config = ref<StorageEngineConfig>(defaultConfig())
const engineStatus = ref<{ local: boolean; minio: boolean; cos: boolean }>({
local: true,
minio: false,
cos: true,
})
const minioEnvAvailable = ref(false)
const minioBuckets = ref<MinioBucketInfo[]>([])
const loadingBuckets = ref(false)
const saving = ref(false)
const saveMessage = ref('')
const saveSuccess = ref(false)
const checkingMinio = ref(false)
const minioCheckResult = ref<{ ok: boolean; message: string } | null>(null)
const checkingCos = ref(false)
const cosCheckResult = ref<{ ok: boolean; message: string } | null>(null)
const minioAvailable = computed(() => {
if (config.value.minio?.mode === 'remote') {
return !!(config.value.minio.endpoint && config.value.minio.access_key_id && config.value.minio.secret_access_key)
}
return minioEnvAvailable.value
})
async function loadConfig() {
try {
const res = await getStorageEngineConfig()
const d = res?.data
if (d) {
config.value = {
default_provider: d.default_provider || 'local',
local: d.local ? { path_prefix: d.local.path_prefix || '' } : { path_prefix: '' },
minio: d.minio
? {
mode: d.minio.mode || 'docker',
endpoint: d.minio.endpoint || '',
access_key_id: d.minio.access_key_id || '',
secret_access_key: d.minio.secret_access_key || '',
bucket_name: d.minio.bucket_name || '',
use_ssl: d.minio.use_ssl ?? false,
path_prefix: d.minio.path_prefix || '',
}
: defaultConfig().minio!,
cos: d.cos
? {
secret_id: d.cos.secret_id || '',
secret_key: d.cos.secret_key || '',
region: d.cos.region || '',
bucket_name: d.cos.bucket_name || '',
app_id: d.cos.app_id || '',
path_prefix: d.cos.path_prefix || '',
}
: defaultConfig().cos!,
}
}
} catch {
config.value = defaultConfig()
}
}
async function loadStatus() {
try {
const res = await getStorageEngineStatus()
const engines = res?.data?.engines ?? []
const status = { local: true, minio: false, cos: true }
for (const e of engines) {
if (e.name === 'local') status.local = e.available
if (e.name === 'minio') status.minio = e.available
if (e.name === 'cos') status.cos = e.available
}
engineStatus.value = status
minioEnvAvailable.value = res?.data?.minio_env_available ?? false
} catch {
engineStatus.value = { local: true, minio: false, cos: true }
minioEnvAvailable.value = false
}
}
async function loadMinioBuckets() {
if (!minioEnvAvailable.value || loadingBuckets.value) return
loadingBuckets.value = true
try {
const res = await listMinioBuckets()
if (res?.data?.buckets) {
minioBuckets.value = res.data.buckets
}
} catch {
minioBuckets.value = []
} finally {
loadingBuckets.value = false
}
}
async function loadAll() {
loading.value = true
error.value = ''
try {
await Promise.all([loadConfig(), loadStatus()])
if (minioEnvAvailable.value) loadMinioBuckets()
} catch (e: unknown) {
error.value = e instanceof Error ? e.message : '加载失败'
} finally {
loading.value = false
}
}
function buildPayload(): StorageEngineConfig {
const mode = config.value.minio?.mode || 'docker'
return {
default_provider: config.value.default_provider || 'local',
local: { path_prefix: (config.value.local?.path_prefix || '').trim() },
minio: {
mode,
endpoint: mode === 'remote' ? (config.value.minio?.endpoint || '').trim() : '',
access_key_id: mode === 'remote' ? (config.value.minio?.access_key_id || '').trim() : '',
secret_access_key: mode === 'remote' ? (config.value.minio?.secret_access_key || '').trim() : '',
bucket_name: (config.value.minio?.bucket_name || '').trim(),
use_ssl: config.value.minio?.use_ssl ?? false,
path_prefix: (config.value.minio?.path_prefix || '').trim(),
},
cos: {
secret_id: (config.value.cos?.secret_id || '').trim(),
secret_key: (config.value.cos?.secret_key || '').trim(),
region: (config.value.cos?.region || '').trim(),
bucket_name: (config.value.cos?.bucket_name || '').trim(),
app_id: (config.value.cos?.app_id || '').trim(),
path_prefix: (config.value.cos?.path_prefix || '').trim(),
},
}
}
async function onSave() {
saving.value = true
saveMessage.value = ''
try {
await updateStorageEngineConfig(buildPayload())
await loadStatus()
saveSuccess.value = true
saveMessage.value = '保存成功'
} catch (e: unknown) {
saveSuccess.value = false
saveMessage.value = e instanceof Error ? e.message : '保存失败'
} finally {
saving.value = false
}
}
async function onCheckMinio() {
checkingMinio.value = true
minioCheckResult.value = null
try {
const payload = buildPayload()
const res = await checkStorageEngine({ provider: 'minio', minio: payload.minio })
minioCheckResult.value = res?.data ?? { ok: false, message: '未知错误' }
} catch (e: unknown) {
minioCheckResult.value = { ok: false, message: e instanceof Error ? e.message : '请求失败' }
} finally {
checkingMinio.value = false
}
}
async function onCheckCos() {
checkingCos.value = true
cosCheckResult.value = null
try {
const payload = buildPayload()
const res = await checkStorageEngine({ provider: 'cos', cos: payload.cos })
cosCheckResult.value = res?.data ?? { ok: false, message: '未知错误' }
} catch (e: unknown) {
cosCheckResult.value = { ok: false, message: e instanceof Error ? e.message : '请求失败' }
} finally {
checkingCos.value = false
}
}
onMounted(loadAll)
</script>
<style lang="less" scoped>
.storage-engine-settings {
width: 100%;
}
.section-header {
margin-bottom: 32px;
h2 {
font-size: 20px;
font-weight: 600;
color: #333;
margin: 0 0 8px 0;
}
.section-description {
font-size: 14px;
color: #666;
margin: 0;
line-height: 1.5;
}
}
.loading-state,
.error-inline {
padding: 24px 0;
}
.loading-state {
display: flex;
align-items: center;
gap: 8px;
color: #999;
}
.engine-section {
margin-top: 0;
}
.section-title-row {
margin-bottom: 20px;
h3 {
font-size: 17px;
font-weight: 600;
color: #333;
margin: 0 0 6px 0;
}
p {
font-size: 13px;
color: #999;
margin: 0;
line-height: 1.5;
}
}
.engine-list {
display: flex;
flex-direction: column;
gap: 20px;
}
.engine-block {
padding: 20px;
border: 1px solid #e5e7eb;
border-radius: 10px;
background: #fff;
display: flex;
flex-direction: column;
gap: 10px;
}
.block-header {
display: flex;
align-items: center;
gap: 10px;
}
.block-name {
font-size: 16px;
font-weight: 600;
color: #333;
}
.block-desc {
font-size: 13px;
color: #666;
margin: 0;
line-height: 1.5;
}
.block-config {
margin-top: 6px;
padding-top: 14px;
border-top: 1px dashed #e5e7eb;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
gap: 14px 24px;
}
.config-item {
display: flex;
flex-direction: column;
gap: 4px;
label {
font-size: 12px;
font-weight: 500;
color: #555;
}
&--inline {
flex-direction: row;
align-items: center;
gap: 10px;
label {
flex-shrink: 0;
}
}
}
// ---- MinIO mode tabs ----
.minio-mode-tabs {
display: flex;
gap: 8px;
margin-top: 4px;
}
.mode-tab {
display: flex;
align-items: center;
gap: 6px;
padding: 8px 16px;
border: 1px solid #e5e7eb;
border-radius: 8px;
cursor: pointer;
transition: all 0.15s;
background: #fafafa;
&:hover {
border-color: #c0c4cc;
}
&.active {
border-color: var(--td-brand-color, #0052d9);
background: var(--td-brand-color-light, #f0f5ff);
}
.tab-label {
font-size: 13px;
font-weight: 500;
color: #333;
}
}
.minio-mode-content {
margin-top: 4px;
}
.mode-hint {
font-size: 13px;
color: #666;
margin: 0 0 4px 0;
line-height: 1.5;
&.success {
color: #52c41a;
}
&.warning {
color: #e6a23c;
}
}
.default-and-save {
margin-top: 24px;
padding-top: 24px;
border-top: 1px solid #e5e7eb;
}
.default-row {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 16px;
label {
font-size: 14px;
font-weight: 500;
color: #333;
}
.hint {
font-size: 13px;
color: #999;
}
}
.save-bar {
display: flex;
align-items: center;
gap: 12px;
}
.save-msg {
font-size: 13px;
&.success {
color: #52c41a;
}
&.error {
color: #ff4d4f;
}
}
.check-bar {
display: flex;
align-items: center;
gap: 10px;
margin-top: 12px;
padding-top: 12px;
border-top: 1px dashed #f0f0f0;
}
.check-msg {
font-size: 13px;
&.success {
color: #52c41a;
}
&.error {
color: #ff4d4f;
}
}
</style>
@@ -31,6 +31,13 @@
<div class="setting-control">
<span class="info-value">
{{ systemInfo?.version || $t('system.unknown') }}
<t-tag
v-if="systemInfo?.edition"
:theme="systemInfo.edition === 'lite' ? 'primary' : 'default'"
variant="light"
size="small"
style="margin-left: 8px;"
>{{ systemInfo.edition === 'lite' ? 'Lite' : 'Standard' }}</t-tag>
<span v-if="systemInfo?.commit_id" class="commit-info">
({{ systemInfo.commit_id }})
</span>