diff --git a/components/app/windows/login.vue b/components/app/windows/login.vue new file mode 100644 index 0000000..c392aee --- /dev/null +++ b/components/app/windows/login.vue @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/pages/app/index.vue b/pages/app/index.vue index 3c7350e..f2a1f9a 100644 --- a/pages/app/index.vue +++ b/pages/app/index.vue @@ -5,10 +5,22 @@ definePageMeta({ import { gsap } from "gsap"; import { TextPlugin } from "gsap/TextPlugin"; gsap.registerPlugin(TextPlugin); -const { t } = useI18n(); + +// Import Windows +import SignIn from "~/components/app/windows/login.vue"; + +// Icons +import { ComputerDesktopIcon, UserIcon } from "@heroicons/vue/24/outline"; + +// i18n +const { t, locale, locales } = useI18n(); const localePath = useLocalePath(); +// Router const router = useRouter(); +// values const popMessage = ref(null); +const menuOpen = ref(false); +// Date const currentDate = ref( new Date().toLocaleDateString("zh-TW", { month: "2-digit", @@ -20,7 +32,6 @@ const currentDate = ref( hour12: false, }), ); - onMounted(() => { setInterval(() => { currentDate.value = new Date().toLocaleDateString("zh-TW", { @@ -35,15 +46,61 @@ onMounted(() => { }, 1000); }); -import { ComputerDesktopIcon } from "@heroicons/vue/24/outline"; +// functions +const showLogin = () => { + const loginWindow = document.createElement("div"); + loginWindow.className = "login-window"; + document.body.appendChild(loginWindow); + const app = createApp(SignIn); + app.component("SignIn", SignIn); + app.mount(loginWindow); + setTimeout(() => { + gsap.fromTo( + loginWindow, + { opacity: 0, scale: 0.5 }, + { opacity: 1, scale: 1, duration: 0.5 }, + ); + }, 100); + setTimeout(() => { + gsap.to(loginWindow, { + opacity: 0, + scale: 0.5, + duration: 0.5, + onComplete: () => { + document.body.removeChild(loginWindow); + }, + }); + }, 5000); +} +// menu +const menuItems = [ + { name: "Hot News", action: () => router.push(localePath("/app/hotnews")) }, + { name: "News", action: () => router.push(localePath("/app/news")) }, + { name: "Sources", action: () => router.push(localePath("/sources")) }, + { type: "separator" }, + { name: 'About This Website', action: () => console.log('About') }, + { name: 'Settings', action: () => router.push('/settings') }, + { type: 'separator' }, + { name: 'Leave', action: () => router.push(localePath('/')) }, +] +const toggleMenu = () => { + menuOpen.value = !menuOpen.value +} +onMounted(() => { + document.addEventListener('click', (e) => { + if (!(e.target as HTMLElement).closest('.menu-container')) { + menuOpen.value = false + } + }) +})