From 215f7f082620338246e7657c6ea2f48da72d823e Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sun, 15 Sep 2024 17:09:13 +0900 Subject: [PATCH] =?UTF-8?q?reloadAsk=E3=82=92=E6=B1=8E=E7=94=A8=E5=8C=96?= =?UTF-8?q?=E3=80=81=E7=90=86=E7=94=B1=E3=82=92=E5=8F=97=E3=81=91=E5=8F=96?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/index.d.ts | 2 +- locales/ja-JP.yml | 2 +- .../frontend/src/pages/settings/general.vue | 2 +- .../frontend/src/pages/settings/navbar.vue | 4 ++-- .../frontend/src/pages/settings/other.vue | 2 +- .../frontend/src/pages/settings/theme.vue | 2 +- packages/frontend/src/scripts/reload-ask.ts | 19 +++++++++++++++---- 7 files changed, 22 insertions(+), 11 deletions(-) diff --git a/locales/index.d.ts b/locales/index.d.ts index fecc5703950d..b06e0f245b19 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -3121,7 +3121,7 @@ export interface Locale extends ILocale { */ "narrow": string; /** - * 設定はページリロード後に反映されます。今すぐリロードしますか? + * 設定はページリロード後に反映されます。 */ "reloadToApplySetting": string; /** diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index a1210bad2948..d8a6f5591372 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -776,7 +776,7 @@ left: "左" center: "中央" wide: "広い" narrow: "狭い" -reloadToApplySetting: "設定はページリロード後に反映されます。今すぐリロードしますか?" +reloadToApplySetting: "設定はページリロード後に反映されます。" needReloadToApply: "反映には再起動が必要です。" showTitlebar: "タイトルバーを表示する" clearCache: "キャッシュをクリア" diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index 8e5e37dc2de4..69238b043693 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -359,7 +359,7 @@ watch([ confirmWhenRevealingSensitiveMedia, contextMenu, ], async () => { - await reloadAsk(); + await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true }); }); const emojiIndexLangs = ['en-US', 'ja-JP', 'ja-JP_hira'] as const; diff --git a/packages/frontend/src/pages/settings/navbar.vue b/packages/frontend/src/pages/settings/navbar.vue index ca63cff9acd2..a0e6cad9c8d4 100644 --- a/packages/frontend/src/pages/settings/navbar.vue +++ b/packages/frontend/src/pages/settings/navbar.vue @@ -90,7 +90,7 @@ function removeItem(index: number) { async function save() { defaultStore.set('menu', items.value.map(x => x.type)); - await reloadAsk(); + await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true }); } function reset() { @@ -101,7 +101,7 @@ function reset() { } watch(menuDisplay, async () => { - await reloadAsk(); + await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true }); }); const headerActions = computed(() => []); diff --git a/packages/frontend/src/pages/settings/other.vue b/packages/frontend/src/pages/settings/other.vue index 089f022a8021..0f7609c83e95 100644 --- a/packages/frontend/src/pages/settings/other.vue +++ b/packages/frontend/src/pages/settings/other.vue @@ -145,7 +145,7 @@ async function updateRepliesAll(withReplies: boolean) { watch([ enableCondensedLineForAcct, ], async () => { - await reloadAsk(); + await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true }); }); const headerActions = computed(() => []); diff --git a/packages/frontend/src/pages/settings/theme.vue b/packages/frontend/src/pages/settings/theme.vue index 6cd70c69e049..6bd51754d6f9 100644 --- a/packages/frontend/src/pages/settings/theme.vue +++ b/packages/frontend/src/pages/settings/theme.vue @@ -144,7 +144,7 @@ watch(wallpaper, () => { } else { miLocalStorage.setItem('wallpaper', wallpaper.value); } - reloadAsk(); + await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true }); }); onActivated(() => { diff --git a/packages/frontend/src/scripts/reload-ask.ts b/packages/frontend/src/scripts/reload-ask.ts index cf90e6676e22..733d91b85ab4 100644 --- a/packages/frontend/src/scripts/reload-ask.ts +++ b/packages/frontend/src/scripts/reload-ask.ts @@ -9,21 +9,32 @@ import { unisonReload } from '@/scripts/unison-reload.js'; let isReloadConfirming = false; -export async function reloadAsk() { +export async function reloadAsk(opts: { + unison?: boolean; + reason?: string; +}) { if (isReloadConfirming) { return; } isReloadConfirming = true; - const { canceled } = await os.confirm({ + const { canceled } = await os.confirm(opts.reason == null ? { type: 'info', - text: i18n.ts.reloadToApplySetting, + text: i18n.ts.reloadConfirm, + } : { + type: 'info', + title: i18n.ts.reloadConfirm, + text: opts.reason, }).finally(() => { isReloadConfirming = false; }); if (canceled) return; - unisonReload(); + if (opts.unison) { + unisonReload(); + } else { + location.reload(); + } }