@@ -368,8 +368,8 @@ <h2>ToAlist</h2>
368368
369369 < div class ="file-list " v-if ="fileList.length > 0 ">
370370 < div style ="margin-top: 10px; ">
371- < el-button type ="primary " @click ="submitUpload "> 开始上传</ el-button >
372- < el-button type ="danger " @click ="clearFiles "> 清空文件</ el-button >
371+ < el-button type ="primary " @click ="submitUpload " :loading =" uploading " > 开始上传</ el-button >
372+ < el-button type ="danger " @click ="clearFiles " :disabled =" uploading " > 清空文件</ el-button >
373373 </ div >
374374 </ div >
375375 </ div >
@@ -475,7 +475,7 @@ <h3>关于 ToAlist</h3>
475475 < p > 主要功能:</ p >
476476 < ul >
477477 < li > 支持拖拽上传和点击上传</ li >
478- < li > 支持图片文件预览 </ li >
478+ < li > 支持图片和MP4视频文件预览 </ li >
479479 < li > 自动生成 Markdown、HTML、BBS 等多种格式的链接</ li >
480480 < li > 支持暗色模式</ li >
481481 < li > 支持多文件同时上传</ li >
@@ -504,15 +504,13 @@ <h3>关于 ToAlist</h3>
504504 const uploadRef = ref ( null )
505505 const fileList = ref ( [ ] )
506506 const uploadedFiles = ref ( [ ] )
507- // 从 localStorage 中读取主题设置,如果没有则默认为 false
507+ const uploading = ref ( false )
508508 const isDark = ref ( localStorage . getItem ( 'theme' ) === 'dark' )
509509
510- // 在组件挂载时应用保存的主题
511510 const applyTheme = ( ) => {
512511 document . documentElement . setAttribute ( 'data-theme' , isDark . value ? 'dark' : 'light' )
513512 }
514513
515- // 页面加载时应用保存的主题
516514 applyTheme ( )
517515
518516 const Moon = ElementPlusIconsVue . Moon
@@ -521,7 +519,6 @@ <h3>关于 ToAlist</h3>
521519
522520 const toggleTheme = ( val ) => {
523521 isDark . value = val
524- // 保存主题设置到 localStorage
525522 localStorage . setItem ( 'theme' , val ? 'dark' : 'light' )
526523 applyTheme ( )
527524 }
@@ -551,6 +548,9 @@ <h3>关于 ToAlist</h3>
551548 }
552549
553550 const submitUpload = async ( ) => {
551+ if ( uploading . value ) return ;
552+ uploading . value = true ;
553+
554554 const formData = new FormData ( )
555555 fileList . value . forEach ( file => {
556556 formData . append ( 'sign' , Date . now ( ) ) ;
@@ -565,7 +565,6 @@ <h3>关于 ToAlist</h3>
565565 const result = await response . json ( )
566566
567567 if ( result . code === 200 || result . code === 207 ) {
568- // 处理上传成功的文件
569568 if ( result . files && result . files . length > 0 ) {
570569 result . files . forEach ( file => {
571570 uploadedFiles . value . push ( {
@@ -575,7 +574,6 @@ <h3>关于 ToAlist</h3>
575574 } )
576575 }
577576
578- // 处理部分成功的情况
579577 if ( result . code === 207 && result . errors ) {
580578 result . errors . forEach ( error => {
581579 ElMessage . warning ( error )
@@ -592,6 +590,8 @@ <h3>关于 ToAlist</h3>
592590 } catch ( error ) {
593591 ElMessage . error ( '上传过程中发生错误' )
594592 console . error ( error )
593+ } finally {
594+ uploading . value = false ;
595595 }
596596 }
597597
@@ -619,6 +619,7 @@ <h3>关于 ToAlist</h3>
619619 Sunny,
620620 UploadFilled,
621621 Document,
622+ uploading,
622623 toggleTheme,
623624 isImage,
624625 isVideo,
0 commit comments