Skip to content

Commit 6201ec6

Browse files
committed
修复报错,优化订阅
1 parent 93c107d commit 6201ec6

File tree

6 files changed

+62
-40
lines changed

6 files changed

+62
-40
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# RSS 配置
2-
RSS_FEED_URL=https://note.weizwz.com/feed.xml
2+
VITE_RSS_FEED_URL=https://note.weizwz.com/feed.xml
33

44
# 博客配置
5-
BLOG_URL=https://note.weizwz.com
5+
VITE_BLOG_URL=https://note.weizwz.com

app/components/BlogArticles.tsx

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -164,33 +164,34 @@ export function BlogArticles({ title = '我的文章', subtitle = '来自博客
164164
const fallbackArticles: Article[] = [
165165
{
166166
id: 1,
167-
title: 'PS快速替换证件照背景',
167+
title: '如何快速无缝的从 vscode 转向AI编辑器 cursor、kiro、trae 等',
168168
category: '资源',
169-
description: '本文介绍了一种使用Photoshop快速替换证件照背景的方法,且替换效果自然无杂色和毛边',
170-
date: '2025年06月19日',
171-
link: 'https://note.weizwz.com/editor/ps/photo-change-bg',
172-
styleName: 'weizwz-icon-ps',
173-
tags: ['ps', '图片']
169+
description: '本文介绍了如何从 VSCode 快速无缝转向 AI 编辑器,如 kiro、cursor、trae 等',
170+
date: '2025年07月25日',
171+
link: config.blog.url + '/editor/ai/to-kiro',
172+
styleName: 'weiz-icon-ai',
173+
tags: ['AI', 'VSCode']
174174
},
175175
{
176176
id: 2,
177-
title: '如何快速无缝的从 vscode 转向AI编辑器 cursor、kiro、trae 等',
177+
title: 'MacOS Sequoia系统优化',
178178
category: '资源',
179-
description: '本文介绍了在VitePress中集成Twikoo的方法,包括安装插件、封装组件、利用布局插槽等步骤',
180-
date: '2025年05月15日',
181-
link: 'https://note.weizwz.com/vitepress/extend/vitepress-twikoo',
182-
styleName: 'weizwz-icon-ai',
183-
tags: ['ai', 'vscode']
179+
description: '本文介绍了 MacOS Sequoia 系统的基础优化设置,包括修改截屏保存位置、修复启动图标错乱、关闭安装来源限制等系统级操作',
180+
date: '2025年04月26日',
181+
link: config.blog.url + '/macos/setting/base-init',
182+
styleName: 'weiz-icon-macos',
183+
tags: ['MacOS']
184184
},
185185
{
186186
id: 3,
187-
title: 'MacOS Sequoia系统优化',
187+
title: 'VitePress 建站资源汇总',
188188
category: '资源',
189-
description: '本文介绍了 MacOS Sequoia 系统的基础优化设置,包括修改截屏保存位置、修复启动图标错乱等',
190-
date: '2025年04月26日',
191-
link: 'https://note.weizwz.com/macos/setting/base-init',
192-
styleName: 'weizwz-icon-macos',
193-
tags: ['macos']
189+
description:
190+
'本文汇总了使用 VitePress 搭建博客的资源与配置方法,包括暗黑模式切换动画、DocSearch 搜索、Fancybox 图片查看器、GitHub Giscus 评论系统、Cloudflare R2 图床配置等内容',
191+
date: '2025年04月18日',
192+
link: config.blog.url + '/vitepress/all/resource-all',
193+
styleName: 'weiz-icon-vitepress',
194+
tags: ['VitePress', '网站']
194195
}
195196
]
196197

@@ -340,14 +341,16 @@ export function BlogArticles({ title = '我的文章', subtitle = '来自博客
340341
onMouseLeave={() => setIsPaused(false)}>
341342
<div className='bg-white/80 backdrop-blur-sm rounded-2xl md:rounded-3xl border-1 border-slate-200 shadow-md shadow-slate-200 h-full hover:shadow-xl transition-all duration-300 overflow-hidden'>
342343
{/* 文章头部 - 渐变背景 */}
343-
<div className={`article-icon-bg ${article.styleName} p-6 relative`}>
344+
<div className={`${article.styleName} article-icon-bg p-6 relative`}>
344345
<div className='flex items-center justify-between mb-4'>
345346
<span className='inline-block px-3 py-1 bg-white/20 backdrop-blur-sm text-white text-sm font-medium rounded-full'>
346347
{article.category}
347348
</span>
348349
<div className='w-10 h-10 article-icon'></div>
349350
</div>
350-
<h3 className='text-4xl text-center font-bold text-white mb-4 line-clamp-2'>{article.title}</h3>
351+
<div className='min-h-20 flex items-center justify-center mb-4'>
352+
<h3 className='text-4xl text-center font-bold text-white line-clamp-2'>{article.title}</h3>
353+
</div>
351354
</div>
352355

353356
{/* 文章内容 */}

app/root.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
5656
if (isRouteErrorResponse(error)) {
5757
is404 = error.status === 404
5858
message = is404 ? '404' : '错误'
59+
60+
// 过滤 Chrome DevTools 的请求,不显示错误页面
61+
if (is404 && error.data && typeof error.data === 'string' &&
62+
error.data.includes('.well-known/appspecific/com.chrome.devtools.json')) {
63+
return null; // 不显示错误页面
64+
}
5965
} else if (import.meta.env.DEV && error && error instanceof Error) {
6066
stack = error.stack
6167
}

app/routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import { type RouteConfig, index, route } from "@react-router/dev/routes";
33
export default [
44
index("routes/home.tsx"),
55
route("api/rss", "routes/api/rss.ts"),
6+
route(".well-known/appspecific/com.chrome.devtools.json", "routes/.well-known/appspecific/com.chrome.devtools.json.ts"),
67
] satisfies RouteConfig;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { LoaderFunctionArgs } from "react-router";
2+
3+
export async function loader({}: LoaderFunctionArgs) {
4+
// 返回空的 JSON 响应,避免 404 错误
5+
return new Response('{}', {
6+
headers: {
7+
'Content-Type': 'application/json',
8+
},
9+
});
10+
}

app/routes/api/rss.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,38 @@
1-
import type { LoaderFunctionArgs } from "react-router";
1+
import type { LoaderFunctionArgs } from 'react-router'
22

33
export async function loader({}: LoaderFunctionArgs) {
44
try {
5-
// 从环境变量获取 RSS URL,提供默认值
6-
const rssUrl = process.env.RSS_FEED_URL || 'https://note.weizwz.com/feed.xml';
5+
76

7+
// 从环境变量获取 RSS URL,提供默认值
8+
const rssUrl = process.env.VITE_RSS_FEED_URL
9+
810
// 获取 RSS 数据
9-
const response = await fetch(rssUrl);
10-
11+
const response = await fetch(rssUrl || '')
12+
1113
if (!response.ok) {
12-
throw new Error(`HTTP error! status: ${response.status}`);
14+
throw new Error(`HTTP error! status: ${response.status}`)
1315
}
14-
15-
const xmlText = await response.text();
16-
16+
17+
const xmlText = await response.text()
18+
1719
// 返回 XML 数据,设置正确的 Content-Type
1820
return new Response(xmlText, {
1921
headers: {
2022
'Content-Type': 'application/xml',
2123
'Access-Control-Allow-Origin': '*',
22-
'Cache-Control': 'public, max-age=300', // 缓存 5 分钟
23-
},
24-
});
24+
'Cache-Control': 'public, max-age=300' // 缓存 5 分钟
25+
}
26+
})
2527
} catch (error) {
26-
console.error('获取 RSS 失败:', error);
27-
28+
console.error('获取 RSS 失败:', error)
29+
2830
// 返回错误响应
2931
return new Response('Failed to fetch RSS', {
3032
status: 500,
3133
headers: {
32-
'Content-Type': 'text/plain',
33-
},
34-
});
34+
'Content-Type': 'text/plain'
35+
}
36+
})
3537
}
36-
}
38+
}

0 commit comments

Comments
 (0)