Compare commits

...

10 Commits

Author SHA1 Message Date
joyzhao
22e7050b23 feat: 添加关于选择 Nuxt.js 和 NestJS 的文章
Some checks failed
Deploy docs for Site / deploy (20.x) (push) Has been cancelled
2025-09-29 11:18:15 +08:00
joyzhao
8df3deebff chore: remove vscode configuration files 2025-07-02 16:18:30 +08:00
joyzhao
4650eac67f ci(deploy): fix incorrect target path in deployment workflow 2025-06-26 09:57:40 +08:00
joyzhao
c65e9e8e9f ci(deploy): fix incorrect target path in deployment workflow 2025-06-26 09:53:48 +08:00
joyzhao
731f57b764 ci: fix incorrect TARGET path in deploy workflow 2025-06-26 09:45:28 +08:00
joyzhao
fefd643fd4 ci: update deploy target path in workflow
Update the TARGET path in deploy workflow to point to the correct directory without the 'dist' subfolder
2025-06-25 21:51:43 +08:00
joyzhao
bb5714f154 ci: update deploy target path in workflow 2025-06-25 21:31:51 +08:00
joyzhao
59b7e8dda4 ci: update deploy target path in workflow 2025-06-25 21:25:30 +08:00
joyzhao
710ce9ba39 refactor(i18n): move Lang type to types/i18n directory
Update import paths for Lang type across layout files to use new location
Add umami analytics script in production mode
2025-06-21 22:30:44 +08:00
joyzhao
3b9e0465e4 ci: update node version to 20.x in deploy workflow 2025-06-21 21:34:04 +08:00
9 changed files with 86 additions and 21 deletions

View File

@@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
node-version: [20.x]
steps:
- name: Checkout repository code
uses: https://gitea.com/actions/checkout@v4
@@ -55,5 +55,5 @@ jobs:
REMOTE_HOST: ${{ secrets.DEPLOY_HOST }}
REMOTE_USER: ${{ secrets.DEPLOY_USER }}
SOURCE: "/dist/"
TARGET: "/webroot/sites/zhaoguiyang"
TARGET: "/opt/1panel/apps/openresty/openresty/www/sites/zhaoguiyang.com/index/dist"
EXCLUDE: "/node_modules/"

View File

@@ -1,4 +0,0 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}

11
.vscode/launch.json vendored
View File

@@ -1,11 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -1,6 +1,6 @@
---
import Layout from './Layout.astro';
import { type Lang } from '@/i18n/utils';
import { type Lang } from '@/types/i18n';
import { defaultLang } from '@/i18n/ui';
import GlassHeader from '@/components/GlassHeader';
import Footer from '@/components/Footer';

View File

@@ -1,7 +1,7 @@
---
import Layout from './Layout.astro';
import type { MarkdownLayoutProps } from 'astro';
import { type Lang } from '@/i18n/utils';
import { type Lang } from '@/types/i18n';
import { type FrontmatterProps } from '@/types';
import { defaultLang } from '@/i18n/ui';
import GlassHeader from '@/components/GlassHeader';

View File

@@ -30,6 +30,11 @@ const t = useTranslations(lang);
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap"
rel="stylesheet"
/>
{
import.meta.env.MODE === 'production' && (
<script defer src="https://cloud.umami.is/script.js" data-website-id="a79f759b-74ae-4165-b738-56d123a1c6be"></script>
)
}
</head>
<body
class="min-h-screen bg-background font-sans antialiased selection:bg-purple-500/20 selection:text-purple-500"

View File

@@ -8,8 +8,7 @@ import BlogList from '../components/blog/BlogList.astro';
import CategoryCard from '../components/blog/CategoryCard.astro';
import TagCard from '../components/blog/TagCard.astro';
import Container from '../components/ui/Container';
import { type Lang } from '@/i18n/utils';
import { defaultLang } from '@/i18n/ui';
import { type Lang } from '@/types/i18n';
import { type BlogPost } from '@/types';
interface Props {

View File

@@ -0,0 +1,76 @@
# 我为什么放弃 Next.js选择 Nuxt.js 和 NestJS
过去几年里,我尝试过很多 Node.js 框架和前端技术栈:**Express、Koa、Fastify、Hono.js**,以及前端的 **Next.js**。这些框架和工具都有各自的优点:轻量、灵活、性能好,社区里也有不少人推荐。然而,随着项目的深入,我逐渐发现了一个事实:**简单、快速实现、自己熟悉、生态完善、可扩展性好**,才是最重要的,而不是盲目追逐“最流行”或“性能最高”的框架。
## 为什么不是 Next.js
我也写过 React 和 Next.js但总感觉生态太杂。尤其是 **状态管理**,从 Redux、MobX 到 Zustand、Jotai再到 React Query、TanStack Query每一种都有各自的优缺点但选择过多反而让我心智负担加重。很多问题并不是没有解决方案而是解决方案太多、没有统一的“最佳实践”。
相比之下,**NuxtJS 在 Vue 生态下要更工程化**。比如:
* 内置路由、布局、服务端渲染等功能,不需要额外选型。
* Vue 的响应式和 Pinia 状态管理简单好用,不需要反复对比。
* 配合 Nuxt UI、TailwindCSS可以快速构建出一致的前端体验。
对我来说NuxtJS 的“约定优于配置”正好能让我聚焦在业务上,而不是被生态碎片化牵扯精力。
## 为什么选择 NestJS
很多人说 **NestJS 太重**,但我的实际体验是:**它恰到好处**。
* NestJS 自带 CLI可以快速生成模块、控制器、服务大大提升开发效率。
* 内置依赖注入、装饰器模式,让代码组织更清晰、可维护。
* 和 TypeScript 深度结合,不仅提高了开发体验,也减少了运行时错误。
* 对数据库、认证、缓存、消息队列等都有完善的解决方案,遇到问题时社区文档和生态资源都很丰富。
更重要的是,在 **AI 辅助开发** 的今天,像 NestJS 和 NuxtJS 这种约定清晰、工程化程度高的框架,更容易被 AI 理解和提供正确的解决方案。相比一些过于灵活的轻量框架AI 在这类框架上的“知识盲区”更少。
## 两套技术方案
结合我的经验和实际需求,我总结出了两套适合的技术栈:
### 1. 轻量级方案(业务简单)
* **NuxtJS**
* **Drizzle ORM**
* **Nuxt UI**
* **TailwindCSS**
适合快速原型、简单应用、验证市场。
### 2. 完整方案(业务复杂)
* **NestJS**
* **NuxtJS**
* **Zod**
* **Drizzle ORM**
* **Redis**
* **Postgres**
* **Nuxt UI**
* **TailwindCSS**
适合需要后端独立、扩展性强的项目,可以通过微服务、缓存、消息队列等方式支撑更复杂的业务。
## 性能并不是唯一的答案
很多人推崇 **Hono.js**、**Elysia.js** 等轻量框架,说它们“简单、快、性能好”。确实,在 Hello World 或简单 API 的场景下,它们的性能数据很漂亮。但在真实的生产环境里,**性能瓶颈往往不在框架**,而在:
* 数据库查询优化
* 缓存策略
* 多实例部署
* 微服务架构
* 负载均衡与扩展能力
这时候,单一框架的“性能优势”几乎可以忽略。真正决定系统表现的,是整体架构设计和资源利用。
## 结论
我的体会是:**技术选型没有绝对的好坏,关键在于适合自己和项目需求**。
对我来说NestJS + NuxtJS 这套组合:
* 工程化、生态完善,能快速实现功能。
* 熟悉度高,减少了心智负担。
* 易于扩展,能应对简单和复杂的业务场景。
* 在 AI 辅助的今天,更容易获得准确支持。
因此,哪怕有人说它们“重”或“不如某某框架”,我依然会坚持:**适合自己的,才是最好的技术栈**。