# ElectronQt **Repository Path**: byzihao/electron-qt ## Basic Information - **Project Name**: ElectronQt - **Description**: https://download.csdn.net/download/ruglcc/86242481 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-05-21 - **Last Updated**: 2024-05-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # VUE + QWebChannel + electron QT工程 standalone ## 安装ws qwebchannel ```nodejs npm install ws qwebchannel npm install @types/ws -D ``` ### vue 插件 ```typescript import { App } from 'vue'; import { WebSocket } from "ws"; import { QWebChannel } from "qwebchannel"; let core: any = null; export default { install(app: App) { const wsUrl: string = "ws://localhost:12345"; const ws = new WebSocket(wsUrl); ws.onopen = (e) => { new QWebChannel(ws, function (channel: QWebChannel) { alert("创建") core = channel.objects.core; core.sendText.connect(function (message: string) { alert(message) }); core.sendNum.connect(function (x: number) { alert(x) }); app.config.globalProperties.$core = core; }); }; } } let receiveText = (msg: string) => { core.receiveText(msg); } let onSendText = (callback: (msg: string) => void) => { core.sendText.connect(callback) } export { receiveText,onSendText } ``` ## vue3事件总线 [https://github.com/developit/mitt](https://github.com/developit/mitt)