@ -66,13 +66,13 @@ export default {
<!-- 通用文件 -- >
<!-- 通用文件 -- >
< div v - show = "activeSubTab === 'file'" >
< div v - show = "activeSubTab === 'file'" >
< div class = "endpoint-info" > < span class = "badge badge-post" > POST < / s p a n > < c o d e s t y l e = " f o n t - s i z e : 1 3 p x ; " > / u p l o a d / f i l e < / c o d e > < s p a n s t y l e = " f o n t - s i z e : 1 2 p x ; c o l o r : v a r ( - - s u b ) ; " > ( T i k a 多 格 式 解 析 ) < / s p a n > < / d i v >
< div class = "endpoint-info" > < span class = "badge badge-post" > POST < / s p a n > < c o d e s t y l e = " f o n t - s i z e : 1 3 p x ; " > / u p l o a d / f i l e < / c o d e > < s p a n s t y l e = " f o n t - s i z e : 1 2 p x ; c o l o r : v a r ( - - s u b ) ; " > ( T i k a 多 格 式 解 析 ) < / s p a n > < / d i v >
< div class = "upload-zone" @ click = "$refs. fileInput.click()" @ dragover . prevent = "$event.currentTarget.classList.add('drag-over')" @ dragleave = "$event.currentTarget.classList.remove('drag-over')" @ drop . prevent = "handleDrop($event, 'file')" >
< div class = "upload-zone" @ click = "fileInput && fileInput.click()" @ dragover . prevent = "$event.currentTarget.classList.add('drag-over')" @ dragleave = "$event.currentTarget.classList.remove('drag-over')" @ drop . prevent = "handleDrop($event, 'file')" >
< div class = "icon" > 📎 < /div><p>点击或拖拽上传,支持多文件(PDF / Word / Excel / PPT / TXT 等 ) < / p >
< div class = "icon" > 📎 < /div><p>点击或拖拽上传,支持多文件(PDF / Word / Excel / PPT / TXT 等 ) < / p >
< input type = "file" ref = "fileInput" style = "display:none" multiple accept = ".pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.csv,.html,.xml,.rtf" @ change = "handleFileSelect($event, 'file')" >
< input type = "file" ref = "fileInput" style = "display:none" multiple accept = ".pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.csv,.html,.xml,.rtf" @ change = "handleFileSelect($event, 'file')" >
< / d i v >
< / d i v >
< div v - html = "fileInfo.file" style = "margin-bottom:8px;font-size:13px;color:var(--sub);" > < / d i v >
< div v - html = "fileInfo.file" style = "margin-bottom:8px;font-size:13px;color:var(--sub);" > < / d i v >
< div v - if = "validationErrors.file" style = "margin-bottom:8px;font-size:13px;color:var(--danger);" > ⚠ ️ { { validationErrors . file } } < / d i v >
< div v - if = "validationErrors.file" style = "margin-bottom:8px;font-size:13px;color:var(--danger);" > ⚠ ️ { { validationErrors . file } } < / d i v >
< button class = "btn btn-primary" @ click = "doUpload('file')" : disabled = "!fileData.file || validationErrors.file " > 🚀 上传并向量化 < / b u t t o n >
< button class = "btn btn-primary" @ click = "doUpload('file')" : disabled = "getButtonState('file') " > 🚀 上传并向量化 < / b u t t o n >
< div v - html = "results.file" > < / d i v >
< div v - html = "results.file" > < / d i v >
< / d i v >
< / d i v >
@ -95,7 +95,7 @@ export default {
< / d i v >
< / d i v >
< div v - html = "fileInfo.markdown" style = "margin-bottom:8px;font-size:13px;color:var(--sub);" > < / d i v >
< div v - html = "fileInfo.markdown" style = "margin-bottom:8px;font-size:13px;color:var(--sub);" > < / d i v >
< div v - if = "validationErrors.markdown" style = "margin-bottom:8px;font-size:13px;color:var(--danger);" > ⚠ ️ { { validationErrors . markdown } } < / d i v >
< div v - if = "validationErrors.markdown" style = "margin-bottom:8px;font-size:13px;color:var(--danger);" > ⚠ ️ { { validationErrors . markdown } } < / d i v >
< button class = "btn btn-primary" @ click = "doUpload('markdown')" : disabled = "!fileData.markdown || validationErrors.markdown " > 🚀 上传并向量化 < / b u t t o n >
< button class = "btn btn-primary" @ click = "doUpload('markdown')" : disabled = "getButtonState('markdown') " > 🚀 上传并向量化 < / b u t t o n >
< div v - html = "results.markdown" > < / d i v >
< div v - html = "results.markdown" > < / d i v >
< / d i v >
< / d i v >
@ -108,7 +108,7 @@ export default {
< / d i v >
< / d i v >
< div v - html = "fileInfo.jsonBasic" style = "margin-bottom:8px;font-size:13px;color:var(--sub);" > < / d i v >
< div v - html = "fileInfo.jsonBasic" style = "margin-bottom:8px;font-size:13px;color:var(--sub);" > < / d i v >
< div v - if = "validationErrors.jsonBasic" style = "margin-bottom:8px;font-size:13px;color:var(--danger);" > ⚠ ️ { { validationErrors . jsonBasic } } < / d i v >
< div v - if = "validationErrors.jsonBasic" style = "margin-bottom:8px;font-size:13px;color:var(--danger);" > ⚠ ️ { { validationErrors . jsonBasic } } < / d i v >
< button class = "btn btn-primary" @ click = "doUpload('jsonBasic')" : disabled = "!fileData.jsonBasic || validationErrors.jsonBasic " > 🚀 上传并向量化 < / b u t t o n >
< button class = "btn btn-primary" @ click = "doUpload('jsonBasic')" : disabled = "getButtonState('jsonBasic') " > 🚀 上传并向量化 < / b u t t o n >
< div v - html = "results.jsonBasic" > < / d i v >
< div v - html = "results.jsonBasic" > < / d i v >
< / d i v >
< / d i v >
@ -122,7 +122,7 @@ export default {
< div v - html = "fileInfo.jsonFields" style = "margin-bottom:8px;font-size:13px;color:var(--sub);" > < / d i v >
< div v - html = "fileInfo.jsonFields" style = "margin-bottom:8px;font-size:13px;color:var(--sub);" > < / d i v >
< div v - if = "validationErrors.jsonFields" style = "margin-bottom:8px;font-size:13px;color:var(--danger);" > ⚠ ️ { { validationErrors . jsonFields } } < / d i v >
< div v - if = "validationErrors.jsonFields" style = "margin-bottom:8px;font-size:13px;color:var(--danger);" > ⚠ ️ { { validationErrors . jsonFields } } < / d i v >
< input class = "input" v - model = "jsonFieldsStr" placeholder = "输入要提取的字段名(逗号分隔),如:title,description,content" style = "margin-bottom:12px;" >
< input class = "input" v - model = "jsonFieldsStr" placeholder = "输入要提取的字段名(逗号分隔),如:title,description,content" style = "margin-bottom:12px;" >
< button class = "btn btn-primary" @ click = "doUpload('jsonFields')" : disabled = "!fileData.jsonFields || validationErrors.jsonFields " > 🚀 上传并向量化 < / b u t t o n >
< button class = "btn btn-primary" @ click = "doUpload('jsonFields')" : disabled = "getButtonState('jsonFields') " > 🚀 上传并向量化 < / b u t t o n >
< div v - html = "results.jsonFields" > < / d i v >
< div v - html = "results.jsonFields" > < / d i v >
< / d i v >
< / d i v >
@ -136,7 +136,7 @@ export default {
< div v - html = "fileInfo.jsonPointer" style = "margin-bottom:8px;font-size:13px;color:var(--sub);" > < / d i v >
< div v - html = "fileInfo.jsonPointer" style = "margin-bottom:8px;font-size:13px;color:var(--sub);" > < / d i v >
< div v - if = "validationErrors.jsonPointer" style = "margin-bottom:8px;font-size:13px;color:var(--danger);" > ⚠ ️ { { validationErrors . jsonPointer } } < / d i v >
< div v - if = "validationErrors.jsonPointer" style = "margin-bottom:8px;font-size:13px;color:var(--danger);" > ⚠ ️ { { validationErrors . jsonPointer } } < / d i v >
< input class = "input" v - model = "jsonPointerStr" placeholder = "输入 JSON Pointer 路径,如:/data/items 或 /products" style = "margin-bottom:12px;" >
< input class = "input" v - model = "jsonPointerStr" placeholder = "输入 JSON Pointer 路径,如:/data/items 或 /products" style = "margin-bottom:12px;" >
< button class = "btn btn-primary" @ click = "doUpload('jsonPointer')" : disabled = "!fileData.jsonPointer || validationErrors.jsonPointer " > 🚀 上传并向量化 < / b u t t o n >
< button class = "btn btn-primary" @ click = "doUpload('jsonPointer')" : disabled = "getButtonState('jsonPointer') " > 🚀 上传并向量化 < / b u t t o n >
< div v - html = "results.jsonPointer" > < / d i v >
< div v - html = "results.jsonPointer" > < / d i v >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
@ -154,6 +154,13 @@ export default {
const overlapOverride = ref ( null )
const overlapOverride = ref ( null )
const uploadProgress = ref ( - 1 )
const uploadProgress = ref ( - 1 )
// 文件 input 的 ref 引用(Composition API 需要声明才能在模板中使用)
const fileInput = ref ( null )
const mdInput = ref ( null )
const jsonBInput = ref ( null )
const jsonFInput = ref ( null )
const jsonPInput = ref ( null )
const fileData = reactive ( {
const fileData = reactive ( {
file : null , markdown : null , jsonBasic : null , jsonFields : null , jsonPointer : null
file : null , markdown : null , jsonBasic : null , jsonFields : null , jsonPointer : null
} )
} )
@ -170,6 +177,14 @@ export default {
file : '' , markdown : '' , jsonBasic : '' , jsonFields : '' , jsonPointer : ''
file : '' , markdown : '' , jsonBasic : '' , jsonFields : '' , jsonPointer : ''
} )
} )
// 添加调试用的计算属性,检查按钮状态
const getButtonState = ( type ) => {
const hasFile = ! ! fileData [ type ]
const hasError = ! ! validationErrors [ type ]
console . log ( ` [BUTTON STATE] type= ${ type } , hasFile= ${ hasFile } , hasError= ${ hasError } , disabled= ${ ! hasFile || hasError } ` )
return ! hasFile || hasError
}
const subTabs = [
const subTabs = [
{ key : 'file' , icon : '📎' , label : '通用文件' } ,
{ key : 'file' , icon : '📎' , label : '通用文件' } ,
{ key : 'string' , icon : '📝' , label : '文本内容' } ,
{ key : 'string' , icon : '📝' , label : '文本内容' } ,
@ -202,8 +217,12 @@ export default {
if ( ! input . files || input . files . length === 0 ) return
if ( ! input . files || input . files . length === 0 ) return
const files = Array . from ( input . files )
const files = Array . from ( input . files )
console . log ( '[DEBUG] handleFileSelect - type:' , type , 'files:' , files . length )
// 前端校验
// 前端校验
const error = validateFiles ( files )
const error = validateFiles ( files )
console . log ( '[DEBUG] validation error:' , error )
if ( error ) {
if ( error ) {
// 校验不通过:清空数据,保持按钮禁用
// 校验不通过:清空数据,保持按钮禁用
validationErrors [ type ] = error
validationErrors [ type ] = error
@ -221,6 +240,10 @@ export default {
? ` 已选择 <strong> ${ files . length } </strong> 个文件(共 ${ formatBytes ( totalSize ) } ) `
? ` 已选择 <strong> ${ files . length } </strong> 个文件(共 ${ formatBytes ( totalSize ) } ) `
: ` 已选择:<strong> ${ files [ 0 ] . name } </strong> ( ${ formatBytes ( files [ 0 ] . size ) } ) `
: ` 已选择:<strong> ${ files [ 0 ] . name } </strong> ( ${ formatBytes ( files [ 0 ] . size ) } ) `
fileInfo [ type ] = label
fileInfo [ type ] = label
console . log ( '[DEBUG] fileData[type] set to:' , fileData [ type ] )
console . log ( '[DEBUG] validationErrors[type] set to:' , validationErrors [ type ] )
console . log ( '[DEBUG] Button should be enabled:' , ! ! fileData [ type ] && ! validationErrors [ type ] )
}
}
function handleDrop ( event , type ) {
function handleDrop ( event , type ) {
@ -374,7 +397,9 @@ export default {
stringTitle , stringContent , jsonFieldsStr , jsonPointerStr ,
stringTitle , stringContent , jsonFieldsStr , jsonPointerStr ,
showAdvanced , chunkSizeOverride , overlapOverride ,
showAdvanced , chunkSizeOverride , overlapOverride ,
uploadProgress ,
uploadProgress ,
fileInput , mdInput , jsonBInput , jsonFInput , jsonPInput ,
fileData , fileInfo , results , validationErrors , store ,
fileData , fileInfo , results , validationErrors , store ,
getButtonState ,
handleFileSelect , handleDrop , doUpload , formatBytes
handleFileSelect , handleDrop , doUpload , formatBytes
}
}
}
}