-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da93faa
commit 7eff529
Showing
748 changed files
with
248,560 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
"use strict"; | ||
const electron = require("electron"); | ||
const path = require("node:path"); | ||
var Store = require("electron-store"); | ||
const store = new Store(); | ||
require("@electron/remote/main").initialize(); | ||
var t = store.get("localTime"); | ||
if (!t) { | ||
store.set("localTime", (/* @__PURE__ */ new Date()).getTime()); | ||
} | ||
process.env.DIST = path.join(__dirname, "../dist"); | ||
process.env.VITE_PUBLIC = electron.app.isPackaged ? process.env.DIST : path.join(process.env.DIST, "../public"); | ||
let win; | ||
const VITE_DEV_SERVER_URL = process.env["VITE_DEV_SERVER_URL"]; | ||
function createWindow() { | ||
win = new electron.BrowserWindow({ | ||
width: 1200, | ||
height: 800, | ||
icon: path.join(process.env.VITE_PUBLIC, "icon.png"), | ||
webPreferences: { | ||
// preload: path.join(__dirname, 'preload.js'), | ||
nodeIntegration: true, | ||
contextIsolation: false, | ||
webSecurity: false, | ||
enableRemoteModule: true | ||
} | ||
}); | ||
require("@electron/remote/main").enable(win.webContents); | ||
win.webContents.on("did-finish-load", () => { | ||
win == null ? void 0 : win.webContents.send("main-process-message", ""); | ||
}); | ||
electron.Menu.setApplicationMenu(null); | ||
if (VITE_DEV_SERVER_URL) { | ||
win.loadURL(VITE_DEV_SERVER_URL); | ||
} else { | ||
win.loadFile(path.join(process.env.DIST, "index.html")); | ||
} | ||
} | ||
electron.app.on("window-all-closed", () => { | ||
if (process.platform !== "darwin") { | ||
electron.app.quit(); | ||
win = null; | ||
} | ||
}); | ||
electron.app.on("activate", () => { | ||
if (electron.BrowserWindow.getAllWindows().length === 0) { | ||
createWindow(); | ||
} | ||
}); | ||
electron.app.whenReady().then(createWindow); | ||
electron.ipcMain.on("openExportWindow", (e, arg) => { | ||
var w = new electron.BrowserWindow({ | ||
// icon: path.join(process.env.VITE_PUBLIC, 'icon.png') | ||
webPreferences: { | ||
// preload: path.join(__dirname, 'preload.js'), | ||
nodeIntegration: true, | ||
contextIsolation: false, | ||
webSecurity: false, | ||
enableRemoteModule: true | ||
} | ||
}); | ||
require("@electron/remote/main").enable(w.webContents); | ||
w.webContents.on("did-finish-load", () => { | ||
w == null ? void 0 : w.webContents.send("main-process-message", arg); | ||
}); | ||
if (VITE_DEV_SERVER_URL) { | ||
win.loadURL(VITE_DEV_SERVER_URL); | ||
} else { | ||
win.loadFile(path.join(process.env.DIST, "index.html")); | ||
} | ||
}); | ||
electron.app.on("window-all-closed", () => { | ||
electron.app.quit(); | ||
}); | ||
electron.ipcMain.on("relaunch", (e, arg) => { | ||
electron.app.relaunch(); | ||
electron.app.exit(); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
"use strict"; | ||
const electron = require("electron"); | ||
electron.contextBridge.exposeInMainWorld("ipcRenderer", withPrototype(electron.ipcRenderer)); | ||
function withPrototype(obj) { | ||
const protos = Object.getPrototypeOf(obj); | ||
for (const [key, value] of Object.entries(protos)) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) | ||
continue; | ||
if (typeof value === "function") { | ||
obj[key] = function(...args) { | ||
return value.call(obj, ...args); | ||
}; | ||
} else { | ||
obj[key] = value; | ||
} | ||
} | ||
return obj; | ||
} | ||
function domReady(condition = ["complete", "interactive"]) { | ||
return new Promise((resolve) => { | ||
if (condition.includes(document.readyState)) { | ||
resolve(true); | ||
} else { | ||
document.addEventListener("readystatechange", () => { | ||
if (condition.includes(document.readyState)) { | ||
resolve(true); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
const safeDOM = { | ||
append(parent, child) { | ||
if (!Array.from(parent.children).find((e) => e === child)) { | ||
parent.appendChild(child); | ||
} | ||
}, | ||
remove(parent, child) { | ||
if (Array.from(parent.children).find((e) => e === child)) { | ||
parent.removeChild(child); | ||
} | ||
} | ||
}; | ||
function useLoading() { | ||
const className = `loaders-css__square-spin`; | ||
const styleContent = ` | ||
@keyframes square-spin { | ||
25% { transform: perspective(100px) rotateX(180deg) rotateY(0); } | ||
50% { transform: perspective(100px) rotateX(180deg) rotateY(180deg); } | ||
75% { transform: perspective(100px) rotateX(0) rotateY(180deg); } | ||
100% { transform: perspective(100px) rotateX(0) rotateY(0); } | ||
} | ||
.${className} > div { | ||
animation-fill-mode: both; | ||
width: 50px; | ||
height: 50px; | ||
background: #fff; | ||
animation: square-spin 3s 0s cubic-bezier(0.09, 0.57, 0.49, 0.9) infinite; | ||
} | ||
.app-loading-wrap { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100vw; | ||
height: 100vh; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
background: #282c34; | ||
z-index: 9; | ||
} | ||
`; | ||
const oStyle = document.createElement("style"); | ||
const oDiv = document.createElement("div"); | ||
oStyle.id = "app-loading-style"; | ||
oStyle.innerHTML = styleContent; | ||
oDiv.className = "app-loading-wrap"; | ||
oDiv.innerHTML = `<div class="${className}"><div></div></div>`; | ||
return { | ||
appendLoading() { | ||
safeDOM.append(document.head, oStyle); | ||
safeDOM.append(document.body, oDiv); | ||
}, | ||
removeLoading() { | ||
safeDOM.remove(document.head, oStyle); | ||
safeDOM.remove(document.body, oDiv); | ||
} | ||
}; | ||
} | ||
const { appendLoading, removeLoading } = useLoading(); | ||
domReady().then(appendLoading); | ||
window.onmessage = (ev) => { | ||
ev.data.payload === "removeLoading" && removeLoading(); | ||
}; | ||
setTimeout(removeLoading, 4999); |
Oops, something went wrong.