Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1185551018 | ||
|
|
b831f2d7c8 | ||
|
|
2d8b319f53 | ||
|
|
8215cc0e95 | ||
|
|
3f77cdba3d | ||
|
|
782bea1115 | ||
|
|
1833020caf | ||
|
|
36798dcced | ||
|
|
1a9be54355 | ||
|
|
17deffcfb5 | ||
|
|
e3a9404d0d | ||
|
|
59b1061ec5 | ||
|
|
ca00c159f0 | ||
|
|
96aa8f1ced | ||
|
|
1c8e2ab163 | ||
|
|
ac85ac8a0a | ||
|
|
65bcb8f15c | ||
|
|
7ec0b4a078 | ||
|
|
d36c357bab | ||
|
|
70e03a8523 |
No files matched your search
@@ -4,8 +4,14 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- codex/desktop-packaging
|
||||
- dev
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
inputs:
|
||||
app_version:
|
||||
description: 正式发布版本号(不含 v)
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -14,14 +20,43 @@ concurrency:
|
||||
group: desktop-cd-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
APP_VERSION: 0.0.0-${{ github.run_number }}
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
name: 准备发布版本
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
app_version: ${{ steps.version.outputs.app_version }}
|
||||
build_version: ${{ steps.version.outputs.build_version }}
|
||||
build_time: ${{ steps.version.outputs.build_time }}
|
||||
steps:
|
||||
- name: 解析并校验版本号
|
||||
id: version
|
||||
shell: bash
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
if [ -n "${{ inputs.app_version }}" ]; then
|
||||
app_version="${{ inputs.app_version }}"
|
||||
build_version="$app_version"
|
||||
else
|
||||
app_version="0.0.${GITHUB_RUN_NUMBER}"
|
||||
build_version="${GITHUB_REF_NAME}-${GITHUB_SHA::12}"
|
||||
fi
|
||||
if [[ ! "$app_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "安装包版本必须符合 1.2.3 格式:$app_version" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "app_version=$app_version" >> "$GITHUB_OUTPUT"
|
||||
echo "build_version=$build_version" >> "$GITHUB_OUTPUT"
|
||||
echo "build_time=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
linux:
|
||||
name: Linux 安装包 (${{ matrix.arch }})
|
||||
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/codex/desktop-packaging'
|
||||
needs: prepare
|
||||
runs-on: ${{ matrix.runner }}
|
||||
env:
|
||||
APP_VERSION: ${{ needs.prepare.outputs.app_version }}
|
||||
BUILD_VERSION: ${{ needs.prepare.outputs.build_version }}
|
||||
BUILD_TIME: ${{ needs.prepare.outputs.build_time }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -45,7 +80,7 @@ jobs:
|
||||
- name: 配置 Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 22
|
||||
node-version: 24
|
||||
cache: npm
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
@@ -60,15 +95,16 @@ jobs:
|
||||
run: |
|
||||
package_dir="dist/ydisks-xianyu-helper-linux-${GOARCH}"
|
||||
mkdir -p "$package_dir"
|
||||
go build -trimpath -ldflags='-s -w' -o "$package_dir/xianyu-server" ./cmd/server
|
||||
version_ldflags="-s -w -X xianyu-go/internal/version.Version=$BUILD_VERSION -X xianyu-go/internal/version.Commit=$GITHUB_SHA -X xianyu-go/internal/version.BuildTime=$BUILD_TIME"
|
||||
go build -trimpath -ldflags="$version_ldflags" -o "$package_dir/xianyu-server" ./cmd/server
|
||||
go build -trimpath -ldflags='-s -w' -o "$package_dir/browser-install" ./cmd/browser-install
|
||||
|
||||
- name: 缓存 Linux Chromium runtime
|
||||
- name: 恢复 Linux Chromium runtime 缓存
|
||||
id: cache-linux-playwright
|
||||
uses: actions/cache@v5
|
||||
uses: actions/cache/restore@v5
|
||||
with:
|
||||
path: dist/ydisks-xianyu-helper-linux-${{ matrix.arch }}/playwright-runtime
|
||||
key: ydisks-playwright-runtime-v6-linux-${{ matrix.arch }}-${{ hashFiles('go.mod', 'go.sum') }}
|
||||
key: ydisks-playwright-runtime-v6-linux-${{ matrix.arch }}-${{ matrix.playwright_platform }}-${{ hashFiles('go.mod', 'go.sum', 'cmd/browser-install/**') }}
|
||||
|
||||
- name: 在原生架构 runner 预下载 Linux Chromium runtime
|
||||
if: steps.cache-linux-playwright.outputs.cache-hit != 'true'
|
||||
@@ -111,8 +147,8 @@ jobs:
|
||||
chromium_path="$(find "$runtime_dir/playwright-browsers" -type f \
|
||||
\( -name chrome -o -name headless_shell -o -name chrome-headless-shell \) -perm -111 -print -quit)"
|
||||
test -n "$chromium_path"
|
||||
chromium_revision="$(RUNTIME_SPEC="$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium").revision)')"
|
||||
headless_revision="$(RUNTIME_SPEC="$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium-headless-shell").revision)')"
|
||||
chromium_revision="$(RUNTIME_SPEC="$PWD/$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium").revision)')"
|
||||
headless_revision="$(RUNTIME_SPEC="$PWD/$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium-headless-shell").revision)')"
|
||||
test -d "$runtime_dir/playwright-browsers/chromium-$chromium_revision"
|
||||
test -d "$runtime_dir/playwright-browsers/chromium_headless_shell-$headless_revision"
|
||||
chromium_type="$(file -b "$chromium_path")"
|
||||
@@ -122,6 +158,13 @@ jobs:
|
||||
*) echo "Chromium 架构错误:$chromium_type" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
- name: 保存 Linux Chromium runtime 缓存
|
||||
if: steps.cache-linux-playwright.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v5
|
||||
with:
|
||||
path: dist/ydisks-xianyu-helper-linux-${{ matrix.arch }}/playwright-runtime
|
||||
key: ${{ steps.cache-linux-playwright.outputs.cache-primary-key }}
|
||||
|
||||
- name: 组装 Linux 安装目录
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
@@ -140,8 +183,12 @@ jobs:
|
||||
|
||||
windows:
|
||||
name: Windows 安装包
|
||||
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/codex/desktop-packaging'
|
||||
needs: prepare
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
APP_VERSION: ${{ needs.prepare.outputs.app_version }}
|
||||
BUILD_VERSION: ${{ needs.prepare.outputs.build_version }}
|
||||
BUILD_TIME: ${{ needs.prepare.outputs.build_time }}
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v6
|
||||
@@ -155,7 +202,7 @@ jobs:
|
||||
- name: 配置 Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 22
|
||||
node-version: 24
|
||||
cache: npm
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
@@ -167,32 +214,42 @@ jobs:
|
||||
shell: pwsh
|
||||
run: |
|
||||
go test ./cmd/tray
|
||||
$serviceScript = (Resolve-Path 'packaging/windows/service-control.ps1').Path
|
||||
$tokens = $null
|
||||
$parseErrors = $null
|
||||
[void][System.Management.Automation.Language.Parser]::ParseFile(
|
||||
(Resolve-Path 'packaging/windows/service-control.ps1'),
|
||||
$serviceScript,
|
||||
[ref]$tokens,
|
||||
[ref]$parseErrors
|
||||
)
|
||||
if ($parseErrors.Count -gt 0) {
|
||||
$parseErrors | ForEach-Object { Write-Error $_.Message }
|
||||
throw 'Windows 服务安装脚本语法检查失败'
|
||||
throw 'Windows 服务安装脚本在 PowerShell 7 下语法检查失败'
|
||||
}
|
||||
|
||||
& "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" `
|
||||
-NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass `
|
||||
-File $serviceScript -Mode stop -ServiceName "YdisksSyntaxCheck-$PID"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Windows 服务安装脚本在 Windows PowerShell 5.1 下检查失败,错误码: $LASTEXITCODE"
|
||||
}
|
||||
|
||||
- name: 编译 Windows 桌面程序
|
||||
shell: pwsh
|
||||
run: |
|
||||
& packaging/windows/build-resources.ps1
|
||||
New-Item -ItemType Directory -Force -Path dist/windows | Out-Null
|
||||
go build -trimpath -ldflags "-s -w" -o dist/windows/xianyu-server.exe ./cmd/server
|
||||
$versionLdflags = "-s -w -X xianyu-go/internal/version.Version=$env:BUILD_VERSION -X xianyu-go/internal/version.Commit=$env:GITHUB_SHA -X xianyu-go/internal/version.BuildTime=$env:BUILD_TIME"
|
||||
go build -trimpath -ldflags $versionLdflags -o dist/windows/xianyu-server.exe ./cmd/server
|
||||
go build -trimpath -ldflags "-s -w" -o dist/windows/browser-install.exe ./cmd/browser-install
|
||||
go build -trimpath -ldflags "-s -w -H=windowsgui" -o dist/windows/xianyu-tray.exe ./cmd/tray
|
||||
|
||||
- name: 缓存 Windows Chromium runtime
|
||||
- name: 恢复 Windows Chromium runtime 缓存
|
||||
id: cache-windows-playwright
|
||||
uses: actions/cache@v5
|
||||
uses: actions/cache/restore@v5
|
||||
with:
|
||||
path: dist/windows/playwright-runtime/amd64
|
||||
key: ydisks-playwright-runtime-v6-windows-amd64-${{ hashFiles('go.mod', 'go.sum') }}
|
||||
key: ydisks-playwright-runtime-v6-windows-amd64-${{ hashFiles('go.mod', 'go.sum', 'cmd/browser-install/**') }}
|
||||
|
||||
- name: 预下载 Windows Chromium runtime
|
||||
if: steps.cache-windows-playwright.outputs.cache-hit != 'true'
|
||||
@@ -223,6 +280,98 @@ jobs:
|
||||
Select-Object -First 1
|
||||
if ($null -eq $chromium) { throw 'Windows Chromium runtime 缺少 Chromium 可执行文件' }
|
||||
|
||||
- name: 实际验证 Windows 服务注册
|
||||
shell: pwsh
|
||||
run: |
|
||||
$serviceName = 'YdisksXianyuHelper'
|
||||
$workDir = Join-Path $env:RUNNER_TEMP $serviceName
|
||||
$runtimeRoot = (Resolve-Path 'dist/windows/playwright-runtime/amd64').Path
|
||||
$serviceScript = (Resolve-Path 'packaging/windows/service-control.ps1').Path
|
||||
$serverPath = (Resolve-Path 'dist/windows/xianyu-server.exe').Path
|
||||
try {
|
||||
foreach ($registerAttempt in 1..2) {
|
||||
& "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" `
|
||||
-NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass `
|
||||
-File $serviceScript -Mode register -ServiceName $serviceName `
|
||||
-ExePath $serverPath -WorkDir $workDir -RuntimeRoot $runtimeRoot
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Windows 服务第 $registerAttempt 次注册失败,错误码: $LASTEXITCODE"
|
||||
}
|
||||
}
|
||||
& "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" `
|
||||
-NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass `
|
||||
-File $serviceScript -Mode start -ServiceName $serviceName
|
||||
if ($LASTEXITCODE -ne 0) { throw "Windows 服务启动失败,错误码: $LASTEXITCODE" }
|
||||
|
||||
$service = Get-Service -Name $serviceName -ErrorAction Stop
|
||||
$serviceStatus = $service.Status
|
||||
$service.Dispose()
|
||||
if ($serviceStatus -ne [System.ServiceProcess.ServiceControllerStatus]::Running) {
|
||||
throw "Windows 服务未进入运行状态: $serviceStatus"
|
||||
}
|
||||
|
||||
$serviceConfig = Get-CimInstance -ClassName Win32_Service -Filter "Name='$serviceName'" -ErrorAction Stop
|
||||
if ($null -eq $serviceConfig) { throw 'Windows 服务注册后无法读取配置' }
|
||||
# Win32_Service.PathName 可能会省略不含空格路径两侧的引号,比较前统一去掉引号。
|
||||
$actualServiceCommand = $serviceConfig.PathName.Replace('"', '')
|
||||
$requiredServiceArguments = @(
|
||||
$serverPath,
|
||||
'-service',
|
||||
"-workdir $workDir",
|
||||
"-playwright-runtime-root $runtimeRoot"
|
||||
)
|
||||
$invalidServiceArgument = $requiredServiceArguments |
|
||||
Where-Object {
|
||||
$actualServiceCommand.IndexOf($_, [StringComparison]::OrdinalIgnoreCase) -lt 0
|
||||
} |
|
||||
Select-Object -First 1
|
||||
if ($null -ne $invalidServiceArgument) {
|
||||
throw "Windows 服务命令行不正确: $($serviceConfig.PathName)"
|
||||
}
|
||||
$delayedStart = Get-ItemPropertyValue `
|
||||
-LiteralPath "Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\$serviceName" `
|
||||
-Name DelayedAutostart -ErrorAction Stop
|
||||
if ($delayedStart -ne 1) { throw "Windows 服务未配置延迟自动启动: $delayedStart" }
|
||||
$sddl = (& "$env:SystemRoot\System32\sc.exe" sdshow $serviceName 2>&1) -join ''
|
||||
if ($LASTEXITCODE -ne 0 -or -not $sddl.Contains('(A;;LCRPWP;;;IU)')) {
|
||||
throw "Windows 服务未授予交互用户启停权限: $sddl"
|
||||
}
|
||||
|
||||
$health = $null
|
||||
$deadline = [DateTime]::UtcNow.AddSeconds(60)
|
||||
while ([DateTime]::UtcNow -lt $deadline -and $null -eq $health) {
|
||||
try {
|
||||
$health = Invoke-RestMethod -Uri 'http://127.0.0.1:59188/health' -TimeoutSec 2
|
||||
} catch {
|
||||
Start-Sleep -Seconds 1
|
||||
}
|
||||
}
|
||||
if ($null -eq $health -or $health.status -ne 'ok' -or $health.database -ne 'ok') {
|
||||
throw "Windows 服务健康检查失败: $($health | ConvertTo-Json -Compress)"
|
||||
}
|
||||
} catch {
|
||||
$serverLog = Join-Path $workDir 'logs\server.log'
|
||||
if (Test-Path -LiteralPath $serverLog) {
|
||||
Get-Content -LiteralPath $serverLog -Tail 200
|
||||
}
|
||||
throw
|
||||
} finally {
|
||||
& "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" `
|
||||
-NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass `
|
||||
-File $serviceScript -Mode uninstall -ServiceName $serviceName
|
||||
if ($LASTEXITCODE -ne 0) { throw "Windows 服务清理失败,错误码: $LASTEXITCODE" }
|
||||
if ($null -ne (Get-Service -Name $serviceName -ErrorAction SilentlyContinue)) {
|
||||
throw 'Windows 服务卸载后仍然存在'
|
||||
}
|
||||
}
|
||||
|
||||
- name: 保存 Windows Chromium runtime 缓存
|
||||
if: steps.cache-windows-playwright.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v5
|
||||
with:
|
||||
path: dist/windows/playwright-runtime/amd64
|
||||
key: ${{ steps.cache-windows-playwright.outputs.cache-primary-key }}
|
||||
|
||||
- name: 导入 Windows 签名证书
|
||||
shell: pwsh
|
||||
env:
|
||||
@@ -254,11 +403,59 @@ jobs:
|
||||
env:
|
||||
APP_VERSION: ${{ env.APP_VERSION }}
|
||||
run: |
|
||||
& 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe' /Qp /O"dist\windows" packaging\windows\installer.iss
|
||||
$installer = Get-ChildItem -Path dist/windows -Filter 'Ydisks-Xianyu-Helper-Setup.exe' -Recurse | Select-Object -First 1
|
||||
if ($null -eq $installer) { throw 'Inno Setup 未生成安装器' }
|
||||
$target = Join-Path (Resolve-Path dist/windows) 'Ydisks-Xianyu-Helper-Setup.exe'
|
||||
if ($installer.FullName -ne $target) { Copy-Item $installer.FullName $target -Force }
|
||||
$shortDrive = 'R:'
|
||||
if (Test-Path -LiteralPath "$shortDrive\") {
|
||||
throw "短路径盘符已被占用: $shortDrive"
|
||||
}
|
||||
& "$env:SystemRoot\System32\subst.exe" $shortDrive $env:GITHUB_WORKSPACE
|
||||
if ($LASTEXITCODE -ne 0 -or -not (Test-Path -LiteralPath "$shortDrive\")) {
|
||||
throw "无法创建 Windows 安装器短路径盘符: $shortDrive"
|
||||
}
|
||||
$locationPushed = $false
|
||||
try {
|
||||
Push-Location "$shortDrive\"
|
||||
$locationPushed = $true
|
||||
$requiredSources = @(
|
||||
'dist/windows/xianyu-server.exe',
|
||||
'dist/windows/xianyu-tray.exe',
|
||||
'dist/windows/playwright-runtime/amd64',
|
||||
'icon/windows/icon.ico',
|
||||
'packaging/windows/languages/ChineseSimplified.isl',
|
||||
'packaging/windows/languages/ChineseTraditional.isl',
|
||||
'packaging/windows/service-control.ps1'
|
||||
)
|
||||
foreach ($source in $requiredSources) {
|
||||
if (-not (Test-Path -LiteralPath $source)) {
|
||||
throw "Windows 安装器源文件或目录不存在: $source"
|
||||
}
|
||||
}
|
||||
$runtimeFiles = Get-ChildItem -LiteralPath 'dist/windows/playwright-runtime/amd64' -Recurse -File
|
||||
if ($null -eq ($runtimeFiles | Select-Object -First 1)) {
|
||||
throw 'Windows 安装器 Playwright runtime 为空'
|
||||
}
|
||||
$longestRuntimeFile = $runtimeFiles |
|
||||
Sort-Object { $_.FullName.Length } -Descending |
|
||||
Select-Object -First 1
|
||||
Write-Host "Windows runtime 最长源路径长度: $($longestRuntimeFile.FullName.Length)"
|
||||
Write-Host "Windows runtime 最长源路径: $($longestRuntimeFile.FullName)"
|
||||
|
||||
$compiler = 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe'
|
||||
$scriptPath = (Resolve-Path 'packaging/windows/installer.iss').Path
|
||||
$outputDir = (Resolve-Path 'dist/windows').Path
|
||||
& $compiler /Qp "/O$outputDir" $scriptPath
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Inno Setup 编译失败,错误码: $LASTEXITCODE"
|
||||
}
|
||||
$installer = Get-ChildItem -Path dist/windows -Filter 'Ydisks-Xianyu-Helper-Setup.exe' -Recurse | Select-Object -First 1
|
||||
if ($null -eq $installer) { throw 'Inno Setup 未生成安装器' }
|
||||
$target = Join-Path (Resolve-Path dist/windows) 'Ydisks-Xianyu-Helper-Setup.exe'
|
||||
if ($installer.FullName -ne $target) { Copy-Item $installer.FullName $target -Force }
|
||||
} finally {
|
||||
if ($locationPushed) {
|
||||
Pop-Location
|
||||
}
|
||||
& "$env:SystemRoot\System32\subst.exe" $shortDrive /D | Out-Null
|
||||
}
|
||||
|
||||
- name: 签名 Windows 安装器
|
||||
shell: pwsh
|
||||
@@ -270,26 +467,140 @@ jobs:
|
||||
-PfxPath $env:WINDOWS_SIGNING_PFX_PATH `
|
||||
-Files 'dist/windows/Ydisks-Xianyu-Helper-Setup.exe'
|
||||
|
||||
- name: 打包 Windows 二进制归档
|
||||
- name: 使用安装器验证服务安装与卸载
|
||||
shell: pwsh
|
||||
env:
|
||||
APP_VERSION: ${{ env.APP_VERSION }}
|
||||
run: |
|
||||
Compress-Archive -Path dist/windows/xianyu-server.exe,dist/windows/xianyu-tray.exe,dist/windows/playwright-runtime -DestinationPath "dist/windows/Ydisks-Xianyu-Helper-${env:APP_VERSION}-binaries.zip"
|
||||
$serviceName = 'YdisksXianyuHelper'
|
||||
$installer = (Resolve-Path 'dist/windows/Ydisks-Xianyu-Helper-Setup.exe').Path
|
||||
$installLog = Join-Path $env:RUNNER_TEMP 'ydisks-windows-installer.log'
|
||||
$installDir = Join-Path $env:ProgramFiles 'Ydisks Xianyu Helper'
|
||||
$uninstaller = Join-Path $installDir 'unins000.exe'
|
||||
try {
|
||||
$installerProcess = Start-Process -FilePath $installer `
|
||||
-ArgumentList @('/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART', "/LOG=$installLog") `
|
||||
-Wait -PassThru
|
||||
$installerExitCode = $installerProcess.ExitCode
|
||||
if ($installerExitCode -ne 0) {
|
||||
if (Test-Path -LiteralPath $installLog) {
|
||||
Get-Content -LiteralPath $installLog -Tail 200
|
||||
}
|
||||
throw "Windows 安装器执行失败,错误码: $installerExitCode"
|
||||
}
|
||||
|
||||
$service = Get-Service -Name $serviceName -ErrorAction Stop
|
||||
$serviceStatus = $service.Status
|
||||
$service.Dispose()
|
||||
if ($serviceStatus -ne [System.ServiceProcess.ServiceControllerStatus]::Running) {
|
||||
throw "安装器未启动 Windows 服务: $serviceStatus"
|
||||
}
|
||||
|
||||
$expectedServer = Join-Path $installDir 'xianyu-server.exe'
|
||||
$expectedRuntime = Join-Path $installDir 'playwright-runtime'
|
||||
$serviceConfig = Get-CimInstance -ClassName Win32_Service -Filter "Name='$serviceName'" -ErrorAction Stop
|
||||
$actualServiceCommand = if ($null -eq $serviceConfig) { '' } else { $serviceConfig.PathName.Replace('"', '') }
|
||||
$requiredServiceArguments = @(
|
||||
$expectedServer,
|
||||
'-service',
|
||||
"-playwright-runtime-root $expectedRuntime"
|
||||
)
|
||||
$invalidServiceArgument = $requiredServiceArguments |
|
||||
Where-Object {
|
||||
$actualServiceCommand.IndexOf($_, [StringComparison]::OrdinalIgnoreCase) -lt 0
|
||||
} |
|
||||
Select-Object -First 1
|
||||
if ($null -ne $invalidServiceArgument) {
|
||||
throw "安装器注册的服务命令行不正确: $($serviceConfig.PathName)"
|
||||
}
|
||||
|
||||
$health = $null
|
||||
$deadline = [DateTime]::UtcNow.AddSeconds(60)
|
||||
while ([DateTime]::UtcNow -lt $deadline -and $null -eq $health) {
|
||||
try {
|
||||
$health = Invoke-RestMethod -Uri 'http://127.0.0.1:59188/health' -TimeoutSec 2
|
||||
} catch {
|
||||
Start-Sleep -Seconds 1
|
||||
}
|
||||
}
|
||||
if ($null -eq $health -or $health.status -ne 'ok' -or $health.database -ne 'ok') {
|
||||
throw "安装器服务健康检查失败: $($health | ConvertTo-Json -Compress)"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $uninstaller -PathType Leaf)) {
|
||||
throw "Windows 卸载器不存在: $uninstaller"
|
||||
}
|
||||
$expectedTray = Join-Path $installDir 'xianyu-tray.exe'
|
||||
$startMenuRoots = @(
|
||||
(Join-Path $env:ProgramData 'Microsoft\Windows\Start Menu\Programs'),
|
||||
(Join-Path $env:APPDATA 'Microsoft\Windows\Start Menu\Programs')
|
||||
)
|
||||
$startMenuShortcut = $startMenuRoots |
|
||||
Where-Object { Test-Path -LiteralPath $_ -PathType Container } |
|
||||
ForEach-Object {
|
||||
Get-ChildItem -LiteralPath $_ -Filter '*.lnk' -Recurse -File -ErrorAction SilentlyContinue
|
||||
} |
|
||||
Where-Object {
|
||||
$shortcutShell = New-Object -ComObject WScript.Shell
|
||||
$shortcutTarget = $shortcutShell.CreateShortcut($_.FullName).TargetPath
|
||||
[StringComparer]::OrdinalIgnoreCase.Equals($shortcutTarget, $expectedTray)
|
||||
} |
|
||||
Select-Object -First 1
|
||||
if ($null -eq $startMenuShortcut) {
|
||||
throw '安装器未创建开始菜单快捷方式'
|
||||
}
|
||||
} catch {
|
||||
if (Test-Path -LiteralPath $installLog) {
|
||||
Get-Content -LiteralPath $installLog -Tail 200
|
||||
}
|
||||
$serverLog = Join-Path $env:ProgramData 'YdisksXianyuHelper\logs\server.log'
|
||||
if (Test-Path -LiteralPath $serverLog) {
|
||||
Get-Content -LiteralPath $serverLog -Tail 200
|
||||
}
|
||||
throw
|
||||
} finally {
|
||||
if (Test-Path -LiteralPath $uninstaller -PathType Leaf) {
|
||||
$uninstallerProcess = Start-Process -FilePath $uninstaller `
|
||||
-ArgumentList @('/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART') `
|
||||
-Wait -PassThru
|
||||
if ($uninstallerProcess.ExitCode -ne 0) {
|
||||
throw "Windows 卸载器执行失败,错误码: $($uninstallerProcess.ExitCode)"
|
||||
}
|
||||
} elseif ($null -ne (Get-CimInstance -ClassName Win32_Service -Filter "Name='$serviceName'" -ErrorAction SilentlyContinue)) {
|
||||
& "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" `
|
||||
-NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass `
|
||||
-File (Resolve-Path 'packaging/windows/service-control.ps1') `
|
||||
-Mode uninstall -ServiceName $serviceName
|
||||
if ($LASTEXITCODE -ne 0) { throw "Windows 服务兜底清理失败,错误码: $LASTEXITCODE" }
|
||||
}
|
||||
if ($null -ne (Get-CimInstance -ClassName Win32_Service -Filter "Name='$serviceName'" -ErrorAction SilentlyContinue)) {
|
||||
throw 'Windows 安装器卸载后服务仍然存在'
|
||||
}
|
||||
}
|
||||
|
||||
- name: 准备唯一 Windows 构建产物
|
||||
shell: pwsh
|
||||
run: |
|
||||
$artifactDir = 'dist/windows-artifact'
|
||||
New-Item -ItemType Directory -Force -Path $artifactDir | Out-Null
|
||||
Copy-Item -LiteralPath 'dist/windows/Ydisks-Xianyu-Helper-Setup.exe' -Destination $artifactDir
|
||||
$artifactFiles = @(Get-ChildItem -LiteralPath $artifactDir -Recurse -File)
|
||||
if ($artifactFiles.Count -ne 1 -or $artifactFiles[0].Name -ne 'Ydisks-Xianyu-Helper-Setup.exe') {
|
||||
throw "Windows 构建产物必须且只能包含安装器: $($artifactFiles.FullName -join ', ')"
|
||||
}
|
||||
|
||||
- name: 上传 Windows 安装包
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ydisks-xianyu-helper-windows-${{ env.APP_VERSION }}
|
||||
path: |
|
||||
dist/windows/Ydisks-Xianyu-Helper-Setup.exe
|
||||
dist/windows/Ydisks-Xianyu-Helper-${{ env.APP_VERSION }}-binaries.zip
|
||||
path: dist/windows-artifact/Ydisks-Xianyu-Helper-Setup.exe
|
||||
if-no-files-found: error
|
||||
|
||||
macos:
|
||||
name: macOS 安装包
|
||||
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/codex/desktop-packaging'
|
||||
needs: prepare
|
||||
runs-on: macos-14
|
||||
env:
|
||||
APP_VERSION: ${{ needs.prepare.outputs.app_version }}
|
||||
BUILD_VERSION: ${{ needs.prepare.outputs.build_version }}
|
||||
BUILD_TIME: ${{ needs.prepare.outputs.build_time }}
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v6
|
||||
@@ -303,7 +614,7 @@ jobs:
|
||||
- name: 配置 Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 22
|
||||
node-version: 24
|
||||
cache: npm
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
@@ -316,8 +627,9 @@ jobs:
|
||||
- name: 编译 macOS 桌面程序
|
||||
run: |
|
||||
mkdir -p dist/macos/arm64 dist/macos/amd64
|
||||
version_ldflags="-s -w -X xianyu-go/internal/version.Version=$BUILD_VERSION -X xianyu-go/internal/version.Commit=$GITHUB_SHA -X xianyu-go/internal/version.BuildTime=$BUILD_TIME"
|
||||
for arch in arm64 amd64; do
|
||||
GOOS=darwin GOARCH="$arch" CGO_ENABLED=1 go build -trimpath -ldflags='-s -w' -o "dist/macos/$arch/xianyu-server" ./cmd/server
|
||||
GOOS=darwin GOARCH="$arch" CGO_ENABLED=1 go build -trimpath -ldflags="$version_ldflags" -o "dist/macos/$arch/xianyu-server" ./cmd/server
|
||||
GOOS=darwin GOARCH="$arch" CGO_ENABLED=1 go build -trimpath -ldflags='-s -w' -o "dist/macos/$arch/browser-install" ./cmd/browser-install
|
||||
GOOS=darwin GOARCH="$arch" CGO_ENABLED=1 go build -trimpath -ldflags='-s -w' -o "dist/macos/$arch/xianyu-tray" ./cmd/tray
|
||||
done
|
||||
@@ -329,7 +641,7 @@ jobs:
|
||||
path: |
|
||||
dist/macos/playwright-runtime/arm64
|
||||
dist/macos/playwright-runtime/amd64
|
||||
key: ydisks-playwright-runtime-v6-macos-universal-${{ hashFiles('go.mod', 'go.sum') }}
|
||||
key: ydisks-playwright-runtime-v6-macos-mac14-universal-${{ hashFiles('go.mod', 'go.sum', 'cmd/browser-install/**') }}
|
||||
|
||||
- name: 预下载 macOS Chromium runtime
|
||||
if: steps.cache-macos-playwright.outputs.cache-hit != 'true'
|
||||
@@ -348,6 +660,34 @@ jobs:
|
||||
-driver-dir "$PWD/dist/macos/playwright-runtime/amd64/playwright-driver" \
|
||||
-browser-dir "$PWD/dist/macos/playwright-runtime/amd64/playwright-browsers"
|
||||
|
||||
- name: 校验 macOS Chromium runtime
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
for runtime_arch in arm64 amd64; do
|
||||
runtime_dir="dist/macos/playwright-runtime/$runtime_arch"
|
||||
node_path="$runtime_dir/playwright-driver/node"
|
||||
spec_path="$PWD/$runtime_dir/playwright-driver/package/browsers.json"
|
||||
test -x "$node_path"
|
||||
test -f "$runtime_dir/playwright-driver/package/cli.js"
|
||||
test -f "$spec_path"
|
||||
chromium_revision="$(RUNTIME_SPEC="$spec_path" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium").revision)')"
|
||||
headless_revision="$(RUNTIME_SPEC="$spec_path" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium-headless-shell").revision)')"
|
||||
test -d "$runtime_dir/playwright-browsers/chromium-$chromium_revision"
|
||||
test -d "$runtime_dir/playwright-browsers/chromium_headless_shell-$headless_revision"
|
||||
chromium_path="$(find "$runtime_dir/playwright-browsers/chromium-$chromium_revision" -type f -path '*/Contents/MacOS/Google Chrome for Testing' -print -quit)"
|
||||
headless_path="$(find "$runtime_dir/playwright-browsers/chromium_headless_shell-$headless_revision" -type f -name chrome-headless-shell -print -quit)"
|
||||
test -n "$chromium_path"
|
||||
test -n "$headless_path"
|
||||
node_type="$(file -b "$node_path")"
|
||||
chromium_type="$(file -b "$chromium_path")"
|
||||
headless_type="$(file -b "$headless_path")"
|
||||
case "$runtime_arch:$node_type:$chromium_type:$headless_type" in
|
||||
arm64:*arm64*:*arm64*:*arm64*) ;;
|
||||
amd64:*x86_64*:*x86_64*:*x86_64*) ;;
|
||||
*) echo "macOS Playwright runtime 架构错误:$runtime_arch / $node_type / $chromium_type / $headless_type" >&2; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
- name: 保存 macOS Chromium runtime 缓存
|
||||
if: steps.cache-macos-playwright.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v5
|
||||
|
||||
@@ -4,8 +4,14 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- codex/desktop-packaging
|
||||
- dev
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
inputs:
|
||||
app_version:
|
||||
description: 正式发布版本号(不含 v)
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -16,8 +22,62 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
verify:
|
||||
name: Docker 发布测试门禁
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
app_version: ${{ steps.version.outputs.app_version }}
|
||||
build_time: ${{ steps.version.outputs.build_time }}
|
||||
steps:
|
||||
- name: 准备构建版本
|
||||
id: version
|
||||
shell: bash
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
if [ -n "${{ inputs.app_version }}" ]; then
|
||||
app_version="${{ inputs.app_version }}"
|
||||
else
|
||||
app_version="${GITHUB_REF_NAME}-${GITHUB_SHA::12}"
|
||||
fi
|
||||
if [ -n "${{ inputs.app_version }}" ] && [[ ! "$app_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "正式版本必须符合 1.2.3 格式:$app_version" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "app_version=$app_version" >> "$GITHUB_OUTPUT"
|
||||
echo "build_time=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: 配置 Go
|
||||
uses: actions/setup-go@v7
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
|
||||
- name: 配置 Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
- name: 验证前端
|
||||
shell: bash
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
npm ci --prefix frontend
|
||||
npm run typecheck --prefix frontend
|
||||
npm test --prefix frontend
|
||||
npm run build --prefix frontend
|
||||
|
||||
- name: 验证 Go 服务
|
||||
run: |
|
||||
go vet ./...
|
||||
go test ./...
|
||||
|
||||
build:
|
||||
name: 构建镜像 (${{ matrix.arch }})
|
||||
needs: verify
|
||||
runs-on: ${{ matrix.runner }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -57,12 +117,17 @@ jobs:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
|
||||
- name: 缓存 Docker Chromium runtime
|
||||
- name: 配置 Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 24
|
||||
|
||||
- name: 恢复 Docker Chromium runtime 缓存
|
||||
id: cache-docker-playwright
|
||||
uses: actions/cache@v5
|
||||
uses: actions/cache/restore@v5
|
||||
with:
|
||||
path: .docker/playwright-runtime/${{ matrix.arch }}
|
||||
key: ydisks-playwright-runtime-v6-docker-${{ matrix.arch }}-${{ hashFiles('go.mod', 'go.sum') }}
|
||||
key: ydisks-playwright-runtime-v6-docker-${{ matrix.arch }}-${{ matrix.playwright_platform }}-${{ hashFiles('go.mod', 'go.sum', 'cmd/browser-install/**') }}
|
||||
|
||||
- name: 准备 Docker Chromium runtime
|
||||
if: steps.cache-docker-playwright.outputs.cache-hit != 'true'
|
||||
@@ -92,11 +157,18 @@ jobs:
|
||||
chromium_path="$(find "$runtime_dir/playwright-browsers" -type f \
|
||||
\( -name chrome -o -name headless_shell -o -name chrome-headless-shell \) -perm -111 -print -quit)"
|
||||
test -n "$chromium_path"
|
||||
chromium_revision="$(RUNTIME_SPEC="$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium").revision)')"
|
||||
headless_revision="$(RUNTIME_SPEC="$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium-headless-shell").revision)')"
|
||||
chromium_revision="$(RUNTIME_SPEC="$PWD/$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium").revision)')"
|
||||
headless_revision="$(RUNTIME_SPEC="$PWD/$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium-headless-shell").revision)')"
|
||||
test -d "$runtime_dir/playwright-browsers/chromium-$chromium_revision"
|
||||
test -d "$runtime_dir/playwright-browsers/chromium_headless_shell-$headless_revision"
|
||||
|
||||
- name: 保存 Docker Chromium runtime 缓存
|
||||
if: steps.cache-docker-playwright.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v5
|
||||
with:
|
||||
path: .docker/playwright-runtime/${{ matrix.arch }}
|
||||
key: ${{ steps.cache-docker-playwright.outputs.cache-primary-key }}
|
||||
|
||||
- name: 配置 Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
|
||||
@@ -119,12 +191,58 @@ jobs:
|
||||
context: .
|
||||
file: Dockerfile.debian13
|
||||
platforms: ${{ matrix.platform }}
|
||||
build-args: |
|
||||
APP_VERSION=${{ needs.verify.outputs.app_version }}
|
||||
VCS_REF=${{ github.sha }}
|
||||
BUILD_TIME=${{ needs.verify.outputs.build_time }}
|
||||
outputs: type=image,name=${{ steps.image.outputs.name }},push-by-digest=true,name-canonical=true,push=true
|
||||
cache-from: type=gha,scope=ydisks-docker-${{ matrix.arch }}
|
||||
cache-to: type=gha,mode=max,scope=ydisks-docker-${{ matrix.arch }}
|
||||
provenance: mode=max
|
||||
sbom: true
|
||||
|
||||
- name: 验证待发布镜像中的 Chromium 与服务
|
||||
shell: bash
|
||||
env:
|
||||
IMAGE_NAME: ${{ steps.image.outputs.name }}
|
||||
IMAGE_DIGEST: ${{ steps.build.outputs.digest }}
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
image_ref="$IMAGE_NAME@$IMAGE_DIGEST"
|
||||
docker pull "$image_ref"
|
||||
|
||||
docker run --rm --entrypoint sh "$image_ref" -ec '
|
||||
chromium_path="$(find /ms-playwright/chromium-* -type f \
|
||||
-name chrome -perm -111 -print -quit)"
|
||||
test -n "$chromium_path"
|
||||
timeout 45 "$chromium_path" \
|
||||
--headless --no-sandbox --disable-gpu --disable-dev-shm-usage \
|
||||
--dump-dom about:blank | grep -q "<html"
|
||||
'
|
||||
|
||||
container_id="$(docker run -d -p 127.0.0.1::59188 "$image_ref")"
|
||||
cleanup() {
|
||||
docker logs "$container_id" || true
|
||||
docker rm -f "$container_id" >/dev/null 2>&1 || true
|
||||
}
|
||||
trap cleanup EXIT
|
||||
host_port="$(docker port "$container_id" 59188/tcp | sed -n 's/.*://p' | head -n 1)"
|
||||
test -n "$host_port"
|
||||
for attempt in $(seq 1 60); do
|
||||
if health="$(curl --fail --silent --show-error "http://127.0.0.1:$host_port/health" 2>/dev/null)"; then
|
||||
printf '%s' "$health" | grep -q '"status":"ok"'
|
||||
printf '%s' "$health" | grep -q '"database":"ok"'
|
||||
exit 0
|
||||
fi
|
||||
if ! docker inspect -f '{{.State.Running}}' "$container_id" | grep -q true; then
|
||||
echo '待发布镜像中的服务提前退出。' >&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo '待发布镜像未能在 60 秒内通过健康检查。' >&2
|
||||
exit 1
|
||||
|
||||
- name: 保存镜像摘要
|
||||
shell: bash
|
||||
env:
|
||||
@@ -140,10 +258,11 @@ jobs:
|
||||
name: ydisks-docker-digest-${{ matrix.arch }}
|
||||
path: dist/digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
retention-days: 30
|
||||
|
||||
publish:
|
||||
name: 合并多架构镜像
|
||||
if: inputs.app_version == ''
|
||||
needs: build
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
@@ -175,13 +294,9 @@ jobs:
|
||||
with:
|
||||
images: ${{ steps.image.outputs.name }}
|
||||
tags: |
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=sha,format=long
|
||||
type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }}
|
||||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
|
||||
type=raw,value=desktop-packaging,enable=${{ github.ref == 'refs/heads/codex/desktop-packaging' }}
|
||||
type=raw,value=alpha,enable=${{ github.ref == 'refs/heads/codex/desktop-packaging' }}
|
||||
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }}
|
||||
|
||||
- name: 创建并推送多架构 manifest
|
||||
shell: bash
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
name: 发布正式版本
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
concurrency:
|
||||
group: release-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
name: 校验正式版本
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
app_version: ${{ steps.version.outputs.app_version }}
|
||||
steps:
|
||||
- name: 检出完整 Git 历史
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: 校验标签、来源与版本顺序
|
||||
id: version
|
||||
shell: bash
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
if [[ ! "$GITHUB_REF_NAME" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
|
||||
echo "正式版本标签必须符合 v1.2.3 格式:$GITHUB_REF_NAME" >&2
|
||||
exit 1
|
||||
fi
|
||||
git fetch origin main --no-tags
|
||||
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
|
||||
echo "正式版本标签必须指向 main 已包含的提交。" >&2
|
||||
exit 1
|
||||
fi
|
||||
newest_tag="$(git tag --list | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1)"
|
||||
if [ "$newest_tag" != "$GITHUB_REF_NAME" ]; then
|
||||
echo "拒绝用旧版本 $GITHUB_REF_NAME 覆盖 latest;当前最高版本是 $newest_tag。" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "app_version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
desktop:
|
||||
name: 构建桌面端安装包
|
||||
needs: prepare
|
||||
uses: ./.github/workflows/desktop-cd.yml
|
||||
with:
|
||||
app_version: ${{ needs.prepare.outputs.app_version }}
|
||||
secrets: inherit
|
||||
|
||||
docker:
|
||||
name: 构建 Docker 镜像
|
||||
needs: prepare
|
||||
uses: ./.github/workflows/docker-publish.yml
|
||||
with:
|
||||
app_version: ${{ needs.prepare.outputs.app_version }}
|
||||
secrets: inherit
|
||||
|
||||
publish:
|
||||
name: 审批并发布正式版本
|
||||
needs:
|
||||
- prepare
|
||||
- desktop
|
||||
- docker
|
||||
runs-on: ubuntu-24.04
|
||||
environment:
|
||||
name: production-release
|
||||
steps:
|
||||
- name: 检出正式版本代码
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: 下载全部构建产物
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
pattern: ydisks-*
|
||||
path: dist/artifacts
|
||||
merge-multiple: true
|
||||
|
||||
- name: 校验桌面产物并生成校验和
|
||||
shell: bash
|
||||
env:
|
||||
APP_VERSION: ${{ needs.prepare.outputs.app_version }}
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
mkdir -p dist/release dist/digests
|
||||
|
||||
echo "下载后的构建产物:"
|
||||
find dist/artifacts -maxdepth 2 -type f -printf '%P\n' | sort
|
||||
|
||||
expected_release_files=(
|
||||
"ydisks-xianyu-helper-linux-amd64-$APP_VERSION.tar.gz"
|
||||
"ydisks-xianyu-helper-linux-arm64-$APP_VERSION.tar.gz"
|
||||
"Ydisks-Xianyu-Helper-Setup.exe"
|
||||
"Ydisks-Xianyu-Helper-$APP_VERSION-arm64.pkg"
|
||||
"Ydisks-Xianyu-Helper-$APP_VERSION-amd64.pkg"
|
||||
)
|
||||
for release_file in "${expected_release_files[@]}"; do
|
||||
source_file="dist/artifacts/$release_file"
|
||||
if [ ! -f "$source_file" ]; then
|
||||
echo "缺少正式发布产物:$release_file" >&2
|
||||
exit 1
|
||||
fi
|
||||
cp -- "$source_file" dist/release/
|
||||
done
|
||||
|
||||
digest_count=0
|
||||
while IFS= read -r artifact_file; do
|
||||
artifact_name="$(basename "$artifact_file")"
|
||||
if [[ "$artifact_name" =~ ^[0-9a-f]{64}$ ]]; then
|
||||
cp -- "$artifact_file" dist/digests/
|
||||
digest_count=$((digest_count + 1))
|
||||
fi
|
||||
done < <(find dist/artifacts -maxdepth 2 -type f -print)
|
||||
if [ "$digest_count" -ne 2 ]; then
|
||||
echo "Docker 镜像摘要数量错误:预期 2 个,实际 $digest_count 个。" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "准备发布的桌面产物:"
|
||||
find dist/release -maxdepth 1 -type f -printf '%f\n' | sort
|
||||
echo "准备发布的 Docker 摘要:"
|
||||
find dist/digests -maxdepth 1 -type f -printf '%f\n' | sort
|
||||
(cd dist/release && sha256sum * > SHA256SUMS)
|
||||
|
||||
- name: 配置 Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
|
||||
- name: 登录 GitHub Container Registry
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: 发布正式 Docker manifest
|
||||
shell: bash
|
||||
env:
|
||||
APP_VERSION: ${{ needs.prepare.outputs.app_version }}
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
image_name="ghcr.io/${GITHUB_REPOSITORY,,}"
|
||||
minor_version="${APP_VERSION%.*}"
|
||||
digest_args=()
|
||||
while IFS= read -r digest_file; do
|
||||
digest_args+=("$image_name@sha256:$(basename "$digest_file")")
|
||||
done < <(find dist/digests -maxdepth 1 -type f -print | sort)
|
||||
docker buildx imagetools create \
|
||||
--tag "$image_name:$GITHUB_REF_NAME" \
|
||||
--tag "$image_name:$APP_VERSION" \
|
||||
--tag "$image_name:$minor_version" \
|
||||
--tag "$image_name:latest" \
|
||||
--tag "$image_name:sha-$GITHUB_SHA" \
|
||||
"${digest_args[@]}"
|
||||
docker buildx imagetools inspect "$image_name:$GITHUB_REF_NAME"
|
||||
docker buildx imagetools inspect "$image_name:latest"
|
||||
|
||||
- name: 创建或更新 GitHub Release
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
APP_VERSION: ${{ needs.prepare.outputs.app_version }}
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
mapfile -t release_files < <(find dist/release -maxdepth 1 -type f -print | sort)
|
||||
if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
|
||||
gh release upload "$GITHUB_REF_NAME" "${release_files[@]}" --clobber
|
||||
else
|
||||
gh release create "$GITHUB_REF_NAME" "${release_files[@]}" \
|
||||
--verify-tag \
|
||||
--generate-notes \
|
||||
--title "Ydisks 闲鱼助手 $APP_VERSION"
|
||||
fi
|
||||
@@ -7,6 +7,8 @@
|
||||
*.test
|
||||
!/Dockerfile.test
|
||||
*.out
|
||||
/cmd/server/rsrc_windows_amd64.syso
|
||||
/cmd/tray/rsrc_windows_amd64.syso
|
||||
|
||||
# Local deployment environment (keep secrets out of Git)
|
||||
/.env
|
||||
|
||||
@@ -107,11 +107,16 @@ packages explicitly bind the server to `127.0.0.1:59188` and keep the server and
|
||||
|
||||
All desktop packages contain the matching Playwright driver, Chromium and headless shell. Do not add a
|
||||
Debian Chromium package or download a second browser during installation. The Docker final image uses
|
||||
`node:latest`, copies the cached runtime prepared by CI, and does not run `apt-get update`. The desktop CI workflow
|
||||
runs on `main` and `codex/desktop-packaging`; Linux amd64 and arm64 jobs use native GitHub-hosted runners and
|
||||
`node:24-trixie-slim`, copies the cached runtime prepared by CI, installs only the Chromium system libraries
|
||||
through the bundled Playwright driver, and clears apt indexes and temporary caches in the same image layer.
|
||||
The desktop CI workflow runs on `main` and `dev`; formal desktop builds are invoked by the unified
|
||||
`release.yml` workflow for `v*.*.*` version tags. Linux amd64 and arm64 jobs use native GitHub-hosted runners and
|
||||
must not use QEMU or cross-architecture emulation. Docker publishing also builds each architecture on its native
|
||||
runner and publishes `main` and `latest` from `main`, `desktop-packaging` and `alpha` from
|
||||
`codex/desktop-packaging`.
|
||||
runner: branch builds publish `main` or `dev` plus a full-commit `sha-*` tag, while formal builds publish semantic
|
||||
version tags, `latest`, and the full-commit `sha-*` tag only after the `production-release` Environment approval.
|
||||
Version tags create a GitHub Release containing all platform packages and SHA-256 checksums. Never publish a Docker
|
||||
manifest until Go/frontend tests, an actual Chromium launch, and the packaged server health check have passed for
|
||||
every architecture.
|
||||
|
||||
The tray state machine is shared by Windows and macOS: it serializes actions, shows transition states,
|
||||
waits for a healthy `/health` response after start/restart, waits for the endpoint to become unreachable
|
||||
|
||||
+25
-5
@@ -1,6 +1,6 @@
|
||||
# syntax=docker/dockerfile:1.7
|
||||
|
||||
FROM --platform=$BUILDPLATFORM node:latest AS frontend
|
||||
FROM --platform=$BUILDPLATFORM node:24-trixie-slim AS frontend
|
||||
WORKDIR /src/frontend
|
||||
COPY frontend/package*.json ./
|
||||
RUN npm ci
|
||||
@@ -10,12 +10,17 @@ RUN npm run build
|
||||
FROM --platform=$BUILDPLATFORM golang:1.26-trixie AS backend
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
ARG APP_VERSION=dev
|
||||
ARG VCS_REF=unknown
|
||||
ARG BUILD_TIME=unknown
|
||||
WORKDIR /src
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
COPY --from=frontend /src/internal/webui/static ./internal/webui/static
|
||||
RUN CGO_ENABLED=0 GOOS="$TARGETOS" GOARCH="$TARGETARCH" go build -trimpath -ldflags="-s -w" -o /out/xianyu-server ./cmd/server \
|
||||
RUN CGO_ENABLED=0 GOOS="$TARGETOS" GOARCH="$TARGETARCH" go build -trimpath \
|
||||
-ldflags="-s -w -X xianyu-go/internal/version.Version=$APP_VERSION -X xianyu-go/internal/version.Commit=$VCS_REF -X xianyu-go/internal/version.BuildTime=$BUILD_TIME" \
|
||||
-o /out/xianyu-server ./cmd/server \
|
||||
&& CGO_ENABLED=0 GOOS="$TARGETOS" GOARCH="$TARGETARCH" go build -trimpath -ldflags="-s -w" -o /out/xianyu-dbseed ./cmd/dbseed \
|
||||
&& CGO_ENABLED=0 GOOS="$TARGETOS" GOARCH="$TARGETARCH" go build -trimpath -ldflags="-s -w" -o /out/xianyu-dbverify ./cmd/dbverify
|
||||
|
||||
@@ -30,7 +35,7 @@ RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/browser-install-ho
|
||||
|
||||
# Docker CI 会把与独立安装包相同的目标架构 runtime 放到
|
||||
# .docker/playwright-runtime,构建时直接复制,不在 Dockerfile 内重复下载浏览器。
|
||||
FROM --platform=$BUILDPLATFORM node:latest AS playwright-runtime
|
||||
FROM --platform=$BUILDPLATFORM node:24-trixie-slim AS playwright-runtime
|
||||
ARG TARGETARCH
|
||||
ENV PLAYWRIGHT_DRIVER_PATH=/ms-playwright-go
|
||||
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
||||
@@ -63,19 +68,34 @@ RUN set -eux; \
|
||||
test -d "/ms-playwright/chromium_headless_shell-$headless_revision"; \
|
||||
find /ms-playwright -type f -perm -111 \( -name chrome -o -name chrome-headless-shell -o -name headless_shell \) -print -quit | grep -q .
|
||||
|
||||
FROM node:latest AS runtime
|
||||
FROM node:24-trixie-slim AS runtime
|
||||
ENV TZ=Asia/Shanghai
|
||||
ENV BROWSER_HEADLESS=true
|
||||
ENV PLAYWRIGHT_DRIVER_PATH=/ms-playwright-go
|
||||
ENV PLAYWRIGHT_NODEJS_PATH=/usr/local/bin/node
|
||||
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
||||
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
||||
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
|
||||
WORKDIR /app
|
||||
COPY --from=backend /out/xianyu-server /app/xianyu-server
|
||||
COPY --from=backend /out/xianyu-dbseed /app/xianyu-dbseed
|
||||
COPY --from=backend /out/xianyu-dbverify /app/xianyu-dbverify
|
||||
COPY --from=playwright-runtime /ms-playwright-go /ms-playwright-go
|
||||
COPY --from=playwright-runtime /ms-playwright /ms-playwright
|
||||
RUN mkdir -p /app/data /app/browser_data
|
||||
# 浏览器文件本身不包含 Linux 动态链接库。使用与 runtime 同捆的 Playwright
|
||||
# driver 只安装 Chromium 所需系统依赖,并在同一镜像层清理 apt/npm/临时缓存。
|
||||
RUN set -eux; \
|
||||
node /ms-playwright-go/package/cli.js install-deps chromium; \
|
||||
apt-get update; \
|
||||
apt-get install --reinstall -y --no-install-recommends ca-certificates; \
|
||||
update-ca-certificates --fresh; \
|
||||
test -s "$SSL_CERT_FILE"; \
|
||||
grep -q -- '-----BEGIN CERTIFICATE-----' "$SSL_CERT_FILE"; \
|
||||
test -x "$PLAYWRIGHT_NODEJS_PATH"; \
|
||||
test -f "$PLAYWRIGHT_DRIVER_PATH/package/cli.js"; \
|
||||
find "$PLAYWRIGHT_BROWSERS_PATH" -type f -perm -111 \( -name chrome -o -name chrome-headless-shell -o -name headless_shell \) -print -quit | grep -q .; \
|
||||
apt-get clean; \
|
||||
rm -rf /var/lib/apt/lists/* /var/cache/apt/* /root/.cache /tmp/* /var/tmp/*; \
|
||||
mkdir -p /app/data /app/browser_data
|
||||
EXPOSE 59188
|
||||
CMD ["/app/xianyu-server", "-addr", ":59188"]
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
FROM alpine:3.22 AS sqlite-tools
|
||||
RUN apk add --no-cache sqlite
|
||||
|
||||
FROM node:latest AS frontend-assets
|
||||
FROM node:24-trixie-slim AS frontend-assets
|
||||
WORKDIR /src/frontend
|
||||
COPY frontend/package*.json ./
|
||||
RUN npm ci
|
||||
@@ -24,7 +24,7 @@ COPY . .
|
||||
COPY --from=frontend-assets /src/internal/webui/static ./internal/webui/static
|
||||
CMD ["golangci-lint", "run", "./..."]
|
||||
|
||||
FROM node:latest AS frontend-test
|
||||
FROM node:24-trixie-slim AS frontend-test
|
||||
WORKDIR /src/frontend
|
||||
COPY frontend/package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
[](go.mod)
|
||||
[](frontend/package.json)
|
||||
[](compose.yml)
|
||||
[](https://github.com/Christ9038/Ydisks-Xianyu-Helper/actions/workflows/docker-publish.yml)
|
||||
[](https://github.com/Christ9038/Ydisks-Xianyu-Helper/actions/workflows/release.yml)
|
||||
|
||||
[功能特性](#功能特性) · [快速开始](#快速开始) · [配置说明](#配置说明) ·
|
||||
[Docker 部署](#docker-部署) · [开发指南](#开发指南) · [开源协议](#开源协议)
|
||||
@@ -158,7 +158,7 @@ docker compose up -d
|
||||
环境要求:
|
||||
|
||||
- Go 1.26.4 或兼容版本
|
||||
- Node.js 22 与 npm
|
||||
- Node.js 24 与 npm
|
||||
- Chromium 运行所需的系统依赖
|
||||
- 默认可直接使用 SQLite,无需额外数据库服务
|
||||
|
||||
@@ -208,10 +208,15 @@ Windows 和 macOS 托盘启动时会自动启动后台服务,并显示检查
|
||||
`/var/log/ydisks-xianyu-helper/server.log`,也可以使用
|
||||
`journalctl -u ydisks-xianyu-helper.service` 查看。
|
||||
|
||||
桌面端安装包由 GitHub Actions 工作流在 `main` 和 `codex/desktop-packaging` 分支构建:Linux 上传
|
||||
amd64/arm64 tar 包,Windows 上传安装器,macOS 分别上传 arm64 和 amd64 安装包。Windows
|
||||
桌面端安装包由 `.github/workflows/desktop-cd.yml` 在 `dev`、`main` 分支上持续构建;正式版本由统一的
|
||||
`.github/workflows/release.yml` 在 `v1.2.3` 格式的版本标签上协调构建:
|
||||
Linux 上传 amd64/arm64 tar 包,Windows 上传安装器,macOS 分别上传 arm64 和 amd64 安装包。
|
||||
分支构建只保留非正式 Actions artifacts;版本标签必须指向 `main` 中的提交,全部桌面端和 Docker
|
||||
构建验证成功后等待 `production-release` Environment 人工审批,审批通过才创建 GitHub Release、
|
||||
上传各平台安装包及 `SHA256SUMS`,并发布正式 Docker 标签。Windows
|
||||
和 macOS 安装包使用工作流中配置的固定签名证书签名;未配置对应 GitHub Secrets 时,签名
|
||||
步骤会失败,不会生成可分发的安装包。
|
||||
步骤会失败,不会生成可分发的安装包。当前仓库未配置正式签名证书时,Windows/macOS 正式发布
|
||||
会停在签名步骤;Linux 安装包不依赖桌面端签名证书。
|
||||
|
||||
Linux 安装包的 `install.sh` 必须在与安装包相同架构的 Linux 主机上以 root 执行。安装包已经
|
||||
包含对应架构的 Playwright driver、Chromium 和 headless shell;安装时只安装 Chromium 所需
|
||||
@@ -315,6 +320,8 @@ DATABASE_URL > -db-url > -db
|
||||
| `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` | 源码 `false` / Docker `true` | 跳过下载 |
|
||||
| `TZ` | 系统时区;Docker 为 `Asia/Shanghai` | 容器和日志时区 |
|
||||
|
||||
前端构建还支持 `VITE_AMAP_JS_KEY`,用于覆盖发布页高德 JS API 的公开 Key;未设置时使用内置的公开 Key。修改后需重新执行 `make frontend` 才会写入嵌入式前端资源。
|
||||
|
||||
Docker Compose 还支持:
|
||||
|
||||
| 变量 | 默认值 | 说明 |
|
||||
@@ -328,8 +335,11 @@ Docker Compose 还支持:
|
||||
| `XIANYU_BIND_ADDRESS` | `0.0.0.0` | 应用在宿主机上的绑定地址 |
|
||||
| `XIANYU_HTTP_PORT` | `59188` | 应用在宿主机上的端口 |
|
||||
|
||||
默认 `compose.yml` 直接拉取 GHCR 的 `:latest` 多架构镜像;如需固定版本,请将
|
||||
`XIANYU_IMAGE` 改为 `:main`、版本号或 `:sha-<提交号>` 标签。
|
||||
默认 `compose.yml` 直接拉取 GHCR 的 `:latest` 多架构镜像;如需固定版本,请把
|
||||
`XIANYU_IMAGE` 设置为完整镜像地址,例如
|
||||
`ghcr.io/christ9038/ydisks-xianyu-helper:v1.2.3`、
|
||||
`ghcr.io/christ9038/ydisks-xianyu-helper:main` 或
|
||||
`ghcr.io/christ9038/ydisks-xianyu-helper:sha-<完整提交号>`。
|
||||
|
||||
`XIANYU_DATA_KEY` 用于加密 Cookie、账号密码、设备令牌、访问令牌、AI/SMTP 密钥和
|
||||
通知凭证。启用后,服务会自动升级历史明文数据。密钥丢失或更换后,已有加密数据将
|
||||
@@ -407,13 +417,14 @@ ARM64 Linux 拉取 arm64,不需要手动设置 `platform`。
|
||||
|
||||
| Git 引用 | 镜像标签 |
|
||||
| --- | --- |
|
||||
| `main` 分支 | `main`、`latest`、`sha-<完整提交号>` |
|
||||
| `codex/desktop-packaging` 分支 | `alpha`、`desktop-packaging`、`sha-<完整提交号>` |
|
||||
| `v1.2.3` 标签 | `1.2.3`、`1.2`、`sha-<完整提交号>` |
|
||||
| `dev` 分支 | `dev`、`sha-<完整提交号>` |
|
||||
| `main` 分支 | `main`、`sha-<完整提交号>` |
|
||||
| `v1.2.3` 标签 | `v1.2.3`、`1.2.3`、`1.2`、`latest`、`sha-<完整提交号>` |
|
||||
|
||||
当前 Docker 发布工作流会在 `main` 分支发布 `main` 和 `latest` 正式镜像,并在
|
||||
`codex/desktop-packaging` 分支发布 `desktop-packaging` 和 `alpha` 标签用于验收;其他开发分支
|
||||
不会自动生成 GHCR 标签。
|
||||
`dev` 是日常调试通道,`main` 是稳定候选通道,两者都不会更新 `latest` 或创建 Release。推送
|
||||
`v1.2.3` 格式的 Git 标签会触发统一正式发布流程。所有 Docker 发布都必须先通过 Go/前端测试,
|
||||
再对每个原生架构镜像实际启动 Chromium 和服务并通过 `/health` 检查;正式版还必须等全部桌面
|
||||
安装包构建成功并通过人工审批,之后才生成版本 manifest、更新 `latest` 并创建 GitHub Release。
|
||||
|
||||
生产环境建议使用明确的版本标签或 SHA 标签,避免上游更新导致未经验证的自动升级。
|
||||
|
||||
@@ -470,12 +481,15 @@ curl -fsS http://127.0.0.1:59188/health
|
||||
docker compose logs --tail=200 app
|
||||
```
|
||||
|
||||
健康接口正常时返回:
|
||||
健康接口正常时返回(构建信息会随运行方式变化):
|
||||
|
||||
```json
|
||||
{"database":"ok","status":"ok"}
|
||||
{"status":"ok","database":"ok","version":"dev","commit":"unknown","build_time":"unknown"}
|
||||
```
|
||||
|
||||
正式安装包和 Docker 镜像会注入对应版本、提交号和构建时间;源码运行默认显示
|
||||
`dev`/`unknown`。管理后台侧边栏底部也会显示当前运行版本和短提交号。
|
||||
|
||||
### 更新镜像
|
||||
|
||||
```bash
|
||||
@@ -650,8 +664,9 @@ go run ./cmd/server -init-admin -db data/xianyu_data.db -admin-password '新密
|
||||
### Chromium 或 Playwright 初始化失败
|
||||
|
||||
- Docker 部署优先使用项目提供的镜像,镜像在构建阶段已下载并校验匹配架构的 Chromium runtime;
|
||||
Docker CI 优先复用 GitHub Actions 缓存,不依赖 Debian 仓库中的 `chromium` 包,也不会在最终镜像
|
||||
构建阶段执行 `apt-get update`。
|
||||
Docker CI 优先复用 GitHub Actions 缓存,不依赖 Debian 仓库中的 `chromium` 包。最终镜像基于
|
||||
固定的 Node.js 24 slim 镜像,只通过 Playwright 安装 Chromium 所需动态库,并在同一镜像层清理
|
||||
apt 索引和临时缓存;发布前会实际启动 Chromium 和服务进行门禁验证。
|
||||
- 独立安装包在 CI 构建阶段下载对应架构的 Playwright driver 和 Chromium;Linux 安装时只
|
||||
安装系统库,不需要再次下载浏览器。
|
||||
- 源码运行时确认系统允许下载 Playwright 驱动和 Chromium。
|
||||
@@ -708,3 +723,9 @@ go run ./cmd/server -init-admin -db data/xianyu_data.db -admin-password '新密
|
||||
连续性或数据完整性的长期兼容。因使用本项目造成的账号限制、交易纠纷、数据损失或
|
||||
其他直接与间接损失,应由使用者自行承担。请勿将本项目用于垃圾消息、欺诈、未授权
|
||||
访问、规避平台限制或任何违法违规活动。
|
||||
|
||||
## 社区支持
|
||||
|
||||
本项目受到 LINUX DO 社区的交流与反馈支持:
|
||||
|
||||
[访问 LINUX DO 社区](https://linux.do/)
|
||||
+14
-2
@@ -29,6 +29,7 @@ import (
|
||||
"xianyu-go/internal/notify"
|
||||
"xianyu-go/internal/renewal"
|
||||
"xianyu-go/internal/server"
|
||||
appversion "xianyu-go/internal/version"
|
||||
)
|
||||
|
||||
type serverOptions struct {
|
||||
@@ -51,6 +52,7 @@ type serverOptions struct {
|
||||
adminEmail string
|
||||
adminPassword string
|
||||
service bool
|
||||
showVersion bool
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -61,6 +63,10 @@ const (
|
||||
|
||||
func main() {
|
||||
opts := parseOptions()
|
||||
if opts.showVersion {
|
||||
fmt.Printf("Ydisks Xianyu Helper %s (commit %s, built %s)\n", appversion.Version, appversion.ShortCommit(), appversion.BuildTime)
|
||||
return
|
||||
}
|
||||
if opts.workDir != "" {
|
||||
if err := os.Chdir(opts.workDir); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "切换工作目录失败: %v\n", err)
|
||||
@@ -106,6 +112,7 @@ func parseOptions() serverOptions {
|
||||
flag.StringVar(&opts.adminEmail, "admin-email", "admin@example.com", "初始化 admin 的邮箱")
|
||||
flag.StringVar(&opts.adminPassword, "admin-password", "", "初始化/重置 admin 密码;也可用 XIANYU_ADMIN_PASSWORD 环境变量")
|
||||
flag.BoolVar(&opts.service, "service", false, "以 Windows Service 模式运行")
|
||||
flag.BoolVar(&opts.showVersion, "version", false, "显示版本和构建信息后退出")
|
||||
flag.Parse()
|
||||
return opts
|
||||
}
|
||||
@@ -118,6 +125,7 @@ func runServer(parent context.Context, opts serverOptions) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
packagedPlaywrightRuntime := strings.TrimSpace(opts.playwrightRuntimeRoot) != ""
|
||||
applyPlaywrightRuntimeRoot(&opts)
|
||||
if dataDir != "" {
|
||||
if err := os.MkdirAll(dataDir, 0o700); err != nil {
|
||||
@@ -126,10 +134,14 @@ func runServer(parent context.Context, opts serverOptions) error {
|
||||
if opts.dataKeyFile == "" {
|
||||
opts.dataKeyFile = filepath.Join(dataDir, defaultDataKeyName)
|
||||
}
|
||||
if opts.playwrightDriverDir == "" {
|
||||
// 只有安装包显式提供 runtime root 时,才把 Playwright runtime
|
||||
// 放进应用数据目录。普通本地开发应沿用 Playwright 的用户缓存;
|
||||
// 空的应用目录会让 playwright-go 误以为 driver 已配置,随后尝试
|
||||
// 执行不存在的 <dataDir>/playwright-driver/node。
|
||||
if packagedPlaywrightRuntime && opts.playwrightDriverDir == "" {
|
||||
opts.playwrightDriverDir = filepath.Join(dataDir, "playwright-driver")
|
||||
}
|
||||
if opts.playwrightBrowserDir == "" {
|
||||
if packagedPlaywrightRuntime && opts.playwrightBrowserDir == "" {
|
||||
opts.playwrightBrowserDir = filepath.Join(dataDir, "playwright-browsers")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ import (
|
||||
type healthResponse struct {
|
||||
Status string `json:"status"`
|
||||
Database string `json:"database"`
|
||||
Version string `json:"version"`
|
||||
Commit string `json:"commit"`
|
||||
}
|
||||
|
||||
var serviceURL = strings.TrimRight(envOr("XIANYU_SERVICE_URL", "http://127.0.0.1:59188"), "/")
|
||||
|
||||
@@ -37,6 +37,9 @@ func serviceAction(action string) error {
|
||||
if action == "stop" && errors.Is(err, windows.ERROR_SERVICE_DOES_NOT_EXIST) {
|
||||
return nil
|
||||
}
|
||||
if errors.Is(err, windows.ERROR_SERVICE_DOES_NOT_EXIST) {
|
||||
return fmt.Errorf("Windows 服务 %s 尚未安装,请重新运行安装器", name)
|
||||
}
|
||||
if errors.Is(err, windows.ERROR_ACCESS_DENIED) {
|
||||
return fmt.Errorf("没有控制 Windows 服务的权限,请重新安装当前版本以更新服务权限")
|
||||
}
|
||||
|
||||
@@ -8,10 +8,6 @@ x-app-env: &app-env
|
||||
LOG_LEVEL: ${LOG_LEVEL:-info}
|
||||
LOG_FORMAT: ${LOG_FORMAT:-json}
|
||||
BROWSER_HEADLESS: ${BROWSER_HEADLESS:-true}
|
||||
PLAYWRIGHT_DRIVER_PATH: ${PLAYWRIGHT_DRIVER_PATH:-/ms-playwright-go}
|
||||
PLAYWRIGHT_NODEJS_PATH: ${PLAYWRIGHT_NODEJS_PATH:-/usr/local/bin/node}
|
||||
PLAYWRIGHT_BROWSERS_PATH: ${PLAYWRIGHT_BROWSERS_PATH:-/ms-playwright}
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: ${PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD:-1}
|
||||
|
||||
x-app-volumes: &app-volumes
|
||||
- app_data:/app/data
|
||||
|
||||
@@ -6,10 +6,6 @@ x-app-env: &app-env
|
||||
LOG_LEVEL: ${LOG_LEVEL:-info}
|
||||
LOG_FORMAT: ${LOG_FORMAT:-json}
|
||||
BROWSER_HEADLESS: ${BROWSER_HEADLESS:-true}
|
||||
PLAYWRIGHT_DRIVER_PATH: ${PLAYWRIGHT_DRIVER_PATH:-/ms-playwright-go}
|
||||
PLAYWRIGHT_NODEJS_PATH: ${PLAYWRIGHT_NODEJS_PATH:-/usr/local/bin/node}
|
||||
PLAYWRIGHT_BROWSERS_PATH: ${PLAYWRIGHT_BROWSERS_PATH:-/ms-playwright}
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: ${PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD:-1}
|
||||
|
||||
x-app-volumes: &app-volumes
|
||||
- app_data:/app/data
|
||||
|
||||
+1
-1
@@ -914,7 +914,7 @@
|
||||
<div style="width: 50px;"></div>
|
||||
</div>
|
||||
<div class="preview-img-container">
|
||||
<img src="img/preview.png" alt="Ydisks 闲鱼助手 Dashboard Preview" loading="lazy">
|
||||
<img src="img/preview_account.png" alt="Ydisks 闲鱼助手 Dashboard Preview" loading="lazy">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -96,6 +96,9 @@ distance = track.width - button.width
|
||||
- 页面加载后随机等待 `0.3–0.8s`,移动鼠标到 `(640, 360)`,滚动 `200–500px`,并保留现有短暂停顿。
|
||||
- 页面包含“抱歉,页面访问出现了问题”时,判定验证链接过期。
|
||||
- 页面包含 `STATUS_BREAKPOINT` 或“崩溃”时,判定验证页崩溃。
|
||||
- 页面准备完成后、首次滑动前必须先判定页面类型:只有同一 frame 内存在可见的滑块按钮和轨道时才进入滑动逻辑。
|
||||
- 如果没有可见滑块,并且任一 frame 的可见正文直接显示“验证失败”“安全验证未通过”“请求/加载失败”“系统繁忙”“服务/网络/页面异常”“请稍后重试”或对应英文错误提示,则判定为无可验证滑块的直接错误页,立即停止自动验证。
|
||||
- 直接错误页不得通过点击错误框、reload 或备用引擎强行转成滑块尝试;只有已经实际拖动过滑块后出现的 `.errloading` 才继续按第 5 节恢复。
|
||||
- 拖动前必须保存所有域上的旧 `x5sec` 值,供严格成功判定使用。
|
||||
|
||||
### 3.2 距离计算
|
||||
@@ -199,6 +202,7 @@ Playwright 主引擎
|
||||
|
||||
- 获取新验证链接的 provider 不得在主引擎持有同账号持久化 profile 锁时调用,避免同账号锁死。
|
||||
- 过期链接最多触发现有的 2 次链接刷新;最终仍过期时直接失败,不把过期 URL 交给备用引擎重放。
|
||||
- 主引擎判定为“没有可见滑块的直接错误页”时立即失败,不刷新链接,也不进入直接 Chromium/CDP 备用引擎。
|
||||
- 进入备用引擎前可再获取一次新链接和更新后的 Cookie。
|
||||
- `CAPTCHA_REAL_MOUSE=true` 在当前 Go/Docker 实现中只记录物理鼠标不可用,并继续备用逻辑;不得假装已启用物理鼠标。
|
||||
- `CAPTCHA_DRISSIONPAGE_FALLBACK_ENABLED` 默认为启用。
|
||||
@@ -242,6 +246,7 @@ Playwright 主引擎
|
||||
- 最终 `left`、最终 class 或最终 X 偏移。
|
||||
- 失败时的按钮 style/class、轨道 class、可见重试选择器和重试文本。
|
||||
- 恢复方式是 `click` 还是 `reload`、所用选择器以及是否重新归位。
|
||||
- 自动滑块最终失败时,错误文本和 `token 风控滑块处理失败` 日志的 `verification_url` 字段必须包含最后实际使用的完整验证地址(包括 query),供用户复制到本机浏览器手动验证。此字段是仅在最终失败时提供的人工接管信息;常规页面/frame 诊断日志仍必须去掉 query 与 fragment。
|
||||
|
||||
页面可能被浏览器扩展注入大量无关 DOM。当前仅把下列注入作为诊断信息记录,不允许它们改变滑块定位、距离或成功判定:
|
||||
|
||||
@@ -268,6 +273,7 @@ go vet ./internal/browser ./internal/engine ./internal/account ./internal/server
|
||||
- 主引擎首次滑动成功。
|
||||
- 主引擎首次失败并隐藏滑块,点击 `.errloading` 恢复后第二次成功。
|
||||
- 直接 Chromium/CDP 备用引擎使用同一恢复流程后成功。
|
||||
- 没有可见滑块、只显示直接错误提示的真实 Chromium 页面必须被识别,并且不得进入滑动或备用引擎。
|
||||
- 标准 `300px` 轨道与 `42px` 按钮得到精确 `258px`。
|
||||
- 旧 `x5sec` 不得判成功,新 `x5sec` 才能判成功。
|
||||
|
||||
@@ -275,6 +281,10 @@ go vet ./internal/browser ./internal/engine ./internal/account ./internal/server
|
||||
|
||||
## 10. 唯一变更流程
|
||||
|
||||
### 2026-08-13 当前授权变更
|
||||
|
||||
用户明确要求改变“未找到滑块时仍执行失败恢复/备用引擎”和“最终失败日志只保留脱敏页面地址”的既有契约。原因是风控页有时只显示平台错误信息而没有可操作滑块,继续 reload、拖动或切换引擎没有验证意义且会增加风控;而真实滑块自动处理失败时,用户需要完整地址在本机浏览器中接管验证。本规范第 3.1、6、8、9 节已同步纳入新的页面分类、编排、日志和集成验证要求。
|
||||
|
||||
只有用户在当前任务中明确点名要求修改滑块认证时,才允许触碰冻结范围。获得授权后也必须在同一个变更中:
|
||||
|
||||
1. 说明要改变本文哪一条冻结契约及原因。
|
||||
|
||||
+10
-1
@@ -22,6 +22,9 @@
|
||||
控制器以及匹配架构的 Playwright driver、Chromium;Linux 安装包自带相同的浏览器 runtime,
|
||||
安装脚本只补齐系统依赖。桌面托盘退出前会先停止后台服务。
|
||||
|
||||
管理后台侧边栏底部会显示当前运行版本和短提交号。源码运行默认显示 `dev`/`unknown`;正式安装包和
|
||||
Docker 镜像会显示构建时注入的正式版本与提交信息。
|
||||
|
||||
Windows 安装包注册 `YdisksXianyuHelper` 服务;macOS 安装包分别提供 Apple Silicon(arm64)和
|
||||
Intel(amd64)版本,并注册 `com.ydisks.xianyu-helper.server` 与
|
||||
`com.ydisks.xianyu-helper.tray` 两个 LaunchAgent。Linux 安装包按 amd64/arm64 分发,执行
|
||||
@@ -46,4 +49,10 @@ Intel(amd64)版本,并注册 `com.ydisks.xianyu-helper.server` 与
|
||||
|
||||
## GitHub Wiki 同步
|
||||
|
||||
这些 Markdown 文件位于仓库 `docs/wiki/`,可直接复制到 GitHub Wiki 对应页面;文件名即页面名。`_Sidebar.md` 是 Wiki 导航。仓库内保留副本便于在 Pull Request 中审阅和版本化维护。
|
||||
这些 Markdown 文件位于仓库 `docs/wiki/`,是 Wiki 的唯一维护来源;文件名即页面名,`_Sidebar.md` 是
|
||||
Wiki 导航。`main` 分支发生变更后,`.github/workflows/sync-wiki.yml` 会自动把这些文件镜像到 GitHub
|
||||
Wiki;也可以通过 GitHub Actions 手动运行该工作流。仓库内保留副本,便于在 Pull Request 中审阅和版本化维护,
|
||||
不建议直接在 GitHub Wiki 仓库中维护内容。
|
||||
|
||||
项目 Pages 站点使用 `main` 分支的 `/docs` 目录发布,域名由 `docs/CNAME` 中的配置决定;修改首页或图片资源
|
||||
后,合并到 `main` 即可由 GitHub Pages 发布。Pages 发布与 GitHub Wiki 同步是两个独立流程。
|
||||
+25
-2
@@ -26,12 +26,35 @@
|
||||
|
||||
Docker 中的自动续期会使用容器内 Chromium 检测到的 Linux 原生浏览器指纹请求闲鱼官网;不会因为宿主系统是 Linux 而跳过静默续期。续期结果仍以闲鱼响应和账号登录态为准。
|
||||
|
||||
## 版本、镜像与正式发布
|
||||
|
||||
项目以 Git 标签作为正式版本来源,正式标签必须符合 `v1.2.3` 格式,并指向 `main` 已包含的提交。
|
||||
推送正式标签后,统一的 `.github/workflows/release.yml` 会重新从该标签提交构建桌面安装包和 Docker 镜像;
|
||||
不会复用之前 `main` 分支构建的产物。
|
||||
构建、Chromium 启动和 `/health` 检查全部通过后,还需要 `production-release` Environment 人工审批,
|
||||
审批通过才会创建 GitHub Release、上传安装包与 `SHA256SUMS`,并更新正式镜像标签。
|
||||
|
||||
Docker 标签规则如下:
|
||||
|
||||
| Git 引用 | 镜像标签 | 是否正式发布 |
|
||||
| --- | --- | --- |
|
||||
| `dev` 分支 | `dev`、`sha-<完整提交号>` | 否,用于日常调试 |
|
||||
| `main` 分支 | `main`、`sha-<完整提交号>` | 否,稳定候选构建 |
|
||||
| `v1.2.3` 标签 | `v1.2.3`、`1.2.3`、`1.2`、`latest`、`sha-<完整提交号>` | 是 |
|
||||
|
||||
`latest` 只在正式版本审批发布阶段更新,不会随 `main` 或 `dev` 分支提交变化。生产环境建议使用
|
||||
`v1.2.3`、`1.2.3` 或 SHA 标签固定版本;Compose 默认使用 `latest`。
|
||||
|
||||
当前 Windows 和 macOS 正式安装包的 CI 签名步骤仍需要对应的签名证书 Secrets;未配置时这些平台的
|
||||
正式发布会在签名步骤失败。Linux 安装包不依赖桌面端签名证书。
|
||||
|
||||
## 独立安装包
|
||||
|
||||
独立安装包与 Docker 使用同一套 Playwright Chromium 版本来源:Chromium、headless shell 和
|
||||
Playwright driver 都在构建阶段下载并放入包内,不使用 Debian 仓库的 Chromium。Docker CI 会优先
|
||||
复用架构专属的 GitHub Actions runtime 缓存,Dockerfile 最终使用 `node:latest` 运行时,不执行
|
||||
`apt-get update` 或安装 Debian Chromium。安装时不需要用户再执行浏览器下载命令。
|
||||
复用架构专属的 GitHub Actions runtime 缓存,Dockerfile 最终使用固定的 Node.js 24 slim 运行时,
|
||||
只通过 Playwright 安装 Chromium 所需系统动态库,随后清理 apt 索引和临时缓存,不安装 Debian
|
||||
仓库中的 Chromium。安装时不需要用户再执行浏览器下载命令。
|
||||
|
||||
| 平台 | 安装方式 | 服务标识 | 默认地址 |
|
||||
| --- | --- | --- | --- |
|
||||
|
||||
@@ -38,6 +38,9 @@ npm run build
|
||||
生产部署无需单独分发前端。若 Go 服务已经运行,构建完成后必须重启 Go 服务,
|
||||
因为嵌入资源在 Go 编译时写入服务二进制;仅刷新浏览器不会更新已运行进程中的前端版本。
|
||||
|
||||
侧边栏底部的运行版本和短提交号来自后端 `/health` 接口。源码运行通常显示 `dev`/`unknown`;CI
|
||||
构建的安装包和 Docker 镜像由构建参数注入对应版本信息。
|
||||
|
||||
## Dashboard 图表约定
|
||||
|
||||
Dashboard 的营收趋势柱状图使用统一的品牌蓝 `#0094f7` 表示同一指标序列,日期之间
|
||||
|
||||
@@ -50,6 +50,7 @@ const AccountList: React.FC = () => {
|
||||
const [showQRModal, setShowQRModal] = useState(false);
|
||||
const [qrCodeUrl, setQrCodeUrl] = useState<string>('');
|
||||
const [qrStatus, setQrStatus] = useState<string>('pending');
|
||||
const [qrErrorMessage, setQrErrorMessage] = useState<string>('');
|
||||
const [verificationScreenshot, setVerificationScreenshot] = useState<string>('');
|
||||
const [faceQrUrl, setFaceQrUrl] = useState<string>('');
|
||||
const [qrReauthTarget, setQrReauthTarget] = useState<AccountDetail | null>(null);
|
||||
@@ -624,12 +625,16 @@ const AccountList: React.FC = () => {
|
||||
setQrReauthTarget(targetAccount);
|
||||
setShowQRModal(true);
|
||||
setQrStatus('loading');
|
||||
setQrErrorMessage('');
|
||||
setQrCodeUrl('');
|
||||
setVerificationScreenshot('');
|
||||
setFaceQrUrl('');
|
||||
try {
|
||||
const res = await generateQRLogin({ signal: controller.signal });
|
||||
if (!qrRequestGateRef.current?.isCurrent(requestGeneration)) return;
|
||||
if (!res.success || !res.qr_code_url || !res.session_id) {
|
||||
throw new Error(res.message || '闲鱼未返回可用的登录二维码');
|
||||
}
|
||||
if (res.success && res.qr_code_url && res.session_id) {
|
||||
const generatedSessionID = res.session_id;
|
||||
setQrCodeUrl(res.qr_code_url);
|
||||
@@ -674,7 +679,10 @@ const AccountList: React.FC = () => {
|
||||
}
|
||||
} catch (e) {
|
||||
if (!qrRequestGateRef.current?.isCurrent(requestGeneration)) return;
|
||||
setQrErrorMessage(e instanceof Error ? e.message : '二维码获取失败,请稍后重试');
|
||||
setQrStatus('error');
|
||||
} finally {
|
||||
if (qrGenerateAbortRef.current === controller) qrGenerateAbortRef.current = null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1029,7 +1037,7 @@ const AccountList: React.FC = () => {
|
||||
{qrStatus === 'error' && (
|
||||
<div className="px-5 text-center">
|
||||
<span className="block text-red-600 font-bold">二维码获取失败</span>
|
||||
<span className="mt-2 block text-xs leading-5 text-gray-500">请关闭窗口后重新发起扫码登录。</span>
|
||||
<span className="mt-2 block text-xs leading-5 text-gray-500">{qrErrorMessage || '请关闭窗口后重新发起扫码登录。'}</span>
|
||||
</div>
|
||||
)}
|
||||
{qrStatus === 'verification' && (
|
||||
|
||||
@@ -20,7 +20,9 @@ import {
|
||||
deleteItem,
|
||||
getShippingRules
|
||||
} from '../services/api';
|
||||
import { ArrowRight, Box, CheckCircle2, CircleDashed, Edit, Filter, Link2, PackagePlus, Plus, RefreshCw, Save, Search, ShoppingBag, Trash2, UploadCloud, User, X } from 'lucide-react';
|
||||
import type { PublishLocation } from '../services/api';
|
||||
import { getPublishLocations } from '../services/amapLocation';
|
||||
import { ArrowRight, Box, CheckCircle2, CircleDashed, Edit, Filter, Link2, LocateFixed, PackagePlus, Plus, RefreshCw, Save, Search, ShoppingBag, Trash2, UploadCloud, User, X } from 'lucide-react';
|
||||
|
||||
interface ItemListProps {
|
||||
onConfigureDelivery: (item: Item) => void;
|
||||
@@ -100,6 +102,11 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
const [batchImagesZip, setBatchImagesZip] = useState<File | null>(null);
|
||||
const [batchCategoryKeyword, setBatchCategoryKeyword] = useState('');
|
||||
const [batchCategoryLoading, setBatchCategoryLoading] = useState(false);
|
||||
const [locationLoading, setLocationLoading] = useState(false);
|
||||
const [publishLocations, setPublishLocations] = useState<PublishLocation[]>([]);
|
||||
const [publishLocation, setPublishLocation] = useState<PublishLocation | null>(null);
|
||||
const [batchLocations, setBatchLocations] = useState<PublishLocation[]>([]);
|
||||
const [batchLocation, setBatchLocation] = useState<PublishLocation | null>(null);
|
||||
const [batchFallbackCategory, setBatchFallbackCategory] = useState({
|
||||
catId: '',
|
||||
catName: '',
|
||||
@@ -133,8 +140,8 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
original_price: '',
|
||||
quantity: '1',
|
||||
postage_mode: 'free',
|
||||
postage: '',
|
||||
images: [] as File[]
|
||||
postage: '',
|
||||
images: [] as File[],
|
||||
});
|
||||
const [publishImagePreviews, setPublishImagePreviews] = useState<{ key: string; url: string }[]>([]);
|
||||
|
||||
@@ -285,12 +292,12 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
if (!publishForm.title.trim()) return alert('请填写商品标题');
|
||||
if (!publishForm.price.trim()) return alert('请填写商品价格');
|
||||
if (!publishForm.quantity || Number(publishForm.quantity) <= 0) return alert('库存数量必须大于 0');
|
||||
if (publishForm.images.length === 0) return alert('至少上传 1 张商品图片');
|
||||
if (publishForm.postage_mode === 'fixed' && !publishForm.postage.trim()) return alert('请填写一口价邮费');
|
||||
if (publishForm.images.length === 0) return alert('至少上传 1 张商品图片');
|
||||
if (publishForm.postage_mode === 'fixed' && !publishForm.postage.trim()) return alert('请填写一口价邮费');
|
||||
|
||||
setPublishing(true);
|
||||
try {
|
||||
const result = await publishItem(publishForm);
|
||||
const result = await publishItem({ ...publishForm, location: publishLocation || undefined });
|
||||
await loadItems();
|
||||
setShowPublishModal(false);
|
||||
setPublishForm({
|
||||
@@ -302,8 +309,10 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
quantity: '1',
|
||||
postage_mode: 'free',
|
||||
postage: '',
|
||||
images: []
|
||||
images: [],
|
||||
});
|
||||
setPublishLocations([]);
|
||||
setPublishLocation(null);
|
||||
if (result?.item_id) {
|
||||
const publishedItem: Item = {
|
||||
id: result.item_id,
|
||||
@@ -339,6 +348,8 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
setBatchImagesZip(null);
|
||||
setBatchCategoryKeyword('');
|
||||
setBatchFallbackCategory({ catId: '', catName: '', channelCatId: '', tbCatId: '' });
|
||||
setBatchLocations([]);
|
||||
setBatchLocation(null);
|
||||
setShowBatchModal(true);
|
||||
setBatchLoading(true);
|
||||
try {
|
||||
@@ -404,6 +415,7 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
imagesZip: batchImagesZip,
|
||||
defaultCookieId: selectedAccount,
|
||||
fallbackCategory: batchFallbackCategory,
|
||||
location: batchLocation || undefined,
|
||||
});
|
||||
setBatchPreview(result);
|
||||
setBatchDetail(null);
|
||||
@@ -517,6 +529,26 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
setShowPublishModal(true);
|
||||
};
|
||||
|
||||
const locateForPublish = async (batch: boolean) => {
|
||||
const cookieId = batch ? selectedAccount : publishForm.cookie_id;
|
||||
if (!cookieId) return alert('请先选择发布账号');
|
||||
if (!navigator.geolocation) return alert('当前浏览器不支持定位');
|
||||
setLocationLoading(true);
|
||||
navigator.geolocation.getCurrentPosition(async position => {
|
||||
try {
|
||||
const locations = await getPublishLocations(position.coords.longitude, position.coords.latitude);
|
||||
if (!locations.length) throw new Error('当前位置附近没有可用的高德发货地,请稍后重试');
|
||||
if (batch) { setBatchLocations(locations); setBatchLocation(locations[0]); }
|
||||
else { setPublishLocations(locations); setPublishLocation(locations[0]); }
|
||||
} catch (error: any) {
|
||||
alert(error?.message || '获取发货地失败');
|
||||
} finally { setLocationLoading(false); }
|
||||
}, error => {
|
||||
setLocationLoading(false);
|
||||
alert(error.code === error.PERMISSION_DENIED ? '定位权限被拒绝,请在浏览器设置中允许定位' : '无法获取当前位置,请稍后重试');
|
||||
}, { enableHighAccuracy: true, timeout: 15000, maximumAge: 60000 });
|
||||
};
|
||||
|
||||
const rulesForItem = (item: Item) => shippingRules.filter(rule =>
|
||||
rule.cookie_id === item.cookie_id && rule.item_id === item.item_id
|
||||
).length > 0
|
||||
@@ -822,7 +854,11 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label className="block text-sm font-bold text-gray-700">发布账号</label>
|
||||
<select className="w-full ios-input px-4 py-3 rounded-xl" value={publishForm.cookie_id} onChange={e => setPublishForm({...publishForm, cookie_id: e.target.value})}>
|
||||
<select className="w-full ios-input px-4 py-3 rounded-xl" value={publishForm.cookie_id} onChange={e => {
|
||||
setPublishForm({...publishForm, cookie_id: e.target.value});
|
||||
setPublishLocations([]);
|
||||
setPublishLocation(null);
|
||||
}}>
|
||||
<option value="">选择账号</option>
|
||||
{accounts.map(acc => <option key={acc.id} value={acc.id}>{accountName(acc.id)}</option>)}
|
||||
</select>
|
||||
@@ -866,6 +902,17 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
<input className="w-full ios-input px-4 py-3 rounded-xl" placeholder="例如 8.00" value={publishForm.postage} onChange={e => setPublishForm({...publishForm, postage: e.target.value})} />
|
||||
</div>
|
||||
)}
|
||||
<div className="rounded-2xl border border-sky-200 bg-sky-50 p-4 space-y-3">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div><div className="text-sm font-extrabold text-gray-900">发货地(可选)</div><p className="mt-1 text-xs text-sky-800">虚拟商品无需发货地;发布失败时可再定位并作为补充信息提交。</p></div>
|
||||
<button type="button" disabled={locationLoading || !publishForm.cookie_id} onClick={() => void locateForPublish(false)} className="ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50">
|
||||
<LocateFixed className="h-4 w-4" />{locationLoading ? '定位中...' : '获取当前位置'}
|
||||
</button>
|
||||
</div>
|
||||
{publishLocations.length > 0 && <select className="w-full ios-input rounded-xl bg-white px-4 py-3" value={String(Math.max(0, publishLocations.indexOf(publishLocation!)))} onChange={e => setPublishLocation(publishLocations[Number(e.target.value)] || null)}>
|
||||
{publishLocations.map((item, index) => <option key={`${item.division_id}-${item.poi_id}-${index}`} value={String(index)}>{[item.province, item.city, item.area, item.poi_name].filter(Boolean).join(' ')}</option>)}
|
||||
</select>}
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label className="block text-sm font-bold text-gray-700">商品图片(1-9 张)</label>
|
||||
<label className="flex min-h-[120px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-emerald-300 hover:bg-emerald-50/50 transition-colors">
|
||||
@@ -951,7 +998,11 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
<select
|
||||
className="w-full ios-input px-4 py-3 rounded-xl"
|
||||
value={selectedAccount}
|
||||
onChange={e => setSelectedAccount(e.target.value)}
|
||||
onChange={e => {
|
||||
setSelectedAccount(e.target.value);
|
||||
setBatchLocations([]);
|
||||
setBatchLocation(null);
|
||||
}}
|
||||
>
|
||||
<option value="">选择账号</option>
|
||||
{accounts.map(acc => <option key={acc.id} value={acc.id}>{accountName(acc.id)}</option>)}
|
||||
@@ -1012,6 +1063,18 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div className="rounded-xl border border-sky-200 bg-sky-50 p-4 space-y-3">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div><div className="text-sm font-extrabold text-gray-900">批次发货地(可选)</div><p className="mt-1 text-xs text-sky-800">虚拟商品可留空;填写后整个批次使用同一个发货地,并随任务保存用于恢复和重试。</p></div>
|
||||
<button type="button" disabled={locationLoading || !selectedAccount} onClick={() => void locateForPublish(true)} className="ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50">
|
||||
<LocateFixed className="h-4 w-4" />{locationLoading ? '定位中...' : '获取当前位置'}
|
||||
</button>
|
||||
</div>
|
||||
{batchLocations.length > 0 && <select className="w-full ios-input rounded-xl bg-white px-4 py-3" value={String(Math.max(0, batchLocations.indexOf(batchLocation!)))} onChange={e => setBatchLocation(batchLocations[Number(e.target.value)] || null)}>
|
||||
{batchLocations.map((item, index) => <option key={`${item.division_id}-${item.poi_id}-${index}`} value={String(index)}>{[item.province, item.city, item.area, item.poi_name].filter(Boolean).join(' ')}</option>)}
|
||||
</select>}
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<label className="flex min-h-[150px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-blue-300 hover:bg-blue-50 transition-colors">
|
||||
<UploadCloud className="w-9 h-9 text-blue-600 mb-3" />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import {
|
||||
Bell, Box, ChevronLeft, ChevronRight, CreditCard, LayoutDashboard,
|
||||
LogOut, MessageCircleMore, Settings, ShoppingBag, Users, Zap,
|
||||
GitCommitHorizontal, LogOut, MessageCircleMore, Settings, ShoppingBag, Users, Zap,
|
||||
} from 'lucide-react';
|
||||
import { YdisksBrandIcon } from './YdisksLogo';
|
||||
|
||||
@@ -14,9 +14,30 @@ interface SidebarProps {
|
||||
onLogout: () => void;
|
||||
}
|
||||
|
||||
interface BuildInfo {
|
||||
version: string;
|
||||
commit: string;
|
||||
}
|
||||
|
||||
const Sidebar: React.FC<SidebarProps> = ({
|
||||
activeTab, isAdmin = false, collapsed, onToggleCollapsed, onNavigate, onLogout,
|
||||
}) => {
|
||||
const [buildInfo, setBuildInfo] = useState<BuildInfo>({ version: 'dev', commit: 'unknown' });
|
||||
|
||||
useEffect(() => {
|
||||
const controller = new AbortController();
|
||||
fetch('/health', { signal: controller.signal })
|
||||
.then(response => response.ok ? response.json() : Promise.reject(new Error('health request failed')))
|
||||
.then(data => setBuildInfo({
|
||||
version: String(data.version || 'dev'),
|
||||
commit: String(data.commit || 'unknown'),
|
||||
}))
|
||||
.catch(error => {
|
||||
if (error instanceof DOMException && error.name === 'AbortError') return;
|
||||
});
|
||||
return () => controller.abort();
|
||||
}, []);
|
||||
|
||||
const menuItems = [
|
||||
{ id: 'dashboard', icon: LayoutDashboard, label: '仪表盘' },
|
||||
{ id: 'accounts', icon: Users, label: '账号管理' },
|
||||
@@ -28,6 +49,9 @@ const Sidebar: React.FC<SidebarProps> = ({
|
||||
{ id: 'notifications', icon: Bell, label: '通知设置' },
|
||||
...(isAdmin ? [{ id: 'settings', icon: Settings, label: '系统与AI' }] : []),
|
||||
];
|
||||
const displayVersion = /^\d+\.\d+\.\d+$/.test(buildInfo.version)
|
||||
? `v${buildInfo.version}`
|
||||
: buildInfo.version;
|
||||
|
||||
return (
|
||||
<aside className={`fixed inset-y-0 left-0 z-20 flex flex-col border-r border-slate-200/80 bg-white/95 shadow-sidebar backdrop-blur-xl transition-[width] duration-300 ${collapsed ? 'w-16' : 'w-64'}`}>
|
||||
@@ -41,13 +65,13 @@ const Sidebar: React.FC<SidebarProps> = ({
|
||||
)}
|
||||
</div>
|
||||
|
||||
<nav className={`flex-1 space-y-1.5 overflow-y-auto py-5 ${collapsed ? 'px-2' : 'px-3'}`} aria-label="主导航">
|
||||
<nav className={`flex-1 space-y-1.5 overflow-y-auto pt-5 ${collapsed ? 'px-2' : 'px-3'}`} aria-label="主导航">
|
||||
{menuItems.map((item) => {
|
||||
const Icon = item.icon;
|
||||
const active = activeTab === item.id;
|
||||
return (
|
||||
<button
|
||||
key={item.id}
|
||||
<React.Fragment key={item.id}>
|
||||
<button
|
||||
type="button"
|
||||
title={collapsed ? item.label : undefined}
|
||||
aria-label={item.label}
|
||||
@@ -62,32 +86,54 @@ const Sidebar: React.FC<SidebarProps> = ({
|
||||
<Icon className={`h-[19px] w-[19px] shrink-0 ${active ? 'text-white' : 'text-slate-400 group-hover:text-slate-700'}`} />
|
||||
{!collapsed && <span className="truncate text-sm font-bold">{item.label}</span>}
|
||||
{active && !collapsed && <span className="ml-auto h-1.5 w-1.5 rounded-full bg-white/90" />}
|
||||
</button>
|
||||
</button>
|
||||
</React.Fragment>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
|
||||
<div className={`space-y-2 border-t border-slate-100 p-2 ${collapsed ? '' : 'p-3'}`}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onToggleCollapsed}
|
||||
title={collapsed ? '展开侧边栏' : '收起侧边栏'}
|
||||
aria-label={collapsed ? '展开侧边栏' : '收起侧边栏'}
|
||||
className={`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-900 ${collapsed ? 'justify-center' : 'gap-3 px-3'}`}
|
||||
<div>
|
||||
<div
|
||||
title={collapsed ? `版本 ${buildInfo.version} · ${buildInfo.commit}` : undefined}
|
||||
className={`border-y border-slate-100 bg-slate-50/70 py-2.5 ${collapsed ? 'flex justify-center px-1' : 'px-6'}`}
|
||||
>
|
||||
{collapsed ? <ChevronRight className="h-5 w-5" /> : <ChevronLeft className="h-5 w-5" />}
|
||||
{!collapsed && <span className="text-sm font-bold">收起侧边栏</span>}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onLogout}
|
||||
title={collapsed ? '退出登录' : undefined}
|
||||
aria-label="退出登录"
|
||||
className={`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-red-50 hover:text-red-600 ${collapsed ? 'justify-center' : 'gap-3 px-3'}`}
|
||||
>
|
||||
<LogOut className="h-5 w-5" />
|
||||
{!collapsed && <span className="text-sm font-bold">退出登录</span>}
|
||||
</button>
|
||||
{collapsed ? (
|
||||
<GitCommitHorizontal className="h-[18px] w-[18px] text-slate-400" aria-label={`版本 ${buildInfo.version}`} />
|
||||
) : (
|
||||
<div className="min-w-0">
|
||||
<div className="flex items-center gap-2 text-[10px] font-extrabold uppercase tracking-[0.18em] text-slate-400">
|
||||
<GitCommitHorizontal className="h-3.5 w-3.5" />
|
||||
运行版本
|
||||
</div>
|
||||
<div className="mt-1 flex items-baseline gap-2">
|
||||
<span className="truncate font-mono text-xs font-bold text-slate-700">{displayVersion}</span>
|
||||
<span className="truncate font-mono text-[10px] text-slate-400">{buildInfo.commit}</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className={`space-y-2 p-2 ${collapsed ? '' : 'p-3'}`}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onToggleCollapsed}
|
||||
title={collapsed ? '展开侧边栏' : '收起侧边栏'}
|
||||
aria-label={collapsed ? '展开侧边栏' : '收起侧边栏'}
|
||||
className={`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-900 ${collapsed ? 'justify-center' : 'gap-3 px-3'}`}
|
||||
>
|
||||
{collapsed ? <ChevronRight className="h-5 w-5" /> : <ChevronLeft className="h-5 w-5" />}
|
||||
{!collapsed && <span className="text-sm font-bold">收起侧边栏</span>}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onLogout}
|
||||
title={collapsed ? '退出登录' : undefined}
|
||||
aria-label="退出登录"
|
||||
className={`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-red-50 hover:text-red-600 ${collapsed ? 'justify-center' : 'gap-3 px-3'}`}
|
||||
>
|
||||
<LogOut className="h-5 w-5" />
|
||||
{!collapsed && <span className="text-sm font-bold">退出登录</span>}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ describe('frontend navigation routing', () => {
|
||||
test('logout button invalidates the backend session before clearing UI state', () => {
|
||||
const app = readFrontendFile('App.tsx');
|
||||
|
||||
expect(app).toContain('import { login, logout, verifySession }');
|
||||
expect(app).toContain('import { initializeAdmin, login, logout, verifySession }');
|
||||
expect(app).toContain('await logout();');
|
||||
expect(app).toContain('onLogout={handleLogout}');
|
||||
});
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { expect, test } from 'vitest';
|
||||
import { amapPOIToPublishLocation } from './amapLocation';
|
||||
|
||||
test('maps AMap POI fields to the publish location shape', () => {
|
||||
expect(amapPOIToPublishLocation({
|
||||
id: 'B000A74398',
|
||||
name: '人民广场',
|
||||
address: '人民大道',
|
||||
adname: '黄浦区',
|
||||
cityname: '上海市',
|
||||
adcode: '310101',
|
||||
pname: '上海市',
|
||||
location: { lng: 121.4737, lat: 31.2304 },
|
||||
})).toEqual({
|
||||
area: '黄浦区',
|
||||
city: '上海市',
|
||||
division_id: '310101',
|
||||
longitude: 121.4737,
|
||||
latitude: 31.2304,
|
||||
poi_id: 'B000A74398',
|
||||
poi_name: '人民广场',
|
||||
province: '上海市',
|
||||
});
|
||||
});
|
||||
|
||||
test('drops incomplete or invalid AMap POIs', () => {
|
||||
expect(amapPOIToPublishLocation({
|
||||
id: 'poi',
|
||||
name: '无坐标',
|
||||
adcode: '310101',
|
||||
pname: '上海市',
|
||||
cityname: '上海市',
|
||||
location: { lng: 0, lat: 31.2 },
|
||||
})).toBeNull();
|
||||
});
|
||||
@@ -0,0 +1,153 @@
|
||||
import type { PublishLocation } from './api';
|
||||
|
||||
const AMAP_SCRIPT_ID = 'ydisks-amap-js-api';
|
||||
// 高德 JS API 的 Key 是前端公开 Key;部署时可通过 VITE_AMAP_JS_KEY 覆盖。
|
||||
const DEFAULT_AMAP_JS_KEY = 'c9b68d4ce9a2a97f22a4a439404488ca';
|
||||
|
||||
export interface AMapLocationValue {
|
||||
lng: number;
|
||||
lat: number;
|
||||
}
|
||||
|
||||
export interface AMapPOI {
|
||||
id?: string;
|
||||
name?: string;
|
||||
address?: string;
|
||||
adname?: string;
|
||||
cityname?: string;
|
||||
adcode?: string | number;
|
||||
pname?: string;
|
||||
location?: AMapLocationValue;
|
||||
}
|
||||
|
||||
interface AMapPlaceSearchResult {
|
||||
poiList?: {
|
||||
pois?: AMapPOI[];
|
||||
};
|
||||
}
|
||||
|
||||
interface AMapPlaceSearch {
|
||||
searchNearBy(
|
||||
keyword: string,
|
||||
center: [number, number],
|
||||
radius: number,
|
||||
callback: (status: string, result: AMapPlaceSearchResult) => void,
|
||||
): void;
|
||||
}
|
||||
|
||||
interface AMapAPI {
|
||||
PlaceSearch: new (options: { extensions: 'all'; pageSize: number }) => AMapPlaceSearch;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
AMap?: AMapAPI;
|
||||
__ydisksAmapLoaded?: () => void;
|
||||
}
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_AMAP_JS_KEY?: string;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
}
|
||||
|
||||
let amapLoadPromise: Promise<AMapAPI> | null = null;
|
||||
|
||||
const configuredAmapKey = (): string => {
|
||||
const key = import.meta.env.VITE_AMAP_JS_KEY?.trim();
|
||||
return key || DEFAULT_AMAP_JS_KEY;
|
||||
};
|
||||
|
||||
const loadAMap = (): Promise<AMapAPI> => {
|
||||
if (window.AMap) return Promise.resolve(window.AMap);
|
||||
if (amapLoadPromise) return amapLoadPromise;
|
||||
|
||||
amapLoadPromise = new Promise<AMapAPI>((resolve, reject) => {
|
||||
const existing = document.getElementById(AMAP_SCRIPT_ID) as HTMLScriptElement | null;
|
||||
const script = existing || document.createElement('script');
|
||||
const cleanup = () => {
|
||||
window.__ydisksAmapLoaded = undefined;
|
||||
window.clearTimeout(timeout);
|
||||
};
|
||||
const finish = () => {
|
||||
if (window.AMap) {
|
||||
cleanup();
|
||||
resolve(window.AMap);
|
||||
} else {
|
||||
cleanup();
|
||||
reject(new Error('高德地图 API 加载完成但未找到 AMap 对象'));
|
||||
}
|
||||
};
|
||||
const timeout = window.setTimeout(() => {
|
||||
cleanup();
|
||||
reject(new Error('高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置'));
|
||||
}, 15_000);
|
||||
|
||||
window.__ydisksAmapLoaded = finish;
|
||||
script.id = AMAP_SCRIPT_ID;
|
||||
script.async = true;
|
||||
script.src = `https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(configuredAmapKey())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`;
|
||||
script.onerror = () => {
|
||||
cleanup();
|
||||
reject(new Error('高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置'));
|
||||
};
|
||||
if (!existing) document.head.appendChild(script);
|
||||
}).catch(error => {
|
||||
amapLoadPromise = null;
|
||||
throw error;
|
||||
});
|
||||
|
||||
return amapLoadPromise;
|
||||
};
|
||||
|
||||
const validCoordinate = (value: number): boolean => Number.isFinite(value) && value !== 0;
|
||||
|
||||
// 字段映射与闲鱼网页版发布页一致:adcode → divisionId,name → poi,pname/cityname/adname → 行政区。
|
||||
export const amapPOIToPublishLocation = (poi: AMapPOI): PublishLocation | null => {
|
||||
const longitude = Number(poi.location?.lng);
|
||||
const latitude = Number(poi.location?.lat);
|
||||
const location: PublishLocation = {
|
||||
area: String(poi.adname || '').trim(),
|
||||
city: String(poi.cityname || '').trim(),
|
||||
division_id: String(poi.adcode || '').trim(),
|
||||
longitude,
|
||||
latitude,
|
||||
poi_id: String(poi.id || '').trim(),
|
||||
poi_name: String(poi.name || '').trim(),
|
||||
province: String(poi.pname || '').trim(),
|
||||
};
|
||||
if (!location.division_id || !location.province || !location.city || !location.poi_id || !location.poi_name) {
|
||||
return null;
|
||||
}
|
||||
if (!validCoordinate(longitude) || !validCoordinate(latitude) || longitude < -180 || longitude > 180 || latitude < -90 || latitude > 90) {
|
||||
return null;
|
||||
}
|
||||
return location;
|
||||
};
|
||||
|
||||
export const getPublishLocations = async (longitude: number, latitude: number): Promise<PublishLocation[]> => {
|
||||
if (!validCoordinate(longitude) || !validCoordinate(latitude) || longitude < -180 || longitude > 180 || latitude < -90 || latitude > 90) {
|
||||
throw new Error('经纬度无效');
|
||||
}
|
||||
const amap = await loadAMap();
|
||||
return new Promise<PublishLocation[]>((resolve, reject) => {
|
||||
const placeSearch = new amap.PlaceSearch({ extensions: 'all', pageSize: 10 });
|
||||
placeSearch.searchNearBy('', [longitude, latitude], 1_000, (status, result) => {
|
||||
if (status !== 'complete') {
|
||||
if (status === 'no_data') {
|
||||
resolve([]);
|
||||
return;
|
||||
}
|
||||
reject(new Error('高德地图附近地址查询失败,请稍后重试'));
|
||||
return;
|
||||
}
|
||||
const locations = (result?.poiList?.pois || [])
|
||||
.map(amapPOIToPublishLocation)
|
||||
.filter((location): location is PublishLocation => location !== null);
|
||||
resolve(locations);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
completeQRVerification,
|
||||
createNotificationChannel,
|
||||
getAccountDetails,
|
||||
getCards,
|
||||
getAutomationIssues,
|
||||
getItems,
|
||||
getItemPublishBatches,
|
||||
@@ -17,8 +18,9 @@ import {
|
||||
getShippingRules,
|
||||
getShippingRulesPage,
|
||||
getSystemSettings,
|
||||
getValidOrders,
|
||||
logout,
|
||||
getValidOrders,
|
||||
publishItem,
|
||||
logout,
|
||||
importOrders,
|
||||
passwordLogin,
|
||||
resolveAutomationRun,
|
||||
@@ -92,6 +94,11 @@ test('getItemPublishBatches unwraps persisted batch list', async () => {
|
||||
expect(fetchMock).toHaveBeenCalledWith('/items/publish-batches?limit=10', expect.objectContaining({ credentials: 'include' }));
|
||||
});
|
||||
|
||||
test('getCards treats an empty backend response as an empty list', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(jsonResponse(null)));
|
||||
await expect(getCards()).resolves.toEqual([]);
|
||||
});
|
||||
|
||||
test('automation issue APIs expose and resolve quarantined work', async () => {
|
||||
const fetchMock = vi.fn()
|
||||
.mockResolvedValueOnce(jsonResponse({ runs: [{ id: 1 }], pending_tasks: [{ id: 2 }] }))
|
||||
@@ -228,6 +235,22 @@ test('deleteItemPublishBatch removes an abandoned preview', async () => {
|
||||
}));
|
||||
});
|
||||
|
||||
test('publishItem allows virtual publishing without an optional location', async () => {
|
||||
const fetchMock = vi.fn().mockResolvedValue(jsonResponse({ success: true }));
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
await publishItem({
|
||||
cookie_id: 'acc1',
|
||||
title: '虚拟商品',
|
||||
description: '',
|
||||
price: '12.50',
|
||||
quantity: 1,
|
||||
postage_mode: 'none',
|
||||
images: [],
|
||||
});
|
||||
const body = fetchMock.mock.calls[0][1].body as FormData;
|
||||
expect(body.get('location')).toBeNull();
|
||||
});
|
||||
|
||||
test('getItems normalizes multi-spec flags from backend values', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(jsonResponse([{
|
||||
cookie_id: 'cookie-1',
|
||||
|
||||
@@ -163,8 +163,9 @@ export const getAccountRuntimeStatuses = async (options?: RequestControlOptions)
|
||||
return get('/cookies/runtime-status', undefined, options);
|
||||
};
|
||||
|
||||
export const generateQRLogin = async (options?: RequestControlOptions): Promise<{ success: boolean; session_id?: string; qr_code_url?: string }> => {
|
||||
return post('/qr-login/generate', undefined, options);
|
||||
export const generateQRLogin = async (options?: RequestControlOptions): Promise<{ success: boolean; session_id?: string; qr_code_url?: string; message?: string }> => {
|
||||
// 风控后匿名 token 接口可能超过通用的 30 秒请求窗口;后端总生成窗口为 2 分钟。
|
||||
return post('/qr-login/generate', undefined, { ...options, timeoutMs: options?.timeoutMs ?? 130_000 });
|
||||
};
|
||||
|
||||
export const checkQRLoginStatus = async (sessionId: string, signal?: AbortSignal): Promise<any> => {
|
||||
@@ -449,7 +450,7 @@ const cardPayload = (data: Partial<Card>): Record<string, unknown> => ({
|
||||
|
||||
export const getCards = async (): Promise<Card[]> => {
|
||||
const res = await get<any>('/cards');
|
||||
const cards = Array.isArray(res) ? res : (res.cards || []);
|
||||
const cards = Array.isArray(res) ? res : (res?.cards || []);
|
||||
return cards.map(normalizeCard);
|
||||
};
|
||||
|
||||
@@ -526,6 +527,7 @@ export const publishItem = async (form: {
|
||||
postage_mode: string;
|
||||
postage?: string;
|
||||
images: File[];
|
||||
location?: PublishLocation;
|
||||
}): Promise<any> => {
|
||||
const body = new FormData();
|
||||
body.set('cookie_id', form.cookie_id);
|
||||
@@ -536,12 +538,24 @@ export const publishItem = async (form: {
|
||||
body.set('quantity', String(form.quantity));
|
||||
body.set('postage_mode', form.postage_mode);
|
||||
body.set('postage', form.postage || '');
|
||||
if (form.location) body.set('location', JSON.stringify(form.location));
|
||||
for (const file of form.images) {
|
||||
body.append('images', file);
|
||||
}
|
||||
return postForm('/items/publish', body);
|
||||
}
|
||||
|
||||
export interface PublishLocation {
|
||||
area: string;
|
||||
city: string;
|
||||
division_id: string;
|
||||
longitude: number;
|
||||
latitude: number;
|
||||
poi_id: string;
|
||||
poi_name: string;
|
||||
province: string;
|
||||
}
|
||||
|
||||
export const recommendPublishCategory = async (cookieId: string, keyword: string): Promise<{
|
||||
success: boolean;
|
||||
category: {
|
||||
@@ -564,6 +578,7 @@ export const previewItemPublishBatch = async (form: {
|
||||
channelCatId?: string;
|
||||
tbCatId?: string;
|
||||
};
|
||||
location?: PublishLocation;
|
||||
}): Promise<any> => {
|
||||
const body = new FormData();
|
||||
body.set('file', form.file);
|
||||
@@ -573,6 +588,7 @@ export const previewItemPublishBatch = async (form: {
|
||||
body.set('fallback_category_name', form.fallbackCategory.catName);
|
||||
body.set('fallback_channel_category_id', form.fallbackCategory.channelCatId || '');
|
||||
body.set('fallback_tb_category_id', form.fallbackCategory.tbCatId || '');
|
||||
if (form.location) body.set('location', JSON.stringify(form.location));
|
||||
return postForm('/items/publish-batches/preview', body);
|
||||
}
|
||||
|
||||
|
||||
@@ -159,6 +159,15 @@ func (m *Manager) Sender(cookieID string) (automation.MessageSender, bool) {
|
||||
return m.GetInstance(cookieID)
|
||||
}
|
||||
|
||||
// RecoverExpiredCredential 把任意上层 MTOP API 检测到的 Session 失效统一
|
||||
// 转交给账号 Handler 的协议续期流程。调用方必须先释放账号凭证锁。
|
||||
func (m *Manager) RecoverExpiredCredential(ctx context.Context, cookieID string) bool {
|
||||
if m == nil || m.handler == nil {
|
||||
return false
|
||||
}
|
||||
return m.handler.OnPasswordLoginRefresh(ctx, cookieID)
|
||||
}
|
||||
|
||||
// RuntimeStatuses 返回所有已启动账号的实时状态快照。
|
||||
func (m *Manager) RuntimeStatuses() map[string]engine.RuntimeStatus {
|
||||
m.mu.Lock()
|
||||
|
||||
@@ -276,7 +276,11 @@ func (a *Adapter) OnTokenCaptchaVerification(ctx context.Context, cookieID, cook
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
a.logger.Warn("token 风控滑块处理失败", "account", cookieID, "err", err)
|
||||
manualURL := browser.TokenCaptchaManualVerificationURL(err)
|
||||
if strings.TrimSpace(manualURL) == "" {
|
||||
manualURL = verificationURL
|
||||
}
|
||||
a.logger.Warn("token 风控滑块处理失败", "account", cookieID, "err", err, "verification_url", manualURL)
|
||||
if a.store != nil && a.store.RiskLogs != nil {
|
||||
_ = a.store.RiskLogs.Update(ctx, logID, db.RiskControlLog{
|
||||
ProcessingStatus: "failed",
|
||||
|
||||
@@ -2,6 +2,7 @@ package automation
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -45,14 +46,32 @@ func (c *Center) RunAccountTask(ctx context.Context, accountID, taskType string)
|
||||
if err != nil {
|
||||
return AccountTaskSummary{TaskType: taskType}, err
|
||||
}
|
||||
return c.runConfiguredAccountTask(ctx, settings, taskType)
|
||||
}
|
||||
|
||||
func (c *Center) runConfiguredAccountTask(ctx context.Context, settings db.AccountTaskSettings, taskType string) (AccountTaskSummary, error) {
|
||||
if blocked, err := c.accountTaskSessionBlocked(ctx, settings.CookieID); err != nil {
|
||||
return AccountTaskSummary{TaskType: taskType}, err
|
||||
} else if blocked {
|
||||
return AccountTaskSummary{TaskType: taskType, Skipped: 1, Message: "Session 已失效,等待续期或重新登录"},
|
||||
fmt.Errorf("账号 Session 已失效,已停止自动化 API 请求,等待续期或重新登录")
|
||||
}
|
||||
var (
|
||||
summary AccountTaskSummary
|
||||
err error
|
||||
)
|
||||
switch taskType {
|
||||
case TaskAutoRate:
|
||||
return c.runAutoRate(ctx, settings)
|
||||
summary, err = c.runAutoRate(ctx, settings)
|
||||
case TaskAutoPolish:
|
||||
return c.runAutoPolish(ctx, settings, beijingNow(), true)
|
||||
summary, err = c.runAutoPolish(ctx, settings, beijingNow(), true)
|
||||
default:
|
||||
return AccountTaskSummary{TaskType: taskType}, fmt.Errorf("不支持的账号任务: %s", taskType)
|
||||
}
|
||||
if err != nil && mtop.IsSessionExpiredErr(err) {
|
||||
err = c.recoverAccountTaskSession(ctx, settings.CookieID, err)
|
||||
}
|
||||
return summary, err
|
||||
}
|
||||
|
||||
func (c *Center) scanAccountTasks(ctx context.Context) {
|
||||
@@ -70,19 +89,70 @@ func (c *Center) scanAccountTasks(ctx context.Context) {
|
||||
if err != nil || !allowed {
|
||||
continue
|
||||
}
|
||||
if blocked, blockErr := c.accountTaskSessionBlocked(ctx, setting.CookieID); blockErr != nil || blocked {
|
||||
continue
|
||||
}
|
||||
if setting.AutoRateEnabled {
|
||||
if _, err := c.runAutoRate(ctx, setting); err != nil {
|
||||
if _, err := c.runConfiguredAccountTask(ctx, setting, TaskAutoRate); err != nil {
|
||||
c.logger.Warn("自动评价扫描失败", "account", setting.CookieID, "err", err)
|
||||
}
|
||||
}
|
||||
if setting.AutoPolishEnabled && polishDue(setting, now) {
|
||||
if _, err := c.runAutoPolish(ctx, setting, now, false); err != nil {
|
||||
c.logger.Warn("每日擦亮失败", "account", setting.CookieID, "err", err)
|
||||
if blocked, _ := c.accountTaskSessionBlocked(ctx, setting.CookieID); blocked {
|
||||
continue
|
||||
}
|
||||
_, taskErr := c.runAutoPolish(ctx, setting, now, false)
|
||||
if taskErr != nil && mtop.IsSessionExpiredErr(taskErr) {
|
||||
taskErr = c.recoverAccountTaskSession(ctx, setting.CookieID, taskErr)
|
||||
}
|
||||
if taskErr != nil {
|
||||
c.logger.Warn("每日擦亮失败", "account", setting.CookieID, "err", taskErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Center) recoverAccountTaskSession(ctx context.Context, accountID string, sessionErr error) error {
|
||||
fingerprint, fingerprintErr := c.accountCredentialFingerprint(ctx, accountID)
|
||||
if fingerprintErr == nil {
|
||||
c.sessionExpired.Store(accountID, fingerprint)
|
||||
}
|
||||
c.logger.Warn("自动化 API 检测到 Session 过期,停止后续请求并开始即时续期", "account", accountID, "err", sessionErr)
|
||||
if c.recoverer != nil && c.recoverer.RecoverExpiredCredential(ctx, accountID) {
|
||||
c.sessionExpired.Delete(accountID)
|
||||
return fmt.Errorf("%w;Session 续期成功,本次自动化已停止,下一轮将使用新凭证", sessionErr)
|
||||
}
|
||||
return fmt.Errorf("%w;已停止该账号自动化 API 请求,等待续期或重新登录", sessionErr)
|
||||
}
|
||||
|
||||
func (c *Center) accountTaskSessionBlocked(ctx context.Context, accountID string) (bool, error) {
|
||||
blockedFingerprint, ok := c.sessionExpired.Load(accountID)
|
||||
if !ok {
|
||||
return false, nil
|
||||
}
|
||||
current, err := c.accountCredentialFingerprint(ctx, accountID)
|
||||
if err != nil {
|
||||
return true, err
|
||||
}
|
||||
if current != blockedFingerprint.(string) {
|
||||
c.sessionExpired.Delete(accountID)
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (c *Center) accountCredentialFingerprint(ctx context.Context, accountID string) (string, error) {
|
||||
detail, err := c.store.Cookies.GetDetails(ctx, accountID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if detail == nil {
|
||||
return "", db.ErrNotFound
|
||||
}
|
||||
sum := sha256.Sum256([]byte(detail.Value + "\x00" + detail.MetadataJSON))
|
||||
return fmt.Sprintf("%x", sum[:]), nil
|
||||
}
|
||||
|
||||
func (c *Center) runAutoRate(ctx context.Context, settings db.AccountTaskSettings) (AccountTaskSummary, error) {
|
||||
summary := AccountTaskSummary{TaskType: TaskAutoRate}
|
||||
if c.accountTasks == nil {
|
||||
@@ -125,6 +195,9 @@ func (c *Center) runAutoRate(ctx context.Context, settings db.AccountTaskSetting
|
||||
}
|
||||
_ = c.store.AccountTasks.FinishRun(ctx, runKey, "failed", 0, 1, message, time.Now().UTC().Add(10*time.Minute).Unix())
|
||||
summary.Failed++
|
||||
if mtop.IsSessionExpiredErr(rateErr) {
|
||||
return summary, rateErr
|
||||
}
|
||||
continue
|
||||
}
|
||||
current = c.persistTaskCookies(ctx, settings.CookieID, current, result.UpdatedCookies)
|
||||
@@ -178,6 +251,10 @@ func (c *Center) runAutoPolish(ctx context.Context, settings db.AccountTaskSetti
|
||||
if result != nil && result.Message != "" {
|
||||
lastError = result.Message
|
||||
}
|
||||
if mtop.IsSessionExpiredErr(polishErr) {
|
||||
_ = c.store.AccountTasks.FinishRun(ctx, runKey, "failed", summary.Success, summary.Failed, lastError, 0)
|
||||
return summary, polishErr
|
||||
}
|
||||
continue
|
||||
}
|
||||
current = c.persistTaskCookies(ctx, settings.CookieID, current, result.UpdatedCookies)
|
||||
|
||||
@@ -3,6 +3,7 @@ package automation
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -15,6 +16,8 @@ type fakeAccountTaskClient struct {
|
||||
rateCalls int
|
||||
polishCalls int
|
||||
pending []mtop.PendingRateOrder
|
||||
pendingErr error
|
||||
rateErr error
|
||||
items []mtop.ItemListItem
|
||||
fetchItemsErr error
|
||||
fetchPageSize int
|
||||
@@ -24,11 +27,17 @@ type fakeAccountTaskClient struct {
|
||||
|
||||
func (f *fakeAccountTaskClient) FetchPendingRateOrders(context.Context, string, int, int) (*mtop.PendingRateResult, error) {
|
||||
f.pendingCalls++
|
||||
if f.pendingErr != nil {
|
||||
return nil, f.pendingErr
|
||||
}
|
||||
return &mtop.PendingRateResult{Orders: f.pending}, nil
|
||||
}
|
||||
|
||||
func (f *fakeAccountTaskClient) RateBuyer(context.Context, string, string, string) (*mtop.AccountTaskResult, error) {
|
||||
f.rateCalls++
|
||||
if f.rateErr != nil {
|
||||
return nil, f.rateErr
|
||||
}
|
||||
return &mtop.AccountTaskResult{Success: true, Message: "ok"}, nil
|
||||
}
|
||||
|
||||
@@ -69,6 +78,72 @@ func TestAccountTaskRateIsOrderIdempotent(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccountTaskSessionExpiredRecoversOnceAndBlocksFurtherAPIRequests(t *testing.T) {
|
||||
store, cleanup := newAutomationTestStore(t)
|
||||
defer cleanup()
|
||||
ctx := context.Background()
|
||||
sessionErr := &mtop.SessionExpiredError{API: "自动评价接口", Ret: []string{"FAIL_SYS_SESSION_EXPIRED::Session过期"}}
|
||||
client := &fakeAccountTaskClient{pendingErr: sessionErr}
|
||||
recoverer := &fakeCredentialRecoverer{store: store, fail: true}
|
||||
center := New(store, testSenderProvider{sender: &testSender{}}, nil)
|
||||
center.SetAccountTaskClient(client)
|
||||
center.SetOrderDetailFetcher(recoverer)
|
||||
if err := store.AccountTasks.Upsert(ctx, db.AccountTaskSettings{CookieID: "cid", AutoRateEnabled: true,
|
||||
RateContent: "交易愉快", PolishTime: "03:00"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := center.RunAccountTask(ctx, "cid", TaskAutoRate); err == nil || !mtop.IsSessionExpiredErr(err) {
|
||||
t.Fatalf("首次 session 失效应触发续期并返回原始分类错误: %v", err)
|
||||
}
|
||||
if client.pendingCalls != 1 || recoverer.calls != 1 {
|
||||
t.Fatalf("first calls: api=%d recover=%d want 1/1", client.pendingCalls, recoverer.calls)
|
||||
}
|
||||
if _, err := center.RunAccountTask(ctx, "cid", TaskAutoRate); err == nil || !strings.Contains(err.Error(), "已停止自动化 API 请求") {
|
||||
t.Fatalf("未更新凭证时应保持阻断: %v", err)
|
||||
}
|
||||
if client.pendingCalls != 1 || recoverer.calls != 1 {
|
||||
t.Fatalf("blocked run must not call API/recovery again: api=%d recover=%d", client.pendingCalls, recoverer.calls)
|
||||
}
|
||||
|
||||
if err := store.Cookies.UpdateValueExisting(ctx, "cid", "unb=1; _m_h5_tk=fresh_1; renewed=1"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
client.pendingErr = nil
|
||||
if _, err := center.RunAccountTask(ctx, "cid", TaskAutoRate); err != nil {
|
||||
t.Fatalf("凭证变化后应自动解除阻断: %v", err)
|
||||
}
|
||||
if client.pendingCalls != 2 {
|
||||
t.Fatalf("api calls after credential update=%d want 2", client.pendingCalls)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccountTaskStopsRemainingOrdersOnSessionExpired(t *testing.T) {
|
||||
store, cleanup := newAutomationTestStore(t)
|
||||
defer cleanup()
|
||||
ctx := context.Background()
|
||||
sessionErr := &mtop.SessionExpiredError{API: "评价接口", Ret: []string{"FAIL_SYS_SESSION_EXPIRED::Session过期"}}
|
||||
client := &fakeAccountTaskClient{
|
||||
pending: []mtop.PendingRateOrder{{TradeID: "order-1"}, {TradeID: "order-2"}},
|
||||
rateErr: sessionErr,
|
||||
}
|
||||
recoverer := &fakeCredentialRecoverer{store: store, fail: true}
|
||||
center := New(store, testSenderProvider{sender: &testSender{}}, nil)
|
||||
center.SetAccountTaskClient(client)
|
||||
center.SetOrderDetailFetcher(recoverer)
|
||||
if err := store.AccountTasks.Upsert(ctx, db.AccountTaskSettings{CookieID: "cid", AutoRateEnabled: true,
|
||||
RateContent: "交易愉快", PolishTime: "03:00"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := center.RunAccountTask(ctx, "cid", TaskAutoRate); err == nil {
|
||||
t.Fatal("session expiry must be returned")
|
||||
}
|
||||
if client.rateCalls != 1 || recoverer.calls != 1 {
|
||||
t.Fatalf("remaining orders must stop immediately: rate=%d recover=%d", client.rateCalls, recoverer.calls)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccountTaskPolishRunsOncePerBeijingDay(t *testing.T) {
|
||||
store, cleanup := newAutomationTestStore(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -96,6 +96,9 @@ type Center struct {
|
||||
logger *slog.Logger
|
||||
cookieSrc func(context.Context, string) (string, error)
|
||||
cardLocks sync.Map
|
||||
// sessionExpired 保存检测到 Session 失效时的凭证指纹。在凭证续期或
|
||||
// 重新登录真正改变之前,账号任务不得再次调用任何 MTOP 业务接口。
|
||||
sessionExpired sync.Map
|
||||
}
|
||||
|
||||
// New 构造自动化中心。
|
||||
|
||||
@@ -30,6 +30,53 @@ type TokenCaptchaURLProvider func(ctx context.Context, currentCookies string) (u
|
||||
type tokenCaptchaEngineFunc func(ctx context.Context, cookieID, cookieStr, verificationURL string, headless bool, provider TokenCaptchaURLProvider) (string, error)
|
||||
|
||||
var errTokenCaptchaURLExpired = errors.New("token 风控验证链接已过期")
|
||||
var errTokenCaptchaDirectPageError = errors.New("token 风控页面直接显示错误且没有可验证滑块")
|
||||
|
||||
// TokenCaptchaFailureError 保留自动验证失败时最后实际使用的完整验证地址,
|
||||
// 便于用户复制到本机浏览器中手动完成验证。
|
||||
type TokenCaptchaFailureError struct {
|
||||
VerificationURL string
|
||||
Cause error
|
||||
}
|
||||
|
||||
func (e *TokenCaptchaFailureError) Error() string {
|
||||
if e == nil {
|
||||
return ""
|
||||
}
|
||||
if e.Cause == nil {
|
||||
if strings.TrimSpace(e.VerificationURL) == "" {
|
||||
return "token 风控自动验证失败"
|
||||
}
|
||||
return fmt.Sprintf("token 风控自动验证失败;手动验证地址: %s", e.VerificationURL)
|
||||
}
|
||||
if strings.TrimSpace(e.VerificationURL) == "" {
|
||||
return e.Cause.Error()
|
||||
}
|
||||
return fmt.Sprintf("%v;手动验证地址: %s", e.Cause, e.VerificationURL)
|
||||
}
|
||||
|
||||
func (e *TokenCaptchaFailureError) Unwrap() error {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
return e.Cause
|
||||
}
|
||||
|
||||
// TokenCaptchaManualVerificationURL 从自动验证失败中提取可供用户手动打开的完整地址。
|
||||
func TokenCaptchaManualVerificationURL(err error) string {
|
||||
var failure *TokenCaptchaFailureError
|
||||
if errors.As(err, &failure) {
|
||||
return failure.VerificationURL
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func tokenCaptchaFailure(err error, verificationURL string) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return &TokenCaptchaFailureError{VerificationURL: strings.TrimSpace(verificationURL), Cause: err}
|
||||
}
|
||||
|
||||
// TokenCaptchaRecover solves a token-refresh captcha and returns cookies with x5sec merged in.
|
||||
func (m *Manager) TokenCaptchaRecover(ctx context.Context, cookieID, cookieStr, verificationURL string, headless bool, provider TokenCaptchaURLProvider) (string, error) {
|
||||
@@ -77,8 +124,8 @@ func (m *Manager) TokenCaptchaRecoverWithEngine(ctx context.Context, cookieID, c
|
||||
primaryURL = freshURL
|
||||
}
|
||||
// An expired URL cannot be repaired by replaying it through the fallback.
|
||||
if errors.Is(primaryErr, errTokenCaptchaURLExpired) {
|
||||
return "", "", primaryErr
|
||||
if errors.Is(primaryErr, errTokenCaptchaURLExpired) || errors.Is(primaryErr, errTokenCaptchaDirectPageError) {
|
||||
return "", "", tokenCaptchaFailure(primaryErr, primaryURL)
|
||||
}
|
||||
|
||||
if realMouseRequested() {
|
||||
@@ -87,7 +134,7 @@ func (m *Manager) TokenCaptchaRecoverWithEngine(ctx context.Context, cookieID, c
|
||||
m.logger.Error("CAPTCHA_REAL_MOUSE 已开启但物理鼠标引擎不可用,回退备用滑块逻辑", "goos", runtime.GOOS)
|
||||
}
|
||||
if !drissionFallbackEnabled() {
|
||||
return "", "playwright", primaryErr
|
||||
return "", "playwright", tokenCaptchaFailure(primaryErr, primaryURL)
|
||||
}
|
||||
|
||||
fallbackURL := verificationURL
|
||||
@@ -121,7 +168,10 @@ func (m *Manager) TokenCaptchaRecoverWithEngine(ctx context.Context, cookieID, c
|
||||
if fallbackErr == nil {
|
||||
fallbackErr = fmt.Errorf("备用滑块引擎未获取到新的 x5sec Cookie")
|
||||
}
|
||||
return "", "", fmt.Errorf("Playwright 主引擎失败: %v;备用滑块引擎失败: %w", primaryErr, fallbackErr)
|
||||
return "", "", tokenCaptchaFailure(
|
||||
fmt.Errorf("Playwright 主引擎失败: %v;备用滑块引擎失败: %w", primaryErr, fallbackErr),
|
||||
fallbackURL,
|
||||
)
|
||||
}
|
||||
|
||||
func (m *Manager) tokenCaptchaPlaywrightRecover(ctx context.Context, cookieID, cookieStr, verificationURL string, headless bool, _ TokenCaptchaURLProvider) (string, error) {
|
||||
@@ -176,6 +226,10 @@ func (m *Manager) tokenCaptchaPlaywrightRecover(ctx context.Context, cookieID, c
|
||||
if strings.Contains(content, "STATUS_BREAKPOINT") || strings.Contains(content, "崩溃") {
|
||||
return "", fmt.Errorf("token 风控验证页面崩溃")
|
||||
}
|
||||
if pageErr := tokenCaptchaDirectPageError(page); pageErr != nil {
|
||||
m.logger.Warn("token 风控页面没有可验证滑块,停止自动验证", "cookieID", cookieID, "err", pageErr)
|
||||
return "", pageErr
|
||||
}
|
||||
|
||||
scratch := isScratchCaptcha(content)
|
||||
if err := solveSliderStrict(page, scratch, m.logger, previousX5SecValues, browserDeadline); err != nil {
|
||||
@@ -255,6 +309,47 @@ func captchaURLExpired(content string) bool {
|
||||
return strings.Contains(content, "抱歉,页面访问出现了问题")
|
||||
}
|
||||
|
||||
func tokenCaptchaDirectPageError(page playwright.Page) error {
|
||||
if page == nil {
|
||||
return nil
|
||||
}
|
||||
if _, _, _, err := findSliderElements(page); err == nil {
|
||||
return nil
|
||||
}
|
||||
frames := append([]playwright.Frame{page.MainFrame()}, page.Frames()...)
|
||||
for _, frame := range frames {
|
||||
body, err := frame.QuerySelector("body")
|
||||
if err != nil || body == nil {
|
||||
continue
|
||||
}
|
||||
text, err := body.InnerText()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if tokenCaptchaDirectErrorText(text) {
|
||||
return fmt.Errorf("%w: %s", errTokenCaptchaDirectPageError, truncateSliderText(text))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func tokenCaptchaDirectErrorText(text string) bool {
|
||||
normalized := strings.ToLower(strings.Join(strings.Fields(text), " "))
|
||||
if normalized == "" {
|
||||
return false
|
||||
}
|
||||
for _, marker := range []string{
|
||||
"验证失败", "安全验证未通过", "请求失败", "加载失败", "系统繁忙", "服务异常", "网络异常",
|
||||
"页面异常", "页面出错", "发生错误", "请稍后重试", "something's wrong", "something went wrong",
|
||||
"please refresh and try again", "try again later",
|
||||
} {
|
||||
if strings.Contains(normalized, marker) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func waitForFreshX5SecCookie(ctx context.Context, reader browserCookieReader, previousValues map[string]struct{}, timeout, pollInterval time.Duration) (map[string]string, error) {
|
||||
if timeout <= 0 || pollInterval <= 0 {
|
||||
return nil, fmt.Errorf("等待 x5sec Cookie 的超时和轮询间隔必须大于 0")
|
||||
|
||||
@@ -112,6 +112,10 @@ func (m *Manager) tokenCaptchaCDPFallback(ctx context.Context, cookieID, cookieS
|
||||
if err := sleepUntil(ctx, deadline, secondsDuration(randomFloat(1, 3))); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if pageErr := tokenCaptchaDirectPageError(page); pageErr != nil {
|
||||
m.logger.Warn("备用滑块引擎页面没有可验证滑块,停止自动验证", "cookieID", cookieID, "err", pageErr)
|
||||
return "", pageErr
|
||||
}
|
||||
|
||||
for attempt := 0; attempt < 3; attempt++ {
|
||||
if err := contextDeadlineError(ctx, deadline); err != nil {
|
||||
|
||||
@@ -2,6 +2,7 @@ package browser
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -169,6 +170,43 @@ document.addEventListener('click', event => {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTokenCaptchaDirectErrorPageBrowserIntegration(t *testing.T) {
|
||||
if os.Getenv("RUN_BROWSER_INTEGRATION") != "1" {
|
||||
t.Skip("set RUN_BROWSER_INTEGRATION=1 to exercise direct-error page classification")
|
||||
}
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
_, _ = io.WriteString(w, `<!doctype html><html><head><title>验证码拦截</title></head><body>
|
||||
<div class="errloading">Oops... something's wrong. Please refresh and try again.(error:6T0DWd)</div>
|
||||
</body></html>`)
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
m := NewManager(nil)
|
||||
defer m.Close()
|
||||
if err := m.init(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
browser, err := m.pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
|
||||
Headless: playwright.Bool(true),
|
||||
Args: chromiumLaunchArgs(),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() { _ = browser.Close() }()
|
||||
page, err := browser.NewPage()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := page.Goto(server.URL+"/punish", playwright.PageGotoOptions{WaitUntil: playwright.WaitUntilStateDomcontentloaded}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := tokenCaptchaDirectPageError(page); !errors.Is(err, errTokenCaptchaDirectPageError) {
|
||||
t.Fatalf("无滑块错误页应停止自动验证: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTokenCaptchaCDPFallbackBrowserIntegration(t *testing.T) {
|
||||
if os.Getenv("RUN_BROWSER_INTEGRATION") != "1" {
|
||||
t.Skip("set RUN_BROWSER_INTEGRATION=1 to exercise the direct-CDP Chromium fallback")
|
||||
|
||||
@@ -3,6 +3,7 @@ package browser
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -77,6 +78,49 @@ func TestTokenCaptchaExpiredURLSkipsFallback(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTokenCaptchaDirectErrorPageSkipsFallbackAndKeepsManualURL(t *testing.T) {
|
||||
fallbackCalls := 0
|
||||
verificationURL := "https://h5api.m.goofish.com/punish?x5secdata=full-sensitive-value&action=captcha"
|
||||
m := &Manager{
|
||||
logger: slog.Default(),
|
||||
tokenCaptchaPrimaryFn: func(context.Context, string, string, string, bool, TokenCaptchaURLProvider) (string, error) {
|
||||
return "", fmt.Errorf("%w: Oops... something's wrong", errTokenCaptchaDirectPageError)
|
||||
},
|
||||
tokenCaptchaFallbackFn: func(context.Context, string, string, string, bool, TokenCaptchaURLProvider) (string, error) {
|
||||
fallbackCalls++
|
||||
return "", errors.New("must not run")
|
||||
},
|
||||
}
|
||||
_, engine, err := m.TokenCaptchaRecoverWithEngine(context.Background(), "cid", "unb=1", verificationURL, true, nil)
|
||||
if !errors.Is(err, errTokenCaptchaDirectPageError) || engine != "" || fallbackCalls != 0 {
|
||||
t.Fatalf("engine=%q fallback=%d err=%v", engine, fallbackCalls, err)
|
||||
}
|
||||
if got := TokenCaptchaManualVerificationURL(err); got != verificationURL || !strings.Contains(err.Error(), verificationURL) {
|
||||
t.Fatalf("manual URL=%q err=%v", got, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTokenCaptchaSliderFailureReportsLatestFallbackURL(t *testing.T) {
|
||||
t.Setenv("CAPTCHA_DRISSIONPAGE_FALLBACK_ENABLED", "true")
|
||||
freshURL := "https://h5api.m.goofish.com/punish?x5secdata=latest-full-value&action=captcha"
|
||||
m := &Manager{
|
||||
logger: slog.Default(),
|
||||
tokenCaptchaPrimaryFn: func(context.Context, string, string, string, bool, TokenCaptchaURLProvider) (string, error) {
|
||||
return "", errors.New("slider failed three times")
|
||||
},
|
||||
tokenCaptchaFallbackFn: func(context.Context, string, string, string, bool, TokenCaptchaURLProvider) (string, error) {
|
||||
return "", errors.New("fallback slider failed three times")
|
||||
},
|
||||
}
|
||||
provider := func(context.Context, string) (string, bool, string, error) {
|
||||
return freshURL, false, "unb=1; _m_h5_tk=fresh", nil
|
||||
}
|
||||
_, _, err := m.TokenCaptchaRecoverWithEngine(context.Background(), "cid", "unb=1", "https://old.example/punish", true, provider)
|
||||
if err == nil || TokenCaptchaManualVerificationURL(err) != freshURL || !strings.Contains(err.Error(), freshURL) {
|
||||
t.Fatalf("err=%v manual=%q", err, TokenCaptchaManualVerificationURL(err))
|
||||
}
|
||||
}
|
||||
|
||||
func TestTokenCaptchaExpiredURLRefreshesAfterPrimaryCloses(t *testing.T) {
|
||||
primaryCalls := 0
|
||||
providerCalls := 0
|
||||
|
||||
@@ -140,3 +140,20 @@ func TestX5SecValuesCollectsAllDomains(t *testing.T) {
|
||||
t.Fatal("缺少 two")
|
||||
}
|
||||
}
|
||||
|
||||
func TestTokenCaptchaDirectErrorTextRequiresAnErrorPrompt(t *testing.T) {
|
||||
for _, text := range []string{
|
||||
"验证失败,点击框体重试(error:YzRQd)",
|
||||
"Oops... something's wrong. Please refresh and try again.(error:6T0DWd)",
|
||||
"系统繁忙,请稍后重试",
|
||||
} {
|
||||
if !tokenCaptchaDirectErrorText(text) {
|
||||
t.Fatalf("应识别无滑块错误提示 %q", text)
|
||||
}
|
||||
}
|
||||
for _, text := range []string{"请按住滑块,拖动到最右边", "验证码加载中,请稍候", "验证码拦截"} {
|
||||
if tokenCaptchaDirectErrorText(text) {
|
||||
t.Fatalf("正常滑块提示不应识别为错误页 %q", text)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ type ItemPublishBatch struct {
|
||||
DefaultCookieID string // 默认发布账号(明细行未指定账号时回退到此)
|
||||
Filename string // 原始上传文件名
|
||||
UploadDir string // 图片资源目录(发布时读取商品图片的根目录)
|
||||
LocationJSON string // 批次统一使用的发货地 JSON
|
||||
Status string // 批次状态:pending/running/completed/partially_failed/failed
|
||||
TotalCount int // 明细行总数(Recount 维护)
|
||||
SuccessCount int // 成功数(Recount 维护)
|
||||
@@ -66,6 +67,9 @@ type ItemPublishBatchRow struct {
|
||||
// 明细行的 quantity/postage_mode/status/images_json/raw_json/automation_json 缺省值在此补齐。
|
||||
// total_count 取 len(rows),success/failed 初始为 0。
|
||||
func (b *ItemPublishBatches) Create(ctx context.Context, batch *ItemPublishBatch, rows []ItemPublishBatchRow) error {
|
||||
if strings.TrimSpace(batch.LocationJSON) == "" {
|
||||
batch.LocationJSON = "{}"
|
||||
}
|
||||
tx, err := b.DB.BeginTx(ctx, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -73,10 +77,10 @@ func (b *ItemPublishBatches) Create(ctx context.Context, batch *ItemPublishBatch
|
||||
defer tx.Rollback()
|
||||
if _, err := tx.ExecContext(ctx,
|
||||
`INSERT INTO item_publish_batches
|
||||
(id,user_id,default_cookie_id,filename,upload_dir,status,total_count,success_count,failed_count)
|
||||
VALUES (?,?,?,?,?,?,?,?,?)`,
|
||||
(id,user_id,default_cookie_id,filename,upload_dir,location_json,status,total_count,success_count,failed_count)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?)`,
|
||||
batch.ID, batch.UserID, batch.DefaultCookieID, batch.Filename, batch.UploadDir,
|
||||
batch.Status, len(rows), 0, 0); err != nil {
|
||||
batch.LocationJSON, batch.Status, len(rows), 0, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, row := range rows {
|
||||
@@ -119,11 +123,11 @@ func (b *ItemPublishBatches) Create(ctx context.Context, batch *ItemPublishBatch
|
||||
func (b *ItemPublishBatches) Get(ctx context.Context, userID int64, id string) (*ItemPublishBatch, error) {
|
||||
var out ItemPublishBatch
|
||||
err := b.DB.QueryRowContext(ctx,
|
||||
`SELECT id,user_id,default_cookie_id,filename,upload_dir,status,total_count,success_count,failed_count,
|
||||
`SELECT id,user_id,default_cookie_id,filename,upload_dir,COALESCE(location_json,'{}'),status,total_count,success_count,failed_count,
|
||||
COALESCE(worker_token,''),COALESCE(lease_expires_at,0),
|
||||
created_at,updated_at
|
||||
FROM item_publish_batches WHERE id=? AND user_id=?`, id, userID).Scan(
|
||||
&out.ID, &out.UserID, &out.DefaultCookieID, &out.Filename, &out.UploadDir, &out.Status,
|
||||
&out.ID, &out.UserID, &out.DefaultCookieID, &out.Filename, &out.UploadDir, &out.LocationJSON, &out.Status,
|
||||
&out.TotalCount, &out.SuccessCount, &out.FailedCount, &out.WorkerToken, &out.LeaseExpiresAt,
|
||||
&out.CreatedAt, &out.UpdatedAt)
|
||||
if err != nil {
|
||||
@@ -140,7 +144,7 @@ func (b *ItemPublishBatches) ListForUser(ctx context.Context, userID int64, limi
|
||||
if limit <= 0 || limit > 100 {
|
||||
limit = 20
|
||||
}
|
||||
rows, err := b.DB.QueryContext(ctx, `SELECT id,user_id,default_cookie_id,filename,upload_dir,status,
|
||||
rows, err := b.DB.QueryContext(ctx, `SELECT id,user_id,default_cookie_id,filename,upload_dir,COALESCE(location_json,'{}'),status,
|
||||
total_count,success_count,failed_count,COALESCE(worker_token,''),COALESCE(lease_expires_at,0),created_at,updated_at
|
||||
FROM item_publish_batches WHERE user_id=? ORDER BY created_at DESC,id DESC LIMIT ?`, userID, limit)
|
||||
if err != nil {
|
||||
@@ -150,7 +154,7 @@ func (b *ItemPublishBatches) ListForUser(ctx context.Context, userID int64, limi
|
||||
var out []ItemPublishBatch
|
||||
for rows.Next() {
|
||||
var batch ItemPublishBatch
|
||||
if err := rows.Scan(&batch.ID, &batch.UserID, &batch.DefaultCookieID, &batch.Filename, &batch.UploadDir,
|
||||
if err := rows.Scan(&batch.ID, &batch.UserID, &batch.DefaultCookieID, &batch.Filename, &batch.UploadDir, &batch.LocationJSON,
|
||||
&batch.Status, &batch.TotalCount, &batch.SuccessCount, &batch.FailedCount, &batch.WorkerToken,
|
||||
&batch.LeaseExpiresAt, &batch.CreatedAt, &batch.UpdatedAt); err != nil {
|
||||
return nil, err
|
||||
@@ -165,7 +169,7 @@ func (b *ItemPublishBatches) Recoverable(ctx context.Context, now int64, limit i
|
||||
if limit <= 0 {
|
||||
limit = 20
|
||||
}
|
||||
rows, err := b.DB.QueryContext(ctx, `SELECT id,user_id,default_cookie_id,filename,upload_dir,status,
|
||||
rows, err := b.DB.QueryContext(ctx, `SELECT id,user_id,default_cookie_id,filename,upload_dir,COALESCE(location_json,'{}'),status,
|
||||
total_count,success_count,failed_count,COALESCE(worker_token,''),COALESCE(lease_expires_at,0),created_at,updated_at
|
||||
FROM item_publish_batches b
|
||||
WHERE (b.status IN ('running','canceling') AND (b.lease_expires_at=0 OR b.lease_expires_at<?))
|
||||
@@ -179,7 +183,7 @@ func (b *ItemPublishBatches) Recoverable(ctx context.Context, now int64, limit i
|
||||
var out []ItemPublishBatch
|
||||
for rows.Next() {
|
||||
var batch ItemPublishBatch
|
||||
if err := rows.Scan(&batch.ID, &batch.UserID, &batch.DefaultCookieID, &batch.Filename, &batch.UploadDir,
|
||||
if err := rows.Scan(&batch.ID, &batch.UserID, &batch.DefaultCookieID, &batch.Filename, &batch.UploadDir, &batch.LocationJSON,
|
||||
&batch.Status, &batch.TotalCount, &batch.SuccessCount, &batch.FailedCount, &batch.WorkerToken,
|
||||
&batch.LeaseExpiresAt, &batch.CreatedAt, &batch.UpdatedAt); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -129,7 +129,7 @@ func TestLatestMigrationsDownUpSQLite(t *testing.T) {
|
||||
}
|
||||
goose.SetBaseFS(migrationsFS)
|
||||
// 依次回滚最新版本到 13,再整体升级。
|
||||
for i := 0; i < 14; i++ {
|
||||
for i := 0; i < 15; i++ {
|
||||
if err := goose.Down(d, "migrations/sqlite"); err != nil {
|
||||
t.Fatalf("down migration #%d: %v", i+1, err)
|
||||
}
|
||||
@@ -155,6 +155,9 @@ func TestLatestMigrationsDownUpSQLite(t *testing.T) {
|
||||
if columnExists(t, d, "orders", "deleted_at") {
|
||||
t.Fatal("orders.deleted_at should be removed after migration 27 down")
|
||||
}
|
||||
if columnExists(t, d, "item_publish_batches", "location_json") {
|
||||
t.Fatal("item_publish_batches.location_json should be removed after migration 28 down")
|
||||
}
|
||||
for _, table := range []string{"account_task_settings", "account_task_runs", "chat_sessions", "chat_messages"} {
|
||||
if tableExists(t, d, table) {
|
||||
t.Fatalf("table should be removed after migration 24 down: %s", table)
|
||||
@@ -178,6 +181,7 @@ func TestLatestMigrationsDownUpSQLite(t *testing.T) {
|
||||
{"default_reply_records", "text_sent"},
|
||||
{"account_tokens", "cookie_fingerprint"},
|
||||
{"item_publish_batch_rows", "category_json"},
|
||||
{"item_publish_batches", "location_json"},
|
||||
{"account_task_settings", "auto_rate_enabled"},
|
||||
{"account_task_runs", "run_key"},
|
||||
{"chat_sessions", "unread_count"},
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE item_publish_batches ADD COLUMN location_json LONGTEXT NULL;
|
||||
UPDATE item_publish_batches SET location_json='{}' WHERE location_json IS NULL;
|
||||
ALTER TABLE item_publish_batches MODIFY COLUMN location_json LONGTEXT NOT NULL;
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE item_publish_batches DROP COLUMN location_json;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE item_publish_batches ADD COLUMN location_json TEXT NOT NULL DEFAULT '{}';
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE item_publish_batches DROP COLUMN location_json;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE item_publish_batches ADD COLUMN location_json TEXT NOT NULL DEFAULT '{}';
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE item_publish_batches DROP COLUMN location_json;
|
||||
@@ -771,7 +771,7 @@ func TestMultiDB_LatestMigrationsDownUp(t *testing.T) {
|
||||
t.Fatalf("set goose dialect: %v", err)
|
||||
}
|
||||
goose.SetBaseFS(migrationsFS)
|
||||
for i := 0; i < 14; i++ {
|
||||
for i := 0; i < 15; i++ {
|
||||
if err := goose.Down(tg.store.DB, "migrations/"+subdir); err != nil {
|
||||
t.Fatalf("migration down #%d: %v", i+1, err)
|
||||
}
|
||||
@@ -791,6 +791,9 @@ func TestMultiDB_LatestMigrationsDownUp(t *testing.T) {
|
||||
if columnExistsForDialect(t, tg.store.DB, tg.dialect, "item_publish_batch_rows", "category_json") {
|
||||
t.Fatal("item_publish_batch_rows.category_json should be removed after down")
|
||||
}
|
||||
if columnExistsForDialect(t, tg.store.DB, tg.dialect, "item_publish_batches", "location_json") {
|
||||
t.Fatal("item_publish_batches.location_json should be removed after down")
|
||||
}
|
||||
for _, table := range []string{"account_task_settings", "account_task_runs", "chat_sessions", "chat_messages"} {
|
||||
if tableExistsForDialect(t, tg.store.DB, tg.dialect, table) {
|
||||
t.Fatalf("table should be removed after migration 24 down: %s", table)
|
||||
@@ -816,6 +819,7 @@ func TestMultiDB_LatestMigrationsDownUp(t *testing.T) {
|
||||
{"automation_runs", "action_started"},
|
||||
{"account_tokens", "cookie_fingerprint"},
|
||||
{"item_publish_batch_rows", "category_json"},
|
||||
{"item_publish_batches", "location_json"},
|
||||
{"item_info", "deleted_at"},
|
||||
{"automation_rules", "deleted_at"},
|
||||
{"orders", "deleted_at"},
|
||||
|
||||
@@ -443,9 +443,19 @@ func (a *Account) Run(parent context.Context) error {
|
||||
return err
|
||||
}
|
||||
if mtop.IsSessionExpiredErr(err) {
|
||||
reason := "登录凭证已失效,请重新登录"
|
||||
a.logger.Warn("session 已失效,停止消息登录", "err", err)
|
||||
reason := "登录凭证已失效,正在立即续期"
|
||||
a.logger.Warn("token API 检测到 Session 过期,停止重试并开始即时续期", "err", err)
|
||||
a.clearTokenCache(ctx)
|
||||
a.setRuntimeState(RuntimeReconnecting, reason)
|
||||
a.notifyOffline(ctx, reason+":"+errString(err))
|
||||
if a.handler != nil && a.handler.OnPasswordLoginRefresh(ctx, a.CookieID) {
|
||||
a.reloadCookieFromDB(ctx)
|
||||
a.clearCurrentToken()
|
||||
a.resetFailures()
|
||||
a.setRuntimeState(RuntimeConnecting, "Session 续期成功,正在重新连接")
|
||||
continue
|
||||
}
|
||||
reason = "登录凭证已失效,自动续期失败,请重新扫码登录"
|
||||
a.setRuntimeState(RuntimeAuthExpired, reason)
|
||||
a.notifyOffline(ctx, reason+":"+errString(err))
|
||||
return err
|
||||
|
||||
@@ -188,8 +188,17 @@ func (s *Scheduler) executeLoginRenew(ctx context.Context) {
|
||||
func (s *Scheduler) loginRenewOne(ctx context.Context, batchID string, account db.RenewalAccount) {
|
||||
credentialUnlock := s.store.LockAccountCredentials(account.ID)
|
||||
credentialUpdated := false
|
||||
sessionExpired := false
|
||||
defer func() {
|
||||
credentialUnlock()
|
||||
if sessionExpired {
|
||||
s.logger.Warn("loginuser.get 检测到 Session 过期,开始即时续期", "account", account.ID)
|
||||
if s.refresher != nil && s.refresher.OnPasswordLoginRefresh(ctx, account.ID) {
|
||||
s.wakeCredentialBlockedAutomation(ctx, account.ID)
|
||||
s.restartAfterCredentialUpdate(ctx, account.ID, account.Enabled, "Session 即时续期")
|
||||
}
|
||||
return
|
||||
}
|
||||
if credentialUpdated {
|
||||
s.wakeCredentialBlockedAutomation(ctx, account.ID)
|
||||
s.restartAfterCredentialUpdate(ctx, account.ID, account.Enabled, "登录态续期")
|
||||
@@ -267,6 +276,9 @@ func (s *Scheduler) loginRenewOne(ctx context.Context, batchID string, account d
|
||||
if res.Status == mtop.LoginStatusSessionExpired || res.Status == mtop.LoginStatusTokenEmpty {
|
||||
s.markSessionExpired(account.ID)
|
||||
}
|
||||
if res.Status == mtop.LoginStatusSessionExpired {
|
||||
sessionExpired = true
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Scheduler) executeAPICookieRenew(ctx context.Context) {
|
||||
|
||||
@@ -400,6 +400,26 @@ func TestLoginRenewPreservesValidTokenCache(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoginRenewSessionExpiredStartsImmediateRecovery(t *testing.T) {
|
||||
store, cleanup := newSchedulerTestStore(t)
|
||||
defer cleanup()
|
||||
ctx := context.Background()
|
||||
account := createSchedulerAccount(t, store, "cid-login-session-expired", "unb=1; _m_h5_tk=old_1")
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
_, _ = w.Write([]byte(`{"ret":["FAIL_SYS_SESSION_EXPIRED::Session过期"],"data":{}}`))
|
||||
}))
|
||||
defer srv.Close()
|
||||
refresher := &schedulerFakePasswordRefresher{}
|
||||
s := NewScheduler(store, nil, refresher, nil)
|
||||
s.mtop = &mtop.ClientImpl{HTTPClient: srv.Client(), LoginUserURL: srv.URL}
|
||||
|
||||
s.loginRenewOne(ctx, "batch-login-session-expired", account)
|
||||
|
||||
if got := refresher.calls.Load(); got != 1 {
|
||||
t.Fatalf("session 过期应在登录态检查返回后立即触发一次续期,calls=%d", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoginRenewPersistsAuthoritativeSessionBeforeParseError(t *testing.T) {
|
||||
store, cleanup := newSchedulerTestStore(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -27,9 +27,14 @@ func (s *Server) listCards(w http.ResponseWriter, r *http.Request) {
|
||||
sess := auth.SessionFromContext(r.Context())
|
||||
cards, err := s.Store.Cards.AllForUser(r.Context(), sess.UserID)
|
||||
if err != nil {
|
||||
s.Logger.Error("查询卡密失败", "user_id", sess.UserID, "err", err)
|
||||
writeErr(w, http.StatusInternalServerError, "查询失败")
|
||||
return
|
||||
}
|
||||
if cards == nil {
|
||||
s.Logger.Debug("用户没有卡密,返回空列表", "user_id", sess.UserID)
|
||||
cards = []db.CardFull{}
|
||||
}
|
||||
writeJSON(w, http.StatusOK, cards)
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@ func (s *Server) listChatSessions(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
hasMore, nextCursor = page.HasMore, page.NextCursor
|
||||
} else {
|
||||
s.recoverExpiredMTOPSession(r.Context(), accountID, fetchErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,6 +82,8 @@ func (s *Server) listChatSessions(w http.ResponseWriter, r *http.Request) {
|
||||
defer resolveCancel()
|
||||
jobs := make(chan int)
|
||||
var workers sync.WaitGroup
|
||||
var sessionOnce sync.Once
|
||||
var sessionErr error
|
||||
for worker := 0; worker < 8; worker++ {
|
||||
workers.Add(1)
|
||||
go func() {
|
||||
@@ -88,6 +92,13 @@ func (s *Server) listChatSessions(w http.ResponseWriter, r *http.Request) {
|
||||
infoCtx, cancel := context.WithTimeout(resolveCtx, 3*time.Second)
|
||||
info, infoErr := client.FetchChatUserInfo(infoCtx, cookieValue, rows[index].ChatID)
|
||||
cancel()
|
||||
if mtop.IsSessionExpiredErr(infoErr) {
|
||||
sessionOnce.Do(func() {
|
||||
sessionErr = infoErr
|
||||
resolveCancel()
|
||||
})
|
||||
continue
|
||||
}
|
||||
if infoErr != nil || info == nil {
|
||||
continue
|
||||
}
|
||||
@@ -115,6 +126,9 @@ func (s *Server) listChatSessions(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
close(jobs)
|
||||
workers.Wait()
|
||||
if sessionErr != nil {
|
||||
s.recoverExpiredMTOPSession(r.Context(), accountID, sessionErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{"sessions": rows, "has_more": hasMore, "next_cursor": nextCursor})
|
||||
@@ -283,6 +297,8 @@ func (s *Server) resolveSelectedChatIdentity(ctx context.Context, accountID stri
|
||||
if info.AvatarURL != "" {
|
||||
session.BuyerAvatar = info.AvatarURL
|
||||
}
|
||||
} else if err != nil {
|
||||
s.recoverExpiredMTOPSession(ctx, accountID, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -839,6 +839,7 @@ func (s *Server) refreshAccountProfile(ctx context.Context, d *db.CookieDetail)
|
||||
s.updateRunningCookie(ctx, d.ID, runtimeCookie)
|
||||
}
|
||||
if callErr != nil {
|
||||
s.recoverExpiredMTOPSession(ctx, d.ID, callErr)
|
||||
if s.Logger != nil {
|
||||
s.Logger.Warn("刷新账号资料失败", "account", d.ID, "err", callErr)
|
||||
}
|
||||
|
||||
@@ -89,6 +89,15 @@ func (s *Server) publishItem(w http.ResponseWriter, r *http.Request) {
|
||||
writeErr(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
var location mtop.PublishLocation
|
||||
var selectedLocation *mtop.PublishLocation
|
||||
if rawLocation := strings.TrimSpace(r.FormValue("location")); rawLocation != "" {
|
||||
if err := json.Unmarshal([]byte(rawLocation), &location); err != nil {
|
||||
writeErr(w, http.StatusBadRequest, "发货地格式错误,请重新定位")
|
||||
return
|
||||
}
|
||||
selectedLocation = &location
|
||||
}
|
||||
credentialUnlock := s.Store.LockAccountCredentials(cookieID)
|
||||
latest, err := s.Store.Cookies.GetDetails(r.Context(), cookieID)
|
||||
if err != nil || latest == nil || latest.UserID != userID || !hasStoredCookieCredential(latest) {
|
||||
@@ -110,6 +119,7 @@ func (s *Server) publishItem(w http.ResponseWriter, r *http.Request) {
|
||||
PostageMode: postageMode,
|
||||
PostageCents: postageCents,
|
||||
Virtual: true,
|
||||
Location: selectedLocation,
|
||||
Images: images,
|
||||
})
|
||||
runtimeCookie := ""
|
||||
@@ -141,6 +151,7 @@ func (s *Server) publishItem(w http.ResponseWriter, r *http.Request) {
|
||||
if responseCookieErr != nil {
|
||||
callErr = errors.Join(callErr, fmt.Errorf("保存发布响应 Cookie: %w", responseCookieErr))
|
||||
}
|
||||
s.recoverExpiredMTOPSession(r.Context(), cookieID, callErr)
|
||||
var perr *mtop.PublishError
|
||||
if errors.As(callErr, &perr) {
|
||||
status := http.StatusBadGateway
|
||||
@@ -372,6 +383,7 @@ func (s *Server) syncItemsFromAccount(w http.ResponseWriter, r *http.Request) {
|
||||
} else if valueChanged {
|
||||
s.updateRunningCookie(r.Context(), req.CookieID, value)
|
||||
}
|
||||
s.recoverExpiredMTOPSession(r.Context(), req.CookieID, callErr)
|
||||
writeErr(w, http.StatusBadGateway, callErr.Error())
|
||||
return
|
||||
}
|
||||
@@ -379,7 +391,7 @@ func (s *Server) syncItemsFromAccount(w http.ResponseWriter, r *http.Request) {
|
||||
if res.UpdatedCookies != "" {
|
||||
detailCookies = res.UpdatedCookies
|
||||
}
|
||||
s.enrichSyncedItemMultiSpec(mtopCtx, client, detailCookies, req.CookieID, res.Items)
|
||||
detailErr := s.enrichSyncedItemMultiSpec(mtopCtx, client, detailCookies, req.CookieID, res.Items)
|
||||
runtimeCookie := ""
|
||||
runtimeCookieChanged := false
|
||||
value, valueChanged, handled, persistErr := s.persistMTopCookieSessionLocked(r.Context(), latest, cookieSession)
|
||||
@@ -408,6 +420,11 @@ func (s *Server) syncItemsFromAccount(w http.ResponseWriter, r *http.Request) {
|
||||
if runtimeCookieChanged {
|
||||
s.updateRunningCookie(r.Context(), req.CookieID, runtimeCookie)
|
||||
}
|
||||
if detailErr != nil {
|
||||
s.recoverExpiredMTOPSession(r.Context(), req.CookieID, detailErr)
|
||||
writeErr(w, http.StatusBadGateway, detailErr.Error())
|
||||
return
|
||||
}
|
||||
syncResult, syncErr := s.syncSyncedItems(r.Context(), req.CookieID, res.Items)
|
||||
if syncErr != nil {
|
||||
if s.Logger != nil {
|
||||
@@ -466,6 +483,7 @@ func (s *Server) syncItemsPageFromAccount(w http.ResponseWriter, r *http.Request
|
||||
} else if valueChanged {
|
||||
s.updateRunningCookie(r.Context(), req.CookieID, value)
|
||||
}
|
||||
s.recoverExpiredMTOPSession(r.Context(), req.CookieID, callErr)
|
||||
writeErr(w, http.StatusBadGateway, callErr.Error())
|
||||
return
|
||||
}
|
||||
@@ -473,7 +491,7 @@ func (s *Server) syncItemsPageFromAccount(w http.ResponseWriter, r *http.Request
|
||||
if res.UpdatedCookies != "" {
|
||||
detailCookies = res.UpdatedCookies
|
||||
}
|
||||
s.enrichSyncedItemMultiSpec(mtopCtx, client, detailCookies, req.CookieID, res.Items)
|
||||
detailErr := s.enrichSyncedItemMultiSpec(mtopCtx, client, detailCookies, req.CookieID, res.Items)
|
||||
runtimeCookie := ""
|
||||
runtimeCookieChanged := false
|
||||
value, valueChanged, handled, persistErr := s.persistMTopCookieSessionLocked(r.Context(), latest, cookieSession)
|
||||
@@ -502,6 +520,11 @@ func (s *Server) syncItemsPageFromAccount(w http.ResponseWriter, r *http.Request
|
||||
if runtimeCookieChanged {
|
||||
s.updateRunningCookie(r.Context(), req.CookieID, runtimeCookie)
|
||||
}
|
||||
if detailErr != nil {
|
||||
s.recoverExpiredMTOPSession(r.Context(), req.CookieID, detailErr)
|
||||
writeErr(w, http.StatusBadGateway, detailErr.Error())
|
||||
return
|
||||
}
|
||||
saved := s.saveSyncedItems(r.Context(), req.CookieID, res.Items)
|
||||
writeJSON(w, http.StatusOK, map[string]any{
|
||||
"success": true,
|
||||
@@ -582,10 +605,10 @@ func (s *Server) syncSyncedItems(ctx context.Context, cookieID string, items []m
|
||||
return s.Store.Items.SyncFromRemote(ctx, cookieID, rows)
|
||||
}
|
||||
|
||||
func (s *Server) enrichSyncedItemMultiSpec(ctx context.Context, client mtop.Client, cookies, cookieID string, items []mtop.ItemListItem) {
|
||||
func (s *Server) enrichSyncedItemMultiSpec(ctx context.Context, client mtop.Client, cookies, cookieID string, items []mtop.ItemListItem) error {
|
||||
fetcher, ok := client.(mtop.ItemDetailFetcher)
|
||||
if !ok {
|
||||
return
|
||||
return nil
|
||||
}
|
||||
for index := range items {
|
||||
if items[index].IsMultiSpec || s.Store.Items.IsMultiSpec(ctx, cookieID, items[index].ID) {
|
||||
@@ -594,6 +617,9 @@ func (s *Server) enrichSyncedItemMultiSpec(ctx context.Context, client mtop.Clie
|
||||
}
|
||||
isMultiSpec, err := fetcher.DetectItemMultiSpec(ctx, cookies, items[index].ID)
|
||||
if err != nil {
|
||||
if mtop.IsSessionExpiredErr(err) {
|
||||
return err
|
||||
}
|
||||
if s.Logger != nil {
|
||||
s.Logger.Warn("识别商品多规格状态失败", "cookie_id", cookieID, "item_id", items[index].ID, "err", err)
|
||||
}
|
||||
@@ -601,6 +627,7 @@ func (s *Server) enrichSyncedItemMultiSpec(ctx context.Context, client mtop.Clie
|
||||
}
|
||||
items[index].IsMultiSpec = isMultiSpec
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) listItemsByCookie(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -241,8 +241,6 @@ func TestPublishItemSuccess(t *testing.T) {
|
||||
switch {
|
||||
case strings.Contains(u, "stream-upload.goofish.com"):
|
||||
respBody = `{"object":{"url":"https://img.alicdn.com/published.png","pix":"800_800"}}`
|
||||
case strings.Contains(u, "mtop.taobao.idle.local.poi.get"):
|
||||
respBody = `{"ret":["SUCCESS::调用成功"],"data":{"commonAddresses":[{"address":"北京"}]}}`
|
||||
case strings.Contains(u, "mtop.taobao.idle.kgraph.property.recommend"):
|
||||
respBody = `{"ret":["SUCCESS::调用成功"],"data":{"categoryPredictResult":{"catId":"99","catName":"数码"}}}`
|
||||
case strings.Contains(u, "mtop.idle.pc.idleitem.publish"):
|
||||
@@ -330,8 +328,6 @@ func TestPublishItemStockPermissionMissing(t *testing.T) {
|
||||
switch {
|
||||
case strings.Contains(u, "stream-upload.goofish.com"):
|
||||
respBody = `{"object":{"url":"https://img.alicdn.com/published.png","pix":"800_800"}}`
|
||||
case strings.Contains(u, "mtop.taobao.idle.local.poi.get"):
|
||||
respBody = `{"ret":["SUCCESS::调用成功"],"data":{"commonAddresses":[{"address":"北京"}]}}`
|
||||
case strings.Contains(u, "mtop.taobao.idle.kgraph.property.recommend"):
|
||||
respBody = `{"ret":["SUCCESS::调用成功"],"data":{"categoryPredictResult":{"catId":"99","catName":"数码"}}}`
|
||||
case strings.Contains(u, "mtop.idle.pc.idleitem.publish"):
|
||||
|
||||
@@ -194,6 +194,15 @@ func (s *Server) previewItemPublishBatch(w http.ResponseWriter, r *http.Request)
|
||||
ChannelCatID: strings.TrimSpace(r.FormValue("fallback_channel_category_id")),
|
||||
TBCatID: strings.TrimSpace(r.FormValue("fallback_tb_category_id")),
|
||||
}
|
||||
var batchLocation mtop.PublishLocation
|
||||
locationJSON := strings.TrimSpace(r.FormValue("location"))
|
||||
if locationJSON != "" {
|
||||
if json.Unmarshal([]byte(locationJSON), &batchLocation) != nil {
|
||||
writeErr(w, http.StatusBadRequest, "发货地格式错误,请重新定位")
|
||||
return
|
||||
}
|
||||
}
|
||||
locationBytes, _ := json.Marshal(batchLocation)
|
||||
hasDefaultCategory := fallbackCategory.CatID != "" || fallbackCategory.CatName != "" || fallbackCategory.ChannelCatID != "" || fallbackCategory.TBCatID != ""
|
||||
if hasDefaultCategory && (fallbackCategory.CatID == "" || fallbackCategory.CatName == "" || fallbackCategory.ChannelCatID == "") {
|
||||
writeErr(w, http.StatusBadRequest, "默认类目信息不完整,请重新通过关键词获取")
|
||||
@@ -331,6 +340,7 @@ func (s *Server) previewItemPublishBatch(w http.ResponseWriter, r *http.Request)
|
||||
DefaultCookieID: defaultCookieID,
|
||||
Filename: sourceName,
|
||||
UploadDir: uploadDir,
|
||||
LocationJSON: string(locationBytes),
|
||||
Status: "preview",
|
||||
}, rows); err != nil {
|
||||
writeErr(w, http.StatusInternalServerError, "保存预检结果失败")
|
||||
@@ -695,11 +705,12 @@ func (s *Server) runItemPublishBatch(ctx context.Context, userID int64, batchID,
|
||||
if !claimed {
|
||||
continue
|
||||
}
|
||||
if err := s.publishBatchRow(ctx, userID, client, row, workerToken); err != nil {
|
||||
if rowErr := s.publishBatchRow(ctx, userID, client, row, workerToken); rowErr != nil {
|
||||
sessionExpired := mtop.IsSessionExpiredErr(rowErr)
|
||||
statusCtx, statusCancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
status, _ := s.Store.PublishBatches.BatchStatus(statusCtx, batchID)
|
||||
statusCancel()
|
||||
message, failureKind := publishBatchFailure(err, status)
|
||||
message, failureKind := publishBatchFailure(rowErr, status)
|
||||
wctx, cancel := publishStatusContext(ctx)
|
||||
marked, markErr := s.Store.PublishBatches.MarkClaimedRowFailed(wctx, row.ID, workerToken, message, failureKind)
|
||||
cancel()
|
||||
@@ -709,6 +720,10 @@ func (s *Server) runItemPublishBatch(ctx context.Context, userID int64, batchID,
|
||||
}
|
||||
return
|
||||
}
|
||||
if sessionExpired {
|
||||
s.finishInterruptedPublishBatch(ctx, userID, batchID, workerToken)
|
||||
return
|
||||
}
|
||||
}
|
||||
wctx, cancel = publishStatusContext(ctx)
|
||||
if err := s.Store.PublishBatches.Recount(wctx, batchID); err != nil && s.Logger != nil {
|
||||
@@ -854,6 +869,18 @@ func (s *Server) publishBatchRow(ctx context.Context, userID int64, client mtop.
|
||||
if err != nil {
|
||||
return errors.New("批量任务不存在")
|
||||
}
|
||||
var location mtop.PublishLocation
|
||||
locationJSON := strings.TrimSpace(batch.LocationJSON)
|
||||
if locationJSON == "" {
|
||||
locationJSON = "{}"
|
||||
}
|
||||
if err := json.Unmarshal([]byte(locationJSON), &location); err != nil {
|
||||
return errors.New("批量任务发货地配置损坏,请重新创建任务")
|
||||
}
|
||||
var selectedLocation *mtop.PublishLocation
|
||||
if strings.TrimSpace(location.DivisionID) != "" {
|
||||
selectedLocation = &location
|
||||
}
|
||||
cookieValue, err := s.cookieValueForUser(ctx, userID, row.CookieID)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -919,6 +946,7 @@ func (s *Server) publishBatchRow(ctx context.Context, userID int64, client mtop.
|
||||
PostageMode: row.PostageMode,
|
||||
PostageCents: postageCents,
|
||||
Virtual: true,
|
||||
Location: selectedLocation,
|
||||
PreferredCategory: preferredCategory,
|
||||
Images: images,
|
||||
})
|
||||
@@ -954,6 +982,7 @@ func (s *Server) publishBatchRow(ctx context.Context, userID int64, client mtop.
|
||||
s.updateRunningCookie(ctx, row.CookieID, runtimeCookie)
|
||||
}
|
||||
if err != nil {
|
||||
s.recoverExpiredMTOPSession(ctx, row.CookieID, err)
|
||||
if ctx.Err() != nil {
|
||||
return &uncertainRemotePublishError{err: fmt.Errorf("取消时远端发布结果未知: %w", err)}
|
||||
}
|
||||
@@ -1308,6 +1337,10 @@ func (s *Server) validatePublishAutomation(ctx context.Context, userID int64, cf
|
||||
}
|
||||
|
||||
func publishBatchToMap(batch *db.ItemPublishBatch, rows []db.ItemPublishBatchRow) map[string]any {
|
||||
locationJSON := strings.TrimSpace(batch.LocationJSON)
|
||||
if locationJSON == "" {
|
||||
locationJSON = "{}"
|
||||
}
|
||||
outRows := make([]map[string]any, 0, len(rows))
|
||||
pending := 0
|
||||
running := 0
|
||||
@@ -1343,6 +1376,7 @@ func publishBatchToMap(batch *db.ItemPublishBatch, rows []db.ItemPublishBatchRow
|
||||
"id": batch.ID, "status": batch.Status, "filename": batch.Filename,
|
||||
"total": batch.TotalCount, "success": batch.SuccessCount, "failed": batch.FailedCount,
|
||||
"pending": pending, "running": running, "retryable": retryable, "rows": outRows,
|
||||
"location": json.RawMessage(locationJSON),
|
||||
"created_at": batch.CreatedAt, "updated_at": batch.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@ func (s *Server) refreshOrders(w http.ResponseWriter, r *http.Request) {
|
||||
discovered, listUpdated, softDeleted, failed := 0, 0, 0, 0
|
||||
results := []map[string]any{}
|
||||
newOrderIDs := make(map[string]struct{})
|
||||
sessionExpiredAccounts := make(map[string]struct{})
|
||||
if fetcher, ok := s.mtopClient().(mtop.SoldOrderFetcher); ok {
|
||||
for cid := range all {
|
||||
credentialUnlock := s.Store.LockAccountCredentials(cid)
|
||||
@@ -218,6 +219,10 @@ func (s *Server) refreshOrders(w http.ResponseWriter, r *http.Request) {
|
||||
if persistErr == nil && valueChanged {
|
||||
s.updateRunningCookie(r.Context(), cid, value)
|
||||
}
|
||||
if mtop.IsSessionExpiredErr(discoveryErr) {
|
||||
sessionExpiredAccounts[cid] = struct{}{}
|
||||
s.recoverExpiredMTOPSession(r.Context(), cid, discoveryErr)
|
||||
}
|
||||
discovered += accountDiscovered
|
||||
listUpdated += accountUpdated
|
||||
for orderID := range accountNewIDs {
|
||||
@@ -250,6 +255,9 @@ func (s *Server) refreshOrders(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
ordersByCookie := map[string][]refreshTarget{}
|
||||
for cid := range all {
|
||||
if _, blocked := sessionExpiredAccounts[cid]; blocked {
|
||||
continue
|
||||
}
|
||||
for offset := 0; ; offset += 500 {
|
||||
rows, err := s.Store.Orders.ByCookiePage(r.Context(), cid, 500, offset)
|
||||
if err != nil {
|
||||
@@ -312,6 +320,7 @@ func (s *Server) refreshOrders(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
updated, noChange := 0, 0
|
||||
for cid, targets := range ordersByCookie {
|
||||
accountSessionExpired := false
|
||||
for _, chunk := range chunkRefreshTargets(targets, refreshOrderChunkSize) {
|
||||
credentialUnlock := s.Store.LockAccountCredentials(cid)
|
||||
latest, latestErr := s.Store.Cookies.GetDetails(r.Context(), cid)
|
||||
@@ -323,6 +332,7 @@ func (s *Server) refreshOrders(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 3*time.Minute)
|
||||
mtopCtx, cookieSession := withMTopCookieSnapshot(ctx, latest)
|
||||
var sessionErr error
|
||||
for _, target := range chunk {
|
||||
detail, fetchErr := detailFetcher.FetchOrderDetail(mtopCtx, latest.Value, target.OrderID)
|
||||
if fetchErr != nil || detail == nil {
|
||||
@@ -336,6 +346,10 @@ func (s *Server) refreshOrders(w http.ResponseWriter, r *http.Request) {
|
||||
"success": false,
|
||||
"error": message,
|
||||
})
|
||||
if mtop.IsSessionExpiredErr(fetchErr) {
|
||||
sessionErr = fetchErr
|
||||
break
|
||||
}
|
||||
continue
|
||||
}
|
||||
newStatus := db.NormalizeOrderStatus(detail.OrderStatus)
|
||||
@@ -377,6 +391,14 @@ func (s *Server) refreshOrders(w http.ResponseWriter, r *http.Request) {
|
||||
} else if valueChanged {
|
||||
s.updateRunningCookie(r.Context(), cid, value)
|
||||
}
|
||||
if sessionErr != nil {
|
||||
s.recoverExpiredMTOPSession(r.Context(), cid, sessionErr)
|
||||
accountSessionExpired = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if accountSessionExpired {
|
||||
continue
|
||||
}
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{
|
||||
@@ -544,6 +566,7 @@ func (s *Server) refreshSingleOrder(w http.ResponseWriter, r *http.Request) {
|
||||
s.updateRunningCookie(r.Context(), cookieID, runtimeCookie)
|
||||
}
|
||||
if callErr != nil {
|
||||
s.recoverExpiredMTOPSession(r.Context(), cookieID, callErr)
|
||||
writeErr(w, http.StatusBadGateway, callErr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -311,8 +311,6 @@ func TestRunItemPublishBatch_Success(t *testing.T) {
|
||||
switch {
|
||||
case strings.Contains(u, "stream-upload.goofish.com"):
|
||||
body = `{"object":{"url":"https://img.alicdn.com/published.png","pix":"800_800"}}`
|
||||
case strings.Contains(u, "mtop.taobao.idle.local.poi.get"):
|
||||
body = `{"ret":["SUCCESS::调用成功"],"data":{"commonAddresses":[{"address":"北京"}]}}`
|
||||
case strings.Contains(u, "mtop.taobao.idle.kgraph.property.recommend"):
|
||||
body = `{"ret":["SUCCESS::调用成功"],"data":{}}`
|
||||
case strings.Contains(u, "mtop.idle.pc.idleitem.publish"):
|
||||
|
||||
@@ -16,6 +16,8 @@ import (
|
||||
"xianyu-go/internal/xianyu/protocol"
|
||||
)
|
||||
|
||||
const qrLoginGenerateTimeout = 2 * time.Minute
|
||||
|
||||
// mountQRLoginReal 扫码登录端点(纯 HTTP,不需要浏览器)。
|
||||
func (s *Server) mountQRLoginReal(r chi.Router) {
|
||||
r.Post("/qr-login/generate", s.generateQRLogin)
|
||||
@@ -32,12 +34,26 @@ func (s *Server) generateQRLogin(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
s.cleanupQRLoginSessions()
|
||||
sessionID, qrCodeURL, err := s.QRLogin.GenerateQRCode(r.Context())
|
||||
// 风控后的闲鱼匿名 token 接口偶尔会明显变慢。二维码生成需要连续完成
|
||||
// token、登录参数和二维码请求,不能沿用前端通用接口的短超时。
|
||||
generateCtx, cancel := context.WithTimeout(r.Context(), qrLoginGenerateTimeout)
|
||||
defer cancel()
|
||||
sessionID, qrCodeURL, err := s.QRLogin.GenerateQRCode(generateCtx)
|
||||
if err != nil {
|
||||
s.Logger.Error("生成二维码失败", "err", err)
|
||||
message := "生成二维码失败: " + err.Error()
|
||||
switch {
|
||||
case errors.Is(err, context.Canceled):
|
||||
s.Logger.Info("二维码生成请求已取消")
|
||||
message = "二维码生成请求已取消,请重新获取"
|
||||
case errors.Is(err, context.DeadlineExceeded):
|
||||
s.Logger.Error("生成二维码超时", "err", err)
|
||||
message = "闲鱼二维码接口响应超时,请稍后重新获取"
|
||||
default:
|
||||
s.Logger.Error("生成二维码失败", "err", err)
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{
|
||||
"success": false,
|
||||
"message": "生成二维码失败: " + err.Error(),
|
||||
"message": message,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -15,14 +15,16 @@ import (
|
||||
)
|
||||
|
||||
type fakeQRLoginService struct {
|
||||
status map[string]any
|
||||
generateErr error
|
||||
completeCookies string
|
||||
completeUNB string
|
||||
completeErr error
|
||||
status map[string]any
|
||||
generateErr error
|
||||
generateDeadline time.Time
|
||||
completeCookies string
|
||||
completeUNB string
|
||||
completeErr error
|
||||
}
|
||||
|
||||
func (f *fakeQRLoginService) GenerateQRCode(context.Context) (string, string, error) {
|
||||
func (f *fakeQRLoginService) GenerateQRCode(ctx context.Context) (string, string, error) {
|
||||
f.generateDeadline, _ = ctx.Deadline()
|
||||
if f.generateErr != nil {
|
||||
return "", "", f.generateErr
|
||||
}
|
||||
@@ -54,7 +56,8 @@ func (f *fakeQRLoginService) CompleteVerification(context.Context, string) (stri
|
||||
func TestGenerateQRLogin(t *testing.T) {
|
||||
srv, _, cleanup := newTestServer(t)
|
||||
defer cleanup()
|
||||
srv.QRLogin = &fakeQRLoginService{}
|
||||
qr := &fakeQRLoginService{}
|
||||
srv.QRLogin = qr
|
||||
h := srv.Router()
|
||||
cookie := loginHelper(t, h)
|
||||
|
||||
@@ -70,6 +73,10 @@ func TestGenerateQRLogin(t *testing.T) {
|
||||
if res["success"] != true || res["session_id"] == nil || res["session_id"] == "" {
|
||||
t.Fatalf("生成二维码响应异常: %+v", res)
|
||||
}
|
||||
remaining := time.Until(qr.generateDeadline)
|
||||
if remaining < qrLoginGenerateTimeout-time.Second || remaining > qrLoginGenerateTimeout {
|
||||
t.Fatalf("二维码生成超时窗口=%v want≈%v", remaining, qrLoginGenerateTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
func TestQRLoginSessionCannotBeReadByAnotherUser(t *testing.T) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"xianyu-go/internal/chat"
|
||||
"xianyu-go/internal/db"
|
||||
"xianyu-go/internal/notify"
|
||||
appversion "xianyu-go/internal/version"
|
||||
"xianyu-go/internal/webui"
|
||||
"xianyu-go/internal/xianyu/mtop"
|
||||
"xianyu-go/internal/xianyu/qrlogin"
|
||||
@@ -128,6 +129,21 @@ func (s *Server) mtopClient() mtop.Client {
|
||||
return mtop.NewClient()
|
||||
}
|
||||
|
||||
// recoverExpiredMTOPSession 是 HTTP/API 入口的统一 Session 失效出口。
|
||||
// 各调用点必须先保存响应 Cookie 并释放账号凭证锁,再进入续期,避免锁反转。
|
||||
func (s *Server) recoverExpiredMTOPSession(ctx context.Context, cookieID string, err error) bool {
|
||||
if !mtop.IsSessionExpiredErr(err) {
|
||||
return false
|
||||
}
|
||||
if s.Logger != nil {
|
||||
s.Logger.Warn("MTOP API 检测到 Session 过期,停止业务请求并开始即时续期", "account", cookieID, "err", err)
|
||||
}
|
||||
if s.Manager == nil {
|
||||
return false
|
||||
}
|
||||
return s.Manager.RecoverExpiredCredential(ctx, cookieID)
|
||||
}
|
||||
|
||||
// Router 构建完整路由树。
|
||||
func (s *Server) Router() http.Handler {
|
||||
r := chi.NewRouter()
|
||||
@@ -349,7 +365,13 @@ func (s *Server) health(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusServiceUnavailable, map[string]any{"status": "degraded", "database": "unavailable"})
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{"status": "ok", "database": "ok"})
|
||||
writeJSON(w, http.StatusOK, map[string]any{
|
||||
"status": "ok",
|
||||
"database": "ok",
|
||||
"version": appversion.Version,
|
||||
"commit": appversion.ShortCommit(),
|
||||
"build_time": appversion.BuildTime,
|
||||
})
|
||||
}
|
||||
|
||||
// 各分组 mount*Real 方法在 handlers 文件中实现;为避免单文件过大,按业务域分文件。
|
||||
|
||||
@@ -390,6 +390,9 @@ func TestHealth(t *testing.T) {
|
||||
if rec.Code != 200 {
|
||||
t.Fatalf("health status=%d", rec.Code)
|
||||
}
|
||||
if !strings.Contains(rec.Body.String(), `"version":"dev"`) {
|
||||
t.Fatalf("health response missing build version: %s", rec.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestHealthReportsUnavailableDatabase(t *testing.T) {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Package version exposes build metadata injected by release builds.
|
||||
package version
|
||||
|
||||
import "strings"
|
||||
|
||||
var (
|
||||
Version = "dev"
|
||||
Commit = "unknown"
|
||||
BuildTime = "unknown"
|
||||
)
|
||||
|
||||
// ShortCommit returns a compact commit identifier suitable for UI display.
|
||||
func ShortCommit() string {
|
||||
commit := strings.TrimSpace(Commit)
|
||||
if len(commit) > 12 {
|
||||
return commit[:12]
|
||||
}
|
||||
if commit == "" {
|
||||
return "unknown"
|
||||
}
|
||||
return commit
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package version
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestShortCommit(t *testing.T) {
|
||||
original := Commit
|
||||
t.Cleanup(func() { Commit = original })
|
||||
|
||||
Commit = "0123456789abcdef"
|
||||
if got := ShortCommit(); got != "0123456789ab" {
|
||||
t.Fatalf("ShortCommit() = %q", got)
|
||||
}
|
||||
}
|
||||
+90
-80
@@ -1,4 +1,4 @@
|
||||
import{r as s}from"./react-vendor-C_od1ZSF.js";/**
|
||||
import{r as h}from"./react-vendor-C_od1ZSF.js";/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
@@ -13,394 +13,404 @@ import{r as s}from"./react-vendor-C_od1ZSF.js";/**
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const m=s.forwardRef(({color:t="currentColor",size:a=24,strokeWidth:c=2,absoluteStrokeWidth:o,className:y="",children:h,iconNode:p,...d},i)=>s.createElement("svg",{ref:i,...v,width:a,height:a,stroke:t,strokeWidth:o?Number(c)*24/Number(a):c,className:k("lucide",y),...!h&&!x(d)&&{"aria-hidden":"true"},...d},[...p.map(([r,l])=>s.createElement(r,l)),...Array.isArray(h)?h:[h]]));/**
|
||||
*/const m=h.forwardRef(({color:t="currentColor",size:a=24,strokeWidth:c=2,absoluteStrokeWidth:o,className:s="",children:y,iconNode:i,...d},p)=>h.createElement("svg",{ref:p,...v,width:a,height:a,stroke:t,strokeWidth:o?Number(c)*24/Number(a):c,className:k("lucide",s),...!y&&!x(d)&&{"aria-hidden":"true"},...d},[...i.map(([r,l])=>h.createElement(r,l)),...Array.isArray(y)?y:[y]]));/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const e=(t,a)=>{const c=s.forwardRef(({className:o,...y},h)=>s.createElement(m,{ref:h,iconNode:a,className:k(`lucide-${M(n(t))}`,`lucide-${t}`,o),...y}));return c.displayName=n(t),c};/**
|
||||
*/const e=(t,a)=>{const c=h.forwardRef(({className:o,...s},y)=>h.createElement(m,{ref:y,iconNode:a,className:k(`lucide-${M(n(t))}`,`lucide-${t}`,o),...s}));return c.displayName=n(t),c};/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const g=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],I1=e("activity",g);/**
|
||||
*/const g=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],O1=e("activity",g);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const u=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],O1=e("arrow-right",u);/**
|
||||
*/const u=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Z1=e("arrow-right",u);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const $=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Z1=e("bell",$);/**
|
||||
*/const $=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],K1=e("bell",$);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const N=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],F1=e("bot",N);/**
|
||||
*/const N=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],G1=e("bot",N);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const f=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],K1=e("box",f);/**
|
||||
*/const f=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],Q1=e("box",f);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const w=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],Q1=e("calendar-clock",w);/**
|
||||
*/const w=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],J1=e("calendar-clock",w);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const b=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],G1=e("check-check",b);/**
|
||||
*/const z=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],X1=e("check-check",z);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const z=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],J1=e("check",z);/**
|
||||
*/const b=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Y1=e("check",b);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const q=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],X1=e("chevron-down",q);/**
|
||||
*/const q=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],e2=e("chevron-down",q);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const C=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Y1=e("chevron-left",C);/**
|
||||
*/const C=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],a2=e("chevron-left",C);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const A=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],e2=e("chevron-right",A);/**
|
||||
*/const j=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],t2=e("chevron-right",j);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const j=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],a2=e("circle-alert",j);/**
|
||||
*/const A=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],c2=e("circle-alert",A);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const H=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],t2=e("circle-check",H);/**
|
||||
*/const H=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],o2=e("circle-check",H);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const V=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],c2=e("circle-dashed",V);/**
|
||||
*/const V=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],y2=e("circle-dashed",V);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const L=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],o2=e("clock-3",L);/**
|
||||
*/const L=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],h2=e("clock-3",L);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const P=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],h2=e("clock",P);/**
|
||||
*/const P=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],s2=e("clock",P);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const S=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],s2=e("cloud-upload",S);/**
|
||||
*/const S=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],d2=e("cloud-upload",S);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const U=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],y2=e("code",U);/**
|
||||
*/const U=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],n2=e("code",U);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const E=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],d2=e("copy",E);/**
|
||||
*/const E=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],k2=e("copy",E);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const B=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],n2=e("credit-card",B);/**
|
||||
*/const B=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],i2=e("credit-card",B);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const D=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],k2=e("database",D);/**
|
||||
*/const D=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],p2=e("database",D);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const R=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],p2=e("dollar-sign",R);/**
|
||||
*/const R=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],r2=e("dollar-sign",R);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const T=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],i2=e("external-link",T);/**
|
||||
*/const T=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],l2=e("external-link",T);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const W=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],r2=e("eye-off",W);/**
|
||||
*/const W=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],M2=e("eye-off",W);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const I=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],l2=e("eye",I);/**
|
||||
*/const F=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],_2=e("eye",F);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const O=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],M2=e("file-down",O);/**
|
||||
*/const I=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],x2=e("file-down",I);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const Z=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],_2=e("file-text",Z);/**
|
||||
*/const O=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],v2=e("file-text",O);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const F=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],x2=e("funnel",F);/**
|
||||
*/const Z=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],m2=e("funnel",Z);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const K=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],v2=e("gift",K);/**
|
||||
*/const K=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],g2=e("gift",K);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const Q=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],m2=e("image-plus",Q);/**
|
||||
*/const G=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],u2=e("git-commit-horizontal",G);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const G=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],g2=e("image",G);/**
|
||||
*/const Q=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],$2=e("image-plus",Q);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const J=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],u2=e("key",J);/**
|
||||
*/const J=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],N2=e("image",J);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const X=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],$2=e("layers",X);/**
|
||||
*/const X=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],f2=e("key",X);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const Y=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],N2=e("layout-dashboard",Y);/**
|
||||
*/const Y=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],w2=e("layers",Y);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const e1=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],f2=e("link-2",e1);/**
|
||||
*/const e1=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],z2=e("layout-dashboard",e1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const a1=[["path",{d:"M16 5H3",key:"m91uny"}],["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 19H3",key:"zzsher"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]],w2=e("list-plus",a1);/**
|
||||
*/const a1=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],b2=e("link-2",a1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const t1=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],b2=e("loader-circle",t1);/**
|
||||
*/const t1=[["path",{d:"M16 5H3",key:"m91uny"}],["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 19H3",key:"zzsher"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]],q2=e("list-plus",t1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const c1=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],z2=e("lock-keyhole",c1);/**
|
||||
*/const c1=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],C2=e("loader-circle",c1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const o1=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],q2=e("lock",o1);/**
|
||||
*/const o1=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],j2=e("locate-fixed",o1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const h1=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],C2=e("log-out",h1);/**
|
||||
*/const y1=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],A2=e("lock-keyhole",y1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const s1=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],A2=e("mail",s1);/**
|
||||
*/const h1=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],H2=e("lock",h1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const y1=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]],j2=e("message-circle-more",y1);/**
|
||||
*/const s1=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],V2=e("log-out",s1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const d1=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],H2=e("message-circle",d1);/**
|
||||
*/const d1=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],L2=e("mail",d1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const n1=[["path",{d:"M14 14a2 2 0 0 0 2-2V8h-2",key:"1r06pg"}],["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M8 14a2 2 0 0 0 2-2V8H8",key:"1jzu5j"}]],V2=e("message-square-quote",n1);/**
|
||||
*/const n1=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]],P2=e("message-circle-more",n1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const k1=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],L2=e("package-check",k1);/**
|
||||
*/const k1=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],S2=e("message-circle",k1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const p1=[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],P2=e("package-plus",p1);/**
|
||||
*/const i1=[["path",{d:"M14 14a2 2 0 0 0 2-2V8h-2",key:"1r06pg"}],["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M8 14a2 2 0 0 0 2-2V8H8",key:"1jzu5j"}]],U2=e("message-square-quote",i1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const i1=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],S2=e("package",i1);/**
|
||||
*/const p1=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],E2=e("package-check",p1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const r1=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],U2=e("pen",r1);/**
|
||||
*/const r1=[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],B2=e("package-plus",r1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const l1=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],E2=e("play",l1);/**
|
||||
*/const l1=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],D2=e("package",l1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const M1=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],B2=e("plus",M1);/**
|
||||
*/const M1=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],R2=e("pen",M1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const _1=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],D2=e("power",_1);/**
|
||||
*/const _1=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],T2=e("play",_1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const x1=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],R2=e("qr-code",x1);/**
|
||||
*/const x1=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],W2=e("plus",x1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const v1=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],T2=e("refresh-cw",v1);/**
|
||||
*/const v1=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],F2=e("power",v1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const m1=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],W2=e("save",m1);/**
|
||||
*/const m1=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],I2=e("qr-code",m1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const g1=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],I2=e("search",g1);/**
|
||||
*/const g1=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],O2=e("refresh-cw",g1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const u1=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],O2=e("send",u1);/**
|
||||
*/const u1=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Z2=e("save",u1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const $1=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Z2=e("settings",$1);/**
|
||||
*/const $1=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],K2=e("search",$1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const N1=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],F2=e("shield-check",N1);/**
|
||||
*/const N1=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],G2=e("send",N1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const f1=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],K2=e("shopping-bag",f1);/**
|
||||
*/const f1=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Q2=e("settings",f1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const w1=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],Q2=e("shopping-cart",w1);/**
|
||||
*/const w1=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],J2=e("shield-check",w1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const b1=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],G2=e("sliders-horizontal",b1);/**
|
||||
*/const z1=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],X2=e("shopping-bag",z1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const z1=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],J2=e("smile",z1);/**
|
||||
*/const b1=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],Y2=e("shopping-cart",b1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const q1=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],X2=e("sparkles",q1);/**
|
||||
*/const q1=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],e0=e("sliders-horizontal",q1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const C1=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],Y2=e("square-pen",C1);/**
|
||||
*/const C1=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],a0=e("smile",C1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const A1=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],e0=e("trash-2",A1);/**
|
||||
*/const j1=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],t0=e("sparkles",j1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const j1=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],a0=e("trending-up",j1);/**
|
||||
*/const A1=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],c0=e("square-pen",A1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const H1=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],t0=e("triangle-alert",H1);/**
|
||||
*/const H1=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],o0=e("trash-2",H1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const V1=[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]],c0=e("truck",V1);/**
|
||||
*/const V1=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],y0=e("trending-up",V1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const L1=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],o0=e("upload",L1);/**
|
||||
*/const L1=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],h0=e("triangle-alert",L1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const P1=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],h0=e("user-round",P1);/**
|
||||
*/const P1=[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]],s0=e("truck",P1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const S1=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],s0=e("user",S1);/**
|
||||
*/const S1=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],d0=e("upload",S1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const U1=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],y0=e("users",U1);/**
|
||||
*/const U1=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],n0=e("user-round",U1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const E1=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],d0=e("webhook",E1);/**
|
||||
*/const E1=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],k0=e("user",E1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const B1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],n0=e("wifi-off",B1);/**
|
||||
*/const B1=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],i0=e("users",B1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const D1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],k0=e("wifi",D1);/**
|
||||
*/const D1=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],p0=e("webhook",D1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const R1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],p0=e("x",R1);/**
|
||||
*/const R1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],r0=e("wifi-off",R1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const T1=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],i0=e("zap",T1);export{x2 as $,I1 as A,K1 as B,n2 as C,p2 as D,i2 as E,c0 as F,I2 as G,Y2 as H,o0 as I,G2 as J,u2 as K,N2 as L,j2 as M,d2 as N,_2 as O,S2 as P,R2 as Q,T2 as R,K2 as S,a0 as T,y0 as U,g2 as V,w2 as W,p0 as X,M2 as Y,i0 as Z,y2 as _,Z1 as a,P2 as a0,s2 as a1,t2 as a2,c2 as a3,f2 as a4,O1 as a5,k2 as a6,X1 as a7,F2 as a8,z2 as a9,h0 as aa,o2 as ab,v2 as ac,$2 as ad,O2 as ae,A2 as af,d0 as ag,k0 as ah,n0 as ai,G1 as aj,J2 as ak,m2 as al,q2 as am,Z2 as b,e2 as c,Y1 as d,C2 as e,a2 as f,Q2 as g,L2 as h,t0 as i,b2 as j,V2 as k,E2 as l,X2 as m,Q1 as n,W2 as o,s0 as p,J1 as q,F1 as r,H2 as s,h2 as t,U2 as u,D2 as v,e0 as w,r2 as x,l2 as y,B2 as z};
|
||||
*/const T1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],l0=e("wifi",T1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const W1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],M0=e("x",W1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const F1=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],_0=e("zap",F1);export{n2 as $,O1 as A,Q1 as B,i2 as C,r2 as D,l2 as E,s0 as F,u2 as G,K2 as H,c0 as I,d0 as J,f2 as K,z2 as L,P2 as M,e0 as N,k2 as O,D2 as P,I2 as Q,O2 as R,X2 as S,y0 as T,i0 as U,v2 as V,N2 as W,M0 as X,q2 as Y,_0 as Z,x2 as _,K1 as a,m2 as a0,B2 as a1,d2 as a2,o2 as a3,y2 as a4,b2 as a5,Z1 as a6,j2 as a7,p2 as a8,e2 as a9,J2 as aa,A2 as ab,n0 as ac,h2 as ad,g2 as ae,w2 as af,G2 as ag,L2 as ah,p0 as ai,l0 as aj,r0 as ak,X1 as al,a0 as am,$2 as an,H2 as ao,Q2 as b,t2 as c,a2 as d,V2 as e,c2 as f,Y2 as g,E2 as h,h0 as i,C2 as j,U2 as k,T2 as l,t0 as m,J1 as n,Z2 as o,k0 as p,Y1 as q,G1 as r,S2 as s,s2 as t,R2 as u,F2 as v,o0 as w,M2 as x,_2 as y,W2 as z};
|
||||
@@ -1 +0,0 @@
|
||||
*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(147 197 253 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(147 197 253 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:rgb(var(--color-neutral-200) / 1)}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}input::placeholder,textarea::placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.\!container{width:100%!important}.container{width:100%}@media(min-width:640px){.\!container{max-width:640px!important}.container{max-width:6Line truncated
|
||||
@@ -1,19 +0,0 @@
|
||||
import{j as e,r,b as qe,c as ia,d as Ea}from"./react-vendor-C_od1ZSF.js";import{L as Ta,U as oa,M as as,C as ls,B as ca,S as da,Z as rs,a as yt,b as hs,c as gs,d as bs,e as Ma,f as nt,A as Cs,D as qa,g as Ss,P as xa,h as $t,E as ma,T as Fa,i as Ba,j as Re,X as De,k as za,l as Ua,m as fs,n as pa,o as Ye,Q as Kt,p as mt,q as Ze,r as ft,s as At,t as Ls,R as Ue,u as ua,v as Wa,w as Ke,K as Va,x as xt,y as rt,z as at,F as Os,G as Nt,H as jt,I as It,J as ha,N as Ja,O as Is,V as As,W as Qa,Y as Ga,_ as Ka,$ as Ha,a0 as Ht,a1 as Tt,a2 as ns,a3 as Za,a4 as Ya,a5 as is,a6 as Xa,a7 as el,a8 as Rt,a9 as Rs,aa as Wt,ab as ga,ac as tl,ad as sl,ae as Jt,af as ba,ag as al,ah as ll,ai as rl,aj as nl,ak as il,al as ol,am as $s}from"./icons-vendor-DjsKcZkz.js";import{R as Mt,B as cl,X as Ps,Y as Ds,T as qt,a as dl,C as Zt,A as xl,b as ml,c as pl,P as Es,d as Ts,L as ul}from"./charts-vendor-BxxJOyEX.js";import"./vendor-D-Edl3pr.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const p of document.querySelectorAll('link[rel="modulepreload"]'))i(p);new MutationObserver(p=>{for(const v of p)if(v.type==="childList")for(const k of v.addedNodes)k.tagName==="LINK"&&k.rel==="modulepreload"&&i(k)}).observe(document,{childList:!0,subtree:!0});function l(p){const v={};return p.integrity&&(v.integrity=p.integrity),p.referrerPolicy&&(v.referrerPolicy=p.referrerPolicy),p.crossOrigin==="use-credentials"?v.credentials="include":p.crossOrigin==="anonymous"?v.credentials="omit":v.credentials="same-origin",v}function i(p){if(p.ep)return;p.ep=!0;const v=l(p);fetch(p.href,v)}})();const hl=({className:t="w-full h-full text-white"})=>e.jsx("svg",{className:t,viewBox:"0 0 256 256","aria-hidden":"true",children:e.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:e.jsx("path",{d:"M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z",fill:"currentColor"})})}),os=({sizeClass:t="w-12 h-12",logoClassName:s="w-full h-full text-white"})=>e.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[e.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),e.jsxs("div",{className:`relative ${t} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[e.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"rgb(var(--color-brand))"}),e.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),e.jsx("path",{d:"M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23.51 12.25 L 27.29
Line truncated
|
||||
|
||||
例如:回复时保持礼貌专业、使用简洁的语言、强调产品质量等`,className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-bold text-blue-900 mb-2 flex items-center gap-2",children:[e.jsx(hs,{className:"w-4 h-4"}),"AI如何工作"]}),e.jsxs("ul",{className:"text-xs text-blue-800 space-y-1",children:[e.jsx("li",{children:"• 自动识别买家的砍价请求"}),e.jsx("li",{children:"• 根据设定的策略智能回复"}),e.jsx("li",{children:"• 在合理范围内同意降价或礼貌拒绝"}),e.jsx("li",{children:"• 保持专业友好的沟通风格"})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:Et,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:I,children:"取消"}),e.jsxs("button",{onClick:Ge,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:I,children:[I?e.jsx(Re,{className:"w-4 h-4 animate-spin"}):e.jsx(Ye,{className:"w-4 h-4"}),I?"保存中...":"保存"]})]})})]})}),document.body)]})},Zr=t=>({total:Number((t==null?void 0:t.total)||0),success_count:Number((t==null?void 0:t.success_count)||0),failed_count:Number((t==null?void 0:t.failed_count)||0),results:Array.isArray(t==null?void 0:t.results)?t.results.map(s=>({order_id:String((s==null?void 0:s.order_id)||"unknown"),success:(s==null?void 0:s.success)===!0,message:String((s==null?void 0:s.message)||"")})):[]}),Yr=t=>(t==null?void 0:t.results.filter(s=>!s.success))||[],Ks=({status:t})=>{const s={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},l={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${s[t]||s.cancelled}`,children:l[t]||t})},Xr=()=>{const[t,s]=r.useState([]),[l,i]=r.useState([]),[p,v]=r.useState([]),[k,D]=r.useState({}),[g,R]=r.useState("all"),[y,J]=r.useState(""),[Z,pe]=r.useState(""),[de,N]=r.useState(""),q=r.useRef(0),[xe,Q]=r.useState(1),[Y,U]=r.useState(1),[be,ge]=r.useState(!1),[L,G]=r.useState(!1),[ae,H]=r.useState(!1),[me,$]=r.useState(!1),[T,X]=r.useState(null),[M,se]=r.useState(null),[we,je]=r.useState({}),[F,d]=r.useState(!1),[h,W]=r.useState(""),[w,ee]=r.useState(!1),[ie,_e]=r.useState(null),[$e,fe]=r.useState(null),[c,_]=r.useState(null),[re,x]=r.useState(!1),[u,I]=r.useState(null),[A,K]=r.useState(null),P=async()=>{const m=++q.current;ge(!0);try{const E=await Jl(y||void 0,g,xe,20,de);if(m!==q.current)return;s(E.data),U(E.total_pages)}catch(E){console.error("加载订单失败:",E)}finally{m===q.current&&ge(!1)}},ke=(m,E,oe)=>{if(oe&&oe.trim())return oe;if(k[`${m}:${E}`])return k[`${m}:${E}`];const ne=l.find(We=>{if(oe&&We.item_title){const et=oe.toLowerCase(),tt=We.item_title.toLowerCase();return tt.includes(et)||et.includes(tt)}return!1});return ne!=null&&ne.item_title?ne.item_title:"未知商品"},Oe=m=>{const E={};m.forEach(oe=>{oe.item_id&&(E[`${oe.cookie_id}:${oe.item_id}`]=oe.item_title||oe.item_id)}),D(E)};r.useEffect(()=>{const m=window.setTimeout(()=>{Q(1),N(Z.trim())},300);return()=>window.clearTimeout(m)},[Z]),r.useEffect(()=>{P()},[y,g,xe,de]),r.useEffect(()=>{Promise.all([Pt(),_t()]).then(([m,E])=>{v(m),i(E),Oe(E)}).catch(m=>{console.error("加载商品列表失败:",m)})},[]);const Pe=r.useMemo(()=>new Map(p.map(m=>[m.id,m])),[p]),Ee=m=>{const E=Pe.get(m),oe=(E==null?void 0:E.remark)||(E==null?void 0:E.nickname);return oe?`${oe} · ${m.slice(0,6)}`:`账号 ${m.slice(0,8)}`},Te=m=>{const E=Pe.get(m);return(E==null?void 0:E.remark)||(E==null?void 0:E.nickname)||"未命名账号"},f=async()=>{ge(!0);try{const m=await Kl(y||void 0,g);await P(),m!=null&&m.message&&alert(m.message)}catch(m){console.error("同步订单失败:",m),alert((m==null?void 0:m.message)||"同步失败,请重试")}finally{ge(!1)}},C=m=>{W(m),_e(null),d(!0)},B=async m=>{var E;ee(!0),_e(null);try{const oe=await Zl([h],m),ne=(E=oe==null?void 0:oe.results)==null?void 0:E[0];ne!=null&&ne.success?(_e({success:!0,message:ne.message}),P()):_e({success:!1,message:(ne==null?void 0:ne.message)||"发货失败"})}catch(oe){_e({success:!1,message:(oe==null?void 0:oe.message)||"请求失败"})}finally{ee(!1)}},V=m=>{X(m),G(!0)},Ce=m=>{se({...m}),H(!0)},Me=async()=>{if(!(!M||!M.order_id))try{const m={};M.status!==void 0&&(m.order_status=M.status),M.buyer_id!==void 0&&(m.buyer_id=M.buyer_id),M.amount!==void 0&&(m.amount=M.amount),M.receiver_name!==void 0&&(m.receiver_name=M.receiver_name),M.receiver_phone!=
Line truncated
|
||||
VIP-MONTH-002
|
||||
VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map(A=>A.map(K=>`"${String(K).replace(/"/g,'""')}"`).join(",")).join(`
|
||||
`),x=new Blob(["\uFEFF"+re],{type:"text/csv;charset=utf-8"}),u=URL.createObjectURL(x),I=document.createElement("a");I.href=u,I.download="卡密组批量导入模板.csv",document.body.appendChild(I),I.click(),I.remove(),URL.revokeObjectURL(u)},_e=async()=>{if(q){be(!0),Y(null);try{const c=await lr(q);if(Y(c),c.created>0){const _=await st();s(_)}}catch(c){Y({error:(c==null?void 0:c.message)||"上传失败"})}finally{be(!1)}}},$e=async()=>{if(!(!ge||!G.trim())){be(!0),me(null);try{const c=await rr(ge,G);me({added:c.added}),ae("");const _=await st();s(_)}catch(c){alert("追加失败:"+((c==null?void 0:c.message)||"未知错误"))}finally{be(!1)}}},fe=()=>{var c;N("create"),xe(null),Y(null),L((c=w[0])!=null&&c.id?String(w[0].id):""),ae(""),me(null),pe(!0)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"卡密库存"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理自动发货的卡密、链接或图片资源。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:fe,className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 rounded-2xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(It,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>v(!0),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(at,{className:"w-5 h-5"}),"添加新卡密"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-gray-50 bg-surface-muted p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative sm:w-48",children:[e.jsx(ha,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按卡密类型筛选",value:$,onChange:c=>T(c.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部类型"}),e.jsx("option",{value:"data",children:"批量卡密"}),e.jsx("option",{value:"text",children:"文本"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"image",children:"图片"})]})]}),e.jsxs("div",{className:"relative w-full sm:max-w-sm",children:[e.jsx(Nt,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"按卡密名称搜索",placeholder:"搜索卡密名称...",value:X,onChange:c=>M(c.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]})]}),e.jsxs("div",{className:"whitespace-nowrap px-1 text-xs font-bold text-gray-400",children:["显示 ",ee.length," / ",t.length," 组"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full table-fixed text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"w-[23%] px-5 py-5",children:"卡密名称"}),e.jsx("th",{className:"w-[8%] px-3 py-5",children:"卡密组ID"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"类型"}),e.jsx("th",{className:"w-[27%] px-5 py-5",children:"内容/库存"}),e.jsx("th",{className:"w-[19%] px-5 py-5",children:"描述"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"状态"}),e.jsx("th",{className:"w-[9%] px-3 py-5 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:ee.map(c=>{let _="";return c.type==="data"&&c.data_content?_=`库存: ${c.data_content.split(`
|
||||
`).filter(x=>x.trim()).length} 条`:c.type==="text"&&c.text_content?_=c.text_content:c.type==="api"&&c.api_config?_=c.api_config.url:c.type==="image"&&c.image_url&&(_="图片链接"),e.jsxs("tr",{className:"hover:bg-warning-50/50 transition-colors group",children:[e.jsx("td",{className:"px-5 py-5 align-middle",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white",children:e.jsx(se,{type:c.type})}),e.jsx("span",{className:"line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900",title:c.name,children:c.name})]})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("button",{onClick:()=>W(c.id),className:"inline-flex max-w-full items-center gap-1 rounded-lg bg-gray-100 px-2 py-1.5 font-mono text-[11px] font-extrabold text-gray-700 transition-colors hover:bg-gray-200",title:"复制卡密组ID,用于批量铺货表格",children:[e.jsx("span",{className:"truncate",children:c.id}),e.jsx(Ja,{className:"h-3 w-3 shrink-0"})]})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("span",{className:`inline-flex rounded-md px-2 py-1 text-[11px] font-bold ${c.type==="text"?"bg-blue-50 text-blue-600":c.type==="data"?"bg-purple-50 text-purple-600":c.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:c.type==="text"?"文本":c.type==="data"?"批量":c.type==="api"?"API":"图片"})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"line-clamp-3 break-all font-mono text-sm leading-5 text-gray-600",title:_,children:_})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"block truncate text-sm text-gray-500",title:c.description||"-",children:c.description||"-"})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("button",{onClick:()=>h(c),className:`w-12 h-8 rounded-full relative transition-colors ${c.enabled?"bg-green-500":"bg-gray-300"}`,children:e.jsx("div",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-sm transition-transform ${c.enabled?"left-5":"left-1"}`})})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e.jsx("button",{onClick:()=>we(c),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black",title:"编辑",children:e.jsx(jt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>F(c.id),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500",children:e.jsx(Ke,{className:"h-4 w-4"})})]})})]},c.id)})})]})}),ee.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(xa,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:t.length===0?"暂无卡密配置,请点击右上角添加。":"没有符合当前筛选条件的卡密组。"})]})]}),l&&k&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑卡密"}),e.jsx("button",{onClick:()=>i(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(De,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:["卡密名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:g.name||"",onChange:c=>R({...g,name:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:游戏点卡、会员卡等"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡券类型"}),e.jsxs("select",{value:g.type||"text",onChange:c=>R({...g,type:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"请选择类型"}),e.jsx("option",{value:"text",children:"固定文字"}),e.jsx("option",{value:"data",children:"批量数据"}),(k==null?void 0:k.type)==="api"&&e.jsx("option",{value:"api",children:"API接口(仅保留现有配置)"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),g.type==="api"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 space-y-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900",children:"API 配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"API 地址"}),e.jsx("input",{type:"url",value:g.api_url||"",onChange:c=>R({...g,api_url:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://api.example.com/get-card"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsLine truncated
|
||||
卡号1:密码1
|
||||
卡号2:密码2
|
||||
或者
|
||||
兑换码1
|
||||
兑换码2`}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持格式:卡号:密码 或 单独的兑换码"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-blue-600",children:g.data_content?g.data_content.split(`
|
||||
`).filter(c=>c.trim()).length:0})," 条"]})]})]}),g.type==="image"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"图片配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{type:"url",value:g.image_url||"",onChange:c=>R({...g,image_url:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://example.com/image.png"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"输入图片卡密的 URL 地址"})]}),g.image_url&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片预览"}),e.jsx("img",{src:g.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:c=>{c.currentTarget.src="https://via.placeholder.com/400x200?text=图片加载失败"}})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"延时发货时间(秒)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",value:g.delay_seconds||0,onChange:c=>R({...g,delay_seconds:parseInt(c.target.value)||0}),className:"flex-1 ios-input px-4 py-3 rounded-xl",min:"0",max:"3600",placeholder:"0"}),e.jsx("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:"秒"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"0表示立即发货,最大3600秒(1小时)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注信息"}),e.jsx("textarea",{value:g.description||"",onChange:c=>R({...g,description:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none",placeholder:"可选的备注信息"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsx("span",{className:"font-bold text-gray-900",children:"启用状态"}),e.jsx("button",{type:"button",onClick:()=>R({...g,enabled:!g.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${g.enabled?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${g.enabled?"translate-x-7":"translate-x-1"}`})})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>i(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:je,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ye,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),p&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"780px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"添加新卡密"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"选择交付方式并录入自动发货内容"})]}),e.jsx("button",{onClick:()=>v(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx(De,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡密名称"}),e.jsx("input",{type:"text",value:y.name,onChange:c=>J({...y,name:c.target.value}),placeholder:"例如:VIP会员卡密",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"类型"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>J({...y,type:"data",content:""}),className:`p-3 rounded-xl font-bold transition-all ${y.type==="data"?"bg-brand text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(ls,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:()=>J({...y,type:"text",content:""}),className:`p-3 rounded-xl font-bold transition-all ${y.type==="text"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Is,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:()=>J({...y,type:"image",content:""}),className:`p-3 rounded-xl font-bold transition-all ${y.type==="image"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children
Line truncated
|
||||
CODE-789012
|
||||
...`:"请输入每次发货时发送的固定文字"}),y.type==="data"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-brand",children:y.content.split(`
|
||||
`).filter(c=>c.trim()).length})," 条"]})]}),y.type==="api"&&e.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求方法"}),e.jsxs("select",{value:y.api_method,onChange:c=>J({...y,api_method:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"超时时间(秒)"}),e.jsx("input",{type:"number",min:"1",max:"60",value:y.api_timeout,onChange:c=>J({...y,api_timeout:parseInt(c.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求头(JSON)"}),e.jsx("textarea",{value:y.api_headers,onChange:c=>J({...y,api_headers:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"Authorization":"Bearer token"}'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求参数(JSON)"}),e.jsx("textarea",{value:y.api_params,onChange:c=>J({...y,api_params:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"order_id":"{order_id}"}'})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"描述"}),e.jsx("input",{value:y.description,onChange:c=>J({...y,description:c.target.value}),placeholder:"卡密用途描述(可选)",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"延时发货(秒)"}),e.jsx("input",{type:"number",value:y.delay_seconds,onChange:c=>J({...y,delay_seconds:parseInt(c.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>v(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:d,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(at,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),Z&&qe.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"40rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量导入卡密"}),e.jsx("button",{onClick:()=>pe(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(De,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[e.jsxs("button",{onClick:()=>N("create"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${de==="create"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Qa,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:()=>N("append"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${de==="append"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(It,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),de==="create"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-4 text-xs text-blue-900 leading-5",children:["上传表格,每行一个卡密组。表头:",e.jsx("code",{className:"bg-blue-100/70 px-1.5 py-0.5 rounded",children:"名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值"}),'。 类型填 text/data/image;data 类型的"内容"按行存卡密(CSV 单元格内换行需用引号包裹)。']}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:ie,className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm tran
Line truncated
|
||||
VIP-002
|
||||
VIP-003`,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),e.jsx("p",{className:"text-xs text-gray-500",children:"一行一个卡密号,空行自动忽略。会追加到该组现有库存末尾。"})]}),H&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",H.added," 个卡密"]})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>pe(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),de==="create"?e.jsxs("button",{onClick:_e,disabled:!q||U,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[U?e.jsx(Re,{className:"w-4 h-4 animate-spin"}):e.jsx(It,{className:"w-4 h-4"}),U?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:$e,disabled:!ge||!G.trim()||U||w.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[U?e.jsx(Re,{className:"w-4 h-4 animate-spin"}):e.jsx(at,{className:"w-4 h-4"}),U?"处理中...":"追加卡密"]})]})]})}),document.body)]})},sn=t=>t.find(s=>s.status==="running"||s.status==="canceling"),an=t=>{const s=String(t||"").trim();return s?/^[¥¥]/.test(s)?s:`¥${s}`:"-"},ln=({onConfigureDelivery:t})=>{const[s,l]=r.useState([]),[i,p]=r.useState([]),[v,k]=r.useState([]),[D,g]=r.useState(""),[R,y]=r.useState(""),[J,Z]=r.useState(!1),[pe,de]=r.useState(!1),[N,q]=r.useState(!1),[xe,Q]=r.useState(!1),[Y,U]=r.useState(!1),[be,ge]=r.useState(!1),[L,G]=r.useState(!1),[ae,H]=r.useState("upload"),[me,$]=r.useState(null),[T,X]=r.useState(null),[M,se]=r.useState(""),[we,je]=r.useState(!1),[F,d]=r.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[h,W]=r.useState(null),[w,ee]=r.useState(null),[ie,_e]=r.useState(null),$e=r.useRef(!1),[fe,c]=r.useState(null),[_,re]=r.useState({}),[x,u]=r.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[I,A]=r.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),[K,P]=r.useState([]);r.useEffect(()=>{if(!be||I.images.length===0){P([]);return}const n=I.images.map((O,le)=>({key:O.name+le,url:URL.createObjectURL(O)}));return P(n),()=>{n.forEach(O=>URL.revokeObjectURL(O.url))}},[be,I.images]);const ke=async()=>{const n=await _t();l(n)},Oe=async()=>{p(await ms())};r.useEffect(()=>{Promise.all([Pt(),_t(),ms(),Us(20)]).then(([n,O,le,Je])=>{k(n),l(O),p(le);const Ge=Je.find(ze=>["running","canceling"].includes(ze.status))||Je.find(ze=>ze.status!=="preview");_e(Ge||null)}).catch(n=>console.error("加载商品配置失败:",n))},[]),r.useEffect(()=>{if(!L||!(w!=null&&w.id)||!["running","canceling"].includes(w.status))return;const n=window.setInterval(async()=>{if(!$e.current){$e.current=!0;try{const O=await gt(w.id);ee(O),_e(O),["running","canceling"].includes(O.status)||(H("done"),await ke(),await Oe())}catch(O){console.error("刷新批量铺货进度失败:",O)}finally{$e.current=!1}}},3e3);return()=>{window.clearInterval(n)}},[L,w==null?void 0:w.id,w==null?void 0:w.status]);const Pe=async()=>{if(!D)return alert("请先选择账号");Z(!0);try{const n=await nr(D);await ke(),alert((n==null?void 0:n.message)||"商品同步完成")}catch(n){console.error("同步商品失败:",n),alert((n==null?void 0:n.message)||"同步失败,请重试")}finally{Z(!1)}},Ee=n=>{c(n),re({...n}),Q(!0)},Te=async()=>{if(fe)try{await gr(fe.cookie_id,fe.item_id,{item_title:_.item_title||"",item_description:_.item_description||"",item_category:_.item_category||"",item_price:_.item_price||"",item_detail:_.item_detail||fe.item_detail||""}),await ke(),await Oe(),Q(!1),c(null)}catch(n){console.error("更新商品失败:",n),alert("更新失败,请重试")}},f=async n=>{if(confirm(`确认删除商品"${n.item_title}"吗?`))try{await ir(n.cookie_id,n.item_id),l(O=>O.filter(le=>!(le.cookie_id===n.cookie_id&&le.item_id===n.item_id)))}catch(O){console.error("删除商品失败:",O),alert("删除失败,请重试")}},C=async()=>{try{if(!x.cookie_id||!x.item_id){alert("请选择账号并填写商品ID");return}await or(x.cookie_id,{item_id:x.item_id,item_title:x.item_title,item_price:x.item_price,item_detail:x.item_image?JSON.stringify({item_image:x.item_image}):""}),await ke(),U(!1),u({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(n){console.error("添加商品失败:",n),alert("添加失败,请重试")}},B=async()=>{if(!I.cookie_id)return alert("请选择发布账号");if(!I.title.trim())return alert("请填写商品标题");if(!I.price.trim())return alert("请填写商品价格");if(!I.quantity||Number(I.quantity)<=0)return alert("库存数量必须大于 0");if(I.images.length===0)return alert("至少上传 1 张商品图片");if(I.postage_mode==="f
Line truncated
|
||||
`),Je=new Blob(["\uFEFF"+le],{type:"text/csv;charset=utf-8"}),Ge=URL.createObjectURL(Je),ze=document.createElement("a");ze.href=Ge,ze.download="批量铺货模板.csv",document.body.appendChild(ze),ze.click(),ze.remove(),URL.revokeObjectURL(Ge)},ne=()=>{u(n=>({...n,cookie_id:D||n.cookie_id})),U(!0)},We=()=>{A(n=>({...n,cookie_id:D||n.cookie_id})),ge(!0)},et=n=>i.filter(O=>O.cookie_id===n.cookie_id&&O.item_id===n.item_id).length>0?i.filter(O=>O.cookie_id===n.cookie_id&&O.item_id===n.item_id):i.filter(O=>O.cookie_id===n.cookie_id&&!O.item_id),tt=n=>{switch(n){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return n||"-"}},it=n=>{switch(n){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}},Ve=r.useMemo(()=>new Map(v.map(n=>[n.id,n])),[v]),Qe=r.useMemo(()=>R?s.filter(n=>n.cookie_id===R):s,[R,s]),He=n=>{const O=Ve.get(n),le=(O==null?void 0:O.remark)||(O==null?void 0:O.nickname);return le?`${le} · ${n.slice(0,6)}`:`账号 ${n.slice(0,8)}`},pt=n=>{const O=Ve.get(n);return(O==null?void 0:O.remark)||(O==null?void 0:O.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ha,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:R,onChange:n=>y(n.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),v.map(n=>e.jsx("option",{value:n.id,children:He(n.id)},n.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(mt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:D,onChange:n=>g(n.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),v.map(n=>e.jsx("option",{value:n.id,children:He(n.id)},n.id))]})]})]}),e.jsxs("button",{onClick:Pe,disabled:J||!D,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(Ue,{className:`w-4 h-4 ${J?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:ne,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(at,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:We,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-500 text-white hover:bg-emerald-600 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(Ht,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void V(),className:"px-5 py-3 rounded-2xl font-bold bg-brand text-white hover:bg-brand-highlight transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(Tt,{className:"w-4 h-4"}),ie&&["running","canceling"].includes(ie.status)?"继续批量任务":"批量铺货"]}),ie&&!["running","canceling"].includes(ie.status)&&e.jsx("button",{onClick:()=>void Me(),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[Qe.map(n=>{const O=et(n),le=O.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all gro
Line truncated
|
||||
@@ -0,0 +1,19 @@
|
||||
import{j as e,r,c as ys,b as qe,d as Ua}from"./react-vendor-C_od1ZSF.js";import{L as Wa,U as ha,M as is,C as os,B as ga,S as ba,Z as cs,a as jt,b as js,G as As,c as _s,d as Ns,e as Ja,f as rt,A as $s,D as Va,g as Ps,P as fa,h as qt,E as ya,T as Qa,i as Ga,j as Pe,X as Me,k as Ka,l as Ha,m as vs,n as ja,o as He,Q as Xt,p as xt,q as Ke,r as yt,s as Tt,t as Rs,R as ze,u as _a,v as Za,w as Qe,K as Ya,x as dt,y as lt,z as et,F as Es,H as Nt,I as _t,J as Dt,N as Na,O as Xa,V as Ds,W as Ts,Y as el,_ as tl,$ as sl,a0 as al,a1 as es,a2 as Bt,a3 as ds,a4 as ll,a5 as rl,a6 as xs,a7 as Ms,a8 as nl,a9 as il,aa as Mt,ab as qs,ac as Gt,ad as va,ae as ol,af as cl,ag as Zt,ah as wa,ai as dl,aj as xl,ak as ml,al as pl,am as ul,an as hl,ao as Fs}from"./icons-vendor-BpMgNNfy.js";import{R as zt,B as gl,X as Bs,Y as zs,T as Ut,a as bl,C as ts,A as fl,b as yl,c as jl,P as Us,d as Ws,L as _l}from"./charts-vendor-BxxJOyEX.js";import"./vendor-D-Edl3pr.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const m of document.querySelectorAll('link[rel="modulepreload"]'))i(m);new MutationObserver(m=>{for(const _ of m)if(_.type==="childList")for(const N of _.addedNodes)N.tagName==="LINK"&&N.rel==="modulepreload"&&i(N)}).observe(document,{childList:!0,subtree:!0});function l(m){const _={};return m.integrity&&(_.integrity=m.integrity),m.referrerPolicy&&(_.referrerPolicy=m.referrerPolicy),m.crossOrigin==="use-credentials"?_.credentials="include":m.crossOrigin==="anonymous"?_.credentials="omit":_.credentials="same-origin",_}function i(m){if(m.ep)return;m.ep=!0;const _=l(m);fetch(m.href,_)}})();const Nl=({className:t="w-full h-full text-white"})=>e.jsx("svg",{className:t,viewBox:"0 0 256 256","aria-hidden":"true",children:e.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:e.jsx("path",{d:"M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z",fill:"currentColor"})})}),ms=({sizeClass:t="w-12 h-12",logoClassName:a="w-full h-full text-white"})=>e.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[e.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),e.jsxs("div",{className:`relative ${t} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[e.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"rgb(var(--color-brand))"}),e.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),e.jsx("path",{d:"M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23Line truncated
|
||||
|
||||
例如:回复时保持礼貌专业、使用简洁的语言、强调产品质量等`,className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-bold text-blue-900 mb-2 flex items-center gap-2",children:[e.jsx(js,{className:"w-4 h-4"}),"AI如何工作"]}),e.jsxs("ul",{className:"text-xs text-blue-800 space-y-1",children:[e.jsx("li",{children:"• 自动识别买家的砍价请求"}),e.jsx("li",{children:"• 根据设定的策略智能回复"}),e.jsx("li",{children:"• 在合理范围内同意降价或礼貌拒绝"}),e.jsx("li",{children:"• 保持专业友好的沟通风格"})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:n,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:Y,children:"取消"}),e.jsxs("button",{onClick:ut,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:Y,children:[Y?e.jsx(Pe,{className:"w-4 h-4 animate-spin"}):e.jsx(He,{className:"w-4 h-4"}),Y?"保存中...":"保存"]})]})})]})}),document.body)]})},ln=t=>({total:Number((t==null?void 0:t.total)||0),success_count:Number((t==null?void 0:t.success_count)||0),failed_count:Number((t==null?void 0:t.failed_count)||0),results:Array.isArray(t==null?void 0:t.results)?t.results.map(a=>({order_id:String((a==null?void 0:a.order_id)||"unknown"),success:(a==null?void 0:a.success)===!0,message:String((a==null?void 0:a.message)||"")})):[]}),rn=t=>(t==null?void 0:t.results.filter(a=>!a.success))||[],sa=({status:t})=>{const a={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},l={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${a[t]||a.cancelled}`,children:l[t]||t})},nn=()=>{const[t,a]=r.useState([]),[l,i]=r.useState([]),[m,_]=r.useState([]),[N,I]=r.useState({}),[g,C]=r.useState("all"),[j,F]=r.useState(""),[G,me]=r.useState(""),[oe,v]=r.useState(""),q=r.useRef(0),[ce,Q]=r.useState(1),[ee,B]=r.useState(1),[ge,ue]=r.useState(!1),[k,Z]=r.useState(!1),[se,K]=r.useState(!1),[ve,J]=r.useState(!1),[A,E]=r.useState(null),[P,be]=r.useState(null),[Re,ae]=r.useState({}),[T,p]=r.useState(!1),[b,U]=r.useState(""),[M,ne]=r.useState(!1),[he,ye]=r.useState(null),[Ee,ke]=r.useState(null),[x,V]=r.useState(null),[X,c]=r.useState(!1),[d,D]=r.useState(null),[S,Y]=r.useState(null),O=async()=>{const u=++q.current;ue(!0);try{const L=await Xl(j||void 0,g,ce,20,oe);if(u!==q.current)return;a(L.data),B(L.total_pages)}catch(L){console.error("加载订单失败:",L)}finally{u===q.current&&ue(!1)}},de=(u,L,le)=>{if(le&&le.trim())return le;if(N[`${u}:${L}`])return N[`${u}:${L}`];const _e=l.find(Ue=>{if(le&&Ue.item_title){const Fe=le.toLowerCase(),tt=Ue.item_title.toLowerCase();return tt.includes(Fe)||Fe.includes(tt)}return!1});return _e!=null&&_e.item_title?_e.item_title:"未知商品"},Se=u=>{const L={};u.forEach(le=>{le.item_id&&(L[`${le.cookie_id}:${le.item_id}`]=le.item_title||le.item_id)}),I(L)};r.useEffect(()=>{const u=window.setTimeout(()=>{Q(1),v(G.trim())},300);return()=>window.clearTimeout(u)},[G]),r.useEffect(()=>{O()},[j,g,ce,oe]),r.useEffect(()=>{Promise.all([Ft(),vt()]).then(([u,L])=>{_(u),i(L),Se(L)}).catch(u=>{console.error("加载商品列表失败:",u)})},[]);const fe=r.useMemo(()=>new Map(m.map(u=>[u.id,u])),[m]),Oe=u=>{const L=fe.get(u),le=(L==null?void 0:L.remark)||(L==null?void 0:L.nickname);return le?`${le} · ${u.slice(0,6)}`:`账号 ${u.slice(0,8)}`},re=u=>{const L=fe.get(u);return(L==null?void 0:L.remark)||(L==null?void 0:L.nickname)||"未命名账号"},h=async()=>{ue(!0);try{const u=await sr(j||void 0,g);await O(),u!=null&&u.message&&alert(u.message)}catch(u){console.error("同步订单失败:",u),alert((u==null?void 0:u.message)||"同步失败,请重试")}finally{ue(!1)}},f=u=>{U(u),ye(null),p(!0)},R=async u=>{var L;ne(!0),ye(null);try{const le=await lr([b],u),_e=(L=le==null?void 0:le.results)==null?void 0:L[0];_e!=null&&_e.success?(ye({success:!0,message:_e.message}),O()):ye({success:!1,message:(_e==null?void 0:_e.message)||"发货失败"})}catch(le){ye({success:!1,message:(le==null?void 0:le.message)||"请求失败"})}finally{ne(!1)}},z=u=>{E(u),Z(!0)},Ie=u=>{be({...u}),K(!0)},Ae=async()=>{if(!(!P||!P.order_id))try{const u={};P.status!==void 0&&(u.order_status=P.status),P.buyer_id!==void 0&&(u.buyer_id=P.buyer_id),P.amount!==void 0&&(u.amount=P.amount),P.receiver_name!==void 0&&(u.receiver_name=P.receiver_name),P.receiver_phone!==
Line truncated
|
||||
VIP-MONTH-002
|
||||
VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map(S=>S.map(Y=>`"${String(Y).replace(/"/g,'""')}"`).join(",")).join(`
|
||||
`),c=new Blob(["\uFEFF"+X],{type:"text/csv;charset=utf-8"}),d=URL.createObjectURL(c),D=document.createElement("a");D.href=d,D.download="卡密组批量导入模板.csv",document.body.appendChild(D),D.click(),D.remove(),URL.revokeObjectURL(d)},ye=async()=>{if(q){ge(!0),ee(null);try{const x=await xr(q);if(ee(x),x.created>0){const V=await Xe();a(V)}}catch(x){ee({error:(x==null?void 0:x.message)||"上传失败"})}finally{ge(!1)}}},Ee=async()=>{if(!(!ue||!Z.trim())){ge(!0),ve(null);try{const x=await mr(ue,Z);ve({added:x.added}),se("");const V=await Xe();a(V)}catch(x){alert("追加失败:"+((x==null?void 0:x.message)||"未知错误"))}finally{ge(!1)}}},ke=()=>{var x;v("create"),ce(null),ee(null),k((x=M[0])!=null&&x.id?String(M[0].id):""),se(""),ve(null),me(!0)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"卡密库存"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理自动发货的卡密、链接或图片资源。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:ke,className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 rounded-2xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(Dt,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>_(!0),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(et,{className:"w-5 h-5"}),"添加新卡密"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-gray-50 bg-surface-muted p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative sm:w-48",children:[e.jsx(Na,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按卡密类型筛选",value:J,onChange:x=>A(x.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部类型"}),e.jsx("option",{value:"data",children:"批量卡密"}),e.jsx("option",{value:"text",children:"文本"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"image",children:"图片"})]})]}),e.jsxs("div",{className:"relative w-full sm:max-w-sm",children:[e.jsx(Nt,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"按卡密名称搜索",placeholder:"搜索卡密名称...",value:E,onChange:x=>P(x.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]})]}),e.jsxs("div",{className:"whitespace-nowrap px-1 text-xs font-bold text-gray-400",children:["显示 ",ne.length," / ",t.length," 组"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full table-fixed text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"w-[23%] px-5 py-5",children:"卡密名称"}),e.jsx("th",{className:"w-[8%] px-3 py-5",children:"卡密组ID"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"类型"}),e.jsx("th",{className:"w-[27%] px-5 py-5",children:"内容/库存"}),e.jsx("th",{className:"w-[19%] px-5 py-5",children:"描述"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"状态"}),e.jsx("th",{className:"w-[9%] px-3 py-5 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:ne.map(x=>{let V="";return x.type==="data"&&x.data_content?V=`库存: ${x.data_content.split(`
|
||||
`).filter(c=>c.trim()).length} 条`:x.type==="text"&&x.text_content?V=x.text_content:x.type==="api"&&x.api_config?V=x.api_config.url:x.type==="image"&&x.image_url&&(V="图片链接"),e.jsxs("tr",{className:"hover:bg-warning-50/50 transition-colors group",children:[e.jsx("td",{className:"px-5 py-5 align-middle",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white",children:e.jsx(be,{type:x.type})}),e.jsx("span",{className:"line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900",title:x.name,children:x.name})]})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("button",{onClick:()=>U(x.id),className:"inline-flex max-w-full items-center gap-1 rounded-lg bg-gray-100 px-2 py-1.5 font-mono text-[11px] font-extrabold text-gray-700 transition-colors hover:bg-gray-200",title:"复制卡密组ID,用于批量铺货表格",children:[e.jsx("span",{className:"truncate",children:x.id}),e.jsx(Xa,{className:"h-3 w-3 shrink-0"})]})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("span",{className:`inline-flex rounded-md px-2 py-1 text-[11px] font-bold ${x.type==="text"?"bg-blue-50 text-blue-600":x.type==="data"?"bg-purple-50 text-purple-600":x.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:x.type==="text"?"文本":x.type==="data"?"批量":x.type==="api"?"API":"图片"})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"line-clamp-3 break-all font-mono text-sm leading-5 text-gray-600",title:V,children:V})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"block truncate text-sm text-gray-500",title:x.description||"-",children:x.description||"-"})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("button",{onClick:()=>b(x),className:`w-12 h-8 rounded-full relative transition-colors ${x.enabled?"bg-green-500":"bg-gray-300"}`,children:e.jsx("div",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-sm transition-transform ${x.enabled?"left-5":"left-1"}`})})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e.jsx("button",{onClick:()=>Re(x),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black",title:"编辑",children:e.jsx(_t,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>T(x.id),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500",children:e.jsx(Qe,{className:"h-4 w-4"})})]})})]},x.id)})})]})}),ne.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(fa,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:t.length===0?"暂无卡密配置,请点击右上角添加。":"没有符合当前筛选条件的卡密组。"})]})]}),l&&N&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑卡密"}),e.jsx("button",{onClick:()=>i(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(Me,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:["卡密名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:g.name||"",onChange:x=>C({...g,name:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:游戏点卡、会员卡等"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡券类型"}),e.jsxs("select",{value:g.type||"text",onChange:x=>C({...g,type:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"请选择类型"}),e.jsx("option",{value:"text",children:"固定文字"}),e.jsx("option",{value:"data",children:"批量数据"}),(N==null?void 0:N.type)==="api"&&e.jsx("option",{value:"api",children:"API接口(仅保留现有配置)"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),g.type==="api"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 space-y-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900",children:"API 配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"API 地址"}),e.jsx("input",{type:"url",value:g.api_url||"",onChange:x=>C({...g,api_url:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://api.example.com/get-card"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsLine truncated
|
||||
卡号1:密码1
|
||||
卡号2:密码2
|
||||
或者
|
||||
兑换码1
|
||||
兑换码2`}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持格式:卡号:密码 或 单独的兑换码"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-blue-600",children:g.data_content?g.data_content.split(`
|
||||
`).filter(x=>x.trim()).length:0})," 条"]})]})]}),g.type==="image"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"图片配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{type:"url",value:g.image_url||"",onChange:x=>C({...g,image_url:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://example.com/image.png"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"输入图片卡密的 URL 地址"})]}),g.image_url&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片预览"}),e.jsx("img",{src:g.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:x=>{x.currentTarget.src="https://via.placeholder.com/400x200?text=图片加载失败"}})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"延时发货时间(秒)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",value:g.delay_seconds||0,onChange:x=>C({...g,delay_seconds:parseInt(x.target.value)||0}),className:"flex-1 ios-input px-4 py-3 rounded-xl",min:"0",max:"3600",placeholder:"0"}),e.jsx("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:"秒"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"0表示立即发货,最大3600秒(1小时)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注信息"}),e.jsx("textarea",{value:g.description||"",onChange:x=>C({...g,description:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none",placeholder:"可选的备注信息"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsx("span",{className:"font-bold text-gray-900",children:"启用状态"}),e.jsx("button",{type:"button",onClick:()=>C({...g,enabled:!g.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${g.enabled?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${g.enabled?"translate-x-7":"translate-x-1"}`})})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>i(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:ae,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(He,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),m&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"780px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"添加新卡密"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"选择交付方式并录入自动发货内容"})]}),e.jsx("button",{onClick:()=>_(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx(Me,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡密名称"}),e.jsx("input",{type:"text",value:j.name,onChange:x=>F({...j,name:x.target.value}),placeholder:"例如:VIP会员卡密",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"类型"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>F({...j,type:"data",content:""}),className:`p-3 rounded-xl font-bold transition-all ${j.type==="data"?"bg-brand text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(os,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:()=>F({...j,type:"text",content:""}),className:`p-3 rounded-xl font-bold transition-all ${j.type==="text"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Ds,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:()=>F({...j,type:"image",content:""}),className:`p-3 rounded-xl font-bold transition-all ${j.type==="image"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children
Line truncated
|
||||
CODE-789012
|
||||
...`:"请输入每次发货时发送的固定文字"}),j.type==="data"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-brand",children:j.content.split(`
|
||||
`).filter(x=>x.trim()).length})," 条"]})]}),j.type==="api"&&e.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求方法"}),e.jsxs("select",{value:j.api_method,onChange:x=>F({...j,api_method:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"超时时间(秒)"}),e.jsx("input",{type:"number",min:"1",max:"60",value:j.api_timeout,onChange:x=>F({...j,api_timeout:parseInt(x.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求头(JSON)"}),e.jsx("textarea",{value:j.api_headers,onChange:x=>F({...j,api_headers:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"Authorization":"Bearer token"}'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求参数(JSON)"}),e.jsx("textarea",{value:j.api_params,onChange:x=>F({...j,api_params:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"order_id":"{order_id}"}'})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"描述"}),e.jsx("input",{value:j.description,onChange:x=>F({...j,description:x.target.value}),placeholder:"卡密用途描述(可选)",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"延时发货(秒)"}),e.jsx("input",{type:"number",value:j.delay_seconds,onChange:x=>F({...j,delay_seconds:parseInt(x.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>_(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:p,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(et,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),G&&qe.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"40rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量导入卡密"}),e.jsx("button",{onClick:()=>me(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(Me,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[e.jsxs("button",{onClick:()=>v("create"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${oe==="create"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(el,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:()=>v("append"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${oe==="append"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Dt,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),oe==="create"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-4 text-xs text-blue-900 leading-5",children:["上传表格,每行一个卡密组。表头:",e.jsx("code",{className:"bg-blue-100/70 px-1.5 py-0.5 rounded",children:"名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值"}),'。 类型填 text/data/image;data 类型的"内容"按行存卡密(CSV 单元格内换行需用引号包裹)。']}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:he,className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm tran
Line truncated
|
||||
VIP-002
|
||||
VIP-003`,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),e.jsx("p",{className:"text-xs text-gray-500",children:"一行一个卡密号,空行自动忽略。会追加到该组现有库存末尾。"})]}),K&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",K.added," 个卡密"]})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>me(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),oe==="create"?e.jsxs("button",{onClick:ye,disabled:!q||B,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[B?e.jsx(Pe,{className:"w-4 h-4 animate-spin"}):e.jsx(Dt,{className:"w-4 h-4"}),B?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:Ee,disabled:!ue||!Z.trim()||B||M.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[B?e.jsx(Pe,{className:"w-4 h-4 animate-spin"}):e.jsx(et,{className:"w-4 h-4"}),B?"处理中...":"追加卡密"]})]})]})}),document.body)]})},dn=t=>t.find(a=>a.status==="running"||a.status==="canceling"),la="ydisks-amap-js-api",xn="c9b68d4ce9a2a97f22a4a439404488ca";let $t=null;const mn=()=>xn,pn=()=>window.AMap?Promise.resolve(window.AMap):$t||($t=new Promise((t,a)=>{const l=document.getElementById(la),i=l||document.createElement("script"),m=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(N)},_=()=>{window.AMap?(m(),t(window.AMap)):(m(),a(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},N=window.setTimeout(()=>{m(),a(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=_,i.id=la,i.async=!0,i.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(mn())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,i.onerror=()=>{m(),a(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},l||document.head.appendChild(i)}).catch(t=>{throw $t=null,t}),$t),Ht=t=>Number.isFinite(t)&&t!==0,un=t=>{var m,_;const a=Number((m=t.location)==null?void 0:m.lng),l=Number((_=t.location)==null?void 0:_.lat),i={area:String(t.adname||"").trim(),city:String(t.cityname||"").trim(),division_id:String(t.adcode||"").trim(),longitude:a,latitude:l,poi_id:String(t.id||"").trim(),poi_name:String(t.name||"").trim(),province:String(t.pname||"").trim()};return!i.division_id||!i.province||!i.city||!i.poi_id||!i.poi_name||!Ht(a)||!Ht(l)||a<-180||a>180||l<-90||l>90?null:i},hn=async(t,a)=>{if(!Ht(t)||!Ht(a)||t<-180||t>180||a<-90||a>90)throw new Error("经纬度无效");const l=await pn();return new Promise((i,m)=>{new l.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[t,a],1e3,(N,I)=>{var C;if(N!=="complete"){if(N==="no_data"){i([]);return}m(new Error("高德地图附近地址查询失败,请稍后重试"));return}const g=(((C=I==null?void 0:I.poiList)==null?void 0:C.pois)||[]).map(un).filter(j=>j!==null);i(g)})})},gn=t=>{const a=String(t||"").trim();return a?/^[¥¥]/.test(a)?a:`¥${a}`:"-"},bn=({onConfigureDelivery:t})=>{const[a,l]=r.useState([]),[i,m]=r.useState([]),[_,N]=r.useState([]),[I,g]=r.useState(""),[C,j]=r.useState(""),[F,G]=r.useState(!1),[me,oe]=r.useState(!1),[v,q]=r.useState(!1),[ce,Q]=r.useState(!1),[ee,B]=r.useState(!1),[ge,ue]=r.useState(!1),[k,Z]=r.useState(!1),[se,K]=r.useState("upload"),[ve,J]=r.useState(null),[A,E]=r.useState(null),[P,be]=r.useState(""),[Re,ae]=r.useState(!1),[T,p]=r.useState(!1),[b,U]=r.useState([]),[M,ne]=r.useState(null),[he,ye]=r.useState([]),[Ee,ke]=r.useState(null),[x,V]=r.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[X,c]=r.useState(null),[d,D]=r.useState(null),[S,Y]=r.useState(null),O=r.useRef(!1),[de,Se]=r.useState(null),[fe,Oe]=r.useState({}),[re,h]=r.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[f,R]=r.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),[z,Ie]=r.useState([]);r.useEffect(()=>{if(!ge||f.images.length===0){Ie([]);return}const n=f.images.map((w,H)=>({key:w.name+H,url:URL.createObjectURL(w)}));return Ie(n),()=>{n.forEach(w=>URL.revokeObjectURL(w.url))}},[ge,f.images]);const Ae=async()=>{const n=await vt();l(n)},we=async()=>{m(await gs())};r.useEffect(()=>{Promise.all([Ft(),vt(),gs(),Hs(20)]).then(([n,w,H,Te])=>{N(n),l(w),m(H);const s=Te.find(o=>["running","canceling"].includes(o.status))||Te.find(o=>o.status!=="preview");Y(s||null)}).catch(n=>console.error("加载商品配置失败:",n))},[]),r.useEffect(()=>{if(!k||!(d!=null&&d.id)||!["running","canceling"].includes(d.status))return;const n=window.setInterval(async()=>{if(!O.current){O.current=!0;try{const w=await bt(d.id);D(w),Y(w),[
Line truncated
|
||||
`),Te=new Blob(["\uFEFF"+H],{type:"text/csv;charset=utf-8"}),s=URL.createObjectURL(Te),o=document.createElement("a");o.href=s,o.download="批量铺货模板.csv",document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(s)},Lt=()=>{h(n=>({...n,cookie_id:I||n.cookie_id})),B(!0)},nt=()=>{R(n=>({...n,cookie_id:I||n.cookie_id})),ue(!0)},it=async n=>{if(!(n?I:f.cookie_id))return alert("请先选择发布账号");if(!navigator.geolocation)return alert("当前浏览器不支持定位");p(!0),navigator.geolocation.getCurrentPosition(async H=>{try{const Te=await hn(H.coords.longitude,H.coords.latitude);if(!Te.length)throw new Error("当前位置附近没有可用的高德发货地,请稍后重试");n?(ye(Te),ke(Te[0])):(U(Te),ne(Te[0]))}catch(Te){alert((Te==null?void 0:Te.message)||"获取发货地失败")}finally{p(!1)}},H=>{p(!1),alert(H.code===H.PERMISSION_DENIED?"定位权限被拒绝,请在浏览器设置中允许定位":"无法获取当前位置,请稍后重试")},{enableHighAccuracy:!0,timeout:15e3,maximumAge:6e4})},Ot=n=>i.filter(w=>w.cookie_id===n.cookie_id&&w.item_id===n.item_id).length>0?i.filter(w=>w.cookie_id===n.cookie_id&&w.item_id===n.item_id):i.filter(w=>w.cookie_id===n.cookie_id&&!w.item_id),pt=n=>{switch(n){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return n||"-"}},ut=n=>{switch(n){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}},st=r.useMemo(()=>new Map(_.map(n=>[n.id,n])),[_]),ht=r.useMemo(()=>C?a.filter(n=>n.cookie_id===C):a,[C,a]),Ge=n=>{const w=st.get(n),H=(w==null?void 0:w.remark)||(w==null?void 0:w.nickname);return H?`${H} · ${n.slice(0,6)}`:`账号 ${n.slice(0,8)}`},ot=n=>{const w=st.get(n);return(w==null?void 0:w.remark)||(w==null?void 0:w.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(al,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:C,onChange:n=>j(n.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),_.map(n=>e.jsx("option",{value:n.id,children:Ge(n.id)},n.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(xt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:I,onChange:n=>g(n.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),_.map(n=>e.jsx("option",{value:n.id,children:Ge(n.id)},n.id))]})]})]}),e.jsxs("button",{onClick:De,disabled:F||!I,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(ze,{className:`w-4 h-4 ${F?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:Lt,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(et,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:nt,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-500 text-white hover:bg-emerald-600 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(es,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void _e(),className:"px-5 py-3 rounded-2xl font-bold bg-brand text-white
Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(147 197 253 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(147 197 253 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:rgb(var(--color-neutral-200) / 1)}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}input::placeholder,textarea::placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.\!container{width:100%!important}.container{width:100%}@media(min-width:640px){.\!container{max-width:640px!important}.container{max-width:6Line truncated
|
||||
@@ -6,12 +6,12 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Ydisks闲鱼助手 - 自动发货与管家系统</title>
|
||||
<meta name="description" content="Ydisks闲鱼助手 - 自动回复、自动发货、订单管理、AI智能议价一体化解决方案" />
|
||||
<script type="module" crossorigin src="/static/assets/index-Bp6jEzSl.js"></script>
|
||||
<script type="module" crossorigin src="/static/assets/index-CHuZDt8D.js"></script>
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/react-vendor-C_od1ZSF.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/icons-vendor-DjsKcZkz.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/icons-vendor-BpMgNNfy.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/vendor-D-Edl3pr.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/charts-vendor-BxxJOyEX.js">
|
||||
<link rel="stylesheet" crossorigin href="/static/assets/index-B8qM55ET.css">
|
||||
<link rel="stylesheet" crossorigin href="/static/assets/index-DVSGe2YH.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -93,6 +93,9 @@ func (c *ClientImpl) PolishItem(ctx context.Context, cookiesStr, itemID string)
|
||||
if duplicatePolishError(err) {
|
||||
return &AccountTaskResult{Success: true, Message: "商品今天已经擦亮", UpdatedCookies: updated}, nil
|
||||
}
|
||||
if IsSessionExpiredErr(err) || IsRiskVerificationErr(err) {
|
||||
return nil, err
|
||||
}
|
||||
primaryErr := err
|
||||
if strings.TrimSpace(updated) == "" {
|
||||
updated = cookiesStr
|
||||
@@ -141,6 +144,9 @@ func (c *ClientImpl) accountTaskRequest(ctx context.Context, cookiesStr, endpoin
|
||||
if isRiskVerificationRet(decoded.Ret) {
|
||||
return nil, updated, &RiskVerificationError{Ret: decoded.Ret}
|
||||
}
|
||||
if isSessionExpiredRet(decoded.Ret) {
|
||||
return nil, updated, sessionExpiredError(api, decoded.Ret)
|
||||
}
|
||||
if !isTokenExpiredRet(decoded.Ret) {
|
||||
return nil, updated, fmt.Errorf("%s 返回失败: %s", api, firstRet(decoded.Ret))
|
||||
}
|
||||
|
||||
@@ -101,3 +101,22 @@ func TestPolishItemFallsBackToAlternateAPI(t *testing.T) {
|
||||
t.Fatalf("calls=%v want=%v", calls, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPolishItemSessionExpiredDoesNotCallBackupOrTokenAPI(t *testing.T) {
|
||||
calls := 0
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
calls++
|
||||
_, _ = w.Write([]byte(`{"ret":["FAIL_SYS_SESSION_EXPIRED::Session过期"],"data":{}}`))
|
||||
}))
|
||||
defer server.Close()
|
||||
client := &ClientImpl{
|
||||
HTTPClient: server.Client(), PolishItemURL: server.URL, PolishItemBackupURL: server.URL, TokenURL: server.URL,
|
||||
}
|
||||
_, err := client.PolishItem(context.Background(), "unb=123; _m_h5_tk=token_1", "item-1")
|
||||
if err == nil || !IsSessionExpiredErr(err) {
|
||||
t.Fatalf("err=%v want session expired", err)
|
||||
}
|
||||
if calls != 1 {
|
||||
t.Fatalf("session expiry must stop all fallback/retry requests, calls=%d", calls)
|
||||
}
|
||||
}
|
||||
@@ -208,14 +208,48 @@ func isTokenExpiredRet(ret []string) bool {
|
||||
for _, r := range ret {
|
||||
if strings.Contains(r, "FAIL_SYS_TOKEN_EXOIRED") ||
|
||||
strings.Contains(r, "FAIL_SYS_TOKEN_EXPIRED") ||
|
||||
strings.Contains(r, "FAIL_SYS_TOKEN_EMPTY") ||
|
||||
strings.Contains(r, "FAIL_SYS_SESSION_EXPIRED") {
|
||||
strings.Contains(r, "FAIL_SYS_TOKEN_EMPTY") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// SessionExpiredError 表示平台已经明确判定整个登录 Session 失效。
|
||||
// 它与可通过响应 Set-Cookie 重签的普通 MTOP token 过期不同:调用方必须
|
||||
// 立刻停止业务 API 重试,转入账号级 Session 续期流程。
|
||||
type SessionExpiredError struct {
|
||||
API string
|
||||
Ret []string
|
||||
}
|
||||
|
||||
func (e *SessionExpiredError) Error() string {
|
||||
if e == nil {
|
||||
return ""
|
||||
}
|
||||
if e.API == "" {
|
||||
return fmt.Sprintf("Session 过期: ret=%v", e.Ret)
|
||||
}
|
||||
return fmt.Sprintf("%s Session 过期: ret=%v", e.API, e.Ret)
|
||||
}
|
||||
|
||||
func isSessionExpiredRet(ret []string) bool {
|
||||
for _, value := range ret {
|
||||
lower := strings.ToLower(value)
|
||||
if strings.Contains(lower, "fail_sys_session_expired") ||
|
||||
strings.Contains(lower, "session过期") ||
|
||||
strings.Contains(lower, "session expired") ||
|
||||
strings.Contains(lower, "会话过期") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func sessionExpiredError(api string, ret []string) error {
|
||||
return &SessionExpiredError{API: api, Ret: append([]string(nil), ret...)}
|
||||
}
|
||||
|
||||
// RiskVerificationError 表示闲鱼服务端要求用户验证(滑块/人脸/风控页)。
|
||||
// 这类错误不能按普通 token 过期快速重试,否则会持续打接口并放大风控。
|
||||
type RiskVerificationError struct {
|
||||
@@ -269,9 +303,15 @@ func IsSessionExpiredErr(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var sessionErr *SessionExpiredError
|
||||
if errors.As(err, &sessionErr) {
|
||||
return true
|
||||
}
|
||||
msg := strings.ToLower(err.Error())
|
||||
return strings.Contains(msg, "fail_sys_session_expired") ||
|
||||
strings.Contains(msg, "session过期") ||
|
||||
strings.Contains(msg, "session expired") ||
|
||||
strings.Contains(msg, "会话过期") ||
|
||||
strings.Contains(msg, "登录凭证已失效")
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ func TestIsTokenExpiredRet(t *testing.T) {
|
||||
}{
|
||||
{[]string{"FAIL_SYS_TOKEN_EXOIRED::令牌过期"}, true},
|
||||
{[]string{"FAIL_SYS_TOKEN_EXPIRED::令牌过期"}, true},
|
||||
{[]string{"FAIL_SYS_SESSION_EXPIRED::会话过期"}, true},
|
||||
{[]string{"FAIL_SYS_SESSION_EXPIRED::会话过期"}, false},
|
||||
{[]string{"FAIL_SYS_USER_VALIDATE::非法请求TOKEN"}, false},
|
||||
{[]string{"SUCCESS::调用成功"}, false},
|
||||
{[]string{"FAIL_BIZ_ORDER_STATUS_ERROR::订单状态错误"}, false},
|
||||
@@ -184,6 +184,20 @@ func TestIsTokenExpiredRet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionExpiredRetIsSeparateFromTokenExpiry(t *testing.T) {
|
||||
ret := []string{"FAIL_SYS_SESSION_EXPIRED::会话过期"}
|
||||
if !isSessionExpiredRet(ret) {
|
||||
t.Fatal("session expiry must be recognized")
|
||||
}
|
||||
if isTokenExpiredRet(ret) {
|
||||
t.Fatal("session expiry must not enter token retry path")
|
||||
}
|
||||
err := sessionExpiredError("test API", ret)
|
||||
if !IsSessionExpiredErr(fmt.Errorf("wrapped: %w", err)) {
|
||||
t.Fatalf("typed wrapped error not recognized: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsSessionExpiredErr(t *testing.T) {
|
||||
cases := []struct {
|
||||
err error
|
||||
|
||||
@@ -42,6 +42,9 @@ func (c *ClientImpl) ConsignContext(ctx context.Context, cookiesStr, orderID str
|
||||
if ok {
|
||||
return true, ret, currentCookies, nil
|
||||
}
|
||||
if isSessionExpiredRet(ret) {
|
||||
return false, ret, currentCookies, sessionExpiredError("确认发货接口", ret)
|
||||
}
|
||||
if !isTokenExpiredRet(ret) {
|
||||
return false, ret, currentCookies, nil
|
||||
}
|
||||
|
||||
@@ -279,15 +279,9 @@ func TestPublishWorkflowUsesCookieSessionForEveryRequest(t *testing.T) {
|
||||
rotate(w, "token2")
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"categoryPredictResult":{"catId":"c1","catName":"类目"}}}`)
|
||||
},
|
||||
"mtop.taobao.idle.local.poi.get": func(w http.ResponseWriter, req *http.Request) {
|
||||
"mtop.idle.pc.idleitem.publish": func(w http.ResponseWriter, req *http.Request) {
|
||||
assertCookies(req, "token2", "api_http_only=api")
|
||||
assertSign(req, "token2")
|
||||
rotate(w, "token3")
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"commonAddresses":[{"area":"X","city":"Y","divisionId":"1","longitude":118.7,"latitude":31.9,"poiId":"p1","poi":"P","prov":"Z"}]}}`)
|
||||
},
|
||||
"mtop.idle.pc.idleitem.publish": func(w http.ResponseWriter, req *http.Request) {
|
||||
assertCookies(req, "token3", "api_http_only=api")
|
||||
assertSign(req, "token3")
|
||||
rotate(w, "token4")
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"itemId":"new-item"}}`)
|
||||
},
|
||||
@@ -297,12 +291,13 @@ func TestPublishWorkflowUsesCookieSessionForEveryRequest(t *testing.T) {
|
||||
Title: "T",
|
||||
PriceCents: 100,
|
||||
Quantity: 1,
|
||||
Location: &PublishLocation{Area: "X", City: "Y", DivisionID: "1", Longitude: 118.7, Latitude: 31.9, POIID: "p1", POIName: "P", Province: "Z"},
|
||||
Images: []PublishImage{{Filename: "a.png", ContentType: "image/png", Data: tinyPNG(t)}},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("PublishItem: %v", err)
|
||||
}
|
||||
if requestCount != 4 || result.ItemID != "new-item" || !strings.Contains(result.UpdatedCookies, "_m_h5_tk=token4_1") {
|
||||
if requestCount != 3 || result.ItemID != "new-item" || !strings.Contains(result.UpdatedCookies, "_m_h5_tk=token4_1") {
|
||||
t.Fatalf("requests=%d result=%+v", requestCount, result)
|
||||
}
|
||||
canonical, _, changed := session.State()
|
||||
|
||||
@@ -67,6 +67,9 @@ func (c *ClientImpl) DetectItemMultiSpec(ctx context.Context, cookies, itemID st
|
||||
if err := json.Unmarshal(raw, &decoded); err != nil {
|
||||
return false, fmt.Errorf("解析商品详情响应失败: %w (body=%s)", err, truncate(string(raw), 300))
|
||||
}
|
||||
if isSessionExpiredRet(decoded.Ret) {
|
||||
return false, sessionExpiredError("商品详情接口", decoded.Ret)
|
||||
}
|
||||
if !hasMTopSuccess(decoded.Ret) {
|
||||
return false, fmt.Errorf("商品详情接口返回非成功: ret=%v", decoded.Ret)
|
||||
}
|
||||
|
||||
@@ -36,6 +36,9 @@ func (c *ClientImpl) FetchItemsPage(ctx context.Context, cookiesStr string, page
|
||||
if res != nil {
|
||||
return res, nil
|
||||
}
|
||||
if isSessionExpiredRet(ret) {
|
||||
return nil, sessionExpiredError("商品列表接口", ret)
|
||||
}
|
||||
if !isTokenExpiredRet(ret) {
|
||||
return nil, fmt.Errorf("商品列表接口返回非成功: ret=%v", ret)
|
||||
}
|
||||
|
||||
@@ -45,6 +45,9 @@ func (c *ClientImpl) FetchOrderDetail(ctx context.Context, cookiesStr, orderID s
|
||||
result.UpdatedCookies = currentCookies
|
||||
return result, nil
|
||||
}
|
||||
if isSessionExpiredRet(ret) {
|
||||
return nil, sessionExpiredError("订单详情接口", ret)
|
||||
}
|
||||
if !isTokenExpiredRet(ret) {
|
||||
return nil, fmt.Errorf("订单详情接口返回非成功: ret=%v", ret)
|
||||
}
|
||||
|
||||
@@ -24,10 +24,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
UploadMediaAPI = "https://stream-upload.goofish.com/api/upload.api"
|
||||
PublishItemAPI = "https://h5api.m.goofish.com/h5/mtop.idle.pc.idleitem.publish/1.0/"
|
||||
RecommendItemAPI = "https://h5api.m.goofish.com/h5/mtop.taobao.idle.kgraph.property.recommend/2.0/"
|
||||
DefaultLocationAPI = "https://h5api.m.goofish.com/h5/mtop.taobao.idle.local.poi.get/1.0/"
|
||||
UploadMediaAPI = "https://stream-upload.goofish.com/api/upload.api"
|
||||
PublishItemAPI = "https://h5api.m.goofish.com/h5/mtop.idle.pc.idleitem.publish/1.0/"
|
||||
RecommendItemAPI = "https://h5api.m.goofish.com/h5/mtop.taobao.idle.kgraph.property.recommend/2.0/"
|
||||
)
|
||||
|
||||
// ErrPublishCategoryUnrecognized 表示闲鱼类目推荐接口调用成功,但没有给出可发布类目。
|
||||
@@ -73,6 +72,18 @@ type PublishCategory struct {
|
||||
TBCatID string `json:"tb_cat_id,omitempty"`
|
||||
}
|
||||
|
||||
// PublishLocation 是高德附近 POI 映射成的、可直接用于闲鱼发布商品的发货地。
|
||||
type PublishLocation struct {
|
||||
Area string `json:"area"`
|
||||
City string `json:"city"`
|
||||
DivisionID string `json:"division_id"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
Latitude float64 `json:"latitude"`
|
||||
POIID string `json:"poi_id"`
|
||||
POIName string `json:"poi_name"`
|
||||
Province string `json:"province"`
|
||||
}
|
||||
|
||||
// DefaultVirtualPublishCategory 是从闲鱼类目推荐响应中核实的“电子资料”类目。
|
||||
// 该类目没有 tbCatId,发布时必须保留为空而不是伪造淘宝类目 ID。
|
||||
func DefaultVirtualPublishCategory() PublishCategory {
|
||||
@@ -91,9 +102,10 @@ type PublishItemRequest struct {
|
||||
Quantity int
|
||||
PostageMode string
|
||||
PostageCents int64
|
||||
// Virtual 表示商品只通过系统的虚拟发货流程交付,不需要实物发货地址。
|
||||
// Virtual 表示商品通过系统的虚拟发货流程交付;显式提供 Location 时仍会向闲鱼提交发货地。
|
||||
Virtual bool
|
||||
PreferredCategory *PublishCategory
|
||||
Location *PublishLocation
|
||||
Images []PublishImage
|
||||
}
|
||||
|
||||
@@ -171,17 +183,7 @@ func (c *ClientImpl) PublishItem(ctx context.Context, cookiesStr string, req Pub
|
||||
}
|
||||
}
|
||||
}
|
||||
var location map[string]any
|
||||
if !req.Virtual {
|
||||
location, updated, err = c.defaultPublishLocation(ctx, currentCookies)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if updated != "" {
|
||||
currentCookies = updated
|
||||
}
|
||||
}
|
||||
return c.publishItemOnce(ctx, currentCookies, req, uploaded, category, location)
|
||||
return c.publishItemOnce(ctx, currentCookies, req, uploaded, category)
|
||||
}
|
||||
|
||||
// RecommendPublishCategory 根据关键词调用闲鱼推荐接口,返回可直接用于发布的完整类目。
|
||||
@@ -398,28 +400,11 @@ func fallbackPublishCategory(category PublishCategory) map[string]any {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ClientImpl) defaultPublishLocation(ctx context.Context, cookiesStr string) (map[string]any, string, error) {
|
||||
data := map[string]any{"longitude": 118.78248347393424, "latitude": 31.91629189813543}
|
||||
decoded, updated, err := c.callMTop(ctx, cookiesStr, DefaultLocationAPI, "mtop.taobao.idle.local.poi.get", "1.0", "a21ybx.publish.0.0", "a21ybx.item.sidebar.1.38262218ame5nr", "38262218ame5nr", data)
|
||||
if err != nil {
|
||||
return nil, updated, err
|
||||
}
|
||||
if !hasMTopSuccess(retFromDecoded(decoded)) {
|
||||
return nil, updated, classifyPublishError(retFromDecoded(decoded), decoded)
|
||||
}
|
||||
dataMap := mapFromAny(decoded["data"])
|
||||
addresses, _ := dataMap["commonAddresses"].([]any)
|
||||
if len(addresses) == 0 {
|
||||
return nil, updated, fmt.Errorf("账号缺少默认发货地址/定位信息,无法发布商品")
|
||||
}
|
||||
loc := mapFromAny(addresses[0])
|
||||
if loc == nil {
|
||||
return nil, updated, fmt.Errorf("默认地址格式异常,无法发布商品")
|
||||
}
|
||||
return loc, updated, nil
|
||||
func validPublishLocation(loc PublishLocation) bool {
|
||||
return loc.DivisionID != "" && loc.Province != "" && loc.City != "" && loc.Longitude >= -180 && loc.Longitude <= 180 && loc.Latitude >= -90 && loc.Latitude <= 90 && !(loc.Longitude == 0 && loc.Latitude == 0)
|
||||
}
|
||||
|
||||
func (c *ClientImpl) publishItemOnce(ctx context.Context, cookiesStr string, req PublishItemRequest, images []uploadedImage, category, location map[string]any) (*PublishItemResult, error) {
|
||||
func (c *ClientImpl) publishItemOnce(ctx context.Context, cookiesStr string, req PublishItemRequest, images []uploadedImage, category map[string]any) (*PublishItemResult, error) {
|
||||
imagePayloads := make([]any, 0, len(images))
|
||||
for i, img := range images {
|
||||
imagePayloads = append(imagePayloads, publishImagePayload(img, i == 0))
|
||||
@@ -450,16 +435,18 @@ func (c *ClientImpl) publishItemOnce(ctx context.Context, cookiesStr string, req
|
||||
"bizcode": "pcMainPublish",
|
||||
"publishScene": "pcMainPublish",
|
||||
}
|
||||
if !req.Virtual {
|
||||
data["itemAddrDTO"] = map[string]any{
|
||||
"area": location["area"],
|
||||
"city": location["city"],
|
||||
"divisionId": location["divisionId"],
|
||||
"gps": fmt.Sprintf("%s,%s", mtopString(location["longitude"]), mtopString(location["latitude"])),
|
||||
"poiId": location["poiId"],
|
||||
"poiName": location["poi"],
|
||||
"prov": location["prov"],
|
||||
if req.Location != nil {
|
||||
if !validPublishLocation(*req.Location) {
|
||||
return nil, errors.New("发货地信息不完整,请重新定位并选择")
|
||||
}
|
||||
data["itemAddrDTO"] = map[string]any{
|
||||
"area": req.Location.Area, "city": req.Location.City, "divisionId": req.Location.DivisionID,
|
||||
// 闲鱼网页版发布页使用 latitude,longitude 的顺序。
|
||||
"gps": fmt.Sprintf("%s,%s", strconv.FormatFloat(req.Location.Latitude, 'f', -1, 64), strconv.FormatFloat(req.Location.Longitude, 'f', -1, 64)),
|
||||
"poiId": req.Location.POIID, "poiName": req.Location.POIName, "prov": req.Location.Province,
|
||||
}
|
||||
} else if !req.Virtual {
|
||||
return nil, errors.New("发布实物商品前必须选择发货地")
|
||||
}
|
||||
decoded, updated, err := c.callMTop(ctx, cookiesStr, PublishItemAPI, "mtop.idle.pc.idleitem.publish", "1.0", "a21ybx.publish.0.0", "a21ybx.home.sidebar.1.46413da6EPl7v5", "46413da6EPl7v5", data)
|
||||
if err != nil {
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// publish.go 用常量 URL(UploadMediaAPI / RecommendItemAPI / DefaultLocationAPI / PublishItemAPI),
|
||||
// publish.go 用常量 URL(UploadMediaAPI / RecommendItemAPI / PublishItemAPI),
|
||||
// 通过 dispatchTransport 按 api query 参数分发到不同本地 handler,覆盖各 mtop 调用路径。
|
||||
|
||||
type dispatchTransport struct {
|
||||
@@ -78,6 +78,7 @@ func TestPublishItemValidationFailures(t *testing.T) {
|
||||
func TestPublishItemDescriptionDefaultsToTitle(t *testing.T) {
|
||||
png1 := tinyPNG(t)
|
||||
var gotDesc string
|
||||
var publishedData map[string]any
|
||||
dt := &dispatchTransport{handlers: map[string]http.HandlerFunc{
|
||||
"_upload": func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"object":{"url":"https://cdn/a.jpg","pix":"800x600"}}`)
|
||||
@@ -96,10 +97,8 @@ func TestPublishItemDescriptionDefaultsToTitle(t *testing.T) {
|
||||
}
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"categoryPredictResult":{"catId":"c1","catName":"类目"}}}`)
|
||||
},
|
||||
"mtop.taobao.idle.local.poi.get": func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"commonAddresses":[{"area":"X","city":"Y","divisionId":"1","longitude":118.7,"latitude":31.9,"poiId":"p1","poi":"P","prov":"Z"}]}}`)
|
||||
},
|
||||
"mtop.idle.pc.idleitem.publish": func(w http.ResponseWriter, r *http.Request) {
|
||||
publishedData, _ = parseDataURL(readBody(r))
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"itemId":"new-item-1"}}`)
|
||||
},
|
||||
}}
|
||||
@@ -110,6 +109,7 @@ func TestPublishItemDescriptionDefaultsToTitle(t *testing.T) {
|
||||
Quantity: 1,
|
||||
PostageMode: "fixed",
|
||||
PostageCents: 500,
|
||||
Location: &PublishLocation{Area: "X", City: "Y", DivisionID: "1", Longitude: 118.7, Latitude: 31.9, POIID: "p1", POIName: "P", Province: "Z"},
|
||||
Images: []PublishImage{{Filename: "a.png", ContentType: "image/png", Data: png1}},
|
||||
}
|
||||
res, err := client.PublishItem(context.Background(), consignCookies, req)
|
||||
@@ -128,6 +128,10 @@ func TestPublishItemDescriptionDefaultsToTitle(t *testing.T) {
|
||||
if res.ImageURL != "https://cdn/a.jpg" {
|
||||
t.Fatalf("ImageURL=%q", res.ImageURL)
|
||||
}
|
||||
addr, ok := publishedData["itemAddrDTO"].(map[string]any)
|
||||
if !ok || addr["gps"] != "31.9,118.7" {
|
||||
t.Fatalf("itemAddrDTO=%+v, gps should be latitude,longitude", publishedData["itemAddrDTO"])
|
||||
}
|
||||
}
|
||||
|
||||
// TestPublishItemUploadImageFailure: 图片上传失败导致 PublishItem 失败。
|
||||
@@ -210,7 +214,7 @@ func TestPublishItemRecommendCategoryMissingDataUsesElectronicMaterials(t *testi
|
||||
}
|
||||
}
|
||||
|
||||
// TestPublishItemLocationFailure: 默认地址缺失。
|
||||
// TestPublishItemLocationFailure: 实物发布没有选择发货地。
|
||||
func TestPublishItemLocationFailure(t *testing.T) {
|
||||
png1 := tinyPNG(t)
|
||||
dt := &dispatchTransport{handlers: map[string]http.HandlerFunc{
|
||||
@@ -220,9 +224,6 @@ func TestPublishItemLocationFailure(t *testing.T) {
|
||||
"mtop.taobao.idle.kgraph.property.recommend": func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"categoryPredictResult":{"catId":"c1","catName":"类目"}}}`)
|
||||
},
|
||||
"mtop.taobao.idle.local.poi.get": func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"commonAddresses":[]}}`)
|
||||
},
|
||||
}}
|
||||
client := &ClientImpl{HTTPClient: &http.Client{Transport: dt}}
|
||||
req := PublishItemRequest{
|
||||
@@ -232,7 +233,7 @@ func TestPublishItemLocationFailure(t *testing.T) {
|
||||
Images: []PublishImage{{Filename: "a.png", ContentType: "image/png", Data: png1}},
|
||||
}
|
||||
_, err := client.PublishItem(context.Background(), consignCookies, req)
|
||||
if err == nil || !strings.Contains(err.Error(), "缺少默认发货地址") {
|
||||
if err == nil || !strings.Contains(err.Error(), "必须选择发货地") {
|
||||
t.Fatalf("err=%v", err)
|
||||
}
|
||||
}
|
||||
@@ -364,9 +365,6 @@ func TestPublishItemFinalPublishFailure(t *testing.T) {
|
||||
"mtop.taobao.idle.kgraph.property.recommend": func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"categoryPredictResult":{"catId":"c1","catName":"类目"}}}`)
|
||||
},
|
||||
"mtop.taobao.idle.local.poi.get": func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"commonAddresses":[{"area":"X","city":"Y","divisionId":"1","longitude":118.7,"latitude":31.9,"poiId":"p1","poi":"P","prov":"Z"}]}}`)
|
||||
},
|
||||
"mtop.idle.pc.idleitem.publish": func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"ret":["FAIL_SYS_TOKEN_EXPIRED::令牌过期"]}`)
|
||||
},
|
||||
@@ -378,6 +376,7 @@ func TestPublishItemFinalPublishFailure(t *testing.T) {
|
||||
Quantity: 1,
|
||||
PostageMode: "fixed",
|
||||
PostageCents: 500,
|
||||
Location: &PublishLocation{Area: "X", City: "Y", DivisionID: "1", Longitude: 118.7, Latitude: 31.9, POIID: "p1", POIName: "P", Province: "Z"},
|
||||
Images: []PublishImage{{Filename: "a.png", ContentType: "image/png", Data: png1}},
|
||||
}
|
||||
_, err := client.PublishItem(context.Background(), consignCookies, req)
|
||||
@@ -400,9 +399,6 @@ func TestPublishItemStockPermissionError(t *testing.T) {
|
||||
"mtop.taobao.idle.kgraph.property.recommend": func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"categoryPredictResult":{"catId":"c1","catName":"类目"}}}`)
|
||||
},
|
||||
"mtop.taobao.idle.local.poi.get": func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"commonAddresses":[{"area":"X","city":"Y","divisionId":"1","longitude":118.7,"latitude":31.9,"poiId":"p1","poi":"P","prov":"Z"}]}}`)
|
||||
},
|
||||
"mtop.idle.pc.idleitem.publish": func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"ret":["账号没有库存发布权限"]}`)
|
||||
},
|
||||
@@ -412,6 +408,7 @@ func TestPublishItemStockPermissionError(t *testing.T) {
|
||||
Title: "T",
|
||||
PriceCents: 1000,
|
||||
Quantity: 1,
|
||||
Location: &PublishLocation{Area: "X", City: "Y", DivisionID: "1", Longitude: 118.7, Latitude: 31.9, POIID: "p1", POIName: "P", Province: "Z"},
|
||||
Images: []PublishImage{{Filename: "a.png", ContentType: "image/png", Data: png1}},
|
||||
}
|
||||
_, err := client.PublishItem(context.Background(), consignCookies, req)
|
||||
@@ -618,38 +615,6 @@ func TestRecommendPublishCategoryEmptyCatId(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- defaultPublishLocation 直接测试 ----
|
||||
|
||||
func TestDefaultPublishLocationSuccess(t *testing.T) {
|
||||
dt := &dispatchTransport{handlers: map[string]http.HandlerFunc{
|
||||
"mtop.taobao.idle.local.poi.get": func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"commonAddresses":[{"area":"A","city":"C","divisionId":"1","poiId":"p","poi":"P","prov":"PR"}]}}`)
|
||||
},
|
||||
}}
|
||||
client := &ClientImpl{HTTPClient: &http.Client{Transport: dt}}
|
||||
loc, _, err := client.defaultPublishLocation(context.Background(), consignCookies)
|
||||
if err != nil {
|
||||
t.Fatalf("err=%v", err)
|
||||
}
|
||||
if loc["area"] != "A" || loc["city"] != "C" {
|
||||
t.Fatalf("loc=%+v", loc)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultPublishLocationMalformedAddress(t *testing.T) {
|
||||
dt := &dispatchTransport{handlers: map[string]http.HandlerFunc{
|
||||
"mtop.taobao.idle.local.poi.get": func(w http.ResponseWriter, r *http.Request) {
|
||||
// commonAddresses[0] 不是 map
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"commonAddresses":["not-a-map"]}}`)
|
||||
},
|
||||
}}
|
||||
client := &ClientImpl{HTTPClient: &http.Client{Transport: dt}}
|
||||
_, _, err := client.defaultPublishLocation(context.Background(), consignCookies)
|
||||
if err == nil || !strings.Contains(err.Error(), "默认地址格式异常") {
|
||||
t.Fatalf("err=%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// ---- callMTop / buildMTopQuery ----
|
||||
|
||||
func TestCallMTopParseFailure(t *testing.T) {
|
||||
|
||||
@@ -108,6 +108,9 @@ func (c *ClientImpl) FetchSoldOrdersPage(ctx context.Context, cookies string, pa
|
||||
if err := json.Unmarshal(raw, &decoded); err != nil {
|
||||
return nil, fmt.Errorf("解析订单列表响应失败: %w (body=%s)", err, truncate(string(raw), 300))
|
||||
}
|
||||
if isSessionExpiredRet(decoded.Ret) {
|
||||
return nil, sessionExpiredError("订单列表接口", decoded.Ret)
|
||||
}
|
||||
if !hasMTopSuccess(decoded.Ret) {
|
||||
return nil, fmt.Errorf("订单列表接口返回非成功: ret=%v", decoded.Ret)
|
||||
}
|
||||
|
||||
@@ -77,6 +77,9 @@ func (c *ClientImpl) RefreshTokenWithCredentialContext(ctx context.Context, cook
|
||||
if isRiskVerificationRet(ret) {
|
||||
return refreshResultFromContext(ctx, currentCookies, currentSnapshot, currentSnapshotComplete, cookieStateChanged), &RiskVerificationError{Ret: ret, VerificationURL: verificationURL}
|
||||
}
|
||||
if isSessionExpiredRet(ret) {
|
||||
return refreshResultFromContext(ctx, currentCookies, currentSnapshot, currentSnapshotComplete, cookieStateChanged), sessionExpiredError("token API", ret)
|
||||
}
|
||||
if !isOfficialTokenRetryRet(ret) {
|
||||
return refreshResultFromContext(ctx, currentCookies, currentSnapshot, currentSnapshotComplete, cookieStateChanged), fmt.Errorf("token API 返回非成功: ret=%v (status=%d)", ret, status)
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ func (c *ClientImpl) FetchUserProfile(ctx context.Context, cookiesStr string) (*
|
||||
if res != nil {
|
||||
return res, nil
|
||||
}
|
||||
if isSessionExpiredRet(ret) {
|
||||
return nil, sessionExpiredError("账号资料接口", ret)
|
||||
}
|
||||
if !isTokenExpiredRet(ret) {
|
||||
return nil, fmt.Errorf("账号资料接口返回非成功: ret=%v", ret)
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.ydisks.xianyu-helper</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Ydisks闲鱼助手</string>
|
||||
<string>Ydisks Xianyu Helper</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Ydisks闲鱼助手</string>
|
||||
<string>Ydisks Xianyu Helper</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
/* English application display name. */
|
||||
"CFBundleName" = "Ydisks Xianyu Helper";
|
||||
"CFBundleDisplayName" = "Ydisks Xianyu Helper";
|
||||
@@ -0,0 +1,3 @@
|
||||
/* Simplified Chinese application display name. */
|
||||
"CFBundleName" = "Ydisks闲鱼助手";
|
||||
"CFBundleDisplayName" = "Ydisks闲鱼助手";
|
||||
@@ -0,0 +1,3 @@
|
||||
/* Chinese application display name. */
|
||||
"CFBundleName" = "Ydisks闲鱼助手";
|
||||
"CFBundleDisplayName" = "Ydisks闲鱼助手";
|
||||
@@ -60,6 +60,15 @@ mkdir -p "$APP/Contents/Resources/playwright-runtime/$ARCH"
|
||||
cp -R "$DIST_DIR/playwright-runtime/$ARCH/." "$APP/Contents/Resources/playwright-runtime/$ARCH/"
|
||||
cp "$PROJECT_ROOT/icon/macos/Assets.car" "$APP/Contents/Resources/Assets.car"
|
||||
cp "$PROJECT_ROOT/icon/macos/icon.icns" "$APP/Contents/Resources/icon.icns"
|
||||
mkdir -p "$APP/Contents/Resources/en.lproj" \
|
||||
"$APP/Contents/Resources/zh-Hans.lproj" \
|
||||
"$APP/Contents/Resources/zh-Hant.lproj"
|
||||
cp "$SCRIPT_DIR/Resources/en.lproj/InfoPlist.strings" \
|
||||
"$APP/Contents/Resources/en.lproj/InfoPlist.strings"
|
||||
cp "$SCRIPT_DIR/Resources/zh-Hans.lproj/InfoPlist.strings" \
|
||||
"$APP/Contents/Resources/zh-Hans.lproj/InfoPlist.strings"
|
||||
cp "$SCRIPT_DIR/Resources/zh-Hant.lproj/InfoPlist.strings" \
|
||||
"$APP/Contents/Resources/zh-Hant.lproj/InfoPlist.strings"
|
||||
sed "s/__VERSION__/$VERSION/g" "$SCRIPT_DIR/Info.plist" > "$APP/Contents/Info.plist"
|
||||
chmod 0755 "$APP/Contents/MacOS/Ydisks闲鱼助手" "$APP/Contents/Helpers/xianyu-server" "$APP_DIR/卸载 Ydisks闲鱼助手.command"
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
|
||||
$iconPath = (Resolve-Path (Join-Path $repoRoot 'icon\windows\icon.ico')).Path
|
||||
$winresTool = 'github.com/tc-hib/go-winres@v0.3.3'
|
||||
|
||||
$resourceSpecs = @(
|
||||
@{ Package = 'cmd\server'; Output = 'rsrc'; Manifest = 'cli'; Description = 'Ydisks Xianyu Helper server'; Filename = 'xianyu-server.exe' },
|
||||
@{ Package = 'cmd\tray'; Output = 'rsrc'; Manifest = 'gui'; Description = 'Ydisks Xianyu Helper tray'; Filename = 'xianyu-tray.exe' }
|
||||
)
|
||||
|
||||
foreach ($spec in $resourceSpecs) {
|
||||
$outputPrefix = Join-Path $repoRoot (Join-Path $spec.Package $spec.Output)
|
||||
$outputFile = "${outputPrefix}_windows_amd64.syso"
|
||||
Remove-Item -LiteralPath $outputFile -Force -ErrorAction SilentlyContinue
|
||||
|
||||
& go run $winresTool simply `
|
||||
--arch amd64 `
|
||||
--out $outputPrefix `
|
||||
--manifest $spec.Manifest `
|
||||
--icon $iconPath `
|
||||
--product-name 'Ydisks Xianyu Helper' `
|
||||
--file-description $spec.Description `
|
||||
--original-filename $spec.Filename
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "生成 Windows 资源失败: $($spec.Package)"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $outputFile -PathType Leaf)) {
|
||||
throw "Windows 资源文件未生成: $outputFile"
|
||||
}
|
||||
}
|
||||
+156
-11
@@ -1,30 +1,56 @@
|
||||
#define AppName "Ydisks Xianyu Helper"
|
||||
#define AppVersion GetEnv("APP_VERSION")
|
||||
#define AppPublisher "Christ9038"
|
||||
#define AppExeName "xianyu-server.exe"
|
||||
#define AppDataDir "{commonappdata}\YdisksXianyuHelper"
|
||||
#define RepoRoot AddBackslash(SourcePath) + "..\.."
|
||||
#define WindowsDistDir AddBackslash(RepoRoot) + "dist\windows"
|
||||
#define WindowsRuntimeDir AddBackslash(WindowsDistDir) + "playwright-runtime\amd64"
|
||||
#define WindowsIconDir AddBackslash(RepoRoot) + "icon\windows"
|
||||
#define WindowsLanguageDir AddBackslash(SourcePath) + "languages"
|
||||
|
||||
[Setup]
|
||||
AppId={{A6E8B04B-3C8A-4E20-AE62-6B1C3F6B31AE}
|
||||
AppName={#AppName}
|
||||
AppName={cm:ProductName}
|
||||
AppVersion={#AppVersion}
|
||||
AppPublisher={#AppPublisher}
|
||||
DefaultDirName={autopf}\Ydisks Xianyu Helper
|
||||
DefaultGroupName={#AppName}
|
||||
DefaultDirName={autopf}\{cm:ProductName}
|
||||
DefaultGroupName={cm:ProductName}
|
||||
OutputBaseFilename=Ydisks-Xianyu-Helper-Setup
|
||||
PrivilegesRequired=admin
|
||||
ArchitecturesInstallIn64BitMode=x64compatible
|
||||
DisableProgramGroupPage=yes
|
||||
UninstallDisplayIcon={app}\icon.ico
|
||||
SetupIconFile=..\..\icon\windows\icon.ico
|
||||
SetupIconFile={#WindowsIconDir}\icon.ico
|
||||
Compression=lzma2
|
||||
SolidCompression=yes
|
||||
|
||||
[Languages]
|
||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||
Name: "chinesesimplified"; MessagesFile: "{#WindowsLanguageDir}\ChineseSimplified.isl"
|
||||
Name: "chinesetraditional"; MessagesFile: "{#WindowsLanguageDir}\ChineseTraditional.isl"
|
||||
|
||||
[CustomMessages]
|
||||
english.ProductName=Ydisks Xianyu Helper
|
||||
chinesesimplified.ProductName=Ydisks闲鱼助手
|
||||
chinesetraditional.ProductName=Ydisks闲鱼助手
|
||||
english.StartMenuShortcut=Create a Start Menu shortcut
|
||||
chinesesimplified.StartMenuShortcut=创建开始菜单快捷方式
|
||||
chinesetraditional.StartMenuShortcut=创建开始菜单快捷方式
|
||||
english.DesktopShortcut=Create a desktop shortcut
|
||||
chinesesimplified.DesktopShortcut=创建桌面快捷方式
|
||||
chinesetraditional.DesktopShortcut=创建桌面快捷方式
|
||||
english.ShortcutOptions=Shortcut options:
|
||||
chinesesimplified.ShortcutOptions=快捷方式选项:
|
||||
chinesetraditional.ShortcutOptions=快捷方式选项:
|
||||
english.StartTray=Start tray controller
|
||||
chinesesimplified.StartTray=启动托盘控制器
|
||||
chinesetraditional.StartTray=启动托盘控制器
|
||||
|
||||
[Files]
|
||||
Source: "..\..\dist\windows\xianyu-server.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||
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: "{#WindowsDistDir}\xianyu-server.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#WindowsDistDir}\xianyu-tray.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#WindowsIconDir}\icon.ico"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#WindowsRuntimeDir}\*"; DestDir: "{app}\playwright-runtime"; Flags: recursesubdirs createallsubdirs ignoreversion
|
||||
Source: "service-control.ps1"; Flags: dontcopy
|
||||
Source: "service-control.ps1"; DestDir: "{app}"; Flags: ignoreversion
|
||||
|
||||
@@ -36,14 +62,36 @@ 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
|
||||
|
||||
[Tasks]
|
||||
Name: "startmenuicon"; Description: "{cm:StartMenuShortcut}"; GroupDescription: "{cm:ShortcutOptions}"
|
||||
Name: "desktopicon"; Description: "{cm:DesktopShortcut}"; GroupDescription: "{cm:ShortcutOptions}"; Flags: unchecked
|
||||
|
||||
[Icons]
|
||||
Name: "{group}\{cm:ProductName}"; Filename: "{app}\xianyu-tray.exe"; WorkingDir: "{app}"; IconFilename: "{app}\icon.ico"; Tasks: startmenuicon
|
||||
Name: "{autodesktop}\{cm:ProductName}"; Filename: "{app}\xianyu-tray.exe"; WorkingDir: "{app}"; IconFilename: "{app}\icon.ico"; Tasks: desktopicon
|
||||
|
||||
[Run]
|
||||
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
|
||||
Filename: "{app}\xianyu-tray.exe"; Description: "{cm:StartTray}"; Flags: nowait postinstall skipifsilent runasoriginaluser; Check: ServiceStartedSuccessfully
|
||||
|
||||
[UninstallRun]
|
||||
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]
|
||||
var
|
||||
ServiceRegistered: Boolean;
|
||||
ServiceStartFailed: Boolean;
|
||||
InstallationCompleted: Boolean;
|
||||
|
||||
function ServiceScriptParameters(const ScriptPath, Mode: String): String;
|
||||
begin
|
||||
Result := '-NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "' +
|
||||
ScriptPath + '" -Mode ' + Mode +
|
||||
' -ExePath "' + ExpandConstant('{app}\xianyu-server.exe') +
|
||||
'" -TrayPath "' + ExpandConstant('{app}\xianyu-tray.exe') +
|
||||
'" -WorkDir "' + ExpandConstant('{commonappdata}\YdisksXianyuHelper') +
|
||||
'" -RuntimeRoot "' + ExpandConstant('{app}\playwright-runtime') + '"';
|
||||
end;
|
||||
|
||||
function PrepareToInstall(var NeedsRestart: Boolean): String;
|
||||
var
|
||||
ResultCode: Integer;
|
||||
@@ -61,3 +109,100 @@ begin
|
||||
else if ResultCode <> 0 then
|
||||
Result := '旧版后台服务停止失败,错误码:' + IntToStr(ResultCode) + '。';
|
||||
end;
|
||||
|
||||
procedure RegisterWindowsService;
|
||||
var
|
||||
ResultCode: Integer;
|
||||
PowerShellPath: String;
|
||||
Parameters: String;
|
||||
begin
|
||||
PowerShellPath := ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe');
|
||||
Parameters := ServiceScriptParameters(
|
||||
ExpandConstant('{tmp}\service-control.ps1'), 'register') +
|
||||
' -CreatedMarkerPath "' + ExpandConstant('{tmp}\service-created.marker') + '"';
|
||||
|
||||
if not Exec(PowerShellPath, Parameters, '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
|
||||
begin
|
||||
Log('Unable to execute Windows service registration script.');
|
||||
SuppressibleMsgBox(
|
||||
'无法执行 Windows 服务注册脚本。请以管理员身份重新运行安装器。',
|
||||
mbError, MB_OK, IDOK);
|
||||
Abort;
|
||||
end;
|
||||
if ResultCode <> 0 then
|
||||
begin
|
||||
Log('Windows service registration failed, result code: ' + IntToStr(ResultCode));
|
||||
SuppressibleMsgBox(
|
||||
'Windows 服务注册失败(错误码:' + IntToStr(ResultCode) + ')。',
|
||||
mbError, MB_OK, IDOK);
|
||||
Abort;
|
||||
end;
|
||||
ServiceRegistered := True;
|
||||
end;
|
||||
|
||||
procedure StartWindowsService;
|
||||
var
|
||||
ResultCode: Integer;
|
||||
PowerShellPath: String;
|
||||
Parameters: String;
|
||||
begin
|
||||
PowerShellPath := ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe');
|
||||
Parameters := ServiceScriptParameters(
|
||||
ExpandConstant('{app}\service-control.ps1'), 'start');
|
||||
|
||||
ServiceStartFailed :=
|
||||
(not Exec(PowerShellPath, Parameters, '', SW_HIDE,
|
||||
ewWaitUntilTerminated, ResultCode)) or (ResultCode <> 0);
|
||||
if ServiceStartFailed then
|
||||
begin
|
||||
Log('Windows service failed to start, result code: ' + IntToStr(ResultCode));
|
||||
SuppressibleMsgBox(
|
||||
'Windows 后台服务未能启动(错误码:' + IntToStr(ResultCode) +
|
||||
')。安装器将返回失败,请查看安装日志。',
|
||||
mbError, MB_OK, IDOK);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure CleanupCreatedWindowsService;
|
||||
var
|
||||
ResultCode: Integer;
|
||||
ScriptPath: String;
|
||||
begin
|
||||
if not FileExists(ExpandConstant('{tmp}\service-created.marker')) then
|
||||
exit;
|
||||
ScriptPath := ExpandConstant('{tmp}\service-control.ps1');
|
||||
if FileExists(ScriptPath) then
|
||||
Exec(
|
||||
ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'),
|
||||
ServiceScriptParameters(ScriptPath, 'uninstall'),
|
||||
'', SW_HIDE, ewWaitUntilTerminated, ResultCode);
|
||||
end;
|
||||
|
||||
function ServiceStartedSuccessfully: Boolean;
|
||||
begin
|
||||
Result := ServiceRegistered and (not ServiceStartFailed);
|
||||
end;
|
||||
|
||||
function GetCustomSetupExitCode: Integer;
|
||||
begin
|
||||
if ServiceStartFailed then
|
||||
Result := 1001
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
procedure CurStepChanged(CurStep: TSetupStep);
|
||||
begin
|
||||
if CurStep = ssInstall then
|
||||
RegisterWindowsService
|
||||
else if CurStep = ssPostInstall then
|
||||
StartWindowsService
|
||||
else if CurStep = ssDone then
|
||||
InstallationCompleted := True;
|
||||
end;
|
||||
|
||||
procedure DeinitializeSetup;
|
||||
begin
|
||||
if not InstallationCompleted then
|
||||
CleanupCreatedWindowsService;
|
||||
end;
|
||||
@@ -0,0 +1,419 @@
|
||||
; *** Inno Setup version 6.5.0+ Chinese Simplified messages ***
|
||||
;
|
||||
; To download user-contributed translations of this file, go to:
|
||||
; https://jrsoftware.org/files/istrans/
|
||||
;
|
||||
; Note: When translating this text, do not add periods (.) to the end of
|
||||
; messages that didn't have them already, because on those messages Inno
|
||||
; Setup adds the periods automatically (appending a period would result in
|
||||
; two periods being displayed).
|
||||
;
|
||||
; Maintained by Zhenghan Yang
|
||||
; Email: 847320916@QQ.com
|
||||
; Translation based on network resource
|
||||
; The latest Translation is on https://github.com/kira-96/Inno-Setup-Chinese-Simplified-Translation
|
||||
;
|
||||
|
||||
[LangOptions]
|
||||
; The following three entries are very important. Be sure to read and
|
||||
; understand the '[LangOptions] section' topic in the help file.
|
||||
LanguageName=简体中文
|
||||
; If Language Name display incorrect, uncomment next line
|
||||
; LanguageName=<7B80><4F53><4E2D><6587>
|
||||
; About LanguageID, to reference link:
|
||||
; https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c
|
||||
LanguageID=$0804
|
||||
; About CodePage, to reference link:
|
||||
; https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
|
||||
LanguageCodePage=936
|
||||
; If the language you are translating to requires special font faces or
|
||||
; sizes, uncomment any of the following entries and change them accordingly.
|
||||
;DialogFontName=
|
||||
;DialogFontSize=9
|
||||
;DialogFontBaseScaleWidth=7
|
||||
;DialogFontBaseScaleHeight=15
|
||||
;WelcomeFontName=Segoe UI
|
||||
;WelcomeFontSize=14
|
||||
|
||||
[Messages]
|
||||
|
||||
; *** 应用程序标题
|
||||
SetupAppTitle=安装
|
||||
SetupWindowTitle=安装 - %1
|
||||
UninstallAppTitle=卸载
|
||||
UninstallAppFullTitle=%1 卸载
|
||||
|
||||
; *** Misc. common
|
||||
InformationTitle=信息
|
||||
ConfirmTitle=确认
|
||||
ErrorTitle=错误
|
||||
|
||||
; *** SetupLdr messages
|
||||
SetupLdrStartupMessage=现在将安装 %1。您想要继续吗?
|
||||
LdrCannotCreateTemp=无法创建临时文件。安装程序已中止
|
||||
LdrCannotExecTemp=无法执行临时目录中的文件。安装程序已中止
|
||||
HelpTextNote=
|
||||
|
||||
; *** 启动错误消息
|
||||
LastErrorMessage=%1。%n%n错误 %2: %3
|
||||
SetupFileMissing=安装目录中缺少文件 %1。请修正这个问题或者获取程序的新副本。
|
||||
SetupFileCorrupt=安装文件已损坏。请获取程序的新副本。
|
||||
SetupFileCorruptOrWrongVer=安装文件已损坏,或是与这个安装程序的版本不兼容。请修正这个问题或获取新的程序副本。
|
||||
InvalidParameter=无效的命令行参数:%n%n%1
|
||||
SetupAlreadyRunning=安装程序正在运行。
|
||||
WindowsVersionNotSupported=此程序不支持当前计算机运行的 Windows 版本。
|
||||
WindowsServicePackRequired=此程序需要 %1 服务包 %2 或更高版本。
|
||||
NotOnThisPlatform=此程序不能在 %1 上运行。
|
||||
OnlyOnThisPlatform=此程序只能在 %1 上运行。
|
||||
OnlyOnTheseArchitectures=此程序只能安装到为下列处理器架构设计的 Windows 版本中:%n%n%1
|
||||
WinVersionTooLowError=此程序需要 %1 版本 %2 或更高。
|
||||
WinVersionTooHighError=此程序不能安装于 %1 版本 %2 或更高。
|
||||
AdminPrivilegesRequired=在安装此程序时您必须以管理员身份登录。
|
||||
PowerUserPrivilegesRequired=在安装此程序时您必须以管理员身份或有权限的用户组身份登录。
|
||||
SetupAppRunningError=安装程序发现 %1 当前正在运行。%n%n请先关闭正在运行的程序,然后点击“确定”继续,或点击“取消”退出。
|
||||
UninstallAppRunningError=卸载程序发现 %1 当前正在运行。%n%n请先关闭正在运行的程序,然后点击“确定”继续,或点击“取消”退出。
|
||||
|
||||
; *** 启动问题
|
||||
PrivilegesRequiredOverrideTitle=选择安装程序模式
|
||||
PrivilegesRequiredOverrideInstruction=选择安装模式
|
||||
PrivilegesRequiredOverrideText1=%1 可以为所有用户安装(需要管理员权限),或仅为您安装。
|
||||
PrivilegesRequiredOverrideText2=%1 可以仅为您安装,或为所有用户安装(需要管理员权限)。
|
||||
PrivilegesRequiredOverrideAllUsers=为所有用户安装(&A)
|
||||
PrivilegesRequiredOverrideAllUsersRecommended=为所有用户安装(&A) (建议选项)
|
||||
PrivilegesRequiredOverrideCurrentUser=仅为我安装(&M)
|
||||
PrivilegesRequiredOverrideCurrentUserRecommended=仅为我安装(&M) (建议选项)
|
||||
|
||||
; *** 其他错误
|
||||
ErrorCreatingDir=安装程序无法创建目录“%1”
|
||||
ErrorTooManyFilesInDir=无法在目录“%1”中创建文件,因为里面包含太多文件
|
||||
|
||||
; *** 安装程序公共消息
|
||||
ExitSetupTitle=退出安装程序
|
||||
ExitSetupMessage=安装程序尚未完成。如果现在退出,将不会安装该程序。%n%n您之后可以再次运行安装程序完成安装。%n%n现在退出安装程序吗?
|
||||
AboutSetupMenuItem=关于安装程序(&A)...
|
||||
AboutSetupTitle=关于安装程序
|
||||
AboutSetupMessage=%1 版本 %2%n%3%n%n%1 主页:%n%4
|
||||
AboutSetupNote=
|
||||
TranslatorNote=简体中文翻译由Kira(847320916@qq.com)维护。项目地址:https://github.com/kira-96/Inno-Setup-Chinese-Simplified-Translation
|
||||
|
||||
; *** 按钮
|
||||
ButtonBack=< 上一步(&B)
|
||||
ButtonNext=下一步(&N) >
|
||||
ButtonInstall=安装(&I)
|
||||
ButtonOK=确定
|
||||
ButtonCancel=取消
|
||||
ButtonYes=是(&Y)
|
||||
ButtonYesToAll=全是(&A)
|
||||
ButtonNo=否(&N)
|
||||
ButtonNoToAll=全否(&O)
|
||||
ButtonFinish=完成(&F)
|
||||
ButtonBrowse=浏览(&B)...
|
||||
ButtonWizardBrowse=浏览(&R)...
|
||||
ButtonNewFolder=新建文件夹(&M)
|
||||
|
||||
; *** “选择语言”对话框消息
|
||||
SelectLanguageTitle=选择安装语言
|
||||
SelectLanguageLabel=选择安装时使用的语言。
|
||||
|
||||
; *** 公共向导文字
|
||||
ClickNext=点击“下一步”继续,或点击“取消”退出安装程序。
|
||||
BeveledLabel=
|
||||
BrowseDialogTitle=浏览文件夹
|
||||
BrowseDialogLabel=在下面的列表中选择一个文件夹,然后点击“确定”。
|
||||
NewFolderName=新建文件夹
|
||||
|
||||
; *** “欢迎”向导页
|
||||
WelcomeLabel1=欢迎使用 [name] 安装向导
|
||||
WelcomeLabel2=现在将安装 [name/ver] 到您的电脑中。%n%n建议您在继续安装前关闭所有其他应用程序。
|
||||
|
||||
; *** “密码”向导页
|
||||
WizardPassword=密码
|
||||
PasswordLabel1=这个安装程序有密码保护。
|
||||
PasswordLabel3=请输入密码,然后点击“下一步”继续。密码区分大小写。
|
||||
PasswordEditLabel=密码(&P):
|
||||
IncorrectPassword=您输入的密码不正确,请重新输入。
|
||||
|
||||
; *** “许可协议”向导页
|
||||
WizardLicense=许可协议
|
||||
LicenseLabel=请在继续安装前阅读以下重要信息。
|
||||
LicenseLabel3=请仔细阅读下列许可协议。在继续安装前您必须同意这些协议条款。
|
||||
LicenseAccepted=我同意此协议(&A)
|
||||
LicenseNotAccepted=我不同意此协议(&D)
|
||||
|
||||
; *** “信息”向导页
|
||||
WizardInfoBefore=信息
|
||||
InfoBeforeLabel=请在继续安装前阅读以下重要信息。
|
||||
InfoBeforeClickLabel=准备好继续安装后,点击“下一步”。
|
||||
WizardInfoAfter=信息
|
||||
InfoAfterLabel=请在继续安装前阅读以下重要信息。
|
||||
InfoAfterClickLabel=准备好继续安装后,点击“下一步”。
|
||||
|
||||
; *** “用户信息”向导页
|
||||
WizardUserInfo=用户信息
|
||||
UserInfoDesc=请输入您的信息。
|
||||
UserInfoName=用户名(&U):
|
||||
UserInfoOrg=组织(&O):
|
||||
UserInfoSerial=序列号(&S):
|
||||
UserInfoNameRequired=您必须输入用户名。
|
||||
|
||||
; *** “选择目标目录”向导页
|
||||
WizardSelectDir=选择目标位置
|
||||
SelectDirDesc=您想将 [name] 安装在哪里?
|
||||
SelectDirLabel3=安装程序将安装 [name] 到下面的文件夹中。
|
||||
SelectDirBrowseLabel=点击“下一步”继续。如果您想选择其他文件夹,点击“浏览”。
|
||||
DiskSpaceGBLabel=至少需要有 [gb] GB 的可用磁盘空间。
|
||||
DiskSpaceMBLabel=至少需要有 [mb] MB 的可用磁盘空间。
|
||||
CannotInstallToNetworkDrive=安装程序无法安装到一个网络驱动器。
|
||||
CannotInstallToUNCPath=安装程序无法安装到一个 UNC 路径。
|
||||
InvalidPath=您必须输入一个带驱动器卷标的完整路径,例如:%n%nC:\APP%n%n或UNC路径:%n%n\\server\share
|
||||
InvalidDrive=您选定的驱动器或 UNC 共享不存在或不能访问。请选择其他位置。
|
||||
DiskSpaceWarningTitle=磁盘空间不足
|
||||
DiskSpaceWarning=安装程序至少需要 %1 KB 的可用空间才能安装,但选定驱动器只有 %2 KB 的可用空间。%n%n您一定要继续吗?
|
||||
DirNameTooLong=文件夹名称或路径太长。
|
||||
InvalidDirName=文件夹名称无效。
|
||||
BadDirName32=文件夹名称不能包含下列任何字符:%n%n%1
|
||||
DirExistsTitle=文件夹已存在
|
||||
DirExists=文件夹:%n%n%1%n%n已经存在。您一定要安装到这个文件夹中吗?
|
||||
DirDoesntExistTitle=文件夹不存在
|
||||
DirDoesntExist=文件夹:%n%n%1%n%n不存在。您想要创建此文件夹吗?
|
||||
|
||||
; *** “选择组件”向导页
|
||||
WizardSelectComponents=选择组件
|
||||
SelectComponentsDesc=您想安装哪些程序组件?
|
||||
SelectComponentsLabel2=选中您想安装的组件;取消您不想安装的组件。然后点击“下一步”继续。
|
||||
FullInstallation=完全安装
|
||||
; if possible don't translate 'Compact' as 'Minimal' (I mean 'Minimal' in your language)
|
||||
CompactInstallation=简洁安装
|
||||
CustomInstallation=自定义安装
|
||||
NoUninstallWarningTitle=组件已存在
|
||||
NoUninstallWarning=安装程序检测到下列组件已安装在您的电脑中:%n%n%1%n%n取消选中这些组件不会卸载它们。%n%n确定要继续吗?
|
||||
ComponentSize1=%1 KB
|
||||
ComponentSize2=%1 MB
|
||||
ComponentsDiskSpaceGBLabel=当前选择的组件需要至少 [gb] GB 的磁盘空间。
|
||||
ComponentsDiskSpaceMBLabel=当前选择的组件需要至少 [mb] MB 的磁盘空间。
|
||||
|
||||
; *** “选择附加任务”向导页
|
||||
WizardSelectTasks=选择附加任务
|
||||
SelectTasksDesc=您想要安装程序执行哪些附加任务?
|
||||
SelectTasksLabel2=选择您想要安装程序在安装 [name] 时执行的附加任务,然后点击“下一步”。
|
||||
|
||||
; *** “选择开始菜单文件夹”向导页
|
||||
WizardSelectProgramGroup=选择开始菜单文件夹
|
||||
SelectStartMenuFolderDesc=安装程序应该在哪里放置程序的快捷方式?
|
||||
SelectStartMenuFolderLabel3=安装程序将在下列“开始”菜单文件夹中创建程序的快捷方式。
|
||||
SelectStartMenuFolderBrowseLabel=点击“下一步”继续。如果您想选择其他文件夹,点击“浏览”。
|
||||
MustEnterGroupName=您必须输入一个文件夹名。
|
||||
GroupNameTooLong=文件夹名或路径太长。
|
||||
InvalidGroupName=无效的文件夹名字。
|
||||
BadGroupName=文件夹名不能包含下列任何字符:%n%n%1
|
||||
NoProgramGroupCheck2=不创建开始菜单文件夹(&D)
|
||||
|
||||
; *** “准备安装”向导页
|
||||
WizardReady=准备安装
|
||||
ReadyLabel1=安装程序准备就绪,现在可以开始安装 [name] 到您的电脑。
|
||||
ReadyLabel2a=点击“安装”继续此安装程序。如果您想重新考虑或修改任何设置,点击“上一步”。
|
||||
ReadyLabel2b=点击“安装”继续此安装程序。
|
||||
ReadyMemoUserInfo=用户信息:
|
||||
ReadyMemoDir=目标位置:
|
||||
ReadyMemoType=安装类型:
|
||||
ReadyMemoComponents=已选择组件:
|
||||
ReadyMemoGroup=开始菜单文件夹:
|
||||
ReadyMemoTasks=附加任务:
|
||||
|
||||
; *** TExtractionWizardPage 向导页面与 ExtractArchive
|
||||
ExtractingLabel=正在解压文件...
|
||||
ButtonStopExtraction=停止解压(&S)
|
||||
StopExtraction=您确定要停止解压吗?
|
||||
ErrorExtractionAborted=解压已中止
|
||||
ErrorExtractionFailed=解压失败:%1
|
||||
|
||||
; *** 压缩文件解压失败详情
|
||||
ArchiveIncorrectPassword=压缩文件密码不正确
|
||||
ArchiveIsCorrupted=压缩文件已损坏
|
||||
ArchiveUnsupportedFormat=不支持的压缩文件格式
|
||||
|
||||
; *** TDownloadWizardPage 向导页面和 DownloadTemporaryFile
|
||||
DownloadingLabel2=正在下载文件...
|
||||
ButtonStopDownload=停止下载(&S)
|
||||
StopDownload=您确定要停止下载吗?
|
||||
ErrorDownloadAborted=下载已中止
|
||||
ErrorDownloadFailed=下载失败:%1 %2
|
||||
ErrorDownloadSizeFailed=获取下载大小失败:%1 %2
|
||||
ErrorProgress=无效的进度:%1 / %2
|
||||
ErrorFileSize=文件大小错误:预期 %1,实际 %2
|
||||
|
||||
; *** “正在准备安装”向导页
|
||||
WizardPreparing=正在准备安装
|
||||
PreparingDesc=安装程序正在准备安装 [name] 到您的电脑。
|
||||
PreviousInstallNotCompleted=先前的程序安装或卸载未完成,您需要重启您的电脑以完成。%n%n在重启电脑后,再次运行安装程序以完成 [name] 的安装。
|
||||
CannotContinue=安装程序不能继续。请点击“取消”退出。
|
||||
ApplicationsFound=以下应用程序正在使用将由安装程序更新的文件。建议您允许安装程序自动关闭这些应用程序。
|
||||
ApplicationsFound2=以下应用程序正在使用将由安装程序更新的文件。建议您允许安装程序自动关闭这些应用程序。安装完成后,安装程序将尝试重新启动这些应用程序。
|
||||
CloseApplications=自动关闭应用程序(&A)
|
||||
DontCloseApplications=不要关闭应用程序(&D)
|
||||
ErrorCloseApplications=安装程序无法自动关闭所有应用程序。建议您在继续之前,关闭所有在使用需要由安装程序更新的文件的应用程序。
|
||||
PrepareToInstallNeedsRestart=安装程序必须重启您的计算机。计算机重启后,请再次运行安装程序以完成 [name] 的安装。%n%n是否立即重新启动?
|
||||
|
||||
; *** “正在安装”向导页
|
||||
WizardInstalling=正在安装
|
||||
InstallingLabel=安装程序正在安装 [name] 到您的电脑,请稍候。
|
||||
|
||||
; *** “安装完成”向导页
|
||||
FinishedHeadingLabel=[name] 安装完成
|
||||
FinishedLabelNoIcons=安装程序已在您的电脑中安装了 [name]。
|
||||
FinishedLabel=安装程序已在您的电脑中安装了 [name]。您可以通过已安装的快捷方式运行此应用程序。
|
||||
ClickFinish=点击“完成”退出安装程序。
|
||||
FinishedRestartLabel=为完成 [name] 的安装,安装程序必须重新启动您的电脑。要立即重启吗?
|
||||
FinishedRestartMessage=为完成 [name] 的安装,安装程序必须重新启动您的电脑。%n%n要立即重启吗?
|
||||
ShowReadmeCheck=是,我想查阅自述文件
|
||||
YesRadio=是,立即重启电脑(&Y)
|
||||
NoRadio=否,稍后重启电脑(&N)
|
||||
; used for example as 'Run MyProg.exe'
|
||||
RunEntryExec=运行 %1
|
||||
; used for example as 'View Readme.txt'
|
||||
RunEntryShellExec=查阅 %1
|
||||
|
||||
; *** “安装程序需要下一张磁盘”提示
|
||||
ChangeDiskTitle=安装程序需要下一张磁盘
|
||||
SelectDiskLabel2=请插入磁盘 %1 并点击“确定”。%n%n如果这个磁盘中的文件可以在下列文件夹之外的文件夹中找到,请输入正确的路径或点击“浏览”。
|
||||
PathLabel=路径(&P):
|
||||
FileNotInDir2=“%2”中找不到文件“%1”。请插入正确的磁盘或选择其他文件夹。
|
||||
SelectDirectoryLabel=请指定下一张磁盘的位置。
|
||||
|
||||
; *** 安装阶段消息
|
||||
SetupAborted=安装程序未完成安装。%n%n请修正这个问题并重新运行安装程序。
|
||||
AbortRetryIgnoreSelectAction=选择操作
|
||||
AbortRetryIgnoreRetry=重试(&T)
|
||||
AbortRetryIgnoreIgnore=忽略错误并继续(&I)
|
||||
AbortRetryIgnoreCancel=关闭安装程序
|
||||
RetryCancelSelectAction=选择操作
|
||||
RetryCancelRetry=重试(&T)
|
||||
RetryCancelCancel=取消(&C)
|
||||
|
||||
; *** 安装状态消息
|
||||
StatusClosingApplications=正在关闭应用程序...
|
||||
StatusCreateDirs=正在创建目录...
|
||||
StatusExtractFiles=正在提取文件...
|
||||
StatusDownloadFiles=正在下载文件...
|
||||
StatusCreateIcons=正在创建快捷方式...
|
||||
StatusCreateIniEntries=正在创建 INI 条目...
|
||||
StatusCreateRegistryEntries=正在创建注册表条目...
|
||||
StatusRegisterFiles=正在注册文件...
|
||||
StatusSavingUninstall=正在保存卸载信息...
|
||||
StatusRunProgram=正在完成安装...
|
||||
StatusRestartingApplications=正在重启应用程序...
|
||||
StatusRollback=正在撤销更改...
|
||||
|
||||
; *** 其他错误
|
||||
ErrorInternal2=内部错误:%1
|
||||
ErrorFunctionFailedNoCode=%1 失败
|
||||
ErrorFunctionFailed=%1 失败;错误代码 %2
|
||||
ErrorFunctionFailedWithMessage=%1 失败;错误代码 %2.%n%3
|
||||
ErrorExecutingProgram=无法执行文件:%n%1
|
||||
|
||||
; *** 注册表错误
|
||||
ErrorRegOpenKey=打开注册表项时出错:%n%1\%2
|
||||
ErrorRegCreateKey=创建注册表项时出错:%n%1\%2
|
||||
ErrorRegWriteKey=写入注册表项时出错:%n%1\%2
|
||||
|
||||
; *** INI 错误
|
||||
ErrorIniEntry=在文件“%1”中创建 INI 条目时出错。
|
||||
|
||||
; *** 文件复制错误
|
||||
FileAbortRetryIgnoreSkipNotRecommended=跳过此文件(&S) (不推荐)
|
||||
FileAbortRetryIgnoreIgnoreNotRecommended=忽略错误并继续(&I) (不推荐)
|
||||
SourceIsCorrupted=源文件已损坏
|
||||
SourceDoesntExist=源文件“%1”不存在
|
||||
SourceVerificationFailed=源文件验证失败: %1
|
||||
VerificationSignatureDoesntExist=签名文件“%1”不存在
|
||||
VerificationSignatureInvalid=签名文件“%1”无效
|
||||
VerificationKeyNotFound=签名文件“%1”使用了未知密钥
|
||||
VerificationFileNameIncorrect=文件名不正确
|
||||
VerificationFileTagIncorrect=文件标签不正确
|
||||
VerificationFileSizeIncorrect=文件大小不正确
|
||||
VerificationFileHashIncorrect=文件哈希值不正确
|
||||
ExistingFileReadOnly2=无法替换现有文件,它是只读的。
|
||||
ExistingFileReadOnlyRetry=移除只读属性并重试(&R)
|
||||
ExistingFileReadOnlyKeepExisting=保留现有文件(&K)
|
||||
ErrorReadingExistingDest=尝试读取现有文件时出错:
|
||||
FileExistsSelectAction=选择操作
|
||||
FileExists2=文件已经存在。
|
||||
FileExistsOverwriteExisting=覆盖已存在的文件(&O)
|
||||
FileExistsKeepExisting=保留现有的文件(&K)
|
||||
FileExistsOverwriteOrKeepAll=为所有冲突文件执行此操作(&D)
|
||||
ExistingFileNewerSelectAction=选择操作
|
||||
ExistingFileNewer2=现有的文件比安装程序将要安装的文件还要新。
|
||||
ExistingFileNewerOverwriteExisting=覆盖已存在的文件(&O)
|
||||
ExistingFileNewerKeepExisting=保留现有的文件(&K) (推荐)
|
||||
ExistingFileNewerOverwriteOrKeepAll=为所有冲突文件执行此操作(&D)
|
||||
ErrorChangingAttr=尝试更改下列现有文件的属性时出错:
|
||||
ErrorCreatingTemp=尝试在目标目录创建文件时出错:
|
||||
ErrorReadingSource=尝试读取下列源文件时出错:
|
||||
ErrorCopying=尝试复制下列文件时出错:
|
||||
ErrorDownloading=下载文件时出错:
|
||||
ErrorExtracting=解压压缩文件时出错:
|
||||
ErrorReplacingExistingFile=尝试替换现有文件时出错:
|
||||
ErrorRestartReplace=重启并替换失败:
|
||||
ErrorRenamingTemp=尝试重命名下列目标目录中的一个文件时出错:
|
||||
ErrorRegisterServer=无法注册 DLL/OCX:%1
|
||||
ErrorRegSvr32Failed=RegSvr32 失败;退出代码 %1
|
||||
ErrorRegisterTypeLib=无法注册类库:%1
|
||||
|
||||
; *** 卸载显示名字标记
|
||||
; used for example as 'My Program (32-bit)'
|
||||
UninstallDisplayNameMark=%1 (%2)
|
||||
; used for example as 'My Program (32-bit, All users)'
|
||||
UninstallDisplayNameMarks=%1 (%2, %3)
|
||||
UninstallDisplayNameMark32Bit=32 位
|
||||
UninstallDisplayNameMark64Bit=64 位
|
||||
UninstallDisplayNameMarkAllUsers=所有用户
|
||||
UninstallDisplayNameMarkCurrentUser=当前用户
|
||||
|
||||
; *** 安装后错误
|
||||
ErrorOpeningReadme=尝试打开自述文件时出错。
|
||||
ErrorRestartingComputer=安装程序无法重启电脑,请手动重启。
|
||||
|
||||
; *** 卸载消息
|
||||
UninstallNotFound=文件“%1”不存在。无法卸载。
|
||||
UninstallOpenError=文件“%1”不能被打开。无法卸载。
|
||||
UninstallUnsupportedVer=此版本的卸载程序无法识别卸载日志文件“%1”的格式。无法卸载
|
||||
UninstallUnknownEntry=卸载日志中遇到一个未知条目 (%1)
|
||||
ConfirmUninstall=您确认要完全移除 %1 及其所有组件吗?
|
||||
UninstallOnlyOnWin64=仅允许在 64 位 Windows 中卸载此程序。
|
||||
OnlyAdminCanUninstall=仅使用管理员权限的用户能完成此卸载。
|
||||
UninstallStatusLabel=正在从您的电脑中移除 %1,请稍候。
|
||||
UninstalledAll=已顺利从您的电脑中移除 %1。
|
||||
UninstalledMost=%1 卸载完成。%n%n有部分内容未能被删除,但您可以手动删除它们。
|
||||
UninstalledAndNeedsRestart=为完成 %1 的卸载,需要重启您的电脑。%n%n立即重启电脑吗?
|
||||
UninstallDataCorrupted=文件“%1”已损坏。无法卸载
|
||||
|
||||
; *** 卸载状态消息
|
||||
ConfirmDeleteSharedFileTitle=删除共享的文件吗?
|
||||
ConfirmDeleteSharedFile2=系统表示下列共享的文件已不有其他程序使用。您希望卸载程序删除这些共享的文件吗?%n%n如果删除这些文件,但仍有程序在使用这些文件,则这些程序可能出现异常。如果您不能确定,请选择“否”,在系统中保留这些文件以免引发问题。
|
||||
SharedFileNameLabel=文件名:
|
||||
SharedFileLocationLabel=位置:
|
||||
WizardUninstalling=卸载状态
|
||||
StatusUninstalling=正在卸载 %1...
|
||||
|
||||
; *** Shutdown block reasons
|
||||
ShutdownBlockReasonInstallingApp=正在安装 %1。
|
||||
ShutdownBlockReasonUninstallingApp=正在卸载 %1。
|
||||
|
||||
; The custom messages below aren't used by Setup itself, but if you make
|
||||
; use of them in your scripts, you'll want to translate them.
|
||||
|
||||
[CustomMessages]
|
||||
|
||||
NameAndVersion=%1 版本 %2
|
||||
AdditionalIcons=附加快捷方式:
|
||||
CreateDesktopIcon=创建桌面快捷方式(&D)
|
||||
CreateQuickLaunchIcon=创建快速启动栏快捷方式(&Q)
|
||||
ProgramOnTheWeb=%1 网站
|
||||
UninstallProgram=卸载 %1
|
||||
LaunchProgram=运行 %1
|
||||
AssocFileExtension=将 %2 文件扩展名与 %1 建立关联(&A)
|
||||
AssocingFileExtension=正在将 %2 文件扩展名与 %1 建立关联...
|
||||
AutoStartProgramGroupDescription=启动:
|
||||
AutoStartProgram=自动启动 %1
|
||||
AddonHostProgramNotFound=您选择的文件夹中无法找到 %1。%n%n您要继续吗?
|
||||
|
||||
@@ -0,0 +1,384 @@
|
||||
; *** Inno Setup version 6.1.0+ Chinese (Traditional) messages ***
|
||||
; Name: Enfeng Tsao, nelson22768384@gmail.com
|
||||
; Based on 5.5.3+ translations by Samuel Lee, Email: 751555749@qq.com
|
||||
; Translation based on network resource
|
||||
;
|
||||
; Note: When translating this text, do not add periods (.) to the end of
|
||||
; messages that didn't have them already, because on those messages Inno
|
||||
; Setup adds the periods automatically (appending a period would result in
|
||||
; two periods being displayed).
|
||||
|
||||
[LangOptions]
|
||||
; The following three entries are very important. Be sure to read and
|
||||
; understand the '[LangOptions] section' topic in the help file.
|
||||
LanguageName=<7e41><9ad4><4e2d><6587>
|
||||
LanguageID=$0404
|
||||
LanguageCodepage=950
|
||||
; If the language you are translating to requires special font faces or
|
||||
; sizes, uncomment any of the following entries and change them accordingly.
|
||||
;DialogFontName=
|
||||
;DialogFontSize=8
|
||||
;TitleFontName=Arial
|
||||
;TitleFontSize=29
|
||||
;WelcomeFontName=Verdana
|
||||
;WelcomeFontSize=12
|
||||
;CopyrightFontName=Arial
|
||||
;CopyrightFontSize=8
|
||||
|
||||
[Messages]
|
||||
|
||||
; *** Application titles
|
||||
SetupAppTitle=安裝程式
|
||||
SetupWindowTitle=%1 安裝程式
|
||||
UninstallAppTitle=解除安裝
|
||||
UninstallAppFullTitle=解除安裝 %1
|
||||
|
||||
; *** Misc. common
|
||||
InformationTitle=訊息
|
||||
ConfirmTitle=確認
|
||||
ErrorTitle=錯誤
|
||||
|
||||
; *** SetupLdr messages
|
||||
SetupLdrStartupMessage=這將會安裝 %1。您想要繼續嗎?
|
||||
LdrCannotCreateTemp=無法建立暫存檔案。安裝程式將會結束。
|
||||
LdrCannotExecTemp=無法執行暫存檔案。安裝程式將會結束。
|
||||
HelpTextNote=
|
||||
|
||||
; *** Startup error messages
|
||||
LastErrorMessage=%1%n%n錯誤 %2: %3
|
||||
SetupFileMissing=安裝資料夾中遺失檔案 %1。請修正此問題或重新取得此軟體。
|
||||
SetupFileCorrupt=安裝檔案已經損毀。請重新取得此軟體。
|
||||
SetupFileCorruptOrWrongVer=安裝檔案已經損毀,或與安裝程式的版本不符。請重新取得此軟體。
|
||||
InvalidParameter=某個無效的變量已被傳遞到了命令列:%n%n%1
|
||||
SetupAlreadyRunning=安裝程式已經在執行。
|
||||
WindowsVersionNotSupported=本安裝程式並不支援目前在電腦所運行的 Windows 版本。
|
||||
WindowsServicePackRequired=本安裝程式需要 %1 Service Pack %2 或更新。
|
||||
NotOnThisPlatform=這個程式無法在 %1 執行。
|
||||
OnlyOnThisPlatform=這個程式必須在 %1 執行。
|
||||
OnlyOnTheseArchitectures=這個程式只能在專門為以下處理器架構而設計的 Windows 上安裝:%n%n%1
|
||||
WinVersionTooLowError=這個程式必須在 %1 版本 %2 或以上的系統執行。
|
||||
WinVersionTooHighError=這個程式無法安裝在 %1 版本 %2 或以上的系統。
|
||||
AdminPrivilegesRequired=您必須登入成系統管理員以安裝這個程式。
|
||||
PowerUserPrivilegesRequired=您必須登入成具有系統管理員或 Power User 權限的使用者以安裝這個程式。
|
||||
SetupAppRunningError=安裝程式偵測到 %1 正在執行。%n%n請關閉該程式後按 「確定」 繼續,或按 「取消」 離開。
|
||||
UninstallAppRunningError=解除安裝程式偵測到 %1 正在執行。%n%n請關閉該程式後按 「確定」 繼續,或按 「取消」 離開。
|
||||
|
||||
; *** Startup questions
|
||||
PrivilegesRequiredOverrideTitle=選擇安裝程式安裝模式
|
||||
PrivilegesRequiredOverrideInstruction=選擇安裝模式
|
||||
PrivilegesRequiredOverrideText1=可以為所有使用者安裝 %1 (需要系統管理權限),或是僅為您安裝。
|
||||
PrivilegesRequiredOverrideText2=可以僅為您安裝 %1,或是為所有使用者安裝 (需要系統管理權限)。
|
||||
PrivilegesRequiredOverrideAllUsers=為所有使用者安裝 (&A)
|
||||
PrivilegesRequiredOverrideAllUsersRecommended=為所有使用者安裝 (建議選項) (&A)
|
||||
PrivilegesRequiredOverrideCurrentUser=僅為我安裝 (&M)
|
||||
PrivilegesRequiredOverrideCurrentUserRecommended=僅為我安裝 (建議選項) (&M)
|
||||
|
||||
; *** Misc. errors
|
||||
ErrorCreatingDir=安裝程式無法建立資料夾“%1”。
|
||||
ErrorTooManyFilesInDir=無法在資料夾“%1”內建立檔案,因為資料夾內有太多的檔案。
|
||||
|
||||
; *** Setup common messages
|
||||
ExitSetupTitle=結束安裝程式
|
||||
ExitSetupMessage=安裝尚未完成。如果您現在結束安裝程式,這個程式將不會被安裝。%n%n您可以稍後再執行安裝程式以完成安裝程序。您現在要結束安裝程式嗎?
|
||||
AboutSetupMenuItem=關於安裝程式 (&A)...
|
||||
AboutSetupTitle=關於安裝程式
|
||||
AboutSetupMessage=%1 版本 %2%n%3%n%n%1 網址:%n%4
|
||||
AboutSetupNote=
|
||||
TranslatorNote=
|
||||
|
||||
; *** Buttons
|
||||
ButtonBack=< 上一步(&B)
|
||||
ButtonInstall=安裝(&I)
|
||||
ButtonNext=下一步(&N) >
|
||||
ButtonOK=確定
|
||||
ButtonCancel=取消
|
||||
ButtonYes=是(&Y)
|
||||
ButtonYesToAll=全部皆是 (&A)
|
||||
ButtonNo=否(&N)
|
||||
ButtonNoToAll=全部皆否 (&O)
|
||||
ButtonFinish=完成 (&F)
|
||||
ButtonBrowse=瀏覽 (&B)...
|
||||
ButtonWizardBrowse=瀏覽 (&R)...
|
||||
ButtonNewFolder=建立新資料夾 (&M)
|
||||
|
||||
; *** "Select Language" dialog messages
|
||||
SelectLanguageTitle=選擇安裝語言
|
||||
SelectLanguageLabel=選擇在安裝過程中使用的語言:
|
||||
|
||||
; *** Common wizard text
|
||||
ClickNext=按 「下一步」 繼續安裝,或按 「取消」 結束安裝程式。
|
||||
BeveledLabel=
|
||||
BrowseDialogTitle=瀏覽資料夾
|
||||
BrowseDialogLabel=在下面的資料夾列表中選擇一個資料夾,然後按 「確定」。
|
||||
NewFolderName=新資料夾
|
||||
|
||||
; *** "Welcome" wizard page
|
||||
WelcomeLabel1=歡迎使用 [name] 安裝程式
|
||||
WelcomeLabel2=這個安裝程式將會安裝 [name/ver] 到您的電腦。%n%n我們強烈建議您在安裝過程中關閉其它的應用程式,以避免與安裝程式發生沖突。
|
||||
|
||||
; *** "Password" wizard page
|
||||
WizardPassword=密碼
|
||||
PasswordLabel1=這個安裝程式具有密碼保護。
|
||||
PasswordLabel3=請輸入密碼,然後按 「下一步」 繼續。密碼是區分大小寫的。
|
||||
PasswordEditLabel=密碼 (&P):
|
||||
IncorrectPassword=您輸入的密碼不正確,請重新輸入。
|
||||
|
||||
; *** "License Agreement" wizard page
|
||||
WizardLicense=授權合約
|
||||
LicenseLabel=請閱讀以下授權合約。
|
||||
LicenseLabel3=請閱讀以下授權合約,您必須接受合約的各項條款才能繼續安裝。
|
||||
LicenseAccepted=我同意 (&A)
|
||||
LicenseNotAccepted=我不同意 (&D)
|
||||
|
||||
; *** "Information" wizard pages
|
||||
WizardInfoBefore=訊息
|
||||
InfoBeforeLabel=在繼續安裝之前請閱讀以下重要資訊。
|
||||
InfoBeforeClickLabel=當您準備好繼續安裝,請按 「下一步」。
|
||||
WizardInfoAfter=訊息
|
||||
InfoAfterLabel=在繼續安裝之前請閱讀以下重要資訊。
|
||||
InfoAfterClickLabel=當您準備好繼續安裝,請按 「下一步」。
|
||||
|
||||
; *** "User Information" wizard page
|
||||
WizardUserInfo=使用者資訊
|
||||
UserInfoDesc=請輸入您的資料。
|
||||
UserInfoName=使用者名稱(&U):
|
||||
UserInfoOrg=組織(&O):
|
||||
UserInfoSerial=序號(&S):
|
||||
UserInfoNameRequired=您必須輸入您的名稱。
|
||||
|
||||
; *** "Select Destination Location" wizard page
|
||||
WizardSelectDir=選擇目的資料夾
|
||||
SelectDirDesc=選擇安裝程式安裝 [name] 的位置。
|
||||
SelectDirLabel3=安裝程式將會把 [name] 安裝到下面的資料夾。
|
||||
SelectDirBrowseLabel=按 「下一步」 繼續,如果您想選擇另一個資料夾,請按 「瀏覽」。
|
||||
DiskSpaceGBLabel=最少需要 [gb] GB 磁碟空間。
|
||||
DiskSpaceMBLabel=最少需要 [mb] MB 磁碟空間。
|
||||
CannotInstallToNetworkDrive=安裝程式無法安裝於網絡磁碟機。
|
||||
CannotInstallToUNCPath=安裝程式無法安裝於 UNC 路徑。
|
||||
InvalidPath=您必須輸入完整的路徑名稱及磁碟機代碼。%n%n例如 C:\App 或 UNC 路徑格式 \\伺服器\共用資料夾。
|
||||
InvalidDrive=您選取的磁碟機或 UNC 名稱不存在或無法存取,請選擇其他的目的地。
|
||||
DiskSpaceWarningTitle=磁碟空間不足
|
||||
DiskSpaceWarning=安裝程式需要至少 %1 KB 的磁碟空間,您所選取的磁碟只有 %2 KB 可用空間。%n%n您要繼續安裝嗎?
|
||||
DirNameTooLong=資料夾名稱或路徑太長。
|
||||
InvalidDirName=資料夾名稱不正確。
|
||||
BadDirName32=資料夾名稱不得包含以下特殊字元:%n%n%1
|
||||
DirExistsTitle=資料夾已經存在
|
||||
DirExists=資料夾:%n%n%1%n%n 已經存在。仍要安裝到該資料夾嗎?
|
||||
DirDoesntExistTitle=資料夾不存在
|
||||
DirDoesntExist=資料夾:%n%n%1%n%n 不存在。要建立該資料夾嗎?
|
||||
|
||||
; *** "Select Components" wizard page
|
||||
WizardSelectComponents=選擇元件
|
||||
SelectComponentsDesc=選擇將會被安裝的元件。
|
||||
SelectComponentsLabel2=選擇您想要安裝的元件;清除您不想安裝的元件。然後按 「下一步」 繼續安裝。
|
||||
FullInstallation=完整安裝
|
||||
; if possible don't translate 'Compact' as 'Minimal' (I mean 'Minimal' in your language)
|
||||
CompactInstallation=最小安裝
|
||||
CustomInstallation=自訂安裝
|
||||
NoUninstallWarningTitle=元件已存在
|
||||
NoUninstallWarning=安裝程式偵測到以下元件已經安裝在您的電腦上:%n%n%1%n%n取消選擇這些元件將不會移除它們。%n%n您仍然要繼續嗎?
|
||||
ComponentSize1=%1 KB
|
||||
ComponentSize2=%1 MB
|
||||
ComponentsDiskSpaceGBLabel=目前的選擇需要至少 [gb] GB 磁碟空間。
|
||||
ComponentsDiskSpaceMBLabel=目前的選擇需要至少 [mb] MB 磁碟空間。
|
||||
|
||||
; *** "Select Additional Tasks" wizard page
|
||||
WizardSelectTasks=選擇附加的工作
|
||||
SelectTasksDesc=選擇要執行的附加工作。
|
||||
SelectTasksLabel2=選擇安裝程式在安裝 [name] 時要執行的附加工作,然後按 「下一步」。
|
||||
|
||||
; *** "Select Start Menu Folder" wizard page
|
||||
WizardSelectProgramGroup=選擇「開始」功能表的資料夾
|
||||
SelectStartMenuFolderDesc=選擇安裝程式建立程式的捷徑的位置。
|
||||
SelectStartMenuFolderLabel3=安裝程式將會把程式的捷徑建立在下面的「開始」功能表資料夾。
|
||||
SelectStartMenuFolderBrowseLabel=按 「下一步」 繼續,如果您想選擇另一個資料夾,請按 「瀏覽」。
|
||||
MustEnterGroupName=您必須輸入一個資料夾的名稱。
|
||||
GroupNameTooLong=資料夾名稱或路徑太長。
|
||||
InvalidGroupName=資料夾名稱不正確。
|
||||
BadGroupName=資料夾名稱不得包含下列字元:%n%n%1
|
||||
NoProgramGroupCheck2=不要在「開始」功能表中建立資料夾 (&D)
|
||||
|
||||
; *** "Ready to Install" wizard page
|
||||
WizardReady=準備安裝
|
||||
ReadyLabel1=安裝程式將開始安裝 [name] 到您的電腦中。
|
||||
ReadyLabel2a=按下 「安裝」 繼續安裝,或按 「上一步」 重新檢視或設定各選項的內容。
|
||||
ReadyLabel2b=按下 「安裝」 繼續安裝。
|
||||
ReadyMemoUserInfo=使用者資訊
|
||||
ReadyMemoDir=目的資料夾:
|
||||
ReadyMemoType=安裝型態:
|
||||
ReadyMemoComponents=選擇的元件:
|
||||
ReadyMemoGroup=「開始」功能表資料夾:
|
||||
ReadyMemoTasks=附加工作:
|
||||
|
||||
; *** TDownloadWizardPage wizard page and DownloadTemporaryFile
|
||||
DownloadingLabel=正在下載額外檔案...
|
||||
ButtonStopDownload=停止下載 (&S)
|
||||
StopDownload=您確定要停止下載嗎?
|
||||
ErrorDownloadAborted=已停止下載
|
||||
ErrorDownloadFailed=下載失敗: %1 %2
|
||||
ErrorDownloadSizeFailed=取得檔案大小失敗: %1 %2
|
||||
ErrorFileHash1=檔案雜湊失敗: %1
|
||||
ErrorFileHash2=檔案雜湊無效: 必須為 %1,收到 %2
|
||||
ErrorProgress=進度無效: %1 之 %2
|
||||
ErrorFileSize=檔案大小無效: 必須為 %1,收到 %2
|
||||
|
||||
; *** "Preparing to Install" wizard page
|
||||
WizardPreparing=準備安裝程式
|
||||
PreparingDesc=安裝程式準備將 [name] 安裝到您的電腦上。
|
||||
PreviousInstallNotCompleted=先前的安裝/ 解除安裝尚未完成,您必須重新啟動電腦以完成該安裝。%n%n在重新啟動電腦之後,請再執行這個程式來安裝 [name]。
|
||||
CannotContinue=安裝程式無法繼續。請按 「取消」 離開。
|
||||
ApplicationsFound=下面的應用程式正在使用安裝程式所需要更新的檔案。建議您允許安裝程式自動關閉這些應用程式。
|
||||
ApplicationsFound2=下面的應用程式正在使用安裝程式所需要更新的檔案。建議您允許安裝程式自動關閉這些應用程式。當安裝過程結束後,本安裝程式將會嘗試重新開啟該應用程式。
|
||||
CloseApplications=關閉應用程式 (&A)
|
||||
DontCloseApplications=不要關閉應用程式 (&D)
|
||||
ErrorCloseApplications=安裝程式無法自動關閉所有應用程式。建議您在繼續前先關閉所有應用程式使用的檔案。
|
||||
PrepareToInstallNeedsRestart=安裝程式必須重新啟動您的電腦。重新啟動後,請再次執行安裝程式以完成 [name] 的安裝。%n%n您想要現在重新啟動電腦嗎?
|
||||
|
||||
; *** "Installing" wizard page
|
||||
WizardInstalling=正在安裝
|
||||
InstallingLabel=請稍候,安裝程式正在將 [name] 安裝到您的電腦上
|
||||
|
||||
; *** "Setup Completed" wizard page
|
||||
FinishedHeadingLabel=安裝完成
|
||||
FinishedLabelNoIcons=安裝程式已經將 [name] 安裝在您的電腦上。
|
||||
FinishedLabel=安裝程式已經將 [name] 安裝在您的電腦中,您可以選擇程式的圖示來執行該應用程式。
|
||||
ClickFinish=按 「完成」 以結束安裝程式。
|
||||
FinishedRestartLabel=要完成 [name] 的安裝,安裝程式必須重新啟動您的電腦。您想要現在重新啟動電腦嗎?
|
||||
FinishedRestartMessage=要完成 [name] 的安裝,安裝程式必須重新啟動您的電腦。%n%n您想要現在重新啟動電腦嗎?
|
||||
ShowReadmeCheck=是,我要閱讀讀我檔案。
|
||||
YesRadio=是,立即重新啟動電腦(&Y)
|
||||
NoRadio=否,我稍後重新啟動電腦(&N)
|
||||
; used for example as 'Run MyProg.exe'
|
||||
RunEntryExec=執行 %1
|
||||
; used for example as 'View Readme.txt'
|
||||
RunEntryShellExec=檢視 %1
|
||||
|
||||
; *** "Setup Needs the Next Disk"
|
||||
ChangeDiskTitle=安裝程式需要下一張磁片
|
||||
SelectDiskLabel2=請插入磁片 %1,然後按 「確定」。%n%n如果檔案不在以下所顯示的資料夾之中,請輸入正確的資料夾名稱或按 [瀏覽] 選取。
|
||||
PathLabel=路徑(&P):
|
||||
FileNotInDir2=檔案“%1”無法在“%2”找到。請插入正確的磁片或選擇其它的資料夾。
|
||||
SelectDirectoryLabel=請指定下一張磁片的位置。
|
||||
|
||||
; *** Installation phase messages
|
||||
SetupAborted=安裝沒有完成。%n%n請更正問題後重新安裝一次。
|
||||
AbortRetryIgnoreSelectAction=選取動作
|
||||
AbortRetryIgnoreRetry=請再試一次 (&T)
|
||||
AbortRetryIgnoreIgnore=略過錯誤並繼續 (&I)
|
||||
AbortRetryIgnoreCancel=取消安裝
|
||||
|
||||
; *** Installation status messages
|
||||
StatusClosingApplications=正在關閉應用程式...
|
||||
StatusCreateDirs=正在建立資料夾...
|
||||
StatusExtractFiles=正在解壓縮檔案...
|
||||
StatusCreateIcons=正在建立程式集圖示...
|
||||
StatusCreateIniEntries=寫入 INI 檔案的項目...
|
||||
StatusCreateRegistryEntries=正在更新系統登錄...
|
||||
StatusRegisterFiles=正在登錄檔案...
|
||||
StatusSavingUninstall=儲存解除安裝資訊...
|
||||
StatusRunProgram=正在完成安裝...
|
||||
StatusRestartingApplications=正在重新開啟應用程式...
|
||||
StatusRollback=正在復原變更...
|
||||
|
||||
; *** Misc. errors
|
||||
ErrorInternal2=內部錯誤: %1
|
||||
ErrorFunctionFailedNoCode=%1 失敗
|
||||
ErrorFunctionFailed=%1 失敗;代碼 %2
|
||||
ErrorFunctionFailedWithMessage=%1 失敗;代碼 %2.%n%3
|
||||
ErrorExecutingProgram=無法執行檔案:%n%1
|
||||
|
||||
; *** Registry errors
|
||||
ErrorRegOpenKey=無法開啟登錄鍵:%n%1\%2
|
||||
ErrorRegCreateKey=無法建立登錄項目:%n%1\%2
|
||||
ErrorRegWriteKey=無法變更登錄項目:%n%1\%2
|
||||
|
||||
; *** INI errors
|
||||
ErrorIniEntry=在檔案“%1”建立 INI 項目錯誤。
|
||||
|
||||
; *** File copying errors
|
||||
FileAbortRetryIgnoreSkipNotRecommended=略過這個檔案 (不建議) (&S)
|
||||
FileAbortRetryIgnoreIgnoreNotRecommended=略過錯誤並繼續 (不建議) (&I)
|
||||
SourceDoesntExist=來源檔案“%1”不存在。
|
||||
SourceIsCorrupted=來源檔案已經損毀。
|
||||
ExistingFileReadOnly2=無法取代現有檔案,因為檔案已標示為唯讀。
|
||||
ExistingFileReadOnlyRetry=移除唯讀屬性並重試 (&R)
|
||||
ExistingFileReadOnlyKeepExisting=保留現有檔案 (&K)
|
||||
ErrorReadingExistingDest=讀取一個已存在的檔案時發生錯誤:
|
||||
FileExistsSelectAction=選擇操作
|
||||
FileExists2=檔案已存在。
|
||||
FileExistsOverwriteExisting=覆寫現有檔案
|
||||
FileExistsKeepExisting=保留現有檔案 (&O)
|
||||
FileExistsOverwriteOrKeepAll=對下次衝突執行相同操作 (&D)
|
||||
ExistingFileNewerSelectAction=選擇操作
|
||||
ExistingFileNewer2=現有檔案比安裝程式嘗試安裝的檔案還新。
|
||||
ExistingFileNewerOverwriteExisting=覆寫現有檔案 (&O)
|
||||
ExistingFileNewerKeepExisting=保留現有檔案 (&K) (建議選項)
|
||||
ExistingFileNewerOverwriteOrKeepAll=對下次衝突執行相同操作 (&D)
|
||||
ErrorChangingAttr=在變更檔案屬性時發生錯誤:
|
||||
ErrorCreatingTemp=在目的資料夾中建立檔案時發生錯誤:
|
||||
ErrorReadingSource=讀取原始檔案時發生錯誤:
|
||||
ErrorCopying=複製檔案時發生錯誤:
|
||||
ErrorReplacingExistingFile=取代檔案時發生錯誤:
|
||||
ErrorRestartReplace=重新啟動電腦後取代檔案失敗:
|
||||
ErrorRenamingTemp=在目的資料夾變更檔案名稱時發生錯誤:
|
||||
ErrorRegisterServer=無法注冊 DLL/OCX 檔案: %1。
|
||||
ErrorRegSvr32Failed=RegSvr32 失敗;退出代碼 %1
|
||||
ErrorRegisterTypeLib=無法注冊類型庫: %1。
|
||||
|
||||
; *** Uninstall display name markings
|
||||
; used for example as 'My Program (32-bit)'
|
||||
UninstallDisplayNameMark=%1 (%2)
|
||||
; used for example as 'My Program (32-bit, All users)'
|
||||
UninstallDisplayNameMarks=%1 (%2, %3)
|
||||
UninstallDisplayNameMark32Bit=32 位元
|
||||
UninstallDisplayNameMark64Bit=64 位元
|
||||
UninstallDisplayNameMarkAllUsers=所有使用者
|
||||
UninstallDisplayNameMarkCurrentUser=目前使用者
|
||||
|
||||
; *** Post-installation errors
|
||||
ErrorOpeningReadme=開啟讀我檔案時發生錯誤。
|
||||
ErrorRestartingComputer=安裝程式無法重新啟動電腦,請自行重新啟動。
|
||||
|
||||
; *** Uninstaller messages
|
||||
UninstallNotFound=檔案“%1”不存在,無法解除安裝。
|
||||
UninstallOpenError=無法開啟檔案“%1”,無法解除安裝
|
||||
UninstallUnsupportedVer=這個版本的解除安裝程式無法辨識記錄檔 “%1” 之格式,無法解除安裝。
|
||||
UninstallUnknownEntry=解除安裝記錄檔中發現未知的記錄 (%1)。
|
||||
ConfirmUninstall=您確定要完全移除 %1 及其相關的檔案嗎?
|
||||
UninstallOnlyOnWin64=這個程式只能在 64 位元的 Windows 上解除安裝。
|
||||
OnlyAdminCanUninstall=這個程式要具備系統管理員權限的使用者方可解除安裝。
|
||||
UninstallStatusLabel=正在從您的電腦移除 %1 中,請稍候...
|
||||
UninstalledAll=%1 已經成功從您的電腦中移除。
|
||||
UninstalledMost=%1 解除安裝完成。%n%n某些檔案及元件無法移除,您可以自行刪除這些檔案。
|
||||
UninstalledAndNeedsRestart=要完成 %1 的解除安裝程序,您必須重新啟動電腦。%n%n您想要現在重新啟動電腦嗎?
|
||||
UninstallDataCorrupted=檔案“%1”已經損毀,無法解除安裝
|
||||
|
||||
; *** Uninstallation phase messages
|
||||
ConfirmDeleteSharedFileTitle=移除共用檔案
|
||||
ConfirmDeleteSharedFile2=系統顯示下列共用檔案已不再被任何程式所使用,您要移除這些檔案嗎?%n%n%1%n%n倘若您移除了以上檔案但仍有程式需要使用它們,將造成這些程式無法正常執行,因此您若無法確定請選擇 [否]。保留這些檔案在您的系統中不會造成任何損害。
|
||||
SharedFileNameLabel=檔案名稱:
|
||||
SharedFileLocationLabel=位置:
|
||||
WizardUninstalling=解除安裝狀態
|
||||
StatusUninstalling=正在解除安裝 %1...
|
||||
|
||||
; *** Shutdown block reasons
|
||||
ShutdownBlockReasonInstallingApp=正在安裝 %1。
|
||||
ShutdownBlockReasonUninstallingApp=正在解除安裝 %1。
|
||||
|
||||
; The custom messages below aren't used by Setup itself, but if you make
|
||||
; use of them in your scripts, you'll want to translate them.
|
||||
|
||||
[CustomMessages]
|
||||
|
||||
NameAndVersion=%1 版本 %2
|
||||
AdditionalIcons=附加圖示:
|
||||
CreateDesktopIcon=建立桌面圖示(&D)
|
||||
CreateQuickLaunchIcon=建立快速啟動圖示(&Q)
|
||||
ProgramOnTheWeb=%1 的網站
|
||||
UninstallProgram=解除安裝 %1
|
||||
LaunchProgram=啟動 %1
|
||||
AssocFileExtension=將 %1 與檔案副檔名 %2 產生關聯(&A)
|
||||
AssocingFileExtension=正在將 %1 與檔案副檔名 %2 產生關聯...
|
||||
AutoStartProgramGroupDescription=開啟:
|
||||
AutoStartProgram=自動開啟 %1
|
||||
AddonHostProgramNotFound=%1 無法在您所選的資料夾中找到。%n%n您是否還要繼續?
|
||||
@@ -1,13 +1,14 @@
|
||||
param(
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateSet('stop', 'install', 'uninstall')]
|
||||
[ValidateSet('stop', 'register', 'start', 'install', 'uninstall')]
|
||||
[string]$Mode,
|
||||
|
||||
[string]$ServiceName = 'YdisksXianyuHelper',
|
||||
[string]$ExePath = '',
|
||||
[string]$TrayPath = '',
|
||||
[string]$WorkDir = '',
|
||||
[string]$RuntimeRoot = ''
|
||||
[string]$RuntimeRoot = '',
|
||||
[string]$CreatedMarkerPath = ''
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
@@ -16,17 +17,30 @@ function Get-InstalledService {
|
||||
Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
function Test-ServiceInstalled {
|
||||
$service = Get-InstalledService
|
||||
if ($null -eq $service) {
|
||||
return $false
|
||||
}
|
||||
$service.Dispose()
|
||||
return $true
|
||||
}
|
||||
|
||||
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)
|
||||
)
|
||||
try {
|
||||
if ($service.Status -ne [System.ServiceProcess.ServiceControllerStatus]::Stopped) {
|
||||
Stop-Service -Name $ServiceName -ErrorAction Stop
|
||||
$service.WaitForStatus(
|
||||
[System.ServiceProcess.ServiceControllerStatus]::Stopped,
|
||||
[TimeSpan]::FromSeconds(30)
|
||||
)
|
||||
}
|
||||
} finally {
|
||||
$service.Dispose()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +74,16 @@ function Stop-InstalledComponents {
|
||||
Stop-InstalledService
|
||||
}
|
||||
|
||||
function Wait-ServiceDeleted {
|
||||
$deadline = [DateTime]::UtcNow.AddSeconds(30)
|
||||
while (Test-ServiceInstalled) {
|
||||
if ([DateTime]::UtcNow -ge $deadline) {
|
||||
throw "等待 Windows 服务 $ServiceName 删除超时"
|
||||
}
|
||||
Start-Sleep -Milliseconds 250
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-ScChecked {
|
||||
param([Parameter(ValueFromRemainingArguments = $true)][string[]]$Arguments)
|
||||
|
||||
@@ -97,38 +121,103 @@ function Grant-InteractiveUserServiceControl {
|
||||
Invoke-ScChecked sdset $ServiceName $updatedSddl
|
||||
}
|
||||
|
||||
function Assert-ServiceInstallParameters {
|
||||
if ([string]::IsNullOrWhiteSpace($ExePath) -or
|
||||
[string]::IsNullOrWhiteSpace($WorkDir) -or
|
||||
[string]::IsNullOrWhiteSpace($RuntimeRoot)) {
|
||||
throw '安装服务缺少 ExePath、WorkDir 或 RuntimeRoot'
|
||||
}
|
||||
}
|
||||
|
||||
function Register-InstalledService {
|
||||
Assert-ServiceInstallParameters
|
||||
Stop-InstalledComponents
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $WorkDir | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path (Join-Path $WorkDir 'data') | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path (Join-Path $WorkDir 'logs') | Out-Null
|
||||
|
||||
$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 (-not (Test-ServiceInstalled)) {
|
||||
if (-not [string]::IsNullOrWhiteSpace($CreatedMarkerPath)) {
|
||||
Set-Content -LiteralPath $CreatedMarkerPath -Value $ServiceName -Encoding ASCII
|
||||
}
|
||||
New-Service -Name $ServiceName `
|
||||
-BinaryPathName $binaryPath `
|
||||
-DisplayName 'Ydisks Xianyu Helper' `
|
||||
-StartupType Automatic `
|
||||
-ErrorAction Stop | Out-Null
|
||||
} else {
|
||||
Invoke-ScChecked config $ServiceName 'binPath=' $binaryPath
|
||||
}
|
||||
|
||||
Invoke-ScChecked config $ServiceName 'start=' 'delayed-auto'
|
||||
Invoke-ScChecked description $ServiceName 'Ydisks Xianyu Helper background service'
|
||||
Grant-InteractiveUserServiceControl
|
||||
|
||||
if (-not (Test-ServiceInstalled)) {
|
||||
throw "Windows 服务 $ServiceName 注册后无法查询"
|
||||
}
|
||||
}
|
||||
|
||||
function Start-InstalledService {
|
||||
$service = Get-InstalledService
|
||||
if ($null -eq $service) {
|
||||
throw "Windows 服务 $ServiceName 尚未注册"
|
||||
}
|
||||
|
||||
try {
|
||||
if ($service.Status -eq [System.ServiceProcess.ServiceControllerStatus]::StopPending) {
|
||||
$service.WaitForStatus(
|
||||
[System.ServiceProcess.ServiceControllerStatus]::Stopped,
|
||||
[TimeSpan]::FromSeconds(30)
|
||||
)
|
||||
$service.Refresh()
|
||||
}
|
||||
if ($service.Status -eq [System.ServiceProcess.ServiceControllerStatus]::StartPending) {
|
||||
$service.WaitForStatus(
|
||||
[System.ServiceProcess.ServiceControllerStatus]::Running,
|
||||
[TimeSpan]::FromSeconds(30)
|
||||
)
|
||||
$service.Refresh()
|
||||
}
|
||||
if ($service.Status -ne [System.ServiceProcess.ServiceControllerStatus]::Running) {
|
||||
Start-Service -Name $ServiceName -ErrorAction Stop
|
||||
$service.Refresh()
|
||||
$service.WaitForStatus(
|
||||
[System.ServiceProcess.ServiceControllerStatus]::Running,
|
||||
[TimeSpan]::FromSeconds(30)
|
||||
)
|
||||
$service.Refresh()
|
||||
}
|
||||
if ($service.Status -ne [System.ServiceProcess.ServiceControllerStatus]::Running) {
|
||||
throw "Windows 服务 $ServiceName 未进入运行状态: $($service.Status)"
|
||||
}
|
||||
} finally {
|
||||
$service.Dispose()
|
||||
}
|
||||
}
|
||||
|
||||
switch ($Mode) {
|
||||
'stop' {
|
||||
Stop-InstalledComponents
|
||||
}
|
||||
'register' {
|
||||
Register-InstalledService
|
||||
}
|
||||
'start' {
|
||||
Start-InstalledService
|
||||
}
|
||||
'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)
|
||||
)
|
||||
Register-InstalledService
|
||||
Start-InstalledService
|
||||
}
|
||||
'uninstall' {
|
||||
Stop-InstalledComponents
|
||||
if ($null -ne (Get-InstalledService)) {
|
||||
if (Test-ServiceInstalled) {
|
||||
Invoke-ScChecked delete $ServiceName
|
||||
Wait-ServiceDeleted
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user