From a1e57841e71e442b1bf52e445e6c541f16ec066d Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 21 Feb 2018 02:53:34 +0900 Subject: wip --- src/web/app/init.ts | 43 ++++++++----------------------------------- 1 file changed, 8 insertions(+), 35 deletions(-) (limited to 'src/web/app/init.ts') diff --git a/src/web/app/init.ts b/src/web/app/init.ts index 9e49c4f0fb..b814a18066 100644 --- a/src/web/app/init.ts +++ b/src/web/app/init.ts @@ -34,7 +34,7 @@ Vue.mixin({ import App from './app.vue'; import checkForUpdate from './common/scripts/check-for-update'; -import MiOS from './common/mios'; +import MiOS, { API } from './common/mios'; /** * APP ENTRY POINT! @@ -79,59 +79,32 @@ if (localStorage.getItem('should-refresh') == 'true') { location.reload(true); } -type API = { - chooseDriveFile: (opts: { - title?: string; - currentFolder?: any; - multiple?: boolean; - }) => Promise; - - chooseDriveFolder: (opts: { - title?: string; - currentFolder?: any; - }) => Promise; - - dialog: (opts: { - title: string; - text: string; - actions: Array<{ - text: string; - id: string; - }>; - }) => Promise; - - input: (opts: { - title: string; - placeholder?: string; - default?: string; - }) => Promise; - - post: () => void; -}; - // MiOSを初期化してコールバックする -export default (callback: (launch: (api: API) => Vue) => void, sw = false) => { +export default (callback: (launch: (api: (os: MiOS) => API) => [Vue, MiOS]) => void, sw = false) => { const os = new MiOS(sw); os.init(() => { // アプリ基底要素マウント document.body.innerHTML = '
'; - const launch = (api: API) => { + const launch = (api: (os: MiOS) => API) => { + os.apis = api(os); Vue.mixin({ created() { (this as any).os = os; (this as any).api = os.api; - (this as any).apis = api; + (this as any).apis = os.apis; } }); - return new Vue({ + const app = new Vue({ router: new VueRouter({ mode: 'history' }), render: createEl => createEl(App) }).$mount('#app'); + + return [app, os] as [Vue, MiOS]; }; try { -- cgit v1.2.3-freya