fix type of MkModalPageWindow

This commit is contained in:
Lhcfl 2024-04-12 11:31:11 +08:00
parent 5da03666b2
commit 2bf51abc12
9 changed files with 33 additions and 29 deletions

View File

@ -182,8 +182,8 @@ function describe() {
},
{
done: (result: {
canceled: boolean,
result?: string | null,
canceled: boolean;
result?: string | null;
}) => {
if (!result || result.canceled) return;
const comment = result.result;

View File

@ -73,7 +73,7 @@ import { deviceKind } from "@/scripts/device-kind";
const props = withDefaults(
defineProps<{
src?: HTMLElement;
anchor?: {
anchor?: {
x: "left" | "center" | "right";
y: "top" | "center" | "bottom";
};

View File

@ -108,7 +108,7 @@ type ModalTypes = "popup" | "dialog" | "dialog:top" | "drawer";
const props = withDefaults(
defineProps<{
manualShowing?: boolean | null;
anchor?: {
anchor?: {
x: "left" | "center" | "right";
y: "top" | "center" | "bottom";
};

View File

@ -29,7 +29,7 @@
<button
class="_button"
:aria-label="i18n.ts.close"
@click="$refs.modal.close()"
@click="modal!.close()"
>
<i :class="icon('ph-x')"></i>
</button>
@ -65,6 +65,7 @@ import type { PageMetadata } from "@/scripts/page-metadata";
import { provideMetadataReceiver } from "@/scripts/page-metadata";
import { Router } from "@/nirax";
import icon from "@/scripts/icon";
import type { MenuItem } from "@/types/menu";
const props = defineProps<{
initialPath: string;
@ -81,11 +82,11 @@ router.addListener("push", (ctx) => {});
const pageMetadata = ref<null | ComputedRef<PageMetadata>>();
const rootEl = ref();
const modal = ref<InstanceType<typeof MkModal>>();
const modal = ref<InstanceType<typeof MkModal> | null>(null);
const path = ref(props.initialPath);
const width = ref(860);
const height = ref(660);
const history = [];
const history: string[] = [];
provide("router", router);
provideMetadataReceiver((info) => {
@ -95,7 +96,7 @@ provide("shouldOmitHeaderTitle", true);
provide("shouldHeaderThin", true);
const pageUrl = computed(() => url + path.value);
const contextmenu = computed(() => {
const contextmenu = computed((): MenuItem[] => {
return [
{
type: "label",
@ -117,7 +118,7 @@ const contextmenu = computed(() => {
text: i18n.ts.openInNewTab,
action: () => {
window.open(pageUrl.value, "_blank");
modal.value.close();
modal.value!.close();
},
},
{
@ -130,23 +131,26 @@ const contextmenu = computed(() => {
];
});
function navigate(path, record = true) {
function navigate(path: string, record = true) {
if (record) history.push(router.getCurrentPath());
router.push(path);
}
function back() {
navigate(history.pop(), false);
const backTo = history.pop();
if (backTo) {
navigate(backTo, false);
}
}
function expand() {
mainRouter.push(path.value);
modal.value.close();
modal.value!.close();
}
function popout() {
_popout(path.value, rootEl.value);
modal.value.close();
modal.value!.close();
}
function onContextmenu(ev: MouseEvent) {

View File

@ -6,7 +6,7 @@ import { shallowRef } from "vue";
import { safeURIDecode } from "@/scripts/safe-uri-decode";
import { pleaseLogin } from "@/scripts/please-login";
interface RouteDef {
export interface RouteDef {
path: string;
component: Component;
query?: Record<string, string>;

View File

@ -3,10 +3,7 @@
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, Ref } from "vue";
import { defineAsyncComponent, markRaw, ref } from "vue";
import { i18n } from "./i18n";
import MkDialog from "@/components/MkDialog.vue";
@ -177,11 +174,13 @@ export function promiseDialog<T>(
}
let popupIdCount = 0;
export const popups = ref<{
id: number;
component: Component;
props: Record<string, unknown>;
}[]>([]);
export const popups = ref<
{
id: number;
component: Component;
props: Record<string, unknown>;
}[]
>([]);
const zIndexes = {
low: 1000000,

View File

@ -1,18 +1,18 @@
import type { AsyncComponentLoader } from "vue";
import { defineAsyncComponent, inject } from "vue";
import { isEmojiMod, isModerator, me } from "@/me";
import { Router } from "@/nirax";
import { type RouteDef, Router } from "@/nirax";
import MkError from "@/pages/_error_.vue";
import MkLoading from "@/pages/_loading_.vue";
const page = (loader: AsyncComponentLoader<any>) =>
const page = (loader: AsyncComponentLoader) =>
defineAsyncComponent({
loader,
loadingComponent: MkLoading,
errorComponent: MkError,
});
export const routes = [
export const routes: RouteDef[] = [
{
path: "/@:initUser/pages/:initPageName/view-source",
component: page(() => import("./pages/page-editor/page-editor.vue")),

View File

@ -12,6 +12,7 @@ export interface PageMetadata {
avatar?: entities.UserDetailed | null;
userName?: entities.User | null;
bg?: string;
hideHeader?: boolean;
}
export function definePageMetadata(

View File

@ -281,9 +281,9 @@ export type Endpoints = {
"drive/files/attached-notes": { req: TODO; res: Note[] };
"drive/files/caption-image": {
req: {
url: string,
}
res: string,
url: string;
};
res: string;
};
"drive/files/check-existence": { req: TODO; res: TODO };
"drive/files/create": { req: TODO; res: TODO };