2025-03-05 10:12:08 +08:00
|
|
|
|
<template>
|
2025-03-05 19:08:05 +08:00
|
|
|
|
<div class="friend-links">
|
2025-03-06 19:02:28 +08:00
|
|
|
|
<h1>
|
|
|
|
|
<i class="fa-solid fa-link"></i>友链
|
|
|
|
|
</h1>
|
2025-03-05 23:07:23 +08:00
|
|
|
|
<!-- 加载状态 -->
|
|
|
|
|
<div v-if="loading" class="loading-container">
|
|
|
|
|
<el-skeleton :rows="10" animated />
|
|
|
|
|
</div>
|
2025-03-05 19:08:05 +08:00
|
|
|
|
<!-- 友链列表 -->
|
2025-03-05 23:07:23 +08:00
|
|
|
|
<template v-else>
|
|
|
|
|
<div>
|
2025-03-05 19:08:05 +08:00
|
|
|
|
<el-card
|
2025-03-05 23:07:23 +08:00
|
|
|
|
v-for="(category, categoryIndex) in friendLinks"
|
|
|
|
|
:key="categoryIndex"
|
|
|
|
|
class="category-card"
|
2025-03-05 19:08:05 +08:00
|
|
|
|
>
|
2025-03-05 23:07:23 +08:00
|
|
|
|
<template #header>
|
|
|
|
|
<div class="category-header">{{ category.category }}</div>
|
|
|
|
|
</template>
|
|
|
|
|
<div class="links-container">
|
|
|
|
|
<el-card
|
|
|
|
|
v-for="(link, linkIndex) in category.links"
|
|
|
|
|
:key="linkIndex"
|
|
|
|
|
class="link-card"
|
|
|
|
|
@mouseenter="hoverEffect(`${categoryIndex}-${linkIndex}`)"
|
|
|
|
|
@mouseleave="resetEffect"
|
|
|
|
|
:style="cardStyle(`${categoryIndex}-${linkIndex}`)"
|
|
|
|
|
@click="openLink(link.url)"
|
|
|
|
|
>
|
|
|
|
|
<div class="link-content">
|
|
|
|
|
<el-avatar :src="link.avatar" class="link-avatar" />
|
|
|
|
|
<div class="link-info">
|
|
|
|
|
<div class="link-title">{{ link.title }}</div>
|
|
|
|
|
<div class="link-description">{{ link.description }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-card>
|
2025-03-05 19:08:05 +08:00
|
|
|
|
</div>
|
|
|
|
|
</el-card>
|
2025-03-07 10:22:17 +08:00
|
|
|
|
<el-card class="add-link-card">
|
2025-03-05 19:08:05 +08:00
|
|
|
|
<div class="add-link-header">添加友链</div>
|
|
|
|
|
<div class="add-link-content">
|
|
|
|
|
<p>请按照以下格式提交您的友链信息:</p>
|
2025-03-12 12:03:00 +08:00
|
|
|
|
<i><pre>avatar: "您的头像链接"
|
2025-03-05 19:08:05 +08:00
|
|
|
|
title: "您的博客标题"
|
2025-03-05 19:42:45 +08:00
|
|
|
|
description: "您的博客描述"
|
2025-03-12 12:03:00 +08:00
|
|
|
|
url: "您的博客链接"</pre></i>
|
2025-03-05 19:08:05 +08:00
|
|
|
|
<p>
|
|
|
|
|
并发送至:<a href="mailto:links@kisechan.space"
|
|
|
|
|
>links@kisechan.space</a
|
|
|
|
|
>
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2025-03-07 10:22:17 +08:00
|
|
|
|
</el-card>
|
2025-03-05 23:07:23 +08:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
2025-03-05 10:12:08 +08:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2025-03-05 19:08:05 +08:00
|
|
|
|
<script>
|
|
|
|
|
import yaml from "js-yaml";
|
|
|
|
|
import { ref } from "vue";
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "FriendLinks",
|
|
|
|
|
setup() {
|
|
|
|
|
const friendLinks = ref([]);
|
|
|
|
|
const hoveredCardId = ref(null);
|
2025-03-05 23:07:23 +08:00
|
|
|
|
const loading = ref(true);
|
2025-03-05 19:08:05 +08:00
|
|
|
|
// 加载 YAML 文件
|
2025-03-12 12:03:00 +08:00
|
|
|
|
fetch(import.meta.env.VITE_LINKS_YAML_URL)
|
2025-03-05 19:08:05 +08:00
|
|
|
|
.then((response) => response.text())
|
|
|
|
|
.then((text) => {
|
|
|
|
|
friendLinks.value = yaml.load(text);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
console.error("Failed to load YAML file:", error);
|
2025-03-05 23:07:23 +08:00
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
loading.value = false; // 数据加载完成后,设置 loading 为 false
|
2025-03-05 19:08:05 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const hoverEffect = (cardId) => {
|
|
|
|
|
hoveredCardId.value = cardId;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const resetEffect = () => {
|
|
|
|
|
hoveredCardId.value = null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const cardStyle = (cardId) => {
|
|
|
|
|
return {
|
|
|
|
|
transform: hoveredCardId.value === cardId ? "scale(1.05)" : "scale(1)",
|
|
|
|
|
transition: "transform 0.3s ease",
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2025-03-05 19:42:45 +08:00
|
|
|
|
const openLink = (url) => {
|
|
|
|
|
window.open(url, "_blank");
|
|
|
|
|
};
|
|
|
|
|
|
2025-03-05 19:08:05 +08:00
|
|
|
|
return {
|
|
|
|
|
friendLinks,
|
|
|
|
|
hoverEffect,
|
|
|
|
|
resetEffect,
|
|
|
|
|
cardStyle,
|
2025-03-05 19:42:45 +08:00
|
|
|
|
openLink,
|
2025-03-05 23:07:23 +08:00
|
|
|
|
loading,
|
2025-03-05 19:08:05 +08:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
2025-03-05 10:12:08 +08:00
|
|
|
|
<style scoped>
|
2025-03-05 19:08:05 +08:00
|
|
|
|
.friend-links {
|
|
|
|
|
padding: 20px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.add-link-card {
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.add-link-header {
|
|
|
|
|
font-size: 1.5em;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.add-link-content {
|
|
|
|
|
font-size: 1em;
|
2025-03-07 23:00:47 +08:00
|
|
|
|
background-color: var(--code-background-color);
|
|
|
|
|
color: var(--code-text-color);
|
2025-03-05 19:08:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.add-link-content pre {
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
overflow-x: auto;
|
2025-03-07 23:00:47 +08:00
|
|
|
|
font-family: Consolas, Monaco, "Courier New", monospace; /* 使用等宽字体 */
|
|
|
|
|
font-size: 0.9em; /* 调整字体大小 */
|
|
|
|
|
line-height: 1.5; /* 调整行高 */
|
|
|
|
|
color: #698db1;
|
|
|
|
|
padding: 10px; /* 可选:增加内边距 */
|
2025-03-05 19:08:05 +08:00
|
|
|
|
}
|
2025-03-05 10:12:08 +08:00
|
|
|
|
|
2025-03-05 19:08:05 +08:00
|
|
|
|
.add-link-content a {
|
|
|
|
|
color: #409eff;
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.add-link-content a:hover {
|
|
|
|
|
text-decoration: underline;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.category-card {
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.category-header {
|
|
|
|
|
font-size: 1.5em;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.links-container {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
|
|
|
|
gap: 15px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.link-card {
|
|
|
|
|
width: 100%;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
position: relative;
|
|
|
|
|
z-index: 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.link-card:hover {
|
|
|
|
|
z-index: 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.link-content {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.link-avatar {
|
|
|
|
|
margin-right: 15px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.link-info {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.link-title {
|
|
|
|
|
font-size: 1.2em;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.link-description {
|
|
|
|
|
font-size: 0.9em;
|
2025-03-07 19:20:12 +08:00
|
|
|
|
color: var(--code-text-color);
|
2025-03-05 19:08:05 +08:00
|
|
|
|
}
|
2025-03-05 23:07:23 +08:00
|
|
|
|
|
|
|
|
|
.loading-container {
|
|
|
|
|
padding: 20px;
|
|
|
|
|
}
|
2025-03-06 19:02:28 +08:00
|
|
|
|
|
|
|
|
|
h1 {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 10px;
|
|
|
|
|
}
|
2025-03-06 22:33:49 +08:00
|
|
|
|
|
|
|
|
|
.link-content {
|
|
|
|
|
color: var(--text-color);
|
|
|
|
|
}
|
2025-03-05 19:08:05 +08:00
|
|
|
|
</style>
|