当前位置: 首页 > news >正文

外国的html 素材网站学技术的培训机构

外国的html 素材网站,学技术的培训机构,网站营销管理培训班,网站建设网站网页模板文章目录 渲染进程到主进程#xff08;单向#xff09;渲染进程到主进程#xff08;双向#xff09;主进程到渲染进程 #xff08;单向#xff0c;可模拟双向#xff09; 渲染进程到主进程#xff08;单向#xff09; send #xff08;render 发送#xff09;on 单向渲染进程到主进程双向主进程到渲染进程 单向可模拟双向 渲染进程到主进程单向 send render 发送on main 监听 // main.js 主要代码// electron/main includes types for all main process modules. const { app, ipcMain } require(electron/main) app.whenReady().then((){// 需要在 HTML 文件加载之前监听保证从渲染器调用之前处理程序能够准备就绪。ipcMain.on(set-title, (event, title) {const webContents event.senderconst win BrowserWindow.fromWebContents(webContents)win.setTitle(title)})createWindow(); // 创建窗口 })// preload.js // electron/renderer includes types for all renderer process modules. const { contextBridge, ipcRenderer } require(electron/renderer) contextBridge.exposeInMainWorld(electronAPI, (){setTitle: (title) ipcRenderer.send(set-title,title) })// renderer.js// 插入html中的js, 运行于渲染程序中 const setButton document.getElementById(btn) const titleInput document.getElementById(title) setButton.addEventListener(click, () {const title titleInput.valuewindow.electronAPI.setTitle(title) })渲染进程到主进程双向 invokerender 发送handlemain 监听 const { app, ipcMain, dialog } require(electron/main) app.whenReady().then((){// 需要在 HTML 文件加载之前监听保证从渲染器调用之前处理程序能够准备就绪。// IPC 通道名称上的 dialog: 前缀对代码没有影响。 它仅用作命名空间以帮助提高代码的可读性。ipcMain.handle(dialog:openFile, async () {const { canceled, filePaths } await dialog.showOpenDialog()if(!canceled) return filePaths[0]})createWindow(); // 创建窗口 })// preload.js // electron/renderer includes types for all renderer process modules. const { contextBridge, ipcRenderer } require(electron/renderer) contextBridge.exposeInMainWorld(electronAPI, (){openFile: () ipcRenderer.invoke(dialog:openFile) })// renderer.js// 插入html中的js, 运行于渲染程序中 const setButton document.getElementById(btn) const filePath document.getElementById(filePath) setButton.addEventListener(click, async () {const path await window.electronAPI.openFile()filePath.innerText path })主进程到渲染进程 单向可模拟双向 send on // main.jsconst { app, BrowserWindow, Menu, ipcMain } require(electron/main) const path require(node:path)function createWindow () {const mainWindow new BrowserWindow({webPreferences: {preload: path.join(__dirname, preload.js)}})const menu Menu.buildFromTemplate([{label: app.name,submenu: [{// 使用 webContents.send API 将 IPC 消息从主进程发送到目标渲染器。// 其使用方式与 ipcRenderer.send 相同。click: () mainWindow.webContents.send(update-counter, 1),label: Increment},{click: () mainWindow.webContents.send(update-counter, -1),label: Decrement}]}])Menu.setApplicationMenu(menu)mainWindow.loadFile(index.html) }app.whenReady().then(() {// 模拟双向通信接收渲染进程发送的数据update-counter 触发ipcMain.on(counter-value, (_event, value) {console.log(value) })createWindow() })// preload.jsconst { contextBridge, ipcRenderer } require(electron/renderer) contextBridge.exposeInMainWorld(electronAPI, {onUpdateCounter: (callback) ipcRenderer.on(update-counter, (event,value) callback(value)),sendCount: (value) ipcRender.send(counter-value, value) })// render.js const count document.getElementById(count) window.electronAPI.onUpdateCounter((value){const newValue Number(count.innerText) value;count.innerText newValue.toString();window.electronAPI.sendCount(newValue) })
http://www.w-s-a.com/news/612746/

相关文章:

  • 网站网址相对路径如何设置wordpress怎么加快网站打开速度
  • 有没有能帮人快速网站备案的机构网站建设与制作总结
  • 网站不用了怎么办苏州h5模板建站
  • 网站建设制作定制免费网络短剧
  • 建设部建造师强制注销网站h5响应式网站模板下载
  • 蛋糕网站内容规划建设网站需要多少钱济南兴田德润o厉害吗
  • 企业如何建设网站呢做网站的高手
  • 为什么打开网址都是站长工具开发一款网站需要多少钱
  • 做一个网站app需要多少钱分类信息网站建设计划
  • 怎样下载建设部网站建模培训
  • 北流网站建设制作旅游网站开发目的和目标
  • 网站公司怎么做的网站建设论文二稿
  • 网站建设服务商都有哪些html项目答辩
  • 网站上传到万网主机wordpress视频防盗链
  • 西安建设商城类网站广告设计公司文案
  • 如何建设好高校网站麻辣烫配方教授网站怎么做
  • 宁波网站建设计品牌推广策略分析
  • 网站自建设需要买什么时候开始深圳市建筑市场信息公开平台
  • 平台营销型网站建设小城镇建设的网站文献
  • 燕郊个人做网站小企业网站模板
  • 网站ip需要备案新开河街做网站公司
  • 网站定制设计方案wordpress批量传图片
  • 做外贸兼职的网站设计福州网站开发私人
  • 金华建站模板目前国内有哪些网站做家具回收
  • 个人做网站还是公众号赚钱好部门网站建设和维护
  • 系列图标设计网站推荐建商城网站
  • 中牟建设工程信息网站黑龙江 哈尔滨
  • 网站设计基本结构wap自助建论坛网站
  • 专业番禺网站建设爱做网站外国
  • 深圳罗湖网站设计公司价格制作网站的公司办什么营业执照