-
-
+
+
+
+
+ {{ title }}
+ {{ content }}
+
+
+
+
+
+
+
diff --git a/apps/client/components/main/MessageBox/MessageBox.vue b/apps/client/components/main/MessageBox/MessageBox.vue
deleted file mode 100644
index f7ec60f79..000000000
--- a/apps/client/components/main/MessageBox/MessageBox.vue
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
-
diff --git a/apps/client/components/main/MessageBox/tests/message-box.spec.ts b/apps/client/components/main/MessageBox/tests/message-box.spec.ts
deleted file mode 100644
index 9bfa4767a..000000000
--- a/apps/client/components/main/MessageBox/tests/message-box.spec.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import { flushPromises } from "@vue/test-utils";
-import { afterEach, describe, expect, test } from "vitest";
-
-import MessageBox from "../useMessageBox";
-
-const selector = ".modal";
-
-describe("MessageBox", () => {
- afterEach(async () => {
- MessageBox.close();
- document.body.innerHTML = "";
- await flushPromises();
- });
-
- test("create messageBox", async () => {
- MessageBox("这是一段内容", "消息");
- let msgbox: any = document.querySelector(selector);
-
- expect(msgbox).toBeDefined();
- expect(msgbox.querySelector(".font-bold").textContent).toEqual("消息");
- expect(msgbox.querySelector(".py-4").textContent).toEqual("这是一段内容");
- });
-
- test("close messageBox", async () => {
- MessageBox("这是一段内容", "消息");
-
- MessageBox.close();
- let msgbox: any = document.querySelector(selector);
- expect(msgbox).toBe(null);
- });
-
- describe("promise", () => {
- test("confirm", async () => {
- let msgAction = "";
- MessageBox("此操作将永久删除该文件, 是否继续?", "提示").then((action) => {
- msgAction = action;
- });
- await flushPromises();
- const btn = document.querySelector(selector)!.querySelector(".confirm") as HTMLButtonElement;
- btn.click();
- await flushPromises();
-
- expect(msgAction).toEqual("confirm");
- });
-
- test("cancel", async () => {
- let msgAction = "";
- MessageBox("此操作将永久删除该文件, 是否继续?", "提示").catch((action) => {
- msgAction = action;
- });
- await flushPromises();
- const btn = document.querySelector(selector)!.querySelector(".cancel") as HTMLButtonElement;
- btn.click();
- await flushPromises();
-
- expect(msgAction).toEqual("cancel");
- });
- });
-});
diff --git a/apps/client/components/main/MessageBox/useMessageBox.ts b/apps/client/components/main/MessageBox/useMessageBox.ts
deleted file mode 100644
index ae2822cb5..000000000
--- a/apps/client/components/main/MessageBox/useMessageBox.ts
+++ /dev/null
@@ -1,128 +0,0 @@
-import type { ComponentPublicInstance } from "vue";
-
-import { createVNode, render } from "vue";
-
-import type { IMessageBoxProps } from "~/composables/messageBox/modal";
-import MessageBoxConstructor from "./MessageBox.vue";
-
-interface MessageBoxOptions {
- /** Text content of confirm button */
- confirmBtnText: string;
- /** Text content of cancel button */
- cancelBtnText: string;
- /** Custom element to append the message box to */
- appendTo?: HTMLElement | string;
-}
-
-type Action = "confirm" | "cancel";
-
-interface MessageBoxProps extends IMessageBoxProps {
- container: HTMLElement;
-}
-
-const messageInstance = new Map<
- ComponentPublicInstance
,
- {
- options: any;
- reject: (res: any) => void;
- resolve: (reson?: any) => void;
- }
->();
-
-const genContainer = () => {
- return document.createElement("div");
-};
-
-const getAppendToElement = (props: any): HTMLElement => {
- let appendTo: HTMLElement | null = document.body;
- if (props.appendTo) {
- if (typeof props.appendTo === "string") {
- appendTo = document.querySelector(props.appendTo);
- }
- if (props.appendTo instanceof Element) {
- appendTo = props.appendTo;
- }
- if (!(appendTo instanceof Element)) {
- appendTo = document.body;
- }
- }
- return appendTo;
-};
-
-const teardown = (vm: ComponentPublicInstance, container: HTMLElement) => {
- render(null, container);
- messageInstance.delete(vm);
-};
-
-const initInstance = (props: any, container: HTMLElement) => {
- const vnode = createVNode(MessageBoxConstructor, props);
- render(vnode, container);
- getAppendToElement(props).appendChild(container.firstElementChild!);
- return vnode.component;
-};
-
-const showMessage = (options: any) => {
- const container = genContainer();
-
- options.onConfirm = () => {
- const currentMsg = messageInstance.get(vm)!;
- currentMsg.resolve("confirm");
-
- teardown(vm, container);
- };
-
- options.onCancel = () => {
- const currentMsg = messageInstance.get(vm)!;
- currentMsg.reject("cancel");
-
- teardown(vm, container);
- };
-
- const instance = initInstance(options, container)!;
-
- const vm = instance.proxy as ComponentPublicInstance;
-
- vm.container = container;
-
- for (const prop in options) {
- if (Object.hasOwn(options, prop) && !Object.hasOwn(vm.$props, prop)) {
- vm[prop as keyof ComponentPublicInstance] = options[prop];
- }
- }
-
- return vm;
-};
-
-function MessageBox(
- content: string = "Are you sure?",
- title: string = "Tips",
- options?: MessageBoxOptions,
-): Promise {
- return new Promise((resolve, reject) => {
- const vm = showMessage(
- Object.assign(
- {
- content,
- title,
- isShowModal: true,
- confirmBtnText: "Confirm",
- cancelBtnText: "Cancel",
- },
- options,
- ),
- );
- messageInstance.set(vm, {
- options,
- resolve,
- reject,
- });
- });
-}
-
-MessageBox.close = () => {
- messageInstance.forEach((_, vm) => {
- teardown(vm, vm.container);
- });
-};
-
-export default MessageBox;
diff --git a/apps/client/components/main/Share.vue b/apps/client/components/main/Share.vue
index bc1bb4658..43b7cfc9e 100644
--- a/apps/client/components/main/Share.vue
+++ b/apps/client/components/main/Share.vue
@@ -1,65 +1,59 @@
-
-
+
+
+
+
+