随笔分类 -  electron

1
摘要:const fs = window.require('fs').promises // const path = window.require('path') const fileHelper = { readFile:(path) => { return fs.readFile(path,{enc 阅读全文
posted @ 2022-02-07 21:09 13522679763-任国强 阅读(38) 评论(0) 推荐(0)
摘要:export const flattenArr = (arr) => { return arr.reduce((map,item)=>{ map[item.id] = item return map },{}) } export const objToArr = (obj) => { return 阅读全文
posted @ 2022-02-07 21:09 13522679763-任国强 阅读(31) 评论(0) 推荐(0)
摘要:const { BrowserWindow } = require('electron') class AppWindow extends BrowserWindow { constructor(config,urlLocation){ const basicConfig = { width:102 阅读全文
posted @ 2022-02-06 15:33 13522679763-任国强 阅读(34) 评论(0) 推荐(0)
摘要:cnpm i --save-dev devtron require('devtron').install() mainWindow.webContents.openDevTools() 阅读全文
posted @ 2022-02-06 15:32 13522679763-任国强 阅读(60) 评论(0) 推荐(0)
摘要:const { ipcRenderer } = require('electron') window.addEventListener('DOMContentLoaded', () => { document.getElementById('node-version').innerHTML = pr 阅读全文
posted @ 2022-02-06 15:32 13522679763-任国强 阅读(62) 评论(0) 推荐(0)
摘要:-- 是否为 发开环境 cnpm install electron-is-dev --save-dev npm install concurrently --save-dev npm install nodemon --save-dev npm i nodemon --save-dev 配置命令 " 阅读全文
posted @ 2022-02-06 15:31 13522679763-任国强 阅读(99) 评论(0) 推荐(0)
摘要:// 导入文件 const importFiles = () => { remote.dialog.showOpenDialog({ title:'选择导入的 markdown 文件', properties:['openfile','multiSelections'], filters:[ {na 阅读全文
posted @ 2022-02-06 15:29 13522679763-任国强 阅读(166) 评论(0) 推荐(0)
摘要:const {app,shell } = require('electron') let template = [ { label:'文件', submenu:[ { label:'新建', accelerator:'CmdOrCtrl+N', click:(menuItem,browserWind 阅读全文
posted @ 2022-02-06 15:28 13522679763-任国强 阅读(61) 评论(0) 推荐(0)
摘要:remote.getCurrentWindow().close() 阅读全文
posted @ 2022-02-06 15:27 13522679763-任国强 阅读(35) 评论(0) 推荐(0)
摘要:const Store = require('electron-store') const settingsStore = new Store({name:'Settings'}) let savedLocation = settingsStore.get('saveFileLocation') i 阅读全文
posted @ 2022-02-06 15:26 13522679763-任国强 阅读(33) 评论(0) 推荐(0)
摘要:const Store = require('electron-store') const { v4: uuidv4 } = require('uuid'); const path = require('path') class DataStore extends Store { construct 阅读全文
posted @ 2022-01-30 17:08 13522679763-任国强 阅读(218) 评论(0) 推荐(0)
摘要:exports.$ = (id) => { return document.getElementById(id) } exports.convertDuration = (time) => { // 计算分钟 02 020 const minutes = "0" + Math.floor(time/ 阅读全文
posted @ 2022-01-30 17:07 13522679763-任国强 阅读(50) 评论(0) 推荐(0)
摘要:封装公共窗口 class AppWindow extends BrowserWindow { constructor(config,fileLocation){ const baseConfig = { width: 800, height: 600, webPreferences: { nodeI 阅读全文
posted @ 2022-01-30 17:06 13522679763-任国强 阅读(34) 评论(0) 推荐(0)
摘要:// 自动打开调试窗口 mainWindow.webContents.openDevTools() 阅读全文
posted @ 2022-01-30 09:02 13522679763-任国强 阅读(31) 评论(0) 推荐(0)
摘要:npm i nodemon --save-dev 修改启动命令 "scripts": { "start": " nodemon --watch main.js --exec electron ." }, 阅读全文
posted @ 2022-01-30 09:02 13522679763-任国强 阅读(46) 评论(0) 推荐(0)
摘要:const {remote} = require('electron') var rightTemplate = [ { label:"粘贴" , accelerator:'ctrl+c', // 增加快捷键 }, { label:"复制", accelerator:'ctrl+v', // 增加快 阅读全文
posted @ 2022-01-30 09:01 13522679763-任国强 阅读(85) 评论(0) 推荐(0)
摘要:// 打开外部跳转链接 var { shell } = require('electron') var aHref = this.document.querySelector('#aHref') aHref.onclick = function(e){ e.preventDefault() var 阅读全文
posted @ 2022-01-30 09:01 13522679763-任国强 阅读(47) 评论(0) 推荐(0)
摘要:底部通知消息 <body> <button id="notifyBtn">通知消息</button> </body> <script> var notifyBtn = document.getElementById('notifyBtn') var option = { title:'小二,来订单了 阅读全文
posted @ 2022-01-30 09:00 13522679763-任国强 阅读(19) 评论(0) 推荐(0)
摘要:// 绑定全局快捷键 globalShortcut.register('ctrl+e',()=>{ mainWindow.loadURL('http://baidu.com/') }) // 判断是否绑定快捷键 let isRegister = globalShortcut.isRegistered 阅读全文
posted @ 2022-01-30 08:59 13522679763-任国强 阅读(152) 评论(0) 推荐(0)
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="wi 阅读全文
posted @ 2022-01-30 08:58 13522679763-任国强 阅读(33) 评论(0) 推荐(0)

1