From acdeb5cc442abecf58b5857945f953c487694e92 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sat, 6 Jul 2024 10:54:05 +0900 Subject: [PATCH] refactor --- packages/frontend/src/scripts/embed-page.ts | 4 +++- packages/frontend/src/scripts/get-embed-code.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/scripts/embed-page.ts b/packages/frontend/src/scripts/embed-page.ts index 67f5cc8802..6b91634a9e 100644 --- a/packages/frontend/src/scripts/embed-page.ts +++ b/packages/frontend/src/scripts/embed-page.ts @@ -62,8 +62,10 @@ export function parseEmbedParams(searchParams: URLSearchParams | string): Parsed let _searchParams: URLSearchParams; if (typeof searchParams === 'string') { _searchParams = new URLSearchParams(searchParams); - } else { + } else if (searchParams instanceof URLSearchParams) { _searchParams = searchParams; + } else { + throw new Error('searchParams must be URLSearchParams or string'); } const params: EmbedParams = {}; diff --git a/packages/frontend/src/scripts/get-embed-code.ts b/packages/frontend/src/scripts/get-embed-code.ts index c66deb9cc7..e5a2858fdd 100644 --- a/packages/frontend/src/scripts/get-embed-code.ts +++ b/packages/frontend/src/scripts/get-embed-code.ts @@ -2,6 +2,7 @@ * SPDX-FileCopyrightText: syuilo and misskey-project * SPDX-License-Identifier: AGPL-3.0-only */ +import { defineAsyncComponent } from 'vue'; import { v4 as uuid } from 'uuid'; import { url } from '@/config.js'; import { MOBILE_THRESHOLD } from '@/const.js'; @@ -9,7 +10,6 @@ import * as os from '@/os.js'; import copy from '@/scripts/copy-to-clipboard.js'; import type { EmbedParams, EmbeddableEntity } from '@/scripts/embed-page.js'; import { defaultEmbedParams, embedRouteWithScrollbar } from '@/scripts/embed-page.js'; -import MkEmbedCodeGenDialog from '@/components/MkEmbedCodeGenDialog.vue'; /** * パラメータを正規化する(埋め込みコード作成用) @@ -76,7 +76,7 @@ export function copyEmbedCode(entity: EmbeddableEntity, idOrUsername: string, pa copy(getEmbedCode(`/embed/${entity}/${_idOrUsername}`, _params)); os.success(); } else { - const { dispose } = os.popup(MkEmbedCodeGenDialog, { + const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkEmbedCodeGenDialog.vue')), { entity, idOrUsername, params: _params,