[🐛] Fixed apps not loading
This commit is contained in:
parent
ac8da49df4
commit
3aa3eb9741
1 changed files with 12 additions and 12 deletions
|
|
@ -31,7 +31,7 @@ class Flow {
|
||||||
window.fs.promises.readdir('/Applications').then((list) => {
|
window.fs.promises.readdir('/Applications').then((list) => {
|
||||||
list.forEach((file) => {
|
list.forEach((file) => {
|
||||||
window.fs.promises.readFile('/Applications/' + file).then(content => {
|
window.fs.promises.readFile('/Applications/' + file).then(content => {
|
||||||
if (!content.toString().endsWith('.js')) return
|
if (!file.endsWith('.js') || !file.endsWith('.mjs')) return
|
||||||
if (content.toString() === '') return
|
if (content.toString() === '') return
|
||||||
this.appList.push(`data:text/javascript;base64,${btoa(content.toString())}`)
|
this.appList.push(`data:text/javascript;base64,${btoa(content.toString())}`)
|
||||||
}).catch((e) => console.error(e))
|
}).catch((e) => console.error(e))
|
||||||
|
|
@ -57,19 +57,19 @@ class Flow {
|
||||||
for (const appPath of this.appList) {
|
for (const appPath of this.appList) {
|
||||||
window.preloader.setStatus(`importing appstore apps\n${appPath}`)
|
window.preloader.setStatus(`importing appstore apps\n${appPath}`)
|
||||||
|
|
||||||
try {
|
let error = false
|
||||||
const { default: ImportedApp } = await import(appPath)
|
const { default: ImportedApp } = await import(appPath).catch(async (e: Error) => {
|
||||||
const app = new ImportedApp()
|
|
||||||
app.builtin = false
|
|
||||||
app.meta.icon = app.meta.icon ?? nullIcon
|
|
||||||
|
|
||||||
this.addApp(app)
|
|
||||||
} catch (e: any) {
|
|
||||||
console.error(e)
|
console.error(e)
|
||||||
await window.preloader.setError('apps')
|
await window.preloader.setError('apps')
|
||||||
window.preloader.setStatus(`unable to import ${appPath}\n${(e as Error).name}: ${(e as Error).message}`)
|
window.preloader.setStatus(`unable to import ${appPath}\n${e.name}: ${e.message}`)
|
||||||
break
|
error = true
|
||||||
}
|
})
|
||||||
|
if (error) break
|
||||||
|
const app = new ImportedApp()
|
||||||
|
app.builtin = false
|
||||||
|
app.meta.icon = app.meta.icon ?? nullIcon
|
||||||
|
|
||||||
|
this.addApp(app)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue