chore: 项目基线提交 - 拼豆图纸生成器 V1.0 核心代码
- 前端: React+Vite 首页/AI专区, 算法库(MARD色板/量化/背景去除), API对接 - 后端: Express+SQLite, 兑换码/订单/支付/chibi生成, 风控+云端同步 - CI/CD: GitHub Actions + Docker + nginx 配置 - 文档: PRD/DESIGN/LAUNCH/ROADMAP/E2E/竞品对照等 15 份 - 工程: 任务看板(taskboard) + 健康巡检(agent-health) + Git流程(gitflow)
This commit is contained in:
commit
02762400fb
174 files changed
+28059
No files matched your search
@@ -0,0 +1,87 @@
|
||||
# Final E2E run for PERLER LAB — uses curl.exe -o to capture raw UTF-8 bytes,
|
||||
# then reads files with UTF-8 encoding (avoids PS pipeline codepage mangling).
|
||||
$ErrorActionPreference = "Stop"
|
||||
$base = "http://localhost:8788"
|
||||
$tmp = "D:\拼豆\perler-lab-server\data\e2e"
|
||||
New-Item -ItemType Directory -Path $tmp -Force | Out-Null
|
||||
Remove-Item "$tmp\*" -ErrorAction SilentlyContinue
|
||||
|
||||
# ---------- request bodies (UTF-8 no BOM) ----------
|
||||
$ordersBody = '{"packageName":"体验包","paymentMethod":"wechat"}'
|
||||
$genBody = '{"code":"CODEHERE","image":"data:image/png;base64,iVBORw0KGgo=","category":"pet","subtype":"cat","gridSize":64,"colorCount":24,"composition":"主体特写","detailTags":["眼睛更有神"]}'
|
||||
[System.IO.File]::WriteAllText("$tmp\orders.json", $ordersBody, (New-Object System.Text.UTF8Encoding($false)))
|
||||
[System.IO.File]::WriteAllText("$tmp\gen.template.json", $genBody, (New-Object System.Text.UTF8Encoding($false)))
|
||||
|
||||
function CurlJson($name, $method, $url, $dataFile, $extraHeaders) {
|
||||
$out = "$tmp\$name.json"
|
||||
$code = "$tmp\$name.code"
|
||||
$args = @("-s","-o",$out,"-w","%{http_code}", "-X",$method, $url, "-H","Content-Type: application/json; charset=utf-8")
|
||||
if ($dataFile) { $args += @("--data-binary", "@$dataFile") }
|
||||
if ($extraHeaders) { $args += $extraHeaders }
|
||||
curl.exe @args | Out-File $code -Encoding ascii -NoNewline
|
||||
$http = (Get-Content $code -Raw).Trim()
|
||||
$json = Get-Content $out -Raw -Encoding UTF8
|
||||
return @{ http = [int]$http; json = $json }
|
||||
}
|
||||
|
||||
$results = [ordered]@{}
|
||||
|
||||
# S1 health
|
||||
$h = curl.exe -s -o "$tmp\health.json" -w "%{http_code}" "$base/health"
|
||||
$results["S1_health"] = "GET /health -> HTTP $h `n $([System.IO.File]::ReadAllText("$tmp\health.json"))"
|
||||
|
||||
# S2 CORS preflight
|
||||
$p = curl.exe -s -o NUL -w "%{http_code}" -X OPTIONS "$base/api/codes/redeem" -H "Origin: http://localhost:5173" -H "Access-Control-Request-Method: POST" -H "Access-Control-Request-Headers: Content-Type"
|
||||
$hdrs = curl.exe -s -D - -o NUL "$base/health" -H "Origin: http://localhost:5173"
|
||||
$corsLine = ($hdrs | Select-String "Access-Control-Allow-Origin|Vary|Access-Control-Allow-Methods|Access-Control-Allow-Headers") -join "; "
|
||||
$results["S2_cors"] = "OPTIONS preflight -> HTTP $p (expect 204); real GET headers -> $corsLine"
|
||||
|
||||
# S3 create order
|
||||
$r = CurlJson "s3_orders" "POST" "$base/api/orders" "$tmp\orders.json"
|
||||
$o = $r.json | ConvertFrom-Json
|
||||
$orderNo = $o.order.orderNo
|
||||
$results["S3_orders"] = "POST /api/orders -> HTTP $($r.http) `n $($r.json) `n orderNo=$orderNo"
|
||||
|
||||
# S4 pay-callback
|
||||
$r = CurlJson "s4_cb" "POST" "$base/api/orders/$orderNo/pay-callback" "$tmp\orders.json"
|
||||
$o = $r.json | ConvertFrom-Json
|
||||
$accessCode = $o.accessCode
|
||||
$results["S4_callback"] = "POST pay-callback -> HTTP $($r.http) `n $($r.json) `n accessCode=$accessCode"
|
||||
|
||||
# S5 redeem
|
||||
$redeemBody = "{`"code`":`"$accessCode`"}"
|
||||
[System.IO.File]::WriteAllText("$tmp\redeem.json", $redeemBody, (New-Object System.Text.UTF8Encoding($false)))
|
||||
$r = CurlJson "s5_redeem" "POST" "$base/api/codes/redeem" "$tmp\redeem.json"
|
||||
$results["S5_redeem"] = "POST /api/codes/redeem -> HTTP $($r.http) `n $($r.json)"
|
||||
|
||||
# S6 consume
|
||||
$consumeBody = "{`"code`":`"$accessCode`",`"fileName`":`"test.png`"}"
|
||||
[System.IO.File]::WriteAllText("$tmp\consume.json", $consumeBody, (New-Object System.Text.UTF8Encoding($false)))
|
||||
$r = CurlJson "s6_consume" "POST" "$base/api/codes/consume" "$tmp\consume.json"
|
||||
$results["S6_consume"] = "POST /api/codes/consume -> HTTP $($r.http) `n $($r.json)"
|
||||
|
||||
# S7 generate
|
||||
$gBody = $genBody.Replace("CODEHERE", $accessCode)
|
||||
[System.IO.File]::WriteAllText("$tmp\gen.json", $gBody, (New-Object System.Text.UTF8Encoding($false)))
|
||||
$r = CurlJson "s7_gen" "POST" "$base/api/chibi/generate" "$tmp\gen.json"
|
||||
$g = $r.json | ConvertFrom-Json
|
||||
$results["S7_generate"] = "POST /api/chibi/generate -> HTTP $($r.http) `n image_prefix=$($g.image.Substring(0,22))... len=$($g.image.Length) `n downloadGrant=$($g.downloadGrant) `n access=$($g.access | ConvertTo-Json -Compress)"
|
||||
|
||||
# S8 redeem invalid code -> 404
|
||||
$invBody = '{"code":"ZZZZZZZZZZZZZZZZ"}'
|
||||
[System.IO.File]::WriteAllText("$tmp\inv.json", $invBody, (New-Object System.Text.UTF8Encoding($false)))
|
||||
$r = CurlJson "s8_inv" "POST" "$base/api/codes/redeem" "$tmp\inv.json"
|
||||
$results["S8_redeem_invalid"] = "POST redeem invalid code -> HTTP $($r.http) (expect 404) `n $($r.json)"
|
||||
|
||||
# S9 exhaust + generate -> 402
|
||||
$r = CurlJson "s9_consume2" "POST" "$base/api/codes/consume" "$tmp\consume.json"
|
||||
$results["S9a_exhaust"] = "POST consume (3rd use) -> HTTP $($r.http) `n $($r.json)"
|
||||
$r = CurlJson "s9_gen_exhausted" "POST" "$base/api/chibi/generate" "$tmp\gen.json"
|
||||
$results["S9b_generate_exhausted"] = "POST generate exhausted -> HTTP $($r.http) (expect 402) `n $($r.json)"
|
||||
|
||||
# ---------- output ----------
|
||||
$out = ""
|
||||
foreach ($k in $results.Keys) { $out += "=== $k ===`n$($results[$k])`n`n" }
|
||||
[System.IO.File]::WriteAllText("$tmp\summary.txt", $out, (New-Object System.Text.UTF8Encoding($false)))
|
||||
Write-Output "SUMMARY_WRITTEN: $tmp\summary.txt"
|
||||
Write-Output "accessCode=$accessCode orderNo=$orderNo"
|
||||
@@ -0,0 +1 @@
|
||||
{"code":"P74AB97BBYLHJE5X","fileName":"test.png"}
|
||||
@@ -0,0 +1 @@
|
||||
{"code":"P74AB97BBYLHJE5X","image":"data:image/png;base64,iVBORw0KGgo=","category":"pet","subtype":"cat","gridSize":64,"colorCount":24,"composition":"主体特写","detailTags":["眼睛更有神"]}
|
||||
@@ -0,0 +1 @@
|
||||
{"code":"CODEHERE","image":"data:image/png;base64,iVBORw0KGgo=","category":"pet","subtype":"cat","gridSize":64,"colorCount":24,"composition":"主体特写","detailTags":["眼睛更有神"]}
|
||||
@@ -0,0 +1 @@
|
||||
{"status":"ok","timestamp":"2026-08-13T13:18:36.344Z"}
|
||||
@@ -0,0 +1 @@
|
||||
{"code":"ZZZZZZZZZZZZZZZZ"}
|
||||
@@ -0,0 +1 @@
|
||||
{"packageName":"体验包","paymentMethod":"wechat"}
|
||||
@@ -0,0 +1 @@
|
||||
{"code":"P74AB97BBYLHJE5X"}
|
||||
@@ -0,0 +1 @@
|
||||
200
|
||||
@@ -0,0 +1 @@
|
||||
{"order":{"orderNo":"PL20260813211836731707","packageName":"体验包","amountCents":490,"paymentMethod":"wechat","status":"pending","createdAt":"2026-08-13T13:18:36.428Z"},"payment":{"url":"https://pay.mock.local/pay?orderNo=PL20260813211836731707&amount=490&method=wechat","qrCode":"https://pay.mock.local/qr?orderNo=PL20260813211836731707"}}
|
||||
@@ -0,0 +1 @@
|
||||
200
|
||||
@@ -0,0 +1 @@
|
||||
{"ok":true,"order":{"order_no":"PL20260813211836731707","package_name":"体验包","amount_cents":490,"payment_method":"wechat","status":"paid","access_code":"P74AB97BBYLHJE5X","created_at":"2026-08-13T13:18:36.428Z","paid_at":"2026-08-13T13:18:36.470Z"},"accessCode":"P74AB97BBYLHJE5X"}
|
||||
@@ -0,0 +1 @@
|
||||
200
|
||||
@@ -0,0 +1 @@
|
||||
{"access":{"code":"P74AB97BBYLHJE5X","packageType":"体验包","remainingUses":3,"totalUses":3}}
|
||||
@@ -0,0 +1 @@
|
||||
200
|
||||
@@ -0,0 +1 @@
|
||||
{"access":{"code":"P74AB97BBYLHJE5X","packageType":"体验包","remainingUses":2,"totalUses":3},"freeDownload":true}
|
||||
@@ -0,0 +1 @@
|
||||
200
|
||||
@@ -0,0 +1 @@
|
||||
{"image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAeUlEQVR4nO3PwQkAIBDAsNvfQdzRl0P4CEKhA6Sz1/m64YIGtKABLWhACxrQgga0oAEtaEALGtCCBrSgAS1oQAsa0IIGtKABLWhACxrQgga0oAEtaEALGtCCBrSgAS1oQAsa0IIGtKABLWhACxrQgga0oAEtaEALHrsh/MH/SPcVvQAAAABJRU5ErkJggg==","access":{"code":"P74AB97BBYLHJE5X","packageType":"体验包","remainingUses":1,"totalUses":3},"downloadGrant":"52e50e06-7218-456f-85e1-3567bf29faa9"}
|
||||
@@ -0,0 +1 @@
|
||||
404
|
||||
@@ -0,0 +1 @@
|
||||
{"error":"兑换码不存在,请检查后重试"}
|
||||
@@ -0,0 +1 @@
|
||||
200
|
||||
@@ -0,0 +1 @@
|
||||
{"access":{"code":"P74AB97BBYLHJE5X","packageType":"体验包","remainingUses":0,"totalUses":3},"freeDownload":false}
|
||||
@@ -0,0 +1 @@
|
||||
402
|
||||
@@ -0,0 +1 @@
|
||||
{"error":"生成次数不足"}
|
||||
@@ -0,0 +1,43 @@
|
||||
=== S1_health ===
|
||||
GET /health -> HTTP 200
|
||||
{"status":"ok","timestamp":"2026-08-13T13:18:36.344Z"}
|
||||
|
||||
=== S2_cors ===
|
||||
OPTIONS preflight -> HTTP 204 (expect 204); real GET headers -> Access-Control-Allow-Origin: http://localhost:5173; Vary: Origin; Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS; Access-Control-Allow-Headers: Content-Type, Authorization
|
||||
|
||||
=== S3_orders ===
|
||||
POST /api/orders -> HTTP 200
|
||||
{"order":{"orderNo":"PL20260813211836731707","packageName":"体验包","amountCents":490,"paymentMethod":"wechat","status":"pending","createdAt":"2026-08-13T13:18:36.428Z"},"payment":{"url":"https://pay.mock.local/pay?orderNo=PL20260813211836731707&amount=490&method=wechat","qrCode":"https://pay.mock.local/qr?orderNo=PL20260813211836731707"}}
|
||||
orderNo=PL20260813211836731707
|
||||
|
||||
=== S4_callback ===
|
||||
POST pay-callback -> HTTP 200
|
||||
{"ok":true,"order":{"order_no":"PL20260813211836731707","package_name":"体验包","amount_cents":490,"payment_method":"wechat","status":"paid","access_code":"P74AB97BBYLHJE5X","created_at":"2026-08-13T13:18:36.428Z","paid_at":"2026-08-13T13:18:36.470Z"},"accessCode":"P74AB97BBYLHJE5X"}
|
||||
accessCode=P74AB97BBYLHJE5X
|
||||
|
||||
=== S5_redeem ===
|
||||
POST /api/codes/redeem -> HTTP 200
|
||||
{"access":{"code":"P74AB97BBYLHJE5X","packageType":"体验包","remainingUses":3,"totalUses":3}}
|
||||
|
||||
=== S6_consume ===
|
||||
POST /api/codes/consume -> HTTP 200
|
||||
{"access":{"code":"P74AB97BBYLHJE5X","packageType":"体验包","remainingUses":2,"totalUses":3},"freeDownload":true}
|
||||
|
||||
=== S7_generate ===
|
||||
POST /api/chibi/generate -> HTTP 200
|
||||
image_prefix=data:image/png;base64,... len=262
|
||||
downloadGrant=52e50e06-7218-456f-85e1-3567bf29faa9
|
||||
access={"code":"P74AB97BBYLHJE5X","packageType":"体验包","remainingUses":1,"totalUses":3}
|
||||
|
||||
=== S8_redeem_invalid ===
|
||||
POST redeem invalid code -> HTTP 404 (expect 404)
|
||||
{"error":"兑换码不存在,请检查后重试"}
|
||||
|
||||
=== S9a_exhaust ===
|
||||
POST consume (3rd use) -> HTTP 200
|
||||
{"access":{"code":"P74AB97BBYLHJE5X","packageType":"体验包","remainingUses":0,"totalUses":3},"freeDownload":false}
|
||||
|
||||
=== S9b_generate_exhausted ===
|
||||
POST generate exhausted -> HTTP 402 (expect 402)
|
||||
{"error":"生成次数不足"}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user