Skip to content

Commit 8f0d482

Browse files
committed
refactor: frontend dir path
1 parent 6cca623 commit 8f0d482

15 files changed

Lines changed: 92 additions & 92 deletions

.githooks/pre-commit

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ go test ./...
1212

1313
# Frontend lint/format (if dependencies installed)
1414
if [ -f "frontend/package.json" ]; then
15-
if command -v pnpm >/dev/null 2>&1 && [ -d "web/node_modules" ]; then
16-
echo "[pre-commit] Running web lint and format checks"
17-
(cd web && pnpm -s lint && pnpm -s format:check)
15+
if command -v pnpm >/dev/null 2>&1 && [ -d "frontend/node_modules" ]; then
16+
echo "[pre-commit] Running frontend lint and format checks"
17+
(cd frontend && pnpm -s lint && pnpm -s format:check)
1818
else
19-
echo "[pre-commit] Skipping web lint: pnpm not available or dependencies not installed"
19+
echo "[pre-commit] Skipping frontend lint: pnpm not available or dependencies not installed"
2020
fi
2121
fi
2222

.github/skills/shadmin-dev/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: shadmin-dev
3-
description: Apply Shadmin feature-development standards (backend Go/Gin/Ent + frontend React/TS). Use when adding/modifying features, CRUD modules, API routes/controllers/usecases/repositories, Ent schemas, web pages/routes, React components, TanStack hooks, or any full-stack work in this project. Trigger whenever the user mentions new features, backend changes, frontend changes, database schema changes, permissions, UI pages, tables, forms, or API endpoints — even if they don't explicitly say "feature development."
3+
description: Apply Shadmin feature-development standards (backend Go/Gin/Ent + frontend React/TS). Use when adding/modifying features, CRUD modules, API routes/controllers/usecases/repositories, Ent schemas, frontend pages/routes, React components, TanStack hooks, or any full-stack work in this project. Trigger whenever the user mentions new features, backend changes, frontend changes, database schema changes, permissions, UI pages, tables, forms, or API endpoints — even if they don't explicitly say "feature development."
44
---
55

66
# Shadmin Feature Development

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#---------------------build web------------------------
2-
FROM docker.io/library/node:22-alpine AS build_web
3-
WORKDIR /app/web
1+
#---------------------build frontend------------------------
2+
FROM docker.io/library/node:22-alpine AS build_frontend
3+
WORKDIR /app/frontend
44
RUN corepack enable
5-
COPY frontend/package.json web/pnpm-lock.yaml web/pnpm-workspace.yaml ./
5+
COPY frontend/package.json frontend/pnpm-lock.yaml frontend/pnpm-workspace.yaml ./
66
RUN pnpm install --frozen-lockfile
77
COPY frontend/ ./
88
RUN pnpm run build
@@ -13,7 +13,7 @@ WORKDIR /app
1313
COPY go.mod go.sum ./
1414
RUN go mod download
1515
COPY . .
16-
COPY --from=build_web /app/web/dist /app/web/dist
16+
COPY --from=build_frontend /app/frontend/dist /app/frontend/dist
1717

1818
# 安装 ent 与 swagger(swag)
1919
RUN go install entgo.io/ent/cmd/ent@latest

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ git clone https://github.com/ahaodev/shadmin.git
4545
cd shadmin
4646

4747
# Install & build frontend
48-
cd web && pnpm install && pnpm build
48+
cd frontend && pnpm install && pnpm build
4949

5050
# Start backend (from project root)
51-
# Generates Ent code, embeds web/dist/, listens on :55667
51+
# Generates Ent code, embeds frontend/dist/, listens on :55667
5252
# .env auto‑generated on first run
5353
cd ..
5454
go generate ./ent
@@ -77,7 +77,7 @@ shadmin/
7777
├── usecase/ # Business logic
7878
├── internal/ # Internal utilities
7979
├── pkg/ # Shared packages
80-
├── web/ # React frontend (Vite + shadcn/ui)
80+
├── frontend/ # React frontend (Vite + shadcn/ui)
8181
│ └── src/
8282
│ ├── routes/ # TanStack file‑based routing
8383
│ ├── features/ # Feature modules

README.zh.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ git clone https://github.com/ahaodev/shadmin.git
4545
cd shadmin
4646

4747
# 安装依赖并构建前端
48-
cd web && pnpm install && pnpm build
48+
cd frontend && pnpm install && pnpm build
4949

5050
# 启动后端(从项目根目录执行)
51-
# 生成 Ent 代码,内嵌 web/dist/,监听 :55667
51+
# 生成 Ent 代码,内嵌 frontend/dist/,监听 :55667
5252
# 首次运行时自动生成 .env
5353
cd ..
5454
go generate ./ent
@@ -77,7 +77,7 @@ shadmin/
7777
├── usecase/ # 业务逻辑层
7878
├── internal/ # 内部工具
7979
├── pkg/ # 公共包
80-
├── web/ # React 前端(Vite + shadcn/ui)
80+
├── frontend/ # React 前端(Vite + shadcn/ui)
8181
│ └── src/
8282
│ ├── routes/ # TanStack 文件路由
8383
│ ├── features/ # 功能模块

cli/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,5 @@ The following items are explicitly **out of scope** for the MVP and tracked for
140140
later iterations:
141141

142142
- Write commands (create / update / delete) gated by stricter audit.
143-
- Backend audit field distinguishing CLI vs Web origin.
143+
- Backend audit field distinguishing CLI vs frontend origin.
144144
- Optional MCP server packaging on top of the same client layer.

docs/department-feature-evaluation.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ bootstrap/admin_init.go # 种子菜单数据(修改)
5858
ent/schema/user.go # 添加 department edge(修改)
5959
6060
# Frontend
61-
web/src/types/department.ts # 类型定义
62-
web/src/services/departmentApi.ts # API 服务
63-
web/src/features/system/departments/ # 功能模块目录
61+
frontend/src/types/department.ts # 类型定义
62+
frontend/src/services/departmentApi.ts # API 服务
63+
frontend/src/features/system/departments/ # 功能模块目录
6464
├── index.tsx # 页面入口
6565
├── components/
6666
│ ├── departments-table.tsx # 树形表格组件
@@ -72,7 +72,7 @@ web/src/features/system/departments/ # 功能模块目录
7272
│ └── use-departments.ts # TanStack Query hooks
7373
└── data/
7474
└── schema.ts # Zod 验证 schema
75-
web/src/routes/_authenticated/system/departments.tsx # 路由文件
75+
frontend/src/routes/_authenticated/system/departments.tsx # 路由文件
7676
```
7777

7878
### 2.2 Backend 详细设计
@@ -230,7 +230,7 @@ app.DB.Menu.Create().SetParentID(deptMgmt.ID).SetName("删除部门").SetSequenc
230230

231231
### 2.3 Frontend 详细设计
232232

233-
#### 2.3.1 类型定义 — `web/src/types/department.ts`
233+
#### 2.3.1 类型定义 — `frontend/src/types/department.ts`
234234

235235
```typescript
236236
export interface Department {
@@ -278,7 +278,7 @@ export interface UpdateDepartmentRequest {
278278
#### 2.3.3 权限常量
279279

280280
```typescript
281-
// web/src/constants/permissions.ts 中新增
281+
// frontend/src/constants/permissions.ts 中新增
282282
DEPARTMENT: {
283283
READ: 'system:dept:read',
284284
CREATE: 'system:dept:add',
@@ -328,11 +328,11 @@ DEPARTMENT: {
328328
| Backend Repository | `repository/department_repository.go` | 中(树形查询) |
329329
| Backend Usecase | `usecase/department_usecase.go` | 中(循环引用检测) |
330330
| Backend Controller | `api/controller/department_controller.go` ||
331-
| Frontend Types | `web/src/types/department.ts` ||
332-
| Frontend Service | `web/src/services/departmentApi.ts` ||
333-
| Frontend Page | `web/src/features/system/departments/index.tsx` ||
331+
| Frontend Types | `frontend/src/types/department.ts` ||
332+
| Frontend Service | `frontend/src/services/departmentApi.ts` ||
333+
| Frontend Page | `frontend/src/features/system/departments/index.tsx` ||
334334
| Frontend Components | `departments-table.tsx`, dialogs, provider | 中(树形表格) |
335-
| Frontend Route | `web/src/routes/.../departments.tsx` ||
335+
| Frontend Route | `frontend/src/routes/.../departments.tsx` ||
336336

337337
### 4.2 修改文件(约 8 个)
338338

@@ -411,9 +411,9 @@ DEPARTMENT: {
411411

412412
### Phase 4:Frontend 部门模块
413413

414-
15. 创建 `web/src/types/department.ts`
415-
16. 创建 `web/src/services/departmentApi.ts`
416-
17. 创建 `web/src/features/system/departments/` 整个模块
414+
15. 创建 `frontend/src/types/department.ts`
415+
16. 创建 `frontend/src/services/departmentApi.ts`
416+
17. 创建 `frontend/src/features/system/departments/` 整个模块
417417
18. 创建路由文件
418418

419419
### Phase 5:Frontend 用户集成

docs/getting-started/architecture.en.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ shadmin/
5858
├── internal/ # Internal utilities: Casbin manager, token service, login security
5959
├── pkg/ # Shared utilities: logging, etc.
6060
├── docs/ # Swagger generated files + architecture docs
61-
├── web/ # React frontend
61+
├── frontend/ # React frontend
6262
│ ├── src/
6363
│ │ ├── routes/ # File-based routing (TanStack Router)
6464
│ │ ├── features/ # Feature modules (pages + components + hooks + schema)
@@ -69,7 +69,7 @@ shadmin/
6969
│ │ ├── types/ # TypeScript type definitions
7070
│ │ ├── lib/ # Utility functions
7171
│ │ └── context/ # React Context Providers
72-
│ └── web.go # Go embed, embeds dist/ into the binary
72+
│ └── frontend.go # Go embed, embeds dist/ into the binary
7373
└── .env.example # Environment variable template
7474
```
7575

@@ -180,7 +180,7 @@ sequenceDiagram
180180
The frontend uses TanStack Router's **file-based routing**, where file paths map to URL paths:
181181

182182
```
183-
web/src/routes/
183+
frontend/src/routes/
184184
├── __root.tsx # Root layout (DevTools, progress bar)
185185
├── (auth)/ # Public route group (login, register)
186186
│ └── sign-in.tsx
@@ -303,7 +303,7 @@ main.go
303303

304304
## Frontend-Backend Collaboration
305305

306-
- **Production Mode**: Frontend build output (`web/dist/`) is embedded into the binary via `web/web.go` using Go embed. The backend serves both the SPA and API.
306+
- **Production Mode**: Frontend build output (`frontend/dist/`) is embedded into the binary via `frontend/frontend.go` using Go embed. The backend serves both the SPA and API.
307307
- **Development Mode**: Vite dev server runs on `:5173` and proxies `/api` requests to the backend at `:55667` via `vite.config.ts`.
308308

309309
## Next Steps

docs/getting-started/architecture.zh.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ shadmin/
5858
├── internal/ # 内部工具:Casbin 管理器、Token 服务、登录安全
5959
├── pkg/ # 公共工具:日志等
6060
├── docs/ # Swagger 生成文件 + 架构文档
61-
├── web/ # React 前端
61+
├── frontend/ # React 前端
6262
│ ├── src/
6363
│ │ ├── routes/ # 文件路由(TanStack Router)
6464
│ │ ├── features/ # 功能模块(页面 + 组件 + hooks + schema)
@@ -69,7 +69,7 @@ shadmin/
6969
│ │ ├── types/ # TypeScript 类型定义
7070
│ │ ├── lib/ # 工具函数
7171
│ │ └── context/ # React Context Providers
72-
│ └── web.go # Go embed,将 dist/ 嵌入二进制
72+
│ └── frontend.go # Go embed,将 dist/ 嵌入二进制
7373
└── .env.example # 环境变量模板
7474
```
7575

@@ -180,7 +180,7 @@ sequenceDiagram
180180
前端使用 TanStack Router 的 **文件路由**,路由定义即文件路径:
181181

182182
```
183-
web/src/routes/
183+
frontend/src/routes/
184184
├── __root.tsx # 根布局(DevTools、进度条)
185185
├── (auth)/ # 公开路由组(登录、注册)
186186
│ └── sign-in.tsx
@@ -303,7 +303,7 @@ main.go
303303

304304
## 前后端协作
305305

306-
- **生产模式**:前端构建产物 (`web/dist/`) 通过 `web/web.go` 以 Go embed 方式嵌入二进制,由后端统一提供 SPA + API 服务
306+
- **生产模式**:前端构建产物 (`frontend/dist/`) 通过 `frontend/frontend.go` 以 Go embed 方式嵌入二进制,由后端统一提供 SPA + API 服务
307307
- **开发模式**:前端 Vite 开发服务器运行在 `:5173`,通过 `vite.config.ts` 中的 proxy 将 `/api` 请求代理到后端 `:55667`
308308

309309
## 下一步

docs/getting-started/deployment.en.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This document covers deploying Shadmin to production, including single Docker co
1818

1919
```bash
2020
# 1. Build the frontend
21-
cd web && pnpm install && pnpm run build && cd ..
21+
cd frontend && pnpm install && pnpm run build && cd ..
2222

2323
# 2. Build the backend (with version injection)
2424
VERSION=$(git describe --tags --always 2>/dev/null || echo "dev")
@@ -30,7 +30,7 @@ CGO_ENABLED=1 go build \
3030
-o shadmin .
3131
```
3232

33-
> **Note:** The frontend must be built first (`pnpm run build`), because `web/web.go` uses Go embed to include `web/dist/`.
33+
> **Note:** The frontend must be built first (`pnpm run build`), because `frontend/frontend.go` uses Go embed to include `frontend/dist/`.
3434
3535
The build output `shadmin` is a self-contained single binary that includes frontend assets, backend logic, and Swagger documentation.
3636

@@ -43,7 +43,7 @@ docker build -t shadmin:latest .
4343
```
4444

4545
Build stages:
46-
1. **Stage 1 (Node)**: Install frontend dependencies and build `web/dist/`
46+
1. **Stage 1 (Node)**: Install frontend dependencies and build `frontend/dist/`
4747
2. **Stage 2 (Go)**: Compile Go backend with embedded frontend assets
4848
3. **Stage 3 (UPX)**: Compress the binary to reduce image size
4949
4. **Stage 4 (Debian slim)**: Final runtime image

0 commit comments

Comments
 (0)