Browse Source

还原【支持mac打开离线场景】代码

dsx 2 năm trước cách đây
mục cha
commit
fe9e24a32c

+ 13 - 1
src/main/java/com/fdkankan/download/service/impl/SceneDownloadHandlerServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.TimeInterval;
 import cn.hutool.core.exceptions.ExceptionUtil;
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.RuntimeUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.ZipUtil;
 import cn.hutool.http.HttpUtil;
@@ -125,6 +126,12 @@ public class SceneDownloadHandlerServiceImpl {
     private String exeContent;
     @Value("${download.config.exe-content-v3}")
     private String exeContentV3;
+    @Value("${download.config.command-name}")
+    private String commandName;
+    @Value("${download.config.command-content}")
+    private String commandContent;
+    @Value("${download.config.command-content-v3}")
+    private String commandContentV3;
 
     @Autowired
     private RedisUtil redisUtil;
@@ -476,11 +483,16 @@ public class SceneDownloadHandlerServiceImpl {
 
     private void zipBat(String num, String version) throws Exception{
         String batContent = String.format(this.exeContent, num);
+        String commandContent = String.format(this.commandContent, num);
         if("v3".equals(version)){
             batContent = String.format(this.exeContentV3, num);
+            commandContent = String.format(this.commandContentV3, num);
         }
-//        this.zipBytes(out, exeName, batContent.getBytes());
         FileUtil.writeUtf8String(batContent, String.format(this.sourceLocal, num, exeName));
+        FileUtil.writeUtf8String(commandContent, String.format(this.sourceLocal, num, commandName));
+        RuntimeUtil.exec("chmod a+x " + String.format(this.sourceLocal, num, commandName));
+        RuntimeUtil.exec("chmod a+x " + String.format(this.sourceLocal, num, "http_darwin"));
+
 
         //更新进度为90%
         this.updateProgress(new BigDecimal("0.9").divide(new BigDecimal("0.8"), 6, BigDecimal.ROUND_HALF_UP), num,