refactor: 全站改用数据库动态驱动,支持分类与统计动态查询,并全面将作者及博主标识由'旺总'切换为'小东'
Build and Deploy Blog / deploy (push) Successful in 40s

This commit is contained in:
2026-10-22 16:59:00 +08:00
parent ae840a47a9
commit 9ad9923d61
4 changed files with 65 additions and 29 deletions
@@ -49,7 +49,7 @@ public class DataInitializer implements CommandLineRunner {
"相比传统臃肿的面料,1Panel 深度拥抱 **Docker 容器化**,所有应用(MySQL、OpenResty、Gitea)完全容器隔离,真正做到“环境随用随建,数据挂载持久化”。\n\n" +
"```bash\n# 快速检查 Docker 运行状态\ndocker ps --format \"table {{.Names}}\\t{{.Status}}\\t{{.Ports}}\"\n```\n\n" +
"> 💡 **运维心得**:永远在云平台控制台统一放行防火墙端口,切勿盲目在系统内部启用 UFW,避免失联风险。");
p1.setAuthor("旺总");
p1.setAuthor("小东");
p1.setCategoryName("云原生 & Linux");
p1.setTags("GCP,Ubuntu,1Panel,Linux");
p1.setReadTime("4 min");
@@ -72,7 +72,7 @@ public class DataInitializer implements CommandLineRunner {
"3. **清空全局默认 Prompt**:消除了默认附带的 2050 历史 Token,读题耗时从 60s 骤降至 0.2s!\n\n" +
"```bash\n# 测试模型运行性能\ndocker exec -it 1Panel-ollama-nzre ollama run qwen2.5:1.5b --verbose\n```\n\n" +
"> 纯 CPU 跑 7B 参数是物理带宽瓶颈,日常开发推荐搭配 1.5B~3B 模型,速度与逻辑达到最佳平衡!");
p2.setAuthor("旺总");
p2.setAuthor("小东");
p2.setCategoryName("AI & 本地模型");
p2.setTags("DeepSeek,Ollama,OpenWebUI,性能调优");
p2.setReadTime("6 min");
@@ -90,7 +90,7 @@ public class DataInitializer implements CommandLineRunner {
"- 数据文件挂载至命名卷 `mysql_data`,容器重启或重建数据零丢失;\n" +
"- Spring Data JPA 实现对象关系映射,自动完成数据库结构维护;\n" +
"- 统一 RESTful API 与响应封装,全栈开发得心应手!");
p3.setAuthor("旺总");
p3.setAuthor("小东");
p3.setCategoryName("全栈开发 & CI/CD");
p3.setTags("Spring Boot,MySQL,JPA,CI/CD");
p3.setReadTime("5 min");
@@ -99,5 +99,18 @@ public class DataInitializer implements CommandLineRunner {
postRepository.saveAll(Arrays.asList(p1, p2, p3));
}
// 3. 自动迁移平滑更新:如果数据库中存留历史旧作者"旺总",自动同步更新为"小东"
List<Post> existingPosts = postRepository.findAll();
boolean hasMigration = false;
for (Post p : existingPosts) {
if ("旺总".equals(p.getAuthor())) {
p.setAuthor("小东");
hasMigration = true;
}
}
if (hasMigration) {
postRepository.saveAll(existingPosts);
}
}
}
@@ -21,7 +21,7 @@ public class Post {
private String content;
@Column(length = 50)
private String author = "旺总";
private String author = "小东";
@Column(name = "category_name", length = 50)
private String categoryName = "技术杂谈";
@@ -51,7 +51,7 @@ public class Post {
if (updatedAt == null) updatedAt = LocalDateTime.now();
if (views == null) views = 0;
if (likes == null) likes = 0;
if (author == null) author = "旺总";
if (author == null) author = "小东";
if (categoryName == null) categoryName = "技术杂谈";
if (readTime == null) readTime = "3 min";
if (status == null) status = "PUBLISHED";
+1 -1
View File
@@ -2,7 +2,7 @@
set -e
echo "=========================================="
echo "🚀 [CI/CD] 开始构建并部署旺总的全栈个人博客..."
echo "🚀 [CI/CD] 开始构建并部署小东的全栈个人博客..."
echo "=========================================="
# 1. 拉取最新代码
+48 -25
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>旺总的技术全栈博客 | Full-Stack · Cloud-Native · DevOps</title>
<title>小东的技术全栈博客 | Full-Stack · Cloud-Native · DevOps</title>
<!-- Tailwind CSS CDN -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
@@ -250,12 +250,12 @@
<div class="flex items-center gap-6">
<a href="#/" @click.prevent="navigateView('home')" class="flex items-center gap-3 group">
<div class="relative w-10 h-10 rounded-xl bg-gradient-to-tr from-sky-500 via-indigo-500 to-purple-600 flex items-center justify-center text-white shadow-md shadow-sky-500/25 group-hover:scale-105 transition-transform">
<span class="text-xl font-black">旺</span>
<span class="text-xl font-black">东</span>
<span class="absolute -bottom-0.5 -right-0.5 w-3 h-3 bg-emerald-500 rounded-full border-2 border-white dark:border-slate-900"></span>
</div>
<div class="hidden sm:block">
<div class="font-extrabold text-base tracking-tight flex items-center gap-2">
<span class="bg-gradient-to-r from-slate-900 to-slate-700 dark:from-white dark:to-slate-300 bg-clip-text text-transparent">旺总的技术全栈</span>
<span class="bg-gradient-to-r from-slate-900 to-slate-700 dark:from-white dark:to-slate-300 bg-clip-text text-transparent">小东的技术全栈</span>
<span class="px-2 py-0.5 rounded-full text-[10px] font-semibold bg-sky-100 text-sky-800 dark:bg-sky-950 dark:text-sky-300 border border-sky-200 dark:border-sky-800">
v2.0
</span>
@@ -341,7 +341,7 @@
<div>
<div class="flex flex-wrap items-center gap-3">
<h1 class="text-2xl sm:text-3xl font-black tracking-tight text-slate-900 dark:text-white">
旺总 <span class="text-slate-400 text-lg font-normal font-mono">(WangZong)</span>
小东 <span class="text-slate-400 text-lg font-normal font-mono">(XiaoDong)</span>
</h1>
<span class="px-2.5 py-0.5 text-xs font-semibold rounded-md bg-gradient-to-r from-sky-500/10 to-indigo-500/10 text-sky-700 dark:text-sky-300 border border-sky-200/60 dark:border-sky-800/60">
🚀 全栈架构师 · DevOps 极客
@@ -544,8 +544,8 @@
<div class="flex flex-wrap items-center gap-4 text-xs text-slate-500 dark:text-slate-400 font-mono">
<span class="flex items-center gap-1.5">
<span class="w-5 h-5 rounded-full bg-slate-800 text-white flex items-center justify-center text-[10px]">旺</span>
<span>作者: {{ activePost.author || '旺总' }}</span>
<span class="w-5 h-5 rounded-full bg-slate-800 text-white flex items-center justify-center text-[10px]">东</span>
<span>作者: {{ activePost.author || '小东' }}</span>
</span>
<span>·</span>
<span>⏱️ 预计耗时 {{ activePost.readTime || '5 min' }}</span>
@@ -758,7 +758,7 @@
<div>
<h1 class="text-3xl font-black text-slate-900 dark:text-white flex items-center gap-3">
<span>👨‍💻</span>
<span>关于旺总 (WangZong) 与本站架构</span>
<span>关于小东 (XiaoDong) 与本站架构</span>
</h1>
<p class="mt-2 text-sm text-slate-500">一个追求工程极致、拥抱云原生与本地大模型的全栈开发者个人空间。</p>
</div>
@@ -878,10 +878,7 @@
<label class="block font-semibold mb-1 text-slate-700 dark:text-slate-300 text-xs">技术专栏分类</label>
<select v-model="newPost.categoryName"
class="w-full px-3.5 py-2 rounded-xl bg-slate-50 dark:bg-slate-800 border border-slate-300 dark:border-slate-700 focus:ring-2 focus:ring-sky-500 focus:outline-none text-xs">
<option value="云原生 & Linux">云原生 & Linux</option>
<option value="Java & Spring Boot">Java & Spring Boot</option>
<option value="AI & 本地模型">AI & 本地模型</option>
<option value="全栈开发 & CI/CD">全栈开发 & CI/CD</option>
<option v-for="cat in availableCategories" :key="cat" :value="cat">{{ cat }}</option>
</select>
</div>
<div>
@@ -964,7 +961,7 @@
<div class="max-w-6xl mx-auto px-4 sm:px-6 flex flex-col sm:flex-row items-center justify-between gap-4">
<div class="flex items-center gap-2">
<span class="w-2 h-2 rounded-full bg-emerald-500"></span>
<span>© 2026 旺总的技术全栈 · 运行于 Google Cloud 台湾节点</span>
<span>© 2026 小东的技术全栈 · 运行于 Google Cloud 台湾节点</span>
</div>
<div class="flex items-center gap-4 font-mono text-[11px]">
<span>Spring Boot 3</span>
@@ -1007,23 +1004,47 @@
const showScrollTop = ref(false);
const toasts = ref([]);
const categories = ['全部', '云原生 & Linux', 'Java & Spring Boot', 'AI & 本地模型', '全栈开发 & CI/CD'];
const categories = ref(['全部']);
const categoryList = ref([]);
const availableCategories = computed(() => categories.value.filter(c => c !== '全部'));
const categoryList = [
const newPost = ref({
title: '',
categoryName: '全栈开发 & CI/CD',
author: '小东',
tags: 'SpringBoot,MySQL',
summary: '',
content: ''
});
// 从后端 MySQL 8.0 动态获取分类列表
async function fetchCategories() {
try {
const res = await fetch(`${API_BASE}/categories`);
if (res.ok) {
const result = await res.json();
const list = result.data || result || [];
if (list.length > 0) {
categoryList.value = list.map(c => ({
name: c.name,
icon: getCategoryIcon(c.name),
desc: c.description || '沉淀架构与工程规范'
}));
categories.value = ['全部', ...list.map(c => c.name)];
return;
}
}
} catch (e) {
console.warn('获取分类数据失败,使用基础兜底:', e);
}
categories.value = ['全部', '云原生 & Linux', 'Java & Spring Boot', 'AI & 本地模型', '全栈开发 & CI/CD'];
categoryList.value = [
{ name: '云原生 & Linux', icon: '☁️', desc: 'Google Cloud 台湾节点云服务器运维、Ubuntu 系统内核参数调优、1Panel 容器环境与网络实战。' },
{ name: 'Java & Spring Boot', icon: '🍃', desc: 'Spring Boot 3.2 现代化分层设计、Spring Data JPA 对象关系映射、事务控制与统一 RESTful 规范。' },
{ name: 'AI & 本地模型', icon: '🧠', desc: 'Ollama 容器化引擎、DeepSeek R1 本地 CPU 性能压测与加速方案、Prompt 预填充降延迟实操。' },
{ name: '全栈开发 & CI/CD', icon: '⚙️', desc: '前后端分离微服务架构、Docker Compose 多容器生命周期管理、私有 Gitea Actions 持续交付流水线。' }
];
const newPost = ref({
title: '',
categoryName: '全栈开发 & CI/CD',
author: '旺总',
tags: 'SpringBoot,MySQL',
summary: '',
content: ''
});
}
// Toast 通知提示系统
function showToast(text, type = 'info', icon = '🔔') {
@@ -1318,8 +1339,8 @@
function openPublishModal() {
newPost.value = {
title: '',
categoryName: '全栈开发 & CI/CD',
author: '旺总',
categoryName: availableCategories.value[0] || '全栈开发 & CI/CD',
author: '小东',
tags: 'SpringBoot,MySQL,Docker',
summary: '',
content: ''
@@ -1479,6 +1500,7 @@
window.addEventListener('scroll', handleScroll);
window.addEventListener('hashchange', handleHashRoute);
await fetchCategories();
await fetchPosts();
handleHashRoute();
});
@@ -1498,6 +1520,7 @@
stats,
categories,
categoryList,
availableCategories,
selectedCategory,
searchKeyword,
selectCategory,