mirror of
https://github.com/Kisechan/Mainpage.git
synced 2025-07-09 14:47:18 +00:00
优化导航栏链接,添加外部和内部链接打开功能,改进用户交互体验
This commit is contained in:
@ -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,9 +47,10 @@ const goToBlog = () => {
|
||||
|
||||
.el-menu-item {
|
||||
font-size: 16px;
|
||||
cursor: pointer; /* 添加手型光标 */
|
||||
}
|
||||
|
||||
.website-name {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
</style>
|
||||
</style>
|
Reference in New Issue
Block a user