1
0
mirror of https://github.com/sendevia/website.git synced 2026-03-07 08:12:35 +08:00

feat(NavBar): try to fix bar not display

This commit is contained in:
2025-12-06 00:57:11 +08:00
parent dcde015ded
commit 8beeb84e0a

View File

@@ -14,6 +14,20 @@ const navSegment = computed(() => {
return Array.isArray(items) && items.length > 0 ? items : [];
});
/**
* 计算导航栏模式 (Rail / Bar)
*/
const navMode = computed(() => {
const currentWidth = screenWidthStore.screenWidth;
const breakpoint = screenWidthStore.breakpoint;
if (currentWidth <= 840) {
return "bar";
}
return currentWidth > breakpoint ? "rail" : "bar";
});
// 规范化路径
function normalizePath(path: string): string {
return path.replace(/(\/index)?\.(md|html)$/, "").replace(/\/$/, "");
@@ -36,13 +50,12 @@ function toggleSearch(event: MouseEvent) {
// 判断是否为外部链接
function isExternalLink(link: string): boolean {
const externalLinkPatterns = [/^https?:\/\//];
return externalLinkPatterns.some((pattern) => pattern.test(link));
}
</script>
<template>
<nav class="NavBar" :class="screenWidthStore.isAboveBreakpoint ? 'rail' : 'bar'">
<nav class="NavBar" :class="navMode">
<button class="fab" @mousedown.prevent @click.stop="toggleSearch">
<span>{{ searchStateStore.isSearchActive ? "close" : "search" }}</span>
</button>