refactor: define more cleared type of os.ts

This commit is contained in:
Lhcfl 2024-04-12 09:33:27 +08:00
parent 38668c4c11
commit 9c75dd0b26
2 changed files with 23 additions and 7 deletions

View file

@ -42,7 +42,7 @@ useTooltip(el, (showing) => {
os.popup(
defineAsyncComponent(() => import("@/components/MkUrlPreviewPopup.vue")),
{
showing,
showing: showing.value,
url: props.url,
source: el.value,
},

View file

@ -3,7 +3,13 @@
import { EventEmitter } from "eventemitter3";
import { type entities, api as firefishApi } from "firefish-js";
import insertTextAtCursor from "insert-text-at-cursor";
import type { Component, Ref } from "vue";
import type {
Component,
ComponentPublicInstance,
DefineComponent,
EmitsOptions,
Ref,
} from "vue";
import { defineAsyncComponent, markRaw, ref } from "vue";
import { i18n } from "./i18n";
import MkDialog from "@/components/MkDialog.vue";
@ -196,13 +202,23 @@ export function claimZIndex(
let uniqueId = 0;
export function getUniqueId(): string {
return uniqueId++ + "";
return String(uniqueId++);
}
export async function popup(
component: Component,
props: Record<string, any>,
events = {},
interface VueComponentConstructor<P, E> {
__isFragment?: never;
__isTeleport?: never;
__isSuspense?: never;
new (): {
$props: P;
};
emits?: E;
}
export async function popup<Props, Emits>(
component: VueComponentConstructor<Props, Emits>,
props: Props & Record<string, unknown>,
events: Partial<NonNullable<Emits>> | Record<string, never> = {},
disposeEvent?: string,
) {
markRaw(component);