Made a warning bomb and also is super laggy.

This commit is contained in:
yuanhau 2025-05-12 09:28:46 +08:00
parent 542a22f168
commit 3c3b65c18e
2 changed files with 22 additions and 11 deletions

View file

@ -13,8 +13,8 @@ const emit = defineEmits(['close'])
const isDragging = ref(false) const isDragging = ref(false)
const position = ref({ const position = ref({
x: props.initialX || 100, x: props.initialX || Math.floor(window.innerWidth / 2) - Math.random() * 200,
y: props.initialY || 100 y: props.initialY || Math.floor(window.innerHeight / 2) - Math.random() * 10
}) })
const offset = ref({ x: 0, y: 0 }) const offset = ref({ x: 0, y: 0 })

View file

@ -14,6 +14,13 @@ interface currentNavBarInterface {
windowAssociated: string; windowAssociated: string;
} }
interface associAppWindowInterface {
name: string;
id: string;
title: string;
component: any;
}
// Import plugins // Import plugins
import { gsap } from "gsap"; import { gsap } from "gsap";
import { TextPlugin } from "gsap/TextPlugin"; import { TextPlugin } from "gsap/TextPlugin";
@ -111,7 +118,7 @@ const toggleLangMenu = () => {
} }
// values // values
const activeWindows = ref(); const activeWindows = ref<associAppWindowInterface>([]);
// ?opemapp= component // ?opemapp= component
const openApp = ref(false); const openApp = ref(false);
@ -129,21 +136,23 @@ watch(() => route.query.openapp, (newVal) => {
}); });
const associAppWindow = [ const associAppWindow = [
{ name: "hotnews", component: HotNewsWindow }, { name: "hotnews", id: "1", title: "Hot News", component: HotNewsWindow, width: "600px", height: "400px" },
{ name: "login", component: LoginWindow }, { name: "login", id: "2", title: "Login", component: LoginWindow },
] ]
const findAndOpenWindow = (windowName: string) => { const findAndOpenWindow = (windowName: string) => {
const app = associAppWindow.find((app) => app.name === windowName); const app = associAppWindow.find((app) => app.name === windowName);
console.log("app", app); // Prevent dual logins
console.log("windowName", windowName); if (windowName === "login" && activeWindows.value.some((window) => window.name === "login")) {
console.log("activeWindows.value", activeWindows.value); return;
console.log("associAppWindow", associAppWindow); }
if (app) { if (app) {
activeWindows.value.push({ activeWindows.value.push({
id: `${windowName}-${Date.now()}`, id: `${windowName}-${Date.now()}`,
component: app.component, component: app.component,
title: windowName title: windowName,
width: app.width || "400px",
height: app.height || "300px",
}); });
console.log("html.value", activeWindows.value); console.log("html.value", activeWindows.value);
} else { } else {
@ -209,8 +218,10 @@ const closeWindow = (windowId: string) => {
:key="window.id" :key="window.id"
:title="window.title" :title="window.title"
@close="closeWindow(window.id)" @close="closeWindow(window.id)"
:width="window.width"
:height="window.height"
> >
<component :is="window.component" /> <Component :is="window.component" @error="console.error('Error:', $event)" />
</DraggableWindow> </DraggableWindow>
</div> </div>
<!--Footer--> <!--Footer-->