From 974269b8f16ab06b2bfa7fab48a9d0da56ce9f88 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 28 Jan 2022 12:20:42 +0900 Subject: [PATCH] refactor --- packages/client/src/components/drive.file.vue | 2 +- packages/client/src/components/drive.vue | 2 +- packages/client/src/components/emoji-picker-dialog.vue | 6 +++--- packages/client/src/components/ui/modal.vue | 6 ++++-- packages/client/src/os.ts | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/client/src/components/drive.file.vue b/packages/client/src/components/drive.file.vue index 209e9b7c47..262eae0de1 100644 --- a/packages/client/src/components/drive.file.vue +++ b/packages/client/src/components/drive.file.vue @@ -95,7 +95,7 @@ function onClick(ev: MouseEvent) { if (props.selectMode) { emit('chosen', props.file); } else { - os.popupMenu(getMenu(), (ev.currentTarget ?? ev.target || undefined) as HTMLElement | undefined); + os.popupMenu(getMenu(), (ev.currentTarget ?? ev.target ?? undefined) as HTMLElement | undefined); } } diff --git a/packages/client/src/components/drive.vue b/packages/client/src/components/drive.vue index 0d3f29d4c3..e044c67523 100644 --- a/packages/client/src/components/drive.vue +++ b/packages/client/src/components/drive.vue @@ -591,7 +591,7 @@ function getMenu() { } function showMenu(ev: MouseEvent) { - os.popupMenu(getMenu(), (ev.currentTarget ?? ev.target || undefined) as HTMLElement | undefined); + os.popupMenu(getMenu(), (ev.currentTarget ?? ev.target ?? undefined) as HTMLElement | undefined); } function onContextmenu(ev: MouseEvent) { diff --git a/packages/client/src/components/emoji-picker-dialog.vue b/packages/client/src/components/emoji-picker-dialog.vue index f06a24636c..9a755be0b9 100644 --- a/packages/client/src/components/emoji-picker-dialog.vue +++ b/packages/client/src/components/emoji-picker-dialog.vue @@ -43,9 +43,9 @@ withDefaults(defineProps<{ }); const emit = defineEmits<{ - (e: 'done', v: any): void; - (e: 'close'): void; - (e: 'closed'): void; + (ev: 'done', v: any): void; + (ev: 'close'): void; + (ev: 'closed'): void; }>(); const modal = ref>(); diff --git a/packages/client/src/components/ui/modal.vue b/packages/client/src/components/ui/modal.vue index cb46d38742..c8bf348fdc 100644 --- a/packages/client/src/components/ui/modal.vue +++ b/packages/client/src/components/ui/modal.vue @@ -25,11 +25,13 @@ function getFixedContainer(el: Element | null): Element | null { } } +type ModalTypes = 'popup' | 'dialog' | 'drawer'; + const props = withDefaults(defineProps<{ manualShowing?: boolean; srcCenter?: boolean; src?: HTMLElement; - preferType?: string; + preferType?: ModalTypes | 'auto'; zPriority?: 'low' | 'middle' | 'high'; noOverlap?: boolean; transparentBg?: boolean; @@ -66,7 +68,7 @@ const type = computed(() => { return props.src != null ? 'popup' : 'dialog'; } } else { - return props.preferType; + return props.preferType!; } }); diff --git a/packages/client/src/os.ts b/packages/client/src/os.ts index c16ea717ad..f3be5c68fb 100644 --- a/packages/client/src/os.ts +++ b/packages/client/src/os.ts @@ -403,7 +403,7 @@ export async function selectDriveFolder(multiple: boolean) { }); } -export async function pickEmoji(src?: HTMLElement, opts) { +export async function pickEmoji(src: HTMLElement | null, opts) { return new Promise((resolve, reject) => { popup(import('@/components/emoji-picker-dialog.vue'), { src,