refactor: 拆分品牌业务类型与页面方案
CI / Static checks (push) Has been cancelled
CI / Production build (push) Has been cancelled
CI / API integration (push) Has been cancelled
CI / Taro builds (acheng-campus-food) (push) Has been cancelled
CI / Taro builds (atelier-solopreneur) (push) Has been cancelled
CI / Taro builds (linjing-editorial) (push) Has been cancelled
CI / Browser regression (push) Has been cancelled
No files matched your search
@@ -1,23 +1,23 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"scope": "模板完成证据登记,保留命令、日志与产物哈希",
|
||||
"generatedAt": "2026-10-19T20:11:56.461+08:00",
|
||||
"generatedAt": "2026-10-20T09:00:52.740+00:00",
|
||||
"templates": {
|
||||
"acheng-campus-food": {
|
||||
"real-manifest-interaction": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"pnpm --filter @personal-brand/api test:integration",
|
||||
"ADMIN_URL=http://localhost:3005 pnpm --filter @personal-brand/taro exec playwright test test/browser/admin-editor.spec.ts"
|
||||
"ADMIN_URL=http://localhost:3000 pnpm --filter @personal-brand/taro exec playwright test test/browser/admin-editor.spec.ts"
|
||||
],
|
||||
"artifacts": [
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/api-integration.log",
|
||||
"sha256": "15a52767f4aeab336095a8046075e8a5817d2dc7400695ea9fa10c19072b1bd6"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20-final/api-integration.log",
|
||||
"sha256": "1efcc2e20c32dc9b42f960a6967a6e94a32aa9e49ca855c17d61b2bc7f6ab891"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/admin-editor.log",
|
||||
"sha256": "01323485f57007c7c932bc239ab07ad8147cfd3efef8eae885e524f90a93dd43"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20/admin-editor.log",
|
||||
"sha256": "281c1bba68b5f6e30438d925ea58d8454bd98cf538fab8217710c7dc4402d103"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
@@ -29,8 +29,12 @@
|
||||
],
|
||||
"artifacts": [
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/api-integration.log",
|
||||
"sha256": "15a52767f4aeab336095a8046075e8a5817d2dc7400695ea9fa10c19072b1bd6"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20-final/api-integration.log",
|
||||
"sha256": "1efcc2e20c32dc9b42f960a6967a6e94a32aa9e49ca855c17d61b2bc7f6ab891"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20-final/api-unit.log",
|
||||
"sha256": "8a7a4bbd46be04b7c89318b702886d75acdb3707d9035c789e1d0550fd052b6e"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
@@ -38,24 +42,24 @@
|
||||
"visual-reference": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"TEMPLATE_PREVIEW_VISUAL_EVIDENCE=/home/que01/Project/persionalBrand/.codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19 ADMIN_URL=http://localhost:3005 pnpm --filter @personal-brand/taro exec playwright test test/browser/template-preview-media.spec.ts"
|
||||
"TEMPLATE_PREVIEW_VISUAL_EVIDENCE=/home/que01/Project/persionalBrand/.codex-tasks/template-audit-execution/raw/visual-matrix-final ADMIN_URL=http://localhost:3000 pnpm --filter @personal-brand/taro exec playwright test test/browser/template-preview-media.spec.ts"
|
||||
],
|
||||
"artifacts": [
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/template-preview-media.log",
|
||||
"sha256": "70cb23333a92751d8d711bbb9c9e0351b4b27c4b3bf9cf92fa74cfc6e70d8886"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20/template-preview-media.log",
|
||||
"sha256": "3eb8132e3fae6c95e2820d2979422ab63ab93e52426de8bcd528fd16b36eba3c"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/01-acheng-campus-food-food-320.png",
|
||||
"sha256": "8e8725895c61af3b77202d00a40a61c4e17d298ff9d2d47940a87565d8089329"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-final/01-acheng-campus-food-food-320.png",
|
||||
"sha256": "3aa442379e6847eeda18b97df78fadb077f6b678ee09f99d692b8fd357d37422"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/01-acheng-campus-food-food-375.png",
|
||||
"sha256": "4cfb078edea3b5223d7bd11899daeac67b4ccf84828f234a600b7429f3e3048f"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-final/01-acheng-campus-food-food-375.png",
|
||||
"sha256": "a0cc26679391dc851056551dcd5b31f50603bfd0dc44a59bc5182ea377a2747f"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/01-acheng-campus-food-food-390.png",
|
||||
"sha256": "81113e44e82dc898a94d8755ff5ec8e248e4d5d0cb8eec7f100a694dc9d449da"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-final/01-acheng-campus-food-food-390.png",
|
||||
"sha256": "f5d517380140ed62bb306a79fdbf818e1846c7ff58ebf229c2c8ed1142221537"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
@@ -63,33 +67,21 @@
|
||||
"empty-error-branches": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"TEMPLATE_PREVIEW_VISUAL_EVIDENCE=/home/que01/Project/persionalBrand/.codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19 ADMIN_URL=http://localhost:3005 pnpm --filter @personal-brand/taro exec playwright test test/browser/template-preview-media.spec.ts",
|
||||
"ADMIN_URL=http://localhost:3005 pnpm --filter @personal-brand/taro exec playwright test test/browser/admin-editor.spec.ts"
|
||||
"TEMPLATE_PREVIEW_VISUAL_EVIDENCE=/home/que01/Project/persionalBrand/.codex-tasks/template-audit-execution/raw/visual-matrix-final ADMIN_URL=http://localhost:3000 pnpm --filter @personal-brand/taro exec playwright test test/browser/template-preview-media.spec.ts",
|
||||
"ADMIN_URL=http://localhost:3000 pnpm --filter @personal-brand/taro exec playwright test test/browser/admin-editor.spec.ts"
|
||||
],
|
||||
"artifacts": [
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/template-preview-media.log",
|
||||
"sha256": "70cb23333a92751d8d711bbb9c9e0351b4b27c4b3bf9cf92fa74cfc6e70d8886"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20/template-preview-media.log",
|
||||
"sha256": "3eb8132e3fae6c95e2820d2979422ab63ab93e52426de8bcd528fd16b36eba3c"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/admin-editor.log",
|
||||
"sha256": "01323485f57007c7c932bc239ab07ad8147cfd3efef8eae885e524f90a93dd43"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20/admin-editor.log",
|
||||
"sha256": "281c1bba68b5f6e30438d925ea58d8454bd98cf538fab8217710c7dc4402d103"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/empty-01-acheng-campus-food-food.png",
|
||||
"sha256": "57360e276a98b1a2623114acb64bc3fc826f69a3cf9dfb961961f0fced5d90af"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/empty-02-atelier-solopreneur-personal.png",
|
||||
"sha256": "32f6d6c2191da4aa23b4d27b2c89457db713aba46422eb7e7618f65676c70fd4"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/empty-03-linjing-editorial-personal.png",
|
||||
"sha256": "433a469d71f7fbe3514ff5ca8faf642848f6d64ebe09a076b60a2d160e7e8305"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/empty-04-linjing-editorial-doors.png",
|
||||
"sha256": "5eaa90f39e05766c86bebd35598d9130b7548c34a77d82ce85d1ff8b3e5311c9"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-final/empty-01-acheng-campus-food-food.png",
|
||||
"sha256": "2a8279db468ab65426f1cf5e13ff8dcffa6ef625bf9f3dd563165b8905a79043"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
@@ -100,16 +92,16 @@
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"pnpm --filter @personal-brand/api test:integration",
|
||||
"ADMIN_URL=http://localhost:3005 pnpm --filter @personal-brand/taro exec playwright test test/browser/admin-editor.spec.ts"
|
||||
"ADMIN_URL=http://localhost:3000 pnpm --filter @personal-brand/taro exec playwright test test/browser/admin-editor.spec.ts"
|
||||
],
|
||||
"artifacts": [
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/api-integration.log",
|
||||
"sha256": "15a52767f4aeab336095a8046075e8a5817d2dc7400695ea9fa10c19072b1bd6"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20-final/api-integration.log",
|
||||
"sha256": "1efcc2e20c32dc9b42f960a6967a6e94a32aa9e49ca855c17d61b2bc7f6ab891"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/admin-editor.log",
|
||||
"sha256": "01323485f57007c7c932bc239ab07ad8147cfd3efef8eae885e524f90a93dd43"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20/admin-editor.log",
|
||||
"sha256": "281c1bba68b5f6e30438d925ea58d8454bd98cf538fab8217710c7dc4402d103"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
@@ -121,8 +113,12 @@
|
||||
],
|
||||
"artifacts": [
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/api-integration.log",
|
||||
"sha256": "15a52767f4aeab336095a8046075e8a5817d2dc7400695ea9fa10c19072b1bd6"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20-final/api-integration.log",
|
||||
"sha256": "1efcc2e20c32dc9b42f960a6967a6e94a32aa9e49ca855c17d61b2bc7f6ab891"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20-final/api-unit.log",
|
||||
"sha256": "8a7a4bbd46be04b7c89318b702886d75acdb3707d9035c789e1d0550fd052b6e"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
@@ -130,23 +126,23 @@
|
||||
"visual-reference": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"TEMPLATE_PREVIEW_VISUAL_EVIDENCE=/home/que01/Project/persionalBrand/.codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19 ADMIN_URL=http://localhost:3005 pnpm --filter @personal-brand/taro exec playwright test test/browser/template-preview-media.spec.ts"
|
||||
"TEMPLATE_PREVIEW_VISUAL_EVIDENCE=/home/que01/Project/persionalBrand/.codex-tasks/template-audit-execution/raw/visual-matrix-final ADMIN_URL=http://localhost:3000 pnpm --filter @personal-brand/taro exec playwright test test/browser/template-preview-media.spec.ts"
|
||||
],
|
||||
"artifacts": [
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/template-preview-media.log",
|
||||
"sha256": "70cb23333a92751d8d711bbb9c9e0351b4b27c4b3bf9cf92fa74cfc6e70d8886"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20/template-preview-media.log",
|
||||
"sha256": "3eb8132e3fae6c95e2820d2979422ab63ab93e52426de8bcd528fd16b36eba3c"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/02-atelier-solopreneur-personal-320.png",
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-final/02-atelier-solopreneur-personal-320.png",
|
||||
"sha256": "e55af9899393c7f9cfba9bb2b5c6ad6c447f90cf28dddd94da8feb6702fc8477"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/02-atelier-solopreneur-personal-375.png",
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-final/02-atelier-solopreneur-personal-375.png",
|
||||
"sha256": "70d251ab829ebfc85dba7fd65ac423272af4af54b39f76d1bea9ebbe0f89bc2d"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/02-atelier-solopreneur-personal-390.png",
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-final/02-atelier-solopreneur-personal-390.png",
|
||||
"sha256": "a430e7c72f794d62f9f0248c52307b6f644ea5b6099ba6c8b929f365504c3b07"
|
||||
}
|
||||
],
|
||||
@@ -155,33 +151,21 @@
|
||||
"empty-error-branches": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"TEMPLATE_PREVIEW_VISUAL_EVIDENCE=/home/que01/Project/persionalBrand/.codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19 ADMIN_URL=http://localhost:3005 pnpm --filter @personal-brand/taro exec playwright test test/browser/template-preview-media.spec.ts",
|
||||
"ADMIN_URL=http://localhost:3005 pnpm --filter @personal-brand/taro exec playwright test test/browser/admin-editor.spec.ts"
|
||||
"TEMPLATE_PREVIEW_VISUAL_EVIDENCE=/home/que01/Project/persionalBrand/.codex-tasks/template-audit-execution/raw/visual-matrix-final ADMIN_URL=http://localhost:3000 pnpm --filter @personal-brand/taro exec playwright test test/browser/template-preview-media.spec.ts",
|
||||
"ADMIN_URL=http://localhost:3000 pnpm --filter @personal-brand/taro exec playwright test test/browser/admin-editor.spec.ts"
|
||||
],
|
||||
"artifacts": [
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/template-preview-media.log",
|
||||
"sha256": "70cb23333a92751d8d711bbb9c9e0351b4b27c4b3bf9cf92fa74cfc6e70d8886"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20/template-preview-media.log",
|
||||
"sha256": "3eb8132e3fae6c95e2820d2979422ab63ab93e52426de8bcd528fd16b36eba3c"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/admin-editor.log",
|
||||
"sha256": "01323485f57007c7c932bc239ab07ad8147cfd3efef8eae885e524f90a93dd43"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20/admin-editor.log",
|
||||
"sha256": "281c1bba68b5f6e30438d925ea58d8454bd98cf538fab8217710c7dc4402d103"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/empty-01-acheng-campus-food-food.png",
|
||||
"sha256": "57360e276a98b1a2623114acb64bc3fc826f69a3cf9dfb961961f0fced5d90af"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/empty-02-atelier-solopreneur-personal.png",
|
||||
"sha256": "32f6d6c2191da4aa23b4d27b2c89457db713aba46422eb7e7618f65676c70fd4"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/empty-03-linjing-editorial-personal.png",
|
||||
"sha256": "433a469d71f7fbe3514ff5ca8faf642848f6d64ebe09a076b60a2d160e7e8305"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/empty-04-linjing-editorial-doors.png",
|
||||
"sha256": "5eaa90f39e05766c86bebd35598d9130b7548c34a77d82ce85d1ff8b3e5311c9"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-final/empty-02-atelier-solopreneur-personal.png",
|
||||
"sha256": "78982dd7aa7a8751e29969de9f68c6c3eab0bcdb2403f1a5442f10cc03b9a843"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
@@ -192,16 +176,16 @@
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"pnpm --filter @personal-brand/api test:integration",
|
||||
"ADMIN_URL=http://localhost:3005 pnpm --filter @personal-brand/taro exec playwright test test/browser/admin-editor.spec.ts"
|
||||
"ADMIN_URL=http://localhost:3000 pnpm --filter @personal-brand/taro exec playwright test test/browser/admin-editor.spec.ts"
|
||||
],
|
||||
"artifacts": [
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/api-integration.log",
|
||||
"sha256": "15a52767f4aeab336095a8046075e8a5817d2dc7400695ea9fa10c19072b1bd6"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20-final/api-integration.log",
|
||||
"sha256": "1efcc2e20c32dc9b42f960a6967a6e94a32aa9e49ca855c17d61b2bc7f6ab891"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/admin-editor.log",
|
||||
"sha256": "01323485f57007c7c932bc239ab07ad8147cfd3efef8eae885e524f90a93dd43"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20/admin-editor.log",
|
||||
"sha256": "281c1bba68b5f6e30438d925ea58d8454bd98cf538fab8217710c7dc4402d103"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
@@ -213,8 +197,12 @@
|
||||
],
|
||||
"artifacts": [
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/api-integration.log",
|
||||
"sha256": "15a52767f4aeab336095a8046075e8a5817d2dc7400695ea9fa10c19072b1bd6"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20-final/api-integration.log",
|
||||
"sha256": "1efcc2e20c32dc9b42f960a6967a6e94a32aa9e49ca855c17d61b2bc7f6ab891"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20-final/api-unit.log",
|
||||
"sha256": "8a7a4bbd46be04b7c89318b702886d75acdb3707d9035c789e1d0550fd052b6e"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
@@ -222,36 +210,24 @@
|
||||
"visual-reference": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"TEMPLATE_PREVIEW_VISUAL_EVIDENCE=/home/que01/Project/persionalBrand/.codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19 ADMIN_URL=http://localhost:3005 pnpm --filter @personal-brand/taro exec playwright test test/browser/template-preview-media.spec.ts"
|
||||
"TEMPLATE_PREVIEW_VISUAL_EVIDENCE=/home/que01/Project/persionalBrand/.codex-tasks/template-audit-execution/raw/visual-matrix-final ADMIN_URL=http://localhost:3000 pnpm --filter @personal-brand/taro exec playwright test test/browser/template-preview-media.spec.ts"
|
||||
],
|
||||
"artifacts": [
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/template-preview-media.log",
|
||||
"sha256": "70cb23333a92751d8d711bbb9c9e0351b4b27c4b3bf9cf92fa74cfc6e70d8886"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20/template-preview-media.log",
|
||||
"sha256": "3eb8132e3fae6c95e2820d2979422ab63ab93e52426de8bcd528fd16b36eba3c"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/03-linjing-editorial-personal-320.png",
|
||||
"sha256": "91ddbc9bd44476f55177320f241ba92dcedb80fb684aef525e0b25d5f7bbafc0"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-final/03-linjing-editorial-doors-320.png",
|
||||
"sha256": "d1569323ca5514b2348338a4c6f37bc3078c2e827e17943437efe8f437dd1188"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/03-linjing-editorial-personal-375.png",
|
||||
"sha256": "6ead246000fb3039924c3451785d02facedf1d91dc39d37b567be427825ee2bf"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-final/03-linjing-editorial-doors-375.png",
|
||||
"sha256": "48960348d896631b6c0c788a5528a21e7eefe3339dfffdbff43330c062f7b983"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/03-linjing-editorial-personal-390.png",
|
||||
"sha256": "46a2c912ec4d8ec0beaff9bd87fa0960b06dcdd52a341a6c487d5ecbb019b85a"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/04-linjing-editorial-doors-320.png",
|
||||
"sha256": "024c48d7f72d5466dade9734bb52252ac929be8fe8f0003c33ce742263d515b5"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/04-linjing-editorial-doors-375.png",
|
||||
"sha256": "22649b1c9bb680b88a70be890a7e869fe807a3ce9da5fb162d4d832c0ead39c8"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/04-linjing-editorial-doors-390.png",
|
||||
"sha256": "a9fbee6a7e96c267d5960bc85061433ac3400971dcfe1ef35c1a6344313ce1ba"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-final/03-linjing-editorial-doors-390.png",
|
||||
"sha256": "dd893c5958c3f4165ae988fef7be6882b27ccb3260112676ae296f2e6fef6be6"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
@@ -259,38 +235,26 @@
|
||||
"empty-error-branches": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"TEMPLATE_PREVIEW_VISUAL_EVIDENCE=/home/que01/Project/persionalBrand/.codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19 ADMIN_URL=http://localhost:3005 pnpm --filter @personal-brand/taro exec playwright test test/browser/template-preview-media.spec.ts",
|
||||
"ADMIN_URL=http://localhost:3005 pnpm --filter @personal-brand/taro exec playwright test test/browser/admin-editor.spec.ts"
|
||||
"TEMPLATE_PREVIEW_VISUAL_EVIDENCE=/home/que01/Project/persionalBrand/.codex-tasks/template-audit-execution/raw/visual-matrix-final ADMIN_URL=http://localhost:3000 pnpm --filter @personal-brand/taro exec playwright test test/browser/template-preview-media.spec.ts",
|
||||
"ADMIN_URL=http://localhost:3000 pnpm --filter @personal-brand/taro exec playwright test test/browser/admin-editor.spec.ts"
|
||||
],
|
||||
"artifacts": [
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/template-preview-media.log",
|
||||
"sha256": "70cb23333a92751d8d711bbb9c9e0351b4b27c4b3bf9cf92fa74cfc6e70d8886"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20/template-preview-media.log",
|
||||
"sha256": "3eb8132e3fae6c95e2820d2979422ab63ab93e52426de8bcd528fd16b36eba3c"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-19/admin-editor.log",
|
||||
"sha256": "01323485f57007c7c932bc239ab07ad8147cfd3efef8eae885e524f90a93dd43"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20/admin-editor.log",
|
||||
"sha256": "281c1bba68b5f6e30438d925ea58d8454bd98cf538fab8217710c7dc4402d103"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/empty-01-acheng-campus-food-food.png",
|
||||
"sha256": "57360e276a98b1a2623114acb64bc3fc826f69a3cf9dfb961961f0fced5d90af"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/empty-02-atelier-solopreneur-personal.png",
|
||||
"sha256": "32f6d6c2191da4aa23b4d27b2c89457db713aba46422eb7e7618f65676c70fd4"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/empty-03-linjing-editorial-personal.png",
|
||||
"sha256": "433a469d71f7fbe3514ff5ca8faf642848f6d64ebe09a076b60a2d160e7e8305"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-2026-10-19/empty-04-linjing-editorial-doors.png",
|
||||
"sha256": "5eaa90f39e05766c86bebd35598d9130b7548c34a77d82ce85d1ff8b3e5311c9"
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-final/empty-03-linjing-editorial-doors.png",
|
||||
"sha256": "d7b2b3197e426f1dd9b2ef99cd8682cb4c34531163b8ba5ebc90453438521970"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"sourceTreeHash": "34ff0c48bc5a76d57949e3fa234865f0a940ed3cd87f75ac2d7f5abee81fa5cd"
|
||||
"sourceTreeHash": "775950266c3ec796f5af6eafabedae91a1fa6c1d4c71b29ca8d5b589b4846473"
|
||||
}
|
||||
@@ -0,0 +1,440 @@
|
||||
|
||||
> @personal-brand/api@ test /home/que01/Project/persionalBrand/apps/api
|
||||
> tsx --test test/**/*.test.ts
|
||||
|
||||
TAP version 13
|
||||
# Subtest: 构建 worker 异常退出时返回明确非零结果
|
||||
ok 1 - 构建 worker 异常退出时返回明确非零结果
|
||||
---
|
||||
duration_ms: 80.679734
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 构建 worker watchdog 超时会终止子进程并返回 timedOut
|
||||
ok 2 - 构建 worker watchdog 超时会终止子进程并返回 timedOut
|
||||
---
|
||||
duration_ms: 36.587105
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 构建进度更新不触发发布状态机的顺序校验
|
||||
ok 3 - 构建进度更新不触发发布状态机的顺序校验
|
||||
---
|
||||
duration_ms: 1.684099
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 构建进度更新按品牌隔离,任务不存在时抛出 404
|
||||
ok 4 - 构建进度更新按品牌隔离,任务不存在时抛出 404
|
||||
---
|
||||
duration_ms: 0.989713
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 重新构建时可以清除上一次遗留的错误信息
|
||||
ok 5 - 重新构建时可以清除上一次遗留的错误信息
|
||||
---
|
||||
duration_ms: 0.32377
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 发布状态机仍拒绝越级变更并允许合法上传流转
|
||||
ok 6 - 发布状态机仍拒绝越级变更并允许合法上传流转
|
||||
---
|
||||
duration_ms: 0.879665
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 失败任务重试时可回到 built 并清除错误
|
||||
ok 7 - 失败任务重试时可回到 built 并清除错误
|
||||
---
|
||||
duration_ms: 0.423466
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: settings presentation never exposes plaintext credentials
|
||||
ok 8 - settings presentation never exposes plaintext credentials
|
||||
---
|
||||
duration_ms: 2.507469
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: update validates URL and private key before persistence
|
||||
ok 9 - update validates URL and private key before persistence
|
||||
---
|
||||
duration_ms: 2.477873
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: update encrypts a valid private key and preserves existing settings
|
||||
ok 10 - update encrypts a valid private key and preserves existing settings
|
||||
---
|
||||
duration_ms: 2.609961
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: upload blocks a currently building task before credentials are read
|
||||
ok 11 - upload blocks a currently building task before credentials are read
|
||||
---
|
||||
duration_ms: 2.803565
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: upload rejects invalid app configuration before building
|
||||
ok 12 - upload rejects invalid app configuration before building
|
||||
---
|
||||
duration_ms: 0.739001
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: failed build records logs and build failure state
|
||||
ok 13 - failed build records logs and build failure state
|
||||
---
|
||||
duration_ms: 11.162244
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: missing artifact records build failure without invoking upload
|
||||
ok 14 - missing artifact records build failure without invoking upload
|
||||
---
|
||||
duration_ms: 1.657659
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: upload rejects missing credentials before build
|
||||
ok 15 - upload rejects missing credentials before build
|
||||
---
|
||||
duration_ms: 0.580422
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: local mode reports configuration and returns a relative local upload URL
|
||||
ok 16 - local mode reports configuration and returns a relative local upload URL
|
||||
---
|
||||
duration_ms: 19.254692
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: upload service validates media type and traversal keys before persistence
|
||||
ok 17 - upload service validates media type and traversal keys before persistence
|
||||
---
|
||||
duration_ms: 5.35153
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: refactored admin controllers preserve their declared API routes
|
||||
ok 18 - refactored admin controllers preserve their declared API routes
|
||||
---
|
||||
duration_ms: 2.171245
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: root module composes bounded feature modules only
|
||||
ok 19 - root module composes bounded feature modules only
|
||||
---
|
||||
duration_ms: 0.224672
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 创建普通套餐订单时保存价格快照和预计金额
|
||||
ok 20 - 创建普通套餐订单时保存价格快照和预计金额
|
||||
---
|
||||
duration_ms: 3.15675
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 普通套餐不能在没有明细时创建
|
||||
ok 21 - 普通套餐不能在没有明细时创建
|
||||
---
|
||||
duration_ms: 1.103406
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 客户只能取消自己的 received 订单
|
||||
ok 22 - 客户只能取消自己的 received 订单
|
||||
---
|
||||
duration_ms: 0.528334
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 取消不存在或不属于当前客户的订单返回不存在
|
||||
ok 23 - 取消不存在或不属于当前客户的订单返回不存在
|
||||
---
|
||||
duration_ms: 0.329831
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 订单状态只能按定义的状态机流转
|
||||
ok 24 - 订单状态只能按定义的状态机流转
|
||||
---
|
||||
duration_ms: 0.789666
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 更新订单标签时拒绝其他品牌的标签
|
||||
ok 25 - 更新订单标签时拒绝其他品牌的标签
|
||||
---
|
||||
duration_ms: 0.44106
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 开发 seed 引用的本地媒体都有随仓库分发的源文件
|
||||
ok 26 - 开发 seed 引用的本地媒体都有随仓库分发的源文件
|
||||
---
|
||||
duration_ms: 1.65813
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 小程序产物根目录锚定仓库根目录,不随 API 进程工作目录变化
|
||||
ok 27 - 小程序产物根目录锚定仓库根目录,不随 API 进程工作目录变化
|
||||
---
|
||||
duration_ms: 1.317639
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 按模板包 key 生成唯一的微信小程序产物目录
|
||||
ok 28 - 按模板包 key 生成唯一的微信小程序产物目录
|
||||
---
|
||||
duration_ms: 0.275849
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 显式配置的产物根目录按仓库根目录解析相对路径
|
||||
ok 29 - 显式配置的产物根目录按仓库根目录解析相对路径
|
||||
---
|
||||
duration_ms: 0.170942
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 发布产物路径隔离品牌、模板版本和 attempt
|
||||
ok 30 - 发布产物路径隔离品牌、模板版本和 attempt
|
||||
---
|
||||
duration_ms: 0.400984
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 发布产物路径拒绝可能越界的品牌或模板字段
|
||||
ok 31 - 发布产物路径拒绝可能越界的品牌或模板字段
|
||||
---
|
||||
duration_ms: 0.578859
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 后台配置的请求地址优先于环境变量,改域名不需要动服务端配置
|
||||
ok 32 - 后台配置的请求地址优先于环境变量,改域名不需要动服务端配置
|
||||
---
|
||||
duration_ms: 1.515873
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 后台地址允许带路径前缀,保存前会去掉结尾斜杠
|
||||
ok 33 - 后台地址允许带路径前缀,保存前会去掉结尾斜杠
|
||||
---
|
||||
duration_ms: 0.593416
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 优先使用 MINIAPP_API_BASE_URL,去掉结尾斜杠
|
||||
ok 34 - 优先使用 MINIAPP_API_BASE_URL,去掉结尾斜杠
|
||||
---
|
||||
duration_ms: 0.192292
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 没有显式配置时由 PUBLIC_BASE_URL 加默认 /api 推导
|
||||
ok 35 - 没有显式配置时由 PUBLIC_BASE_URL 加默认 /api 推导
|
||||
---
|
||||
duration_ms: 0.18611
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 非 https 的公网地址必须被拒绝,避免再次打出 localhost 包
|
||||
ok 36 - 非 https 的公网地址必须被拒绝,避免再次打出 localhost 包
|
||||
---
|
||||
duration_ms: 0.437694
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 本地调试地址允许 http,方便开发环境构建
|
||||
ok 37 - 本地调试地址允许 http,方便开发环境构建
|
||||
---
|
||||
duration_ms: 0.195187
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: AppID 取品牌配置优先,回落 WEAPP_APP_ID,并拒绝占位值
|
||||
ok 38 - AppID 取品牌配置优先,回落 WEAPP_APP_ID,并拒绝占位值
|
||||
---
|
||||
duration_ms: 0.381347
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 构建中的任务在超过阈值未更新时视为已中断
|
||||
ok 39 - 构建中的任务在超过阈值未更新时视为已中断
|
||||
---
|
||||
duration_ms: 1.370659
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 非 building 状态永远不算中断,避免误伤正常流程
|
||||
ok 40 - 非 building 状态永远不算中断,避免误伤正常流程
|
||||
---
|
||||
duration_ms: 0.278604
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 时间戳异常时按未中断处理,宁可挡住重试也不允许并发构建
|
||||
ok 41 - 时间戳异常时按未中断处理,宁可挡住重试也不允许并发构建
|
||||
---
|
||||
duration_ms: 0.20209
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 阈值可通过环境变量覆盖,非法值回退到默认 30 分钟
|
||||
ok 42 - 阈值可通过环境变量覆盖,非法值回退到默认 30 分钟
|
||||
---
|
||||
duration_ms: 0.285577
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 构建超时阈值支持环境变量并有独立默认值
|
||||
ok 43 - 构建超时阈值支持环境变量并有独立默认值
|
||||
---
|
||||
duration_ms: 0.203984
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: CommonJS 形态的 miniprogram-ci 从 default 上取 Project 与 upload
|
||||
ok 44 - CommonJS 形态的 miniprogram-ci 从 default 上取 Project 与 upload
|
||||
---
|
||||
duration_ms: 1.180822
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 已是命名导出的模块可以直接使用
|
||||
ok 45 - 已是命名导出的模块可以直接使用
|
||||
---
|
||||
duration_ms: 0.218942
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 缺少 Project 或 upload 时抛出明确错误,而不是 undefined is not a constructor
|
||||
ok 46 - 缺少 Project 或 upload 时抛出明确错误,而不是 undefined is not a constructor
|
||||
---
|
||||
duration_ms: 0.67514
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 单行私钥(换行被输入框吞掉)可以还原为合法 PEM 并恢复签名能力
|
||||
ok 47 - 单行私钥(换行被输入框吞掉)可以还原为合法 PEM 并恢复签名能力
|
||||
---
|
||||
duration_ms: 46.62352
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 字面量 \\n 转义的私钥同样可以还原
|
||||
ok 48 - 字面量 \\n 转义的私钥同样可以还原
|
||||
---
|
||||
duration_ms: 35.171352
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 规范化是幂等的,不会反复改写已正确的 PEM
|
||||
ok 49 - 规范化是幂等的,不会反复改写已正确的 PEM
|
||||
---
|
||||
duration_ms: 93.585148
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 损坏或非 PEM 内容会被判定为无效,而不是静默保存
|
||||
ok 50 - 损坏或非 PEM 内容会被判定为无效,而不是静默保存
|
||||
---
|
||||
duration_ms: 45.896122
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 同一任务同一阶段的有效 lease 拒绝并发操作
|
||||
ok 51 - 同一任务同一阶段的有效 lease 拒绝并发操作
|
||||
---
|
||||
duration_ms: 2.956083
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 过期 lease 会先收敛为 timed_out,再允许新的 attempt 接管
|
||||
ok 52 - 过期 lease 会先收敛为 timed_out,再允许新的 attempt 接管
|
||||
---
|
||||
duration_ms: 0.652408
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 服务进程重建后从持久化记录恢复,并接管已过期的 build attempt
|
||||
ok 53 - 服务进程重建后从持久化记录恢复,并接管已过期的 build attempt
|
||||
---
|
||||
duration_ms: 0.790237
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: heartbeat 遇到过期上传 lease 时将任务阶段收敛为 timed_out
|
||||
ok 54 - heartbeat 遇到过期上传 lease 时将任务阶段收敛为 timed_out
|
||||
---
|
||||
duration_ms: 0.830002
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 错误 lease 不能结束操作,正确 lease 结束上传后更新阶段状态
|
||||
ok 55 - 错误 lease 不能结束操作,正确 lease 结束上传后更新阶段状态
|
||||
---
|
||||
duration_ms: 0.85031
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: heartbeat 续租并更新日志,结束后的 attempt 拒绝迟到 heartbeat
|
||||
ok 56 - heartbeat 续租并更新日志,结束后的 attempt 拒绝迟到 heartbeat
|
||||
---
|
||||
duration_ms: 1.451821
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 执行结束时 lease 已过期会持久化 timed_out,而不是回滚为 running
|
||||
ok 57 - 执行结束时 lease 已过期会持久化 timed_out,而不是回滚为 running
|
||||
---
|
||||
duration_ms: 0.48344
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 上传工作目录位于系统临时目录,不会落在仓库内
|
||||
ok 58 - 上传工作目录位于系统临时目录,不会落在仓库内
|
||||
---
|
||||
duration_ms: 1.278095
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: miniprogram-ci 的相对路径缓存目录落在临时工作目录而不是仓库
|
||||
ok 59 - miniprogram-ci 的相对路径缓存目录落在临时工作目录而不是仓库
|
||||
---
|
||||
duration_ms: 889.708804
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 上传会在临时工作目录下启动,失败也不会在仓库留下目录
|
||||
ok 60 - 上传会在临时工作目录下启动,失败也不会在仓库留下目录
|
||||
---
|
||||
duration_ms: 35.854056
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 上传在独立进程执行,失败时返回可读错误且不抛出未捕获异常
|
||||
ok 61 - 上传在独立进程执行,失败时返回可读错误且不抛出未捕获异常
|
||||
---
|
||||
duration_ms: 64.635283
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 上传超时会终止子进程并返回明确错误
|
||||
ok 62 - 上传超时会终止子进程并返回明确错误
|
||||
---
|
||||
duration_ms: 5.145082
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: miniprogram-ci compatibility patches keep overridden runtime APIs usable
|
||||
ok 63 - miniprogram-ci compatibility patches keep overridden runtime APIs usable
|
||||
---
|
||||
duration_ms: 681.182262
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: public default brand context fails fast when configuration is missing
|
||||
ok 64 - public default brand context fails fast when configuration is missing
|
||||
---
|
||||
duration_ms: 2.103899
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: every API route has an explicit authorization and success coverage contract
|
||||
ok 65 - every API route has an explicit authorization and success coverage contract
|
||||
---
|
||||
duration_ms: 503.725354
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: preview resources verify raster content and diagnose invalid or oversized assets
|
||||
ok 66 - preview resources verify raster content and diagnose invalid or oversized assets
|
||||
---
|
||||
duration_ms: 84.808494
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: preview resources reject image checksum drift and unavailable archives
|
||||
ok 67 - preview resources reject image checksum drift and unavailable archives
|
||||
---
|
||||
duration_ms: 63.867568
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: template preview matrix discovers newly added package manifests
|
||||
ok 68 - template preview matrix discovers newly added package manifests
|
||||
---
|
||||
duration_ms: 14.07272
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: template preview matrix keeps every deployed package, industry, and version isolated
|
||||
ok 69 - template preview matrix keeps every deployed package, industry, and version isolated
|
||||
---
|
||||
duration_ms: 923.427842
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 模板版本按 SemVer 而不是导入时间判断最新版
|
||||
ok 70 - 模板版本按 SemVer 而不是导入时间判断最新版
|
||||
---
|
||||
duration_ms: 1.899655
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: 模板版本排序正确处理预发布版本和同版本稳定性
|
||||
ok 71 - 模板版本排序正确处理预发布版本和同版本稳定性
|
||||
---
|
||||
duration_ms: 0.468962
|
||||
type: 'test'
|
||||
...
|
||||
1..71
|
||||
# tests 71
|
||||
# suites 0
|
||||
# pass 71
|
||||
# fail 0
|
||||
# cancelled 0
|
||||
# skipped 0
|
||||
# todo 0
|
||||
# duration_ms 2561.461139
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
Running 2 tests using 1 worker
|
||||
|
||||
(node:297051) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
|
||||
(Use `node --trace-warnings ...` to show where the warning was created)
|
||||
(node:297051) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
|
||||
(Use `node --trace-warnings ...` to show where the warning was created)
|
||||
✓ 1 test/browser/admin-editor.spec.ts:235:1 › Admin 按通用预览目标筛选字段并同步品牌草稿 (22.4s)
|
||||
✓ 2 test/browser/admin-editor.spec.ts:654:1 › 林境模板支持首页和主理人区域点选 (22.9s)
|
||||
|
||||
2 passed (46.2s)
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
Running 1 test using 1 worker
|
||||
|
||||
(node:297457) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
|
||||
(Use `node --trace-warnings ...` to show where the warning was created)
|
||||
(node:297457) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
|
||||
(Use `node --trace-warnings ...` to show where the warning was created)
|
||||
(node:297554) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
|
||||
(Use `node --trace-warnings ...` to show where the warning was created)
|
||||
(node:297665) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
|
||||
(Use `node --trace-warnings ...` to show where the warning was created)
|
||||
(node:297714) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
|
||||
(Use `node --trace-warnings ...` to show where the warning was created)
|
||||
✓ 1 test/browser/template-preview-media.spec.ts:154:1 › 导入包预览矩阵展示身份、资源和完整媒体槽位 (7.0s)
|
||||
|
||||
1 passed (7.9s)
|
||||
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 74 KiB |
|
After Width: | Height: | Size: 80 KiB |
|
After Width: | Height: | Size: 89 KiB |
@@ -1,6 +1,6 @@
|
||||
# Project Status
|
||||
|
||||
最后更新:2026-10-18
|
||||
最后更新:2026-10-20
|
||||
|
||||
## 当前阶段
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
- 三套已交付模板:
|
||||
- `acheng-campus-food@1.0.3`
|
||||
- `atelier-solopreneur@1.3.2`
|
||||
- `linjing-editorial@1.0.6`
|
||||
- `linjing-editorial@1.0.7`
|
||||
- Taro Runtime、Admin 组件预览、真实 manifest 驱动编辑、草稿/发布隔离。
|
||||
- 依赖 override 的运行时兼容性通过 `miniprogram-ci` / Jimp / image-size / uuid smoke test 守卫。
|
||||
- 小程序构建、上传任务状态机、attempt lease 和失败记录。
|
||||
@@ -67,7 +67,7 @@ unresolvedIssues=0
|
||||
- 当前三个新版本已通过模板导入服务导入并发布:
|
||||
- `acheng-campus-food@1.0.3`
|
||||
- `atelier-solopreneur@1.3.2`
|
||||
- `linjing-editorial@1.0.6`
|
||||
- `linjing-editorial@1.0.7`
|
||||
- 既有品牌安装仍锁定各自原版本,需通过 Admin 的显式升级流程升级,不在本任务中静默变更。
|
||||
|
||||
## 未决事项
|
||||
|
||||
@@ -270,19 +270,21 @@
|
||||
|
||||
以下为各页面的视觉结构约定,业务逻辑不变。
|
||||
|
||||
| 页面 | 结构要点 |
|
||||
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 登录 | 居中 400px 卡片,标识 + 说明 + 表单 + 通栏主按钮;错误态展示在字段下方 |
|
||||
| 首次改密 | 同登录卡片形态,说明文案 + 三个密码字段 + 「保存新密码」 |
|
||||
| 品牌概览 | 品牌卡 + 三张指标卡(等宽一行)+ 两栏(发布准备度 / 品牌内容检查) |
|
||||
| 配置与发布 | 三 Tab(内容发布 / 小程序发布 / 小程序配置);内容发布含「选择表达方式」(行业模板 + 视觉模板 + 版本升级/回滚)+ 发布状态卡 + 草稿卡 + 历史版本表 |
|
||||
| 小程序页面 | 左右两栏:左 380px 编辑面板,右预览画布;预览内选中区域虚线高亮 + 区域名气泡 |
|
||||
| 信任内容 | 列表行(类型图标或配图 + 标题 + 发布状态标签 + 类型/展示位置说明 + 两行摘要 + 行内操作),按模板类型顺序排列,不用表格 |
|
||||
| 业务提供项 | 表格(名称 / 价格 / 状态开关 / 排序 / 操作)+ 新增弹窗 |
|
||||
| 咨询记录 | 顶部三指标 + 左 380px 列表 + 右详情的主从布局 |
|
||||
| 咨询表单与字段 | 咨询表单表(名称 / 版本 / 字段数 / 状态 / 操作)+ 新增与编辑弹窗(含选项编辑);高级自定义字段表 + 新增弹窗 |
|
||||
| 能力插件 | 插件卡片列表(图标 + 名称 + 说明 + 开关),停用态降低对比度 |
|
||||
| 团队成员 | 表格(成员 / 角色 / 状态 / 最近登录 / 操作)+ 邀请弹窗 |
|
||||
| 页面 | 结构要点 |
|
||||
| -------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
||||
| 登录 | 居中 400px 卡片,标识 + 说明 + 表单 + 通栏主按钮;错误态展示在字段下方 |
|
||||
| 首次改密 | 同登录卡片形态,说明文案 + 三个密码字段 + 「保存新密码」 |
|
||||
| 品牌概览 | 品牌卡 + 三张指标卡(等宽一行)+ 两栏(发布准备度 / 品牌内容检查) |
|
||||
| 内容与发布 | 内容发布 / 小程序发布 / 小程序配置三个分区;内容发布含发布状态卡、草稿卡和历史版本表,不承载业务类型或页面方案选择 |
|
||||
| 页面方案 | 当前业务类型与页面方案 + 升级预览 + 版本选择 + 配置恢复 + 高级示例内容导入 |
|
||||
| 品牌管理 | 品牌列表与创建入口;创建品牌先选不可变的业务类型,再选兼容页面方案,创建时不导入示例内容 |
|
||||
| 小程序页面 | 左右两栏:左 380px 编辑面板,右预览画布;预览内选中区域虚线高亮 + 区域名气泡 |
|
||||
| 信任内容 | 列表行(类型图标或配图 + 标题 + 发布状态标签 + 类型/展示位置说明 + 两行摘要 + 行内操作),按模板类型顺序排列,不用表格 |
|
||||
| 业务提供项 | 表格(名称 / 价格 / 状态开关 / 排序 / 操作)+ 新增弹窗 |
|
||||
| 咨询记录 | 顶部三指标 + 左 380px 列表 + 右详情的主从布局 |
|
||||
| 咨询表单与字段 | 咨询表单表(名称 / 版本 / 字段数 / 状态 / 操作)+ 新增与编辑弹窗(含选项编辑);高级自定义字段表 + 新增弹窗 |
|
||||
| 能力插件 | 插件卡片列表(图标 + 名称 + 说明 + 开关),停用态降低对比度 |
|
||||
| 团队成员 | 表格(成员 / 角色 / 状态 / 最近登录 / 操作)+ 邀请弹窗 |
|
||||
|
||||
两栏页面在小屏下折叠为单列,编辑/预览改为上下排列。
|
||||
|
||||
|
||||
@@ -4,9 +4,11 @@ import {
|
||||
BarsOutlined,
|
||||
CloudUploadOutlined,
|
||||
FormOutlined,
|
||||
LayoutOutlined,
|
||||
MessageOutlined,
|
||||
MobileOutlined,
|
||||
SafetyCertificateOutlined,
|
||||
ShopOutlined,
|
||||
TeamOutlined,
|
||||
ThunderboltOutlined,
|
||||
} from "@ant-design/icons";
|
||||
@@ -16,10 +18,13 @@ import { BrandMark } from "../components/BrandMark.js";
|
||||
import { StatusTag } from "../components/StatusTag.js";
|
||||
import {
|
||||
FeatureBrandPage,
|
||||
FeatureBrandsPage,
|
||||
FeatureCapabilitiesPage,
|
||||
FeatureCreateBrandPage,
|
||||
FeatureInquiriesPage,
|
||||
FeatureMembersPage,
|
||||
FeatureOverviewPage,
|
||||
FeaturePageSchemePage,
|
||||
FeaturePublicationPage,
|
||||
FeatureTemplateManagementPage,
|
||||
FeatureServicesPage,
|
||||
@@ -34,6 +39,7 @@ import { AdminSelect } from "../components/AdminSelect.js";
|
||||
import { AdminLayout } from "../components/AdminLayout.js";
|
||||
import { Route, Routes } from "react-router-dom";
|
||||
import { AdminOverviewRedirect } from "./AdminRouter.js";
|
||||
import { createBrandRouteElement } from "./route-access.js";
|
||||
import { Suspense } from "react";
|
||||
|
||||
export function Dashboard({
|
||||
@@ -70,7 +76,7 @@ export function Dashboard({
|
||||
label: "日常经营",
|
||||
children: [
|
||||
{ key: "overview", label: "当前品牌概览", icon: <AppstoreOutlined /> },
|
||||
{ key: "publication", label: "配置与发布", icon: <CloudUploadOutlined /> },
|
||||
{ key: "publication", label: "内容与发布", icon: <CloudUploadOutlined /> },
|
||||
{ key: "brand", label: "小程序页面", icon: <MobileOutlined /> },
|
||||
{ key: "trust", label: "信任内容", icon: <SafetyCertificateOutlined /> },
|
||||
{ key: "services", label: "业务提供项", icon: <BarsOutlined /> },
|
||||
@@ -83,8 +89,10 @@ export function Dashboard({
|
||||
: [
|
||||
{
|
||||
type: "group" as const,
|
||||
label: "系统管理",
|
||||
label: "品牌设置",
|
||||
children: [
|
||||
{ key: "brands", label: "品牌管理", icon: <ShopOutlined /> },
|
||||
{ key: "page-scheme", label: "页面方案", icon: <LayoutOutlined /> },
|
||||
{ key: "capabilities", label: "能力插件", icon: <ThunderboltOutlined /> },
|
||||
{ key: "members", label: "团队成员", icon: <TeamOutlined /> },
|
||||
...(platformTemplateRole === "template_admin"
|
||||
@@ -141,10 +149,7 @@ export function Dashboard({
|
||||
<Routes>
|
||||
<Route index element={<AdminOverviewRedirect />} />
|
||||
<Route path="overview" element={<FeatureOverviewPage />} />
|
||||
<Route
|
||||
path="publication"
|
||||
element={<FeaturePublicationPage canManageTemplate={role !== "editor"} />}
|
||||
/>
|
||||
<Route path="publication" element={<FeaturePublicationPage />} />
|
||||
<Route path="brand" element={<FeatureBrandPage />} />
|
||||
<Route path="trust" element={<FeatureTrustContentPage />} />
|
||||
<Route path="services" element={<FeatureServicesPage />} />
|
||||
@@ -152,6 +157,15 @@ export function Dashboard({
|
||||
<Route path="workspace" element={<FeatureWorkspacePage />} />
|
||||
{role === "editor" ? null : (
|
||||
<>
|
||||
<Route
|
||||
path="brands"
|
||||
element={<FeatureBrandsPage canCreate={role === "owner"} />}
|
||||
/>
|
||||
<Route
|
||||
path="brands/new"
|
||||
element={createBrandRouteElement(role, <FeatureCreateBrandPage />)}
|
||||
/>
|
||||
<Route path="page-scheme" element={<FeaturePageSchemePage />} />
|
||||
<Route path="capabilities" element={<FeatureCapabilitiesPage />} />
|
||||
<Route path="members" element={<FeatureMembersPage />} />
|
||||
{platformTemplateRole === "template_admin" ? (
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { createElement, type ReactNode } from "react";
|
||||
import { Navigate } from "react-router-dom";
|
||||
|
||||
export const createBrandFallbackPath = "/admin/brands";
|
||||
|
||||
export function canCreateBrand(role: string) {
|
||||
return role === "owner";
|
||||
}
|
||||
|
||||
export function createBrandRouteElement(role: string, content: ReactNode) {
|
||||
return canCreateBrand(role)
|
||||
? content
|
||||
: createElement(Navigate, { to: createBrandFallbackPath, replace: true });
|
||||
}
|
||||
@@ -48,3 +48,18 @@ export const FeatureTemplateManagementPage = React.lazy(() =>
|
||||
default: module.TemplateManagementPage,
|
||||
})),
|
||||
);
|
||||
export const FeatureBrandsPage = React.lazy(() =>
|
||||
import("../features/brands/BrandsPage.js").then((module) => ({
|
||||
default: module.BrandsPage,
|
||||
})),
|
||||
);
|
||||
export const FeatureCreateBrandPage = React.lazy(() =>
|
||||
import("../features/brands/CreateBrandPage.js").then((module) => ({
|
||||
default: module.CreateBrandPage,
|
||||
})),
|
||||
);
|
||||
export const FeaturePageSchemePage = React.lazy(() =>
|
||||
import("../features/page-scheme/PageSchemePage.js").then((module) => ({
|
||||
default: module.PageSchemePage,
|
||||
})),
|
||||
);
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Alert, Button, Col, Form, Input, Row, Select, Segmented, message } from "antd";
|
||||
import { Alert, Button, Col, Form, Input, Row, Segmented, message } from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useState } from "react";
|
||||
import { Link, useLocation } from "react-router-dom";
|
||||
@@ -36,10 +36,6 @@ export function BrandPage() {
|
||||
queryFn: () => client.getPublicTemplate(brand.data!.templateKey),
|
||||
enabled: Boolean(brand.data?.templateKey),
|
||||
});
|
||||
const templateCatalog = useQuery({
|
||||
queryKey: ["template-catalog"],
|
||||
queryFn: () => client.listPublicTemplates(),
|
||||
});
|
||||
const save = useMutation({
|
||||
mutationFn: (values: Partial<BrandProfile>) => client.updateAdminBrand(values),
|
||||
onSuccess: () => {
|
||||
@@ -60,7 +56,12 @@ export function BrandPage() {
|
||||
? `先让访客理解你是谁、服务谁,以及为什么值得信任。${template.data.description}`
|
||||
: "先让访客理解你是谁、服务谁,以及为什么值得信任。"
|
||||
}
|
||||
extra={<StatusTag tone="info" label={template.data?.name ?? "当前模板"} />}
|
||||
extra={
|
||||
<StatusTag
|
||||
tone="info"
|
||||
label={workspace.data?.templateContent?.displayName ?? "当前页面方案"}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<div className="brand-page__toolbar">
|
||||
<Segmented
|
||||
@@ -169,25 +170,20 @@ export function BrandPage() {
|
||||
<div className="admin-section-head">
|
||||
<div>
|
||||
<h2 id="brand-visual-title" className="admin-section-title">
|
||||
模板与品牌视觉
|
||||
品牌视觉
|
||||
</h2>
|
||||
<p className="admin-section-description">
|
||||
模板负责业务表达,品牌信息仍由你统一维护。
|
||||
头像和封面会用于品牌身份展示;页面结构和资源位由页面方案统一管理。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<Form.Item
|
||||
name="templateKey"
|
||||
label="业务表达模板"
|
||||
help="模板只改变业务表达,不改变个人品牌主线。"
|
||||
>
|
||||
<Select
|
||||
disabled
|
||||
options={(templateCatalog.data?.industries ?? []).map((item) => ({
|
||||
value: item.key,
|
||||
label: item.name,
|
||||
}))}
|
||||
/>
|
||||
<Form.Item label="当前页面方案">
|
||||
<div>
|
||||
<strong>{workspace.data?.templateContent?.displayName ?? "尚未安装"}</strong>
|
||||
<p className="admin-section-description">
|
||||
页面方案的版本、升级和资源位由品牌负责人统一维护。
|
||||
</p>
|
||||
</div>
|
||||
</Form.Item>
|
||||
<Row gutter={16}>
|
||||
<Col xs={24} md={12}>
|
||||
@@ -223,7 +219,7 @@ export function BrandPage() {
|
||||
className="brand-page__template-note"
|
||||
type="info"
|
||||
showIcon
|
||||
message={`当前使用:${template.data.name}`}
|
||||
message={`当前页面方案:${workspace.data?.templateContent?.displayName ?? template.data.name}`}
|
||||
description={`适用场景:${template.data.serviceCategories.join("、") || "通用品牌展示"}`}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
@@ -311,12 +311,12 @@ export function PresentationEditor({
|
||||
</div>
|
||||
{templateContent ? <StatusTag tone="info" label={templateContent.displayName} /> : null}
|
||||
</div>
|
||||
{loading ? <Alert type="info" showIcon message="正在读取当前模板的编辑项目" /> : null}
|
||||
{loading ? <Alert type="info" showIcon message="正在读取当前页面方案的编辑项目" /> : null}
|
||||
{error ? (
|
||||
<Alert type="warning" showIcon message="模板编辑项目读取失败,请刷新后重试。" />
|
||||
<Alert type="warning" showIcon message="页面方案编辑项目读取失败,请刷新后重试。" />
|
||||
) : null}
|
||||
{!loading && !error && !templateContent ? (
|
||||
<Alert type="warning" showIcon message="当前模板暂未提供可编辑的页面内容。" />
|
||||
<Alert type="warning" showIcon message="当前页面方案暂未提供可编辑的页面内容。" />
|
||||
) : null}
|
||||
{templateContent ? (
|
||||
<>
|
||||
|
||||
@@ -46,8 +46,8 @@ export function useBrandPresentationSections(
|
||||
return [
|
||||
...[...new Set(declaredTemplateFields.map((field) => field.page ?? "home"))].map((page) => ({
|
||||
key: `template-data:${page}`,
|
||||
title: "模板专属内容",
|
||||
description: "这些字段由当前小程序模板定义,保存后发布才会对外展示。",
|
||||
title: "页面方案专属内容",
|
||||
description: "这些字段由当前页面方案定义,保存后发布才会对外展示。",
|
||||
page,
|
||||
target: "brand" as const,
|
||||
fields: declaredTemplateFields.filter((field) => (field.page ?? "home") === page),
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
import { Alert, Button, Card, Col, Row, Space } from "antd";
|
||||
import { PlusOutlined } from "@ant-design/icons";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { adminMessage as message } from "../../components/AdminMessage.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { EmptyState } from "../../components/EmptyState.js";
|
||||
import { QueryState } from "../../components/QueryState.js";
|
||||
import { StatusTag } from "../../components/StatusTag.js";
|
||||
|
||||
const client = createApiClient();
|
||||
|
||||
export function BrandsPage({ canCreate }: { canCreate: boolean }) {
|
||||
const navigate = useNavigate();
|
||||
const brands = useQuery({
|
||||
queryKey: ["admin-brand-memberships"],
|
||||
queryFn: () => client.listAdminBrands(),
|
||||
});
|
||||
const current = useQuery({
|
||||
queryKey: ["admin-shell-brand"],
|
||||
queryFn: () => client.getAdminBrand(),
|
||||
});
|
||||
const switchBrand = async (brandId: string) => {
|
||||
try {
|
||||
await client.switchAdminBrand(brandId);
|
||||
window.location.assign("/admin/overview");
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : "品牌切换失败,请重试");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<QueryState
|
||||
loading={brands.isLoading || current.isLoading}
|
||||
error={brands.error || current.error}
|
||||
onRetry={() => {
|
||||
void brands.refetch();
|
||||
void current.refetch();
|
||||
}}
|
||||
>
|
||||
<AdminPageHeader
|
||||
title="品牌管理"
|
||||
description="每个品牌拥有独立的业务类型、页面方案、内容与发布记录。"
|
||||
extra={
|
||||
canCreate ? (
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<PlusOutlined />}
|
||||
onClick={() => navigate("/admin/brands/new")}
|
||||
>
|
||||
创建品牌
|
||||
</Button>
|
||||
) : null
|
||||
}
|
||||
/>
|
||||
<Alert
|
||||
className="admin-offset-bottom"
|
||||
type="info"
|
||||
showIcon
|
||||
message="切换品牌会进入对应品牌的工作区"
|
||||
description="品牌之间的业务内容、成员、发布记录和页面方案相互隔离。"
|
||||
/>
|
||||
{brands.data?.length ? (
|
||||
<Row gutter={[16, 16]} className="admin-equal-height">
|
||||
{brands.data.map((membership) => {
|
||||
const isCurrent = membership.brand.id === current.data?.id;
|
||||
return (
|
||||
<Col key={membership.brand.id} xs={24} lg={12}>
|
||||
<Card
|
||||
title={membership.brand.name}
|
||||
extra={
|
||||
<StatusTag
|
||||
tone={isCurrent ? "success" : "neutral"}
|
||||
label={
|
||||
isCurrent ? "当前品牌" : membership.role === "owner" ? "负责人" : "编辑"
|
||||
}
|
||||
/>
|
||||
}
|
||||
actions={[
|
||||
<Button
|
||||
key="switch"
|
||||
type={isCurrent ? "default" : "primary"}
|
||||
disabled={isCurrent}
|
||||
onClick={() => void switchBrand(membership.brand.id)}
|
||||
>
|
||||
{isCurrent ? "正在使用" : "进入此品牌"}
|
||||
</Button>,
|
||||
]}
|
||||
>
|
||||
<Space direction="vertical" size={8}>
|
||||
<span className="admin-section-description">
|
||||
小程序地址标识:{membership.brand.slug}
|
||||
</span>
|
||||
{membership.role === "owner" ? (
|
||||
<span className="admin-section-description">
|
||||
你可以在该品牌中管理页面方案、成员和发布。
|
||||
</span>
|
||||
) : (
|
||||
<span className="admin-section-description">
|
||||
你在该品牌中的角色是内容编辑,不能管理页面方案或成员。
|
||||
</span>
|
||||
)}
|
||||
</Space>
|
||||
</Card>
|
||||
</Col>
|
||||
);
|
||||
})}
|
||||
</Row>
|
||||
) : (
|
||||
<Card>
|
||||
<EmptyState
|
||||
title="还没有可管理的品牌"
|
||||
description={
|
||||
canCreate ? "创建第一个品牌后即可开始配置内容。" : "请联系品牌负责人邀请你加入。"
|
||||
}
|
||||
action={
|
||||
canCreate ? (
|
||||
<Button type="primary" onClick={() => navigate("/admin/brands/new")}>
|
||||
创建品牌
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
</Card>
|
||||
)}
|
||||
</QueryState>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
import { Alert, Button, Col, Form, Input, Radio, Row, Space } from "antd";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import type {
|
||||
BrandCreationOptionBusiness,
|
||||
BrandCreationOptionPageScheme,
|
||||
CreateBrandInput,
|
||||
} from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { AdminSection } from "../../components/AdminSection.js";
|
||||
import { EmptyState } from "../../components/EmptyState.js";
|
||||
import { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
import { StatusTag } from "../../components/StatusTag.js";
|
||||
|
||||
const client = createApiClient();
|
||||
|
||||
function compatibleSchemes(
|
||||
schemes: BrandCreationOptionPageScheme[],
|
||||
businessType?: CreateBrandInput["businessType"],
|
||||
) {
|
||||
return businessType
|
||||
? schemes.filter((scheme) => scheme.supportedBusinessTypes.includes(businessType))
|
||||
: [];
|
||||
}
|
||||
|
||||
export function CreateBrandPage() {
|
||||
const navigate = useNavigate();
|
||||
const [form] = Form.useForm<CreateBrandInput>();
|
||||
const businessType = Form.useWatch("businessType", form);
|
||||
const options = useQuery({
|
||||
queryKey: ["admin-brand-creation-options"],
|
||||
queryFn: () => client.getAdminBrandCreationOptions(),
|
||||
});
|
||||
const create = useMutation({
|
||||
mutationFn: (values: CreateBrandInput) => client.createAdminBrand(values),
|
||||
onSuccess: () => {
|
||||
// 创建接口会切换品牌会话;完整导航确保所有查询重新绑定到新品牌。
|
||||
window.location.assign("/admin/overview");
|
||||
},
|
||||
});
|
||||
const schemes = compatibleSchemes(options.data?.pageSchemes ?? [], businessType);
|
||||
|
||||
return (
|
||||
<QueryState
|
||||
loading={options.isLoading}
|
||||
error={options.error}
|
||||
onRetry={() => void options.refetch()}
|
||||
>
|
||||
<AdminPageHeader
|
||||
title="创建品牌"
|
||||
description="先确定业务类型,再选择与该业务兼容的页面方案。业务类型创建后不可更改。"
|
||||
/>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
onFinish={(values) => create.mutate(values)}
|
||||
onValuesChange={(changed: Partial<CreateBrandInput>) => {
|
||||
if (!changed.businessType) return;
|
||||
const nextSchemes = compatibleSchemes(
|
||||
options.data?.pageSchemes ?? [],
|
||||
changed.businessType,
|
||||
);
|
||||
const selected = form.getFieldValue("templatePackageVersionId") as unknown;
|
||||
if (!nextSchemes.some((scheme) => scheme.templatePackageVersionId === selected)) {
|
||||
form.setFieldValue("templatePackageVersionId", undefined);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="admin-stack">
|
||||
<AdminSection title="品牌身份" description="这些信息会展示给访客,之后仍可继续完善。">
|
||||
<Row gutter={16}>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item
|
||||
name="name"
|
||||
label="品牌名称"
|
||||
rules={[{ required: true, message: "请输入品牌名称" }]}
|
||||
>
|
||||
<Input size="large" maxLength={80} placeholder="例如:林境建筑" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item
|
||||
name="slug"
|
||||
label="小程序地址标识"
|
||||
help="用于生成和识别公开品牌地址,只能使用小写字母、数字和连字符。"
|
||||
rules={[
|
||||
{ required: true, message: "请输入小程序地址标识" },
|
||||
{
|
||||
pattern: /^[a-z0-9]+(?:-[a-z0-9]+)*$/,
|
||||
message: "只能使用小写字母、数字和连字符",
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input size="large" maxLength={80} placeholder="例如:linjing-architecture" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
</AdminSection>
|
||||
|
||||
<AdminSection
|
||||
title="业务类型"
|
||||
description="业务类型决定品牌需要填写哪些内容。不同业务类型的字段和能力不同,创建后不能修改。"
|
||||
>
|
||||
<Form.Item name="businessType" rules={[{ required: true, message: "请选择业务类型" }]}>
|
||||
<Radio.Group className="admin-stack">
|
||||
<Row gutter={[12, 12]}>
|
||||
{(options.data?.businesses ?? []).map((business: BrandCreationOptionBusiness) => (
|
||||
<Col key={business.key} xs={24} lg={8}>
|
||||
<Radio.Button value={business.key} className="admin-choice-card">
|
||||
<strong>{business.name}</strong>
|
||||
<span>{business.description}</span>
|
||||
</Radio.Button>
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
{businessType ? (
|
||||
schemes.length ? null : (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="当前业务类型还没有可用的页面方案"
|
||||
description="请先联系平台管理员发布兼容的页面方案。"
|
||||
/>
|
||||
)
|
||||
) : (
|
||||
<Alert type="info" showIcon message="选择业务类型后,将只显示兼容的页面方案" />
|
||||
)}
|
||||
</AdminSection>
|
||||
|
||||
<AdminSection
|
||||
title="页面方案"
|
||||
description="页面方案决定页面结构、视觉和资源位。版本可在创建后继续升级或切换。"
|
||||
>
|
||||
{schemes.length ? (
|
||||
<Form.Item
|
||||
name="templatePackageVersionId"
|
||||
rules={[{ required: true, message: "请选择页面方案" }]}
|
||||
>
|
||||
<Radio.Group className="admin-stack">
|
||||
<Space direction="vertical" size={12} className="admin-full-width">
|
||||
{schemes.map((scheme) => (
|
||||
<Radio.Button
|
||||
key={scheme.templatePackageVersionId}
|
||||
value={scheme.templatePackageVersionId}
|
||||
className="admin-choice-card admin-choice-card--wide"
|
||||
>
|
||||
<span className="admin-row-line">
|
||||
<strong>{scheme.name}</strong>
|
||||
<StatusTag
|
||||
tone={scheme.isLatestForPackage ? "success" : "neutral"}
|
||||
label={
|
||||
scheme.isLatestForPackage
|
||||
? `最新版 ${scheme.version}`
|
||||
: `版本 ${scheme.version}`
|
||||
}
|
||||
/>
|
||||
</span>
|
||||
<span>{scheme.description}</span>
|
||||
</Radio.Button>
|
||||
))}
|
||||
</Space>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
) : (
|
||||
<EmptyState
|
||||
title={businessType ? "没有兼容的页面方案" : "先选择业务类型"}
|
||||
description={
|
||||
businessType
|
||||
? "平台尚未发布适配该业务类型的页面方案。"
|
||||
: "选择业务类型后,这里会列出可用的页面结构和视觉方案。"
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</AdminSection>
|
||||
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="创建品牌不会自动导入示例内容"
|
||||
description="新品牌会从空白内容开始,避免把示例品牌、案例或联系方式误当成真实信息发布。"
|
||||
/>
|
||||
<MutationError error={create.error} />
|
||||
<Space>
|
||||
<Button onClick={() => navigate("/admin/brands")}>取消</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
htmlType="submit"
|
||||
size="large"
|
||||
loading={create.isPending}
|
||||
disabled={!businessType || schemes.length === 0}
|
||||
>
|
||||
创建并进入品牌
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</Form>
|
||||
</QueryState>
|
||||
);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ export function CapabilitiesPage() {
|
||||
<QueryState loading={query.isLoading} error={query.error} onRetry={() => void query.refetch()}>
|
||||
<AdminPageHeader
|
||||
title="能力插件"
|
||||
description="以经营者视角调整模板能力的开关与展示设置;保存后进入草稿,发布后生效。"
|
||||
description="以经营者视角调整当前页面方案提供的业务能力;保存后进入草稿,发布后生效。"
|
||||
/>
|
||||
{query.data?.length ? (
|
||||
<Row gutter={[16, 16]} className="admin-equal-height">
|
||||
@@ -29,9 +29,9 @@ export function CapabilitiesPage() {
|
||||
<Card>
|
||||
<EmptyState
|
||||
icon={<AppstoreOutlined />}
|
||||
title="当前模板没有可配置能力"
|
||||
description="能力的开关由品牌当前使用的行业模板决定;更换行业模板不在本版本范围内。"
|
||||
action={<Button onClick={() => navigate("/admin/publication")}>查看模板与发布</Button>}
|
||||
title="当前页面方案没有可配置能力"
|
||||
description="能力由品牌当前使用的业务类型和页面方案决定。"
|
||||
action={<Button onClick={() => navigate("/admin/page-scheme")}>查看页面方案</Button>}
|
||||
/>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
@@ -8,12 +8,12 @@ import { CapabilityStatusControl, CapabilityStatusTag } from "./CapabilityStatus
|
||||
|
||||
const sourceLabels = {
|
||||
brand: "品牌覆盖",
|
||||
template: "模板默认",
|
||||
template: "方案默认",
|
||||
} as const;
|
||||
|
||||
const disablePolicyLabels = {
|
||||
allowed: "该能力允许停用,保存后进入草稿。",
|
||||
disabled: "该能力为模板必需项,保存后进入草稿。",
|
||||
disabled: "该能力为页面方案必需项,保存后进入草稿。",
|
||||
} as const;
|
||||
|
||||
const updatedTimeFormatter = new Intl.DateTimeFormat("zh-CN", {
|
||||
@@ -143,7 +143,7 @@ export function CapabilityCard({ capability }: { capability: AdminCapability })
|
||||
) : null}
|
||||
<Typography.Text type="secondary">
|
||||
{capability.source === "template"
|
||||
? "当前使用模板默认设置;修改后保存会创建品牌覆盖。"
|
||||
? "当前使用页面方案默认设置;修改后保存会创建品牌覆盖。"
|
||||
: "当前已创建品牌覆盖;修改后保存会更新草稿。"}
|
||||
{capability.updatedAt
|
||||
? ` 最近更新:${updatedTimeFormatter.format(new Date(capability.updatedAt))}`
|
||||
|
||||
@@ -213,7 +213,7 @@ export function InquiriesPage() {
|
||||
</AdminSection>
|
||||
<AdminSection
|
||||
title={`动态咨询提交${submissions.data ? `(${submissions.data.length})` : ""}`}
|
||||
description="按模板表单提交的咨询记录,字段随表单配置变化。"
|
||||
description="按咨询表单提交的记录,字段随表单配置变化。"
|
||||
extra={
|
||||
<Button onClick={() => void submissions.refetch()} loading={submissions.isFetching}>
|
||||
刷新提交记录
|
||||
@@ -248,7 +248,7 @@ export function InquiriesPage() {
|
||||
<EmptyState
|
||||
compact
|
||||
title="暂无动态咨询提交"
|
||||
description="按模板表单提交的咨询会汇总在这里。"
|
||||
description="按咨询表单提交的内容会汇总在这里。"
|
||||
/>
|
||||
),
|
||||
}}
|
||||
|
||||
@@ -90,7 +90,7 @@ export function OverviewPage() {
|
||||
<p className="admin-brand-tagline">{brand?.tagline || "还没有设置一句话定位"}</p>
|
||||
<StatusTag
|
||||
tone="info"
|
||||
label={`当前模板:${workspace?.templateContent?.displayName ?? "尚未安装模板"}`}
|
||||
label={`当前页面方案:${workspace?.templateContent?.displayName ?? "尚未安装页面方案"}`}
|
||||
/>
|
||||
</Card>
|
||||
<Row gutter={[16, 16]}>
|
||||
|
||||
@@ -0,0 +1,375 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Alert, Button, Card, Collapse, Descriptions, Empty, List, Modal, Space, Tag } from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { adminMessage as message } from "../../components/AdminMessage.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { AdminSection } from "../../components/AdminSection.js";
|
||||
import { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
import { StatusTag } from "../../components/StatusTag.js";
|
||||
|
||||
const client = createApiClient();
|
||||
|
||||
export function PageSchemePage() {
|
||||
const queryClient = useQueryClient();
|
||||
const [selectedVersionId, setSelectedVersionId] = useState<string>();
|
||||
const [samplePreview, setSamplePreview] = useState<Awaited<
|
||||
ReturnType<typeof client.previewAdminSampleContent>
|
||||
> | null>(null);
|
||||
const workspace = useQuery({
|
||||
queryKey: ["page-scheme-workspace"],
|
||||
queryFn: () => client.getAdminWorkspace(),
|
||||
});
|
||||
const options = useQuery({
|
||||
queryKey: ["admin-page-scheme-options"],
|
||||
queryFn: () => client.getAdminPageSchemeOptions(),
|
||||
});
|
||||
const upgradePreview = useQuery({
|
||||
queryKey: ["page-scheme-upgrade-preview"],
|
||||
queryFn: () => client.getAdminTemplateUpgradePreview(),
|
||||
});
|
||||
const installation = workspace.data?.installations[0];
|
||||
const currentVersionId = installation?.templatePackageVersionId;
|
||||
const currentScheme = options.data?.pageSchemes.find(
|
||||
(scheme) => scheme.templatePackageVersionId === currentVersionId,
|
||||
);
|
||||
const business = options.data?.business;
|
||||
const compatibleSchemes = options.data?.pageSchemes ?? [];
|
||||
|
||||
useEffect(() => {
|
||||
if (currentVersionId) setSelectedVersionId(currentVersionId);
|
||||
}, [currentVersionId]);
|
||||
|
||||
const refresh = () => {
|
||||
for (const queryKey of [
|
||||
"page-scheme-workspace",
|
||||
"page-scheme-upgrade-preview",
|
||||
"admin-workspace",
|
||||
"admin-preview-workspace",
|
||||
"admin-overview-workspace",
|
||||
"publication-workspace",
|
||||
"publication-readiness",
|
||||
]) {
|
||||
void queryClient.invalidateQueries({ queryKey: [queryKey] });
|
||||
}
|
||||
};
|
||||
|
||||
const selectVersion = useMutation({
|
||||
mutationFn: (templatePackageVersionId: string) =>
|
||||
client.selectAdminTemplateVersion({
|
||||
templatePackageVersionId,
|
||||
expectedCurrentPackageVersionId: currentVersionId ?? null,
|
||||
confirm: true,
|
||||
}),
|
||||
onSuccess: () => {
|
||||
message.success("页面方案版本已切换");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const upgrade = useMutation({
|
||||
mutationFn: async () => {
|
||||
const preview = upgradePreview.data;
|
||||
if (
|
||||
!preview?.canUpgrade ||
|
||||
!preview.targetPackageVersionId ||
|
||||
!preview.targetContentChecksum
|
||||
) {
|
||||
throw new Error("当前没有可升级的页面方案版本,请刷新后重试");
|
||||
}
|
||||
return client.upgradeAdminTemplate({
|
||||
templatePackageVersionId: preview.targetPackageVersionId,
|
||||
expectedContentChecksum: preview.targetContentChecksum,
|
||||
expectedCurrentVersion: preview.currentVersion,
|
||||
expectedCurrentPackageVersionId: preview.currentPackageVersionId,
|
||||
confirm: true,
|
||||
preservedBindings: preview.conflicts.map(({ key, binding }) => ({
|
||||
key,
|
||||
binding,
|
||||
action: "preserve",
|
||||
})),
|
||||
});
|
||||
},
|
||||
onSuccess: () => {
|
||||
message.success("页面方案已升级,现有内容已全部保留");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const rollback = useMutation({
|
||||
mutationFn: () => {
|
||||
const preview = upgradePreview.data;
|
||||
if (!preview?.canRollback) throw new Error("当前没有可恢复的上一版配置基线");
|
||||
return client.rollbackAdminTemplate({
|
||||
expectedCurrentVersion: preview.currentVersion,
|
||||
confirm: true,
|
||||
});
|
||||
},
|
||||
onSuccess: () => {
|
||||
message.success("已恢复上一版页面方案配置基线");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const previewSample = useMutation({
|
||||
mutationFn: () =>
|
||||
client.previewAdminSampleContent({
|
||||
...(currentVersionId ? { templatePackageVersionId: currentVersionId } : {}),
|
||||
strategy: "missing_only",
|
||||
}),
|
||||
onSuccess: (data) => setSamplePreview(data),
|
||||
});
|
||||
const importSample = useMutation({
|
||||
mutationFn: () =>
|
||||
client.importAdminSampleContent({
|
||||
...(currentVersionId ? { templatePackageVersionId: currentVersionId } : {}),
|
||||
strategy: "missing_only",
|
||||
confirm: true,
|
||||
}),
|
||||
onSuccess: () => {
|
||||
message.success("示例内容已按缺失项导入,现有内容未被覆盖");
|
||||
setSamplePreview(null);
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
|
||||
const confirmSelect = (templatePackageVersionId: string) => {
|
||||
const target = compatibleSchemes.find(
|
||||
(scheme) => scheme.templatePackageVersionId === templatePackageVersionId,
|
||||
);
|
||||
Modal.confirm({
|
||||
title: "切换页面方案版本",
|
||||
content: target
|
||||
? `将当前品牌切换到「${target.name}」版本 ${target.version}。现有品牌内容会保留。`
|
||||
: "将切换当前品牌使用的页面方案版本。现有品牌内容会保留。",
|
||||
okText: "确认切换",
|
||||
cancelText: "取消",
|
||||
onOk: () => selectVersion.mutateAsync(templatePackageVersionId),
|
||||
});
|
||||
};
|
||||
const confirmUpgrade = () => {
|
||||
const preview = upgradePreview.data;
|
||||
Modal.confirm({
|
||||
title: "升级页面方案",
|
||||
content:
|
||||
preview && preview.conflicts.length
|
||||
? `将升级到版本 ${preview.latestVersion},并全部保留 ${preview.conflicts.length} 项现有内容。`
|
||||
: `将升级到版本 ${preview?.latestVersion ?? "最新版"},现有品牌内容会保留。`,
|
||||
okText: "确认升级",
|
||||
cancelText: "取消",
|
||||
onOk: () => upgrade.mutateAsync(),
|
||||
});
|
||||
};
|
||||
const confirmRollback = () => {
|
||||
Modal.confirm({
|
||||
title: "恢复上一版配置基线",
|
||||
content: "此操作只恢复上一版页面方案配置,不会删除品牌内容、业务提供项或咨询记录。",
|
||||
okText: "确认恢复",
|
||||
cancelText: "取消",
|
||||
onOk: () => rollback.mutateAsync(),
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<QueryState
|
||||
loading={workspace.isLoading || options.isLoading || upgradePreview.isLoading}
|
||||
error={workspace.error || options.error || upgradePreview.error}
|
||||
onRetry={() => {
|
||||
void workspace.refetch();
|
||||
void options.refetch();
|
||||
void upgradePreview.refetch();
|
||||
}}
|
||||
>
|
||||
<AdminPageHeader
|
||||
title="页面方案"
|
||||
description="页面方案决定小程序有哪些页面、页面结构、视觉和资源位。它可以独立于内容发布进行升级或版本切换。"
|
||||
/>
|
||||
<div className="admin-stack">
|
||||
<AdminSection
|
||||
title="当前方案"
|
||||
description="业务类型创建后固定;页面方案和版本可以继续调整。"
|
||||
>
|
||||
<Descriptions column={{ xs: 1, md: 2 }} bordered>
|
||||
<Descriptions.Item label="业务类型">{business?.name ?? "未识别"}</Descriptions.Item>
|
||||
<Descriptions.Item label="页面方案">
|
||||
{currentScheme?.name ?? workspace.data?.templateContent?.displayName ?? "尚未安装"}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="当前状态">
|
||||
<StatusTag
|
||||
tone={installation ? "info" : "neutral"}
|
||||
label={
|
||||
installation ? `正在使用版本 ${installation.templateVersion}` : "尚未安装页面方案"
|
||||
}
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
{business?.description ? (
|
||||
<p className="admin-section-description admin-offset-top">{business.description}</p>
|
||||
) : null}
|
||||
</AdminSection>
|
||||
|
||||
<AdminSection
|
||||
title="升级预览"
|
||||
description="升级前先查看页面、模块、资源和绑定的变化;冲突项默认保留现有内容。"
|
||||
>
|
||||
<Card>
|
||||
{upgradePreview.data?.canUpgrade ? (
|
||||
<Space direction="vertical" size={12} className="admin-full-width">
|
||||
<div className="admin-row-line">
|
||||
<strong>可升级到版本 {upgradePreview.data.latestVersion}</strong>
|
||||
<Tag color="blue">建议先预览</Tag>
|
||||
</div>
|
||||
<Descriptions column={{ xs: 1, md: 2 }} size="small">
|
||||
<Descriptions.Item label="新增页面">
|
||||
{upgradePreview.data.changes.pages.added.length}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="变更页面">
|
||||
{upgradePreview.data.changes.pages.changed.length}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="新增字段绑定">
|
||||
{upgradePreview.data.changes.templateBindings.added.length}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="需要保留的冲突">
|
||||
{upgradePreview.data.conflicts.length}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
{upgradePreview.data.conflicts.length ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message={`发现 ${upgradePreview.data.conflicts.length} 项自定义内容与新版布局存在差异`}
|
||||
description="升级时会全部保留现有内容,不会逐项覆盖。请确认后再执行升级。"
|
||||
/>
|
||||
) : (
|
||||
<Alert type="success" showIcon message="未发现内容绑定冲突" />
|
||||
)}
|
||||
<Button type="primary" onClick={confirmUpgrade} loading={upgrade.isPending}>
|
||||
升级到 {upgradePreview.data.latestVersion}
|
||||
</Button>
|
||||
</Space>
|
||||
) : (
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description="当前已是可用的最新页面方案版本,暂无可升级版本。"
|
||||
/>
|
||||
)}
|
||||
<MutationError error={upgrade.error} />
|
||||
</Card>
|
||||
</AdminSection>
|
||||
|
||||
<AdminSection
|
||||
title="选择版本"
|
||||
description="可切换到同一业务类型下的其他已发布版本。切换会保留品牌内容。"
|
||||
>
|
||||
<List
|
||||
dataSource={compatibleSchemes}
|
||||
locale={{ emptyText: "没有可切换的页面方案版本" }}
|
||||
renderItem={(scheme) => {
|
||||
const isCurrent = scheme.templatePackageVersionId === currentVersionId;
|
||||
return (
|
||||
<List.Item
|
||||
actions={[
|
||||
<Button
|
||||
key="select"
|
||||
type={isCurrent ? "default" : "primary"}
|
||||
disabled={isCurrent}
|
||||
loading={
|
||||
selectVersion.isPending &&
|
||||
selectedVersionId === scheme.templatePackageVersionId
|
||||
}
|
||||
onClick={() => {
|
||||
setSelectedVersionId(scheme.templatePackageVersionId);
|
||||
confirmSelect(scheme.templatePackageVersionId);
|
||||
}}
|
||||
>
|
||||
{isCurrent ? "当前版本" : "切换到此版本"}
|
||||
</Button>,
|
||||
]}
|
||||
>
|
||||
<List.Item.Meta
|
||||
title={
|
||||
<Space>
|
||||
<span>{scheme.name}</span>
|
||||
<Tag color={scheme.isLatestForPackage ? "green" : "default"}>
|
||||
{scheme.isLatestForPackage ? "最新版" : `版本 ${scheme.version}`}
|
||||
</Tag>
|
||||
</Space>
|
||||
}
|
||||
description={`${scheme.description} · 版本 ${scheme.version}`}
|
||||
/>
|
||||
</List.Item>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<MutationError error={selectVersion.error} />
|
||||
</AdminSection>
|
||||
|
||||
<AdminSection
|
||||
title="配置恢复"
|
||||
description="恢复上一版页面方案配置基线,仅用于升级后出现配置问题时回退。"
|
||||
>
|
||||
<Button danger onClick={confirmRollback} disabled={!upgradePreview.data?.canRollback}>
|
||||
恢复上一版配置
|
||||
</Button>
|
||||
<MutationError error={rollback.error} />
|
||||
</AdminSection>
|
||||
|
||||
<Collapse
|
||||
items={[
|
||||
{
|
||||
key: "sample-content",
|
||||
label: "高级:导入示例内容",
|
||||
children: (
|
||||
<Space direction="vertical" size={12} className="admin-full-width">
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="此操作会写入当前品牌内容"
|
||||
description="仅导入当前缺失的内容,不会覆盖已有品牌资料。创建品牌时不会自动执行。"
|
||||
/>
|
||||
<Space>
|
||||
<Button
|
||||
onClick={() => previewSample.mutate()}
|
||||
loading={previewSample.isPending}
|
||||
>
|
||||
预览将导入的内容
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
danger
|
||||
disabled={!samplePreview}
|
||||
loading={importSample.isPending}
|
||||
onClick={() => importSample.mutate()}
|
||||
>
|
||||
确认导入缺失内容
|
||||
</Button>
|
||||
</Space>
|
||||
<MutationError error={previewSample.error || importSample.error} />
|
||||
{samplePreview ? (
|
||||
<Descriptions bordered size="small" column={{ xs: 1, md: 2 }}>
|
||||
<Descriptions.Item label="品牌资料">
|
||||
{samplePreview.counts.brandConfig}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="业务提供项">
|
||||
{samplePreview.counts.offerings}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="信任内容">
|
||||
{samplePreview.counts.trustContent}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="字段">
|
||||
{samplePreview.counts.fields}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="咨询表单">
|
||||
{samplePreview.counts.inquiryForms}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="是否已导入">
|
||||
{samplePreview.alreadyImported ? "是" : "否"}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
) : null}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</QueryState>
|
||||
);
|
||||
}
|
||||
@@ -1,26 +1,11 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Checkbox,
|
||||
Divider,
|
||||
Input,
|
||||
Popconfirm,
|
||||
Modal,
|
||||
Form,
|
||||
Select,
|
||||
Space,
|
||||
Spin,
|
||||
Tabs,
|
||||
Typography,
|
||||
} from "antd";
|
||||
import type { BrandTemplateKey } from "@personal-brand/api-client";
|
||||
import { Alert, Button, Divider, Form, Input, Modal, Space, Tabs, Typography } from "antd";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { AdminSection } from "../../components/AdminSection.js";
|
||||
import { EmptyState } from "../../components/EmptyState.js";
|
||||
import { ErrorNote, MutationError, QueryState } from "../../components/QueryState.js";
|
||||
import { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
import { StatusTag, statusLabel } from "../../components/StatusTag.js";
|
||||
import { MiniAppReleaseCard } from "./MiniAppReleaseCard.js";
|
||||
import { MiniAppSettingsTab, type MiniAppSettingsValues } from "./MiniAppSettingsTab.js";
|
||||
@@ -30,34 +15,28 @@ import { usePublicationMutations } from "./use-publication-mutations.js";
|
||||
const destinations: Record<string, string> = {
|
||||
brand: "/admin/brand",
|
||||
positioning: "/admin/brand",
|
||||
template: "/admin/publication",
|
||||
visual: "/admin/publication",
|
||||
template: "/admin/page-scheme",
|
||||
visual: "/admin/page-scheme",
|
||||
offerings: "/admin/services",
|
||||
forms: "/admin/workspace",
|
||||
trust: "/admin/trust",
|
||||
};
|
||||
|
||||
export function PublicationPage({ canManageTemplate }: { canManageTemplate: boolean }) {
|
||||
export function PublicationPage() {
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
const [industryTarget, setIndustryTarget] = useState<BrandTemplateKey | null>(null);
|
||||
const [confirmAction, setConfirmAction] = useState<"publish" | "revoke" | null>(null);
|
||||
const [rollbackVersion, setRollbackVersion] = useState<number | null>(null);
|
||||
const [preservedBindings, setPreservedBindings] = useState<Record<string, boolean>>({});
|
||||
const [note, setNote] = useState("");
|
||||
const [activeTab, setActiveTab] = useState("content");
|
||||
const [miniAppSettingsForm] = Form.useForm<MiniAppSettingsValues>();
|
||||
const queries = usePublicationQueries(miniAppSettingsForm);
|
||||
const {
|
||||
brand,
|
||||
workspace,
|
||||
catalog,
|
||||
sample,
|
||||
readiness,
|
||||
releases,
|
||||
miniAppReleases,
|
||||
miniAppSettings,
|
||||
templatePreview,
|
||||
loading,
|
||||
error,
|
||||
retry,
|
||||
@@ -66,11 +45,10 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
for (const key of [
|
||||
"publication-brand",
|
||||
"publication-workspace",
|
||||
"publication-sample",
|
||||
"publication-readiness",
|
||||
"publication-template-preview",
|
||||
"publication-releases",
|
||||
"publication-miniapp-releases",
|
||||
"publication-miniapp-settings",
|
||||
"admin-shell-brand",
|
||||
"admin-workspace",
|
||||
"public-runtime-workspace",
|
||||
@@ -80,18 +58,11 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
};
|
||||
const mutations = usePublicationMutations({
|
||||
refresh,
|
||||
currentTemplatePackageVersionId: workspace.data?.installations[0]?.templatePackageVersionId,
|
||||
onInstallClose: () => setIndustryTarget(null),
|
||||
onPublishClose: () => setConfirmAction(null),
|
||||
onNoteClear: () => setNote(""),
|
||||
onRollbackClose: () => setRollbackVersion(null),
|
||||
});
|
||||
const {
|
||||
install,
|
||||
upgradeTemplate,
|
||||
rollbackTemplate,
|
||||
selectVisual,
|
||||
importSample,
|
||||
publish,
|
||||
revoke,
|
||||
rollback,
|
||||
@@ -100,18 +71,6 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
uploadMiniAppRelease,
|
||||
updateMiniAppStatus,
|
||||
} = mutations;
|
||||
const industryKey =
|
||||
workspace.data?.installations[0]?.templateKey ??
|
||||
workspace.data?.brand?.templateKey ??
|
||||
brand.data?.templateKey ??
|
||||
null;
|
||||
const selectablePackageVersions = (queries.packages.data?.items ?? []).filter(
|
||||
(item) =>
|
||||
item.status === "published" &&
|
||||
typeof industryKey === "string" &&
|
||||
item.manifestSummary?.supportedIndustryTemplates.includes(industryKey),
|
||||
);
|
||||
const visualKey = workspace.data?.installations[0]?.visualTemplateKey ?? null;
|
||||
const currentRelease = releases.data?.find((item) => item.status === "published");
|
||||
const publishedHistory = (releases.data ?? []).filter(
|
||||
(item) => item.status === "published" || item.status === "superseded",
|
||||
@@ -123,12 +82,12 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
isEnabled: boolean;
|
||||
}>;
|
||||
|
||||
const contentTab = null;
|
||||
return (
|
||||
<QueryState loading={loading} error={error} onRetry={retry}>
|
||||
<AdminPageHeader
|
||||
title="配置与发布"
|
||||
description="编辑内容不会立即影响小程序;确认后统一发布当前品牌。"
|
||||
title="内容与发布"
|
||||
description="检查当前草稿并发布品牌内容;页面方案与内容发布互不混用。"
|
||||
extra={<Button onClick={() => navigate("/admin/page-scheme")}>管理页面方案</Button>}
|
||||
/>
|
||||
<Tabs
|
||||
activeKey={activeTab}
|
||||
@@ -137,418 +96,175 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
{
|
||||
key: "content",
|
||||
label: "内容发布",
|
||||
children: contentTab,
|
||||
children: (
|
||||
<div className="admin-stack">
|
||||
<AdminSection
|
||||
title="发布前检查"
|
||||
description="请先处理未完成的检查项,再发布当前草稿。发布不会自动修改页面方案。"
|
||||
>
|
||||
{draftOfferings.length || draftForms.length ? (
|
||||
<p className="admin-section-description">
|
||||
当前草稿包含 {draftOfferings.length} 个启用中的业务提供项和{" "}
|
||||
{draftForms.length} 个咨询表单。
|
||||
</p>
|
||||
) : null}
|
||||
<ul className="admin-list">
|
||||
{(readiness.data?.checks ?? []).map((check) => (
|
||||
<li key={check.key} className="admin-row">
|
||||
<div className="admin-row-main">
|
||||
<div className="admin-row-line">
|
||||
<StatusTag
|
||||
tone={check.passed ? "success" : "warning"}
|
||||
label={check.passed ? "已完成" : "待完善"}
|
||||
/>
|
||||
<span className="admin-row-title">{check.label}</span>
|
||||
{!check.passed && check.help ? (
|
||||
<span className="admin-row-meta">{check.help}</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
{!check.passed ? (
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
onClick={() =>
|
||||
navigate(
|
||||
check.destination ?? destinations[check.key] ?? "/admin/overview",
|
||||
)
|
||||
}
|
||||
>
|
||||
去处理
|
||||
</Button>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Space wrap className="admin-offset-top">
|
||||
<Button
|
||||
type="primary"
|
||||
disabled={!readiness.data?.ready}
|
||||
onClick={() => setConfirmAction("publish")}
|
||||
>
|
||||
发布当前草稿
|
||||
</Button>
|
||||
{currentRelease && (
|
||||
<Button danger onClick={() => setConfirmAction("revoke")}>
|
||||
撤回当前版本
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
<MutationError error={publish.error || revoke.error} />
|
||||
<Divider className="admin-divider" />
|
||||
<h3 className="admin-section-title">发布记录</h3>
|
||||
{releases.data?.length ? (
|
||||
<ul className="admin-list admin-offset-top-xs">
|
||||
{releases.data.map((item) => (
|
||||
<li key={item.id} className="admin-row">
|
||||
<div className="admin-row-main">
|
||||
<div className="admin-row-line">
|
||||
<span className="admin-row-title">v{item.version}</span>
|
||||
<StatusTag
|
||||
tone={item.status === "published" ? "success" : "neutral"}
|
||||
label={statusLabel(item.status)}
|
||||
/>
|
||||
<span className="admin-row-meta">
|
||||
{new Date(item.createdAt).toLocaleString("zh-CN")}
|
||||
</span>
|
||||
{item.note ? (
|
||||
<span className="admin-row-meta">{item.note}</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
{item.status === "superseded" && publishedHistory.length > 1 ? (
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
onClick={() => setRollbackVersion(item.version)}
|
||||
>
|
||||
恢复此版本
|
||||
</Button>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<EmptyState
|
||||
compact
|
||||
title="暂无发布记录"
|
||||
description="完成检查并发布后,这里会保留每个版本的记录。"
|
||||
/>
|
||||
)}
|
||||
<MutationError error={rollback.error} />
|
||||
</AdminSection>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: "miniapp",
|
||||
label: "小程序发布",
|
||||
children: (
|
||||
<div className="admin-stack admin-stack-lg">
|
||||
<AdminSection
|
||||
title="小程序代码发布"
|
||||
description="使用微信官方工具上传代码;审核与发布状态需按微信平台结果人工确认。"
|
||||
extra={
|
||||
<Space wrap>
|
||||
<Button
|
||||
type="primary"
|
||||
disabled={!currentRelease}
|
||||
loading={uploadLatestMiniAppRelease.isPending}
|
||||
onClick={() => uploadLatestMiniAppRelease.mutate()}
|
||||
>
|
||||
上传当前版本到微信
|
||||
</Button>
|
||||
{miniAppSettings.data?.hasStoredCredentials ? (
|
||||
<StatusTag tone="success" label="已配置上传凭据" />
|
||||
) : (
|
||||
<StatusTag tone="warning" label="未配置上传凭据" />
|
||||
)}
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
{miniAppReleases.data?.length ? (
|
||||
<div className="admin-stack admin-stack-tight">
|
||||
{miniAppReleases.data.map((task) => (
|
||||
<MiniAppReleaseCard
|
||||
key={task.id}
|
||||
task={task}
|
||||
uploading={uploadMiniAppRelease.isPending}
|
||||
onUpload={() => uploadMiniAppRelease.mutate(task.id)}
|
||||
onStatusChange={(status) =>
|
||||
updateMiniAppStatus.mutate({ id: task.id, status })
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState
|
||||
compact
|
||||
title="暂无小程序发布任务"
|
||||
description="先发布品牌内容,再上传当前版本到微信。"
|
||||
/>
|
||||
)}
|
||||
</AdminSection>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{ key: "miniapp", label: "小程序发布", children: null },
|
||||
{
|
||||
key: "settings",
|
||||
label: "小程序配置",
|
||||
children:
|
||||
activeTab === "settings" ? (
|
||||
<MiniAppSettingsTab
|
||||
form={miniAppSettingsForm}
|
||||
settings={miniAppSettings.data}
|
||||
saving={saveMiniAppSettings.isPending}
|
||||
error={saveMiniAppSettings.error}
|
||||
onSave={(values) => saveMiniAppSettings.mutate(values)}
|
||||
/>
|
||||
) : null,
|
||||
children: (
|
||||
<MiniAppSettingsTab
|
||||
form={miniAppSettingsForm}
|
||||
settings={miniAppSettings.data}
|
||||
saving={saveMiniAppSettings.isPending}
|
||||
error={saveMiniAppSettings.error}
|
||||
onSave={(values) => saveMiniAppSettings.mutate(values)}
|
||||
/>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
{activeTab === "content" && (
|
||||
<div className="admin-stack">
|
||||
<AdminSection
|
||||
title="选择表达方式"
|
||||
description="行业模板决定内容结构,视觉模板决定小程序的排版风格。"
|
||||
>
|
||||
<Space wrap>
|
||||
<Select
|
||||
aria-label="行业模板"
|
||||
className="admin-field-w-xl"
|
||||
value={industryKey}
|
||||
disabled={!canManageTemplate || Boolean(workspace.data?.installations.length)}
|
||||
options={(catalog.data?.industries ?? []).map((item) => ({
|
||||
value: item.key,
|
||||
label: item.name,
|
||||
}))}
|
||||
onChange={(key: BrandTemplateKey) => setIndustryTarget(key)}
|
||||
/>
|
||||
<Select
|
||||
aria-label="视觉模板"
|
||||
className="admin-field-w-xl"
|
||||
value={visualKey}
|
||||
disabled={!canManageTemplate}
|
||||
loading={selectVisual.isPending}
|
||||
options={selectablePackageVersions.map((item) => ({
|
||||
value: item.id,
|
||||
label: `${item.displayName} · ${item.version}`,
|
||||
}))}
|
||||
onChange={(versionId) => selectVisual.mutate(versionId)}
|
||||
/>
|
||||
</Space>
|
||||
{industryKey ? (
|
||||
<div className="admin-offset-top-sm">
|
||||
<Space wrap>
|
||||
<StatusTag
|
||||
tone="neutral"
|
||||
label={`当前版本 ${templatePreview.data?.currentVersion ?? "加载中"}`}
|
||||
/>
|
||||
<StatusTag
|
||||
tone="info"
|
||||
label={`最新版本 ${templatePreview.data?.latestVersion ?? "加载中"}`}
|
||||
/>
|
||||
{templatePreview.data?.canUpgrade ? (
|
||||
<Popconfirm
|
||||
title="确认升级到已发布模板包?"
|
||||
description={`新增 binding ${templatePreview.data.changes.templateBindings.added.length} 项;冲突值需逐项确认保留。升级不会删除字段或业务内容。`}
|
||||
okText="确认升级"
|
||||
cancelText="取消"
|
||||
onConfirm={() => {
|
||||
const preview = templatePreview.data;
|
||||
if (!preview?.targetPackageVersionId || !preview.targetContentChecksum)
|
||||
return;
|
||||
if (
|
||||
!preview.conflicts.every(
|
||||
(item) => preservedBindings[`${item.key}:${item.binding}`],
|
||||
)
|
||||
)
|
||||
return;
|
||||
upgradeTemplate.mutate({
|
||||
templatePackageVersionId: preview.targetPackageVersionId,
|
||||
expectedContentChecksum: preview.targetContentChecksum,
|
||||
expectedCurrentVersion: preview.currentVersion,
|
||||
expectedCurrentPackageVersionId: preview.currentPackageVersionId,
|
||||
confirm: true,
|
||||
preservedBindings: preview.conflicts.map(({ key, binding }) => ({
|
||||
key,
|
||||
binding,
|
||||
action: "preserve" as const,
|
||||
})),
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
type="primary"
|
||||
size="small"
|
||||
disabled={
|
||||
!canManageTemplate ||
|
||||
!templatePreview.data?.targetPackageVersionId ||
|
||||
!templatePreview.data.conflicts.every(
|
||||
(item) => preservedBindings[`${item.key}:${item.binding}`],
|
||||
)
|
||||
}
|
||||
loading={upgradeTemplate.isPending}
|
||||
>
|
||||
升级模板
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
) : (
|
||||
<StatusTag tone="success" label="已是最新版本" />
|
||||
)}
|
||||
{templatePreview.data?.canRollback ? (
|
||||
<Popconfirm
|
||||
title="确认恢复上一版模板配置基线?"
|
||||
description="不会删除品牌字段、业务内容、历史发布或客户咨询记录。"
|
||||
okText="确认回滚"
|
||||
cancelText="取消"
|
||||
onConfirm={() => {
|
||||
const currentVersion = templatePreview.data?.currentVersion;
|
||||
if (!currentVersion) return;
|
||||
rollbackTemplate.mutate({
|
||||
expectedCurrentVersion: currentVersion,
|
||||
confirm: true,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
danger
|
||||
size="small"
|
||||
disabled={!canManageTemplate}
|
||||
loading={rollbackTemplate.isPending}
|
||||
>
|
||||
回滚到上一版
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
) : null}
|
||||
</Space>
|
||||
<p className="admin-section-description admin-offset-top-sm">
|
||||
行业模板随品牌身份固定。升级目标为当前视觉模板最新已发布包,并按包版本与 checksum
|
||||
锁定预览;新增字段会补入,改动冲突和已移除字段不会覆盖或删除。回滚仅恢复配置基线,不删除品牌字段、内容或历史发布。
|
||||
</p>
|
||||
{templatePreview.data?.conflicts.length ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message={`请逐项确认保留 ${templatePreview.data.conflicts.length} 个现有品牌配置值`}
|
||||
description={
|
||||
<Space direction="vertical">
|
||||
{templatePreview.data.conflicts.map((item) => {
|
||||
const key = `${item.key}:${item.binding}`;
|
||||
return (
|
||||
<Checkbox
|
||||
key={key}
|
||||
checked={Boolean(preservedBindings[key])}
|
||||
onChange={(event) =>
|
||||
setPreservedBindings((current) => ({
|
||||
...current,
|
||||
[key]: event.target.checked,
|
||||
}))
|
||||
}
|
||||
>
|
||||
保留 {item.binding}({item.reason})
|
||||
</Checkbox>
|
||||
);
|
||||
})}
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
{templatePreview.data ? (
|
||||
<div className="admin-section-description admin-offset-top-sm">
|
||||
页面入口变更:新增 {templatePreview.data.changes.pages.added.length}、变更{" "}
|
||||
{templatePreview.data.changes.pages.changed.length}、移除{" "}
|
||||
{templatePreview.data.changes.pages.removed.length};资源槽位变更:新增{" "}
|
||||
{templatePreview.data.changes.assets.slots.added.length}、变更{" "}
|
||||
{templatePreview.data.changes.assets.slots.changed.length}、移除{" "}
|
||||
{templatePreview.data.changes.assets.slots.removed.length};
|
||||
{templatePreview.data.changes.assets.files.available
|
||||
? `包内文件变更:新增 ${templatePreview.data.changes.assets.files.added?.length ?? 0}、变更 ${templatePreview.data.changes.assets.files.changed?.length ?? 0}、移除 ${templatePreview.data.changes.assets.files.removed?.length ?? 0}`
|
||||
: templatePreview.data.changes.assets.files.reason}
|
||||
。模块与 renderer 由已部署的平台视觉模板管理,此次包升级不会替换 renderer。
|
||||
</div>
|
||||
) : null}
|
||||
<MutationError
|
||||
error={templatePreview.error || upgradeTemplate.error || rollbackTemplate.error}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
<MutationError error={install.error || selectVisual.error} />
|
||||
<Divider className="admin-divider" />
|
||||
<Space wrap>
|
||||
<Typography.Text>示例内容</Typography.Text>
|
||||
{sample.isLoading && <Spin size="small" />}
|
||||
{sample.data && (
|
||||
<StatusTag
|
||||
tone={sample.data.alreadyImported ? "success" : "info"}
|
||||
label={sample.data.alreadyImported ? "已导入" : "可导入"}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
disabled={!canManageTemplate || !sample.data || sample.data.alreadyImported}
|
||||
loading={importSample.isPending}
|
||||
onClick={() => importSample.mutate(sample.data?.source.templatePackageVersionId)}
|
||||
>
|
||||
导入示例内容
|
||||
</Button>
|
||||
{sample.isError && <Button onClick={() => void sample.refetch()}>重试</Button>}
|
||||
</Space>
|
||||
{sample.isError && (
|
||||
<div className="admin-offset-top-sm">
|
||||
<ErrorNote error={sample.error} onRetry={() => void sample.refetch()} />
|
||||
</div>
|
||||
)}
|
||||
{sample.data && !sample.data.alreadyImported && (
|
||||
<p className="admin-section-description admin-offset-top-sm">
|
||||
来源:{sample.data.source.packageKey}@{sample.data.source.version}
|
||||
(checksum {(sample.data.source.contentChecksum ?? "").slice(0, 12)})
|
||||
。将向草稿添加{" "}
|
||||
{Object.entries(sample.data.counts)
|
||||
.map(([key, count]) => `${key} ${count} 项`)
|
||||
.join("、")}
|
||||
;同时补齐当前模板缺失的页面初始配置,保留已有配置和已启用表单。发布前请替换示例文案和图片。
|
||||
</p>
|
||||
)}
|
||||
<MutationError error={importSample.error} />
|
||||
</AdminSection>
|
||||
<AdminSection
|
||||
title="核对草稿内容"
|
||||
description="此处核对的是待发布内容,不是小程序视觉预览。"
|
||||
>
|
||||
<ul className="admin-list">
|
||||
<li className="admin-row">
|
||||
<div className="admin-row-main">
|
||||
<div className="admin-row-line">
|
||||
<span className="admin-row-title">{brand.data?.name || "未命名品牌"}</span>
|
||||
<span className="admin-row-meta">
|
||||
{brand.data?.tagline || "尚未填写品牌定位"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li className="admin-row">
|
||||
<div className="admin-row-main">
|
||||
<div className="admin-row-line">
|
||||
<span className="admin-row-title">已启用业务项</span>
|
||||
<span className="admin-row-meta">
|
||||
{draftOfferings.map((item) => item.name).join("、") || "无"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li className="admin-row">
|
||||
<div className="admin-row-main">
|
||||
<div className="admin-row-line">
|
||||
<span className="admin-row-title">已启用咨询表单</span>
|
||||
<span className="admin-row-meta">
|
||||
{draftForms
|
||||
.filter((item) => item.isEnabled)
|
||||
.map((item) => item.name)
|
||||
.join("、") || "无"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<Space wrap className="admin-offset-top">
|
||||
<Button onClick={() => navigate("/admin/brand")}>编辑小程序页面</Button>
|
||||
<Button onClick={() => navigate("/admin/services")}>编辑业务展示和详情</Button>
|
||||
<Button onClick={() => navigate("/admin/trust")}>编辑信任证明</Button>
|
||||
</Space>
|
||||
</AdminSection>
|
||||
<AdminSection
|
||||
title="检查并发布"
|
||||
extra={
|
||||
<Space wrap>
|
||||
<StatusTag
|
||||
tone={currentRelease ? "success" : "neutral"}
|
||||
label={currentRelease ? `已发布 v${currentRelease.version}` : "尚未发布"}
|
||||
/>
|
||||
<Button onClick={() => void readiness.refetch()}>重新检查</Button>
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
<ul className="admin-list">
|
||||
{(readiness.data?.checks ?? []).map((check) => (
|
||||
<li key={check.key} className="admin-row">
|
||||
<div className="admin-row-main">
|
||||
<div className="admin-row-line">
|
||||
<StatusTag
|
||||
tone={check.passed ? "success" : "warning"}
|
||||
label={check.passed ? "已完成" : "待完善"}
|
||||
/>
|
||||
<span className="admin-row-title">{check.label}</span>
|
||||
{!check.passed && check.help ? (
|
||||
<span className="admin-row-meta">{check.help}</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
{!check.passed ? (
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
onClick={() =>
|
||||
navigate(check.destination ?? destinations[check.key] ?? "/admin/overview")
|
||||
}
|
||||
>
|
||||
去处理
|
||||
</Button>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Space wrap className="admin-offset-top">
|
||||
<Button
|
||||
type="primary"
|
||||
disabled={!readiness.data?.ready}
|
||||
onClick={() => setConfirmAction("publish")}
|
||||
>
|
||||
发布当前草稿
|
||||
</Button>
|
||||
{currentRelease && (
|
||||
<Button danger onClick={() => setConfirmAction("revoke")}>
|
||||
撤回当前版本
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
<MutationError error={publish.error || revoke.error} />
|
||||
<Divider className="admin-divider" />
|
||||
<h3 className="admin-section-title">发布记录</h3>
|
||||
{releases.data?.length ? (
|
||||
<ul className="admin-list admin-offset-top-xs">
|
||||
{releases.data.map((item) => (
|
||||
<li key={item.id} className="admin-row">
|
||||
<div className="admin-row-main">
|
||||
<div className="admin-row-line">
|
||||
<span className="admin-row-title">v{item.version}</span>
|
||||
<StatusTag
|
||||
tone={item.status === "published" ? "success" : "neutral"}
|
||||
label={statusLabel(item.status)}
|
||||
/>
|
||||
<span className="admin-row-meta">
|
||||
{new Date(item.createdAt).toLocaleString("zh-CN")}
|
||||
</span>
|
||||
{item.note ? <span className="admin-row-meta">{item.note}</span> : null}
|
||||
</div>
|
||||
</div>
|
||||
{item.status === "superseded" && publishedHistory.length > 1 ? (
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
onClick={() => setRollbackVersion(item.version)}
|
||||
>
|
||||
恢复此版本
|
||||
</Button>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<EmptyState
|
||||
compact
|
||||
title="暂无发布记录"
|
||||
description="完成检查并发布后,这里会保留每个版本的记录。"
|
||||
/>
|
||||
)}
|
||||
<MutationError error={rollback.error} />
|
||||
</AdminSection>
|
||||
</div>
|
||||
)}
|
||||
{activeTab === "miniapp" && (
|
||||
<div className="admin-stack admin-stack-lg">
|
||||
<AdminSection
|
||||
title="小程序代码发布"
|
||||
description="使用微信官方工具上传代码;审核与发布状态需按微信平台结果人工确认。"
|
||||
extra={
|
||||
<Space wrap>
|
||||
<Button
|
||||
type="primary"
|
||||
disabled={!currentRelease}
|
||||
loading={uploadLatestMiniAppRelease.isPending}
|
||||
onClick={() => uploadLatestMiniAppRelease.mutate()}
|
||||
>
|
||||
上传当前版本到微信
|
||||
</Button>
|
||||
{miniAppSettings.data?.hasStoredCredentials ? (
|
||||
<StatusTag tone="success" label="已配置上传凭据" />
|
||||
) : (
|
||||
<StatusTag tone="warning" label="未配置上传凭据" />
|
||||
)}
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
{miniAppReleases.data?.length ? (
|
||||
<div className="admin-stack admin-stack-tight">
|
||||
{miniAppReleases.data.map((task) => (
|
||||
<MiniAppReleaseCard
|
||||
key={task.id}
|
||||
task={task}
|
||||
uploading={uploadMiniAppRelease.isPending}
|
||||
onUpload={() => uploadMiniAppRelease.mutate(task.id)}
|
||||
onStatusChange={(status) => updateMiniAppStatus.mutate({ id: task.id, status })}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState
|
||||
compact
|
||||
title="暂无小程序发布任务"
|
||||
description="先发布品牌内容,再上传当前版本到微信。"
|
||||
/>
|
||||
)}
|
||||
</AdminSection>
|
||||
</div>
|
||||
)}
|
||||
<Modal
|
||||
title={confirmAction === "revoke" ? "确认撤回品牌" : "确认发布品牌"}
|
||||
open={confirmAction !== null}
|
||||
@@ -584,23 +300,6 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
>
|
||||
将 v{rollbackVersion} 重新发布为新版本;当前草稿不会被覆盖。
|
||||
</Modal>
|
||||
<Modal
|
||||
title="确认安装行业模板"
|
||||
open={industryTarget !== null}
|
||||
onCancel={() => setIndustryTarget(null)}
|
||||
okButtonProps={{ disabled: !templatePreview.data?.targetPackageVersionId }}
|
||||
onOk={() =>
|
||||
industryTarget &&
|
||||
templatePreview.data?.targetPackageVersionId &&
|
||||
install.mutate({
|
||||
key: industryTarget,
|
||||
versionId: templatePreview.data.targetPackageVersionId,
|
||||
})
|
||||
}
|
||||
confirmLoading={install.isPending}
|
||||
>
|
||||
模板会更新当前品牌的草稿结构,不会立即改变已发布的小程序。请安装后核对业务内容与视觉模板。
|
||||
</Modal>
|
||||
</QueryState>
|
||||
);
|
||||
}
|
||||
@@ -1,14 +1,11 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { message } from "antd";
|
||||
import type { BrandTemplateKey } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
|
||||
const client = createApiClient();
|
||||
|
||||
interface MutationOptions {
|
||||
refresh: () => void;
|
||||
currentTemplatePackageVersionId: string | null | undefined;
|
||||
onInstallClose: () => void;
|
||||
onPublishClose: () => void;
|
||||
onNoteClear: () => void;
|
||||
onRollbackClose: () => void;
|
||||
@@ -16,83 +13,11 @@ interface MutationOptions {
|
||||
|
||||
export function usePublicationMutations({
|
||||
refresh,
|
||||
onInstallClose,
|
||||
onPublishClose,
|
||||
onNoteClear,
|
||||
onRollbackClose,
|
||||
currentTemplatePackageVersionId,
|
||||
}: MutationOptions) {
|
||||
const queryClient = useQueryClient();
|
||||
const install = useMutation({
|
||||
mutationFn: ({ key, versionId }: { key: BrandTemplateKey; versionId: string }) =>
|
||||
client.installAdminTemplate(key, versionId),
|
||||
onSuccess: () => {
|
||||
onInstallClose();
|
||||
message.success("行业模板已安装");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const upgradeTemplate = useMutation({
|
||||
mutationFn: (input: {
|
||||
templatePackageVersionId: string;
|
||||
expectedContentChecksum: string;
|
||||
expectedCurrentVersion: string;
|
||||
expectedCurrentPackageVersionId: string | null;
|
||||
confirm: true;
|
||||
preservedBindings: Array<{ key: string; binding: string; action: "preserve" }>;
|
||||
}) => client.upgradeAdminTemplate(input),
|
||||
onSuccess: () => {
|
||||
message.success("行业模板已升级,现有内容未被覆盖");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const rollbackTemplate = useMutation({
|
||||
mutationFn: (input: { expectedCurrentVersion: string; confirm: true }) =>
|
||||
client.rollbackAdminTemplate(input),
|
||||
onSuccess: () => {
|
||||
message.success("行业模板配置基线已回滚");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const selectVisual = useMutation({
|
||||
mutationFn: (templatePackageVersionId: string) =>
|
||||
client.selectAdminTemplateVersion({
|
||||
templatePackageVersionId,
|
||||
...(currentTemplatePackageVersionId !== undefined
|
||||
? { expectedCurrentPackageVersionId: currentTemplatePackageVersionId }
|
||||
: {}),
|
||||
confirm: true,
|
||||
}),
|
||||
onSuccess: () => {
|
||||
message.success("模板版本已切换");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const importSample = useMutation<
|
||||
Awaited<ReturnType<typeof client.importAdminSampleContent>>,
|
||||
Error,
|
||||
string | undefined
|
||||
>({
|
||||
mutationFn: (templatePackageVersionId) =>
|
||||
client.importAdminSampleContent({
|
||||
...(templatePackageVersionId ? { templatePackageVersionId } : {}),
|
||||
strategy: "missing_only",
|
||||
confirm: true,
|
||||
}),
|
||||
onSuccess: ({ counts, alreadyImported }) => {
|
||||
if (alreadyImported) {
|
||||
message.info("该模板包版本的示例内容已导入,未重复创建");
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
message.success(
|
||||
counts.inquiryForms
|
||||
? "示例内容和客户咨询表单已导入草稿"
|
||||
: "示例内容已导入草稿,现有客户咨询表单已保留",
|
||||
);
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const publish = useMutation({
|
||||
mutationFn: (note: string) => client.publishAdminRelease(note || undefined),
|
||||
onSuccess: () => {
|
||||
@@ -163,11 +88,6 @@ export function usePublicationMutations({
|
||||
});
|
||||
|
||||
return {
|
||||
install,
|
||||
upgradeTemplate,
|
||||
rollbackTemplate,
|
||||
selectVisual,
|
||||
importSample,
|
||||
publish,
|
||||
revoke,
|
||||
rollback,
|
||||
|
||||
@@ -20,25 +20,6 @@ export function usePublicationQueries(
|
||||
queryKey: ["publication-workspace"],
|
||||
queryFn: () => client.getAdminWorkspace(),
|
||||
});
|
||||
const catalog = useQuery<Awaited<ReturnType<typeof client.listPublicTemplates>>>({
|
||||
queryKey: ["publication-catalog"],
|
||||
queryFn: () => client.listPublicTemplates(),
|
||||
});
|
||||
const packages = useQuery<Awaited<ReturnType<typeof client.listAdminTemplatePackages>>>({
|
||||
queryKey: ["publication-template-packages"],
|
||||
queryFn: () => client.listAdminTemplatePackages({ page: 1, pageSize: 100 }),
|
||||
});
|
||||
const sample = useQuery<Awaited<ReturnType<typeof client.previewAdminSampleContent>>>({
|
||||
queryKey: ["publication-sample", workspace.data?.installations[0]?.templatePackageVersionId],
|
||||
queryFn: () =>
|
||||
client.previewAdminSampleContent({
|
||||
...(workspace.data?.installations[0]?.templatePackageVersionId
|
||||
? { templatePackageVersionId: workspace.data.installations[0].templatePackageVersionId }
|
||||
: {}),
|
||||
strategy: "missing_only",
|
||||
}),
|
||||
enabled: Boolean(workspace.data),
|
||||
});
|
||||
const readiness = useQuery<Awaited<ReturnType<typeof client.getAdminReleaseReadiness>>>({
|
||||
queryKey: ["publication-readiness"],
|
||||
queryFn: () => client.getAdminReleaseReadiness(),
|
||||
@@ -55,12 +36,6 @@ export function usePublicationQueries(
|
||||
queryKey: ["publication-miniapp-settings"],
|
||||
queryFn: () => client.getAdminMiniAppSettings(),
|
||||
});
|
||||
const templatePreview = useQuery<
|
||||
Awaited<ReturnType<typeof client.getAdminTemplateUpgradePreview>>
|
||||
>({
|
||||
queryKey: ["publication-template-preview"],
|
||||
queryFn: () => client.getAdminTemplateUpgradePreview(),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!miniAppSettings.data) return;
|
||||
@@ -82,31 +57,15 @@ export function usePublicationQueries(
|
||||
return () => clearInterval(timer);
|
||||
}, [miniAppReleases]);
|
||||
|
||||
const loading = [
|
||||
brand,
|
||||
workspace,
|
||||
catalog,
|
||||
packages,
|
||||
readiness,
|
||||
releases,
|
||||
miniAppReleases,
|
||||
miniAppSettings,
|
||||
].some((query) => query.isLoading);
|
||||
const error = [
|
||||
brand,
|
||||
workspace,
|
||||
catalog,
|
||||
packages,
|
||||
readiness,
|
||||
releases,
|
||||
miniAppReleases,
|
||||
miniAppSettings,
|
||||
].find((query) => query.isError)?.error;
|
||||
const loading = [brand, workspace, readiness, releases, miniAppReleases, miniAppSettings].some(
|
||||
(query) => query.isLoading,
|
||||
);
|
||||
const error = [brand, workspace, readiness, releases, miniAppReleases, miniAppSettings].find(
|
||||
(query) => query.isError,
|
||||
)?.error;
|
||||
const retry = () => {
|
||||
void brand.refetch();
|
||||
void workspace.refetch();
|
||||
void catalog.refetch();
|
||||
void packages.refetch();
|
||||
void readiness.refetch();
|
||||
void releases.refetch();
|
||||
void miniAppReleases.refetch();
|
||||
@@ -116,14 +75,10 @@ export function usePublicationQueries(
|
||||
return {
|
||||
brand,
|
||||
workspace,
|
||||
catalog,
|
||||
packages,
|
||||
sample,
|
||||
readiness,
|
||||
releases,
|
||||
miniAppReleases,
|
||||
miniAppSettings,
|
||||
templatePreview,
|
||||
loading,
|
||||
error,
|
||||
retry,
|
||||
|
||||
@@ -20,7 +20,7 @@ export function useOfferingEditor(templateFields: TemplateAdminField[]) {
|
||||
const templateFieldSection = useMemo<TemplateAdminSection>(
|
||||
() => ({
|
||||
key: "offering",
|
||||
title: "模板内容",
|
||||
title: "页面方案内容",
|
||||
description: "",
|
||||
page: "detail",
|
||||
target: "offering",
|
||||
|
||||
@@ -66,7 +66,7 @@ export function TrustContentPage() {
|
||||
}
|
||||
/>
|
||||
<AdminSection
|
||||
title="当前模板需要配置的内容"
|
||||
title="当前页面方案需要配置的内容"
|
||||
description="标记为「发布必填」的项目需要填写完整后,才能发布小程序。"
|
||||
>
|
||||
<TrustRequirementsList
|
||||
|
||||
@@ -137,7 +137,7 @@ function sharesMeaningfulOverlap(label: string, token: string): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 列表按模板声明的类型顺序排列,与「当前模板需要配置的内容」保持一致。
|
||||
// 列表按页面方案声明的类型顺序排列,与「当前页面方案需要配置的内容」保持一致。
|
||||
export function sortTrustContentByTypeOrder(
|
||||
items: TrustContent[],
|
||||
availableTypes: TrustTypeOption[],
|
||||
|
||||
@@ -156,6 +156,44 @@ body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.admin-full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.admin-choice-card.ant-radio-button-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 104px;
|
||||
padding: 16px;
|
||||
white-space: normal;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.admin-choice-card--wide.ant-radio-button-wrapper {
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.admin-choice-card.ant-radio-button-wrapper > span:last-child {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.admin-choice-card .ant-radio-button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.admin-choice-card span {
|
||||
color: var(--admin-text-secondary);
|
||||
}
|
||||
|
||||
.admin-choice-card strong {
|
||||
color: var(--admin-text);
|
||||
}
|
||||
|
||||
.admin-content {
|
||||
flex: 1;
|
||||
padding: 24px;
|
||||
|
||||
@@ -4,12 +4,20 @@ import { createElement } from "react";
|
||||
import { renderToString } from "react-dom/server";
|
||||
import { MemoryRouter, Route, Routes, resolvePath } from "react-router-dom";
|
||||
import { AdminOverviewRedirect, AdminRouter } from "../src/app/AdminRouter.ts";
|
||||
import {
|
||||
canCreateBrand,
|
||||
createBrandFallbackPath,
|
||||
createBrandRouteElement,
|
||||
} from "../src/app/route-access.ts";
|
||||
|
||||
test("后台父路由正确匹配所有菜单及深层链接", () => {
|
||||
const pages = [
|
||||
"overview",
|
||||
"publication",
|
||||
"brand",
|
||||
"brands",
|
||||
"brands/new",
|
||||
"page-scheme",
|
||||
"trust",
|
||||
"services",
|
||||
"inquiries",
|
||||
@@ -51,3 +59,17 @@ test("默认与无效地址的概览重定向为绝对地址且替换历史记
|
||||
assert.equal(resolvePath(redirect.props.to, pathname).pathname, "/admin/overview");
|
||||
}
|
||||
});
|
||||
|
||||
test("只有品牌负责人可以进入创建品牌路由", () => {
|
||||
assert.equal(canCreateBrand("owner"), true);
|
||||
for (const role of ["admin", "editor", "platform-admin"]) {
|
||||
assert.equal(canCreateBrand(role), false);
|
||||
}
|
||||
|
||||
const content = createElement("h1", null, "create-brand");
|
||||
assert.equal(createBrandRouteElement("owner", content), content);
|
||||
|
||||
const denied = createBrandRouteElement("admin", content);
|
||||
assert.equal(denied.props.to, createBrandFallbackPath);
|
||||
assert.equal(denied.props.replace, true);
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE "BrandProfile" ALTER COLUMN "slug" DROP DEFAULT;
|
||||
ALTER TABLE "BrandProfile" ALTER COLUMN "templateKey" DROP DEFAULT;
|
||||
@@ -35,9 +35,9 @@ enum FulfillmentType {
|
||||
|
||||
model BrandProfile {
|
||||
id String @id @default(uuid())
|
||||
slug String @unique @default("default-brand")
|
||||
slug String @unique
|
||||
name String
|
||||
templateKey String @default("food")
|
||||
templateKey String
|
||||
tagline String?
|
||||
description String?
|
||||
avatarUrl String?
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
import { existsSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { PrismaClient, type Prisma } from "@prisma/client";
|
||||
import type { TemplatePackageManifest } from "@personal-brand/config";
|
||||
import bcrypt from "bcryptjs";
|
||||
import { buildBrandReleaseSnapshot } from "../src/brand-release.service.js";
|
||||
import { latestTemplateVersion } from "../src/template-version-order.js";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
const seedAssetsDirectory = path.join(path.dirname(fileURLToPath(import.meta.url)), "assets");
|
||||
|
||||
function seedMediaExists(url: unknown): boolean {
|
||||
if (typeof url !== "string" || !url) return false;
|
||||
if (!url.startsWith("/media/seed/")) return true;
|
||||
return existsSync(path.join(seedAssetsDirectory, path.basename(url)));
|
||||
}
|
||||
|
||||
const runtimeImages = {
|
||||
doors: [
|
||||
@@ -48,7 +59,7 @@ interface RuntimeSeedTemplate {
|
||||
const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTemplate> = {
|
||||
personal: {
|
||||
templateKey: "personal",
|
||||
visualTemplateKey: "linjing-editorial",
|
||||
visualTemplateKey: "atelier-solopreneur",
|
||||
brandConfig: {
|
||||
templateData: { designPhilosophy: "先厘清问题,再设计表达" },
|
||||
title: "品牌策略顾问",
|
||||
@@ -299,7 +310,7 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
|
||||
phone: "186-0218-9908",
|
||||
wechat: "LIN-ATELIER-2024",
|
||||
studioAddress: "上海市静安区威海路设计中心 A 座 / 杭州良渚研造工坊",
|
||||
avatarUrl: "/media/seed/personal-avatar.jpg",
|
||||
avatarUrl: "/media/seed/founder-portrait.jpg",
|
||||
profilePresentation: {
|
||||
coverage: [
|
||||
{
|
||||
@@ -718,23 +729,42 @@ async function ensureRuntimeContent(brandId: string, template: RuntimeSeedTempla
|
||||
data: { isEnabled: false },
|
||||
});
|
||||
}
|
||||
const incompleteOfferings = await prisma.offering.findMany({
|
||||
where: { brandId, isEnabled: true, coverUrl: null },
|
||||
select: { id: true, name: true },
|
||||
});
|
||||
for (const [index, item] of incompleteOfferings.entries()) {
|
||||
const image = offerings[index % offerings.length]?.image;
|
||||
if (!image) throw new Error("Development fixture has no offering image");
|
||||
// 旧模板迁移后可能留下数组形态的 config 或失效媒体引用。开发种子只修复结构,
|
||||
// 不删除品牌内容,也不擅自重新启用已停用的业务提供项。
|
||||
const allOfferings = await prisma.offering.findMany({ where: { brandId } });
|
||||
const fallbackImage = offerings[0]?.image;
|
||||
if (!fallbackImage) throw new Error("Development fixture has no offering image");
|
||||
for (const offering of allOfferings) {
|
||||
const rawConfig = offering.config;
|
||||
const config =
|
||||
rawConfig && typeof rawConfig === "object" && !Array.isArray(rawConfig)
|
||||
? (rawConfig as Record<string, unknown>)
|
||||
: {};
|
||||
const media = config.media;
|
||||
const hasValidMedia =
|
||||
Array.isArray(media) &&
|
||||
media.length > 0 &&
|
||||
media.every(
|
||||
(entry) =>
|
||||
entry &&
|
||||
typeof entry === "object" &&
|
||||
!Array.isArray(entry) &&
|
||||
seedMediaExists((entry as Record<string, unknown>).url),
|
||||
);
|
||||
const hasValidCover = seedMediaExists(offering.coverUrl);
|
||||
const coverUrl = hasValidCover ? (offering.coverUrl as string) : fallbackImage;
|
||||
if (hasValidCover && hasValidMedia && !Array.isArray(rawConfig)) continue;
|
||||
await prisma.offering.update({
|
||||
where: { id: item.id },
|
||||
where: { id: offering.id },
|
||||
data: {
|
||||
coverUrl: image,
|
||||
coverUrl,
|
||||
config: {
|
||||
categoryKey: "custom",
|
||||
keywords: [],
|
||||
media: [{ url: image, alt: item.name, type: "image" }],
|
||||
sections: [],
|
||||
},
|
||||
...config,
|
||||
...(config.categoryKey === undefined ? { categoryKey: "custom" } : {}),
|
||||
...(Array.isArray(config.keywords) ? {} : { keywords: [] }),
|
||||
media: [{ url: coverUrl, alt: offering.name, type: "image" }],
|
||||
...(Array.isArray(config.sections) ? {} : { sections: [] }),
|
||||
} as Prisma.InputJsonValue,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -812,10 +842,12 @@ async function ensureTemplateInstallation(brandId: string): Promise<void> {
|
||||
throw new Error("Development brand installation does not satisfy the template contract");
|
||||
return;
|
||||
}
|
||||
const packageVersion = await prisma.templatePackageVersion.findFirst({
|
||||
where: { packageKey: visualKey, status: "published" },
|
||||
orderBy: { importedAt: "desc" },
|
||||
});
|
||||
// 版本升级必须按 SemVer 判断最新版,导入时间只用于同版本排序。
|
||||
const packageVersion = latestTemplateVersion(
|
||||
await prisma.templatePackageVersion.findMany({
|
||||
where: { packageKey: visualKey, status: "published" },
|
||||
}),
|
||||
);
|
||||
if (!packageVersion)
|
||||
throw new Error(`Development brand requires a published package version: ${visualKey}`);
|
||||
const configSnapshot = packageVersion.manifestSnapshot as Prisma.InputJsonValue;
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
MinLength,
|
||||
Matches,
|
||||
Max,
|
||||
MaxLength,
|
||||
Min,
|
||||
} from "class-validator";
|
||||
import { brandTemplateKeys } from "@personal-brand/config";
|
||||
@@ -53,6 +54,26 @@ export class CreateBrandMemberDto {
|
||||
@IsIn(["owner", "editor"]) role!: "owner" | "editor";
|
||||
}
|
||||
|
||||
export class CreateBrandDto {
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(80)
|
||||
name!: string;
|
||||
|
||||
@IsString()
|
||||
@Matches(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, {
|
||||
message: "slug 只能包含小写字母、数字和连字符",
|
||||
})
|
||||
@MaxLength(80)
|
||||
slug!: string;
|
||||
|
||||
@IsIn(brandTemplateKeys)
|
||||
businessType!: BrandTemplateKey;
|
||||
|
||||
@IsUUID()
|
||||
templatePackageVersionId!: string;
|
||||
}
|
||||
|
||||
export class ChangeAdminPasswordDto {
|
||||
@IsString() currentPassword!: string;
|
||||
@IsString() @MinLength(8) newPassword!: string;
|
||||
|
||||
@@ -3,7 +3,8 @@ import { Body, Controller, Get, Param, Patch, Post, Req, Res } from "@nestjs/com
|
||||
import type { FastifyReply, FastifyRequest } from "fastify";
|
||||
import { setAdminSessionCookie } from "../../admin-session-cookie.js";
|
||||
import { requireAdminIdentity } from "../../admin-access.identity.js";
|
||||
import { CreateBrandMemberDto, UpdateBrandMemberDto } from "../../admin.dto.js";
|
||||
import { signIdentity } from "../../auth.js";
|
||||
import { CreateBrandDto, CreateBrandMemberDto, UpdateBrandMemberDto } from "../../admin.dto.js";
|
||||
import { TenantService } from "./tenant.service.js";
|
||||
|
||||
@AdminBrand()
|
||||
@@ -11,10 +12,38 @@ import { TenantService } from "./tenant.service.js";
|
||||
export class TenantController {
|
||||
constructor(private readonly tenants: TenantService) {}
|
||||
|
||||
@AdminRoles(["owner"])
|
||||
@Get("creation-options")
|
||||
async creationOptions(): Promise<unknown> {
|
||||
return this.tenants.getCreationOptions();
|
||||
}
|
||||
|
||||
@AdminRoles(["owner"])
|
||||
@Post()
|
||||
async create(
|
||||
@Req() request: FastifyRequest,
|
||||
@Body() body: CreateBrandDto,
|
||||
@Res({ passthrough: true }) reply: FastifyReply,
|
||||
): Promise<{ role: string; brand: unknown }> {
|
||||
const identity = adminIdentity(request);
|
||||
const requestId = request.headers["x-request-id"]?.toString() ?? request.id;
|
||||
const brand = await this.tenants.createBrand(identity, body, requestId);
|
||||
setAdminSessionCookie(
|
||||
reply,
|
||||
signIdentity({
|
||||
subject: identity.subject,
|
||||
brandId: brand.id,
|
||||
role: "admin",
|
||||
...(identity.tokenVersion === undefined ? {} : { tokenVersion: identity.tokenVersion }),
|
||||
}),
|
||||
);
|
||||
return { role: "owner", brand };
|
||||
}
|
||||
|
||||
@AdminRoles(["owner", "admin", "platform-admin"])
|
||||
@Get("members")
|
||||
async listMembers(@Req() request: FastifyRequest): Promise<unknown> {
|
||||
const current = this.adminIdentity(request);
|
||||
const current = adminIdentity(request);
|
||||
return this.tenants.listMembers(current.brandId);
|
||||
}
|
||||
|
||||
@@ -24,7 +53,7 @@ export class TenantController {
|
||||
@Req() request: FastifyRequest,
|
||||
@Body() body: CreateBrandMemberDto,
|
||||
): Promise<unknown> {
|
||||
const actor = this.adminIdentity(request);
|
||||
const actor = adminIdentity(request);
|
||||
return this.tenants.createMember(actor.brandId, body);
|
||||
}
|
||||
|
||||
@@ -35,13 +64,13 @@ export class TenantController {
|
||||
@Param("id") id: string,
|
||||
@Body() body: UpdateBrandMemberDto,
|
||||
): Promise<unknown> {
|
||||
const actor = this.adminIdentity(request);
|
||||
const actor = adminIdentity(request);
|
||||
return this.tenants.updateMember(actor.brandId, actor.subject, id, body);
|
||||
}
|
||||
|
||||
@Get()
|
||||
async list(@Req() request: FastifyRequest): Promise<unknown> {
|
||||
const identity = this.adminIdentity(request);
|
||||
const identity = adminIdentity(request);
|
||||
return this.tenants.listMemberships(identity.subject);
|
||||
}
|
||||
|
||||
@@ -51,13 +80,13 @@ export class TenantController {
|
||||
@Param("brandId") brandId: string,
|
||||
@Res({ passthrough: true }) reply: FastifyReply,
|
||||
): Promise<{ role: string; brand: unknown }> {
|
||||
const identity = this.adminIdentity(request);
|
||||
const identity = adminIdentity(request);
|
||||
const result = await this.tenants.switchBrand(identity, brandId);
|
||||
setAdminSessionCookie(reply, result.token);
|
||||
return { role: result.role, brand: result.brand };
|
||||
}
|
||||
}
|
||||
|
||||
private adminIdentity(request: FastifyRequest) {
|
||||
return requireAdminIdentity(request);
|
||||
}
|
||||
function adminIdentity(request: FastifyRequest) {
|
||||
return requireAdminIdentity(request);
|
||||
}
|
||||
@@ -5,15 +5,107 @@ import {
|
||||
Injectable,
|
||||
} from "@nestjs/common";
|
||||
import bcrypt from "bcryptjs";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { getBrandTemplate } from "@personal-brand/config";
|
||||
import { PrismaService } from "../../prisma.service.js";
|
||||
import { signIdentity } from "../../auth.js";
|
||||
import type { CreateBrandMemberDto, UpdateBrandMemberDto } from "../../admin.dto.js";
|
||||
import type {
|
||||
CreateBrandDto,
|
||||
CreateBrandMemberDto,
|
||||
UpdateBrandMemberDto,
|
||||
} from "../../admin.dto.js";
|
||||
import { TemplateWorkspaceService } from "../../template-workspace.service.js";
|
||||
|
||||
type AdminIdentity = { subject: string; brandId: string; tokenVersion?: number };
|
||||
|
||||
@Injectable()
|
||||
export class TenantService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly templateWorkspace: TemplateWorkspaceService,
|
||||
) {}
|
||||
|
||||
async getCreationOptions() {
|
||||
const catalog = await this.templateWorkspace.getPageSchemeCatalog();
|
||||
// 创建品牌只应从每个页面方案的最新已发布版本开始;旧版本仍可在页面方案页显式切换。
|
||||
return {
|
||||
...catalog,
|
||||
pageSchemes: catalog.pageSchemes.filter((scheme) => scheme.isLatestForPackage),
|
||||
};
|
||||
}
|
||||
|
||||
async createBrand(identity: AdminIdentity, body: CreateBrandDto, requestId?: string) {
|
||||
const template = getBrandTemplate(body.businessType);
|
||||
if (!template) throw new BadRequestException("业务类型不存在");
|
||||
const name = body.name.trim();
|
||||
const slug = body.slug.trim();
|
||||
if (!name || !slug) throw new BadRequestException("品牌名称和小程序地址标识不能为空");
|
||||
const packageVersion = await this.templateWorkspace.resolveInstallablePackageVersion(
|
||||
body.businessType,
|
||||
body.templatePackageVersionId,
|
||||
);
|
||||
|
||||
try {
|
||||
return await this.prisma.$transaction(async (tx) => {
|
||||
const brand = await tx.brandProfile.create({
|
||||
data: {
|
||||
name,
|
||||
slug,
|
||||
templateKey: body.businessType,
|
||||
config: {},
|
||||
},
|
||||
});
|
||||
await tx.brandTemplateInstallation.create({
|
||||
data: {
|
||||
brandId: brand.id,
|
||||
templateKey: body.businessType,
|
||||
templateVersion: packageVersion.version,
|
||||
templatePackageVersionId: packageVersion.id,
|
||||
contentChecksum: packageVersion.contentChecksum,
|
||||
configSnapshot: packageVersion.manifestSnapshot as Prisma.InputJsonValue,
|
||||
},
|
||||
});
|
||||
await tx.brandFieldDefinition.createMany({
|
||||
data: template.fields.map(({ scope, key, label, type, required }, sortOrder) => ({
|
||||
brandId: brand.id,
|
||||
scope,
|
||||
key,
|
||||
label,
|
||||
type,
|
||||
required,
|
||||
sortOrder,
|
||||
source: "core",
|
||||
})),
|
||||
});
|
||||
await tx.brandMembership.create({
|
||||
data: {
|
||||
adminUserId: identity.subject,
|
||||
brandId: brand.id,
|
||||
role: "owner",
|
||||
isEnabled: true,
|
||||
},
|
||||
});
|
||||
await tx.templatePackageAuditLog.create({
|
||||
data: {
|
||||
templatePackageVersionId: packageVersion.id,
|
||||
actorId: identity.subject,
|
||||
action: "brand_created",
|
||||
...(requestId ? { requestId } : {}),
|
||||
metadata: {
|
||||
brandId: brand.id,
|
||||
businessType: body.businessType,
|
||||
slug: brand.slug,
|
||||
},
|
||||
},
|
||||
});
|
||||
return brand;
|
||||
});
|
||||
} catch (error) {
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError && error.code === "P2002")
|
||||
throw new ConflictException("小程序地址标识已被使用,请更换后重试");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
listMembers(brandId: string) {
|
||||
return this.prisma.brandMembership.findMany({
|
||||
|
||||
@@ -10,6 +10,13 @@ import { requireAdminIdentity } from "../../admin-access.identity.js";
|
||||
class AdminTemplateController {
|
||||
constructor(private readonly templateWorkspace: TemplateWorkspaceService) {}
|
||||
|
||||
@AdminRoles(["owner", "admin", "platform-admin"])
|
||||
@Get("template/options")
|
||||
options(@Req() request: FastifyRequest): Promise<unknown> {
|
||||
return this.templateWorkspace.getPageSchemeOptions(requireAdminIdentity(request).brandId);
|
||||
}
|
||||
|
||||
@AdminRoles(["owner", "admin", "platform-admin"])
|
||||
@Get("template/preview")
|
||||
preview(@Req() request: FastifyRequest): Promise<unknown> {
|
||||
return this.templateWorkspace.preview(requireAdminIdentity(request).brandId);
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
const SEMVER_PATTERN =
|
||||
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
||||
const fallbackVersionCollator = new Intl.Collator("en", {
|
||||
numeric: true,
|
||||
sensitivity: "base",
|
||||
});
|
||||
|
||||
type VersionOrderable = {
|
||||
version: string;
|
||||
importedAt?: Date;
|
||||
createdAt?: Date;
|
||||
};
|
||||
|
||||
function comparePrerelease(left: string, right: string) {
|
||||
if (left === right) return 0;
|
||||
if (!left) return 1;
|
||||
if (!right) return -1;
|
||||
const leftParts = left.split(".");
|
||||
const rightParts = right.split(".");
|
||||
for (let index = 0; index < Math.max(leftParts.length, rightParts.length); index += 1) {
|
||||
const leftPart = leftParts[index];
|
||||
const rightPart = rightParts[index];
|
||||
if (leftPart === undefined) return -1;
|
||||
if (rightPart === undefined) return 1;
|
||||
if (leftPart === rightPart) continue;
|
||||
const leftNumeric = /^\d+$/.test(leftPart);
|
||||
const rightNumeric = /^\d+$/.test(rightPart);
|
||||
if (leftNumeric && rightNumeric) return Number(leftPart) - Number(rightPart);
|
||||
if (leftNumeric !== rightNumeric) return leftNumeric ? -1 : 1;
|
||||
return leftPart.localeCompare(rightPart);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
export function compareTemplateVersions(left: string, right: string) {
|
||||
const leftMatch = SEMVER_PATTERN.exec(left);
|
||||
const rightMatch = SEMVER_PATTERN.exec(right);
|
||||
if (!leftMatch || !rightMatch) return fallbackVersionCollator.compare(left, right);
|
||||
for (let index = 1; index <= 3; index += 1) {
|
||||
const difference = Number(leftMatch[index]) - Number(rightMatch[index]);
|
||||
if (difference !== 0) return difference;
|
||||
}
|
||||
return comparePrerelease(leftMatch[4] ?? "", rightMatch[4] ?? "");
|
||||
}
|
||||
|
||||
/** 按 SemVer 从新到旧排序;同版本使用导入和创建时间保证顺序稳定。 */
|
||||
export function compareTemplateVersionOrder(left: VersionOrderable, right: VersionOrderable) {
|
||||
const versionOrder = compareTemplateVersions(right.version, left.version);
|
||||
if (versionOrder !== 0) return versionOrder;
|
||||
const importedOrder = (right.importedAt?.getTime() ?? 0) - (left.importedAt?.getTime() ?? 0);
|
||||
if (importedOrder !== 0) return importedOrder;
|
||||
return (right.createdAt?.getTime() ?? 0) - (left.createdAt?.getTime() ?? 0);
|
||||
}
|
||||
|
||||
export function latestTemplateVersion<T extends VersionOrderable>(versions: readonly T[]) {
|
||||
return versions.reduce<T | undefined>((latest, current) => {
|
||||
if (!latest || compareTemplateVersionOrder(current, latest) < 0) return current;
|
||||
return latest;
|
||||
}, undefined);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import type { TemplatePackageVersion } from "@prisma/client";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import {
|
||||
type BrandTemplateKey,
|
||||
brandTemplateKeys,
|
||||
getBrandTemplate,
|
||||
getVisualTemplate,
|
||||
getVisualTemplateManifest,
|
||||
@@ -14,10 +15,99 @@ import type { CreateTrustContentDto, UpdateTrustContentDto } from "./admin.dto.j
|
||||
import type { RollbackTemplateDto, UpgradeTemplateDto } from "./admin.dto.js";
|
||||
import { PrismaService } from "./prisma.service.js";
|
||||
import { recordTemplateOperationFailure } from "./modules/admin/template-operation-failure.js";
|
||||
import { compareTemplateVersions, latestTemplateVersion } from "./template-version-order.js";
|
||||
|
||||
@Injectable()
|
||||
export class TemplateWorkspaceService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async getPageSchemeCatalog() {
|
||||
const versions = await this.prisma.templatePackageVersion.findMany({
|
||||
where: { status: "published" },
|
||||
orderBy: [{ importedAt: "desc" }, { createdAt: "desc" }],
|
||||
});
|
||||
const candidates = versions.flatMap((version) => {
|
||||
const manifest = record(version.manifestSnapshot);
|
||||
const visualTemplateKey = manifest.visualTemplateKey;
|
||||
if (
|
||||
manifest.packageKey !== version.packageKey ||
|
||||
manifest.version !== version.version ||
|
||||
typeof visualTemplateKey !== "string" ||
|
||||
visualTemplateKey !== version.packageKey
|
||||
)
|
||||
return [];
|
||||
const visualTemplate = getVisualTemplate(visualTemplateKey);
|
||||
const visualManifest = getVisualTemplateManifest(visualTemplateKey);
|
||||
if (!visualTemplate || !visualManifest) return [];
|
||||
const supportedBusinessTypes = Array.isArray(manifest.supportedIndustryTemplates)
|
||||
? manifest.supportedIndustryTemplates.filter(
|
||||
(value): value is BrandTemplateKey =>
|
||||
typeof value === "string" &&
|
||||
brandTemplateKeys.includes(value) &&
|
||||
Boolean(getBrandTemplate(value)),
|
||||
)
|
||||
: [];
|
||||
if (
|
||||
supportedBusinessTypes.length === 0 ||
|
||||
supportedBusinessTypes.some(
|
||||
(businessType) => !isVisualTemplateCompatible(visualTemplate, businessType),
|
||||
) ||
|
||||
validateTemplatePackageManifest(manifest).length > 0
|
||||
)
|
||||
return [];
|
||||
return [
|
||||
{
|
||||
templatePackageVersionId: version.id,
|
||||
packageKey: version.packageKey,
|
||||
name: version.displayName,
|
||||
description: visualManifest.description,
|
||||
version: version.version,
|
||||
supportedBusinessTypes,
|
||||
},
|
||||
];
|
||||
});
|
||||
const latestByPackage = new Map<string, string>();
|
||||
for (const candidate of candidates) {
|
||||
const latestVersion = latestByPackage.get(candidate.packageKey);
|
||||
if (!latestVersion || compareTemplateVersions(candidate.version, latestVersion) > 0) {
|
||||
latestByPackage.set(candidate.packageKey, candidate.version);
|
||||
}
|
||||
}
|
||||
const pageSchemes = candidates.map(({ packageKey, ...candidate }) => ({
|
||||
...candidate,
|
||||
isLatestForPackage: latestByPackage.get(packageKey) === candidate.version,
|
||||
}));
|
||||
|
||||
return {
|
||||
businesses: brandTemplateKeys.map((key) => {
|
||||
const template = getBrandTemplate(key);
|
||||
if (!template) throw new BadRequestException("业务类型配置不完整");
|
||||
return { key, name: template.name, description: template.description };
|
||||
}),
|
||||
pageSchemes,
|
||||
};
|
||||
}
|
||||
|
||||
async getPageSchemeOptions(brandId: string) {
|
||||
const brand = await this.prisma.brandProfile.findUnique({
|
||||
where: { id: brandId },
|
||||
select: { templateKey: true },
|
||||
});
|
||||
const template = brand ? getBrandTemplate(brand.templateKey) : undefined;
|
||||
if (!brand || !template) throw new BadRequestException("品牌业务类型无效");
|
||||
const catalog = await this.getPageSchemeCatalog();
|
||||
return {
|
||||
business: {
|
||||
key: template.key,
|
||||
name: template.name,
|
||||
description: template.description,
|
||||
},
|
||||
pageSchemes: catalog.pageSchemes.filter((scheme) =>
|
||||
scheme.supportedBusinessTypes.includes(template.key),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
async getTrustContentTypes(brandId: string): Promise<string[]> {
|
||||
const installation = await this.prisma.brandTemplateInstallation.findUnique({
|
||||
where: { brandId },
|
||||
@@ -124,6 +214,7 @@ export class TemplateWorkspaceService {
|
||||
select: { templateKey: true },
|
||||
}),
|
||||
]);
|
||||
if (!brand) throw new BadRequestException("品牌不存在");
|
||||
// 一个品牌只使用一个行业模板(BrandProfile.templateKey 即身份)。安装只允许补建当前模板的版本台账,
|
||||
// 不得换成别的行业模板,否则会出现「身份是 A、台账是 B」的漂移,并把发布快照接到不适配的视觉模板上。
|
||||
const currentTemplate = brand?.templateKey ? getBrandTemplate(brand.templateKey) : undefined;
|
||||
@@ -147,15 +238,11 @@ export class TemplateWorkspaceService {
|
||||
)
|
||||
throw new BadRequestException("当前视觉模板不适配行业模板");
|
||||
return this.prisma.$transaction(async (tx) => {
|
||||
await tx.brandProfile.update({
|
||||
where: { id: brandId },
|
||||
data: { templateKey },
|
||||
});
|
||||
const installation = await tx.brandTemplateInstallation.create({
|
||||
data: {
|
||||
brandId,
|
||||
templateKey,
|
||||
templateVersion: template.version,
|
||||
templateVersion: packageVersion.version,
|
||||
templatePackageVersionId: packageVersion.id,
|
||||
contentChecksum: packageVersion.contentChecksum,
|
||||
configSnapshot: packageVersion.manifestSnapshot as Prisma.InputJsonValue,
|
||||
@@ -176,7 +263,7 @@ export class TemplateWorkspaceService {
|
||||
return { installation, template, visualTemplate: visualManifest };
|
||||
});
|
||||
}
|
||||
private async resolveInstallablePackageVersion(
|
||||
async resolveInstallablePackageVersion(
|
||||
templateKey: BrandTemplateKey,
|
||||
templatePackageVersionId: string,
|
||||
): Promise<TemplatePackageVersion> {
|
||||
@@ -195,7 +282,7 @@ export class TemplateWorkspaceService {
|
||||
!Array.isArray(manifest.supportedIndustryTemplates) ||
|
||||
!manifest.supportedIndustryTemplates.includes(templateKey)
|
||||
) {
|
||||
throw new BadRequestException("模板包版本与行业或视觉模板不匹配");
|
||||
throw new BadRequestException("页面方案与所选业务类型不兼容,请重新选择");
|
||||
}
|
||||
if (validateTemplatePackageManifest(manifest).length)
|
||||
throw new BadRequestException("模板包版本不符合统一模板契约");
|
||||
@@ -253,11 +340,17 @@ export class TemplateWorkspaceService {
|
||||
if (!target || target.status !== "published")
|
||||
throw new BadRequestException("指定模板包版本不存在或未发布");
|
||||
const manifest = record(target.manifestSnapshot) as unknown as TemplatePackageManifest;
|
||||
const visualTemplate =
|
||||
typeof manifest.visualTemplateKey === "string"
|
||||
? getVisualTemplate(manifest.visualTemplateKey)
|
||||
: undefined;
|
||||
if (
|
||||
target.packageKey !== manifest.packageKey ||
|
||||
target.version !== manifest.version ||
|
||||
manifest.packageKey !== manifest.visualTemplateKey ||
|
||||
!manifest.supportedIndustryTemplates?.includes(brand.templateKey) ||
|
||||
!visualTemplate ||
|
||||
!isVisualTemplateCompatible(visualTemplate, brand.templateKey) ||
|
||||
validateTemplatePackageManifest(manifest).length
|
||||
)
|
||||
throw new BadRequestException("指定模板包版本不符合当前品牌的统一模板契约");
|
||||
@@ -329,15 +422,28 @@ export class TemplateWorkspaceService {
|
||||
).visualTemplateKey;
|
||||
if (typeof visualTemplateKey !== "string")
|
||||
throw new BadRequestException("已安装模板版本缺少 visualTemplateKey 声明");
|
||||
const [currentPackage, targetPackage] = await Promise.all([
|
||||
const [currentPackage, publishedTargets] = await Promise.all([
|
||||
this.prisma.templatePackageVersion.findUnique({
|
||||
where: { id: installation.templatePackageVersionId },
|
||||
}),
|
||||
this.prisma.templatePackageVersion.findFirst({
|
||||
this.prisma.templatePackageVersion.findMany({
|
||||
where: { packageKey: visualTemplateKey, status: "published" },
|
||||
orderBy: { importedAt: "desc" },
|
||||
}),
|
||||
]);
|
||||
const targetPackage = latestTemplateVersion(
|
||||
publishedTargets.filter((candidate) => {
|
||||
const manifest = record(candidate.manifestSnapshot);
|
||||
return (
|
||||
candidate.packageKey === visualTemplateKey &&
|
||||
manifest.packageKey === candidate.packageKey &&
|
||||
manifest.version === candidate.version &&
|
||||
manifest.visualTemplateKey === visualTemplateKey &&
|
||||
Array.isArray(manifest.supportedIndustryTemplates) &&
|
||||
manifest.supportedIndustryTemplates.includes(installation.templateKey) &&
|
||||
validateTemplatePackageManifest(manifest).length === 0
|
||||
);
|
||||
}),
|
||||
);
|
||||
if (!currentPackage) throw new BadRequestException("当前安装引用的模板包版本不存在");
|
||||
if (
|
||||
currentPackage.packageKey !== visualTemplateKey ||
|
||||
@@ -507,7 +613,7 @@ export class TemplateWorkspaceService {
|
||||
})
|
||||
.sort();
|
||||
if (JSON.stringify(expectedConflicts) !== JSON.stringify(preserved))
|
||||
throw new ConflictException("冲突处理与当前预览不一致,请重新预览并逐项确认");
|
||||
throw new ConflictException("冲突处理与当前预览不一致,请重新预览后再升级");
|
||||
const manifest = record(target.manifestSnapshot);
|
||||
if (
|
||||
target.packageKey !==
|
||||
|
||||
@@ -12,11 +12,20 @@ import { AdminCapabilityController } from "../src/modules/workspace/admin-capabi
|
||||
import { AdminOfferingController } from "../src/modules/workspace/admin-offering.controller.js";
|
||||
import { AdminInquiryController } from "../src/modules/workspace/admin-inquiry.controller.js";
|
||||
import { AdminTemplatePackageController } from "../src/modules/admin/admin-template-package.controller.js";
|
||||
import { TenantController } from "../src/modules/tenant/tenant.controller.js";
|
||||
|
||||
const expectedRoutes = new Set([
|
||||
"GET /admin/brands/creation-options",
|
||||
"POST /admin/brands",
|
||||
"GET /admin/brands/members",
|
||||
"POST /admin/brands/members",
|
||||
"PATCH /admin/brands/members/:id",
|
||||
"GET /admin/brands",
|
||||
"POST /admin/brands/:brandId/switch",
|
||||
"GET /admin/workspace",
|
||||
"GET /admin/workspace/preview",
|
||||
"POST /admin/workspace/install",
|
||||
"GET /admin/workspace/template/options",
|
||||
"GET /admin/workspace/template/preview",
|
||||
"POST /admin/workspace/template/upgrade",
|
||||
"POST /admin/workspace/template/rollback",
|
||||
@@ -50,6 +59,7 @@ const expectedRoutes = new Set([
|
||||
|
||||
test("refactored admin controllers preserve their declared API routes", () => {
|
||||
const controllers = [
|
||||
TenantController,
|
||||
AdminWorkspacePreviewController,
|
||||
AdminTemplateController,
|
||||
AdminCapabilityController,
|
||||
|
||||
@@ -137,11 +137,12 @@ test("模板目录只允许平台模板管理员访问,并支持安全、幂
|
||||
const baseline = JSON.parse(empty.body);
|
||||
assert.deepEqual(baseline.items.map((item) => item.packageKey).sort(), [
|
||||
"acheng-campus-food",
|
||||
"atelier-solopreneur",
|
||||
"linjing-editorial",
|
||||
]);
|
||||
const linjingVersion = baseline.items.find((item) => item.packageKey === "linjing-editorial");
|
||||
assert.ok(linjingVersion);
|
||||
assert.equal(linjingVersion.version, "1.0.6");
|
||||
assert.equal(linjingVersion.version, "1.0.7");
|
||||
const linjingPreview = await request(
|
||||
`/admin/templates/${linjingVersion.id}/preview?industry=doors`,
|
||||
{ headers },
|
||||
@@ -380,15 +381,12 @@ test("平台模板管理员可以按行业预览版本,且预览不写入品
|
||||
assert.equal(rejectedImport.statusCode, 400, rejectedImport.body);
|
||||
assert.match(JSON.parse(rejectedImport.body).error.message, /previewFixture/);
|
||||
assert.equal(await prisma.templatePackageVersion.count(), versionCount);
|
||||
const archive = createTemplateArchive("atelier-solopreneur");
|
||||
const multipart = multipartArchive(archive);
|
||||
const imported = await request("/admin/templates/import", {
|
||||
method: "POST",
|
||||
headers: { ...headers, ...multipart.headers },
|
||||
rawPayload: multipart.payload,
|
||||
// 预览只允许使用平台当前已部署的精确 renderer 版本;复用 prepare 阶段导入的基线版本,
|
||||
// 避免测试自造一个 renderer 尚未部署的新版本。
|
||||
const baselineVersion = await prisma.templatePackageVersion.findFirstOrThrow({
|
||||
where: { packageKey: "atelier-solopreneur", version: "1.3.2", status: "published" },
|
||||
});
|
||||
assert.equal(imported.statusCode, 201);
|
||||
const versionId = JSON.parse(imported.body).version.id;
|
||||
const versionId = baselineVersion.id;
|
||||
|
||||
const businessCounts = () =>
|
||||
Promise.all([
|
||||
@@ -625,21 +623,17 @@ test("平台模板管理员可以按行业预览版本,且预览不写入品
|
||||
assert.match(JSON.parse(incompatible.body).error.message, /不支持所选行业/);
|
||||
assert.deepEqual(await businessCounts(), before);
|
||||
|
||||
const repeatedPublish = await request(`/admin/templates/${versionId}/publish`, {
|
||||
method: "POST",
|
||||
headers,
|
||||
});
|
||||
assert.equal(repeatedPublish.statusCode, 201);
|
||||
assert.equal(JSON.parse(repeatedPublish.body).changed, false);
|
||||
const retired = await request(`/admin/templates/${versionId}/retire`, {
|
||||
method: "POST",
|
||||
headers,
|
||||
});
|
||||
assert.equal(retired.statusCode, 409);
|
||||
const published = await request(`/admin/templates/${versionId}/publish`, {
|
||||
method: "POST",
|
||||
headers,
|
||||
});
|
||||
assert.equal(published.statusCode, 201);
|
||||
const retiredAfterPublish = await request(`/admin/templates/${versionId}/retire`, {
|
||||
method: "POST",
|
||||
headers,
|
||||
});
|
||||
assert.equal(retiredAfterPublish.statusCode, 201);
|
||||
assert.equal(retired.statusCode, 201);
|
||||
const retiredPreview = await request(`/admin/templates/${versionId}/preview?industry=personal`, {
|
||||
headers,
|
||||
});
|
||||
@@ -1988,7 +1982,7 @@ test("visual template compatibility is enforced by catalog, preview, and version
|
||||
}
|
||||
assert.deepEqual(
|
||||
visuals.find((visual) => visual.key === "linjing-editorial").supportedIndustryTemplates,
|
||||
["personal", "doors"],
|
||||
["doors"],
|
||||
);
|
||||
const incompatiblePreview = await request(
|
||||
"/public/templates/preview?industry=food&visual=linjing-editorial",
|
||||
@@ -2149,6 +2143,337 @@ test("seeded public workspaces keep personal, food, and doors brands isolated",
|
||||
assert.equal(new Set(workspaces.map((workspace) => workspace.brand.id)).size, 2);
|
||||
});
|
||||
|
||||
test("brand creation options are owner-scoped", async () => {
|
||||
const unauthorized = await request("/admin/brands/creation-options");
|
||||
assert.equal(unauthorized.statusCode, 401);
|
||||
const customerForbidden = await request("/admin/brands/creation-options", {
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
});
|
||||
assert.equal(customerForbidden.statusCode, 403);
|
||||
|
||||
const ownerLogin = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const ownerToken = sessionToken(ownerLogin);
|
||||
const editorUser = await prisma.adminUser.create({
|
||||
data: {
|
||||
username: `creation-options-editor-${randomUUID()}`,
|
||||
passwordHash: "unused",
|
||||
displayName: "建品牌权限测试编辑",
|
||||
mustChangePassword: false,
|
||||
},
|
||||
});
|
||||
const editorMembership = await prisma.brandMembership.create({
|
||||
data: { adminUserId: editorUser.id, brandId, role: "editor" },
|
||||
});
|
||||
try {
|
||||
const editorToken = signIdentity({
|
||||
subject: editorUser.id,
|
||||
brandId,
|
||||
role: "admin",
|
||||
tokenVersion: editorUser.tokenVersion,
|
||||
});
|
||||
const editorForbidden = await request("/admin/brands/creation-options", {
|
||||
headers: { authorization: `Bearer ${editorToken}` },
|
||||
});
|
||||
assert.equal(editorForbidden.statusCode, 403);
|
||||
|
||||
const response = await request("/admin/brands/creation-options", {
|
||||
headers: { authorization: `Bearer ${ownerToken}` },
|
||||
});
|
||||
assert.equal(response.statusCode, 200, response.body);
|
||||
const options = JSON.parse(response.body);
|
||||
assert.deepEqual(options.businesses.map((business) => business.key).sort(), [
|
||||
"doors",
|
||||
"food",
|
||||
"personal",
|
||||
]);
|
||||
assert.ok(options.businesses.every((business) => business.name && business.description));
|
||||
// 创建品牌只暴露每个页面方案的最新版本,避免新品牌起步在旧版本上。
|
||||
assert.equal(options.pageSchemes.length, 3, JSON.stringify(options.pageSchemes));
|
||||
const linjingScheme = options.pageSchemes.find((scheme) => scheme.name.includes("林境"));
|
||||
assert.ok(linjingScheme);
|
||||
assert.equal(linjingScheme.version, "1.0.7");
|
||||
assert.deepEqual(linjingScheme.supportedBusinessTypes, ["doors"]);
|
||||
assert.equal(linjingScheme.isLatestForPackage, true);
|
||||
const atelierScheme = options.pageSchemes.find((scheme) => scheme.name.includes("工坊"));
|
||||
assert.ok(atelierScheme);
|
||||
assert.equal(atelierScheme.version, "1.3.2");
|
||||
assert.deepEqual(atelierScheme.supportedBusinessTypes, ["personal"]);
|
||||
assert.equal(
|
||||
options.pageSchemes.some(
|
||||
(scheme) =>
|
||||
scheme.supportedBusinessTypes.includes("personal") &&
|
||||
scheme.supportedBusinessTypes.includes("doors"),
|
||||
),
|
||||
false,
|
||||
"页面方案不应同时兼容 personal 和 doors",
|
||||
);
|
||||
assert.equal(JSON.stringify(options).includes("visualTemplateKey"), false);
|
||||
assert.equal(JSON.stringify(options).includes("packageKey"), false);
|
||||
} finally {
|
||||
await prisma.brandMembership.delete({ where: { id: editorMembership.id } });
|
||||
await prisma.adminUser.delete({ where: { id: editorUser.id } });
|
||||
}
|
||||
});
|
||||
|
||||
test("owner can create an isolated brand", async () => {
|
||||
const startedAt = new Date();
|
||||
const suffix = randomUUID().slice(0, 8);
|
||||
const personalSlug = `atelier-created-${suffix}`;
|
||||
const doorsSlug = `linjing-created-${suffix}`;
|
||||
// 集成 fixture 必须锁定精确版本,避免导入时间或历史版本影响测试语义。
|
||||
const atelier = await prisma.templatePackageVersion.findFirstOrThrow({
|
||||
where: {
|
||||
packageKey: "atelier-solopreneur",
|
||||
version: "1.3.2",
|
||||
status: "published",
|
||||
},
|
||||
});
|
||||
const linjing = await prisma.templatePackageVersion.findFirstOrThrow({
|
||||
where: {
|
||||
packageKey: "linjing-editorial",
|
||||
version: "1.0.7",
|
||||
status: "published",
|
||||
},
|
||||
});
|
||||
const ownerLogin = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const ownerToken = sessionToken(ownerLogin);
|
||||
const ownerIdentity = readIdentity(ownerToken);
|
||||
const unauthorizedPayload = {
|
||||
name: "未授权品牌",
|
||||
slug: `unauthorized-${suffix}`,
|
||||
businessType: "personal",
|
||||
templatePackageVersionId: atelier.id,
|
||||
};
|
||||
const unauthorized = await request("/admin/brands", {
|
||||
method: "POST",
|
||||
payload: unauthorizedPayload,
|
||||
});
|
||||
assert.equal(unauthorized.statusCode, 401);
|
||||
const customerForbidden = await request("/admin/brands", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
payload: unauthorizedPayload,
|
||||
});
|
||||
assert.equal(customerForbidden.statusCode, 403);
|
||||
const incompatible = await request("/admin/brands", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${ownerToken}` },
|
||||
payload: {
|
||||
name: "不兼容品牌",
|
||||
slug: `incompatible-${suffix}`,
|
||||
businessType: "personal",
|
||||
templatePackageVersionId: linjing.id,
|
||||
},
|
||||
});
|
||||
assert.equal(incompatible.statusCode, 400, incompatible.body);
|
||||
assert.match(errorMessage(incompatible.body), /业务类型|页面方案|兼容/);
|
||||
assert.equal(await prisma.brandProfile.count({ where: { slug: `incompatible-${suffix}` } }), 0);
|
||||
|
||||
try {
|
||||
const created = await request("/admin/brands", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${ownerToken}` },
|
||||
payload: {
|
||||
name: "新建独立工坊",
|
||||
slug: personalSlug,
|
||||
businessType: "personal",
|
||||
templatePackageVersionId: atelier.id,
|
||||
},
|
||||
});
|
||||
assert.equal(created.statusCode, 201, created.body);
|
||||
const createdBrand = JSON.parse(created.body).brand;
|
||||
assert.equal(createdBrand.slug, personalSlug);
|
||||
assert.equal(createdBrand.templateKey, "personal");
|
||||
|
||||
const profile = await prisma.brandProfile.findUniqueOrThrow({
|
||||
where: { id: createdBrand.id },
|
||||
});
|
||||
assert.equal(profile.templateKey, "personal");
|
||||
assert.deepEqual(profile.config, {});
|
||||
const installation = await prisma.brandTemplateInstallation.findUniqueOrThrow({
|
||||
where: { brandId: createdBrand.id },
|
||||
});
|
||||
assert.equal(installation.templateKey, "personal");
|
||||
assert.equal(installation.templatePackageVersionId, atelier.id);
|
||||
assert.equal(installation.templateVersion, atelier.version);
|
||||
assert.ok(
|
||||
(await prisma.brandFieldDefinition.count({ where: { brandId: createdBrand.id } })) > 0,
|
||||
);
|
||||
const membership = await prisma.brandMembership.findUniqueOrThrow({
|
||||
where: {
|
||||
adminUserId_brandId: {
|
||||
adminUserId: ownerIdentity.subject,
|
||||
brandId: createdBrand.id,
|
||||
},
|
||||
},
|
||||
});
|
||||
assert.equal(membership.role, "owner");
|
||||
assert.equal(membership.isEnabled, true);
|
||||
const audit = await prisma.templatePackageAuditLog.findFirstOrThrow({
|
||||
where: {
|
||||
templatePackageVersionId: atelier.id,
|
||||
actorId: ownerIdentity.subject,
|
||||
action: "brand_created",
|
||||
createdAt: { gte: startedAt },
|
||||
},
|
||||
orderBy: { createdAt: "desc" },
|
||||
});
|
||||
assert.equal(audit.metadata.brandId, createdBrand.id);
|
||||
assert.equal(audit.metadata.businessType, "personal");
|
||||
const newCookie = sessionToken(created);
|
||||
assert.equal(readIdentity(newCookie).brandId, createdBrand.id);
|
||||
const current = await request("/admin/config/brand", {
|
||||
headers: { authorization: `Bearer ${newCookie}` },
|
||||
});
|
||||
assert.equal(current.statusCode, 200, current.body);
|
||||
assert.equal(JSON.parse(current.body).id, createdBrand.id);
|
||||
|
||||
const duplicate = await request("/admin/brands", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${ownerToken}` },
|
||||
payload: {
|
||||
name: "重复地址品牌",
|
||||
slug: personalSlug,
|
||||
businessType: "personal",
|
||||
templatePackageVersionId: atelier.id,
|
||||
},
|
||||
});
|
||||
assert.equal(duplicate.statusCode, 409, duplicate.body);
|
||||
assert.equal(await prisma.brandProfile.count({ where: { slug: personalSlug } }), 1);
|
||||
|
||||
const invalidBusinessType = await request("/admin/brands", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${ownerToken}` },
|
||||
payload: {
|
||||
name: "非法业务品牌",
|
||||
slug: `invalid-business-${suffix}`,
|
||||
businessType: "consulting",
|
||||
templatePackageVersionId: atelier.id,
|
||||
},
|
||||
});
|
||||
assert.equal(invalidBusinessType.statusCode, 400);
|
||||
|
||||
const incompatible = await request("/admin/brands", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${ownerToken}` },
|
||||
payload: {
|
||||
name: "不兼容页面方案品牌",
|
||||
slug: `incompatible-${suffix}`,
|
||||
businessType: "personal",
|
||||
templatePackageVersionId: linjing.id,
|
||||
},
|
||||
});
|
||||
assert.equal(incompatible.statusCode, 400, incompatible.body);
|
||||
assert.equal(await prisma.brandProfile.count({ where: { slug: `incompatible-${suffix}` } }), 0);
|
||||
|
||||
const doorsCreated = await request("/admin/brands", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${ownerToken}` },
|
||||
payload: {
|
||||
name: "新建林境门窗",
|
||||
slug: doorsSlug,
|
||||
businessType: "doors",
|
||||
templatePackageVersionId: linjing.id,
|
||||
},
|
||||
});
|
||||
assert.equal(doorsCreated.statusCode, 201, doorsCreated.body);
|
||||
const doorsBrand = JSON.parse(doorsCreated.body).brand;
|
||||
const doorsInstallation = await prisma.brandTemplateInstallation.findUniqueOrThrow({
|
||||
where: { brandId: doorsBrand.id },
|
||||
});
|
||||
assert.equal(doorsInstallation.templateKey, "doors");
|
||||
assert.equal(doorsInstallation.templatePackageVersionId, linjing.id);
|
||||
} finally {
|
||||
await prisma.templatePackageAuditLog.deleteMany({
|
||||
where: {
|
||||
actorId: ownerIdentity.subject,
|
||||
action: "brand_created",
|
||||
createdAt: { gte: startedAt },
|
||||
},
|
||||
});
|
||||
await prisma.brandProfile.deleteMany({
|
||||
where: { slug: { in: [personalSlug, doorsSlug] } },
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test("page scheme options are readable by owners and admins only", async () => {
|
||||
const unauthorized = await request("/admin/workspace/template/options");
|
||||
assert.equal(unauthorized.statusCode, 401);
|
||||
const customerForbidden = await request("/admin/workspace/template/options", {
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
});
|
||||
assert.equal(customerForbidden.statusCode, 403);
|
||||
const ownerLogin = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const ownerToken = sessionToken(ownerLogin);
|
||||
const members = [];
|
||||
|
||||
try {
|
||||
for (const role of ["admin", "editor"]) {
|
||||
const user = await prisma.adminUser.create({
|
||||
data: {
|
||||
username: `page-scheme-${role}-${randomUUID()}`,
|
||||
passwordHash: "unused",
|
||||
displayName: `页面方案${role}测试`,
|
||||
mustChangePassword: false,
|
||||
},
|
||||
});
|
||||
const membership = await prisma.brandMembership.create({
|
||||
data: { adminUserId: user.id, brandId, role },
|
||||
});
|
||||
members.push({ userId: user.id, membershipId: membership.id });
|
||||
const token = signIdentity({
|
||||
subject: user.id,
|
||||
brandId,
|
||||
role: "admin",
|
||||
tokenVersion: user.tokenVersion,
|
||||
});
|
||||
if (role === "admin") {
|
||||
const adminResponse = await request("/admin/workspace/template/options", {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(adminResponse.statusCode, 200, adminResponse.body);
|
||||
const adminOptions = JSON.parse(adminResponse.body);
|
||||
assert.equal(adminOptions.business.key, "food");
|
||||
assert.equal(adminOptions.pageSchemes.length > 0, true);
|
||||
assert.ok(
|
||||
adminOptions.pageSchemes.every((scheme) =>
|
||||
scheme.supportedBusinessTypes.includes("food"),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
const editorForbidden = await request("/admin/workspace/template/options", {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(editorForbidden.statusCode, 403);
|
||||
}
|
||||
}
|
||||
|
||||
const ownerResponse = await request("/admin/workspace/template/options", {
|
||||
headers: { authorization: `Bearer ${ownerToken}` },
|
||||
});
|
||||
assert.equal(ownerResponse.statusCode, 200, ownerResponse.body);
|
||||
const ownerOptions = JSON.parse(ownerResponse.body);
|
||||
assert.equal(ownerOptions.business.key, "food");
|
||||
assert.equal(JSON.stringify(ownerOptions).includes("visualTemplateKey"), false);
|
||||
assert.equal(JSON.stringify(ownerOptions).includes("packageKey"), false);
|
||||
} finally {
|
||||
for (const item of members.reverse()) {
|
||||
await prisma.brandMembership.delete({ where: { id: item.membershipId } });
|
||||
await prisma.adminUser.delete({ where: { id: item.userId } });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("public workspace uses brand-scoped capability installations and preserves status", async () => {
|
||||
await prisma.capabilityInstallation.deleteMany({ where: { brandId } });
|
||||
const installation = await prisma.capabilityInstallation.create({
|
||||
@@ -2281,6 +2606,10 @@ test("editor membership can manage brand content but cannot change system settin
|
||||
payload: { config: { visualTemplateKey: "unknown-visual" } },
|
||||
});
|
||||
assert.equal(visualUpdate.statusCode, 400);
|
||||
const pageSchemePreview = await request("/admin/workspace/template/preview", {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(pageSchemePreview.statusCode, 403);
|
||||
} finally {
|
||||
await prisma.brandMembership.update({
|
||||
where: { id: membership.id },
|
||||
@@ -2887,10 +3216,19 @@ test("template ledger install, upgrade preview, and rollback stay brand-scoped",
|
||||
const initialManifest = structuredClone(installedPackageVersion.manifestSnapshot);
|
||||
initialManifest.version = initialPackageVersion;
|
||||
initialManifest.templateFields = [
|
||||
{ key: "founder", binding: "brand.config.founder", label: "主理人" },
|
||||
{ key: "founder", binding: "brand.config.templateData.founder", label: "主理人" },
|
||||
];
|
||||
initialManifest.assetSlots = [
|
||||
{
|
||||
key: "brand.logo",
|
||||
binding: "brand.avatarUrl",
|
||||
target: "brand",
|
||||
label: "品牌标志",
|
||||
help: "用于品牌身份展示。",
|
||||
required: false,
|
||||
kind: "logo",
|
||||
},
|
||||
];
|
||||
initialManifest.entrypoints = { home: "pages/index/index" };
|
||||
initialManifest.assetSlots = [{ key: "brand.logo", binding: "brand.avatarUrl" }];
|
||||
initialManifest.requiredCapabilities = ["offerings"];
|
||||
const initialPackageVersionRecord = await prisma.templatePackageVersion.create({
|
||||
data: {
|
||||
@@ -2911,9 +3249,20 @@ test("template ledger install, upgrade preview, and rollback stay brand-scoped",
|
||||
const originalConfig =
|
||||
originalBrand.config && typeof originalBrand.config === "object" ? originalBrand.config : {};
|
||||
const existingFounder = "升级前的品牌主理人";
|
||||
const originalTemplateData =
|
||||
originalConfig.templateData &&
|
||||
typeof originalConfig.templateData === "object" &&
|
||||
!Array.isArray(originalConfig.templateData)
|
||||
? originalConfig.templateData
|
||||
: {};
|
||||
await prisma.brandProfile.update({
|
||||
where: { id: brandId },
|
||||
data: { config: { ...originalConfig, founder: existingFounder } },
|
||||
data: {
|
||||
config: {
|
||||
...originalConfig,
|
||||
templateData: { ...originalTemplateData, founder: existingFounder },
|
||||
},
|
||||
},
|
||||
});
|
||||
await prisma.brandTemplateInstallation.update({
|
||||
where: { id: installedRecord.id },
|
||||
@@ -2927,15 +3276,32 @@ test("template ledger install, upgrade preview, and rollback stay brand-scoped",
|
||||
const targetManifest = structuredClone(initialManifest);
|
||||
targetManifest.version = packageVersion;
|
||||
targetManifest.templateFields = [
|
||||
{ key: "founder", binding: "brand.config.founder", label: "品牌主理人" },
|
||||
{ key: "founder", binding: "brand.config.templateData.founder", label: "品牌主理人" },
|
||||
];
|
||||
targetManifest.entrypoints = {
|
||||
...initialManifest.entrypoints,
|
||||
home: "pages/home/index",
|
||||
profile: "pages/profile/index",
|
||||
gallery: "pages/gallery/index",
|
||||
};
|
||||
targetManifest.assetSlots = [
|
||||
{ key: "brand.logo", binding: "brand.avatarUrl" },
|
||||
{ key: "home.hero", binding: "brand.config.heroImage" },
|
||||
{
|
||||
key: "brand.logo",
|
||||
binding: "brand.avatarUrl",
|
||||
target: "brand",
|
||||
label: "品牌标志",
|
||||
help: "用于品牌身份展示。",
|
||||
required: false,
|
||||
kind: "logo",
|
||||
},
|
||||
{
|
||||
key: "home.hero",
|
||||
binding: "brand.config.heroImage",
|
||||
target: "brand",
|
||||
label: "首页主图",
|
||||
help: "用于首页展示品牌重点内容。",
|
||||
required: false,
|
||||
kind: "image",
|
||||
},
|
||||
];
|
||||
targetManifest.requiredCapabilities = [];
|
||||
const packageVersionRecord = await prisma.templatePackageVersion.create({
|
||||
@@ -2962,7 +3328,7 @@ test("template ledger install, upgrade preview, and rollback stay brand-scoped",
|
||||
assert.equal(actionable.targetPackageVersionId, packageVersionRecord.id);
|
||||
assert.equal(actionable.changes.brandFields.available, false);
|
||||
assert.equal(actionable.conflicts.length, 1);
|
||||
assert.equal(actionable.conflicts[0].binding, "brand.config.founder");
|
||||
assert.equal(actionable.conflicts[0].binding, "brand.config.templateData.founder");
|
||||
assert.equal(actionable.changes.pages.added.length, 1);
|
||||
assert.equal(actionable.changes.assets.slots.added.length, 1);
|
||||
assert.deepEqual(actionable.changes.capabilities.removed, ["offerings"]);
|
||||
@@ -3001,7 +3367,9 @@ test("template ledger install, upgrade preview, and rollback stay brand-scoped",
|
||||
expectedCurrentVersion: actionable.currentVersion,
|
||||
expectedCurrentPackageVersionId: actionable.currentPackageVersionId,
|
||||
confirm: true,
|
||||
preservedBindings: [{ key: "founder", binding: "brand.config.founder", action: "preserve" }],
|
||||
preservedBindings: [
|
||||
{ key: "founder", binding: "brand.config.templateData.founder", action: "preserve" },
|
||||
],
|
||||
};
|
||||
const upgradeAttempts = await Promise.all(
|
||||
[0, 1].map(() =>
|
||||
@@ -3020,7 +3388,8 @@ test("template ledger install, upgrade preview, and rollback stay brand-scoped",
|
||||
packageVersionRecord.id,
|
||||
);
|
||||
assert.equal(
|
||||
(await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } })).config.founder,
|
||||
(await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } })).config.templateData
|
||||
.founder,
|
||||
existingFounder,
|
||||
);
|
||||
const retainedOldPackage = await prisma.templatePackageVersion.findUniqueOrThrow({
|
||||
@@ -3391,6 +3760,86 @@ test("selected package version is reflected in public runtime workspace", async
|
||||
assert.equal(body.visualTemplateManifest.key, selectedVersion.manifestSnapshot.visualTemplateKey);
|
||||
});
|
||||
|
||||
test("legacy doors installation preview separates content package and platform renderer versions", async () => {
|
||||
const doorsBrand = await prisma.brandProfile.findUniqueOrThrow({
|
||||
where: { slug: "linjing-doors" },
|
||||
});
|
||||
const adminUser = await prisma.adminUser.findUniqueOrThrow({ where: { username: "admin" } });
|
||||
const installation = await prisma.brandTemplateInstallation.findUniqueOrThrow({
|
||||
where: { brandId: doorsBrand.id },
|
||||
});
|
||||
const currentPackage = await prisma.templatePackageVersion.findFirstOrThrow({
|
||||
where: {
|
||||
packageKey: "linjing-editorial",
|
||||
version: "1.0.7",
|
||||
status: "published",
|
||||
},
|
||||
});
|
||||
// 模拟真实旧安装:内容包锁定 1.0.6,但平台 renderer 已是 1.0.7。
|
||||
const legacyManifest = {
|
||||
...currentPackage.manifestSnapshot,
|
||||
version: "1.0.6",
|
||||
supportedIndustryTemplates: ["personal", "doors"],
|
||||
};
|
||||
const legacyPackage = await prisma.templatePackageVersion.create({
|
||||
data: {
|
||||
templatePackageId: currentPackage.templatePackageId,
|
||||
packageKey: currentPackage.packageKey,
|
||||
version: "1.0.6",
|
||||
displayName: currentPackage.displayName,
|
||||
status: "published",
|
||||
manifestSnapshot: legacyManifest,
|
||||
validationReport: currentPackage.validationReport,
|
||||
contentChecksum: `legacy-${randomUUID()}`,
|
||||
archiveChecksum: `legacy-archive-${randomUUID()}`,
|
||||
artifactPath: currentPackage.artifactPath,
|
||||
importedById: adminUser.id,
|
||||
},
|
||||
});
|
||||
const headers = {
|
||||
authorization: `Bearer ${signIdentity({
|
||||
subject: adminUser.id,
|
||||
brandId: doorsBrand.id,
|
||||
role: "admin",
|
||||
tokenVersion: adminUser.tokenVersion,
|
||||
})}`,
|
||||
};
|
||||
try {
|
||||
await prisma.brandTemplateInstallation.update({
|
||||
where: { brandId: doorsBrand.id },
|
||||
data: {
|
||||
templateVersion: legacyPackage.version,
|
||||
templatePackageVersionId: legacyPackage.id,
|
||||
contentChecksum: legacyPackage.contentChecksum,
|
||||
configSnapshot: legacyPackage.manifestSnapshot,
|
||||
},
|
||||
});
|
||||
|
||||
const previewResponse = await request("/admin/workspace/template/preview", { headers });
|
||||
assert.equal(previewResponse.statusCode, 200, previewResponse.body);
|
||||
const preview = JSON.parse(previewResponse.body);
|
||||
assert.equal(preview.currentVersion, "1.0.6");
|
||||
assert.equal(preview.latestVersion, "1.0.7");
|
||||
assert.equal(preview.canUpgrade, true);
|
||||
assert.equal(preview.targetPackageVersionId, currentPackage.id);
|
||||
assert.equal(preview.changes.renderer.available, true);
|
||||
assert.equal(preview.changes.renderer.source, "platform_visual_manifest");
|
||||
assert.equal(preview.changes.renderer.packageUpgradeChangesRenderer, false);
|
||||
assert.ok(preview.changes.renderer.pages.length > 0);
|
||||
} finally {
|
||||
await prisma.brandTemplateInstallation.update({
|
||||
where: { brandId: doorsBrand.id },
|
||||
data: {
|
||||
templateVersion: installation.templateVersion,
|
||||
templatePackageVersionId: installation.templatePackageVersionId,
|
||||
contentChecksum: installation.contentChecksum,
|
||||
configSnapshot: installation.configSnapshot,
|
||||
},
|
||||
});
|
||||
await prisma.templatePackageVersion.delete({ where: { id: legacyPackage.id } });
|
||||
}
|
||||
});
|
||||
|
||||
test("public workspace exposes declared brand and trust presentation data", async () => {
|
||||
const doorsBrand = await prisma.brandProfile.findUnique({ where: { slug: "linjing-doors" } });
|
||||
assert.ok(doorsBrand);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { test } from "node:test";
|
||||
|
||||
const projectRoot = path.resolve(import.meta.dirname, "../../..");
|
||||
const seedPath = path.join(projectRoot, "apps/api/prisma/seed.ts");
|
||||
const assetDirectory = path.join(projectRoot, "apps/api/prisma/assets");
|
||||
|
||||
test("开发 seed 引用的本地媒体都有随仓库分发的源文件", () => {
|
||||
const seed = readFileSync(seedPath, "utf8");
|
||||
const references = [...seed.matchAll(/["'](\/media\/seed\/[^"']+)["']/g)].map(
|
||||
([, mediaPath]) => mediaPath,
|
||||
);
|
||||
|
||||
assert.ok(references.length > 0, "seed 中没有找到本地媒体引用");
|
||||
for (const mediaPath of new Set(references)) {
|
||||
const filename = path.basename(mediaPath);
|
||||
assert.equal(
|
||||
existsSync(path.join(assetDirectory, filename)),
|
||||
true,
|
||||
`seed 引用的媒体缺少源文件: ${mediaPath}`,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -10,7 +10,7 @@ import { createApp } from "../dist/main.js";
|
||||
import { signIdentity } from "../dist/auth.js";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
const packageKeys = ["acheng-campus-food", "linjing-editorial"];
|
||||
const packageKeys = ["acheng-campus-food", "linjing-editorial", "atelier-solopreneur"];
|
||||
|
||||
function run(command, args, options = {}) {
|
||||
const result = spawnSync(command, args, { stdio: "inherit", ...options });
|
||||
|
||||
@@ -69,6 +69,14 @@ export const ROUTE_COVERAGE: RouteCoverage[] = [
|
||||
authorizationTest: "admin can list and switch only enabled brand memberships",
|
||||
successTest: "admin can list and switch only enabled brand memberships",
|
||||
},
|
||||
{
|
||||
method: "GET",
|
||||
path: "/admin/brands/creation-options",
|
||||
auth: "roles",
|
||||
roles: ["owner"],
|
||||
authorizationTest: "brand creation options are owner-scoped",
|
||||
successTest: "brand creation options are owner-scoped",
|
||||
},
|
||||
{
|
||||
method: "GET",
|
||||
path: "/admin/brands/members",
|
||||
@@ -222,10 +230,19 @@ export const ROUTE_COVERAGE: RouteCoverage[] = [
|
||||
{
|
||||
method: "GET",
|
||||
path: "/admin/workspace/template/preview",
|
||||
auth: "brand",
|
||||
auth: "roles",
|
||||
roles: ["owner", "admin", "platform-admin"],
|
||||
authorizationTest: "template ledger install, upgrade preview, and rollback stay brand-scoped",
|
||||
successTest: "template ledger install, upgrade preview, and rollback stay brand-scoped",
|
||||
},
|
||||
{
|
||||
method: "GET",
|
||||
path: "/admin/workspace/template/options",
|
||||
auth: "roles",
|
||||
roles: ["owner", "admin", "platform-admin"],
|
||||
authorizationTest: "page scheme options are readable by owners and admins only",
|
||||
successTest: "page scheme options are readable by owners and admins only",
|
||||
},
|
||||
{
|
||||
method: "GET",
|
||||
path: "/customer/bookings",
|
||||
@@ -436,6 +453,14 @@ export const ROUTE_COVERAGE: RouteCoverage[] = [
|
||||
authorizationTest: "admin can list and switch only enabled brand memberships",
|
||||
successTest: "admin can list and switch only enabled brand memberships",
|
||||
},
|
||||
{
|
||||
method: "POST",
|
||||
path: "/admin/brands",
|
||||
auth: "roles",
|
||||
roles: ["owner"],
|
||||
authorizationTest: "owner can create an isolated brand",
|
||||
successTest: "owner can create an isolated brand",
|
||||
},
|
||||
{
|
||||
method: "POST",
|
||||
path: "/admin/brands/members",
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
const assert = require("node:assert/strict");
|
||||
const { randomBytes } = require("node:crypto");
|
||||
const { existsSync } = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const { spawnSync } = require("node:child_process");
|
||||
const { PrismaClient } = require("@prisma/client");
|
||||
|
||||
@@ -32,7 +34,47 @@ async function main() {
|
||||
const initialTrustCount = await fixtureDatabase.trustContent.count();
|
||||
const initialFormCount = await fixtureDatabase.inquiryForm.count();
|
||||
const initialReleases = await fixtureDatabase.brandRelease.findMany({ orderBy: { id: "asc" } });
|
||||
// 模拟旧模板遗留数据:数组 config、失效封面和媒体引用。重复 seed 必须修复结构,
|
||||
// 同时保留记录本身和停用状态。
|
||||
const doorsBrand = await fixtureDatabase.brandProfile.findUniqueOrThrow({
|
||||
where: { slug: "linjing-doors" },
|
||||
});
|
||||
const legacyOfferingName = "legacy-offering-repair-fixture";
|
||||
await fixtureDatabase.offering.create({
|
||||
data: {
|
||||
brandId: doorsBrand.id,
|
||||
kind: "service",
|
||||
name: legacyOfferingName,
|
||||
coverUrl: "/media/seed/seed-02.jpg",
|
||||
isEnabled: false,
|
||||
config: [{ url: "/media/seed/seed-02.jpg" }],
|
||||
},
|
||||
});
|
||||
if (run("pnpm", ["db:seed"]) !== 0) return status;
|
||||
const repairedLegacyOffering = await fixtureDatabase.offering.findUniqueOrThrow({
|
||||
where: { brandId_name: { brandId: doorsBrand.id, name: legacyOfferingName } },
|
||||
});
|
||||
assert.equal(
|
||||
Array.isArray(repairedLegacyOffering.config),
|
||||
false,
|
||||
"Repeated seed must repair legacy array config",
|
||||
);
|
||||
assert.ok(
|
||||
repairedLegacyOffering.config &&
|
||||
typeof repairedLegacyOffering.config === "object" &&
|
||||
Array.isArray(repairedLegacyOffering.config.media),
|
||||
"Repeated seed must rebuild legacy media config",
|
||||
);
|
||||
assert.notEqual(
|
||||
repairedLegacyOffering.coverUrl,
|
||||
"/media/seed/seed-02.jpg",
|
||||
"Repeated seed must replace a missing local cover",
|
||||
);
|
||||
assert.equal(
|
||||
repairedLegacyOffering.isEnabled,
|
||||
false,
|
||||
"Repeated seed must preserve disabled offering state",
|
||||
);
|
||||
assert.equal(
|
||||
await fixtureDatabase.trustContent.count(),
|
||||
initialTrustCount,
|
||||
@@ -48,6 +90,32 @@ async function main() {
|
||||
initialReleases,
|
||||
"Repeated seed must preserve release history and snapshots",
|
||||
);
|
||||
const seededOfferings = await fixtureDatabase.offering.findMany({
|
||||
select: { name: true, coverUrl: true, config: true },
|
||||
});
|
||||
assert.ok(seededOfferings.length > 0, "Seed must create offering fixtures");
|
||||
for (const offering of seededOfferings) {
|
||||
assert.ok(
|
||||
offering.config && typeof offering.config === "object" && !Array.isArray(offering.config),
|
||||
`Seed offering config must be an object: ${offering.name}`,
|
||||
);
|
||||
const config = offering.config;
|
||||
const mediaUrls = Array.isArray(config.media)
|
||||
? config.media.flatMap((item) =>
|
||||
item && typeof item === "object" && typeof item.url === "string" ? [item.url] : [],
|
||||
)
|
||||
: [];
|
||||
const localMedia = [offering.coverUrl, ...mediaUrls].filter(
|
||||
(url) => typeof url === "string" && url.startsWith("/media/seed/"),
|
||||
);
|
||||
for (const mediaPath of new Set(localMedia)) {
|
||||
assert.equal(
|
||||
existsSync(path.join(__dirname, "prisma/assets", path.basename(mediaPath))),
|
||||
true,
|
||||
`Seed offering references missing media: ${offering.name} -> ${mediaPath}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
await fixtureDatabase.adminUser.updateMany({
|
||||
where: { username: "admin" },
|
||||
data: { mustChangePassword: false },
|
||||
|
||||
@@ -45,7 +45,7 @@ async function main() {
|
||||
.filter((entry) => entry.isDirectory() && entry.name !== targetMigration)
|
||||
.map((entry) => entry.name)
|
||||
.sort();
|
||||
assert.equal(migrationDirs.at(-1), "20261018180000_add_customer_token_version");
|
||||
assert.equal(migrationDirs.at(-1), "20261019100000_remove_brand_profile_defaults");
|
||||
await admin.$executeRawUnsafe(`CREATE SCHEMA "${schema}"`);
|
||||
createdSchema = true;
|
||||
|
||||
|
||||
@@ -180,8 +180,8 @@ test("template preview matrix keeps every deployed package, industry, and versio
|
||||
}
|
||||
}
|
||||
}
|
||||
// 3 个包 x 支持行业(1 + 1 + 2)x 2 个版本 = 8 个隔离模拟品牌。
|
||||
assert.equal(visibleBrands.size, 8);
|
||||
// 3 个包 × 每个包一个支持行业 × 2 个版本 = 6 个隔离模拟品牌。
|
||||
assert.equal(visibleBrands.size, 6);
|
||||
} finally {
|
||||
for (const fixture of fixtures) rmSync(fixture.root, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { compareTemplateVersions, latestTemplateVersion } from "../src/template-version-order.js";
|
||||
|
||||
test("模板版本按 SemVer 而不是导入时间判断最新版", () => {
|
||||
const importedLaterOldVersion = {
|
||||
version: "1.9.0",
|
||||
importedAt: new Date("2026-10-20T00:00:00Z"),
|
||||
};
|
||||
const importedEarlierNewVersion = {
|
||||
version: "1.10.0",
|
||||
importedAt: new Date("2026-10-19T00:00:00Z"),
|
||||
};
|
||||
assert.equal(
|
||||
latestTemplateVersion([importedEarlierNewVersion, importedLaterOldVersion])?.version,
|
||||
"1.10.0",
|
||||
);
|
||||
assert.ok(compareTemplateVersions("1.10.0", "1.9.0") > 0);
|
||||
});
|
||||
|
||||
test("模板版本排序正确处理预发布版本和同版本稳定性", () => {
|
||||
assert.ok(compareTemplateVersions("1.0.0", "1.0.0-beta.2") > 0);
|
||||
assert.ok(compareTemplateVersions("1.0.0-beta.10", "1.0.0-beta.2") > 0);
|
||||
const first = {
|
||||
version: "1.0.0",
|
||||
importedAt: new Date("2026-10-19T00:00:00Z"),
|
||||
};
|
||||
const second = {
|
||||
version: "1.0.0",
|
||||
importedAt: new Date("2026-10-20T00:00:00Z"),
|
||||
};
|
||||
assert.equal(latestTemplateVersion([first, second]), second);
|
||||
});
|
||||
@@ -657,13 +657,13 @@ test("林境模板支持首页和主理人区域点选", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1600, height: 900 });
|
||||
const editorialBrand = {
|
||||
...structuredClone(brand),
|
||||
templateKey: "personal",
|
||||
avatarUrl: "/assets/acheng-campus-food/owner/portrait.jpg",
|
||||
templateKey: "doors",
|
||||
avatarUrl: "/template-preview/assets/linjing-editorial/content/founder-portrait.jpg",
|
||||
config: {
|
||||
visualTemplateKey: "linjing-editorial",
|
||||
founder: "林境主理人",
|
||||
title: "建筑设计师",
|
||||
heroImage: "/assets/acheng-campus-food/owner/portrait.jpg",
|
||||
title: "门系统设计师",
|
||||
heroImage: "/template-preview/assets/linjing-editorial/content/entry-door.jpg",
|
||||
homeHero: { title: "林境作品" },
|
||||
visualPresentation: {
|
||||
home: {
|
||||
@@ -697,13 +697,13 @@ test("林境模板支持首页和主理人区域点选", async ({ page }) => {
|
||||
...editorialBrand,
|
||||
...editorialBrand.config,
|
||||
founder: "林境主理人",
|
||||
title: "建筑设计师",
|
||||
heroImage: "/assets/acheng-campus-food/owner/portrait.jpg",
|
||||
title: "门系统设计师",
|
||||
heroImage: "/template-preview/assets/linjing-editorial/content/entry-door.jpg",
|
||||
homeHero: { title: "林境作品" },
|
||||
},
|
||||
offerings: structuredClone(runtimeWorkspace.offerings).map((item) => ({
|
||||
...item,
|
||||
coverUrl: "/assets/acheng-campus-food/owner/portrait.jpg",
|
||||
coverUrl: "/template-preview/assets/linjing-editorial/content/entry-door.jpg",
|
||||
})),
|
||||
trustItems: [
|
||||
{
|
||||
@@ -800,9 +800,9 @@ test("林境模板支持首页和主理人区域点选", async ({ page }) => {
|
||||
}
|
||||
if (path === "/admin/config/trust-content")
|
||||
return route.fulfill({ json: editorialWorkspace.trustItems });
|
||||
if (path === "/public/templates/personal")
|
||||
if (path === "/public/templates/doors")
|
||||
return route.fulfill({
|
||||
json: { name: "个人品牌", description: "林境模板", serviceCategories: [] },
|
||||
json: { name: "门窗业务", description: "林境页面方案", serviceCategories: [] },
|
||||
});
|
||||
if (path === "/admin/workspace")
|
||||
return route.fulfill({
|
||||
|
||||
@@ -52,7 +52,6 @@ type MediaCase = {
|
||||
const mediaCases: MediaCase[] = [
|
||||
{ packageKey: "acheng-campus-food", industry: "food", founder: "阿成" },
|
||||
{ packageKey: "atelier-solopreneur", industry: "personal", founder: "林予 · 示例主理人" },
|
||||
{ packageKey: "linjing-editorial", industry: "personal", founder: "示例主理人" },
|
||||
{ packageKey: "linjing-editorial", industry: "doors", founder: "林叙安 (Lin XUAN)" },
|
||||
];
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
{
|
||||
"packageKey": "linjing-editorial",
|
||||
"packageName": "@personal-brand/template-linjing-editorial",
|
||||
"version": "1.0.6"
|
||||
"version": "1.0.7"
|
||||
},
|
||||
{
|
||||
"packageKey": "atelier-solopreneur",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
## Decision
|
||||
|
||||
在视觉模板 definition 与 manifest 中增加 `supportedIndustryTemplates`。目录、组合预览和实际切换均通过共享 `isVisualTemplateCompatible` 校验。当前林境模板支持 `personal`、`doors`;极简模板支持 `personal`、`food`、`doors`。
|
||||
在视觉模板 definition 与 manifest 中增加 `supportedIndustryTemplates`。目录、组合预览和实际切换均通过共享 `isVisualTemplateCompatible` 校验。当前林境模板只支持 `doors`;极简模板支持 `personal`、`food`、`doors`。
|
||||
|
||||
## Alternatives
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
### 2. 后台页面按「日常经营」与「模板治理」拆开
|
||||
|
||||
- `咨询表单与字段`(`/admin/workspace`)只负责咨询入口表单与高级自定义字段,归入「日常经营」,不再承载任何模板、视觉或组合预览。
|
||||
- 模板治理归入「配置与发布 → 内容发布」的「选择表达方式」:行业模板只读展示、视觉模板选择、模板版本升级与回滚。视觉模板是行业模板的排版变体,不是新的行业身份。
|
||||
- 页面方案治理归入独立的「页面方案」页面:业务类型只读展示,页面方案版本可升级、切换和恢复。页面方案是业务类型的排版变体,不是新的行业身份。
|
||||
- 「内容与发布」只处理内容检查、发布、撤回、小程序发布和配置,不再承载业务类型或页面方案选择。
|
||||
|
||||
## 替代方案
|
||||
|
||||
@@ -33,8 +34,8 @@
|
||||
|
||||
- 品牌身份、模板台账、发布快照三者不会再互相漂移;公开运行时始终跑品牌当前的行业模板。
|
||||
- 行业模板不可在后台切换,切换到另一行业需要显式的产品与迁移方案。
|
||||
- 视觉模板切换历史/回滚、模板组合预览从 UI 中移除。当前每个行业实际只适配一个视觉模板,这两块属于不可达的死 UI。
|
||||
- 后台的模板治理不再是 owner 专属的高深设置,而是和发布放在同一处。
|
||||
- 本 ADR 采纳时移除了视觉模板切换历史/回滚和组合预览;后续由 [ADR 0033](0033-brand-business-type-and-page-scheme-separation.md) 将页面方案版本升级、切换和恢复迁入独立「页面方案」页面。
|
||||
- 后台的模板治理不再由内容发布页承载;当前边界以 ADR 0033 为准。
|
||||
|
||||
## 迁移计划
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# 0033 品牌业务类型与页面方案分离
|
||||
|
||||
- 状态:已采纳
|
||||
- 日期:2026-10-20
|
||||
|
||||
## Context
|
||||
|
||||
品牌创建、页面方案选择和内容发布此前共用「行业模板」「视觉模板」「选择表达方式」等内部概念。运营者无法判断哪个选择决定字段与能力,哪个选择只影响页面结构和视觉,也容易把页面方案切换误解为业务类型切换。林境画册还同时出现在 `personal` 与 `doors` 兼容矩阵中,导致个人品牌模板与门窗模板的身份边界失效。
|
||||
|
||||
## Decision
|
||||
|
||||
1. **业务类型是品牌身份**
|
||||
- 业务类型决定字段、能力、业务提供项 schema 和咨询表单语义。
|
||||
- 业务类型在创建品牌时确定,创建后不可修改。
|
||||
- 创建品牌必须显式选择业务类型和一个与它兼容的已发布页面方案。
|
||||
|
||||
2. **页面方案是结构和视觉版本**
|
||||
- 页面方案决定页面清单、模块结构、视觉资源槽位和版本。
|
||||
- 页面方案可以升级、切换到同一业务类型的其他已发布版本,并恢复上一版配置基线。
|
||||
- 页面方案切换不改变品牌业务类型,不删除品牌内容、业务提供项或咨询记录。
|
||||
|
||||
3. **创建流程不导入示例内容**
|
||||
- 创建品牌只建立品牌身份、成员关系、字段定义和页面方案安装记录。
|
||||
- 示例内容只能由管理员在「页面方案 → 高级」中显式预览并确认导入,且只补齐缺失内容。
|
||||
|
||||
4. **兼容矩阵由模板包声明**
|
||||
- `linjing-editorial` 只支持 `doors`,不得在页面方案目录、创建品牌页、预览或 API 中把它与 `personal` 组合。
|
||||
- `personal` 只展示 `atelier-solopreneur`;`food` 只展示 `acheng-campus-food`。
|
||||
|
||||
5. **内部模板键不对运营用户暴露**
|
||||
- Admin 页面不展示 `packageKey`、`visualTemplateKey`、`renderer` 等内部名称。
|
||||
- 页面使用「业务类型」「页面方案」「版本」等用户语义;API 仍以稳定 key 作为边界校验值。
|
||||
|
||||
## Alternatives
|
||||
|
||||
- 继续用一个「表达方式」控件同时选择业务类型和页面方案:运营者无法理解不可变与可升级的差异,拒绝。
|
||||
- 允许创建后修改业务类型:会造成字段、内容、能力与发布快照漂移,需要跨行业迁移方案,当前不支持。
|
||||
- 创建品牌时自动导入示例内容:会把演示文案误认为真实品牌资料,并让空品牌与演示品牌无法区分,拒绝。
|
||||
- 继续让林境兼容 `personal`:与专属个人品牌模板职责重叠,且林境页面和 sample 内容面向门窗业务,拒绝。
|
||||
|
||||
## Consequences
|
||||
|
||||
- 创建品牌多了一步「选择页面方案」,但业务类型的不可变边界变得明确。
|
||||
- 页面方案升级与业务类型稳定解耦,发布流程不再承载模板治理。
|
||||
- 林境不再出现在 `personal` 组合中;旧的不兼容数据必须通过显式迁移或人工修复,不做运行时兜底。
|
||||
- 页面方案的版本切换和配置恢复需要保持幂等、授权校验和内容冲突提示。
|
||||
|
||||
## Migration
|
||||
|
||||
- 新增 owner-only 的 `GET /admin/brands/creation-options` 与 `POST /admin/brands`,创建时校验业务类型、页面方案兼容性和版本发布状态。
|
||||
- 新增 `GET /admin/workspace/template/options`,供 owner/admin/platform-admin 读取当前品牌的业务类型和兼容页面方案。
|
||||
- Admin 新增「创建品牌」与「页面方案」页面;「内容与发布」移除业务类型和页面方案选择。
|
||||
- `linjing-editorial` 升至 `1.0.7`,兼容矩阵收窄为仅 `doors`;同步更新 package、manifest、registry 和测试 fixture。
|
||||
- 已有品牌保留当前业务类型和页面方案版本;不兼容组合不做静默改写,升级或迁移必须显式执行。
|
||||
@@ -444,7 +444,7 @@ Phase 3 现场验收纠偏(2026-10-16):
|
||||
- atelier 独立 fixture 也没有头像。已升为 `atelier-solopreneur@1.3.0`,在 `previewFixture.personal.brand` 中加入包内头像,继续保持预览数据与 bootstrap sample 分离。
|
||||
- 修复 Admin 导入包预览中 food renderer 的资源 key 前缀映射:包内 `/assets/service/*.png` 等图标现在可从 archive 校验后的 data URL 渲染,不回退到本地部署资源。
|
||||
- 矩阵 API 回归新增断言:每个支持行业的主理人身份非空、头像指向包内资源、所有 asset slot 都是 `ready`、没有诊断。
|
||||
- 新增 Playwright 媒体矩阵:覆盖 `acheng/food`、`atelier/personal`、`linjing/personal`、`linjing/doors`,使用真实 `template:pack` 产物和 API preview service;验证失败重试、founder 可见、所有 `data:` 图像 `naturalWidth > 0`、无“内容缺失”、无真实写入请求。四张截图已人工检查。
|
||||
- 新增 Playwright 媒体矩阵:覆盖 `acheng/food`、`atelier/personal`、`linjing/doors`,使用真实 `template:pack` 产物和 API preview service;验证失败重试、founder 可见、所有 `data:` 图像 `naturalWidth > 0`、无“内容缺失”、无真实写入请求。四张截图已人工检查。
|
||||
- 本轮本地目录以最新已发布版本为准:`acheng-campus-food@1.0.1`、`atelier-solopreneur@1.3.0`、`linjing-editorial@1.0.3`;被取代的旧演示版本进入 retired。
|
||||
|
||||
Phase 3 隔离、导航和矩阵收口(2026-10-16):
|
||||
@@ -452,7 +452,7 @@ Phase 3 隔离、导航和矩阵收口(2026-10-16):
|
||||
- Admin dev/preview 响应增加 CSP、`Referrer-Policy: no-referrer` 和 `X-Content-Type-Options: nosniff`。preview/生产 CSP 为 `default-src 'self'`、`script-src 'self'`、`object-src 'none'`、`base-uri 'none'`、`frame-ancestors 'self'`、`form-action 'self'`;图片和媒体允许 `self/data/blob` 以读取通过 checksum 校验的包内资源,样式保留 `unsafe-inline` 以支持现有 React UI。生产构建同时保留 CSP meta 作为静态托管防线。
|
||||
- Vite dev 为 React refresh preamble 单独允许 inline script;这是开发服务器例外,不是 preview/生产契约。Playwright 校验响应中存在 CSP 的 `default-src 'self'`、包内资源所需的 `img-src data:` 和 `frame-ancestors 'self'`。
|
||||
- Admin 画布监听 Taro web preview runtime 发出的导航事件,把 renderer 内真实 CTA 转成画布内切换;`detail` 路由同步选择对应 offering。Playwright 覆盖“首页案例 -> 详情 CTA -> 禁止提交的咨询表单”。
|
||||
- 新增真实包矩阵回归:`acheng-campus-food/food`、`atelier-solopreneur/personal`、`linjing-editorial/{personal,doors}`,每个组合各 2 个版本,共 8 个模拟品牌。测试校验行业兼容、Runtime/renderer 声明、模拟品牌 ID、包内资源逐项 checksum、禁用提交和跨版本隔离。
|
||||
- 新增真实包矩阵回归:`acheng-campus-food/food`、`atelier-solopreneur/personal`、`linjing-editorial/doors`,每个组合各 2 个版本,共 6 个模拟品牌。测试校验行业兼容、Runtime/renderer 声明、模拟品牌 ID、包内资源逐项 checksum、禁用提交和跨版本隔离。
|
||||
- 矩阵回归发现 linjing doors 起始内容声明了未注册 capability `doors`。已将其修正为 `inquiry`,模板包升为 `linjing-editorial@1.0.1`,生成目录、release build 配置和模板注册表同步更新;旧 `1.0.0` 不在本轮改写。
|
||||
- Playwright 支持通过 `TEMPLATE_PREVIEW_VISUAL_EVIDENCE` 输出 `home/detail/inquiry/profile` 截图。本轮已生成并人工检查:独立 fixture 身份、包内图片、详情 CTA、咨询禁用和我的页面正常。该证据覆盖本地 Admin/H5 预览,不替代微信真机视觉验收或审核上传。
|
||||
- 本轮回归:API HTTP integration `52/52`、upload `2/2`、API unit `52/52`、Client `6/6`、Admin unit `6/6`、Playwright `1/1`;全仓 typecheck、变更范围 ESLint、format、Admin production build 和 `template:check` 通过。全仓 `pnpm lint` 仍有先前记录的 Admin 既有 error,非本轮阻塞。
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
### 仓库内视觉模板包
|
||||
|
||||
- acheng-campus-food@1.0.3:餐饮场景,使用 food 行业能力。
|
||||
- linjing-editorial@1.0.4:林境建筑画册,可用于 doors 和 personal 组合。
|
||||
- linjing-editorial@1.0.7:林境建筑画册,仅适配 doors 业务类型。
|
||||
- atelier-solopreneur@1.3.2:独立工坊方向,适配 personal 行业。
|
||||
|
||||
以上是仓库盘点,不表示三个包都已经通过线上导入、预览、品牌安装和微信上传验收。生成目录当前位于 packages/config/src/generated-template-packages.ts,后续必须由导出和 conformance 流程生成并校验。
|
||||
|
||||
@@ -11,10 +11,15 @@ export type {
|
||||
export type {
|
||||
AdminBrandMember,
|
||||
AdminBrandMembership,
|
||||
BrandCreationOptions,
|
||||
BrandCreationOptionBusiness,
|
||||
BrandCreationOptionPageScheme,
|
||||
BrandPageSchemeOptions,
|
||||
BrandPresentationUpdate,
|
||||
BrandProfile,
|
||||
BrandReleaseSummary,
|
||||
BrandUpdate,
|
||||
CreateBrandInput,
|
||||
} from "./types/brand.js";
|
||||
export type { MiniAppReleaseSettings, MiniAppReleaseTask } from "./types/brand.js";
|
||||
export type { CapabilityInstallation } from "./types/capability.js";
|
||||
@@ -192,6 +197,11 @@ export class ApiClient
|
||||
this.resources.brand.getAdminBrand(...arguments_);
|
||||
listAdminBrands = (...arguments_: Parameters<BrandMethods["listAdminBrands"]>) =>
|
||||
this.resources.brand.listAdminBrands(...arguments_);
|
||||
getAdminBrandCreationOptions = (
|
||||
...arguments_: Parameters<BrandMethods["getAdminBrandCreationOptions"]>
|
||||
) => this.resources.brand.getAdminBrandCreationOptions(...arguments_);
|
||||
createAdminBrand = (...arguments_: Parameters<BrandMethods["createAdminBrand"]>) =>
|
||||
this.resources.brand.createAdminBrand(...arguments_);
|
||||
switchAdminBrand = (...arguments_: Parameters<BrandMethods["switchAdminBrand"]>) =>
|
||||
this.resources.brand.switchAdminBrand(...arguments_);
|
||||
listAdminMembers = (...arguments_: Parameters<BrandMethods["listAdminMembers"]>) =>
|
||||
@@ -291,6 +301,9 @@ export class ApiClient
|
||||
getAdminTemplateOperationFailures = (
|
||||
...arguments_: Parameters<TemplateMethods["getAdminTemplateOperationFailures"]>
|
||||
) => this.resources.template.getAdminTemplateOperationFailures(...arguments_);
|
||||
getAdminPageSchemeOptions = (
|
||||
...arguments_: Parameters<TemplateMethods["getAdminPageSchemeOptions"]>
|
||||
) => this.resources.template.getAdminPageSchemeOptions(...arguments_);
|
||||
getPublicOffering = (...arguments_: Parameters<OfferingMethods["getPublicOffering"]>) =>
|
||||
this.resources.offering.getPublicOffering(...arguments_);
|
||||
listPublicOfferings = (...arguments_: Parameters<OfferingMethods["listPublicOfferings"]>) =>
|
||||
|
||||
@@ -2,9 +2,11 @@ import type { RequestFn } from "../client/request.js";
|
||||
import type {
|
||||
AdminBrandMember,
|
||||
AdminBrandMembership,
|
||||
BrandCreationOptions,
|
||||
BrandPresentationUpdate,
|
||||
BrandProfile,
|
||||
BrandReleaseSummary,
|
||||
CreateBrandInput,
|
||||
MiniAppReleaseTask,
|
||||
MiniAppReleaseSettings,
|
||||
BrandUpdate,
|
||||
@@ -13,6 +15,11 @@ import type {
|
||||
export interface BrandMethods {
|
||||
getAdminBrand(): Promise<BrandProfile>;
|
||||
listAdminBrands(): Promise<AdminBrandMembership[]>;
|
||||
getAdminBrandCreationOptions(): Promise<BrandCreationOptions>;
|
||||
createAdminBrand(body: CreateBrandInput): Promise<{
|
||||
role: string;
|
||||
brand: AdminBrandMembership["brand"];
|
||||
}>;
|
||||
switchAdminBrand(
|
||||
brandId: string,
|
||||
): Promise<{ role: string; brand: AdminBrandMembership["brand"] }>;
|
||||
@@ -74,6 +81,8 @@ export function brandMethods({ request }: { request: RequestFn }): BrandMethods
|
||||
return {
|
||||
getAdminBrand: () => request("/admin/config/brand"),
|
||||
listAdminBrands: () => request("/admin/brands"),
|
||||
getAdminBrandCreationOptions: () => request("/admin/brands/creation-options"),
|
||||
createAdminBrand: (body) => request("/admin/brands", { method: "POST", body }),
|
||||
switchAdminBrand: (brandId) =>
|
||||
request(`/admin/brands/${encodeURIComponent(brandId)}/switch`, { method: "POST" }),
|
||||
listAdminMembers: () => request("/admin/brands/members"),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { BrandTemplateKey, RuntimeWorkspace } from "@personal-brand/types";
|
||||
import type { RequestFn } from "../client/request.js";
|
||||
import type { BrandProfile } from "../types/brand.js";
|
||||
import type { BrandPageSchemeOptions, BrandProfile } from "../types/brand.js";
|
||||
import type { CapabilityWithMetadata } from "../types/capability.js";
|
||||
import type { BrandFieldDefinition } from "../types/field.js";
|
||||
import type { Offering } from "../types/offering.js";
|
||||
@@ -8,6 +8,7 @@ import type { AdminTemplateContent } from "../types/template.js";
|
||||
import type { BrandTemplateDefinition } from "../types/template-definition.js";
|
||||
|
||||
export interface TemplateMethods {
|
||||
getAdminPageSchemeOptions(): Promise<BrandPageSchemeOptions>;
|
||||
listAdminTemplatePackages(params?: {
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
@@ -310,6 +311,7 @@ export interface TemplatePackageImportResult {
|
||||
|
||||
export function templateMethods({ request }: { request: RequestFn }): TemplateMethods {
|
||||
return {
|
||||
getAdminPageSchemeOptions: () => request("/admin/workspace/template/options"),
|
||||
listAdminTemplatePackages: (params = {}) => {
|
||||
const query = [
|
||||
params.page === undefined ? null : `page=${encodeURIComponent(String(params.page))}`,
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { BrandTemplateKey } from "@personal-brand/types";
|
||||
|
||||
export interface BrandProfile {
|
||||
id: string;
|
||||
slug?: string;
|
||||
slug: string;
|
||||
name: string;
|
||||
templateKey: BrandTemplateKey;
|
||||
tagline: string | null;
|
||||
@@ -20,7 +20,39 @@ export interface BrandProfile {
|
||||
export interface AdminBrandMembership {
|
||||
id: string;
|
||||
role: string;
|
||||
brand: Pick<BrandProfile, "id" | "name" | "templateKey"> & { slug?: string };
|
||||
brand: Pick<BrandProfile, "id" | "name" | "templateKey" | "slug">;
|
||||
}
|
||||
|
||||
export interface BrandCreationOptionBusiness {
|
||||
key: BrandTemplateKey;
|
||||
name: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface BrandCreationOptionPageScheme {
|
||||
templatePackageVersionId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
version: string;
|
||||
supportedBusinessTypes: BrandTemplateKey[];
|
||||
isLatestForPackage: boolean;
|
||||
}
|
||||
|
||||
export interface BrandCreationOptions {
|
||||
businesses: BrandCreationOptionBusiness[];
|
||||
pageSchemes: BrandCreationOptionPageScheme[];
|
||||
}
|
||||
|
||||
export interface BrandPageSchemeOptions {
|
||||
business: BrandCreationOptionBusiness;
|
||||
pageSchemes: BrandCreationOptionPageScheme[];
|
||||
}
|
||||
|
||||
export interface CreateBrandInput {
|
||||
name: string;
|
||||
slug: string;
|
||||
businessType: BrandTemplateKey;
|
||||
templatePackageVersionId: string;
|
||||
}
|
||||
|
||||
export interface AdminBrandMember {
|
||||
|
||||
@@ -101,6 +101,40 @@ test("品牌切换客户端不再接收 token", async () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test("创建品牌与品牌内页面方案选项使用各自授权接口", async () => {
|
||||
const calls: Array<{ url: string; method?: string; body?: string }> = [];
|
||||
const client = new ApiClient({
|
||||
baseUrl: "http://api.test",
|
||||
token: "owner-token",
|
||||
fetcher: async (url, init) => {
|
||||
calls.push({ url, method: init?.method, body: init?.body });
|
||||
return response({});
|
||||
},
|
||||
});
|
||||
await client.getAdminBrandCreationOptions();
|
||||
await client.createAdminBrand({
|
||||
name: "林境门窗",
|
||||
slug: "linjing-windows",
|
||||
businessType: "doors",
|
||||
templatePackageVersionId: "version-1",
|
||||
});
|
||||
await client.getAdminPageSchemeOptions();
|
||||
assert.deepEqual(calls, [
|
||||
{ url: "http://api.test/admin/brands/creation-options", method: "GET", body: undefined },
|
||||
{
|
||||
url: "http://api.test/admin/brands",
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
name: "林境门窗",
|
||||
slug: "linjing-windows",
|
||||
businessType: "doors",
|
||||
templatePackageVersionId: "version-1",
|
||||
}),
|
||||
},
|
||||
{ url: "http://api.test/admin/workspace/template/options", method: "GET", body: undefined },
|
||||
]);
|
||||
});
|
||||
|
||||
test("客户端将统一错误响应转换为 ApiClientError", async () => {
|
||||
const client = new ApiClient({
|
||||
baseUrl: "http://api.test",
|
||||
@@ -206,7 +240,7 @@ test("模板目录客户端发送分页并支持版本发布和审计", async ()
|
||||
]);
|
||||
});
|
||||
|
||||
test("模板升级和回滚提交预览版本、checksum 与逐项保留确认", async () => {
|
||||
test("模板升级和回滚提交预览版本、checksum 与全部保留确认", async () => {
|
||||
const calls: Array<{ url: string; method?: string; body?: string }> = [];
|
||||
const client = new ApiClient({
|
||||
baseUrl: "http://api.test",
|
||||
|
||||
@@ -4417,12 +4417,11 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
},
|
||||
{
|
||||
"packageKey": "linjing-editorial",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.7",
|
||||
"displayName": "林境建筑画册",
|
||||
"defaultBrandSlug": "linjing-doors",
|
||||
"runtimeContract": "1.0",
|
||||
"supportedIndustryTemplates": [
|
||||
"personal",
|
||||
"doors"
|
||||
],
|
||||
"entrypoints": {
|
||||
@@ -5765,7 +5764,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
"name": "序章·入户门",
|
||||
"summary": "为别墅入口定制的整樘门系统",
|
||||
"categoryKey": "entrance-door",
|
||||
"coverUrl": "/assets/content/doors-hero.jpg",
|
||||
"coverUrl": "/assets/content/entry-door.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「万籁」重型天地轴入户系统",
|
||||
@@ -5784,7 +5783,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/doors-hero.jpg",
|
||||
"url": "/assets/content/entry-door.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -5796,7 +5795,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
"name": "庭院·边界门",
|
||||
"summary": "连接建筑与庭院的定制门",
|
||||
"categoryKey": "garden-door",
|
||||
"coverUrl": "/assets/content/doors-yard-gate.jpg",
|
||||
"coverUrl": "/assets/content/courtyard-gate.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「虚实」透光私家庭院门",
|
||||
@@ -5815,7 +5814,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/doors-yard-gate.jpg",
|
||||
"url": "/assets/content/courtyard-gate.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -5827,7 +5826,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
"name": "室内·静谧门",
|
||||
"summary": "统一室内空间秩序的户内门",
|
||||
"categoryKey": "interior-door",
|
||||
"coverUrl": "/assets/content/doors-room-door.jpg",
|
||||
"coverUrl": "/assets/content/interior-door.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「空灵」2.8m - 3.2m 满高通顶系统",
|
||||
@@ -5846,7 +5845,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/doors-room-door.jpg",
|
||||
"url": "/assets/content/interior-door.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -5858,7 +5857,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
"name": "一对一门系统设计咨询",
|
||||
"summary": "从现场到方案的完整设计沟通",
|
||||
"categoryKey": "custom",
|
||||
"coverUrl": "/assets/content/personal-consulting.jpg",
|
||||
"coverUrl": "/assets/content/design-consultation.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「无垠」密室及背景墙融合门",
|
||||
@@ -5877,7 +5876,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/personal-consulting.jpg",
|
||||
"url": "/assets/content/design-consultation.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -6100,8 +6099,8 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
"phone": "186-0218-9908",
|
||||
"wechat": "LIN-ATELIER-2024",
|
||||
"studioAddress": "上海市静安区威海路设计中心 A 座 / 杭州良渚研造工坊",
|
||||
"avatarUrl": "/assets/content/personal-avatar.jpg",
|
||||
"heroImage": "/assets/content/doors-hero.jpg",
|
||||
"avatarUrl": "/assets/content/founder-portrait.jpg",
|
||||
"heroImage": "/assets/content/entry-door.jpg",
|
||||
"visualPresentation": {
|
||||
"home": {
|
||||
"founderBadge": "接受项目沟通",
|
||||
@@ -6181,151 +6180,6 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"personal": {
|
||||
"templateKey": "personal",
|
||||
"inquiryFormName": "合作咨询表单",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "示例·品牌定位咨询",
|
||||
"summary": "梳理品牌定位与下一步行动。",
|
||||
"categoryKey": "consulting",
|
||||
"coverUrl": "/assets/content/personal-consulting.jpg",
|
||||
"priceText": "按需求确认",
|
||||
"config": {
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/personal-consulting.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "示例·长期顾问支持",
|
||||
"summary": "围绕表达和转化提供持续支持。",
|
||||
"categoryKey": "advisory",
|
||||
"coverUrl": "/assets/content/personal-advisory.jpg",
|
||||
"priceText": "按服务周期确认",
|
||||
"config": {
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/personal-advisory.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"trustContent": [
|
||||
{
|
||||
"type": "credential",
|
||||
"title": "关于主理人",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
},
|
||||
{
|
||||
"type": "process",
|
||||
"title": "合作方法",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
}
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"key": "name",
|
||||
"label": "您的称呼",
|
||||
"type": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "phone",
|
||||
"label": "联系方式",
|
||||
"type": "phone",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "remark",
|
||||
"label": "合作需求",
|
||||
"type": "textarea",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"capabilityKey": "inquiry",
|
||||
"brandConfig": {
|
||||
"templateData": {
|
||||
"designPhilosophy": "先厘清问题,再设计表达"
|
||||
},
|
||||
"title": "品牌策略顾问",
|
||||
"slogan": "用清晰的定位与可执行的表达,让专业被看见。",
|
||||
"phone": "",
|
||||
"wechat": "",
|
||||
"studioAddress": "上海市徐汇区创意园区",
|
||||
"avatarUrl": "/assets/content/personal-avatar.jpg",
|
||||
"heroImage": "/assets/content/personal-consulting.jpg",
|
||||
"visualPresentation": {
|
||||
"home": {
|
||||
"founderBadge": "接受项目沟通",
|
||||
"proofEyebrow": "专业经验与合作成果",
|
||||
"proofTitle": "经验与方法",
|
||||
"manifestoEyebrow": "工作原则",
|
||||
"manifestoTitle": "先厘清问题,再设计表达",
|
||||
"worksEyebrow": "合作方式",
|
||||
"worksTitle": "品牌策略与顾问服务",
|
||||
"worksAction": "查看全部 →"
|
||||
},
|
||||
"offerings": {
|
||||
"title": "合作方式",
|
||||
"subtitle": "围绕定位、表达与业务转化,选择适合当前阶段的支持。",
|
||||
"materialLabel": "包含:",
|
||||
"hardwareLabel": "定制说明:",
|
||||
"detailAction": "查看详情 →",
|
||||
"inquiryAction": "发起咨询"
|
||||
},
|
||||
"detail": {
|
||||
"priceLabel": "价格参考",
|
||||
"spaceLabel": "适合场景",
|
||||
"backgroundTitle": "项目背景",
|
||||
"conceptTitle": "设计思路",
|
||||
"craftsTitle": "交付要点",
|
||||
"materialsTitle": "材料与说明",
|
||||
"inquiryAction": "发起咨询",
|
||||
"inquiryHint": "提交信息后由主理人与您沟通。"
|
||||
},
|
||||
"profile": {
|
||||
"phoneLabel": "联系电话",
|
||||
"wechatLabel": "微信",
|
||||
"addressLabel": "工作地点",
|
||||
"callAction": "呼叫",
|
||||
"copyAction": "复制",
|
||||
"recordsTitle": "我的咨询记录",
|
||||
"recordsCountUnit": "条记录"
|
||||
},
|
||||
"inquiry": {
|
||||
"eyebrow": "COLLABORATION",
|
||||
"title": "合作咨询",
|
||||
"subtitle": "留下你的需求与目标,主理人会尽快联系。",
|
||||
"submitLabel": "提交咨询"
|
||||
},
|
||||
"success": {
|
||||
"eyebrow": "COLLABORATION",
|
||||
"title": "已收到你的咨询",
|
||||
"intro": "主理人会尽快与你联系。",
|
||||
"recordsAction": "查看咨询记录",
|
||||
"homeAction": "返回首页"
|
||||
},
|
||||
"records": {
|
||||
"title": "我的咨询记录",
|
||||
"createAction": "新增咨询",
|
||||
"emptyTitle": "还没有咨询记录",
|
||||
"emptyDescription": "提交一次咨询,开始与你的主理人沟通。",
|
||||
"emptyAction": "开始咨询"
|
||||
}
|
||||
},
|
||||
"founder": "示例主理人"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pages": [
|
||||
@@ -6335,7 +6189,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
],
|
||||
"visualTemplateKey": "linjing-editorial",
|
||||
"visualPresentation": {
|
||||
"description": "适合高端定制、建筑作品和项目型个人品牌。",
|
||||
"description": "适合高端定制的门窗、建筑入口和私宅项目。",
|
||||
"variants": {
|
||||
"hero": "architectural",
|
||||
"offeringList": "editorial",
|
||||
@@ -6389,7 +6243,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
"name": "序章·入户门",
|
||||
"summary": "为别墅入口定制的整樘门系统",
|
||||
"categoryKey": "entrance-door",
|
||||
"coverUrl": "/assets/content/doors-hero.jpg",
|
||||
"coverUrl": "/assets/content/entry-door.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「万籁」重型天地轴入户系统",
|
||||
@@ -6408,7 +6262,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/doors-hero.jpg",
|
||||
"url": "/assets/content/entry-door.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -6420,7 +6274,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
"name": "庭院·边界门",
|
||||
"summary": "连接建筑与庭院的定制门",
|
||||
"categoryKey": "garden-door",
|
||||
"coverUrl": "/assets/content/doors-yard-gate.jpg",
|
||||
"coverUrl": "/assets/content/courtyard-gate.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「虚实」透光私家庭院门",
|
||||
@@ -6439,7 +6293,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/doors-yard-gate.jpg",
|
||||
"url": "/assets/content/courtyard-gate.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -6451,7 +6305,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
"name": "室内·静谧门",
|
||||
"summary": "统一室内空间秩序的户内门",
|
||||
"categoryKey": "interior-door",
|
||||
"coverUrl": "/assets/content/doors-room-door.jpg",
|
||||
"coverUrl": "/assets/content/interior-door.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「空灵」2.8m - 3.2m 满高通顶系统",
|
||||
@@ -6470,7 +6324,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/doors-room-door.jpg",
|
||||
"url": "/assets/content/interior-door.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -6482,7 +6336,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
"name": "一对一门系统设计咨询",
|
||||
"summary": "从现场到方案的完整设计沟通",
|
||||
"categoryKey": "custom",
|
||||
"coverUrl": "/assets/content/personal-consulting.jpg",
|
||||
"coverUrl": "/assets/content/design-consultation.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「无垠」密室及背景墙融合门",
|
||||
@@ -6501,7 +6355,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/personal-consulting.jpg",
|
||||
"url": "/assets/content/design-consultation.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -6724,8 +6578,8 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
"phone": "186-0218-9908",
|
||||
"wechat": "LIN-ATELIER-2024",
|
||||
"studioAddress": "上海市静安区威海路设计中心 A 座 / 杭州良渚研造工坊",
|
||||
"avatarUrl": "/assets/content/personal-avatar.jpg",
|
||||
"heroImage": "/assets/content/doors-hero.jpg",
|
||||
"avatarUrl": "/assets/content/founder-portrait.jpg",
|
||||
"heroImage": "/assets/content/entry-door.jpg",
|
||||
"visualPresentation": {
|
||||
"home": {
|
||||
"founderBadge": "接受项目沟通",
|
||||
@@ -6811,168 +6665,9 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[
|
||||
"customerRecords": "disabled",
|
||||
"contactActions": "disabled"
|
||||
}
|
||||
},
|
||||
"personal": {
|
||||
"schemaVersion": "1",
|
||||
"brand": {
|
||||
"name": "林境建筑画册 · 预览",
|
||||
"tagline": "用于独立预览的模板演示内容",
|
||||
"description": "此内容仅用于平台模板预览,不代表真实品牌或客户案例。",
|
||||
"deliveryNote": "演示预览已禁用真实咨询和联系操作。"
|
||||
},
|
||||
"content": {
|
||||
"templateKey": "personal",
|
||||
"inquiryFormName": "合作咨询表单",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "示例·品牌定位咨询",
|
||||
"summary": "梳理品牌定位与下一步行动。",
|
||||
"categoryKey": "consulting",
|
||||
"coverUrl": "/assets/content/personal-consulting.jpg",
|
||||
"priceText": "按需求确认",
|
||||
"config": {
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/personal-consulting.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "示例·长期顾问支持",
|
||||
"summary": "围绕表达和转化提供持续支持。",
|
||||
"categoryKey": "advisory",
|
||||
"coverUrl": "/assets/content/personal-advisory.jpg",
|
||||
"priceText": "按服务周期确认",
|
||||
"config": {
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/personal-advisory.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"trustContent": [
|
||||
{
|
||||
"type": "credential",
|
||||
"title": "关于主理人",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
},
|
||||
{
|
||||
"type": "process",
|
||||
"title": "合作方法",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
}
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"key": "name",
|
||||
"label": "您的称呼",
|
||||
"type": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "phone",
|
||||
"label": "联系方式",
|
||||
"type": "phone",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "remark",
|
||||
"label": "合作需求",
|
||||
"type": "textarea",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"capabilityKey": "inquiry",
|
||||
"brandConfig": {
|
||||
"templateData": {
|
||||
"designPhilosophy": "先厘清问题,再设计表达"
|
||||
},
|
||||
"title": "品牌策略顾问",
|
||||
"slogan": "用清晰的定位与可执行的表达,让专业被看见。",
|
||||
"phone": "",
|
||||
"wechat": "",
|
||||
"studioAddress": "上海市徐汇区创意园区",
|
||||
"avatarUrl": "/assets/content/personal-avatar.jpg",
|
||||
"heroImage": "/assets/content/personal-consulting.jpg",
|
||||
"visualPresentation": {
|
||||
"home": {
|
||||
"founderBadge": "接受项目沟通",
|
||||
"proofEyebrow": "专业经验与合作成果",
|
||||
"proofTitle": "经验与方法",
|
||||
"manifestoEyebrow": "工作原则",
|
||||
"manifestoTitle": "先厘清问题,再设计表达",
|
||||
"worksEyebrow": "合作方式",
|
||||
"worksTitle": "品牌策略与顾问服务",
|
||||
"worksAction": "查看全部 →"
|
||||
},
|
||||
"offerings": {
|
||||
"title": "合作方式",
|
||||
"subtitle": "围绕定位、表达与业务转化,选择适合当前阶段的支持。",
|
||||
"materialLabel": "包含:",
|
||||
"hardwareLabel": "定制说明:",
|
||||
"detailAction": "查看详情 →",
|
||||
"inquiryAction": "发起咨询"
|
||||
},
|
||||
"detail": {
|
||||
"priceLabel": "价格参考",
|
||||
"spaceLabel": "适合场景",
|
||||
"backgroundTitle": "项目背景",
|
||||
"conceptTitle": "设计思路",
|
||||
"craftsTitle": "交付要点",
|
||||
"materialsTitle": "材料与说明",
|
||||
"inquiryAction": "发起咨询",
|
||||
"inquiryHint": "提交信息后由主理人与您沟通。"
|
||||
},
|
||||
"profile": {
|
||||
"phoneLabel": "联系电话",
|
||||
"wechatLabel": "微信",
|
||||
"addressLabel": "工作地点",
|
||||
"callAction": "呼叫",
|
||||
"copyAction": "复制",
|
||||
"recordsTitle": "我的咨询记录",
|
||||
"recordsCountUnit": "条记录"
|
||||
},
|
||||
"inquiry": {
|
||||
"eyebrow": "COLLABORATION",
|
||||
"title": "合作咨询",
|
||||
"subtitle": "留下你的需求与目标,主理人会尽快联系。",
|
||||
"submitLabel": "提交咨询"
|
||||
},
|
||||
"success": {
|
||||
"eyebrow": "COLLABORATION",
|
||||
"title": "已收到你的咨询",
|
||||
"intro": "主理人会尽快与你联系。",
|
||||
"recordsAction": "查看咨询记录",
|
||||
"homeAction": "返回首页"
|
||||
},
|
||||
"records": {
|
||||
"title": "我的咨询记录",
|
||||
"createAction": "新增咨询",
|
||||
"emptyTitle": "还没有咨询记录",
|
||||
"emptyDescription": "提交一次咨询,开始与你的主理人沟通。",
|
||||
"emptyAction": "开始咨询"
|
||||
}
|
||||
},
|
||||
"founder": "示例主理人"
|
||||
}
|
||||
},
|
||||
"safety": {
|
||||
"submissions": "disabled",
|
||||
"customerRecords": "disabled",
|
||||
"contactActions": "disabled"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
export const generatedTemplatePackageRegistryHash =
|
||||
"6c629f916b92e889a8984fde3ffc8ea3cb39ba25542b070da1f029ae57665d73";
|
||||
"06182e0005339404614b39e2051180d15bc6aa83f572194a7f4b7403650d3e8d";
|
||||
@@ -1,3 +1,3 @@
|
||||
# 林境建筑画册模板包
|
||||
|
||||
林境是个人品牌和项目型业务的编辑式视觉模板。页面只消费公共 Runtime Workspace。
|
||||
林境是面向门窗与建筑入口项目的编辑式视觉模板,只适配 `doors` 业务类型。页面只消费公共 Runtime Workspace。
|
||||
|
After Width: | Height: | Size: 166 KiB |
|
After Width: | Height: | Size: 196 KiB |
|
Before Width: | Height: | Size: 125 KiB |
|
Before Width: | Height: | Size: 121 KiB |
|
After Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 250 KiB |
|
Before Width: | Height: | Size: 210 KiB |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@personal-brand/template-linjing-editorial",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.7",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"files": [
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"packageKey": "linjing-editorial",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.7",
|
||||
"displayName": "林境建筑画册",
|
||||
"defaultBrandSlug": "linjing-doors",
|
||||
"runtimeContract": "1.0",
|
||||
"supportedIndustryTemplates": ["personal", "doors"],
|
||||
"supportedIndustryTemplates": ["doors"],
|
||||
"entrypoints": {
|
||||
"home": "pages/index/index",
|
||||
"offerings": "pages/services/index",
|
||||
@@ -1329,7 +1329,7 @@
|
||||
"name": "序章·入户门",
|
||||
"summary": "为别墅入口定制的整樘门系统",
|
||||
"categoryKey": "entrance-door",
|
||||
"coverUrl": "/assets/content/doors-hero.jpg",
|
||||
"coverUrl": "/assets/content/entry-door.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「万籁」重型天地轴入户系统",
|
||||
@@ -1348,7 +1348,7 @@
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/doors-hero.jpg",
|
||||
"url": "/assets/content/entry-door.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -1360,7 +1360,7 @@
|
||||
"name": "庭院·边界门",
|
||||
"summary": "连接建筑与庭院的定制门",
|
||||
"categoryKey": "garden-door",
|
||||
"coverUrl": "/assets/content/doors-yard-gate.jpg",
|
||||
"coverUrl": "/assets/content/courtyard-gate.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「虚实」透光私家庭院门",
|
||||
@@ -1379,7 +1379,7 @@
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/doors-yard-gate.jpg",
|
||||
"url": "/assets/content/courtyard-gate.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -1391,7 +1391,7 @@
|
||||
"name": "室内·静谧门",
|
||||
"summary": "统一室内空间秩序的户内门",
|
||||
"categoryKey": "interior-door",
|
||||
"coverUrl": "/assets/content/doors-room-door.jpg",
|
||||
"coverUrl": "/assets/content/interior-door.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「空灵」2.8m - 3.2m 满高通顶系统",
|
||||
@@ -1410,7 +1410,7 @@
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/doors-room-door.jpg",
|
||||
"url": "/assets/content/interior-door.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -1422,7 +1422,7 @@
|
||||
"name": "一对一门系统设计咨询",
|
||||
"summary": "从现场到方案的完整设计沟通",
|
||||
"categoryKey": "custom",
|
||||
"coverUrl": "/assets/content/personal-consulting.jpg",
|
||||
"coverUrl": "/assets/content/design-consultation.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「无垠」密室及背景墙融合门",
|
||||
@@ -1441,7 +1441,7 @@
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/personal-consulting.jpg",
|
||||
"url": "/assets/content/design-consultation.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -1664,8 +1664,8 @@
|
||||
"phone": "186-0218-9908",
|
||||
"wechat": "LIN-ATELIER-2024",
|
||||
"studioAddress": "上海市静安区威海路设计中心 A 座 / 杭州良渚研造工坊",
|
||||
"avatarUrl": "/assets/content/personal-avatar.jpg",
|
||||
"heroImage": "/assets/content/doors-hero.jpg",
|
||||
"avatarUrl": "/assets/content/founder-portrait.jpg",
|
||||
"heroImage": "/assets/content/entry-door.jpg",
|
||||
"visualPresentation": {
|
||||
"home": {
|
||||
"founderBadge": "接受项目沟通",
|
||||
@@ -1745,157 +1745,12 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"personal": {
|
||||
"templateKey": "personal",
|
||||
"inquiryFormName": "合作咨询表单",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "示例·品牌定位咨询",
|
||||
"summary": "梳理品牌定位与下一步行动。",
|
||||
"categoryKey": "consulting",
|
||||
"coverUrl": "/assets/content/personal-consulting.jpg",
|
||||
"priceText": "按需求确认",
|
||||
"config": {
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/personal-consulting.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "示例·长期顾问支持",
|
||||
"summary": "围绕表达和转化提供持续支持。",
|
||||
"categoryKey": "advisory",
|
||||
"coverUrl": "/assets/content/personal-advisory.jpg",
|
||||
"priceText": "按服务周期确认",
|
||||
"config": {
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/personal-advisory.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"trustContent": [
|
||||
{
|
||||
"type": "credential",
|
||||
"title": "关于主理人",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
},
|
||||
{
|
||||
"type": "process",
|
||||
"title": "合作方法",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
}
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"key": "name",
|
||||
"label": "您的称呼",
|
||||
"type": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "phone",
|
||||
"label": "联系方式",
|
||||
"type": "phone",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "remark",
|
||||
"label": "合作需求",
|
||||
"type": "textarea",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"capabilityKey": "inquiry",
|
||||
"brandConfig": {
|
||||
"templateData": {
|
||||
"designPhilosophy": "先厘清问题,再设计表达"
|
||||
},
|
||||
"title": "品牌策略顾问",
|
||||
"slogan": "用清晰的定位与可执行的表达,让专业被看见。",
|
||||
"phone": "",
|
||||
"wechat": "",
|
||||
"studioAddress": "上海市徐汇区创意园区",
|
||||
"avatarUrl": "/assets/content/personal-avatar.jpg",
|
||||
"heroImage": "/assets/content/personal-consulting.jpg",
|
||||
"visualPresentation": {
|
||||
"home": {
|
||||
"founderBadge": "接受项目沟通",
|
||||
"proofEyebrow": "专业经验与合作成果",
|
||||
"proofTitle": "经验与方法",
|
||||
"manifestoEyebrow": "工作原则",
|
||||
"manifestoTitle": "先厘清问题,再设计表达",
|
||||
"worksEyebrow": "合作方式",
|
||||
"worksTitle": "品牌策略与顾问服务",
|
||||
"worksAction": "查看全部 →"
|
||||
},
|
||||
"offerings": {
|
||||
"title": "合作方式",
|
||||
"subtitle": "围绕定位、表达与业务转化,选择适合当前阶段的支持。",
|
||||
"materialLabel": "包含:",
|
||||
"hardwareLabel": "定制说明:",
|
||||
"detailAction": "查看详情 →",
|
||||
"inquiryAction": "发起咨询"
|
||||
},
|
||||
"detail": {
|
||||
"priceLabel": "价格参考",
|
||||
"spaceLabel": "适合场景",
|
||||
"backgroundTitle": "项目背景",
|
||||
"conceptTitle": "设计思路",
|
||||
"craftsTitle": "交付要点",
|
||||
"materialsTitle": "材料与说明",
|
||||
"inquiryAction": "发起咨询",
|
||||
"inquiryHint": "提交信息后由主理人与您沟通。"
|
||||
},
|
||||
"profile": {
|
||||
"phoneLabel": "联系电话",
|
||||
"wechatLabel": "微信",
|
||||
"addressLabel": "工作地点",
|
||||
"callAction": "呼叫",
|
||||
"copyAction": "复制",
|
||||
"recordsTitle": "我的咨询记录",
|
||||
"recordsCountUnit": "条记录"
|
||||
},
|
||||
"inquiry": {
|
||||
"eyebrow": "COLLABORATION",
|
||||
"title": "合作咨询",
|
||||
"subtitle": "留下你的需求与目标,主理人会尽快联系。",
|
||||
"submitLabel": "提交咨询"
|
||||
},
|
||||
"success": {
|
||||
"eyebrow": "COLLABORATION",
|
||||
"title": "已收到你的咨询",
|
||||
"intro": "主理人会尽快与你联系。",
|
||||
"recordsAction": "查看咨询记录",
|
||||
"homeAction": "返回首页"
|
||||
},
|
||||
"records": {
|
||||
"title": "我的咨询记录",
|
||||
"createAction": "新增咨询",
|
||||
"emptyTitle": "还没有咨询记录",
|
||||
"emptyDescription": "提交一次咨询,开始与你的主理人沟通。",
|
||||
"emptyAction": "开始咨询"
|
||||
}
|
||||
},
|
||||
"founder": "示例主理人"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pages": ["pages/index/index", "pages/services/index", "pages/bookings/index"],
|
||||
"visualTemplateKey": "linjing-editorial",
|
||||
"visualPresentation": {
|
||||
"description": "适合高端定制、建筑作品和项目型个人品牌。",
|
||||
"description": "适合高端定制的门窗、建筑入口和私宅项目。",
|
||||
"variants": {
|
||||
"hero": "architectural",
|
||||
"offeringList": "editorial",
|
||||
@@ -1937,7 +1792,7 @@
|
||||
"name": "序章·入户门",
|
||||
"summary": "为别墅入口定制的整樘门系统",
|
||||
"categoryKey": "entrance-door",
|
||||
"coverUrl": "/assets/content/doors-hero.jpg",
|
||||
"coverUrl": "/assets/content/entry-door.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「万籁」重型天地轴入户系统",
|
||||
@@ -1956,7 +1811,7 @@
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/doors-hero.jpg",
|
||||
"url": "/assets/content/entry-door.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -1968,7 +1823,7 @@
|
||||
"name": "庭院·边界门",
|
||||
"summary": "连接建筑与庭院的定制门",
|
||||
"categoryKey": "garden-door",
|
||||
"coverUrl": "/assets/content/doors-yard-gate.jpg",
|
||||
"coverUrl": "/assets/content/courtyard-gate.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「虚实」透光私家庭院门",
|
||||
@@ -1987,7 +1842,7 @@
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/doors-yard-gate.jpg",
|
||||
"url": "/assets/content/courtyard-gate.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -1999,7 +1854,7 @@
|
||||
"name": "室内·静谧门",
|
||||
"summary": "统一室内空间秩序的户内门",
|
||||
"categoryKey": "interior-door",
|
||||
"coverUrl": "/assets/content/doors-room-door.jpg",
|
||||
"coverUrl": "/assets/content/interior-door.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「空灵」2.8m - 3.2m 满高通顶系统",
|
||||
@@ -2018,7 +1873,7 @@
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/doors-room-door.jpg",
|
||||
"url": "/assets/content/interior-door.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -2030,7 +1885,7 @@
|
||||
"name": "一对一门系统设计咨询",
|
||||
"summary": "从现场到方案的完整设计沟通",
|
||||
"categoryKey": "custom",
|
||||
"coverUrl": "/assets/content/personal-consulting.jpg",
|
||||
"coverUrl": "/assets/content/design-consultation.jpg",
|
||||
"priceText": "按项目确认",
|
||||
"config": {
|
||||
"series": "「无垠」密室及背景墙融合门",
|
||||
@@ -2049,7 +1904,7 @@
|
||||
},
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/personal-consulting.jpg",
|
||||
"url": "/assets/content/design-consultation.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
@@ -2272,8 +2127,8 @@
|
||||
"phone": "186-0218-9908",
|
||||
"wechat": "LIN-ATELIER-2024",
|
||||
"studioAddress": "上海市静安区威海路设计中心 A 座 / 杭州良渚研造工坊",
|
||||
"avatarUrl": "/assets/content/personal-avatar.jpg",
|
||||
"heroImage": "/assets/content/doors-hero.jpg",
|
||||
"avatarUrl": "/assets/content/founder-portrait.jpg",
|
||||
"heroImage": "/assets/content/entry-door.jpg",
|
||||
"visualPresentation": {
|
||||
"home": {
|
||||
"founderBadge": "接受项目沟通",
|
||||
@@ -2359,165 +2214,6 @@
|
||||
"customerRecords": "disabled",
|
||||
"contactActions": "disabled"
|
||||
}
|
||||
},
|
||||
"personal": {
|
||||
"schemaVersion": "1",
|
||||
"brand": {
|
||||
"name": "林境建筑画册 · 预览",
|
||||
"tagline": "用于独立预览的模板演示内容",
|
||||
"description": "此内容仅用于平台模板预览,不代表真实品牌或客户案例。",
|
||||
"deliveryNote": "演示预览已禁用真实咨询和联系操作。"
|
||||
},
|
||||
"content": {
|
||||
"templateKey": "personal",
|
||||
"inquiryFormName": "合作咨询表单",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "示例·品牌定位咨询",
|
||||
"summary": "梳理品牌定位与下一步行动。",
|
||||
"categoryKey": "consulting",
|
||||
"coverUrl": "/assets/content/personal-consulting.jpg",
|
||||
"priceText": "按需求确认",
|
||||
"config": {
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/personal-consulting.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "示例·长期顾问支持",
|
||||
"summary": "围绕表达和转化提供持续支持。",
|
||||
"categoryKey": "advisory",
|
||||
"coverUrl": "/assets/content/personal-advisory.jpg",
|
||||
"priceText": "按服务周期确认",
|
||||
"config": {
|
||||
"media": [
|
||||
{
|
||||
"url": "/assets/content/personal-advisory.jpg",
|
||||
"alt": "",
|
||||
"type": "image"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"trustContent": [
|
||||
{
|
||||
"type": "credential",
|
||||
"title": "关于主理人",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
},
|
||||
{
|
||||
"type": "process",
|
||||
"title": "合作方法",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
}
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"key": "name",
|
||||
"label": "您的称呼",
|
||||
"type": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "phone",
|
||||
"label": "联系方式",
|
||||
"type": "phone",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "remark",
|
||||
"label": "合作需求",
|
||||
"type": "textarea",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"capabilityKey": "inquiry",
|
||||
"brandConfig": {
|
||||
"templateData": {
|
||||
"designPhilosophy": "先厘清问题,再设计表达"
|
||||
},
|
||||
"title": "品牌策略顾问",
|
||||
"slogan": "用清晰的定位与可执行的表达,让专业被看见。",
|
||||
"phone": "",
|
||||
"wechat": "",
|
||||
"studioAddress": "上海市徐汇区创意园区",
|
||||
"avatarUrl": "/assets/content/personal-avatar.jpg",
|
||||
"heroImage": "/assets/content/personal-consulting.jpg",
|
||||
"visualPresentation": {
|
||||
"home": {
|
||||
"founderBadge": "接受项目沟通",
|
||||
"proofEyebrow": "专业经验与合作成果",
|
||||
"proofTitle": "经验与方法",
|
||||
"manifestoEyebrow": "工作原则",
|
||||
"manifestoTitle": "先厘清问题,再设计表达",
|
||||
"worksEyebrow": "合作方式",
|
||||
"worksTitle": "品牌策略与顾问服务",
|
||||
"worksAction": "查看全部 →"
|
||||
},
|
||||
"offerings": {
|
||||
"title": "合作方式",
|
||||
"subtitle": "围绕定位、表达与业务转化,选择适合当前阶段的支持。",
|
||||
"materialLabel": "包含:",
|
||||
"hardwareLabel": "定制说明:",
|
||||
"detailAction": "查看详情 →",
|
||||
"inquiryAction": "发起咨询"
|
||||
},
|
||||
"detail": {
|
||||
"priceLabel": "价格参考",
|
||||
"spaceLabel": "适合场景",
|
||||
"backgroundTitle": "项目背景",
|
||||
"conceptTitle": "设计思路",
|
||||
"craftsTitle": "交付要点",
|
||||
"materialsTitle": "材料与说明",
|
||||
"inquiryAction": "发起咨询",
|
||||
"inquiryHint": "提交信息后由主理人与您沟通。"
|
||||
},
|
||||
"profile": {
|
||||
"phoneLabel": "联系电话",
|
||||
"wechatLabel": "微信",
|
||||
"addressLabel": "工作地点",
|
||||
"callAction": "呼叫",
|
||||
"copyAction": "复制",
|
||||
"recordsTitle": "我的咨询记录",
|
||||
"recordsCountUnit": "条记录"
|
||||
},
|
||||
"inquiry": {
|
||||
"eyebrow": "COLLABORATION",
|
||||
"title": "合作咨询",
|
||||
"subtitle": "留下你的需求与目标,主理人会尽快联系。",
|
||||
"submitLabel": "提交咨询"
|
||||
},
|
||||
"success": {
|
||||
"eyebrow": "COLLABORATION",
|
||||
"title": "已收到你的咨询",
|
||||
"intro": "主理人会尽快与你联系。",
|
||||
"recordsAction": "查看咨询记录",
|
||||
"homeAction": "返回首页"
|
||||
},
|
||||
"records": {
|
||||
"title": "我的咨询记录",
|
||||
"createAction": "新增咨询",
|
||||
"emptyTitle": "还没有咨询记录",
|
||||
"emptyDescription": "提交一次咨询,开始与你的主理人沟通。",
|
||||
"emptyAction": "开始咨询"
|
||||
}
|
||||
},
|
||||
"founder": "示例主理人"
|
||||
}
|
||||
},
|
||||
"safety": {
|
||||
"submissions": "disabled",
|
||||
"customerRecords": "disabled",
|
||||
"contactActions": "disabled"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,13 @@ test("compatibility report discovers deployed package, industry, visual and rend
|
||||
(item) => item.packageKey === "linjing-editorial" && item.industry === "doors",
|
||||
),
|
||||
);
|
||||
assert.equal(
|
||||
report.packages.some(
|
||||
(item) => item.packageKey === "linjing-editorial" && item.industry === "personal",
|
||||
),
|
||||
false,
|
||||
"林境建筑画册不得出现在 personal 兼容矩阵中",
|
||||
);
|
||||
});
|
||||
|
||||
test("compatibility check rejects renderer, capability and toolchain incompatibilities", () => {
|
||||
|
||||