From 68175bc38d80c96a47fe731b42c35a2124a748d6 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 21 Jan 2025 10:02:27 +0900 Subject: [PATCH] =?UTF-8?q?enhance(frontend):=20=E3=82=AF=E3=82=A8?= =?UTF-8?q?=E3=83=AA=E3=83=91=E3=83=A9=E3=83=A1=E3=83=BC=E3=82=BF=E3=81=A7?= =?UTF-8?q?ui=E3=82=92=E4=B8=80=E6=99=82=E7=9A=84=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=20(#15240)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: クエリパラメータでuiを一時的に変更できるように * docs(changelog): クエリパラメータでuiを一時的に変更できるように * Update packages/frontend/src/boot/main-boot.ts Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> --------- Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> --- CHANGELOG.md | 1 + packages/frontend/src/boot/main-boot.ts | 40 ++++++++++++++++++++----- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fa49e345..5b7ae0821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Enhance: ノートの添付ファイルを一覧で遡れる「ファイル」タブを追加 (Based on https://github.com/Otaku-Social/maniakey/pull/14) - Enhance: AiScriptの拡張API関数において引数の型チェックをより厳格に +- Enhance: クエリパラメータでuiを一時的に変更できるように #15240 - Fix: 画面サイズが変わった際にナビゲーションバーが自動で折りたたまれない問題を修正 - Fix: サーバー情報メニューに区切り線が不足していたのを修正 - Fix: ノートがログインしているユーザーしか見れない場合にログインダイアログを閉じるとその後の動線がなくなる問題を修正 diff --git a/packages/frontend/src/boot/main-boot.ts b/packages/frontend/src/boot/main-boot.ts index 2bf902947..874e97f3a 100644 --- a/packages/frontend/src/boot/main-boot.ts +++ b/packages/frontend/src/boot/main-boot.ts @@ -7,6 +7,7 @@ import { createApp, defineAsyncComponent, markRaw } from 'vue'; import { ui } from '@@/js/config.js'; import { common } from './common.js'; import type * as Misskey from 'misskey-js'; +import type { Component } from 'vue'; import { i18n } from '@/i18n.js'; import { alert, confirm, popup, post, toast } from '@/os.js'; import { useStream } from '@/stream.js'; @@ -25,13 +26,38 @@ import { type Keymap, makeHotkey } from '@/scripts/hotkey.js'; import { addCustomEmoji, removeCustomEmojis, updateCustomEmojis } from '@/custom-emojis.js'; export async function mainBoot() { - const { isClientUpdated } = await common(() => createApp( - new URLSearchParams(window.location.search).has('zen') || (ui === 'deck' && deckStore.state.useSimpleUiForNonRootPages && location.pathname !== '/') ? defineAsyncComponent(() => import('@/ui/zen.vue')) : - !$i ? defineAsyncComponent(() => import('@/ui/visitor.vue')) : - ui === 'deck' ? defineAsyncComponent(() => import('@/ui/deck.vue')) : - ui === 'classic' ? defineAsyncComponent(() => import('@/ui/classic.vue')) : - defineAsyncComponent(() => import('@/ui/universal.vue')), - )); + const { isClientUpdated } = await common(() => { + let uiStyle = ui; + const searchParams = new URLSearchParams(window.location.search); + + if (!$i) uiStyle = 'visitor'; + + if (searchParams.has('zen')) uiStyle = 'zen'; + if (uiStyle === 'deck' && deckStore.state.useSimpleUiForNonRootPages && location.pathname !== '/') uiStyle = 'zen'; + + if (searchParams.has('ui')) uiStyle = searchParams.get('ui'); + + let rootComponent: Component; + switch (uiStyle) { + case 'zen': + rootComponent = defineAsyncComponent(() => import('@/ui/zen.vue')); + break; + case 'deck': + rootComponent = defineAsyncComponent(() => import('@/ui/deck.vue')); + break; + case 'visitor': + rootComponent = defineAsyncComponent(() => import('@/ui/visitor.vue')); + break; + case 'classic': + rootComponent = defineAsyncComponent(() => import('@/ui/classic.vue')); + break; + default: + rootComponent = defineAsyncComponent(() => import('@/ui/universal.vue')); + break; + } + + return createApp(rootComponent); + }); reactionPicker.init(); emojiPicker.init();