fix type of MkModalPageWindow
This commit is contained in:
parent
5da03666b2
commit
2bf51abc12
9 changed files with 33 additions and 29 deletions
|
@ -182,8 +182,8 @@ function describe() {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
done: (result: {
|
done: (result: {
|
||||||
canceled: boolean,
|
canceled: boolean;
|
||||||
result?: string | null,
|
result?: string | null;
|
||||||
}) => {
|
}) => {
|
||||||
if (!result || result.canceled) return;
|
if (!result || result.canceled) return;
|
||||||
const comment = result.result;
|
const comment = result.result;
|
||||||
|
|
|
@ -73,7 +73,7 @@ import { deviceKind } from "@/scripts/device-kind";
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
src?: HTMLElement;
|
src?: HTMLElement;
|
||||||
anchor?: {
|
anchor?: {
|
||||||
x: "left" | "center" | "right";
|
x: "left" | "center" | "right";
|
||||||
y: "top" | "center" | "bottom";
|
y: "top" | "center" | "bottom";
|
||||||
};
|
};
|
||||||
|
|
|
@ -108,7 +108,7 @@ type ModalTypes = "popup" | "dialog" | "dialog:top" | "drawer";
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
manualShowing?: boolean | null;
|
manualShowing?: boolean | null;
|
||||||
anchor?: {
|
anchor?: {
|
||||||
x: "left" | "center" | "right";
|
x: "left" | "center" | "right";
|
||||||
y: "top" | "center" | "bottom";
|
y: "top" | "center" | "bottom";
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<button
|
<button
|
||||||
class="_button"
|
class="_button"
|
||||||
:aria-label="i18n.ts.close"
|
:aria-label="i18n.ts.close"
|
||||||
@click="$refs.modal.close()"
|
@click="modal!.close()"
|
||||||
>
|
>
|
||||||
<i :class="icon('ph-x')"></i>
|
<i :class="icon('ph-x')"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@ -65,6 +65,7 @@ import type { PageMetadata } from "@/scripts/page-metadata";
|
||||||
import { provideMetadataReceiver } from "@/scripts/page-metadata";
|
import { provideMetadataReceiver } from "@/scripts/page-metadata";
|
||||||
import { Router } from "@/nirax";
|
import { Router } from "@/nirax";
|
||||||
import icon from "@/scripts/icon";
|
import icon from "@/scripts/icon";
|
||||||
|
import type { MenuItem } from "@/types/menu";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
initialPath: string;
|
initialPath: string;
|
||||||
|
@ -81,11 +82,11 @@ router.addListener("push", (ctx) => {});
|
||||||
|
|
||||||
const pageMetadata = ref<null | ComputedRef<PageMetadata>>();
|
const pageMetadata = ref<null | ComputedRef<PageMetadata>>();
|
||||||
const rootEl = ref();
|
const rootEl = ref();
|
||||||
const modal = ref<InstanceType<typeof MkModal>>();
|
const modal = ref<InstanceType<typeof MkModal> | null>(null);
|
||||||
const path = ref(props.initialPath);
|
const path = ref(props.initialPath);
|
||||||
const width = ref(860);
|
const width = ref(860);
|
||||||
const height = ref(660);
|
const height = ref(660);
|
||||||
const history = [];
|
const history: string[] = [];
|
||||||
|
|
||||||
provide("router", router);
|
provide("router", router);
|
||||||
provideMetadataReceiver((info) => {
|
provideMetadataReceiver((info) => {
|
||||||
|
@ -95,7 +96,7 @@ provide("shouldOmitHeaderTitle", true);
|
||||||
provide("shouldHeaderThin", true);
|
provide("shouldHeaderThin", true);
|
||||||
|
|
||||||
const pageUrl = computed(() => url + path.value);
|
const pageUrl = computed(() => url + path.value);
|
||||||
const contextmenu = computed(() => {
|
const contextmenu = computed((): MenuItem[] => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
type: "label",
|
type: "label",
|
||||||
|
@ -117,7 +118,7 @@ const contextmenu = computed(() => {
|
||||||
text: i18n.ts.openInNewTab,
|
text: i18n.ts.openInNewTab,
|
||||||
action: () => {
|
action: () => {
|
||||||
window.open(pageUrl.value, "_blank");
|
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());
|
if (record) history.push(router.getCurrentPath());
|
||||||
router.push(path);
|
router.push(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
function back() {
|
function back() {
|
||||||
navigate(history.pop(), false);
|
const backTo = history.pop();
|
||||||
|
if (backTo) {
|
||||||
|
navigate(backTo, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function expand() {
|
function expand() {
|
||||||
mainRouter.push(path.value);
|
mainRouter.push(path.value);
|
||||||
modal.value.close();
|
modal.value!.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
function popout() {
|
function popout() {
|
||||||
_popout(path.value, rootEl.value);
|
_popout(path.value, rootEl.value);
|
||||||
modal.value.close();
|
modal.value!.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onContextmenu(ev: MouseEvent) {
|
function onContextmenu(ev: MouseEvent) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { shallowRef } from "vue";
|
||||||
import { safeURIDecode } from "@/scripts/safe-uri-decode";
|
import { safeURIDecode } from "@/scripts/safe-uri-decode";
|
||||||
import { pleaseLogin } from "@/scripts/please-login";
|
import { pleaseLogin } from "@/scripts/please-login";
|
||||||
|
|
||||||
interface RouteDef {
|
export interface RouteDef {
|
||||||
path: string;
|
path: string;
|
||||||
component: Component;
|
component: Component;
|
||||||
query?: Record<string, string>;
|
query?: Record<string, string>;
|
||||||
|
|
|
@ -3,10 +3,7 @@
|
||||||
import { EventEmitter } from "eventemitter3";
|
import { EventEmitter } from "eventemitter3";
|
||||||
import { type entities, api as firefishApi } from "firefish-js";
|
import { type entities, api as firefishApi } from "firefish-js";
|
||||||
import insertTextAtCursor from "insert-text-at-cursor";
|
import insertTextAtCursor from "insert-text-at-cursor";
|
||||||
import type {
|
import type { Component, Ref } from "vue";
|
||||||
Component,
|
|
||||||
Ref,
|
|
||||||
} from "vue";
|
|
||||||
import { defineAsyncComponent, markRaw, ref } from "vue";
|
import { defineAsyncComponent, markRaw, ref } from "vue";
|
||||||
import { i18n } from "./i18n";
|
import { i18n } from "./i18n";
|
||||||
import MkDialog from "@/components/MkDialog.vue";
|
import MkDialog from "@/components/MkDialog.vue";
|
||||||
|
@ -177,11 +174,13 @@ export function promiseDialog<T>(
|
||||||
}
|
}
|
||||||
|
|
||||||
let popupIdCount = 0;
|
let popupIdCount = 0;
|
||||||
export const popups = ref<{
|
export const popups = ref<
|
||||||
id: number;
|
{
|
||||||
component: Component;
|
id: number;
|
||||||
props: Record<string, unknown>;
|
component: Component;
|
||||||
}[]>([]);
|
props: Record<string, unknown>;
|
||||||
|
}[]
|
||||||
|
>([]);
|
||||||
|
|
||||||
const zIndexes = {
|
const zIndexes = {
|
||||||
low: 1000000,
|
low: 1000000,
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import type { AsyncComponentLoader } from "vue";
|
import type { AsyncComponentLoader } from "vue";
|
||||||
import { defineAsyncComponent, inject } from "vue";
|
import { defineAsyncComponent, inject } from "vue";
|
||||||
import { isEmojiMod, isModerator, me } from "@/me";
|
import { isEmojiMod, isModerator, me } from "@/me";
|
||||||
import { Router } from "@/nirax";
|
import { type RouteDef, Router } from "@/nirax";
|
||||||
import MkError from "@/pages/_error_.vue";
|
import MkError from "@/pages/_error_.vue";
|
||||||
import MkLoading from "@/pages/_loading_.vue";
|
import MkLoading from "@/pages/_loading_.vue";
|
||||||
|
|
||||||
const page = (loader: AsyncComponentLoader<any>) =>
|
const page = (loader: AsyncComponentLoader) =>
|
||||||
defineAsyncComponent({
|
defineAsyncComponent({
|
||||||
loader,
|
loader,
|
||||||
loadingComponent: MkLoading,
|
loadingComponent: MkLoading,
|
||||||
errorComponent: MkError,
|
errorComponent: MkError,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const routes = [
|
export const routes: RouteDef[] = [
|
||||||
{
|
{
|
||||||
path: "/@:initUser/pages/:initPageName/view-source",
|
path: "/@:initUser/pages/:initPageName/view-source",
|
||||||
component: page(() => import("./pages/page-editor/page-editor.vue")),
|
component: page(() => import("./pages/page-editor/page-editor.vue")),
|
||||||
|
|
|
@ -12,6 +12,7 @@ export interface PageMetadata {
|
||||||
avatar?: entities.UserDetailed | null;
|
avatar?: entities.UserDetailed | null;
|
||||||
userName?: entities.User | null;
|
userName?: entities.User | null;
|
||||||
bg?: string;
|
bg?: string;
|
||||||
|
hideHeader?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function definePageMetadata(
|
export function definePageMetadata(
|
||||||
|
|
|
@ -281,9 +281,9 @@ export type Endpoints = {
|
||||||
"drive/files/attached-notes": { req: TODO; res: Note[] };
|
"drive/files/attached-notes": { req: TODO; res: Note[] };
|
||||||
"drive/files/caption-image": {
|
"drive/files/caption-image": {
|
||||||
req: {
|
req: {
|
||||||
url: string,
|
url: string;
|
||||||
}
|
};
|
||||||
res: string,
|
res: string;
|
||||||
};
|
};
|
||||||
"drive/files/check-existence": { req: TODO; res: TODO };
|
"drive/files/check-existence": { req: TODO; res: TODO };
|
||||||
"drive/files/create": { req: TODO; res: TODO };
|
"drive/files/create": { req: TODO; res: TODO };
|
||||||
|
|
Loading…
Reference in a new issue