Parcourir la source

Merge branch 'master' of http://47.101.159.18:3000/Muchinfo/MTP2.0_WEB

huangbin il y a 4 ans
Parent
commit
6e0fd184dd
1 fichiers modifiés avec 16 ajouts et 5 suppressions
  1. 16 5
      src/views/account/login.vue

+ 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) => {