Lv110版本源码上传

This commit is contained in:
西瓜°
2024-11-04 15:00:40 +08:00
parent a6dbccdead
commit e029da72e4
6642 changed files with 131203 additions and 136087 deletions
+28
View File
@@ -0,0 +1,28 @@
import { ipcRenderer } from "electron"
import { useLoading } from "./loading"
const { appendLoading, removeLoading } = useLoading()
window.removeLoading = removeLoading
window.pywebview = {
api: ipcRenderer
}
// window.sharedObject = {
// storage: "test"
// }
/** docoment ready */
function domReady(condition: DocumentReadyState[] = ["complete", "interactive"]) {
return new Promise(resolve => {
if (condition.includes(document.readyState)) {
resolve(true)
} else {
document.addEventListener("readystatechange", () => {
if (condition.includes(document.readyState)) {
resolve(true)
}
})
}
})
}
domReady().then(appendLoading)
+71
View File
@@ -0,0 +1,71 @@
/**
* https://tobiasahlin.com/spinkit
* https://connoratherton.com/loaders
* https://projects.lukehaas.me/css-loaders
* https://matejkustec.github.io/SpinThatShit
*/
const safe = {
append(parent: HTMLElement, child: HTMLElement) {
if (!Array.from(parent.children).find(e => e === child)) {
return parent.appendChild(child)
}
},
remove(parent: HTMLElement, child: HTMLElement) {
if (Array.from(parent.children).find(e => e === child)) {
return parent.removeChild(child)
}
}
}
export 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: 210px;
height: 213px;
// background: rgba(0,0,0,0);
background-image: url("/images/loading.gif");
// 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() {
safe.append(document.head, oStyle)
safe.append(document.body, oDiv)
},
removeLoading() {
safe.remove(document.head, oStyle)
safe.remove(document.body, oDiv)
}
}
}
+20
View File
@@ -0,0 +1,20 @@
{
"name": "dcalc-preload",
"version": "2022.6.6",
"license": "GNU",
"scripts": {
"build": "vite build"
},
"engines": {
"node": ">=14.17.0"
},
"devDependencies": {
"electron": "22.3.12",
"vite": "^4.5.0"
},
"env": {
"//": "Used in build scripts",
"VITE_DEV_SERVER_HOST": "127.0.0.1",
"VITE_DEV_SERVER_PORT": 25252
}
}
+25
View File
@@ -0,0 +1,25 @@
import { builtinModules } from "node:module"
import { defineConfig } from "vite"
import pkg from "../../package.json"
export default defineConfig({
root: __dirname,
build: {
outDir: "../../dist/app/preload",
lib: {
entry: "index.ts",
formats: ["cjs"],
fileName: () => "[name].cjs"
},
/* from mode option */
sourcemap: process.env.NODE_ENV == "development",
/* from mode option */
minify: process.env.NODE_ENV === "production",
// emptyOutDir: true,
rollupOptions: {
external: ["electron", ...builtinModules,
...builtinModules.map((m) => `node:${m}`),
...Object.keys(pkg.devDependencies || {})]
}
}
})