Skip to content

Commit 0315ece

Browse files
committed
refactor: 移除调试日志并优化代码结构
docs: 更新文章模板和示例内容 fix: 修复评论模块的错误提示信息 style: 清理无用代码并调整格式
1 parent fc02856 commit 0315ece

12 files changed

Lines changed: 109 additions & 669 deletions

src/components/base/Comment.astro

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
const commentsContainer = document.getElementById("tcomment");
99
if (commentsContainer) {
1010
if (!twikooEnvId) {
11-
console.error("Twikoo envId 未配置。请在 .env 中设置 PUBLIC_TWIKOO_ENV_ID。");
11+
showError("留言模块未加载,Twikoo envId 未配置。");
1212
return;
1313
}
1414
const script = document.createElement("script");
@@ -29,21 +29,36 @@
2929
// 动态加载 Twikoo 自定义样式的函数
3030
function loadTwikooCustomStyles() {
3131
if (document.getElementById('twikoo-custom-link')) {
32-
return;
33-
}
34-
35-
const link = document.createElement('link');
36-
link.id = 'twikoo-custom-link';
37-
link.rel = 'stylesheet';
38-
link.href = '/src/styles/twikoo-custom.scss'; // 需要构建工具支持
39-
document.head.appendChild(link);
32+
return;
33+
}
34+
35+
const link = document.createElement('link');
36+
link.id = 'twikoo-custom-link';
37+
link.rel = 'stylesheet';
38+
link.href = '/src/styles/twikoo-custom.scss'; // 需要构建工具支持
39+
document.head.appendChild(link);
4040
}
4141
`;
4242
document.body.appendChild(initScript);
4343
};
4444
document.body.appendChild(script);
4545
}
4646
}
47+
48+
function showError(msg){
49+
const list = document.getElementById("tcomment");
50+
if(!list) return;
51+
list.removeAttribute('aria-busy');
52+
list.innerHTML = `
53+
<div class="py-4">
54+
<div class="text-center text-red-600 dark:text-red-400">
55+
${msg || "评论获取失败,请稍后重试。"}
56+
</div>
57+
</div>
58+
`;
59+
const btn = document.getElementById("rc-retry-btn");
60+
if(btn){ btn.addEventListener("click", load, { once: true }); }
61+
}
4762
loadTwikoo();
4863
});
4964
</script>

src/components/base/Footer.astro

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,6 @@ const statsData = {
170170
const footer = document.getElementById("main-footer");
171171
const collapsedContent = document.getElementById("footer-collapsed");
172172
const expandedContent = document.getElementById("footer-expanded");
173-
const expandedContentClass = expandedContent?.className;
174-
console.log("expandedContentClass:", expandedContentClass);
175173

176174
if (!footer || !collapsedContent || !expandedContent) return;
177175

src/components/base/Header.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,11 @@ const menu = [
444444
if (!response.ok) {
445445
throw new Error("无法获取文章列表");
446446
}
447-
448447
const articles = await response.json();
449448
if (!articles || articles.length === 0) {
450449
throw new Error("没有找到可用的文章");
451450
}
451+
452452

453453
// 随机选择一篇文章
454454
const randomIndex = Math.floor(Math.random() * articles.length);

src/components/blog/EntryLayout.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const actuallyHideToc =
3434
hideToc ||
3535
globalHideToc ||
3636
headings.filter((heading) => heading.depth <= tocDepth).length === 0;
37-
console.log("actuallyHideToc:", actuallyHideToc);
37+
3838
// 简化布局类计算
3939
const articleClass = "w-full lg:w-3/4 xl:w-4/5"; //因为侧边栏还有推荐阅读,所以不需要根据toc是否隐藏来计算宽度
4040
// const articleClass = actuallyHideToc ? "w-full" : "w-full lg:w-3/4 xl:w-4/5";

src/components/common/EntryHeader.astro

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ const {
7474
complexity,
7575
} = entry.data as EntryData;
7676
77-
console.log("是否获取Image", image);
78-
7977
categories?.sort((a: string, b: string) => a.localeCompare(b));
8078
tags?.sort((a: string, b: string) => a.localeCompare(b));
8179
---

src/components/common/RecentComments.astro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ const titleMap = Object.fromEntries(
4646
<li class="py-4">
4747
<div class="text-center text-red-600 dark:text-red-400">
4848
${msg || "评论获取失败,请稍后重试。"}
49-
<button id="rc-retry-btn" class="ml-2 px-2 py-1 text-sm rounded border border-red-300 dark:border-red-700 bg-red-50 hover:bg-red-100 dark:bg-red-900/20">重试</button>
5049
</div>
5150
</li>
5251
`;
@@ -123,7 +122,7 @@ const titleMap = Object.fromEntries(
123122
function load(){
124123
if(!list){return}
125124
if(!twikooEnvId){
126-
showError("未配置 Twikoo 环境 ID");
125+
showError("留言模块未加载,Twikoo envId 未配置。");
127126
return;
128127
}
129128
showLoading();

src/content/blog/Liquid_Glass组件.md

Lines changed: 0 additions & 106 deletions
This file was deleted.

src/content/blog/markdown-demo.md

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)