[🚑] Fixed FlowOS apps
This commit is contained in:
parent
1e05eaf7f4
commit
df1fa6b268
1 changed files with 40 additions and 16 deletions
|
|
@ -3,17 +3,19 @@ import nullIcon from '../assets/icons/application-default-icon.svg'
|
||||||
|
|
||||||
class Flow {
|
class Flow {
|
||||||
apps: LoadedApp[] = []
|
apps: LoadedApp[] = []
|
||||||
appList: string[] = [
|
defaultAppList: string[] = [
|
||||||
'../builtin/apps/settings.ts',
|
'settings',
|
||||||
'../builtin/apps/music.ts',
|
'music',
|
||||||
'../builtin/apps/files.ts',
|
'files',
|
||||||
'../builtin/apps/editor.ts',
|
'editor',
|
||||||
'../builtin/apps/info.ts',
|
'info',
|
||||||
'../builtin/apps/manager.ts',
|
'manager',
|
||||||
'../builtin/apps/browser.ts',
|
'browser',
|
||||||
'../builtin/apps/store.ts'
|
'store'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
appList: string[] = []
|
||||||
|
|
||||||
plugins: LoadedPlugin[] = []
|
plugins: LoadedPlugin[] = []
|
||||||
pluginList: string[] = []
|
pluginList: string[] = []
|
||||||
|
|
||||||
|
|
@ -22,17 +24,22 @@ class Flow {
|
||||||
*/
|
*/
|
||||||
private async initApps (): Promise<void> {
|
private async initApps (): Promise<void> {
|
||||||
window.preloader.setPending('apps')
|
window.preloader.setPending('apps')
|
||||||
window.preloader.setStatus('importing default apps...')
|
window.preloader.setStatus('importing apps...')
|
||||||
|
|
||||||
await (await window.fs.promises.readdir('/Applications')).forEach((file) => {
|
window.fs.exists('/Applications', (exists) => {
|
||||||
window.fs.promises.readFile('/Applications/' + file).then(content => {
|
if (!exists) window.fs.promises.mkdir('/Applications').catch(e => console.error(e))
|
||||||
this.appList.push(`data:text/javascript;base64,${btoa(content.toString())}`)
|
window.fs.promises.readdir('/Applications').then((list) => {
|
||||||
}).catch(console.error)
|
list.forEach((file) => {
|
||||||
|
window.fs.promises.readFile('/Applications/' + file).then(content => {
|
||||||
|
this.appList.push(`data:text/javascript;base64,${btoa(content.toString())}`)
|
||||||
|
}).catch((e) => console.error(e))
|
||||||
|
})
|
||||||
|
}).catch(e => console.error(e))
|
||||||
})
|
})
|
||||||
|
|
||||||
for (const appPath of this.appList) {
|
for (const appPath of this.defaultAppList) {
|
||||||
window.preloader.setStatus(`importing default apps\n${appPath}`)
|
window.preloader.setStatus(`importing default apps\n${appPath}`)
|
||||||
const { default: ImportedApp } = await import(`${appPath}`).catch(async (e: Error) => {
|
const { default: ImportedApp } = await import(`../builtin/apps/${appPath}.ts`).catch(async (e: Error) => {
|
||||||
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.name}: ${e.message}`)
|
window.preloader.setStatus(`unable to import ${appPath}\n${e.name}: ${e.message}`)
|
||||||
|
|
@ -44,6 +51,23 @@ class Flow {
|
||||||
this.addApp(app)
|
this.addApp(app)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.appList.length > 0) {
|
||||||
|
for (const appPath of this.appList) {
|
||||||
|
window.preloader.setStatus(`importing appstore apps\n${appPath}`)
|
||||||
|
|
||||||
|
const { default: ImportedApp } = await import(/* @vite-ignore */ appPath).catch(async (e: Error) => {
|
||||||
|
console.error(e)
|
||||||
|
await window.preloader.setError('apps')
|
||||||
|
window.preloader.setStatus(`unable to import ${appPath}\n${e.name}: ${e.message}`)
|
||||||
|
})
|
||||||
|
const app = new ImportedApp()
|
||||||
|
app.builtin = false
|
||||||
|
app.meta.icon = app.meta.icon ?? nullIcon
|
||||||
|
|
||||||
|
this.addApp(app)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
window.wm.launcher.style.opacity = '0'
|
window.wm.launcher.style.opacity = '0'
|
||||||
window.wm.launcher.style.filter = 'blur(0px)'
|
window.wm.launcher.style.filter = 'blur(0px)'
|
||||||
window.wm.launcher.style.pointerEvents = 'none'
|
window.wm.launcher.style.pointerEvents = 'none'
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue