[라우터 방식 변경]
This commit is contained in:
@@ -55,10 +55,10 @@ const subMenus = computed(() => {
|
||||
}));
|
||||
});
|
||||
|
||||
function handleMenuChange(_menuCode: string) {
|
||||
async function handleMenuChange(_menuCode: string) {
|
||||
if (activeMenu.value === "HOME") {
|
||||
showSubmenuBar.value = false;
|
||||
router.push("/");
|
||||
await navigateTo("/");
|
||||
} else {
|
||||
showSubmenuBar.value = true;
|
||||
}
|
||||
|
||||
@@ -101,11 +101,6 @@
|
||||
<script setup lang="ts">
|
||||
import { useUserStore } from "~/stores/user";
|
||||
|
||||
// onMounted(() => {
|
||||
// console.log("index.vue - onMounted");
|
||||
// router.push("/1/");
|
||||
// });
|
||||
|
||||
// 페이지 메타데이터 설정
|
||||
definePageMeta({
|
||||
title: "Home",
|
||||
|
||||
@@ -71,9 +71,9 @@ const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
|
||||
// 이미 로그인된 경우 홈으로 리다이렉션
|
||||
onMounted(() => {
|
||||
onMounted(async () => {
|
||||
if (userStore.isLoggedIn) {
|
||||
router.push("/");
|
||||
await navigateTo("/");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -89,7 +89,7 @@ async function signIn() {
|
||||
const result = await userStore.login(userId.value, password.value);
|
||||
|
||||
if (result.success) {
|
||||
await router.push("/");
|
||||
await navigateTo("/");
|
||||
} else {
|
||||
errorMessage.value = result.error;
|
||||
}
|
||||
|
||||
@@ -85,9 +85,9 @@ const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
|
||||
// 이미 로그인된 경우 홈으로 리다이렉션
|
||||
onMounted(() => {
|
||||
onMounted(async () => {
|
||||
if (userStore.isLoggedIn) {
|
||||
router.push("/");
|
||||
await navigateTo("/");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -133,8 +133,8 @@ async function signUp() {
|
||||
"회원 가입이 완료되었습니다! 로그인 페이지로 이동합니다.";
|
||||
|
||||
// 2초 후 로그인 페이지로 이동
|
||||
setTimeout(() => {
|
||||
router.push("/login");
|
||||
setTimeout(async () => {
|
||||
await navigateTo("/login");
|
||||
}, 2000);
|
||||
}
|
||||
} catch (error: any) {
|
||||
|
||||
@@ -16,9 +16,7 @@ export const useTabsStore = defineStore("tabs", {
|
||||
}),
|
||||
actions: {
|
||||
// 새 탭 추가 (기본 페이지는 "/")
|
||||
addTab() {
|
||||
const { $router } = useNuxtApp();
|
||||
|
||||
async addTab() {
|
||||
if (this.tabs.length >= 10) {
|
||||
alert("탭은 최대 10개까지 열 수 있습니다.");
|
||||
return;
|
||||
@@ -29,21 +27,23 @@ export const useTabsStore = defineStore("tabs", {
|
||||
|
||||
this.tabs.push({ ...defaultTab, key: key });
|
||||
this.activeTab = key;
|
||||
$router.push(defaultTab.to);
|
||||
await navigateTo(defaultTab.to);
|
||||
return key;
|
||||
},
|
||||
|
||||
// 활성 탭 내용 변경 (서브메뉴 클릭)
|
||||
updateActiveTab(sub: { label: string; to: string; componentName: string }) {
|
||||
const { $router } = useNuxtApp();
|
||||
|
||||
async updateActiveTab(sub: {
|
||||
label: string;
|
||||
to: string;
|
||||
componentName: string;
|
||||
}) {
|
||||
const tab = this.tabs.find(t => t.key === this.activeTab);
|
||||
if (tab) {
|
||||
tab.label = sub.label;
|
||||
tab.to = sub.to;
|
||||
tab.componentName = sub.componentName;
|
||||
}
|
||||
$router.push(`/${tab?.key}${tab?.to}`);
|
||||
await navigateTo(`/${tab?.key}${tab?.to}`);
|
||||
},
|
||||
|
||||
// 활성 탭 제거
|
||||
@@ -57,13 +57,12 @@ export const useTabsStore = defineStore("tabs", {
|
||||
},
|
||||
|
||||
// 활성 탭 변경
|
||||
setActiveTab(key: number) {
|
||||
async setActiveTab(key: number) {
|
||||
console.log("tab.ts - setActiveTab", key);
|
||||
const { $router } = useNuxtApp();
|
||||
this.activeTab = key;
|
||||
|
||||
const tab = this.tabs.find(t => t.key === this.activeTab);
|
||||
$router.push(`/${tab?.key}${tab?.to}`);
|
||||
await navigateTo(`/${tab?.key}${tab?.to}`);
|
||||
},
|
||||
|
||||
// 탭 초기화
|
||||
|
||||
Reference in New Issue
Block a user