huangbin há 4 anos atrás
pai
commit
bdbb0956c1
1 ficheiros alterados com 21 adições e 12 exclusões
  1. 21 12
      src/views/account/login.vue

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

@@ -106,21 +106,30 @@ declare global {
         };
     }
 }
-// let qtWebChannel: any = null;
+window.qt = {
+    webChannelTransport: {
+        send() {
+            console.log('QWebChannel simulator activated !');
+        },
+        onmessage() {},
+    },
+};
+let qtWebChannel: any = null;
 
-// new QWebChannel(window.qt.webChannelTransport, (channel: any) => {
-//     // all published objects are available in channel.objects under
-//     // the identifier set in their attached WebChannel.id property
-//     qtWebChannel = channel.objects.bridge;
-//     console.log('qtWebChannel', qtWebChannel);
-// });
+new QWebChannel(window.qt.webChannelTransport, (channel: any) => {
+    alert('成功!!!');
+    // all published objects are available in channel.objects under
+    // the identifier set in their attached WebChannel.id property
+    qtWebChannel = channel.objects.bridge;
+    console.log('qtWebChannel', qtWebChannel);
+});
 
 function qtAction(value: any) {
-    // if (qtWebChannel) {
-    //     qtWebChannel.handleCmd('action');
-    // } else {
-    //     alert('qtWebChannel is null');
-    // }
+    if (qtWebChannel) {
+        qtWebChannel.handleCmd('action');
+    } else {
+        alert('qtWebChannel is null');
+    }
 }
 
 export default defineComponent({