2026-10-20 10:04:17 +08:00
param ( [ ValidateSet ( 'Backend' , 'Frontend' , 'Both' ) ] [ string ] $Component = 'Both' , [ switch ] $RealDataReplay , [ switch ] $HistoryEntry , [ string ] $HistorySource = '' , [ switch ] $Restart )
2026-10-12 16:41:42 +08:00
$ErrorActionPreference = 'Stop'
$taskRoot = ( Resolve-Path ( Join-Path $PSScriptRoot '../..' ) ) . Path
2026-10-20 10:04:17 +08:00
$taskIdentity = [ Security.Principal.WindowsIdentity ] :: GetCurrent ( )
$taskPrincipal = New-Object Security . Principal . WindowsPrincipal ( $taskIdentity )
if ( $taskPrincipal . IsInRole ( [ Security.Principal.WindowsBuiltInRole ] :: Administrator ) ) { throw 'Run local development from a normal PowerShell window, not Administrator mode.' }
2026-10-12 16:41:42 +08:00
$taskTemp = Join-Path $taskRoot '.codex-tmp'
New-Item -ItemType Directory -Path $taskTemp -Force | Out-Null
if ( $Component -in @ ( 'Backend' , 'Both' ) ) {
2026-10-20 10:04:17 +08:00
& ( Join-Path $PSScriptRoot 'Backend-Local.ps1' ) -Action $ ( if ( $Restart ) { 'Restart' } else { 'Start' } ) -RealDataReplay: $RealDataReplay -HistoryEntry: $HistoryEntry -HistorySource $HistorySource
2026-10-12 16:41:42 +08:00
}
if ( $Component -in @ ( 'Frontend' , 'Both' ) ) {
if ( ! ( Get-NetTCPConnection -State Listen -LocalPort 8088 -ErrorAction SilentlyContinue ) ) {
2026-10-15 11:30:55 +08:00
$env:NODE_OPTIONS = '--max-old-space-size=2048'
2026-10-13 09:41:46 +08:00
Start-Process -FilePath 'C:/Program Files/nodejs/node.exe' -ArgumentList @ ( 'node_modules/vite/bin/vite.js' , '--host' , '0.0.0.0' , '--port' , '8088' ) -WorkingDirectory ( Join-Path $taskRoot 'ruoyi-ui-vue3' ) -WindowStyle Hidden -RedirectStandardOutput ( Join-Path $taskTemp 'frontend.out.log' ) -RedirectStandardError ( Join-Path $taskTemp 'frontend.err.log' ) | Out-Null
2026-10-12 16:41:42 +08:00
}
2026-10-13 09:41:46 +08:00
Write-Output 'Frontend Vue3: http://localhost:8088 (ruoyi-ui-vue3)'
2026-10-12 16:41:42 +08:00
}