import { ipcMain } from "electron" import fs from "fs-extra" import path from "path" const homeDir = require("os").homedir() const clockJsonPath = path.resolve(homeDir, ".forceClock/clock.json") fs.ensureFileSync(clockJsonPath) try { console.log(fs.readJSONSync(clockJsonPath)) const job = schedule.scheduleJob('42 * * * *', function(){ console.log('The answer to life, the universe, and everything!'); }); } catch (e) { console.log(e) // 读取JSON文件失败 } ipcMain.on("@func:clock:saveData", function(event, data) { fs.writeJson(clockJsonPath, data) }) ipcMain.handle("@func:clock:getData", function() { return fs.readJSONSync(clockJsonPath) })