完善三平台安装包与服务控制流程

统一服务默认端口为 59188,完善 Windows 服务权限与 macOS LaunchAgent 管理。

实现 Windows 与 macOS 托盘状态机、服务启停等待、单实例保护、日志目录入口和退出前清理后台服务。

统一 Linux、Windows、macOS 与 Docker 的 Playwright Chromium runtime 构建流程,增加缓存、架构校验和 Linux 原生 runner,避免 QEMU。

完善 Windows、macOS、Linux 安装包及签名打包脚本,修正 Chromium 嵌入、服务注册和安装卸载流程。

同步 README、AGENTS、官网首页、Wiki 与前端开发文档,统一端口、初始化、服务、日志、托盘和安装说明。
This commit is contained in:
Christ committed 2026-08-12 20:53:53 +08:00
1 parent 94f4e070f6
commit 2df324647a
35 files changed
+1546 -214

No files matched your search

+27 -6
View File
@@ -25,18 +25,39 @@ Source: "..\..\dist\windows\xianyu-server.exe"; DestDir: "{app}"; Flags: ignorev
Source: "..\..\dist\windows\xianyu-tray.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\icon\windows\icon.ico"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\dist\windows\playwright-runtime\*"; DestDir: "{app}\playwright-runtime"; Flags: recursesubdirs createallsubdirs ignoreversion
Source: "service-control.ps1"; Flags: dontcopy
Source: "service-control.ps1"; DestDir: "{app}"; Flags: ignoreversion
[Dirs]
Name: "{#AppDataDir}"
Name: "{#AppDataDir}\data"
Name: "{#AppDataDir}\logs"; Permissions: users-modify
[Registry]
Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "YdisksXianyuHelperTray"; ValueData: "{app}\xianyu-tray.exe"; Flags: uninsdeletevalue
Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "YdisksXianyuHelperTray"; ValueData: """{app}\xianyu-tray.exe"""; Flags: uninsdeletevalue
[Run]
Filename: "{sys}\sc.exe"; Parameters: "create YdisksXianyuHelper binPath= ""{app}\xianyu-server.exe"" -service -workdir {#AppDataDir} -data-key-file {#AppDataDir}\data-key -addr 127.0.0.1:8080 -playwright-runtime-root ""{app}\playwright-runtime"" start= delayed-auto"; Flags: runhidden waituntilterminated
Filename: "{sys}\sc.exe"; Parameters: "start YdisksXianyuHelper"; Flags: runhidden waituntilterminated
Filename: "{app}\xianyu-tray.exe"; Description: "启动菜单栏控制器"; Flags: nowait postinstall skipifsilent
Filename: "{sys}\WindowsPowerShell\v1.0\powershell.exe"; Parameters: "-NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File ""{app}\service-control.ps1"" -Mode install -ExePath ""{app}\xianyu-server.exe"" -TrayPath ""{app}\xianyu-tray.exe"" -WorkDir ""{#AppDataDir}"" -RuntimeRoot ""{app}\playwright-runtime"""; Flags: runhidden waituntilterminated
Filename: "{app}\xianyu-tray.exe"; Description: "启动菜单栏控制器"; Flags: nowait postinstall skipifsilent runasoriginaluser
[UninstallRun]
Filename: "{sys}\sc.exe"; Parameters: "stop YdisksXianyuHelper"; Flags: runhidden waituntilterminated
Filename: "{sys}\sc.exe"; Parameters: "delete YdisksXianyuHelper"; Flags: runhidden waituntilterminated
Filename: "{sys}\WindowsPowerShell\v1.0\powershell.exe"; Parameters: "-NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File ""{app}\service-control.ps1"" -Mode uninstall -TrayPath ""{app}\xianyu-tray.exe"""; Flags: runhidden waituntilterminated
[Code]
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
ResultCode: Integer;
begin
Result := '';
ExtractTemporaryFile('service-control.ps1');
if not Exec(
ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'),
'-NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "' +
ExpandConstant('{tmp}\service-control.ps1') + '" -Mode stop -TrayPath "' +
ExpandConstant('{app}\xianyu-tray.exe') + '"',
'', SW_HIDE, ewWaitUntilTerminated, ResultCode)
then
Result := '无法执行旧服务停止脚本。'
else if ResultCode <> 0 then
Result := '旧版后台服务停止失败,错误码:' + IntToStr(ResultCode) + '。';
end;
+134
View File
@@ -0,0 +1,134 @@
param(
[Parameter(Mandatory = $true)]
[ValidateSet('stop', 'install', 'uninstall')]
[string]$Mode,
[string]$ServiceName = 'YdisksXianyuHelper',
[string]$ExePath = '',
[string]$TrayPath = '',
[string]$WorkDir = '',
[string]$RuntimeRoot = ''
)
$ErrorActionPreference = 'Stop'
function Get-InstalledService {
Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
}
function Stop-InstalledService {
$service = Get-InstalledService
if ($null -eq $service) {
return
}
if ($service.Status -ne [System.ServiceProcess.ServiceControllerStatus]::Stopped) {
Stop-Service -Name $ServiceName -ErrorAction Stop
$service.WaitForStatus(
[System.ServiceProcess.ServiceControllerStatus]::Stopped,
[TimeSpan]::FromSeconds(30)
)
}
}
function Stop-InstalledTray {
if ([string]::IsNullOrWhiteSpace($TrayPath)) {
return
}
$normalizedTrayPath = [IO.Path]::GetFullPath($TrayPath)
Get-Process -Name 'xianyu-tray' -ErrorAction SilentlyContinue | ForEach-Object {
$processPath = $null
try {
$processPath = $_.Path
} catch {
$processPath = $null
}
if (-not [string]::IsNullOrWhiteSpace($processPath) -and
[StringComparer]::OrdinalIgnoreCase.Equals(
[IO.Path]::GetFullPath($processPath),
$normalizedTrayPath
)) {
Stop-Process -Id $_.Id -Force -ErrorAction Stop
if (-not $_.WaitForExit(10000)) {
throw "等待旧托盘进程退出超时: $($_.Id)"
}
}
}
}
function Stop-InstalledComponents {
Stop-InstalledTray
Stop-InstalledService
}
function Invoke-ScChecked {
param([Parameter(ValueFromRemainingArguments = $true)][string[]]$Arguments)
$output = & "$env:SystemRoot\System32\sc.exe" @Arguments 2>&1
if ($LASTEXITCODE -ne 0) {
throw "sc.exe $($Arguments -join ' ') 失败 ($LASTEXITCODE): $($output -join ' ')"
}
}
function Grant-InteractiveUserServiceControl {
# IU(INTERACTIVE)只包含当前交互式登录会话。授予的 LCRPWP 分别是
# 查询状态、启动和停止;不包含修改配置、修改 ACL 或删除服务。
$controlAce = '(A;;LCRPWP;;;IU)'
$output = & "$env:SystemRoot\System32\sc.exe" sdshow $ServiceName 2>&1
if ($LASTEXITCODE -ne 0) {
throw "读取服务安全描述符失败 ($LASTEXITCODE): $($output -join ' ')"
}
$sddl = $output |
ForEach-Object { $_.ToString().Trim() } |
Where-Object { $_ -like 'D:*' } |
Select-Object -First 1
if ([string]::IsNullOrWhiteSpace($sddl)) {
throw '服务安全描述符中没有找到 DACL'
}
if ($sddl.Contains($controlAce)) {
return
}
$saclIndex = $sddl.IndexOf('S:')
if ($saclIndex -ge 0) {
$updatedSddl = $sddl.Insert($saclIndex, $controlAce)
} else {
$updatedSddl = $sddl + $controlAce
}
Invoke-ScChecked sdset $ServiceName $updatedSddl
}
switch ($Mode) {
'stop' {
Stop-InstalledComponents
}
'install' {
if ([string]::IsNullOrWhiteSpace($ExePath) -or
[string]::IsNullOrWhiteSpace($WorkDir) -or
[string]::IsNullOrWhiteSpace($RuntimeRoot)) {
throw '安装服务缺少 ExePath、WorkDir 或 RuntimeRoot'
}
Stop-InstalledComponents
$binaryPath = '"{0}" -service -workdir "{1}" -data-key-file "{1}\data-key" -addr 127.0.0.1:59188 -playwright-runtime-root "{2}"' -f `
$ExePath, $WorkDir, $RuntimeRoot
if ($null -eq (Get-InstalledService)) {
Invoke-ScChecked create $ServiceName 'binPath=' $binaryPath 'start=' 'delayed-auto'
} else {
Invoke-ScChecked config $ServiceName 'binPath=' $binaryPath 'start=' 'delayed-auto'
}
Invoke-ScChecked description $ServiceName 'Ydisks闲鱼助手后台服务'
Grant-InteractiveUserServiceControl
Start-Service -Name $ServiceName -ErrorAction Stop
(Get-Service -Name $ServiceName).WaitForStatus(
[System.ServiceProcess.ServiceControllerStatus]::Running,
[TimeSpan]::FromSeconds(30)
)
}
'uninstall' {
Stop-InstalledComponents
if ($null -ne (Get-InstalledService)) {
Invoke-ScChecked delete $ServiceName
}
}
}