@@ -271,6 +271,7 @@ <h1 @click="copyText(file.code,0)" style="margin: 0;display: inline;cursor: poin
271271 fileSizeLimit : '{{fileSizeLimit}}' ,
272272 pwd : localStorage . getItem ( 'pwd' ) || '' ,
273273 banners : [ ] ,
274+ enableUpload : false ,
274275 uploadData : {
275276 style : '2' ,
276277 type : '1' ,
@@ -313,7 +314,12 @@ <h1 @click="copyText(file.code,0)" style="margin: 0;display: inline;cursor: poin
313314 }
314315 } ) ;
315316 // 获取Banner
316- axios . get ( '/banner' ) . then ( res => {
317+ axios . get ( '/banner' , {
318+ headers : {
319+ pwd : localStorage . getItem ( 'pwd' )
320+ }
321+ } ) . then ( res => {
322+ this . enableUpload = res . data . enable
317323 this . banners = res . data . data
318324 } )
319325 } ,
@@ -385,24 +391,42 @@ <h1 @click="copyText(file.code,0)" style="margin: 0;display: inline;cursor: poin
385391 changeInput : function ( value ) {
386392 this . code = value ;
387393 } ,
394+ checkFile : function ( file ) {
395+ if ( ! this . enable ) {
396+ this . $message ( {
397+ message : '上传功能已关闭' ,
398+ type : 'error'
399+ } ) ;
400+ return false
401+ }
402+ if ( file . size > this . fileSizeLimit ) {
403+ this . $message ( {
404+ message : `文件大小不能超过${ this . fileSizeLimit / 1024 / 1024 } MB` ,
405+ type : 'error'
406+ } ) ;
407+ return false
408+ }
409+ } ,
388410 toUploadData : function ( ) {
389411 if ( this . uploadData . text === '' && this . uploadData . file === null ) {
390412 this . $message ( {
391413 message : '请先粘贴文字或者上传文件' ,
392414 type : 'error'
393415 } ) ;
394416 } else {
395- this . http ( 'post' , '/share' , this . uploadData , {
396- headers : {
397- 'Content-Type' : 'multipart/form-data' ,
398- 'pwd' : this . pwd
399- }
400- } ) . then ( res => {
401- this . jiFiles . unshift ( res . data ) ;
402- this . jiDrawer = true ;
403- this . uploadData . text = '' ;
404- this . uploadData . file = null ;
405- } ) ;
417+ if ( this . checkFile ( this . uploadData . file ) ) {
418+ this . http ( 'post' , '/share' , this . uploadData , {
419+ headers : {
420+ 'Content-Type' : 'multipart/form-data' ,
421+ 'pwd' : this . pwd
422+ }
423+ } ) . then ( res => {
424+ this . jiFiles . unshift ( res . data ) ;
425+ this . jiDrawer = true ;
426+ this . uploadData . text = '' ;
427+ this . uploadData . file = null ;
428+ } ) ;
429+ }
406430 }
407431 } ,
408432 successUpload ( response , file , fileList ) {
@@ -420,13 +444,7 @@ <h1 @click="copyText(file.code,0)" style="margin: 0;display: inline;cursor: poin
420444 } ) ;
421445 } ,
422446 beforeUpload : function ( file ) {
423- if ( file . size > this . fileSizeLimit ) {
424- this . $message ( {
425- message : `文件大小不能超过${ this . fileSizeLimit / 1024 / 1024 } MB` ,
426- type : 'error'
427- } ) ;
428- return false
429- }
447+ return this . checkFile ( file ) ;
430448 }
431449 }
432450 } )
0 commit comments