|
|
@@ -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({
|