Add your description here
Project description
FastAPI + Vue 3 全栈应用模板
这是一个现代化、生产就绪的全栈应用模板,采用 Python FastAPI 作为后端,Vue 3 作为前端。专为无缝开发体验和单端口部署而设计。
✨ 特性
- 一体化部署: 后端和前端在同一个端口 (8000) 上提供服务,无需额外部署前端服务器。
- SPA 支持: 通过 FastAPI 的 Catch-all 路由完美支持 Vue Router 的 History 模式。
- 现代化工具链:
- 后端: 使用
uv进行超快速的 Python 包管理。 - 前端: 使用
Vite+pnpm+unplugin-vue-router(基于文件的自动路由)。
- 后端: 使用
- 跨平台支持: 内置的任务运行器可在 Windows, macOS 和 Linux 上流畅运行。
- 极致开发体验: 仅需一条命令即可同时启动前后端开发服务器,并支持热重载。
- 简便的前端管理: 提供
f命令代理,无需手动切换目录即可执行前端命令。 - 代码规范: 内置 Ruff (Python) 和 ESLint (Vue/TS) 配置,配合 pre-commit 自动保证代码质量。
📋 环境要求
- Python (3.12+)
- Node.js (20+)
- uv (Python 包管理器)
- pnpm (Node 包管理器)
🚀 快速开始
-
安装依赖
# 安装后端依赖 (一般情况下会在执行 uv run 时自动安装) uv sync # 安装前端依赖 (一般情况下在启动 dev 时会自动安装) uv run f pnpm install
-
启动开发服务器
uv run dev
- 后端地址:
http://localhost:8000 - 前端地址:
http://localhost:5173(API 请求会自动代理到后端)
- 后端地址:
🛠️ 命令参考
我们通过 pyproject.toml 注册了以下快捷命令:
| 命令 | 描述 |
|---|---|
uv run dev |
并发启动后端和前端的开发服务器。 |
uv run build |
将 Vue 前端构建到 frontend_dist/ 目录。 |
uv run start |
启动生产环境后端服务器 (同时托管 API 和静态文件)。 |
uv run preview |
先执行 build 然后执行 start,用于预览生产环境构建效果。 |
uv run f [cmd] |
在 frontend/ 目录下运行命令。例如: uv run f pnpm install |
uv run manage setup |
手动安装/修复 Git Hooks (通常会自动执行,无需手动运行)。 |
(注: 旧的 uv run manage [command] 方式依然受支持)
📂 项目结构
.
├── gudupao_backend_frontend_demo/ # Python 包源码
│ ├── app/ # Python 后端代码
│ │ ├── core/ # 核心逻辑 (如 SPA 路由处理)
│ │ ├── routers/ # API 路由定义
│ │ ├── main.py # FastAPI 入口点 & 静态文件托管逻辑
│ │ └── ...
│ ├── scripts/ # 项目管理脚本
│ │ └── manage.py # 任务运行器逻辑 (dev, build, start 等)
│ └── ...
├── frontend/ # Vue 3 前端源码
│ ├── src/pages/ # 基于文件的路由目录 (自动生成路由)
│ ├── scripts/ # 前端脚本 (如 generate-manifest.ts)
│ ├── vite.config.ts # Vite 配置 (包含 Proxy 和构建输出配置)
│ └── ...
├── frontend_dist/ # 构建产物 (由 build 命令生成)
├── pyproject.toml # Python 依赖 & 脚本入口配置
└── uv.lock
🚢 部署指南
部署到生产环境
本项目设计为可以像标准 Python 应用一样进行部署。
- 构建前端 (在 CI/CD 或本地环境执行):
uv run build
- 准备服务器:
- 将
gudupao_backend_frontend_demo/目录,frontend_dist/目录, 和pyproject.toml复制到服务器。 - 确保服务器已安装 Python 和
uv。
- 将
- 运行服务:
uv sync uv run start
- 注意: 生产环境服务器不需要安装 Node.js (因为我们只托管构建好的静态文件)。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gudupao_backend_frontend_demo-0.0.15.tar.gz.
File metadata
- Download URL: gudupao_backend_frontend_demo-0.0.15.tar.gz
- Upload date:
- Size: 68.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22356e07bd22531c9f518ec457f2a8fd8709118a659f871e39c8930025dfdf15
|
|
| MD5 |
2e9020de032631db367fb7df7d83b04d
|
|
| BLAKE2b-256 |
02a3e653d5fbf5fbfaec451bf7fbfc963bc6b843ea569b114c318a7451f8f01f
|
Provenance
The following attestation bundles were made for gudupao_backend_frontend_demo-0.0.15.tar.gz:
Publisher:
publish.yml on GudupaoCreativity/demo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gudupao_backend_frontend_demo-0.0.15.tar.gz -
Subject digest:
22356e07bd22531c9f518ec457f2a8fd8709118a659f871e39c8930025dfdf15 - Sigstore transparency entry: 853694401
- Sigstore integration time:
-
Permalink:
GudupaoCreativity/demo@67755d5c72b307c0402df57b432fa750358d9c75 -
Branch / Tag:
refs/tags/0.0.15 - Owner: https://github.com/GudupaoCreativity
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@67755d5c72b307c0402df57b432fa750358d9c75 -
Trigger Event:
release
-
Statement type:
File details
Details for the file gudupao_backend_frontend_demo-0.0.15-py3-none-any.whl.
File metadata
- Download URL: gudupao_backend_frontend_demo-0.0.15-py3-none-any.whl
- Upload date:
- Size: 72.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
892fa21fe82eb9cc52340321ae369864decbee94f6adf9a19f25f347916241f9
|
|
| MD5 |
322a2e5c92c68a61078981f306a4d8ee
|
|
| BLAKE2b-256 |
4ffc73660d93e006e51940b4733cb3825a98ee3104f48cd71c63336eb1ea9a4b
|
Provenance
The following attestation bundles were made for gudupao_backend_frontend_demo-0.0.15-py3-none-any.whl:
Publisher:
publish.yml on GudupaoCreativity/demo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gudupao_backend_frontend_demo-0.0.15-py3-none-any.whl -
Subject digest:
892fa21fe82eb9cc52340321ae369864decbee94f6adf9a19f25f347916241f9 - Sigstore transparency entry: 853694439
- Sigstore integration time:
-
Permalink:
GudupaoCreativity/demo@67755d5c72b307c0402df57b432fa750358d9c75 -
Branch / Tag:
refs/tags/0.0.15 - Owner: https://github.com/GudupaoCreativity
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@67755d5c72b307c0402df57b432fa750358d9c75 -
Trigger Event:
release
-
Statement type: