| | |
| | | import os from 'os' |
| | | // import internetAvailable from "internet-available" |
| | | var internetAvailable = require("internet-available") |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | import { ElMessage, ElMessageBox, ElNotification } from 'element-plus' |
| | | import { on } from 'events' |
| | | |
| | | interface ResultInfo{ |
| | |
| | | let clientCode='' |
| | | // 主进程发送消息到渲染进程 |
| | | ipcRenderer.on('message-koa', (_event, ...args) => { |
| | | |
| | | console.log('koa返回http请求消息', ...args) |
| | | // console.log('koa返回http请求消息', ...args) |
| | | const Result:ResultInfo=args[0] |
| | | writeResult(Result) |
| | | }) |
| | |
| | | }) |
| | | // 主进程获取配置项完成sockte注册和httpshu |
| | | ipcRenderer.on('getConfigData',(_event,...args)=>{ |
| | | console.log('----------------') |
| | | console.log("config.json",...args) |
| | | if(args!==null){ |
| | | if(args[0]===undefined){ |
| | |
| | | else if(args.length>0&&args[0].clientCode.length>0){ |
| | | console.log('配置文件读取') |
| | | clientCode=args[0].clientCode |
| | | // 建立sockte 通讯 |
| | | deviceList=args[0].deviceList |
| | | // 存放conging到仓库 |
| | | confingInfoStore().setconfingInfo(args[0]) |
| | | // connect() |
| | | // creatorClient(args[0]) |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | }) |
| | | setInterval(function(){ |
| | | // 检查网络状态 |
| | | internetAvailable({ |
| | | domainName: "baidu.com", |
| | | host: '114.114.114.114' |
| | | }).then(()=>{ |
| | | internetAvailable().then(()=>{ |
| | | sockteStore().setnetLink(true) |
| | | |
| | | }).catch(()=>{ |
| | | sockteStore().setnetLink(false) |
| | | console.log("网路链接失败") |
| | | // console.log("网路链接失败") |
| | | ElMessage.warning('网络已经断开') |
| | | |
| | | }) |
| | | },10000) |
| | | const writeResult=(res: ResultInfo)=>{ |
| | | console.log(res) |
| | | console.log(`写入结果类型${res.deviceType},写入结果=${res.result}`) |
| | | ipcRenderer.invoke('logger', `收到设备回传结果:类型=${res.deviceType},结果=${res.result}`) |
| | | switch(res.deviceType){ |
| | | case '读卡器': |
| | | console.log('读卡器收到消息') |