2
This commit is contained in:
1 parent
67905dfa16
commit
6c3021ea8d
6 files changed
+125
-13
No files matched your search
@@ -2,6 +2,7 @@
|
|||||||
**/obj/
|
**/obj/
|
||||||
**/node_modules/
|
**/node_modules/
|
||||||
**/dist/
|
**/dist/
|
||||||
|
.artifacts/
|
||||||
.vs/
|
.vs/
|
||||||
.vscode/
|
.vscode/
|
||||||
*.user
|
*.user
|
||||||
@@ -10,6 +11,7 @@
|
|||||||
*.sqlite-shm
|
*.sqlite-shm
|
||||||
*.sqlite-wal
|
*.sqlite-wal
|
||||||
src/Jiaowu.Api/data/
|
src/Jiaowu.Api/data/
|
||||||
|
src/Jiaowu.Api/wwwroot/
|
||||||
.env
|
.env
|
||||||
.env.*
|
.env.*
|
||||||
!.env.example
|
!.env.example
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
面向普通高校的教务管理系统。后端使用 ASP.NET Core 10、EF Core 10,前端使用 Vue 3、TypeScript 和 Element Plus。
|
面向普通高校的教务管理系统。后端使用 ASP.NET Core 10、EF Core 10,前端使用 Vue 3、TypeScript 和 Element Plus。
|
||||||
|
|
||||||
## 本地开发
|
## 本地开发:热更新模式
|
||||||
|
|
||||||
本地开发固定使用 SQLite。首次启动会自动创建 `src/Jiaowu.Api/data/jiaowu-dev.sqlite` 并写入演示组织数据。
|
本地开发固定使用 SQLite。首次启动会自动创建 `src/Jiaowu.Api/data/jiaowu-dev.sqlite` 并写入演示组织数据。
|
||||||
|
|
||||||
@@ -20,18 +20,32 @@ npm run dev
|
|||||||
|
|
||||||
访问 `http://localhost:5173`,开发账号为 `admin`,密码为 `Admin@123456`。
|
访问 `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 部署
|
## MySQL 部署
|
||||||
|
|
||||||
非 Development 环境只允许使用 MySQL。连接串和 JWT 密钥应通过环境变量或安全配置中心提供:
|
非 Development 环境只允许使用 MySQL。`dotnet publish` 会自动执行 `npm ci` 和 `npm run build`,并将 Vue 静态文件放入发布目录的 `wwwroot`:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
$env:ASPNETCORE_ENVIRONMENT = 'Production'
|
$env:ASPNETCORE_ENVIRONMENT = 'Production'
|
||||||
$env:Database__Provider = 'MySql'
|
$env:Database__Provider = 'MySql'
|
||||||
$env:ConnectionStrings__MySql = 'Server=127.0.0.1;Port=3306;Database=jiaowu;User=YOUR_USER;Password=YOUR_PASSWORD;'
|
$env:ConnectionStrings__MySql = 'Server=127.0.0.1;Port=3306;Database=jiaowu;User=YOUR_USER;Password=YOUR_PASSWORD;'
|
||||||
$env:Jwt__Key = '至少32字节的随机生产密钥'
|
$env:Jwt__Key = '至少32字节的随机生产密钥'
|
||||||
dotnet run --project src/Jiaowu.Api
|
dotnet publish src/Jiaowu.Api -c Release -o .artifacts/publish
|
||||||
|
.artifacts/publish/Jiaowu.Api.exe
|
||||||
```
|
```
|
||||||
|
|
||||||
|
如需在特殊流水线中跳过自动前端构建,可传入 `-p:BuildFrontendOnPublish=false`。
|
||||||
|
|
||||||
生产环境不会创建默认管理员。首次部署前可以临时配置 `SeedAdmin__UserName`、`SeedAdmin__Password` 和 `SeedAdmin__DisplayName`,账号创建后移除这些配置。
|
生产环境不会创建默认管理员。首次部署前可以临时配置 `SeedAdmin__UserName`、`SeedAdmin__Password` 和 `SeedAdmin__DisplayName`,账号创建后移除这些配置。
|
||||||
|
|
||||||
生产数据库使用 MySQL 专用 EF Core 迁移。部署前先恢复仓库工具并检查迁移:
|
生产数据库使用 MySQL 专用 EF Core 迁移。部署前先恢复仓库工具并检查迁移:
|
||||||
@@ -47,6 +61,6 @@ dotnet ef migrations list --project src/Jiaowu.Api --startup-project src/Jiaowu.
|
|||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
dotnet test Jiaowu.slnx
|
dotnet test Jiaowu.slnx
|
||||||
Set-Location web
|
npm --prefix web run build
|
||||||
npm run build
|
pwsh.exe -NoLogo -NoProfile -NonInteractive -File scripts/smoke-test.ps1
|
||||||
```
|
```
|
||||||
+34
-8
@@ -1,15 +1,30 @@
|
|||||||
|
param(
|
||||||
|
[string] $ApiExecutablePath,
|
||||||
|
[string] $ApiContentRoot
|
||||||
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
$workspaceRoot = Split-Path -Parent $PSScriptRoot
|
$workspaceRoot = Split-Path -Parent $PSScriptRoot
|
||||||
$apiProjectDirectory = Join-Path $workspaceRoot 'src/Jiaowu.Api'
|
$apiExecutable = if ([string]::IsNullOrWhiteSpace($ApiExecutablePath)) {
|
||||||
$apiExecutable = Join-Path $workspaceRoot 'src/Jiaowu.Api/bin/Debug/net10.0/Jiaowu.Api.exe'
|
Join-Path $workspaceRoot 'src/Jiaowu.Api/bin/Debug/net10.0/Jiaowu.Api.exe'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[System.IO.Path]::GetFullPath($ApiExecutablePath, $workspaceRoot)
|
||||||
|
}
|
||||||
|
$apiWorkingDirectory = if ([string]::IsNullOrWhiteSpace($ApiContentRoot)) {
|
||||||
|
Join-Path $workspaceRoot 'src/Jiaowu.Api'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[System.IO.Path]::GetFullPath($ApiContentRoot, $workspaceRoot)
|
||||||
|
}
|
||||||
$stdoutPath = Join-Path $env:TEMP 'jiaowu-api-smoke.out.log'
|
$stdoutPath = Join-Path $env:TEMP 'jiaowu-api-smoke.out.log'
|
||||||
$stderrPath = Join-Path $env:TEMP 'jiaowu-api-smoke.err.log'
|
$stderrPath = Join-Path $env:TEMP 'jiaowu-api-smoke.err.log'
|
||||||
$env:ASPNETCORE_ENVIRONMENT = 'Development'
|
$env:ASPNETCORE_ENVIRONMENT = 'Development'
|
||||||
$env:ASPNETCORE_URLS = 'http://localhost:5255'
|
$env:ASPNETCORE_URLS = 'http://localhost:5255'
|
||||||
$startParameters = @{
|
$startParameters = @{
|
||||||
FilePath = $apiExecutable
|
FilePath = $apiExecutable
|
||||||
WorkingDirectory = $apiProjectDirectory
|
WorkingDirectory = $apiWorkingDirectory
|
||||||
WindowStyle = 'Hidden'
|
WindowStyle = 'Hidden'
|
||||||
RedirectStandardOutput = $stdoutPath
|
RedirectStandardOutput = $stdoutPath
|
||||||
RedirectStandardError = $stderrPath
|
RedirectStandardError = $stderrPath
|
||||||
@@ -51,13 +66,24 @@ try {
|
|||||||
$headers = @{ Authorization = "Bearer $($login.token)" }
|
$headers = @{ Authorization = "Bearer $($login.token)" }
|
||||||
$dashboard = Invoke-RestMethod -Uri 'http://localhost:5255/api/dashboard' -Headers $headers
|
$dashboard = Invoke-RestMethod -Uri 'http://localhost:5255/api/dashboard' -Headers $headers
|
||||||
$campuses = Invoke-RestMethod -Uri 'http://localhost:5255/api/base-data/campuses' -Headers $headers
|
$campuses = Invoke-RestMethod -Uri 'http://localhost:5255/api/base-data/campuses' -Headers $headers
|
||||||
|
$frontend = Invoke-WebRequest -Uri 'http://localhost:5255/' -TimeoutSec 5
|
||||||
|
$spaFallback = Invoke-WebRequest -Uri 'http://localhost:5255/base-data' -TimeoutSec 5
|
||||||
|
$unknownApiParameters = @{
|
||||||
|
Uri = 'http://localhost:5255/api/does-not-exist'
|
||||||
|
SkipHttpErrorCheck = $true
|
||||||
|
TimeoutSec = 5
|
||||||
|
}
|
||||||
|
$unknownApi = Invoke-WebRequest @unknownApiParameters
|
||||||
|
|
||||||
[pscustomobject]@{
|
[pscustomobject]@{
|
||||||
Health = $health.status
|
Health = $health.status
|
||||||
Database = $health.database
|
Database = $health.database
|
||||||
User = $login.user.displayName
|
User = $login.user.displayName
|
||||||
Term = $dashboard.currentTerm.name
|
Term = $dashboard.currentTerm.name
|
||||||
Campuses = @($campuses).Count
|
Campuses = @($campuses).Count
|
||||||
|
StaticIndex = $frontend.Content.Contains('明序教务管理系统')
|
||||||
|
SpaFallback = $spaFallback.StatusCode
|
||||||
|
ApiNotFound = $unknownApi.StatusCode
|
||||||
} | Format-List
|
} | Format-List
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|||||||
Loaded 3 of 6 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user