Przeglądaj źródła

解决CTP穿透问题

zhou.xiaoning 4 lat temu
rodzic
commit
ae2c83354a
2 zmienionych plików z 17 dodań i 6 usunięć
  1. 1 1
      public/config/app.config.json
  2. 16 5
      src/views/account/login.vue

+ 1 - 1
public/config/app.config.json

@@ -1,3 +1,3 @@
 {
-    "apiUrl": "http://218.17.158.45:21001/cfg?key=test_175"
+    "apiUrl": "http://192.168.31.223:8080/cfg?key=test_223"
 }

+ 16 - 5
src/views/account/login.vue

@@ -107,11 +107,7 @@
         function getQtInfo(): Promise<Uint8Array[]> {
             if (qtWebChannel) {
                 return qtWebChannel.getSystemInfo().then((res: any) => {
-                    const arr = [];
-                    for (var i = 0, j = res.length; i < j; ++i) {
-                        arr.push(res.charCodeAt(i));
-                    }
-                    return new Uint8Array(arr);
+                    return base64ToUint8Array(res);
                 });
             } else {
                 console.warn('qtWebChannel is null');
@@ -121,6 +117,21 @@
         return { getQtInfo };
     }
 
+    function base64ToUint8Array(base64String: string) {
+        let padding = '='.repeat((4 - base64String.length % 4) % 4);
+        let base64 = (base64String + padding)
+            .replace(/\-/g, '+')
+            .replace(/_/g, '/');
+
+        let rawData = window.atob(base64);
+        let outputArray = new Uint8Array(rawData.length);
+
+        for (var i = 0; i < rawData.length; ++i) {
+            outputArray[i] = rawData.charCodeAt(i);
+        }
+        return outputArray;
+    }   
+
     // function qtAction(value: any) {
     //     if (qtWebChannel) {
     //         qtWebChannel.getSystemInfo().then((res: any) => {