File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
examples/src/views/DifyChat/mixins Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -4,14 +4,29 @@ export default {
44 data ( ) {
55 return {
66 uploadedFiles : [ ] ,
7+ maxFileCount : 3 ,
78 } ;
89 } ,
10+ computed : {
11+ fileCountStatus ( ) {
12+ return `${ this . uploadedFiles . length } /${ this . maxFileCount } 个文件` ;
13+ } ,
14+ isFileCountLimit ( ) {
15+ return this . uploadedFiles . length >= this . maxFileCount ;
16+ } ,
17+ } ,
918 watch : {
1019 uploadedFiles : {
1120 handler ( newFiles ) {
1221 // 监听上传文件变化,控制header显示隐藏
1322 this . $nextTick ( ( ) => {
1423 this . $emit ( 'files-changed' , newFiles ) ;
24+ this . $emit ( 'file-status-changed' , {
25+ count : newFiles . length ,
26+ maxCount : this . maxFileCount ,
27+ status : this . fileCountStatus ,
28+ isLimit : this . isFileCountLimit ,
29+ } ) ;
1530 } ) ;
1631 } ,
1732 deep : true ,
@@ -28,6 +43,12 @@ export default {
2843 async handleFileChange ( file ) {
2944 if ( ! file ) return ;
3045
46+ // 检查文件数量限制
47+ if ( this . uploadedFiles . length >= this . maxFileCount ) {
48+ this . $message . warning ( `最多只能上传${ this . maxFileCount } 个文件,请先删除现有文件后再试` ) ;
49+ return ;
50+ }
51+
3152 try {
3253 const response = await fileApi . uploadFile ( file , this . difyConfig . user ) ;
3354 // 按照 Dify API 规范格式化文件对象
You can’t perform that action at this time.
0 commit comments