Ikms
const { app } = require("electron"); const path = require("path"); app.dock.setIcon(path.join(__dirname, "../assets/IconTemplate@2x.png")); const dockMenu = Menu.buildFromTemplate([ { label: "New Window", click() { console.log("New Window"); }, }, { label: …
const { app, Menu } = require("electron"); const setAppMenu = () => { if (process.platform === "darwin") { const template = [ { label: "Application", submenu: [ { label: "Quit", accelerator: "Command+Q", click: function () { app.quit(); }, }, ], }, { label: …
clipboard 模块在主进程和渲染进程中都可使用。
主进程中使用 const { clipboard } = require("electron"); clipboard.readText(); 渲染进程中使用 const { clipboard } = require("electron"); clipboard.writeText('hello world'); clipboard.readText();
const fs = require("fs"); const filePath = ''; const content = 'hello world'; fs.writeFileSync(filePath, content);
安装 $ npm install sqlite3 $ npm install bluebird App Dao const sqlite3 = require("sqlite3"); const Promise = require("bluebird"); class AppDAO { constructor(dbFilePath) { this.db = new sqlite3.Database(dbFilePath, (err) => { if (err) { console.log("Could not connect to …
安装 $ npm install dayjs 使用 const dayjs = require("dayjs"); const now = dayjs(); const date = now.format("YYYY-MM-DD"); const time = now.format("HH:mm:ss"); const timestamp = now.valueOf(); More https://github.com/iamkun/dayjs
渲染进程(H5 Notification) const notifyMe = () => { const message = '您有新的内容保存到粘贴板'; // Let's check if the browser supports notifications if (!("Notification" in window)) { alert("This browser does not support desktop notification"); } // Let's check whether notification …
const encode = (str) => { var s = ""; if (str.length == 0) return ""; s = str.replace(/&/g, "&"); s = s.replace(/</g, "<"); s = s.replace(/>/g, ">"); s = s.replace(/\s/g, " "); s = s.replace(/\'/g, …
const { shell } = require("electron"); shell.openExternal("https://www.baidu.com");
index.html <body> <div id="app"> <p class="message">{{ message }}</p> </div> </body> <script src="https://unpkg.com/vue@2.6.12/dist/vue.min.js"></script> <script …