fix app startup & render error

This commit is contained in:
Mega Yu
2026-04-30 16:55:32 +08:00
parent 175b4db837
commit 24b73dcbc2
4 changed files with 41 additions and 9 deletions

View File

@@ -42,14 +42,25 @@
(defn $LSUtils [] (aget js/window "LSUtils"))
(def dev? (some-> ($LSUtils) (aget "isDev")))
(defn- callable-export
[module]
(or (when (fn? module)
module)
(when-let [default (some-> module (gobj/get "default"))]
(when (fn? default)
default))
(when-let [module-exports (some-> module (gobj/get "module.exports"))]
(when (fn? module-exports)
module-exports))))
(defn uuid-color
[uuid-str]
(some-> ($LSUtils) (aget "uniqolor")
(apply [uuid-str
#js {:saturation #js [55, 70],
:lightness 70,
:differencePoint 60}])
(aget "color")))
(when-let [uniqolor (some-> ($LSUtils) (aget "uniqolor") callable-export)]
(some-> (uniqolor uuid-str
#js {:saturation #js [55, 70],
:lightness 70,
:differencePoint 60})
(aget "color"))))
(defn get-path
"Returns the component path."

View File

@@ -47,5 +47,11 @@
},
"resolutions": {
"node-abi": "4.28.0"
},
"pnpm": {
"onlyBuiltDependencies": [
"electron",
"keytar"
]
}
}

View File

@@ -23,9 +23,19 @@ const staticCleanKeep = new Set([
])
function run(command, args, options = {}) {
const env = { ...process.env }
for (const [key, value] of Object.entries(options.env ?? {})) {
if (value == null) {
delete env[key]
} else {
env[key] = value
}
}
execFileSync(command, args, {
cwd: options.cwd ?? rootDir,
env: { ...process.env, ...(options.env ?? {}) },
env,
shell: process.platform === 'win32',
stdio: 'inherit',
})
@@ -56,7 +66,10 @@ function ensureStaticNodeModules() {
function electron() {
ensureStaticNodeModules()
run('pnpm', ['electron:dev'], { cwd: staticDir })
run('pnpm', ['electron:dev'], {
cwd: staticDir,
env: { ELECTRON_RUN_AS_NODE: null },
})
}
function versionFromSource() {

View File

@@ -5,7 +5,9 @@
(defn default-export
"Returns the callable/default value from ESM, CommonJS interop, or namespace-shaped modules."
[module]
(or (when (some? module)
(or (when (fn? module)
module)
(when (some? module)
(gobj/get module "default"))
(when (some? module)
(gobj/get module "module.exports"))