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