From c42d184208b2c44a01e426cbd0667c198c153eb4 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Thu, 22 Aug 2024 17:32:24 +0900 Subject: [PATCH] Update boot.ts --- packages/embed/src/boot.ts | 50 ++++---------------------------------- 1 file changed, 5 insertions(+), 45 deletions(-) diff --git a/packages/embed/src/boot.ts b/packages/embed/src/boot.ts index c9248e0dcd..f8d6ea42a7 100644 --- a/packages/embed/src/boot.ts +++ b/packages/embed/src/boot.ts @@ -8,37 +8,16 @@ import 'vite/modulepreload-polyfill'; import '@/style.scss'; import { createApp, defineAsyncComponent } from 'vue'; -import type { CommonBootOptions } from '@/boot/common.js'; -import { common } from '@/boot/common.js'; import { setIframeId, postMessageToParentWindow } from '@/scripts/post-message.js'; import { parseEmbedParams } from '@/scripts/embed-page.js'; -import { defaultStore } from '@/store.js'; -import { useRouter } from '@/router/supplier.js'; import { createEmbedRouter } from '@/router.js'; -const bootOptions: Partial = { - routerFactory: createEmbedRouter, -}; - const params = new URLSearchParams(location.search); const embedParams = parseEmbedParams(params); -// カラーモードのオーバーライド -if (embedParams.colorMode != null) { - bootOptions.forceColorMode = embedParams.colorMode; -} - // サイズの制限 document.documentElement.style.maxWidth = '500px'; -// サーバー起動の場合はもとから付与されているけど一応 -document.documentElement.classList.add('embed'); - -// 外部タブでのstoreの変更の影響を受けないように -defaultStore.setConfig({ - disableMessageChannel: true, -}); - // iframeIdの設定 function setIframeIdHandler(event: MessageEvent) { if (event.data?.type === 'misskey:embedParent:registerIframeId' && event.data.payload?.iframeId != null) { @@ -49,30 +28,11 @@ function setIframeIdHandler(event: MessageEvent) { window.addEventListener('message', setIframeIdHandler); -// 起動 -common(() => createApp( +const app = createApp( defineAsyncComponent(() => import('@/ui.vue')), -), bootOptions).then(async ({ app }) => { - //#region Embed Provide - app.provide('EMBED_PAGE', true); - app.provide('embedParams', embedParams); - //#endregion +); - //#region defaultStoreを書き換え - await defaultStore.ready; +//#region Embed Provide +app.provide('embedParams', embedParams); +//#endregion - defaultStore.set('sound_notUseSound', true); - //#endregion - - //#region Embed Link Behavior - //強制的に新しいタブで開く - const router = useRouter(); - router.navHook = (path, flag): boolean => { - window.open(path, '_blank', 'noopener'); - return true; - }; - //#endregion - - // 起動完了を通知(このあとクライアント側から misskey:embedParent:registerIframeId が送信される) - postMessageToParentWindow('misskey:embed:ready'); -});