Explorar el Código

判断压缩格式用switch

visuddhinanda hace 2 años
padre
commit
fbcde69afa
Se han modificado 1 ficheros con 11 adiciones y 7 borrados
  1. 11 7
      app/Console/Commands/ExportOffline.php

+ 11 - 7
app/Console/Commands/ExportOffline.php

@@ -45,6 +45,7 @@ class ExportOffline extends Command
         //term
         $this->info('term');
         $this->call('export:term');
+
         //导出channel
         $this->info('channel');
         $this->call('export:channel');
@@ -68,13 +69,16 @@ class ExportOffline extends Command
         $this->info('zip');
         $exportPath = 'app/public/export/offline';
         $exportFile = 'wikipali-offline-'.date("Y-m-d").'.db3';
-        $zipFile = $exportFile.".db3.";
-        if($this->argument('format')==='7z'){
-            $zipFile .= "7z";
-        }else if($this->argument('format')==='lzma'){
-            $zipFile .= "lzma";
-        }else{
-            $zipFile .= "gz";
+        switch ($this->argument('format')) {
+            case '7z':
+                $zipFile = $exportFile . ".7z";
+                break;
+            case 'lzma':
+                $zipFile = $exportFile . ".lzma";
+                break;
+            default:
+                $zipFile = $exportFile . ".gz";
+                break;
         }
         //
         $exportFullFileName = storage_path($exportPath.'/'.$exportFile);