This commit is contained in:
parent
d60aa72c63
commit
39d686ad11
|
@ -62,14 +62,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineAsyncComponent, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { Ref, defineAsyncComponent, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { focusPrev, focusNext } from '@/scripts/focus';
|
||||
import MkSwitchButton from '@/components/MkSwitch.button.vue';
|
||||
import { MenuItem, InnerMenuItem, OuterMenuItem, MenuPending, MenuAction, MenuSwitch, MenuParent } from '@/types/menu';
|
||||
import { MenuItem, InnerMenuItem, MenuPending, MenuAction, MenuSwitch, MenuParent } from '@/types/menu';
|
||||
import * as os from '@/os';
|
||||
import { i18n } from '@/i18n';
|
||||
|
||||
const childrenCache = new WeakMap<MenuParent, OuterMenuItem[]>();
|
||||
const childrenCache = new WeakMap<MenuParent, MenuItem[]>();
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
|
@ -152,7 +152,7 @@ function onItemMouseLeave(item) {
|
|||
}
|
||||
|
||||
async function showChildren(item: MenuParent, ev: MouseEvent) {
|
||||
const children = ref<OuterMenuItem[]>([]);
|
||||
const children: Ref<(MenuItem | MenuPending)[]> = ref([]);
|
||||
if (!item.noCache && childrenCache.has(item)) {
|
||||
children.value = childrenCache.get(item)!;
|
||||
} else {
|
||||
|
@ -170,7 +170,7 @@ async function showChildren(item: MenuParent, ev: MouseEvent) {
|
|||
}
|
||||
|
||||
if (props.asDrawer) {
|
||||
os.popupMenu(children, ev.currentTarget ?? ev.target, {
|
||||
os.popupMenu(children.value as MenuItem[], ev.currentTarget ?? ev.target, {
|
||||
onClosing: () => {
|
||||
close();
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ export type MenuA = { type: 'a', href: string, target?: string, download?: strin
|
|||
export type MenuUser = { type: 'user', user: Misskey.entities.User, active?: boolean, indicate?: boolean, action: MenuAction };
|
||||
export type MenuSwitch = { type: 'switch', ref: Ref<boolean>, text: string, disabled?: boolean };
|
||||
export type MenuButton = { type?: 'button', text: string, icon?: string, indicate?: boolean, danger?: boolean, active?: boolean, avatar?: Misskey.entities.User; action: MenuAction };
|
||||
export type MenuParent = { type: 'parent', text: string, icon?: string, noCache?: boolean, children: OuterMenuItem[] | (() => Promise<OuterMenuItem[]> | OuterMenuItem[]) };
|
||||
export type MenuParent = { type: 'parent', text: string, icon?: string, noCache?: boolean, children: MenuItem[] | (() => Promise<MenuItem[]> | MenuItem[]) };
|
||||
|
||||
export type MenuPending = { type: 'pending' };
|
||||
|
||||
export type OuterMenuItem = MenuDivider | MenuNull | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuParent;
|
||||
type OuterMenuItem = MenuDivider | MenuNull | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuParent;
|
||||
type OuterPromiseMenuItem = Promise<MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuParent>;
|
||||
export type MenuItem = OuterMenuItem | OuterPromiseMenuItem;
|
||||
export type InnerMenuItem = MenuDivider | MenuPending | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuParent;
|
||||
|
|
Loading…
Reference in New Issue