This commit is contained in:
2022-04-05 21:26:02 +08:00
commit dffc739c40
20 changed files with 39396 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
const { openSite } = require("./site");
const { ipcRenderer } = require("electron");
const { reSize } = require("./windows");
const ipc = {
site: {
open: openSite,
},
windows: {
reSize: reSize,
},
};
function getAPI(namespace) {
let api = {};
for (const key in ipc[namespace]) {
api[key] = (...props) => ipcRenderer.send(namespace + "-" + key, ...props);
}
console.log(api);
return api;
}
module.exports = {
ipc,
getAPI,
};
+18
View File
@@ -0,0 +1,18 @@
const { shell } = require("electron");
const openSite = (url, success, fail) => {
console.log("opensite");
console.log(url);
shell
.openExternal(url)
.then(() => {
if (success) success();
})
.catch((e) => {
if (fail) fail(e);
});
};
module.exports = {
openSite,
};
+7
View File
@@ -0,0 +1,7 @@
const reSize = (width, height) => {
global.windows.setSize(width, height);
};
module.exports = {
reSize,
};