生产模块拆分为前缫/后缫;修复菜单卡顿与重复请求;支持 IIS 单站点部署
1. 生产模块按工序拆分为两个一级菜单 - 生产-前缫(落丝记录)、生产-后缫(纤度检验、黑板检验) - 旧的「生产管理」(/prod) 目录及子菜单由种子自动清理,页面组件与权限标识保持不变 - 消息中心跳转路径、首页快捷入口路径同步更新 2. 职工管理独立为一级菜单(原挂在「基础数据」目录下),并清理历史子菜单 3. 修复侧边栏菜单展开卡顿(基础数据等子项较多的目录尤其明显) - 去掉 Element Plus 的 height 过渡动画(会逐帧重排全部子项) - 收起时改用 height:0 + visibility:hidden 而非 display:none,子项提前完成布局 - 菜单区独立滚动并预留滚动条宽度(scrollbar-gutter),消除展开时的横向抖动 - 菜单项增加 contain 布局隔离,淡入动画改为容器级 4. 修复页面首次打开重复请求 - 分页组件挂载时会触发一次 current-change,页码未变化时不再重复加载(18 个页面) - 职工管理去掉 onMounted 与默认选中部门的重复加载 - 工种管理、原料庄口的注册表下拉由按 key 多次请求改为一次全量拉取 5. 后端增加前端静态托管与 SPA 路由回退,支持 IIS 单站点部署(前后端同源) 6. 新增部署脚本 deploy-iis.ps1(首次部署)与 update-iis.ps1(更新发布)
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
# ============================================================
|
||||
# 一键更新 IIS 上的「智慧缫丝系统」(f9-web-ai-test)
|
||||
# 改动代码后运行:停站点 → 重新发布后端 → 同步前端产物 → 启站点 → 自检
|
||||
# 前置:先执行过 deploy-iis.ps1;前端已用 npm run build 构建
|
||||
# 必须以【管理员身份】运行(停/启 IIS 站点、替换被占用的程序文件)
|
||||
# ============================================================
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$root = 'C:\Users\32453\CodeBuddy\20260825142915'
|
||||
$webDir = Join-Path $root 'web'
|
||||
$distDir = Join-Path $webDir 'dist'
|
||||
$apiProject = Join-Path $root 'backend\F9WebAiTest.Api'
|
||||
$publishDir = Join-Path $root 'publish'
|
||||
$appPoolName = 'F9WebAiTest'
|
||||
$siteName = 'F9WebAiTest'
|
||||
|
||||
$logDir = Join-Path $root '_runlog'
|
||||
New-Item -ItemType Directory -Force -Path $logDir | Out-Null
|
||||
try { Start-Transcript -Path (Join-Path $logDir 'update-iis.log') -Force -ErrorAction Stop | Out-Null } catch { }
|
||||
|
||||
function Info($m) { Write-Host "[更新] $m" -ForegroundColor Cyan }
|
||||
function Warn($m) { Write-Host "[警告] $m" -ForegroundColor Yellow }
|
||||
|
||||
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||
throw '请以管理员身份运行本脚本'
|
||||
}
|
||||
if (-not (Test-Path $distDir)) { throw "前端产物不存在:$distDir(请先在 web 目录执行 npm run build)" }
|
||||
|
||||
# 必须先加载 WebAdministration,IIS: 驱动器才存在(否则站点判断会误报不存在)
|
||||
Import-Module WebAdministration
|
||||
if (-not (Get-Website -Name $siteName -ErrorAction SilentlyContinue)) { throw "IIS 站点 $siteName 不存在,请先运行 deploy-iis.ps1" }
|
||||
|
||||
# ---------- 1. 停站点与应用池(释放 dll 与数据库文件占用)----------
|
||||
if ((Get-Website -Name $siteName).State -ne 'Stopped') { Stop-Website -Name $siteName }
|
||||
if ((Get-WebAppPoolState -Name $appPoolName).Value -ne 'Stopped') { Stop-WebAppPool -Name $appPoolName }
|
||||
Start-Sleep -Seconds 3
|
||||
Info '站点已停止,文件已释放'
|
||||
|
||||
# ---------- 2. 发布后端(Release)----------
|
||||
Info '发布后端(Release)...'
|
||||
& 'C:\Program Files\dotnet\dotnet.exe' publish $apiProject -c Release -o $publishDir 2>&1 |
|
||||
Where-Object { $_ -match 'error|已成功|-> ' } | Select-Object -Last 5
|
||||
if ($LASTEXITCODE -ne 0) { throw "dotnet publish 失败(退出码 $LASTEXITCODE)" }
|
||||
|
||||
# ---------- 3. 同步前端产物到 wwwroot ----------
|
||||
$wwwroot = Join-Path $publishDir 'wwwroot'
|
||||
if (Test-Path $wwwroot) { Remove-Item $wwwroot -Recurse -Force }
|
||||
New-Item -ItemType Directory -Force -Path $wwwroot | Out-Null
|
||||
Copy-Item (Join-Path $distDir '*') $wwwroot -Recurse -Force
|
||||
Info "前端产物已同步:$wwwroot"
|
||||
|
||||
# ---------- 4. 目录权限兜底 ----------
|
||||
& icacls $publishDir /grant "IIS AppPool\${appPoolName}:(OI)(CI)M" /T /Q | Out-Null
|
||||
|
||||
# ---------- 5. 启动站点 ----------
|
||||
Start-WebAppPool -Name $appPoolName
|
||||
Start-Website -Name $siteName
|
||||
Start-Sleep -Seconds 5
|
||||
Info '站点已启动'
|
||||
|
||||
# ---------- 6. 自检 ----------
|
||||
$url = 'http://localhost/'
|
||||
try {
|
||||
$r = Invoke-WebRequest -Uri $url -UseBasicParsing -TimeoutSec 40
|
||||
Info "首页:HTTP $($r.StatusCode)"
|
||||
} catch {
|
||||
Warn "首页访问失败:$($_.Exception.Message)"
|
||||
}
|
||||
try {
|
||||
$login = Invoke-RestMethod -Uri "${url}api/auth/login" -Method Post -ContentType 'application/json' `
|
||||
-Body '{"userName":"admin","password":"123456"}' -TimeoutSec 40
|
||||
Info "登录接口:code=$($login.code) $($login.message)"
|
||||
} catch {
|
||||
Warn "登录接口调用失败:$($_.Exception.Message)"
|
||||
}
|
||||
|
||||
Write-Host ''
|
||||
Info "更新完成,访问地址:$url"
|
||||
Reference in New Issue
Block a user