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