zhou.xiaoning 4 年 前
コミット
c564a86718
1 ファイル変更12 行追加11 行削除
  1. 12 11
      src/views/account/login.vue

+ 12 - 11
src/views/account/login.vue

@@ -106,17 +106,10 @@ declare global {
         };
     }
 }
-window.qt = {
-    webChannelTransport: {
-        send() {
-            console.log('QWebChannel simulator activated !');
-        },
-        onmessage() {},
-    },
-};
-let qtWebChannel: any = null;
 
-new QWebChannel(window.qt.webChannelTransport, (channel: any) => {
+let qtWebChannel: any = null;
+const webChannelTransport = window.qt.webChannelTransport
+new QWebChannel(webChannelTransport, (channel: any) => {
     alert('成功!!!');
     // all published objects are available in channel.objects under
     // the identifier set in their attached WebChannel.id property
@@ -126,7 +119,15 @@ new QWebChannel(window.qt.webChannelTransport, (channel: any) => {
 
 function qtAction(value: any) {
     if (qtWebChannel) {
-        qtWebChannel.handleCmd('action');
+        qtWebChannel.getSystemInfo().then((res: any) => {
+            console.log(res);
+
+            var arr = [];
+            for (var i = 0, j = res.length; i < j; ++i) {
+                arr.push(res.charCodeAt(i));
+            }
+            console.log(new Uint8Array(arr));
+        });
     } else {
         alert('qtWebChannel is null');
     }