更新 .gitignore 文件以包含环境变量,修改多个视图以使用环境变量加载 RSS 源和 YAML 文件

This commit is contained in:
2025-03-12 12:03:00 +08:00
parent 706788161e
commit 55000e7ff7
4 changed files with 11 additions and 8 deletions

4
.gitignore vendored
View File

@ -22,3 +22,7 @@ dist-ssr
*.njsproj *.njsproj
*.sln *.sln
*.sw? *.sw?
# 环境变量
.env
.env.*

View File

@ -161,7 +161,8 @@ const cleanupGitHubCalendar = () => {
}; };
const fetchRSSFeed = async () => { const fetchRSSFeed = async () => {
const rssUrl = "https://blog.kisechan.space/atom.xml"; const rssUrl = import.meta.env.VITE_RSS_FEED_URL;
console.log("Fetching RSS Feed:", rssUrl);
try { try {
const response = await fetch(rssUrl); const response = await fetch(rssUrl);
const str = await response.text(); const str = await response.text();

View File

@ -42,12 +42,10 @@
<div class="add-link-header">添加友链</div> <div class="add-link-header">添加友链</div>
<div class="add-link-content"> <div class="add-link-content">
<p>请按照以下格式提交您的友链信息</p> <p>请按照以下格式提交您的友链信息</p>
<i><pre> <i><pre>avatar: "您的头像链接"
avatar: "您的头像链接"
title: "您的博客标题" title: "您的博客标题"
description: "您的博客描述" description: "您的博客描述"
url: "您的博客链接"</pre url: "您的博客链接"</pre></i>
></i>
<p> <p>
并发送至<a href="mailto:links@kisechan.space" 并发送至<a href="mailto:links@kisechan.space"
>links@kisechan.space</a >links@kisechan.space</a
@ -71,7 +69,7 @@ export default {
const hoveredCardId = ref(null); const hoveredCardId = ref(null);
const loading = ref(true); const loading = ref(true);
// 加载 YAML 文件 // 加载 YAML 文件
fetch("/links.yml") fetch(import.meta.env.VITE_LINKS_YAML_URL)
.then((response) => response.text()) .then((response) => response.text())
.then((text) => { .then((text) => {
friendLinks.value = yaml.load(text); friendLinks.value = yaml.load(text);

View File

@ -43,7 +43,7 @@
const loading = ref(true); const loading = ref(true);
// 加载 YAML 文件 // 加载 YAML 文件
fetch("/tools.yml") fetch(import.meta.env.VITE_TOOLS_YAML_URL)
.then((response) => response.text()) .then((response) => response.text())
.then((text) => { .then((text) => {
tools.value = yaml.load(text); tools.value = yaml.load(text);
@ -52,7 +52,7 @@
console.error("Failed to load YAML file:", error); console.error("Failed to load YAML file:", error);
}) })
.finally(() => { .finally(() => {
loading.value = false; // 数据加载完成后,设置 loading 为 false loading.value = false;
}); });
const openLink = (url) => { const openLink = (url) => {