Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06619a191f | ||
|
|
3a0099e674 | ||
|
|
ca1b873a50 | ||
|
|
c2bd956b07 | ||
|
|
b101d169c9 | ||
|
|
ab17f80607 | ||
|
|
6df4e1d72b | ||
|
|
cb046a4c27 | ||
|
|
3738be884b | ||
|
|
193858c727 | ||
|
|
ea81c754ed | ||
|
|
16fd827634 | ||
|
|
38e9d59864 | ||
|
|
fb072d844b | ||
|
|
0d9f4a7d6f | ||
|
|
f02e2cafbb | ||
|
|
5d88cb2040 | ||
|
|
8e29932bc6 | ||
|
|
4ef4be2071 | ||
|
|
0788480ce3 | ||
|
|
bd129a3069 | ||
|
|
3017e3eb49 | ||
|
|
4f0b50c7f1 | ||
|
|
456171aa85 | ||
|
|
50b87e48de | ||
|
|
cd2992c00a | ||
|
|
e6d843b4a7 | ||
|
|
5a93d38437 | ||
|
|
bba20c5b28 | ||
|
|
b47cf5badc | ||
|
|
71c528de34 | ||
|
|
ec16fff70e | ||
|
|
6420b85019 | ||
|
|
c1633fb6f3 | ||
|
|
d1958a7d7f | ||
|
|
b1e8012ded | ||
|
|
5bf54096be | ||
|
|
d38dbe02aa | ||
|
|
b60174885e | ||
|
|
6edde5a8d6 | ||
|
|
413413efda | ||
|
|
553a07c4ec | ||
|
|
cddf836f4f | ||
|
|
58370224b5 | ||
|
|
b6713ea34c | ||
|
|
1918dae36b | ||
|
|
3989fbd39e | ||
|
|
cfd42e17f8 | ||
|
|
f12003004b | ||
|
|
6de7dd8d9e | ||
|
|
0862a4c01d | ||
|
|
18eb8bb9b0 | ||
|
|
a933e1feb6 | ||
|
|
f7be18a35e | ||
|
|
714cbd55f2 | ||
|
|
50753db79d | ||
|
|
5313fd9d32 | ||
|
|
34bd8142de | ||
|
|
04e42b3a80 |
No files matched your search
@@ -0,0 +1,260 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"scope": "模板完成证据登记,保留命令、日志与产物哈希",
|
||||
"generatedAt": "2026-10-20T13:23:08.179Z",
|
||||
"templates": {
|
||||
"acheng-campus-food": {
|
||||
"real-manifest-interaction": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"pnpm --filter @personal-brand/api test:integration",
|
||||
"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-20-final/api-integration.log",
|
||||
"sha256": "1efcc2e20c32dc9b42f960a6967a6e94a32aa9e49ca855c17d61b2bc7f6ab891"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20/admin-editor.log",
|
||||
"sha256": "281c1bba68b5f6e30438d925ea58d8454bd98cf538fab8217710c7dc4402d103"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
},
|
||||
"save-reload-publish-isolation": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"pnpm --filter @personal-brand/api test:integration"
|
||||
],
|
||||
"artifacts": [
|
||||
{
|
||||
"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
|
||||
},
|
||||
"visual-reference": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"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-20/template-preview-media.log",
|
||||
"sha256": "3eb8132e3fae6c95e2820d2979422ab63ab93e52426de8bcd528fd16b36eba3c"
|
||||
},
|
||||
{
|
||||
"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-final/01-acheng-campus-food-food-375.png",
|
||||
"sha256": "a0cc26679391dc851056551dcd5b31f50603bfd0dc44a59bc5182ea377a2747f"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-final/01-acheng-campus-food-food-390.png",
|
||||
"sha256": "f5d517380140ed62bb306a79fdbf818e1846c7ff58ebf229c2c8ed1142221537"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
},
|
||||
"empty-error-branches": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"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-20/template-preview-media.log",
|
||||
"sha256": "3eb8132e3fae6c95e2820d2979422ab63ab93e52426de8bcd528fd16b36eba3c"
|
||||
},
|
||||
{
|
||||
"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-final/empty-01-acheng-campus-food-food.png",
|
||||
"sha256": "2a8279db468ab65426f1cf5e13ff8dcffa6ef625bf9f3dd563165b8905a79043"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
}
|
||||
},
|
||||
"atelier-solopreneur": {
|
||||
"real-manifest-interaction": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"pnpm --filter @personal-brand/api test:integration",
|
||||
"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-20-final/api-integration.log",
|
||||
"sha256": "1efcc2e20c32dc9b42f960a6967a6e94a32aa9e49ca855c17d61b2bc7f6ab891"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20/admin-editor.log",
|
||||
"sha256": "281c1bba68b5f6e30438d925ea58d8454bd98cf538fab8217710c7dc4402d103"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
},
|
||||
"save-reload-publish-isolation": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"pnpm --filter @personal-brand/api test:integration"
|
||||
],
|
||||
"artifacts": [
|
||||
{
|
||||
"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
|
||||
},
|
||||
"visual-reference": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"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-20/template-preview-media.log",
|
||||
"sha256": "3eb8132e3fae6c95e2820d2979422ab63ab93e52426de8bcd528fd16b36eba3c"
|
||||
},
|
||||
{
|
||||
"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-final/02-atelier-solopreneur-personal-375.png",
|
||||
"sha256": "70d251ab829ebfc85dba7fd65ac423272af4af54b39f76d1bea9ebbe0f89bc2d"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-final/02-atelier-solopreneur-personal-390.png",
|
||||
"sha256": "a430e7c72f794d62f9f0248c52307b6f644ea5b6099ba6c8b929f365504c3b07"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
},
|
||||
"empty-error-branches": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"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-20/template-preview-media.log",
|
||||
"sha256": "3eb8132e3fae6c95e2820d2979422ab63ab93e52426de8bcd528fd16b36eba3c"
|
||||
},
|
||||
{
|
||||
"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-final/empty-02-atelier-solopreneur-personal.png",
|
||||
"sha256": "78982dd7aa7a8751e29969de9f68c6c3eab0bcdb2403f1a5442f10cc03b9a843"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
}
|
||||
},
|
||||
"linjing-editorial": {
|
||||
"real-manifest-interaction": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"pnpm --filter @personal-brand/api test:integration",
|
||||
"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-20-final/api-integration.log",
|
||||
"sha256": "1efcc2e20c32dc9b42f960a6967a6e94a32aa9e49ca855c17d61b2bc7f6ab891"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/evidence-2026-10-20/admin-editor.log",
|
||||
"sha256": "281c1bba68b5f6e30438d925ea58d8454bd98cf538fab8217710c7dc4402d103"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
},
|
||||
"save-reload-publish-isolation": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"pnpm --filter @personal-brand/api test:integration"
|
||||
],
|
||||
"artifacts": [
|
||||
{
|
||||
"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
|
||||
},
|
||||
"visual-reference": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"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-20/template-preview-media.log",
|
||||
"sha256": "3eb8132e3fae6c95e2820d2979422ab63ab93e52426de8bcd528fd16b36eba3c"
|
||||
},
|
||||
{
|
||||
"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-final/03-linjing-editorial-doors-375.png",
|
||||
"sha256": "48960348d896631b6c0c788a5528a21e7eefe3339dfffdbff43330c062f7b983"
|
||||
},
|
||||
{
|
||||
"path": ".codex-tasks/template-audit-execution/raw/visual-matrix-final/03-linjing-editorial-doors-390.png",
|
||||
"sha256": "dd893c5958c3f4165ae988fef7be6882b27ccb3260112676ae296f2e6fef6be6"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
},
|
||||
"empty-error-branches": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"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-20/template-preview-media.log",
|
||||
"sha256": "3eb8132e3fae6c95e2820d2979422ab63ab93e52426de8bcd528fd16b36eba3c"
|
||||
},
|
||||
{
|
||||
"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-final/empty-03-linjing-editorial-doors.png",
|
||||
"sha256": "d7b2b3197e426f1dd9b2ef99cd8682cb4c34531163b8ba5ebc90453438521970"
|
||||
}
|
||||
],
|
||||
"exitCode": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"sourceTreeHash": "7db7647772c54d29bcff2211b59bc3a1c261988b543046ba3b078d5945d3a599"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
Running 2 tests using 1 worker
|
||||
|
||||
(node:633537) 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:633537) 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:5 › Admin 按通用预览目标筛选字段并同步品牌草稿 (26.4s)
|
||||
✓ 2 test/browser/admin-editor.spec.ts:637:5 › 林境模板支持首页和主理人区域点选 (27.8s)
|
||||
|
||||
2 passed (55.7s)
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
Running 1 test using 1 worker
|
||||
|
||||
(node:632552) 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:632552) 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:632689) 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:632799) 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:632867) 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:632924) 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:155:5 › 导入包预览矩阵展示身份、资源和完整媒体槽位 (12.7s)
|
||||
|
||||
1 passed (14.2s)
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
Running 2 tests using 1 worker
|
||||
|
||||
(node:12847) 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:12847) 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:5 › Admin 按通用预览目标筛选字段并同步品牌草稿 (21.0s)
|
||||
✓ 2 test/browser/admin-editor.spec.ts:654:5 › 林境模板支持首页和主理人区域点选 (22.2s)
|
||||
|
||||
2 passed (44.1s)
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
Running 1 test using 1 worker
|
||||
|
||||
(node:12338) 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:12338) 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:12435) 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:12543) 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:12607) 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:12662) 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:155:5 › 导入包预览矩阵展示身份、资源和完整媒体槽位 (9.1s)
|
||||
|
||||
1 passed (10.0s)
|
||||
@@ -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: 57 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 94 KiB |
|
After Width: | Height: | Size: 90 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 71 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 107 KiB |
|
After Width: | Height: | Size: 95 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 80 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: 96 KiB |
|
After Width: | Height: | Size: 108 KiB |
|
After Width: | Height: | Size: 107 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 74 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 104 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
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 |
@@ -6,9 +6,11 @@ POSTGRES_DB=personal_brand
|
||||
POSTGRES_PORT=5432
|
||||
API_PORT=3001
|
||||
API_PREFIX=
|
||||
CORS_ORIGINS=http://localhost:3000
|
||||
ADMIN_PORT=3000
|
||||
SESSION_SECRET=replace-with-a-long-random-value
|
||||
DEFAULT_BRAND_ID=00000000-0000-0000-0000-000000000001
|
||||
TEMPLATE_ARTIFACT_ROOT=/var/lib/personal-brand/template-artifacts
|
||||
SEED_ADMIN_PASSWORD=change-me-now-123
|
||||
OBJECT_STORAGE_ENDPOINT=http://localhost:9000
|
||||
OBJECT_STORAGE_PUBLIC_URL=http://localhost:9000/personal-brand-media
|
||||
|
||||
@@ -12,6 +12,7 @@ SEED_MODE=skip
|
||||
|
||||
API_PORT=3001
|
||||
API_PREFIX=
|
||||
CORS_ORIGINS=
|
||||
|
||||
LOCAL_MEDIA_ROOT=/home/ubuntu/persional-brand/media
|
||||
LOCAL_MEDIA_BASE_URL=/media
|
||||
|
||||
@@ -24,6 +24,12 @@ jobs:
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm check
|
||||
- run: pnpm test:api-routes
|
||||
- run: pnpm audit --prod --registry=https://registry.npmjs.org
|
||||
- run: pnpm validate:templates
|
||||
- run: pnpm template:compatibility
|
||||
- run: pnpm --filter @personal-brand/api exec tsx --test test/template-preview-matrix.test.ts
|
||||
- run: pnpm template:conformance
|
||||
- run: pnpm template:doctor
|
||||
|
||||
build:
|
||||
@@ -40,7 +46,9 @@ jobs:
|
||||
node-version: 24
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm build
|
||||
- run: pnpm build:admin:preview
|
||||
- run: pnpm validate:template-release
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: admin-dist
|
||||
@@ -67,6 +75,9 @@ jobs:
|
||||
--health-retries 12
|
||||
env:
|
||||
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/personal_brand
|
||||
DEFAULT_BRAND_ID: 00000000-0000-0000-0000-000000000001
|
||||
SESSION_SECRET: ci-integration-session-secret-0123456789abcdef
|
||||
SEED_ADMIN_PASSWORD: ci-integration-admin-password
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
@@ -77,12 +88,64 @@ jobs:
|
||||
node-version: 24
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- name: Prepare API test env
|
||||
working-directory: apps/api
|
||||
run: |
|
||||
cat > .env <<EOF
|
||||
DATABASE_URL=$DATABASE_URL
|
||||
DEFAULT_BRAND_ID=$DEFAULT_BRAND_ID
|
||||
SESSION_SECRET=$SESSION_SECRET
|
||||
SEED_ADMIN_PASSWORD=$SEED_ADMIN_PASSWORD
|
||||
EOF
|
||||
- run: pnpm --filter @personal-brand/api test:integration
|
||||
|
||||
taro:
|
||||
name: Taro builds
|
||||
runs-on: ubuntu-latest
|
||||
needs: [static]
|
||||
strategy:
|
||||
matrix:
|
||||
template: [acheng-campus-food, atelier-solopreneur, linjing-editorial]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9.15.0
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: TEMPLATE_KEY=acheng-campus-food pnpm --filter @personal-brand/taro build:h5
|
||||
env:
|
||||
TEMPLATE_KEY: ${{ matrix.template }}
|
||||
- run: TEMPLATE_KEY=acheng-campus-food pnpm --filter @personal-brand/taro build:weapp
|
||||
env:
|
||||
TEMPLATE_KEY: ${{ matrix.template }}
|
||||
|
||||
browser:
|
||||
name: Browser regression
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build]
|
||||
needs: [build, taro]
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
env:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: personal_brand
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
--health-cmd "pg_isready -U postgres -d personal_brand"
|
||||
--health-interval 5s
|
||||
--health-timeout 5s
|
||||
--health-retries 12
|
||||
env:
|
||||
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/personal_brand
|
||||
DEFAULT_BRAND_ID: 00000000-0000-0000-0000-000000000001
|
||||
SESSION_SECRET: ci-integration-session-secret-0123456789abcdef
|
||||
SEED_ADMIN_PASSWORD: ci-integration-admin-password
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
@@ -94,13 +157,24 @@ jobs:
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm --filter @personal-brand/taro exec playwright install --with-deps chromium
|
||||
- name: Prepare API test env
|
||||
working-directory: apps/api
|
||||
run: |
|
||||
cat > .env <<EOF
|
||||
DATABASE_URL=$DATABASE_URL
|
||||
DEFAULT_BRAND_ID=$DEFAULT_BRAND_ID
|
||||
SESSION_SECRET=$SESSION_SECRET
|
||||
SEED_ADMIN_PASSWORD=$SEED_ADMIN_PASSWORD
|
||||
EOF
|
||||
- run: pnpm --filter @personal-brand/api db:migrate:deploy
|
||||
- run: pnpm --filter @personal-brand/api db:seed
|
||||
- run: pnpm --filter @personal-brand/api test:integration
|
||||
env:
|
||||
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/personal_brand
|
||||
- name: Start API
|
||||
run: pnpm --filter @personal-brand/api start > /tmp/api.log 2>&1 &
|
||||
env:
|
||||
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/personal_brand
|
||||
DEFAULT_BRAND_ID: 00000000-0000-0000-0000-000000000001
|
||||
SESSION_SECRET: browser-ci-session-secret-0123456789abcdef
|
||||
NODE_ENV: development
|
||||
- name: Start mini program preview
|
||||
run: pnpm --filter @personal-brand/taro dev:h5 > /tmp/taro.log 2>&1 &
|
||||
@@ -120,3 +194,5 @@ jobs:
|
||||
curl --retry 30 --retry-delay 1 --retry-connrefused -fsS http://localhost:3002
|
||||
curl --retry 30 --retry-delay 1 --retry-connrefused -fsS http://localhost:3000
|
||||
- run: pnpm --filter @personal-brand/taro exec playwright test --config=playwright.config.ts --reporter=line
|
||||
env:
|
||||
ADMIN_URL: http://localhost:3000
|
||||
@@ -26,3 +26,5 @@ media/
|
||||
.codex-tasks/
|
||||
docker-compose.override.yml
|
||||
.env.production
|
||||
|
||||
apps/api/storage/
|
||||
@@ -8,6 +8,7 @@
|
||||
- The food template is supported, but it is an example template rather than the product definition.
|
||||
- Backend configuration is the source of truth for brand content, services, template selection, trust-building content, and industry-specific fields. The mini program only renders configuration and submits user input.
|
||||
- Template packages are the source of truth for template manifests, visual structure, default/sample content, field declarations, assets, and capabilities. Do not copy every template's sample data into Prisma seed or global database tables. A template's sample content may be copied into the database only when an administrator explicitly imports it for one specific brand; the resulting rows are brand content, not template registration.
|
||||
- Templates have exactly one active package manifest/runtime contract. Do not add legacy readers, dual-write paths, inferred defaults, aliases, or silent fallbacks. Convert existing persisted data with a one-time, auditable migration that fails on ambiguity, then remove the old representation.
|
||||
- `apps/api/prisma/seed.ts` may contain a small, explicit development fixture for the seeded demo brands, but it must never become the catalog of all templates or require one seed block per production template. New templates must be discoverable and validated from their package manifest without editing global seed data.
|
||||
- Any delivered backend endpoint must have an automated test covering its authorization and successful behavior before it is considered complete.
|
||||
- Keep personal-brand trust details explicit: biography, positioning, credentials, portfolio/proof, process, expectations, availability, contact methods, and clear follow-up status.
|
||||
|
||||
@@ -1,104 +1,128 @@
|
||||
# Project Status
|
||||
|
||||
最后更新:2026-09-19
|
||||
|
||||
## 当前目标
|
||||
|
||||
先为餐饮摊主朋友交付一个真正能带来订单的个人品牌小程序,再根据真实使用把通用能力产品化。产品方的收益、运营和平台化目标不能牺牲朋友的实际使用效果。
|
||||
最后更新:2026-10-21
|
||||
|
||||
## 当前阶段
|
||||
|
||||
后端基础、数据库环境和订单 API 已完成首轮验证,管理后台和小程序静态页面已接入首版结构,下一步进行真实资源与微信登录/预约联调。
|
||||
系统已从“餐饮试点小程序”演进为多模板个人品牌平台。当前已完成统一模板契约收口、模板完成证据门禁、品牌与页面方案拆分、管理员登录态撤销和 release 版本一致性修复。
|
||||
|
||||
## 已完成
|
||||
ADR 0033 已落地:
|
||||
|
||||
- 产品 PRD、原型规格、架构决策、数据/API 设计和实施计划。
|
||||
- 餐饮试点画像与首轮需求访谈决策。
|
||||
- 可点击低保真原型:`prototype/index.html`。
|
||||
- Git 仓库、`main` 分支和远程仓库。
|
||||
- pnpm workspace + Turborepo Monorepo。
|
||||
- TypeScript 严格配置、ESLint、Prettier、EditorConfig、环境变量模板。
|
||||
- NestJS + Fastify API 骨架。
|
||||
- Prisma PostgreSQL schema:品牌、服务、客户身份、订单、订单明细、标签、管理员。
|
||||
- 微信官方 `jscode2session` 登录交换边界。
|
||||
- 客户登录 token、客户订单提交/查询/取消。
|
||||
- 普通套餐价格快照和私厨需求人工报价模型。
|
||||
- 管理员账号密码登录和角色 token。
|
||||
- 管理员订单列表、状态、未读、标签和内部备忘能力。
|
||||
- DTO 校验、全局异常响应、请求 ID和订单状态流转规则。
|
||||
- Docker PostgreSQL Compose、seed 和 Prisma 脚本说明。
|
||||
- 初始 Prisma migration,已在本地 PostgreSQL 应用并验证数据库 schema up to date。
|
||||
- seed 已写入品牌、服务、标签和管理员数据,并完成数量核验。
|
||||
- 管理员订单详情、状态/未读/标签筛选和未读数量接口。
|
||||
- API 自动化业务规则测试:订单创建、客户取消、状态流转和标签品牌隔离,共 6 项通过。
|
||||
- 修复 ESM 下 `bcryptjs` 导入和 Fastify 请求 ID middleware 的运行时问题。
|
||||
- API 已通过真实 HTTP 验证:健康检查、公开品牌/服务读取和管理员登录。
|
||||
- HTTP 集成测试:公开接口、管理员登录、错误密码、管理员权限边界、客户会话、预约 DTO 校验、创建/取消和状态流转,共 8 项通过。
|
||||
- OpenAPI 3.1 契约:`docs/openapi.yaml`,覆盖当前公开、客户和管理员接口。
|
||||
- 类型化 `@personal-brand/api-client`:支持公开内容、客户预约、管理员订单和统一错误处理,并有 2 项客户端测试。
|
||||
- 已根据 `/home/que01/桌面/个人品牌设计图/` 确认 C 端页面视觉规范:暖白、米黄、砖红、深炭黑,16px 卡片圆角和大字号优先。
|
||||
- 小程序已完成首页、服务列表、预约套餐和我的订单静态页面,页面标题使用微信原生导航栏。
|
||||
- 已配置小程序 AppID:`wxd75d946d6978d183`。
|
||||
- 服务分类、预约数量步进器、订单状态卡和底部导航已按设计图完成首版还原。
|
||||
- 已执行多轮 Codex 代码审查并修复关键认证和权限问题。
|
||||
- “表达方式”已从 Admin 源码移除。
|
||||
- “业务类型”和“页面方案”是两个独立概念。
|
||||
- 新增“创建品牌”和“页面方案”页面。
|
||||
- 创建品牌不会自动导入示例内容。
|
||||
- `linjing-editorial` 只兼容 `doors`,不再兼容 `personal`。
|
||||
|
||||
## 最近提交
|
||||
## 当前能力
|
||||
|
||||
- NestJS + Fastify API、Prisma PostgreSQL、全局 DTO 校验、统一错误响应和 `requestId`。
|
||||
- 多品牌 Admin、品牌 membership、角色边界、品牌切换和品牌隔离。
|
||||
- 创建品牌时按业务类型筛选兼容的页面方案;不兼容组合无法提交。
|
||||
- 模板包发现、确定性打包、导入、校验、发布、预览、安装、升级和回滚。
|
||||
- 三套已交付模板及其业务类型:
|
||||
- `acheng-campus-food@1.0.3`:`food`
|
||||
- `atelier-solopreneur@1.3.2`:`personal`
|
||||
- `linjing-editorial@1.0.7`:`doors`
|
||||
- Taro Runtime、Admin 组件预览、真实 manifest 驱动编辑、草稿/发布隔离。
|
||||
- 发布备注为可选字段;空备注不会写入数据库,也不影响发布、回滚和公开内容。
|
||||
- 依赖 override 的运行时兼容性通过 `miniprogram-ci` / Jimp / image-size / uuid smoke test 守卫。
|
||||
- 小程序构建、上传任务状态机、attempt lease 和失败记录。
|
||||
- Admin/Customer token version:修改 admin 密码或调用 logout 后旧 token 立即失效;无 membership 的账号不会自动获得 owner 权限。
|
||||
- `visualPresentation` 已进入唯一 `template.json` 契约,旧手写 visual manifest 优先路径已删除。
|
||||
|
||||
## 生产状态
|
||||
|
||||
当前生产 release:
|
||||
|
||||
```text
|
||||
fee3c77 fix: 按设计图优化预约套餐数量和商品卡
|
||||
13ead2d fix: 对齐服务分类和订单视觉结构
|
||||
255756c feat: 增加小程序品牌首页
|
||||
本次工作:数据库初始化、订单管理接口、业务规则测试和运行时修复
|
||||
f2687c5 chore: prepare portable postgres development environment
|
||||
0e8b8e1 feat: add api http conventions and booking state rules
|
||||
0d4caab feat: add admin order tags and read state
|
||||
bb5ccb1 feat: add admin authentication
|
||||
b89853b fix: harden api authentication and validation
|
||||
20261021022400-c2bd956b0747
|
||||
```
|
||||
|
||||
远程:`https://git.app.que01.top/que01/persionalBrand.git`
|
||||
该 release 由提交 `c2bd956` 构建,包含创建品牌与页面方案的交互修复、浏览器回归用例,以及前置的 Node 24 版本门禁。部署后已完成公开路由健康检查和三个品牌发布快照核对。
|
||||
|
||||
## 下一步优先级
|
||||
生产健康检查:
|
||||
|
||||
1. 接入真实品牌图片、电话和微信配置,并替换当前图片占位区域。
|
||||
2. 在微信开发者工具/真机完成 `wx.login`、预约提交、订单查询和取消联调。
|
||||
3. 完善管理后台订单详情、筛选和状态处理视觉页面。
|
||||
4. 继续补充页面截图回归和真实素材下的移动端溢出检查。
|
||||
|
||||
## 未决问题
|
||||
|
||||
- 普通套餐采用固定菜单、每日菜单,还是固定套餐加每日可用状态。
|
||||
- 朋友最终品牌名称、图片、联系方式、营业时间和配送范围。
|
||||
- 微信小程序主体、AppID、服务类目和订阅消息模板是否可用。
|
||||
- 生产部署使用哪家 PostgreSQL、对象存储和 API 托管服务。
|
||||
- 当前 token 是开发阶段的签名 Bearer token;生产前应替换为带撤销能力的正式 session/Cookie 方案。
|
||||
|
||||
## 当前明确不做
|
||||
|
||||
- 支付、退款、发票、财务对账。
|
||||
- 复杂库存、自动配送判断和每日菜单编排。
|
||||
- 多商户注册、套餐计费、会员和营销系统。
|
||||
- 自动发布微信小程序。
|
||||
|
||||
## 跨电脑恢复
|
||||
|
||||
```bash
|
||||
git clone https://git.app.que01.top/que01/persionalBrand.git
|
||||
cd persionalBrand
|
||||
cat PROJECT_STATUS.md
|
||||
cat agent.md
|
||||
cp .env.example .env
|
||||
```text
|
||||
api=online
|
||||
pm2-autostart=enabled
|
||||
admin=active
|
||||
database=running
|
||||
backups=7
|
||||
/admin/ 200
|
||||
/template-preview/ 200
|
||||
/api/health 200
|
||||
/media/seed/food-package-02.jpg 200
|
||||
```
|
||||
|
||||
有 Docker 的机器再执行:
|
||||
生产数据库已应用全部 48 个 Prisma migration,schema 为 up to date。
|
||||
|
||||
```bash
|
||||
docker compose up -d postgres
|
||||
pnpm install
|
||||
pnpm db:migrate
|
||||
pnpm db:seed
|
||||
三个生产品牌的当前发布快照:
|
||||
|
||||
| 品牌 | 业务类型 | 页面方案 | 发布版本 |
|
||||
| ---------------- | ---------- | --------------------------- | ------------ |
|
||||
| `atelier-studio` | `personal` | `atelier-solopreneur@1.3.2` | `v2 current` |
|
||||
| `default-brand` | `food` | `acheng-campus-food@1.0.3` | `v2 current` |
|
||||
| `linjing-doors` | `doors` | `linjing-editorial@1.0.7` | `v3 current` |
|
||||
|
||||
## 完成证据
|
||||
|
||||
`.codex-tasks/template-audit-execution/raw/completion-evidence.json` 登记四类证据:
|
||||
|
||||
- `real-manifest-interaction`
|
||||
- `save-reload-publish-isolation`
|
||||
- `visual-reference`
|
||||
- `empty-error-branches`
|
||||
|
||||
每条证据保留执行命令、日志和产物 SHA-256。`pnpm template:doctor` 会校验证据覆盖和哈希;当前三套模板均为:
|
||||
|
||||
```text
|
||||
staticStatus=pass
|
||||
completionStatus=complete
|
||||
unresolvedIssues=0
|
||||
```
|
||||
|
||||
## 更新规则
|
||||
Admin 浏览器回归新增 `apps/taro/test/browser/brand-creation-and-page-scheme.spec.ts`,覆盖:
|
||||
|
||||
每完成一个可验证的开发任务,更新“当前阶段”“已完成”“最近提交”和“下一步优先级”。只记录已经发生或已经确认的事实;未确认内容放入“未决问题”。
|
||||
- 创建品牌时按业务类型筛选页面方案。
|
||||
- `personal` 不出现林境页面方案。
|
||||
- 切换业务类型后清除不兼容的页面方案选择,提交按钮禁用。
|
||||
- 创建失败时保留用户输入并显示错误。
|
||||
- 页面方案切换和升级提交正确版本、校验和与冲突保留参数。
|
||||
- 操作成功后刷新工作区、页面方案选项和升级预览查询。
|
||||
|
||||
## 已验证门禁
|
||||
|
||||
- `pnpm check`
|
||||
- `pnpm validate:template-release`
|
||||
- `pnpm --filter @personal-brand/api test`
|
||||
- `pnpm --filter @personal-brand/api test:integration`
|
||||
- `miniprogram-ci` override 兼容 smoke test
|
||||
- `pnpm test:api-client`
|
||||
- `pnpm test:deploy`
|
||||
- `pnpm --filter @personal-brand/admin typecheck`
|
||||
- `pnpm --filter @personal-brand/admin lint`
|
||||
- `pnpm --filter @personal-brand/admin test`
|
||||
- `pnpm --filter @personal-brand/admin build`
|
||||
- `pnpm build`
|
||||
- `pnpm template:doctor`
|
||||
- Playwright:
|
||||
- `brand-creation-and-page-scheme.spec.ts`
|
||||
- `template-preview-media.spec.ts`
|
||||
- `admin-editor.spec.ts`
|
||||
|
||||
发布脚本的 Node 版本门禁已提前到所有构建之前。Node 22 下执行 `pnpm deploy:release` 会立即失败,并给出 Node.js 24 要求提示,不再先执行一轮无用构建。
|
||||
|
||||
## 安全审计
|
||||
|
||||
- `pnpm audit --prod --registry=https://registry.npmjs.org` 已完成。
|
||||
- 可修复 advisory 已通过 `pnpm.overrides` 收敛;`request` 替换为 `@cypress/request@4.0.1`。
|
||||
- 剩余 8 条为 `miniprogram-ci@2.1.31` 无修复版本的上游 advisory,已在 `pnpm.auditConfig.ignoreGhsas` 和 `docs/security-audit.md` 中显式登记风险、控制措施与跟进条件。
|
||||
- Taro 官方 peer 仍声明 Vite 4;当前使用 Vite 6.4.3,H5 与 Weapp 实际构建均通过,peer warning 记录在安全审计文档。
|
||||
|
||||
## 未决事项
|
||||
|
||||
- 本次源码新增的 Admin 浏览器回归、页面方案查询缓存修复和 Node 门禁修复尚未部署到生产;部署后需更新本节的生产 release 和验证结果。
|
||||
- `miniprogram-ci` 上游发布修复版本后,需要移除对应的 audit ignore、风险登记和本地 patch。
|
||||
- Gitea SSH 直连仍受 OCI 安全列表限制;当前本机通过 `oracle_arm` ProxyCommand 转发访问,不阻塞业务。
|
||||
- CI 已加入 audit 和三套模板矩阵构建;后续可继续拆分更细粒度的 smoke/visual matrix。
|
||||
@@ -270,19 +270,21 @@
|
||||
|
||||
以下为各页面的视觉结构约定,业务逻辑不变。
|
||||
|
||||
| 页面 | 结构要点 |
|
||||
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 登录 | 居中 400px 卡片,标识 + 说明 + 表单 + 通栏主按钮;错误态展示在字段下方 |
|
||||
| 首次改密 | 同登录卡片形态,说明文案 + 三个密码字段 + 「保存新密码」 |
|
||||
| 品牌概览 | 品牌卡 + 三张指标卡(等宽一行)+ 两栏(发布准备度 / 品牌内容检查) |
|
||||
| 配置与发布 | 三 Tab(内容发布 / 小程序发布 / 小程序配置);内容发布含「选择表达方式」(行业模板 + 视觉模板 + 版本升级/回滚)+ 发布状态卡 + 草稿卡 + 历史版本表 |
|
||||
| 小程序页面 | 左右两栏:左 380px 编辑面板,右预览画布;预览内选中区域虚线高亮 + 区域名气泡 |
|
||||
| 信任内容 | 列表行(类型图标或配图 + 标题 + 发布状态标签 + 类型/展示位置说明 + 两行摘要 + 行内操作),按模板类型顺序排列,不用表格 |
|
||||
| 业务提供项 | 表格(名称 / 价格 / 状态开关 / 排序 / 操作)+ 新增弹窗 |
|
||||
| 咨询记录 | 顶部三指标 + 左 380px 列表 + 右详情的主从布局 |
|
||||
| 咨询表单与字段 | 咨询表单表(名称 / 版本 / 字段数 / 状态 / 操作)+ 新增与编辑弹窗(含选项编辑);高级自定义字段表 + 新增弹窗 |
|
||||
| 能力插件 | 插件卡片列表(图标 + 名称 + 说明 + 开关),停用态降低对比度 |
|
||||
| 团队成员 | 表格(成员 / 角色 / 状态 / 最近登录 / 操作)+ 邀请弹窗 |
|
||||
| 页面 | 结构要点 |
|
||||
| -------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
||||
| 登录 | 居中 400px 卡片,标识 + 说明 + 表单 + 通栏主按钮;错误态展示在字段下方 |
|
||||
| 首次改密 | 同登录卡片形态,说明文案 + 三个密码字段 + 「保存新密码」 |
|
||||
| 品牌概览 | 品牌卡 + 三张指标卡(等宽一行)+ 两栏(发布准备度 / 品牌内容检查) |
|
||||
| 内容与发布 | 内容发布 / 小程序发布 / 小程序配置三个分区;内容发布含发布状态卡、草稿卡和历史版本表,不承载业务类型或页面方案选择 |
|
||||
| 页面方案 | 当前业务类型与页面方案 + 升级预览 + 版本选择 + 配置恢复 + 高级示例内容导入 |
|
||||
| 品牌管理 | 品牌列表与创建入口;创建品牌先选不可变的业务类型,再选兼容页面方案,创建时不导入示例内容 |
|
||||
| 小程序页面 | 左右两栏:左 380px 编辑面板,右预览画布;预览内选中区域虚线高亮 + 区域名气泡 |
|
||||
| 信任内容 | 列表行(类型图标或配图 + 标题 + 发布状态标签 + 类型/展示位置说明 + 两行摘要 + 行内操作),按模板类型顺序排列,不用表格 |
|
||||
| 业务提供项 | 表格(名称 / 价格 / 状态开关 / 排序 / 操作)+ 新增弹窗 |
|
||||
| 咨询记录 | 顶部三指标 + 左 380px 列表 + 右详情的主从布局 |
|
||||
| 咨询表单与字段 | 咨询表单表(名称 / 版本 / 字段数 / 状态 / 操作)+ 新增与编辑弹窗(含选项编辑);高级自定义字段表 + 新增弹窗 |
|
||||
| 能力插件 | 插件卡片列表(图标 + 名称 + 说明 + 开关),停用态降低对比度 |
|
||||
| 团队成员 | 表格(成员 / 角色 / 状态 / 最近登录 / 操作)+ 邀请弹窗 |
|
||||
|
||||
两栏页面在小屏下折叠为单列,编辑/预览改为上下排列。
|
||||
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="default-src 'self'; img-src 'self' data: blob:; media-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; font-src 'self' data:; connect-src 'self' ws: wss:; script-src 'self'; object-src 'none'; base-uri 'none'; form-action 'self'"
|
||||
/>
|
||||
<title>个人品牌后台</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { createElement, type ReactNode } from "react";
|
||||
import { Navigate, Route, Routes } from "react-router-dom";
|
||||
|
||||
export function AdminOverviewRedirect() {
|
||||
return createElement(Navigate, { to: "/admin/overview", replace: true });
|
||||
}
|
||||
|
||||
export function AdminRouter({ children }: { children: ReactNode }) {
|
||||
return createElement(
|
||||
Routes,
|
||||
null,
|
||||
createElement(Route, { path: "/admin/*", element: children }),
|
||||
createElement(Route, { path: "*", element: createElement(AdminOverviewRedirect) }),
|
||||
);
|
||||
}
|
||||
@@ -4,9 +4,11 @@ import {
|
||||
BarsOutlined,
|
||||
CloudUploadOutlined,
|
||||
FormOutlined,
|
||||
LayoutOutlined,
|
||||
MessageOutlined,
|
||||
MobileOutlined,
|
||||
SafetyCertificateOutlined,
|
||||
ShopOutlined,
|
||||
TeamOutlined,
|
||||
ThunderboltOutlined,
|
||||
} from "@ant-design/icons";
|
||||
@@ -16,25 +18,40 @@ import { BrandMark } from "../components/BrandMark.js";
|
||||
import { StatusTag } from "../components/StatusTag.js";
|
||||
import {
|
||||
FeatureBrandPage,
|
||||
FeatureBrandsPage,
|
||||
FeatureCapabilitiesPage,
|
||||
FeatureCreateBrandPage,
|
||||
FeatureInquiriesPage,
|
||||
FeatureMembersPage,
|
||||
FeatureOverviewPage,
|
||||
FeaturePageSchemePage,
|
||||
FeaturePublicationPage,
|
||||
FeatureTemplateManagementPage,
|
||||
FeatureServicesPage,
|
||||
FeatureTrustContentPage,
|
||||
FeatureWorkspacePage,
|
||||
} from "./routes.js";
|
||||
import { LoadingStack } from "../components/LoadingStack.js";
|
||||
import { AdminMenu } from "../components/AdminMenu.js";
|
||||
import { adminMessage as message } from "../components/AdminMessage.js";
|
||||
import { App } from "antd";
|
||||
import { AdminButton } from "../components/AdminButton.js";
|
||||
import { AdminSelect } from "../components/AdminSelect.js";
|
||||
import { AdminLayout } from "../components/AdminLayout.js";
|
||||
import { Navigate, Route, Routes } from "react-router-dom";
|
||||
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({ onLogout, role }: { onLogout: () => void; role: string }) {
|
||||
export function Dashboard({
|
||||
onLogout,
|
||||
role,
|
||||
platformTemplateRole,
|
||||
}: {
|
||||
onLogout: () => void;
|
||||
role: string;
|
||||
platformTemplateRole: "none" | "template_admin";
|
||||
}) {
|
||||
const { message } = App.useApp();
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const brand = useQuery({
|
||||
@@ -47,8 +64,7 @@ export function Dashboard({ onLogout, role }: { onLogout: () => void; role: stri
|
||||
});
|
||||
const switchBrand = async (brandId: string) => {
|
||||
try {
|
||||
const result = await createApiClient().switchAdminBrand(brandId);
|
||||
localStorage.setItem("adminToken", result.token);
|
||||
await createApiClient().switchAdminBrand(brandId);
|
||||
window.location.reload();
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : "品牌切换失败");
|
||||
@@ -61,7 +77,7 @@ export function Dashboard({ onLogout, role }: { onLogout: () => void; role: stri
|
||||
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 /> },
|
||||
@@ -74,10 +90,15 @@ export function Dashboard({ onLogout, role }: { onLogout: () => void; role: stri
|
||||
: [
|
||||
{
|
||||
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"
|
||||
? [{ key: "templates", label: "模板管理", icon: <AppstoreOutlined /> }]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
]),
|
||||
@@ -110,7 +131,7 @@ export function Dashboard({ onLogout, role }: { onLogout: () => void; role: stri
|
||||
className="admin-brand-switcher"
|
||||
value={brand.data?.id}
|
||||
loading={memberships.isLoading}
|
||||
onChange={(value) => {
|
||||
onChange={(value: string | undefined) => {
|
||||
if (value) void switchBrand(value);
|
||||
}}
|
||||
options={(memberships.data ?? []).map((item) => ({
|
||||
@@ -127,12 +148,9 @@ export function Dashboard({ onLogout, role }: { onLogout: () => void; role: stri
|
||||
<div className="admin-content-inner">
|
||||
<Suspense fallback={<LoadingStack />}>
|
||||
<Routes>
|
||||
<Route path="/" element={<Navigate to="overview" replace />} />
|
||||
<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 />} />
|
||||
@@ -140,11 +158,23 @@ export function Dashboard({ onLogout, role }: { onLogout: () => void; role: stri
|
||||
<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" ? (
|
||||
<Route path="templates" element={<FeatureTemplateManagementPage />} />
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
<Route path="*" element={<Navigate to="overview" replace />} />
|
||||
<Route path="*" element={<AdminOverviewRedirect />} />
|
||||
</Routes>
|
||||
</Suspense>
|
||||
</div>
|
||||
|
||||
@@ -1,38 +1,84 @@
|
||||
import React, { useState } from "react";
|
||||
import type { AdminSession } from "@personal-brand/api-client";
|
||||
import { ChangePassword, Login } from "../features/auth/AuthPages.js";
|
||||
import { Dashboard } from "./Dashboard.js";
|
||||
import { adminMessage as message } from "../components/AdminMessage.js";
|
||||
import { AdminRouter } from "./AdminRouter.js";
|
||||
import { App } from "antd";
|
||||
import { createApiClient } from "../lib/api.js";
|
||||
import { LoadingStack } from "../components/LoadingStack.js";
|
||||
|
||||
type SessionState = Omit<AdminSession, "authenticated">;
|
||||
|
||||
export function Root() {
|
||||
const [loggedIn, setLoggedIn] = useState(Boolean(localStorage.getItem("adminToken")));
|
||||
const [role, setRole] = useState(localStorage.getItem("adminRole") || "owner");
|
||||
const [mustChangePassword, setMustChangePassword] = useState(
|
||||
localStorage.getItem("adminMustChangePassword") === "true",
|
||||
);
|
||||
const { message } = App.useApp();
|
||||
const [session, setSession] = useState<SessionState | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
React.useEffect(() => {
|
||||
let active = true;
|
||||
createApiClient()
|
||||
.getAdminSession()
|
||||
.then((current) => {
|
||||
if (active) setSession(current);
|
||||
})
|
||||
.catch(() => {
|
||||
if (active) setSession(null);
|
||||
})
|
||||
.finally(() => {
|
||||
if (active) setLoading(false);
|
||||
});
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
const expire = () => {
|
||||
message.warning("登录状态已失效,请重新登录");
|
||||
setLoggedIn(false);
|
||||
setSession(null);
|
||||
};
|
||||
window.addEventListener("admin-auth-expired", expire);
|
||||
return () => window.removeEventListener("admin-auth-expired", expire);
|
||||
}, []);
|
||||
const logout = () => {
|
||||
localStorage.removeItem("adminToken");
|
||||
localStorage.removeItem("adminRole");
|
||||
localStorage.removeItem("adminMustChangePassword");
|
||||
setLoggedIn(false);
|
||||
|
||||
const logout = async () => {
|
||||
try {
|
||||
await createApiClient().logoutAdmin();
|
||||
} catch {
|
||||
message.warning("已退出本地会话;服务端撤销请求未完成");
|
||||
} finally {
|
||||
setSession(null);
|
||||
}
|
||||
};
|
||||
if (!loggedIn)
|
||||
|
||||
if (loading) return <LoadingStack />;
|
||||
if (!session)
|
||||
return (
|
||||
<Login
|
||||
onLogin={(session) => {
|
||||
setRole(session.role);
|
||||
setMustChangePassword(session.mustChangePassword);
|
||||
setLoggedIn(true);
|
||||
onLogin={(current) => {
|
||||
setSession(current);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
if (mustChangePassword) return <ChangePassword onComplete={() => setMustChangePassword(false)} />;
|
||||
return <Dashboard onLogout={logout} role={role} />;
|
||||
if (session.mustChangePassword)
|
||||
return (
|
||||
<ChangePassword
|
||||
onComplete={async () => {
|
||||
try {
|
||||
setSession(await createApiClient().getAdminSession());
|
||||
} catch {
|
||||
setSession(null);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<AdminRouter>
|
||||
<Dashboard
|
||||
onLogout={logout}
|
||||
role={session.role}
|
||||
platformTemplateRole={session.platformTemplateRole}
|
||||
/>
|
||||
</AdminRouter>
|
||||
);
|
||||
}
|
||||
@@ -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 });
|
||||
}
|
||||
@@ -43,3 +43,23 @@ export const FeaturePublicationPage = React.lazy(() =>
|
||||
default: module.PublicationPage,
|
||||
})),
|
||||
);
|
||||
export const FeatureTemplateManagementPage = React.lazy(() =>
|
||||
import("../features/template-management/TemplateManagementPage.js").then((module) => ({
|
||||
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 +0,0 @@
|
||||
export { message as adminMessage } from "antd";
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CloudUploadOutlined, DeleteOutlined, PictureOutlined } from "@ant-design/icons";
|
||||
import { Alert, Button, Image, Popconfirm, Spin, Upload, message } from "antd";
|
||||
import { Alert, App, Button, Image, Popconfirm, Spin, Upload } from "antd";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { apiBaseUrl, createApiClient } from "../lib/api.js";
|
||||
import { apiBaseUrl, authenticatedFetch, createApiClient } from "../lib/api.js";
|
||||
|
||||
interface ImageUrlFieldProps {
|
||||
id?: string;
|
||||
@@ -12,6 +12,7 @@ interface ImageUrlFieldProps {
|
||||
}
|
||||
|
||||
export function ImageUrlField({ id, value, onChange, placeholder, scope }: ImageUrlFieldProps) {
|
||||
const { message } = App.useApp();
|
||||
const imageUrl = typeof value === "string" ? value.trim() : "";
|
||||
const [uploading, setUploading] = useState(false);
|
||||
const [storageStatus, setStorageStatus] = useState<
|
||||
@@ -54,14 +55,9 @@ export function ImageUrlField({ id, value, onChange, placeholder, scope }: Image
|
||||
const uploadUrl = isLocalUpload
|
||||
? `${apiBaseUrl.replace(/\/$/, "")}${presign.uploadUrl}`
|
||||
: presign.uploadUrl;
|
||||
const response = await fetch(uploadUrl, {
|
||||
const response = await authenticatedFetch(uploadUrl, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"content-type": file.type,
|
||||
...(isLocalUpload
|
||||
? { authorization: `Bearer ${localStorage.getItem("adminToken") ?? ""}` }
|
||||
: {}),
|
||||
},
|
||||
headers: { "content-type": file.type },
|
||||
body: file,
|
||||
});
|
||||
if (!response.ok) throw new Error(`upload failed: ${response.status}`);
|
||||
@@ -79,7 +75,7 @@ export function ImageUrlField({ id, value, onChange, placeholder, scope }: Image
|
||||
<Alert
|
||||
type={storageStatus === "loading" ? "info" : "warning"}
|
||||
showIcon
|
||||
message={
|
||||
title={
|
||||
storageStatus === "loading"
|
||||
? "正在检查媒体存储..."
|
||||
: storageStatus === "unconfigured"
|
||||
|
||||
@@ -76,7 +76,7 @@ export function RecordContentEditor({
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message={
|
||||
title={
|
||||
source === "offering"
|
||||
? `正在编辑业务提供项:${recordName}`
|
||||
: `正在编辑信任内容:${recordName}`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Form, message } from "antd";
|
||||
import { App, Form } from "antd";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import type { TemplateAdminSection } from "@personal-brand/api-client";
|
||||
@@ -59,6 +59,7 @@ export function useRecordContentEditorState({
|
||||
onDraft?: ((values: PresentationValues) => void) | undefined;
|
||||
onSaved?: (() => void) | undefined;
|
||||
}) {
|
||||
const { message } = App.useApp();
|
||||
const [form] = Form.useForm<PresentationValues>();
|
||||
const queryClient = useQueryClient();
|
||||
const [draftValues, setDraftValues] = useState<PresentationValues>(() =>
|
||||
|
||||
@@ -1,25 +1,20 @@
|
||||
import { useState } from "react";
|
||||
import { App } from "antd";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { BrandMark } from "../../components/BrandMark.js";
|
||||
import { adminMessage as message } from "../../components/AdminMessage.js";
|
||||
import { AdminButton } from "../../components/AdminButton.js";
|
||||
import { AdminCard } from "../../components/AdminCard.js";
|
||||
import { AdminForm, AdminInput } from "../../components/AdminForm.js";
|
||||
import type { AdminLoginSession } from "@personal-brand/api-client";
|
||||
|
||||
export function Login({
|
||||
onLogin,
|
||||
}: {
|
||||
onLogin: (session: { role: string; mustChangePassword: boolean }) => void;
|
||||
}) {
|
||||
export function Login({ onLogin }: { onLogin: (session: AdminLoginSession) => void }) {
|
||||
const { message } = App.useApp();
|
||||
const [form] = AdminForm.useForm();
|
||||
const [loading, setLoading] = useState(false);
|
||||
async function submit(values: { username: string; password: string }) {
|
||||
setLoading(true);
|
||||
try {
|
||||
const result = await createApiClient().loginAdmin(values.username, values.password);
|
||||
localStorage.setItem("adminToken", result.token);
|
||||
localStorage.setItem("adminRole", result.role);
|
||||
localStorage.setItem("adminMustChangePassword", String(result.mustChangePassword));
|
||||
onLogin(result);
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : "登录失败");
|
||||
@@ -58,6 +53,7 @@ export function Login({
|
||||
}
|
||||
|
||||
export function ChangePassword({ onComplete }: { onComplete: () => void }) {
|
||||
const { message } = App.useApp();
|
||||
const [form] = AdminForm.useForm<{
|
||||
currentPassword: string;
|
||||
newPassword: string;
|
||||
@@ -76,7 +72,6 @@ export function ChangePassword({ onComplete }: { onComplete: () => void }) {
|
||||
setLoading(true);
|
||||
try {
|
||||
await createApiClient().changeAdminPassword(values.currentPassword, values.newPassword);
|
||||
localStorage.setItem("adminMustChangePassword", "false");
|
||||
message.success("密码已更新");
|
||||
onComplete();
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Alert, Button, Col, Form, Input, Row, Select, Segmented, message } from "antd";
|
||||
import { Alert, App, Button, Col, Form, Input, Row, Segmented } from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useState } from "react";
|
||||
import { Link, useLocation } from "react-router-dom";
|
||||
@@ -14,6 +14,7 @@ import "./BrandPage.css";
|
||||
import { useEditorDraft } from "./use-editor-draft.js";
|
||||
|
||||
export function BrandPage() {
|
||||
const { message } = App.useApp();
|
||||
const location = useLocation();
|
||||
const initialSelection = location.state as PreviewSelection | undefined;
|
||||
const [panel, setPanel] = useState("pages");
|
||||
@@ -36,10 +37,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 +57,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 +171,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 +220,7 @@ export function BrandPage() {
|
||||
className="brand-page__template-note"
|
||||
type="info"
|
||||
showIcon
|
||||
message={`当前使用:${template.data.name}`}
|
||||
title={`当前页面方案:${workspace.data?.templateContent?.displayName ?? template.data.name}`}
|
||||
description={`适用场景:${template.data.serviceCategories.join("、") || "通用品牌展示"}`}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
@@ -168,6 +168,6 @@
|
||||
display: block;
|
||||
}
|
||||
|
||||
.component-template-preview__overlay-host > * {
|
||||
.component-template-preview__overlay-host > .component-template-preview__composite-select {
|
||||
pointer-events: auto;
|
||||
}
|
||||
@@ -3,15 +3,19 @@ import type { RuntimeWorkspace } from "@personal-brand/api-client";
|
||||
import { Alert } from "antd";
|
||||
import { resolveTemplateRenderer } from "./component-renderers.jsx";
|
||||
import type { PreviewSelection, PreviewTarget } from "./preview-selection.js";
|
||||
import { TemplatePreviewAssetsContext } from "./preview-assets.js";
|
||||
import "./ComponentTemplatePreview.css";
|
||||
|
||||
type PreviewProps = {
|
||||
workspace: RuntimeWorkspace;
|
||||
page: string;
|
||||
offeringId?: string;
|
||||
assetFiles?: Record<string, { sha256: string; dataUrl: string }>;
|
||||
selection?: PreviewSelection;
|
||||
targets: PreviewTarget[];
|
||||
onTargetSelected: (selection?: PreviewSelection) => void;
|
||||
onPageSelected?: (page: string) => void;
|
||||
onOfferingSelected?: (offeringId: string) => void;
|
||||
};
|
||||
|
||||
type Outline = { top: number; left: number; width: number; height: number; label: string };
|
||||
@@ -21,9 +25,12 @@ export function ComponentTemplatePreview({
|
||||
workspace,
|
||||
page,
|
||||
offeringId,
|
||||
assetFiles,
|
||||
selection,
|
||||
targets,
|
||||
onTargetSelected,
|
||||
onPageSelected = () => undefined,
|
||||
onOfferingSelected = () => undefined,
|
||||
}: PreviewProps) {
|
||||
const Renderer = resolveTemplateRenderer(workspace);
|
||||
const root = useRef<HTMLDivElement>(null);
|
||||
@@ -31,6 +38,26 @@ export function ComponentTemplatePreview({
|
||||
const [mode, setMode] = useState<"edit" | "browse">("edit");
|
||||
const [hovered, setHovered] = useState<HTMLElement | null>(null);
|
||||
const overlay = useRef<HTMLDivElement>(null);
|
||||
// 将 renderer 里的 Taro CTA 导航转换为画布内页面/记录切换。
|
||||
useEffect(() => {
|
||||
const navigate = (event: Event) => {
|
||||
const detail = (event as CustomEvent<{ method?: string; options?: { url?: string } }>).detail;
|
||||
const url = detail?.options?.url;
|
||||
if (typeof url !== "string") return;
|
||||
const match = /^\/pages\/([a-z]+)\/index(?:\?(.*))?$/.exec(url);
|
||||
if (!match) return;
|
||||
const nextPage = match[1];
|
||||
if (!nextPage) return;
|
||||
const query = match[2];
|
||||
if (nextPage === "detail") {
|
||||
const id = new URLSearchParams(query ?? "").get("id");
|
||||
if (id) onOfferingSelected(id);
|
||||
}
|
||||
onPageSelected(nextPage);
|
||||
};
|
||||
window.addEventListener("template-preview-navigate", navigate);
|
||||
return () => window.removeEventListener("template-preview-navigate", navigate);
|
||||
}, [onOfferingSelected, onPageSelected]);
|
||||
const targetFor = useCallback(
|
||||
(element: Element | null): HTMLElement | null => {
|
||||
let candidate = element?.closest<HTMLElement>("[data-editor-target]");
|
||||
@@ -178,7 +205,7 @@ export function ComponentTemplatePreview({
|
||||
return () => window.removeEventListener("keydown", clear);
|
||||
}, [onTargetSelected]);
|
||||
if (!Renderer)
|
||||
return <Alert type="warning" showIcon message="此模板尚无组件预览,请使用页面预览" />;
|
||||
return <Alert type="warning" showIcon title="此模板尚无组件预览,请使用页面预览" />;
|
||||
return (
|
||||
<div className="component-template-preview-shell">
|
||||
<div
|
||||
@@ -232,7 +259,9 @@ export function ComponentTemplatePreview({
|
||||
}}
|
||||
>
|
||||
<div ref={canvas} className="component-template-preview__canvas">
|
||||
<Renderer workspace={workspace} page={page} {...(offeringId ? { offeringId } : {})} />
|
||||
<TemplatePreviewAssetsContext.Provider value={assetFiles}>
|
||||
<Renderer workspace={workspace} page={page} {...(offeringId ? { offeringId } : {})} />
|
||||
</TemplatePreviewAssetsContext.Provider>
|
||||
<div
|
||||
ref={overlay}
|
||||
className={`component-template-preview__overlay-host ${
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Alert, Button, Form, Input, Select, Space, Switch, message } from "antd";
|
||||
import { Alert, App, Button, Form, Input, Select, Space, Switch } from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useEffect } from "react";
|
||||
import type { RuntimeWorkspace } from "@personal-brand/api-client";
|
||||
@@ -18,6 +18,7 @@ export function InquiryPreviewEditor({
|
||||
onDraft: (fields: RuntimeInquiryForm["fields"]) => void;
|
||||
onSaved?: () => void;
|
||||
}) {
|
||||
const { message } = App.useApp();
|
||||
const [form] = Form.useForm<Record<string, unknown>>();
|
||||
const cache = useQueryClient();
|
||||
const query = useQuery({
|
||||
@@ -59,7 +60,7 @@ export function InquiryPreviewEditor({
|
||||
return (
|
||||
<Alert
|
||||
type="error"
|
||||
message="表单读取失败"
|
||||
title="表单读取失败"
|
||||
action={<Button onClick={() => void query.refetch()}>重试</Button>}
|
||||
/>
|
||||
);
|
||||
@@ -67,10 +68,10 @@ export function InquiryPreviewEditor({
|
||||
return (
|
||||
<Alert
|
||||
type="info"
|
||||
message={query.isPending ? "正在读取表单" : "未找到对应表单,请刷新后重试"}
|
||||
title={query.isPending ? "正在读取表单" : "未找到对应表单,请刷新后重试"}
|
||||
/>
|
||||
);
|
||||
if (!field) return <Alert type="warning" message="字段已不存在" />;
|
||||
if (!field) return <Alert type="warning" title="字段已不存在" />;
|
||||
return (
|
||||
<Form<Record<string, unknown>>
|
||||
form={form}
|
||||
|
||||
@@ -2,11 +2,7 @@ import { Alert, Button, Grid, Select, Segmented, Space, Typography } from "antd"
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import type {
|
||||
AdminTemplateContent,
|
||||
RuntimeWorkspace,
|
||||
TemplateAdminSection,
|
||||
} from "@personal-brand/api-client";
|
||||
import type { AdminTemplateContent, RuntimeWorkspace } from "@personal-brand/api-client";
|
||||
import type { BrandProfile } from "@personal-brand/api-client";
|
||||
import { StatusTag } from "../../components/StatusTag.js";
|
||||
import { RecordContentEditor } from "../../components/RecordContentEditor.js";
|
||||
@@ -18,10 +14,7 @@ import {
|
||||
type PreviewSelection,
|
||||
type PreviewTarget,
|
||||
} from "./preview-selection.js";
|
||||
import {
|
||||
filterSectionsForPreviewTarget,
|
||||
type PresentationValues,
|
||||
} from "../../lib/presentation/presentation-bindings.js";
|
||||
import { filterSectionsForPreviewTarget } from "../../lib/presentation/presentation-bindings.js";
|
||||
import "./PresentationEditor.css";
|
||||
import { useEditorDraft } from "./use-editor-draft.js";
|
||||
import {
|
||||
@@ -213,7 +206,14 @@ export function PresentationEditor({
|
||||
: pageLinks;
|
||||
const formState = useBrandPresentationForm({ brand, config, sections });
|
||||
const { form, initialValues } = formState;
|
||||
const save = useBrandSaveMutation({ ...formState, brand, config, sections, queryClient });
|
||||
const save = useBrandSaveMutation({
|
||||
...formState,
|
||||
brand,
|
||||
config,
|
||||
sections,
|
||||
queryClient,
|
||||
onSaved: () => setBrandDirty(false),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const initialPage =
|
||||
@@ -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 title="正在读取当前页面方案的编辑项目" /> : null}
|
||||
{error ? (
|
||||
<Alert type="warning" showIcon message="模板编辑项目读取失败,请刷新后重试。" />
|
||||
<Alert type="warning" showIcon title="页面方案编辑项目读取失败,请刷新后重试。" />
|
||||
) : null}
|
||||
{!loading && !error && !templateContent ? (
|
||||
<Alert type="warning" showIcon message="当前模板暂未提供可编辑的页面内容。" />
|
||||
<Alert type="warning" showIcon title="当前页面方案暂未提供可编辑的页面内容。" />
|
||||
) : null}
|
||||
{templateContent ? (
|
||||
<>
|
||||
@@ -454,7 +454,7 @@ export function PresentationEditor({
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="详情页由所选业务内容动态生成"
|
||||
title="详情页由所选业务内容动态生成"
|
||||
description="选择业务内容预览详情,记录内容在业务提供项中维护;公共标题和按钮文案可从左侧区域列表配置,对全部详情生效。"
|
||||
action={
|
||||
<Button
|
||||
@@ -480,7 +480,7 @@ export function PresentationEditor({
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="这是一个组合区域"
|
||||
title="这是一个组合区域"
|
||||
description={
|
||||
<Space wrap>
|
||||
{(selectedTarget.children ?? []).map((childKey) => {
|
||||
@@ -542,7 +542,7 @@ export function PresentationEditor({
|
||||
? "error"
|
||||
: "info"
|
||||
}
|
||||
message={
|
||||
title={
|
||||
(
|
||||
selectedRecordSource === "offering"
|
||||
? offeringsQuery.isError
|
||||
@@ -583,7 +583,7 @@ export function PresentationEditor({
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="此区域尚未配置内容"
|
||||
title="此区域尚未配置内容"
|
||||
description="创建并启用对应内容后,即可在预览中点选编辑。"
|
||||
action={
|
||||
<Button
|
||||
|
||||
@@ -89,7 +89,7 @@ export function PresentationFormPanel({
|
||||
type="info"
|
||||
showIcon
|
||||
className="admin-offset-bottom-lg"
|
||||
message="这个页面还有关联内容"
|
||||
title="这个页面还有关联内容"
|
||||
description={
|
||||
<Space wrap>
|
||||
{relevantPageLinks.map((item) => (
|
||||
|
||||
@@ -124,7 +124,7 @@ export function TemplatePreview({
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="页面预览暂不可用"
|
||||
title="页面预览暂不可用"
|
||||
description="请确认模板预览资源已构建并发布,或本地预览服务正在运行。"
|
||||
/>
|
||||
);
|
||||
@@ -150,7 +150,7 @@ export function TemplatePreview({
|
||||
</div>
|
||||
) : null}
|
||||
{error ? (
|
||||
<Alert type="error" showIcon message="页面预览加载失败" description={error} />
|
||||
<Alert type="error" showIcon title="页面预览加载失败" description={error} />
|
||||
) : null}
|
||||
<iframe
|
||||
key={url}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { TemplateAssetContext } from "./taro-web-components.jsx";
|
||||
const templateRenderers = import.meta.glob("../../../../../packages/template-*/taro/index.tsx", {
|
||||
eager: true,
|
||||
});
|
||||
const resolvedRenderers = new Map();
|
||||
|
||||
function pageContent({ workspace, page }) {
|
||||
if (page === "inquiry") return <Inquiry workspace={workspace} preview />;
|
||||
@@ -16,21 +17,20 @@ function pageContent({ workspace, page }) {
|
||||
}
|
||||
|
||||
export function resolveTemplateRenderer(workspace) {
|
||||
const config = workspace?.brand?.config;
|
||||
const key =
|
||||
config && typeof config === "object" && !Array.isArray(config)
|
||||
? config.visualTemplateKey
|
||||
: undefined;
|
||||
const key = workspace?.visualTemplate?.key;
|
||||
if (typeof key !== "string") return null;
|
||||
if (resolvedRenderers.has(key)) return resolvedRenderers.get(key);
|
||||
const suffix = `/template-${key}/taro/index.tsx`;
|
||||
const entry = Object.entries(templateRenderers).find(([path]) => path.endsWith(suffix));
|
||||
const TemplatePage = entry?.[1]?.TemplatePage;
|
||||
if (!TemplatePage) return null;
|
||||
return function TemplatePreview(props) {
|
||||
function TemplatePreview(props) {
|
||||
return (
|
||||
<TemplateAssetContext.Provider value={key}>
|
||||
<TemplatePage {...props}>{pageContent(props)}</TemplatePage>
|
||||
</TemplateAssetContext.Provider>
|
||||
);
|
||||
};
|
||||
}
|
||||
resolvedRenderers.set(key, TemplatePreview);
|
||||
return TemplatePreview;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Form, message } from "antd";
|
||||
import { App, Form } from "antd";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import type { QueryClient } from "@tanstack/react-query";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
@@ -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),
|
||||
@@ -98,6 +98,7 @@ interface BrandSaveMutationOptions extends BrandPresentationFormState {
|
||||
config: Record<string, unknown> | null | undefined;
|
||||
sections: TemplateAdminSection[];
|
||||
queryClient: QueryClient;
|
||||
onSaved: () => void;
|
||||
}
|
||||
|
||||
export function useBrandSaveMutation({
|
||||
@@ -105,12 +106,12 @@ export function useBrandSaveMutation({
|
||||
config,
|
||||
sections,
|
||||
queryClient,
|
||||
onSaved,
|
||||
}: BrandSaveMutationOptions) {
|
||||
const { message } = App.useApp();
|
||||
return useMutation({
|
||||
mutationFn: (values: PresentationValues) => {
|
||||
const nextConfig = applyPresentationValues(config, sections, values);
|
||||
const contentConfig = { ...nextConfig };
|
||||
delete contentConfig.visualTemplateKey;
|
||||
const standard = applyStandardBrandValues(
|
||||
brand as unknown as Record<string, unknown>,
|
||||
sections,
|
||||
@@ -122,9 +123,10 @@ export function useBrandSaveMutation({
|
||||
key !== "config" && value !== (brand as unknown as Record<string, unknown>)[key],
|
||||
),
|
||||
);
|
||||
return createApiClient().updateAdminBrand({ ...changed, config: contentConfig });
|
||||
return createApiClient().updateAdminBrand({ ...changed, config: nextConfig });
|
||||
},
|
||||
onSuccess: () => {
|
||||
onSaved();
|
||||
message.success("页面内容已保存为草稿,发布后小程序才会更新");
|
||||
window.dispatchEvent(new Event("template-preview-refresh"));
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-brand"] });
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { createContext } from "react";
|
||||
|
||||
export const TemplatePreviewAssetsContext = createContext<
|
||||
Record<string, { sha256: string; dataUrl: string }> | undefined
|
||||
>(undefined);
|
||||
@@ -1,4 +1,5 @@
|
||||
import React from "react";
|
||||
import { TemplatePreviewAssetsContext } from "./preview-assets.js";
|
||||
|
||||
export const TemplateAssetContext = React.createContext("");
|
||||
const templateAssets = import.meta.glob("../../../../../packages/template-*/miniapp/assets/**/*", {
|
||||
@@ -99,10 +100,17 @@ export function Checkbox({ value, checked }) {
|
||||
export const Label = element("label");
|
||||
export const Image = React.forwardRef(({ mode, src, style, ...props }, ref) => {
|
||||
const key = React.useContext(TemplateAssetContext);
|
||||
const assets = React.useContext(TemplatePreviewAssetsContext);
|
||||
return React.createElement("img", {
|
||||
...props,
|
||||
ref,
|
||||
src: resolveImageSource(src, key),
|
||||
src:
|
||||
assets && typeof src === "string" && src.startsWith("/assets/")
|
||||
? // 导入包资源以 /assets 开头;本地多模板预览的 renderer 可能额外携带包 key 前缀。
|
||||
(assets[src]?.dataUrl ??
|
||||
assets[src.replace(`/assets/${key}/`, "/assets/")]?.dataUrl ??
|
||||
src)
|
||||
: resolveImageSource(src, key),
|
||||
style: { objectFit: mode === "aspectFit" ? "contain" : "cover", ...style },
|
||||
});
|
||||
});
|
||||
@@ -2,13 +2,27 @@ import React from "react";
|
||||
const noop = () => Promise.resolve();
|
||||
export const useRouter = () => ({ params: {} });
|
||||
export const useDidShow = (callback) => React.useEffect(callback, []);
|
||||
// Admin 画布监听该事件完成画布内路由;真实 Taro 端仍使用原始 API。
|
||||
const emitPreviewNavigation = (method, options) => {
|
||||
if (typeof window === "undefined") return;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent("template-preview-navigate", { detail: { method, options } }),
|
||||
);
|
||||
};
|
||||
|
||||
const Taro = {
|
||||
setStorageSync() {},
|
||||
getStorageSync() {
|
||||
return undefined;
|
||||
},
|
||||
removeStorageSync() {},
|
||||
switchTab: noop,
|
||||
navigateTo: noop,
|
||||
switchTab(options) {
|
||||
emitPreviewNavigation("switchTab", options);
|
||||
return Promise.resolve();
|
||||
},
|
||||
navigateTo(options) {
|
||||
emitPreviewNavigation("navigateTo", options);
|
||||
return Promise.resolve();
|
||||
},
|
||||
};
|
||||
export default Taro;
|
||||
@@ -8,10 +8,7 @@ import type {
|
||||
TrustContent,
|
||||
} from "@personal-brand/api-client";
|
||||
import { projectBrandAliases, projectTrustPresentation } from "@personal-brand/api-client";
|
||||
import {
|
||||
presentationFieldName,
|
||||
type PresentationValues,
|
||||
} from "../../lib/presentation/presentation-bindings.js";
|
||||
import { presentationFieldName } from "../../lib/presentation/presentation-bindings.js";
|
||||
import type { RecordDraft } from "./presentation-editor-record-preview.js";
|
||||
|
||||
interface DraftWorkspaceInput {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { useEffect } from "react";
|
||||
import { Modal } from "antd";
|
||||
import { App } from "antd";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
export function useEditorDraft(dirty: boolean) {
|
||||
const { modal } = App.useApp();
|
||||
const navigate = useNavigate();
|
||||
useEffect(() => {
|
||||
if (!dirty) return;
|
||||
@@ -22,7 +23,7 @@ export function useEditorDraft(dirty: boolean) {
|
||||
return;
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
Modal.confirm({
|
||||
modal.confirm({
|
||||
title: "有尚未保存的修改",
|
||||
content: "离开工作台会丢失未保存内容。请先保存,或确认放弃修改。",
|
||||
okText: "放弃修改并继续",
|
||||
@@ -40,7 +41,7 @@ export function useEditorDraft(dirty: boolean) {
|
||||
}, [dirty, navigate]);
|
||||
return (action: () => void) => {
|
||||
if (!dirty) return action();
|
||||
Modal.confirm({
|
||||
modal.confirm({
|
||||
title: "有尚未保存的修改",
|
||||
content: "切换后当前内容可能丢失。请先保存,或确认放弃修改。",
|
||||
okText: "放弃修改并继续",
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
import { Alert, App, 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 { 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 { message } = App.useApp();
|
||||
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
|
||||
title="切换品牌会进入对应品牌的工作区"
|
||||
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 orientation="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,206 @@
|
||||
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 selectedSchemeId = Form.useWatch("templatePackageVersionId", 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
|
||||
title="当前业务类型还没有可用的页面方案"
|
||||
description="请先联系平台管理员发布兼容的页面方案。"
|
||||
/>
|
||||
)
|
||||
) : (
|
||||
<Alert type="info" showIcon title="选择业务类型后,将只显示兼容的页面方案" />
|
||||
)}
|
||||
</AdminSection>
|
||||
|
||||
<AdminSection
|
||||
title="页面方案"
|
||||
description="页面方案决定页面结构、视觉和资源位。版本可在创建后继续升级或切换。"
|
||||
>
|
||||
{schemes.length ? (
|
||||
<Form.Item
|
||||
name="templatePackageVersionId"
|
||||
rules={[{ required: true, message: "请选择页面方案" }]}
|
||||
>
|
||||
<Radio.Group className="admin-stack">
|
||||
<Space orientation="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
|
||||
title="创建品牌不会自动导入示例内容"
|
||||
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.some((scheme) => scheme.templatePackageVersionId === selectedSchemeId)
|
||||
}
|
||||
>
|
||||
创建并进入品牌
|
||||
</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))}`
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { message } from "antd";
|
||||
import { App } from "antd";
|
||||
import { createApiClient } from "../../../lib/api.js";
|
||||
import { readAdminCapability } from "../types.js";
|
||||
import type { CapabilityValues } from "../types.js";
|
||||
@@ -17,6 +17,7 @@ export function useCapabilityQuery() {
|
||||
}
|
||||
|
||||
export function useCapabilityMutation() {
|
||||
const { message } = App.useApp();
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({ key, ...values }: { key: string } & CapabilityValues) =>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Badge, Button, Descriptions, Drawer, Select, Space, Table, message, Input } from "antd";
|
||||
import { App, Badge, Button, Descriptions, Drawer, Select, Space, Table, Input } from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import type { AdminBooking, InquirySubmission } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
@@ -51,6 +51,7 @@ const statusTones: Record<string, StatusTone> = {
|
||||
};
|
||||
|
||||
export function InquiriesPage() {
|
||||
const { message } = App.useApp();
|
||||
const client = createApiClient();
|
||||
const queryClient = useQueryClient();
|
||||
const [status, setStatus] = useState<string>();
|
||||
@@ -213,7 +214,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 +249,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,376 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Alert, App, Button, Card, Collapse, Descriptions, Empty, List, Space, Tag } from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { createApiClient } from "../../lib/api.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 { message, modal } = App.useApp();
|
||||
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",
|
||||
"admin-page-scheme-options",
|
||||
"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 orientation="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
|
||||
title={`发现 ${upgradePreview.data.conflicts.length} 项自定义内容与新版布局存在差异`}
|
||||
description="升级时会全部保留现有内容,不会逐项覆盖。请确认后再执行升级。"
|
||||
/>
|
||||
) : (
|
||||
<Alert type="success" showIcon title="未发现内容绑定冲突" />
|
||||
)}
|
||||
<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 orientation="vertical" size={12} className="admin-full-width">
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
title="此操作会写入当前品牌内容"
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import type { StatusTone } from "../../components/StatusTag.js";
|
||||
|
||||
type ReleaseStatus = MiniAppReleaseTask["status"];
|
||||
|
||||
const STALE_BUILDING_MS = 15 * 60 * 1000;
|
||||
const STALE_BUILDING_MS = 30 * 60 * 1000;
|
||||
|
||||
function isStaleBuilding(task: MiniAppReleaseTask): boolean {
|
||||
if (task.buildStatus !== "building") return false;
|
||||
@@ -29,6 +29,27 @@ const statusView: Record<ReleaseStatus, { label: string; tone: StatusTone; hint:
|
||||
failed: { label: "失败", tone: "error", hint: "上次构建或上传失败,可直接重试。" },
|
||||
};
|
||||
|
||||
const uploadStatusView: Record<
|
||||
NonNullable<MiniAppReleaseTask["uploadStatus"]>,
|
||||
{ label: string; tone: StatusTone }
|
||||
> = {
|
||||
idle: { label: "未上传", tone: "neutral" },
|
||||
uploading: { label: "上传中", tone: "warning" },
|
||||
uploaded: { label: "上传完成", tone: "success" },
|
||||
failed: { label: "上传失败", tone: "error" },
|
||||
timed_out: { label: "上传超时", tone: "error" },
|
||||
};
|
||||
|
||||
const reviewStatusView: Record<
|
||||
NonNullable<MiniAppReleaseTask["reviewStatus"]>,
|
||||
{ label: string; tone: StatusTone }
|
||||
> = {
|
||||
not_submitted: { label: "未提交审核", tone: "neutral" },
|
||||
under_review: { label: "审核中", tone: "warning" },
|
||||
approved: { label: "审核通过", tone: "success" },
|
||||
rejected: { label: "审核驳回", tone: "error" },
|
||||
};
|
||||
|
||||
function formatTime(value: string): string {
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return value;
|
||||
@@ -55,6 +76,8 @@ export function MiniAppReleaseCard({
|
||||
const logRef = useRef<HTMLPreElement>(null);
|
||||
const logs = task.buildLogs ?? [];
|
||||
const status = statusView[task.status];
|
||||
const uploadStatus = task.uploadStatus ? uploadStatusView[task.uploadStatus] : null;
|
||||
const reviewStatus = task.reviewStatus ? reviewStatusView[task.reviewStatus] : null;
|
||||
const building = task.buildStatus === "building";
|
||||
const staleBuilding = isStaleBuilding(task);
|
||||
|
||||
@@ -102,19 +125,26 @@ export function MiniAppReleaseCard({
|
||||
return (
|
||||
<Card size="small" styles={{ body: { padding: 16 } }}>
|
||||
<Flex justify="space-between" align="flex-start" gap={12} wrap>
|
||||
<Space direction="vertical" size={4}>
|
||||
<Space orientation="vertical" size={4}>
|
||||
<Space wrap size={8} align="center">
|
||||
<Typography.Text strong>品牌内容 v{task.version}</Typography.Text>
|
||||
<StatusTag label={status.label} tone={status.tone} />
|
||||
{building && (
|
||||
<StatusTag tone="warning" label={staleBuilding ? "构建已中断" : "构建中"} />
|
||||
)}
|
||||
{!building && task.buildStatus === "success" && (
|
||||
<StatusTag tone="success" label="构建完成" />
|
||||
)}
|
||||
{uploadStatus && <StatusTag tone={uploadStatus.tone} label={uploadStatus.label} />}
|
||||
{reviewStatus && reviewStatusView[task.reviewStatus ?? "not_submitted"] && (
|
||||
<StatusTag tone={reviewStatus.tone} label={reviewStatus.label} />
|
||||
)}
|
||||
{task.weappUploadId && (
|
||||
<Typography.Text type="secondary">微信版本 {task.weappUploadId}</Typography.Text>
|
||||
)}
|
||||
</Space>
|
||||
<span className="admin-text-xs">
|
||||
{staleBuilding ? "超过 15 分钟没有新的构建输出,可能已中断;可直接重试。" : status.hint}
|
||||
{staleBuilding ? "超过 30 分钟没有新的构建输出,可能已中断;可直接重试。" : status.hint}
|
||||
</span>
|
||||
<Tooltip title={`创建于 ${formatTime(task.createdAt)}`}>
|
||||
<span className="admin-text-xs-quiet">更新于 {formatTime(task.updatedAt)}</span>
|
||||
|
||||
@@ -37,7 +37,7 @@ export function MiniAppSettingsTab({
|
||||
type="warning"
|
||||
showIcon
|
||||
className="admin-offset-bottom"
|
||||
message="小程序构建参数未就绪"
|
||||
title="小程序构建参数未就绪"
|
||||
description={settings.buildError}
|
||||
/>
|
||||
) : (
|
||||
@@ -45,7 +45,7 @@ export function MiniAppSettingsTab({
|
||||
type="info"
|
||||
showIcon
|
||||
className="admin-offset-bottom"
|
||||
message={`请求域名 ${settings?.requestDomain ?? "未确认"}`}
|
||||
title={`请求域名 ${settings?.requestDomain ?? "未确认"}`}
|
||||
description="该域名在构建时写入小程序包,必须与微信后台“开发设置 → 服务器域名 → request 合法域名”一致;不一致会导致小程序打开即加载失败。"
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -1,48 +1,30 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Divider,
|
||||
Input,
|
||||
Modal,
|
||||
Form,
|
||||
Select,
|
||||
Space,
|
||||
Spin,
|
||||
Tabs,
|
||||
Typography,
|
||||
message,
|
||||
} from "antd";
|
||||
import type { BrandTemplateKey } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
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";
|
||||
import { usePublicationQueries } from "./use-publication-queries.js";
|
||||
import { usePublicationMutations } from "./use-publication-mutations.js";
|
||||
|
||||
const client = createApiClient();
|
||||
|
||||
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 [note, setNote] = useState("");
|
||||
@@ -50,15 +32,11 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
const [miniAppSettingsForm] = Form.useForm<MiniAppSettingsValues>();
|
||||
const queries = usePublicationQueries(miniAppSettingsForm);
|
||||
const {
|
||||
brand,
|
||||
workspace,
|
||||
catalog,
|
||||
sample,
|
||||
readiness,
|
||||
releases,
|
||||
miniAppReleases,
|
||||
miniAppSettings,
|
||||
templatePreview,
|
||||
loading,
|
||||
error,
|
||||
retry,
|
||||
@@ -67,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",
|
||||
@@ -81,18 +58,11 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
};
|
||||
const mutations = usePublicationMutations({
|
||||
refresh,
|
||||
brandConfig: brand.data?.config,
|
||||
onInstallClose: () => setIndustryTarget(null),
|
||||
onPublishClose: () => setConfirmAction(null),
|
||||
onNoteClear: () => setNote(""),
|
||||
onRollbackClose: () => setRollbackVersion(null),
|
||||
});
|
||||
const {
|
||||
install,
|
||||
upgradeTemplate,
|
||||
rollbackTemplate,
|
||||
selectVisual,
|
||||
importSample,
|
||||
publish,
|
||||
revoke,
|
||||
rollback,
|
||||
@@ -101,20 +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 ??
|
||||
catalog.data?.industries[0]?.key ??
|
||||
null;
|
||||
const visuals = (catalog.data?.visuals ?? []).filter(
|
||||
(item) =>
|
||||
typeof industryKey === "string" && item.supportedIndustryTemplates.includes(industryKey),
|
||||
);
|
||||
const visualKey =
|
||||
typeof brand.data?.config?.visualTemplateKey === "string"
|
||||
? brand.data.config.visualTemplateKey
|
||||
: (visuals[0]?.key ?? null);
|
||||
const currentRelease = releases.data?.find((item) => item.status === "published");
|
||||
const publishedHistory = (releases.data ?? []).filter(
|
||||
(item) => item.status === "published" || item.status === "superseded",
|
||||
@@ -126,100 +82,12 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
isEnabled: boolean;
|
||||
}>;
|
||||
|
||||
const contentTab = null;
|
||||
const miniAppSettingsTab = (
|
||||
<div className="admin-stack admin-stack-lg">
|
||||
<AdminSection
|
||||
title="小程序上传配置"
|
||||
description="AppID 用于服务端调用微信官方上传工具;上传私钥保存前会使用 AES-256-GCM 加密。"
|
||||
>
|
||||
{miniAppSettings.data?.buildError ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
className="admin-offset-bottom"
|
||||
message="小程序构建参数未就绪"
|
||||
description={miniAppSettings.data.buildError}
|
||||
/>
|
||||
) : (
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
className="admin-offset-bottom"
|
||||
message={`请求域名 ${miniAppSettings.data?.requestDomain ?? "未确认"}`}
|
||||
description="该域名在构建时写入小程序包,必须与微信后台“开发设置 → 服务器域名 → request 合法域名”一致;不一致会导致小程序打开即加载失败。"
|
||||
/>
|
||||
)}
|
||||
<Form
|
||||
form={miniAppSettingsForm}
|
||||
layout="vertical"
|
||||
onFinish={(values) => saveMiniAppSettings.mutate(values)}
|
||||
>
|
||||
<Form.Item
|
||||
name="appId"
|
||||
label="微信 AppID"
|
||||
rules={[{ required: true, message: "请输入微信 AppID" }]}
|
||||
>
|
||||
<Input maxLength={100} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="apiBaseUrl"
|
||||
label="小程序请求地址"
|
||||
rules={[
|
||||
{ required: true, message: "请输入小程序请求地址" },
|
||||
{
|
||||
validator: (_rule, value: string) =>
|
||||
!value || /^https:\/\/[^/]+/.test(value)
|
||||
? Promise.resolve()
|
||||
: Promise.reject(
|
||||
new Error(
|
||||
"公网地址必须以 https:// 开头,例如 https://wechat.app.que01.top/api",
|
||||
),
|
||||
),
|
||||
},
|
||||
]}
|
||||
extra="构建时写入小程序包,必须与微信后台“开发设置 → 服务器域名 → request 合法域名”一致。修改后需重新构建并上传代码才生效。"
|
||||
>
|
||||
<Input maxLength={200} placeholder="https://wechat.app.que01.top/api" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="privateKey"
|
||||
label="上传私钥"
|
||||
help={
|
||||
miniAppSettings.data?.hasStoredCredentials
|
||||
? "已加密保存。留空保持现有私钥,输入新值可替换。"
|
||||
: "粘贴微信开发者工具导出的 private.<appid>.key 全文,必须保留换行。"
|
||||
}
|
||||
>
|
||||
<Input.TextArea
|
||||
rows={5}
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
placeholder={"-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----"}
|
||||
className="admin-code-input"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Space>
|
||||
<Button type="primary" loading={saveMiniAppSettings.isPending} htmlType="submit">
|
||||
保存上传配置
|
||||
</Button>
|
||||
{miniAppSettings.data?.hasStoredCredentials ? (
|
||||
<StatusTag tone="success" label="已加密保存上传凭据" />
|
||||
) : (
|
||||
<StatusTag tone="warning" label="未配置上传私钥" />
|
||||
)}
|
||||
</Space>
|
||||
<MutationError error={saveMiniAppSettings.error} />
|
||||
</Form>
|
||||
</AdminSection>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<QueryState loading={loading} error={error} onRetry={retry}>
|
||||
<AdminPageHeader
|
||||
title="配置与发布"
|
||||
description="编辑内容不会立即影响小程序;确认后统一发布当前品牌。"
|
||||
title="内容与发布"
|
||||
description="检查当前草稿并发布品牌内容;页面方案与内容发布互不混用。"
|
||||
extra={<Button onClick={() => navigate("/admin/page-scheme")}>管理页面方案</Button>}
|
||||
/>
|
||||
<Tabs
|
||||
activeKey={activeTab}
|
||||
@@ -228,321 +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={visuals.map((item) => ({ value: item.key, label: item.name }))}
|
||||
onChange={(key) => selectVisual.mutate(key)}
|
||||
/>
|
||||
</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 ? (
|
||||
<Button
|
||||
type="primary"
|
||||
size="small"
|
||||
disabled={!canManageTemplate}
|
||||
loading={upgradeTemplate.isPending}
|
||||
onClick={() => upgradeTemplate.mutate()}
|
||||
>
|
||||
升级模板
|
||||
</Button>
|
||||
) : (
|
||||
<StatusTag tone="success" label="已是最新版本" />
|
||||
)}
|
||||
{templatePreview.data?.canRollback ? (
|
||||
<Button
|
||||
danger
|
||||
size="small"
|
||||
disabled={!canManageTemplate}
|
||||
loading={rollbackTemplate.isPending}
|
||||
onClick={() => rollbackTemplate.mutate()}
|
||||
>
|
||||
回滚到上一版
|
||||
</Button>
|
||||
) : null}
|
||||
</Space>
|
||||
<p className="admin-section-description admin-offset-top-sm">
|
||||
行业模板随品牌身份固定,只能升级版本、不能更换行业;升级只补充字段与模块,不覆盖已有内容。视觉模板只替换排版风格。
|
||||
</p>
|
||||
<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()}
|
||||
>
|
||||
导入示例内容
|
||||
</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">
|
||||
将向草稿添加{" "}
|
||||
{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}
|
||||
@@ -555,7 +277,7 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
{confirmAction === "revoke" ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
message="撤回后,小程序将显示品牌尚未发布,新的咨询和预约会停止受理。"
|
||||
title="撤回后,小程序将显示品牌尚未发布,新的咨询和预约会停止受理。"
|
||||
/>
|
||||
) : (
|
||||
<div className="admin-stack">
|
||||
@@ -578,15 +300,6 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
>
|
||||
将 v{rollbackVersion} 重新发布为新版本;当前草稿不会被覆盖。
|
||||
</Modal>
|
||||
<Modal
|
||||
title="确认安装行业模板"
|
||||
open={industryTarget !== null}
|
||||
onCancel={() => setIndustryTarget(null)}
|
||||
onOk={() => industryTarget && install.mutate(industryTarget)}
|
||||
confirmLoading={install.isPending}
|
||||
>
|
||||
模板会更新当前品牌的草稿结构,不会立即改变已发布的小程序。请安装后核对业务内容与视觉模板。
|
||||
</Modal>
|
||||
</QueryState>
|
||||
);
|
||||
}
|
||||