mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-24 00:39:32 +09:00
Update boot.ts
This commit is contained in:
parent
2398a8013d
commit
c42d184208
@ -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<CommonBootOptions> = {
|
||||
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');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user