|
@@ -7,7 +7,7 @@
|
|
|
class="header__nav--item"
|
|
class="header__nav--item"
|
|
|
v-for="item in NAV_LIST"
|
|
v-for="item in NAV_LIST"
|
|
|
:key="item.path"
|
|
:key="item.path"
|
|
|
- :class="{ active: selectedKey === item.name }"
|
|
|
|
|
|
|
+ :class="{ active: selectedKey === item?.name }"
|
|
|
@click="handleNavClick(item)"
|
|
@click="handleNavClick(item)"
|
|
|
>
|
|
>
|
|
|
<span>{{ item.meta?.title }}</span>
|
|
<span>{{ item.meta?.title }}</span>
|
|
@@ -22,7 +22,7 @@
|
|
|
</el-input>
|
|
</el-input>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="platform__right__login">
|
|
<div class="platform__right__login">
|
|
|
- <span @click="handleLogin('login')" v-if="!userInfo">登录</span>
|
|
|
|
|
|
|
+ <span @click="handleLogin('login')" v-if="!userStore.id">登录</span>
|
|
|
<UserInfo
|
|
<UserInfo
|
|
|
v-else
|
|
v-else
|
|
|
@switchAccount="handleLogin('switchAccount')"
|
|
@switchAccount="handleLogin('switchAccount')"
|
|
@@ -31,27 +31,29 @@
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</header>
|
|
</header>
|
|
|
- <Login v-if="showLogin" :type="loginType" @close="showLogin = false" class="fadeIn" />
|
|
|
|
|
|
|
+ <Login v-if="userStore.showLogin" :type="loginType" @close="userStore.showLogin = false" class="fadeIn" />
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
- import { ref, computed, watch } from 'vue';
|
|
|
|
|
|
|
+ import { ref, computed } from 'vue';
|
|
|
import { useRouter, useRoute } from 'vue-router';
|
|
import { useRouter, useRoute } from 'vue-router';
|
|
|
import { NAV_LIST } from '@/constant/nav';
|
|
import { NAV_LIST } from '@/constant/nav';
|
|
|
import logo from 'assets/images/home/comac-logo@1X.png';
|
|
import logo from 'assets/images/home/comac-logo@1X.png';
|
|
|
import searchIcon from 'assets/svg/search.svg';
|
|
import searchIcon from 'assets/svg/search.svg';
|
|
|
import Login from '@/components/Login.vue';
|
|
import Login from '@/components/Login.vue';
|
|
|
import UserInfo from '@/components/UserInfo.vue';
|
|
import UserInfo from '@/components/UserInfo.vue';
|
|
|
- import useMockUserStore from '@/store/modules/mockUser';
|
|
|
|
|
|
|
+ // import useMockUserStore from '@/store/modules/mockUser';
|
|
|
import { useGlobSetting } from '@/hooks/setting';
|
|
import { useGlobSetting } from '@/hooks/setting';
|
|
|
|
|
|
|
|
- import { storeToRefs } from 'pinia';
|
|
|
|
|
|
|
+ // import { storeToRefs } from 'pinia';
|
|
|
|
|
+ import { useUserStore } from '@/store/modules/user';
|
|
|
|
|
|
|
|
- const mockUserStore = useMockUserStore();
|
|
|
|
|
- const { userInfo } = storeToRefs(mockUserStore);
|
|
|
|
|
|
|
+ // const mockUserStore = useMockUserStore();
|
|
|
|
|
+ // const { userInfo } = storeToRefs(mockUserStore);
|
|
|
|
|
+ const userStore = useUserStore();
|
|
|
const activeNav = ref(NAV_LIST[0].name);
|
|
const activeNav = ref(NAV_LIST[0].name);
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
|
- const showLogin = ref(false);
|
|
|
|
|
|
|
+ // const showLogin = ref(false);
|
|
|
const searchValue = ref('');
|
|
const searchValue = ref('');
|
|
|
const loginType = ref<'login' | 'switchAccount' | 'modifyPassword'>('login');
|
|
const loginType = ref<'login' | 'switchAccount' | 'modifyPassword'>('login');
|
|
|
|
|
|
|
@@ -61,22 +63,50 @@
|
|
|
|
|
|
|
|
const handleLogin = (type: 'login' | 'switchAccount' | 'modifyPassword') => {
|
|
const handleLogin = (type: 'login' | 'switchAccount' | 'modifyPassword') => {
|
|
|
loginType.value = type;
|
|
loginType.value = type;
|
|
|
- showLogin.value = true;
|
|
|
|
|
|
|
+ userStore.showLogin = true;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const currentRoute = useRoute();
|
|
const currentRoute = useRoute();
|
|
|
const { title } = useGlobSetting();
|
|
const { title } = useGlobSetting();
|
|
|
|
|
|
|
|
|
|
+<<<<<<< HEAD
|
|
|
const handleNavClick = (item: any) => {
|
|
const handleNavClick = (item: any) => {
|
|
|
|
|
+=======
|
|
|
|
|
+ const handleNavClick = (item: { name: string; path: string }) => {
|
|
|
|
|
+ // 如果不是首页,先检查用户是否登录
|
|
|
|
|
+ // if (item.name !== '首页' && !userInfo.value) {
|
|
|
|
|
+ // handleLogin('login');
|
|
|
|
|
+ // return;
|
|
|
|
|
+ // }
|
|
|
|
|
+>>>>>>> 9bcd636 (fix: 完成了未登录情况下顶级路由高亮显示问题)
|
|
|
if (!item.path) return;
|
|
if (!item.path) return;
|
|
|
activeNav.value = item.name;
|
|
activeNav.value = item.name;
|
|
|
router.push(item.path);
|
|
router.push(item.path);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
|
+=======
|
|
|
|
|
+ console.log('currentRoute', currentRoute);
|
|
|
|
|
+
|
|
|
|
|
+>>>>>>> 9bcd636 (fix: 完成了未登录情况下顶级路由高亮显示问题)
|
|
|
const selectedKey = computed(() => {
|
|
const selectedKey = computed(() => {
|
|
|
- const activeMenu = (currentRoute.meta?.activeMenu as string) || null; // act
|
|
|
|
|
- return activeMenu ? activeMenu : (currentRoute.name as string);
|
|
|
|
|
|
|
+ return currentRoute.matched[0]?.name;
|
|
|
});
|
|
});
|
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
|
+=======
|
|
|
|
|
+
|
|
|
|
|
+ // 跟随页面路由变化,切换菜单选中状态
|
|
|
|
|
+ // watch(
|
|
|
|
|
+ // () => currentRoute.fullPath,
|
|
|
|
|
+ // () => {
|
|
|
|
|
+ // updateMenu();
|
|
|
|
|
+ // const matched = currentRoute.matched;
|
|
|
|
|
+ // openKeys.value = matched.map((item) => item.name);
|
|
|
|
|
+ // const activeMenu: string = (currentRoute.meta?.activeMenu as string) || '';
|
|
|
|
|
+ // selectedKeys.value = activeMenu ? activeMenu : (currentRoute.name as string);
|
|
|
|
|
+ // },
|
|
|
|
|
+ // );
|
|
|
|
|
+>>>>>>> 9bcd636 (fix: 完成了未登录情况下顶级路由高亮显示问题)
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|