diff --git a/components/DraggableWindow.vue b/components/DraggableWindow.vue index ba0eedd..18a10ff 100644 --- a/components/DraggableWindow.vue +++ b/components/DraggableWindow.vue @@ -13,8 +13,8 @@ const emit = defineEmits(['close']) const isDragging = ref(false) const position = ref({ - x: props.initialX || 100, - y: props.initialY || 100 + x: props.initialX || Math.floor(window.innerWidth / 2) - Math.random() * 200, + y: props.initialY || Math.floor(window.innerHeight / 2) - Math.random() * 10 }) const offset = ref({ x: 0, y: 0 }) diff --git a/pages/app/desktop/index.vue b/pages/app/desktop/index.vue index 759471c..0e03ed9 100644 --- a/pages/app/desktop/index.vue +++ b/pages/app/desktop/index.vue @@ -14,6 +14,13 @@ interface currentNavBarInterface { windowAssociated: string; } +interface associAppWindowInterface { + name: string; + id: string; + title: string; + component: any; +} + // Import plugins import { gsap } from "gsap"; import { TextPlugin } from "gsap/TextPlugin"; @@ -111,7 +118,7 @@ const toggleLangMenu = () => { } // values -const activeWindows = ref(); +const activeWindows = ref([]); // ?opemapp= component const openApp = ref(false); @@ -129,21 +136,23 @@ watch(() => route.query.openapp, (newVal) => { }); const associAppWindow = [ - { name: "hotnews", component: HotNewsWindow }, - { name: "login", component: LoginWindow }, + { name: "hotnews", id: "1", title: "Hot News", component: HotNewsWindow, width: "600px", height: "400px" }, + { name: "login", id: "2", title: "Login", component: LoginWindow }, ] const findAndOpenWindow = (windowName: string) => { const app = associAppWindow.find((app) => app.name === windowName); - console.log("app", app); - console.log("windowName", windowName); - console.log("activeWindows.value", activeWindows.value); - console.log("associAppWindow", associAppWindow); + // Prevent dual logins + if (windowName === "login" && activeWindows.value.some((window) => window.name === "login")) { + return; + } if (app) { activeWindows.value.push({ id: `${windowName}-${Date.now()}`, component: app.component, - title: windowName + title: windowName, + width: app.width || "400px", + height: app.height || "300px", }); console.log("html.value", activeWindows.value); } else { @@ -209,8 +218,10 @@ const closeWindow = (windowId: string) => { :key="window.id" :title="window.title" @close="closeWindow(window.id)" + :width="window.width" + :height="window.height" > - +