123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import { createApp, h } from "vue";
- import LoginDialog from "@/components/LoginDialog.vue";
- export function openLoginDialog(
- options: {
- onLogin?: (data: { username: string; password: string }) => void;
- onRegister?: () => void;
- onForgot?: () => void;
- onClose?: () => void;
- } = {}
- ) {
- const container = document.createElement("div");
- document.body.appendChild(container);
- const app = createApp({
- render() {
- return h(LoginDialog, {
- onLogin: (data: any) => {
- options.onLogin?.(data);
- app.unmount();
- document.body.removeChild(container);
- },
- onRegister: () => {
- options.onRegister?.();
- app.unmount();
- document.body.removeChild(container);
- },
- onForgot: () => {
- options.onForgot?.();
- },
- onClose: () => {
- options.onClose?.();
- app.unmount();
- document.body.removeChild(container);
- },
- ref: "dialog",
- });
- },
- mounted() {
- this.$refs.dialog.open();
- },
- });
- app.mount(container);
- }
|