|
@@ -65,6 +65,9 @@ import menu_tickets from "@/assets/img/navbar/menu_tickets.png";
|
|
|
import menu_travel_note from "@/assets/img/navbar/menu_travel_note.png";
|
|
|
import menu_travel_project from "@/assets/img/navbar/menu_travel_project.png";
|
|
|
import menu_visa from "@/assets/img/navbar/menu_visa.png";
|
|
|
+import menu_profile from "@/assets/img/navbar/menu_profile.png";
|
|
|
+
|
|
|
+const visible = defineModel("visible");
|
|
|
|
|
|
const authStore = useAuthStore();
|
|
|
const { token } = storeToRefs(authStore);
|
|
@@ -72,15 +75,21 @@ const { token } = storeToRefs(authStore);
|
|
|
const userInfoStore = useUserInfoStore();
|
|
|
const { userInfo } = storeToRefs(userInfoStore);
|
|
|
|
|
|
-const needLoginMenus = [
|
|
|
- {
|
|
|
- title: "写游记",
|
|
|
- icon: menu_create_note,
|
|
|
- to: "/note-create",
|
|
|
- },
|
|
|
-];
|
|
|
+const menuData = ref([]);
|
|
|
|
|
|
-const menuData = reactive([
|
|
|
+const writeNoteMenu = {
|
|
|
+ title: "写游记",
|
|
|
+ icon: menu_create_note,
|
|
|
+ to: "/note-create",
|
|
|
+};
|
|
|
+
|
|
|
+const profileMenu = {
|
|
|
+ title: "我的",
|
|
|
+ icon: menu_profile,
|
|
|
+ to: "/profile",
|
|
|
+};
|
|
|
+
|
|
|
+const fixedMenuData = [
|
|
|
{
|
|
|
title: "首页",
|
|
|
icon: menu_travel_home,
|
|
@@ -121,14 +130,17 @@ const menuData = reactive([
|
|
|
// icon: menu_tickets,
|
|
|
// to: "/labour",
|
|
|
// },
|
|
|
-]);
|
|
|
+];
|
|
|
|
|
|
watch(
|
|
|
token,
|
|
|
(val) => {
|
|
|
- if (!val) return;
|
|
|
- userInfoStore.getUserInfo();
|
|
|
- menuData.splice(1, 0, ...needLoginMenus);
|
|
|
+ if (!val) {
|
|
|
+ menuData.value = fixedMenuData;
|
|
|
+ } else {
|
|
|
+ userInfoStore.getUserInfo();
|
|
|
+ menuData.value = [...fixedMenuData, writeNoteMenu, profileMenu];
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
immediate: true,
|
|
@@ -136,6 +148,7 @@ watch(
|
|
|
);
|
|
|
|
|
|
function handleClickMenu(item) {
|
|
|
+ visible.value = false;
|
|
|
navigateTo({
|
|
|
path: item.to,
|
|
|
});
|
|
@@ -147,6 +160,7 @@ function handleLogout() {
|
|
|
} finally {
|
|
|
authStore.cleanToken();
|
|
|
navigateTo("/");
|
|
|
+ visible.value = false;
|
|
|
}
|
|
|
}
|
|
|
</script>
|