Skip to content

Commit

Permalink
dist
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMindCkm committed Mar 6, 2024
1 parent da93faa commit 7eff529
Show file tree
Hide file tree
Showing 748 changed files with 248,560 additions and 4 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
dist-electron
release
*.local

# Editor directories and files
Expand Down
78 changes: 78 additions & 0 deletions dist-electron/main.js
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();
});
77 changes: 77 additions & 0 deletions dist-electron/main/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist-electron/main/main.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

95 changes: 95 additions & 0 deletions dist-electron/preload.js
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);
Loading

0 comments on commit 7eff529

Please sign in to comment.