From 05899455a8904b15140cd1bfc2be552cfd0e9caf Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Thu, 29 Aug 2024 18:38:05 +0900 Subject: [PATCH] wip --- packages/frontend/src/boot/common.ts | 27 +++++--------------------- packages/frontend/src/boot/sub-boot.ts | 5 ++--- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/packages/frontend/src/boot/common.ts b/packages/frontend/src/boot/common.ts index c0db797b3f..19d30f64ce 100644 --- a/packages/frontend/src/boot/common.ts +++ b/packages/frontend/src/boot/common.ts @@ -15,7 +15,6 @@ import { updateI18n } from '@/i18n.js'; import { $i, refreshAccount, login } from '@/account.js'; import { defaultStore, ColdDeviceStorage } from '@/store.js'; import { fetchInstance, instance } from '@/instance.js'; -import type { IRouter } from '@/nirax.js'; import { deviceKind } from '@/scripts/device-kind.js'; import { reloadChannel } from '@/scripts/unison-reload.js'; import { getUrlWithoutLoginId } from '@/scripts/login-id.js'; @@ -23,22 +22,10 @@ import { getAccountFromId } from '@/scripts/get-account-from-id.js'; import { deckStore } from '@/ui/deck/deck-store.js'; import { miLocalStorage } from '@/local-storage.js'; import { fetchCustomEmojis } from '@/custom-emojis.js'; -import { createMainRouter } from '@/router/definition.js'; import { setupRouter } from '@/router/main.js'; +import { createMainRouter } from '@/router/definition.js'; -export type CommonBootOptions = { - forceColorMode: 'dark' | 'light' | 'auto'; - routerFactory: ((path: string) => IRouter); -}; - -const defaultCommonBootOptions: CommonBootOptions = { - forceColorMode: 'auto', - routerFactory: createMainRouter, -}; - -export async function common(createVue: () => App, partialOptions?: Partial) { - const bootOptions = Object.assign(defaultCommonBootOptions, partialOptions); - +export async function common(createVue: () => App) { console.info(`Misskey v${version}`); if (_DEV_) { @@ -180,19 +167,15 @@ export async function common(createVue: () => App, partialOptions?: Par }); //#region Sync dark mode - if (ColdDeviceStorage.get('syncDeviceDarkMode') && bootOptions.forceColorMode === 'auto') { + if (ColdDeviceStorage.get('syncDeviceDarkMode')) { defaultStore.set('darkMode', isDeviceDarkmode()); } window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (mql) => { - if (ColdDeviceStorage.get('syncDeviceDarkMode') && bootOptions.forceColorMode === 'auto') { + if (ColdDeviceStorage.get('syncDeviceDarkMode')) { defaultStore.set('darkMode', mql.matches); } }); - - if (bootOptions.forceColorMode !== 'auto') { - defaultStore.set('darkMode', bootOptions.forceColorMode === 'dark'); - } //#endregion fetchInstanceMetaPromise.then(() => { @@ -257,7 +240,7 @@ export async function common(createVue: () => App, partialOptions?: Par const app = createVue(); - setupRouter(app, bootOptions.routerFactory); + setupRouter(app, createMainRouter); if (_DEV_) { app.config.performance = true; diff --git a/packages/frontend/src/boot/sub-boot.ts b/packages/frontend/src/boot/sub-boot.ts index 936d0994c5..35c84d5568 100644 --- a/packages/frontend/src/boot/sub-boot.ts +++ b/packages/frontend/src/boot/sub-boot.ts @@ -5,13 +5,12 @@ import { createApp, defineAsyncComponent } from 'vue'; import { common } from './common.js'; -import type { CommonBootOptions } from './common.js'; import { emojiPicker } from '@/scripts/emoji-picker.js'; -export async function subBoot(options?: Partial) { +export async function subBoot() { const { isClientUpdated } = await common(() => createApp( defineAsyncComponent(() => import('@/ui/minimum.vue')), - ), options); + )); emojiPicker.init(); }