init
This commit is contained in:
+25
@@ -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
@@ -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,
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
const reSize = (width, height) => {
|
||||
global.windows.setSize(width, height);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
reSize,
|
||||
};
|
||||
Reference in New Issue
Block a user