优化导航栏链接,添加外部和内部链接打开功能,改进用户交互体验

This commit is contained in:
2025-03-06 09:06:21 +08:00
parent d1aad382c6
commit 9de7b643f3

View File

@ -1,5 +1,5 @@
<template>
<el-menu mode="horizontal" router class="custom-menu">
<el-menu mode="horizontal" class="custom-menu">
<!-- 左侧网站名 -->
<div class="website-name">
<span style="font-weight: bold">Kisechan </span>
@ -7,17 +7,25 @@
<!-- 右侧导航选项 -->
<div class="menu-items">
<el-menu-item index="/">首页</el-menu-item>
<el-menu-item @click="openLink('/')">首页</el-menu-item>
<el-menu-item @click="goToBlog">博客</el-menu-item>
<el-menu-item index="/links">友链</el-menu-item>
<el-menu-item @click="openLink('/links')">友链</el-menu-item>
</div>
</el-menu>
</template>
<script setup>
// 打开外部链接
const goToBlog = () => {
window.open("https://blog.kisechan.space", "_blank");
};
// 打开内部链接(新标签页)
const openLink = (path) => {
const fullUrl = "https://www.kisechan.space" + path; // 获取完整 URL
if (window.location.href === fullUrl) return; // 防止重复点击
window.open(fullUrl, "_blank");
};
</script>
<style scoped>
@ -39,6 +47,7 @@ const goToBlog = () => {
.el-menu-item {
font-size: 16px;
cursor: pointer; /* 添加手型光标 */
}
.website-name {