From e9ad7cf226435cf002eeb3db242f3d80a099db29 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sat, 13 Jul 2024 12:35:39 +0900 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E3=83=A2=E3=83=BC=E3=83=80?= =?UTF-8?q?=E3=83=AB=E3=81=8C=E8=A4=87=E6=95=B0=E5=80=8B=E9=96=8B=E3=81=91?= =?UTF-8?q?=E3=82=8B=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/os.ts | 24 ++++++++++++++++++++++++ packages/frontend/src/scripts/hotkey.ts | 1 + 2 files changed, 25 insertions(+) diff --git a/packages/frontend/src/os.ts b/packages/frontend/src/os.ts index 5e332533ef..88cbcd24e9 100644 --- a/packages/frontend/src/os.ts +++ b/packages/frontend/src/os.ts @@ -170,13 +170,33 @@ type EmitsExtractor = { [K in keyof T as K extends `onVnode${string}` ? never : K extends `on${infer E}` ? Uncapitalize : K extends string ? never : K]: T[K]; }; +type PopupOptions = { + /** @default false */ + allowMultiple?: boolean; +}; + export function popup( component: T, props: ComponentProps, events: ComponentEmit = {} as ComponentEmit, + options: PopupOptions = {}, ): { dispose: () => void } { markRaw(component); + const _options: Required = Object.assign({ + allowMultiple: false, + }, options); + + if ( + _options.allowMultiple === false && + popups.value.some(popup => popup.component === component) + ) { + if (_DEV_) console.warn('Popup already exists'); + return { + dispose: () => { }, + }; + } + const id = ++popupIdCount; const dispose = () => { // このsetTimeoutが無いと挙動がおかしくなる(autocompleteが閉じなくなる)。Vueのバグ? @@ -203,6 +223,8 @@ export function pageWindow(path: string) { initialPath: path, }, { closed: () => dispose(), + }, { + allowMultiple: true, }); } @@ -211,6 +233,8 @@ export function toast(message: string) { message, }, { closed: () => dispose(), + }, { + allowMultiple: true, }); } diff --git a/packages/frontend/src/scripts/hotkey.ts b/packages/frontend/src/scripts/hotkey.ts index ff3cbe98ac..04fb235694 100644 --- a/packages/frontend/src/scripts/hotkey.ts +++ b/packages/frontend/src/scripts/hotkey.ts @@ -114,6 +114,7 @@ const matchPatterns = (ev: KeyboardEvent, action: Action) => { const key = ev.key.toLowerCase(); return patterns.some(({ which, ctrl, shift, alt }) => { if ( + options.allowRepeat === false && latestHotkey != null && latestHotkey.which.includes(key) && latestHotkey.ctrl === ctrl &&