Files
Academic-Affairs-System/README.md
T
2026-07-24 12:47:12 +08:00

67 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 明序教务管理系统
面向普通高校的教务管理系统。后端使用 ASP.NET Core 10、EF Core 10,前端使用 Vue 3、TypeScript 和 Element Plus。
## 本地开发:热更新模式
本地开发固定使用 SQLite。首次启动会自动创建 `src/Jiaowu.Api/data/jiaowu-dev.sqlite` 并写入演示组织数据。
```powershell
dotnet run --project src/Jiaowu.Api
```
另开一个终端:
```powershell
Set-Location web
npm install
npm run dev
```
访问 `http://localhost:5173`,开发账号为 `admin`,密码为 `Admin@123456`
## 本地开发:单服务模式
不需要前端热更新时,可以先把 Vue 编译进 API 的 `wwwroot`
```powershell
npm --prefix web run build
dotnet run --project src/Jiaowu.Api
```
访问 `http://localhost:5255``/api` 和静态页面由同一个 ASP.NET Core 服务提供,`/base-data` 等前端路由刷新时也会回退到 `index.html`
## MySQL 部署
非 Development 环境只允许使用 MySQL。`dotnet publish` 会自动执行 `npm ci``npm run build`,并将 Vue 静态文件放入发布目录的 `wwwroot`
```powershell
$env:ASPNETCORE_ENVIRONMENT = 'Production'
$env:Database__Provider = 'MySql'
$env:ConnectionStrings__MySql = 'Server=127.0.0.1;Port=3306;Database=jiaowu;User=YOUR_USER;Password=YOUR_PASSWORD;'
$env:Jwt__Key = '至少32字节的随机生产密钥'
dotnet publish src/Jiaowu.Api -c Release -o .artifacts/publish
.artifacts/publish/Jiaowu.Api.exe
```
如需在特殊流水线中跳过自动前端构建,可传入 `-p:BuildFrontendOnPublish=false`
生产环境不会创建默认管理员。首次部署前可以临时配置 `SeedAdmin__UserName``SeedAdmin__Password``SeedAdmin__DisplayName`,账号创建后移除这些配置。
生产数据库使用 MySQL 专用 EF Core 迁移。部署前先恢复仓库工具并检查迁移:
```powershell
dotnet tool restore
dotnet ef migrations list --project src/Jiaowu.Api --startup-project src/Jiaowu.Api
```
应用启动时会自动执行尚未应用的 MySQL 迁移。SQLite 只用于本地开发,并通过 `EnsureCreated` 建立本地数据库;开发模型变化后,可删除本地 SQLite 文件重新生成,不能把该文件用于生产。
## 验证
```powershell
dotnet test Jiaowu.slnx
npm --prefix web run build
pwsh.exe -NoLogo -NoProfile -NonInteractive -File scripts/smoke-test.ps1
```