liwei 1 year ago
parent
commit
fd473156b3
2 changed files with 17 additions and 19 deletions
  1. 2 0
      README.md
  2. 15 19
      src/comm/controllers/deviceCtrl.ts

+ 2 - 0
README.md

@@ -26,3 +26,5 @@ See [Configuration Reference](https://cli.vuejs.org/config/).
 
 # 渲染器参考
 https://github.com/KhronosGroup/glTF-Sample-Viewer/tree/master/app_web
+
+http://www.infish.cn/projects/screenshow/

+ 15 - 19
src/comm/controllers/deviceCtrl.ts

@@ -18,6 +18,13 @@ export type FileInfo = {
   CreateAt: number; //info.ModTime().Unix()
 };
 
+function Sleep(t:number) {
+  return new Promise((r)=>{
+     setTimeout(() => {
+        r(true);
+     }, t);
+  })
+}
 export class DeviceController extends Controller {
   ipc: any;
 
@@ -268,38 +275,27 @@ export class DeviceController extends Controller {
   }
 
   //下在线文件 默认超时时间20分钟
-  DownloadFile(
+  async DownloadFile(
     url: string,
     fpath: string,
-    timeoutSecend: number = 60 * 20,
-    cb?: (event: "start" | "progress" | "error" | "succ", p1: NormMsg) => void
+    timeoutSecend: number = 60 * 20
   ): Promise<boolean> {
-    const sid = "d" + Date.now();
+   
+    await Sleep(500);
+    
     return new Promise((r) => {
-      console.log(url, "==>", fpath);
-      const cancel = this.OnMsg(sid, (data) => {
-        cb && cb(data.type as any, data);
-        if (data.type == "succ") {
-          r(true);
-          cancel.unbind();
-          return;
-        }
-        if (data.type == "error") {
-          r(false);
-          cancel.unbind();
-        }
-      });
-
       const ipc = this.ipc;
       ipc.emit(
         "DownloadFile",
-        [sid, fpath, url, timeoutSecend],
+        [fpath, url, timeoutSecend],
         function (err: string) {
           console.log("DownloadFile callback");
           if (err) {
             console.error(err);
             r(false);
+            return;
           }
+          r(true);
         }
       );
     });