From 38f5cf5e0b2ac1f08235ceec60fc2e4607601543 Mon Sep 17 00:00:00 2001 From: shenlan Date: Wed, 18 Jun 2025 14:36:07 +0800 Subject: [PATCH] docs: add macOS Makefile and usage --- docs/ui/nextjs-admin-panel.md | 14 ++++++++++++++ ui/nextjs/Makefile | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 ui/nextjs/Makefile diff --git a/docs/ui/nextjs-admin-panel.md b/docs/ui/nextjs-admin-panel.md index 8ba3258..da578f8 100644 --- a/docs/ui/nextjs-admin-panel.md +++ b/docs/ui/nextjs-admin-panel.md @@ -55,3 +55,17 @@ styles/ ## 示例代码结构 本仓库 `ui/nextjs` 目录提供了一套最简参考实现,可直接 `npm run build && npx next export` 编译到 `ui/dist` 供 Go 服务嵌入。 + +## macOS 本地开发调试 +`ui/nextjs` 目录下新增的 `Makefile` 可在 macOS 环境一键执行常见任务: + +```bash +make init # 安装依赖(若未检测到 yarn 会自动使用 Homebrew 安装) +make run # 启动开发服务 +make build # 构建生产版本 +make export # 导出静态页面到 out/ +make clean # 清理构建产物 +``` + +执行 `make info` 可查看当前 Node.js 版本,方便排查本地环境问题。 + diff --git a/ui/nextjs/Makefile b/ui/nextjs/Makefile new file mode 100644 index 0000000..b424d63 --- /dev/null +++ b/ui/nextjs/Makefile @@ -0,0 +1,35 @@ +# Makefile for Next.js on macOS + +# Node.js 版本校验(可选) +NODE_VERSION := $(shell node -v 2>/dev/null) +YARN := $(shell command -v yarn 2>/dev/null) + +.PHONY: init build run export clean info + +init: +@echo "🔧 Installing dependencies..." +ifeq ($(YARN),) +@echo "⚠️ Yarn not found. Installing via Homebrew..." +brew install yarn +endif +yarn install + +build: +@echo "🔨 Building Next.js project..." +yarn build + +run: +@echo "🚀 Starting local dev server..." +yarn dev + +export: +@echo "📦 Exporting static site to ./out ..." +yarn build && yarn export + +clean: +@echo "🧹 Cleaning build artifacts..." +rm -rf .next out + +info: +@echo "🧾 Current Node.js version: $(NODE_VERSION)" +