From 57906fd563328f2abb8da95890e791f8a1de3547 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:38:18 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=8E=E3=83=BC=E3=83=9E=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=82=BA=E5=87=A6=E7=90=86=E3=82=92=E5=85=B1=E9=80=9A=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/MkEmbedCodeGenDialog.vue | 10 +++++----- packages/frontend/src/scripts/get-embed-code.ts | 13 ++++++++++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/frontend/src/components/MkEmbedCodeGenDialog.vue b/packages/frontend/src/components/MkEmbedCodeGenDialog.vue index 2b64fd891b..713e527a3f 100644 --- a/packages/frontend/src/components/MkEmbedCodeGenDialog.vue +++ b/packages/frontend/src/components/MkEmbedCodeGenDialog.vue @@ -124,12 +124,12 @@ function ok() { // 本URL生成用params const paramsForUrl = computed(() => ({ - header: header.value === true ? undefined : header.value, - autoload: autoload.value === false ? undefined : autoload.value, + header: header.value, + autoload: autoload.value, maxHeight: typeof maxHeight.value === 'number' ? Math.max(0, maxHeight.value) : undefined, colorMode: colorMode.value === 'auto' ? undefined : colorMode.value, - rounded: rounded.value === true ? undefined : rounded.value, - border: border.value === true ? undefined : border.value, + rounded: rounded.value, + border: border.value, })); // プレビュー用params(手動で更新を掛けるのでref) @@ -142,7 +142,7 @@ const embedPreviewUrl = computed(() => { const maxHeight = parseInt(paramClass.get('maxHeight')!); paramClass.set('maxHeight', maxHeight === 0 ? '500' : Math.min(maxHeight, 700).toString()); // プレビューであまりにも縮小されると見づらいため、700pxまでに制限 } - return `${url}/embed/${props.entity}/${_idOrUsername}?${paramClass.toString()}`; + return `${url}/embed/${props.entity}/${_idOrUsername}${paramClass.toString() ? '?' + paramClass.toString() : ''}`; }); const isEmbedWithScrollbar = computed(() => embedRouteWithScrollbar.includes(props.entity)); diff --git a/packages/frontend/src/scripts/get-embed-code.ts b/packages/frontend/src/scripts/get-embed-code.ts index 33e0601e12..946c2bc1a8 100644 --- a/packages/frontend/src/scripts/get-embed-code.ts +++ b/packages/frontend/src/scripts/get-embed-code.ts @@ -35,11 +35,22 @@ export type EmbedParams = { header?: boolean; }; +// パラメータのデフォルトの値 +export const defaultEmbedParams: EmbedParams = { + maxHeight: undefined, + colorMode: undefined, + rounded: true, + border: true, + autoload: false, + header: true, +}; + export function normalizeEmbedParams(params: EmbedParams): Record { // paramsのvalueをすべてstringに変換。undefinedやnullはプロパティごと消す const normalizedParams: Record = {}; for (const key in params) { - if (params[key] == null) { + // デフォルトの値と同じならparamsに含めない + if (params[key] == null || params[key] === defaultEmbedParams[key]) { continue; } switch (typeof params[key]) {