Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12a3bf2f3b | ||
|
|
ca6d1712bd | ||
|
|
e7ef0b3ce5 | ||
|
|
b82aa12875 | ||
|
|
b43b6f2785 | ||
|
|
965dd10219 | ||
|
|
371689484e | ||
|
|
d923b8cea9 | ||
|
|
a1b29cedee | ||
|
|
34504c0b44 | ||
|
|
3af5611da5 | ||
|
|
2fe108d66a | ||
|
|
4cd3749806 | ||
|
|
00aeaa3cb1 | ||
|
|
b190f2758a | ||
|
|
4d9c84defc | ||
|
|
b4e3e86dcd | ||
|
|
5051839986 | ||
|
|
84522a8908 | ||
|
|
18bcdbeb00 | ||
|
|
040504774d | ||
|
|
1001c43af6 | ||
|
|
121148f6cf | ||
|
|
a08a2f0f98 | ||
|
|
669d4a7de6 | ||
|
|
ec0cf78d69 | ||
|
|
658c94a4e9 | ||
|
|
261a33a5ca | ||
|
|
f28332f49a | ||
|
|
c33c9cbd63 | ||
|
|
b742fc70b5 | ||
|
|
6bd91d5ee8 | ||
|
|
cdc7b407bc | ||
|
|
9bfa4bb736 | ||
|
|
c04ab1ef60 | ||
|
|
4a6bc42635 | ||
|
|
b86c661af5 | ||
|
|
71c068966e | ||
|
|
784b9cbac8 | ||
|
|
2325214078 | ||
|
|
e194e605f9 | ||
|
|
82381a5e93 | ||
|
|
ec6b0dee3e | ||
|
|
060bad2df0 | ||
|
|
adcaa12970 | ||
|
|
330d67adc1 | ||
|
|
737010ea03 | ||
|
|
ec84988e57 | ||
|
|
f266bda3a9 | ||
|
|
88ab2561bd | ||
|
|
98c7701ccd | ||
|
|
e752a3b7ed | ||
|
|
9389235a6c | ||
|
|
a293591dba | ||
|
|
8c5860699f | ||
|
|
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 | ||
|
|
bf4bbf81c7 | ||
|
|
0f6ad8b993 | ||
|
|
2ad009f5c0 | ||
|
|
6f18c67315 | ||
|
|
b23120477f | ||
|
|
12bc263d3b | ||
|
|
7c0f22ad7a | ||
|
|
8973338c64 | ||
|
|
476e3d93dd | ||
|
|
3ae7b462f5 | ||
|
|
f158f906d5 | ||
|
|
aaeec14733 | ||
|
|
6073e72940 | ||
|
|
896f3240f9 | ||
|
|
7b1e9eee47 | ||
|
|
47d6309cba | ||
|
|
ebab77057a | ||
|
|
3ef46b0aa8 | ||
|
|
2f26828f09 | ||
|
|
bb94d80e13 | ||
|
|
29e5666d74 | ||
|
|
d34cb182e3 | ||
|
|
4d1cd8f365 | ||
|
|
9ad2776515 | ||
|
|
53713e5935 | ||
|
|
ac3f433ee6 | ||
|
|
44fe7a0142 | ||
|
|
f52577ff9e | ||
|
|
8e90b8ca09 | ||
|
|
998e32e49c | ||
|
|
8b4d27b0ee | ||
|
|
26f1157083 | ||
|
|
ad949ab370 | ||
|
|
d5a84b51a7 | ||
|
|
760f41a584 | ||
|
|
20f880a761 | ||
|
|
ab1531d9b0 | ||
|
|
3d0252d187 | ||
|
|
526a9db789 | ||
|
|
9b35b8e7a7 | ||
|
|
14b6541bee | ||
|
|
00edcedbcf | ||
|
|
dcf1d76944 | ||
|
|
7f67f4d685 | ||
|
|
d2ca528543 | ||
|
|
47a24e0d53 | ||
|
|
c78deafee3 | ||
|
|
3330b536dc | ||
|
|
07629a4596 | ||
|
|
5c6ad02f46 | ||
|
|
048c42207c | ||
|
|
67735afd45 | ||
|
|
0574a85632 | ||
|
|
18ddf125be | ||
|
|
bb0709b8cc | ||
|
|
076c6124c8 | ||
|
|
89fdfd7d83 | ||
|
|
f87b26b201 | ||
|
|
466dc66907 | ||
|
|
357f271639 | ||
|
|
f3adf7bc15 | ||
|
|
4512d2601d | ||
|
|
d0902d6568 | ||
|
|
7e1dd543fb | ||
|
|
3003e7801d | ||
|
|
567921e726 | ||
|
|
03f947e9b8 | ||
|
|
6ac2d9421b | ||
|
|
aa42e7b866 | ||
|
|
e09b56e0f3 | ||
|
|
84956b8fe2 | ||
|
|
f57c0ca0ea | ||
|
|
9c15a822e9 | ||
|
|
85f37d2eae | ||
|
|
222055595c | ||
|
|
b1d5c2b4b0 | ||
|
|
787a50369f | ||
|
|
422162e580 | ||
|
|
26bcb2b66e | ||
|
|
91322fa9a0 |
No files matched your search
@@ -0,0 +1,260 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"scope": "模板完成证据登记,保留命令、日志与产物哈希",
|
||||||
|
"generatedAt": "2026-10-23T07:40:54.556Z",
|
||||||
|
"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": "f0bb03d734cf303b75be41bbcab6eea15f5479ac197b16c82f78e1faad71b17e"
|
||||||
|
}
|
||||||
@@ -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 |
@@ -0,0 +1,25 @@
|
|||||||
|
.agents
|
||||||
|
.aws
|
||||||
|
.claude
|
||||||
|
.codex
|
||||||
|
.codex-tasks
|
||||||
|
.git
|
||||||
|
.github
|
||||||
|
.turbo
|
||||||
|
.worktrees
|
||||||
|
coverage
|
||||||
|
dist
|
||||||
|
pnpm-lock.yaml.bak
|
||||||
|
docker-compose.override.yml
|
||||||
|
docker-compose.prod.yml
|
||||||
|
docs
|
||||||
|
media
|
||||||
|
node_modules
|
||||||
|
prototype
|
||||||
|
scripts/deploy/*.test.mjs
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.production.example
|
||||||
|
**/node_modules
|
||||||
|
**/dist
|
||||||
|
!apps/api/prisma/assets/**
|
||||||
@@ -6,13 +6,32 @@ POSTGRES_DB=personal_brand
|
|||||||
POSTGRES_PORT=5432
|
POSTGRES_PORT=5432
|
||||||
API_PORT=3001
|
API_PORT=3001
|
||||||
API_PREFIX=
|
API_PREFIX=
|
||||||
|
CORS_ORIGINS=http://localhost:3000
|
||||||
ADMIN_PORT=3000
|
ADMIN_PORT=3000
|
||||||
SESSION_SECRET=replace-with-a-long-random-value
|
SESSION_SECRET=replace-with-a-long-random-value
|
||||||
|
# 单实例使用 memory;多实例部署改用 postgres 并先执行数据库迁移
|
||||||
|
CLIENT_ERROR_THROTTLE_STORE=memory
|
||||||
DEFAULT_BRAND_ID=00000000-0000-0000-0000-000000000001
|
DEFAULT_BRAND_ID=00000000-0000-0000-0000-000000000001
|
||||||
|
TEMPLATE_ARTIFACT_ROOT=/var/lib/personal-brand/template-artifacts
|
||||||
SEED_ADMIN_PASSWORD=change-me-now-123
|
SEED_ADMIN_PASSWORD=change-me-now-123
|
||||||
OBJECT_STORAGE_ENDPOINT=
|
OBJECT_STORAGE_ENDPOINT=http://localhost:9000
|
||||||
OBJECT_STORAGE_BUCKET=
|
OBJECT_STORAGE_PUBLIC_URL=http://localhost:9000/personal-brand-media
|
||||||
OBJECT_STORAGE_ACCESS_KEY=
|
OBJECT_STORAGE_BUCKET=personal-brand-media
|
||||||
OBJECT_STORAGE_SECRET_KEY=
|
OBJECT_STORAGE_ACCESS_KEY=minioadmin
|
||||||
|
OBJECT_STORAGE_SECRET_KEY=minioadmin
|
||||||
WECHAT_APP_ID=
|
WECHAT_APP_ID=
|
||||||
WECHAT_APP_SECRET=
|
WECHAT_APP_SECRET=
|
||||||
|
WECHAT_UPLOAD_PRIVATE_KEY=
|
||||||
|
MINIAPP_CREDENTIAL_ENCRYPTION_KEY=replace-with-32-byte-random-secret
|
||||||
|
# 小程序代码构建产物根目录,相对路径按仓库根目录解析;默认 apps/taro/dist
|
||||||
|
# MINIAPP_ARTIFACT_ROOT=apps/taro/dist
|
||||||
|
# 构建超过该毫秒数没有进度更新即视为中断,允许重新上传;默认 15 分钟
|
||||||
|
# MINIAPP_BUILD_STALE_MS=900000
|
||||||
|
# 小程序请求地址在后台「小程序上传配置」维护,这里仅为回落值;
|
||||||
|
# 未设置时由 PUBLIC_BASE_URL + MINIAPP_API_PATH 推导
|
||||||
|
# MINIAPP_API_BASE_URL=https://wechat.app.que01.top/api
|
||||||
|
# MINIAPP_API_PATH=/api
|
||||||
|
# 单个品牌的 AppID 在后台“小程序上传配置”维护,这里只作为回落值
|
||||||
|
# WEAPP_APP_ID=
|
||||||
|
# 上传子进程工作目录;miniprogram-ci 的编译缓存放这里,默认系统临时目录
|
||||||
|
# MINIAPP_UPLOAD_WORKSPACE=/tmp/personal-brand-miniapp-upload
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
NODE_ENV=production
|
||||||
|
POSTGRES_USER=personal_brand
|
||||||
|
POSTGRES_PASSWORD=replace-with-a-long-database-password
|
||||||
|
POSTGRES_DB=personal_brand
|
||||||
|
POSTGRES_PORT=5432
|
||||||
|
|
||||||
|
DATABASE_URL=postgresql://personal_brand:replace-with-a-long-database-password@127.0.0.1:5432/personal_brand?schema=public
|
||||||
|
SESSION_SECRET=replace-with-at-least-32-random-characters
|
||||||
|
# 单实例使用 memory;多实例部署改用 postgres 并先执行数据库迁移
|
||||||
|
CLIENT_ERROR_THROTTLE_STORE=memory
|
||||||
|
DEFAULT_BRAND_ID=00000000-0000-0000-0000-000000000001
|
||||||
|
SEED_ADMIN_PASSWORD=replace-with-a-one-time-initial-password
|
||||||
|
SEED_MODE=skip
|
||||||
|
|
||||||
|
API_PORT=3001
|
||||||
|
API_PREFIX=
|
||||||
|
CORS_ORIGINS=
|
||||||
|
|
||||||
|
LOCAL_MEDIA_ROOT=/home/ubuntu/persional-brand/media
|
||||||
|
LOCAL_MEDIA_BASE_URL=/media
|
||||||
|
OBJECT_STORAGE_ENDPOINT=
|
||||||
|
OBJECT_STORAGE_PUBLIC_URL=
|
||||||
|
OBJECT_STORAGE_BUCKET=
|
||||||
|
OBJECT_STORAGE_ACCESS_KEY=
|
||||||
|
OBJECT_STORAGE_SECRET_KEY=
|
||||||
|
OBJECT_STORAGE_REGION=us-east-1
|
||||||
|
|
||||||
|
WECHAT_APP_ID=
|
||||||
|
WECHAT_APP_SECRET=
|
||||||
|
|
||||||
|
# 小程序请求地址正常情况下在后台「小程序上传配置」维护;
|
||||||
|
# 这里仅作为后台未配置时的回落值(否则由 PUBLIC_BASE_URL + /api 推导)
|
||||||
|
# MINIAPP_API_BASE_URL=https://wechat.app.que01.top/api
|
||||||
|
# MINIAPP_BUILD_STALE_MS=900000
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
# 纯文档提交不占用 runner;需要状态时用 workflow_dispatch 手动触发。
|
||||||
|
paths-ignore:
|
||||||
|
- "**.md"
|
||||||
|
# PR 不设置 paths-ignore:branch protection 的 required checks 必须始终上报,
|
||||||
|
# 否则纯文档 PR 会永远等不到状态检查而无法合并。
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ci-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
NODE_VERSION: "24"
|
||||||
|
PNPM_VERSION: "9.15.0"
|
||||||
|
# runner 任务容器把该路径 bind mount 到宿主机共享 store,避免每个 job 重复下载依赖。
|
||||||
|
npm_config_store_dir: /workspace/.pnpm-store
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
static:
|
||||||
|
name: Static checks
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 40
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: ${{ env.PNPM_VERSION }}
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
- name: Restore Turbo cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: .turbo/cache
|
||||||
|
key: turbo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
turbo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}-
|
||||||
|
turbo-${{ runner.os }}-${{ runner.arch }}-
|
||||||
|
- run: pnpm install --frozen-lockfile
|
||||||
|
- run: pnpm check
|
||||||
|
- run: pnpm test:api-routes
|
||||||
|
- run: pnpm test:deploy
|
||||||
|
- 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:
|
||||||
|
name: Production build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 60
|
||||||
|
needs: [static]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: ${{ env.PNPM_VERSION }}
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
- name: Restore Turbo cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: .turbo/cache
|
||||||
|
key: turbo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
turbo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}-
|
||||||
|
turbo-${{ runner.os }}-${{ runner.arch }}-
|
||||||
|
- run: pnpm install --frozen-lockfile
|
||||||
|
- run: pnpm build
|
||||||
|
- run: pnpm build:admin:preview
|
||||||
|
- run: pnpm validate:template-release
|
||||||
|
|
||||||
|
browser-smoke:
|
||||||
|
name: Browser smoke
|
||||||
|
# 只在 PR 和手动触发时运行,避免 main 合并后重复消耗共享生产 runner。
|
||||||
|
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 30
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: ${{ env.PNPM_VERSION }}
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
- run: pnpm install --frozen-lockfile
|
||||||
|
- name: Cache Playwright browsers
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.cache/ms-playwright
|
||||||
|
key: playwright-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}
|
||||||
|
- name: Install Chromium
|
||||||
|
# 系统依赖与同版本 Chromium 已预装在 personal-brand-ci:node24 中;这里只做版本兜底。
|
||||||
|
run: pnpm --filter @personal-brand/taro exec playwright install chromium
|
||||||
|
- name: Run PR browser smoke
|
||||||
|
run: pnpm test:browser:smoke
|
||||||
|
|
||||||
|
api:
|
||||||
|
name: API integration
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 45
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:16-alpine
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
POSTGRES_DB: personal_brand
|
||||||
|
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@postgres: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
|
||||||
|
with:
|
||||||
|
version: ${{ env.PNPM_VERSION }}
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
- 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
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# 提交前让模板完成证据的源码哈希跟随当前工作树,避免额外的 chore 提交。
|
||||||
|
set -e
|
||||||
|
[ -f scripts/template-evidence-refresh.mjs ] || exit 0
|
||||||
|
command -v node >/dev/null 2>&1 || exit 0
|
||||||
|
node scripts/template-evidence-refresh.mjs --stage
|
||||||
@@ -2,11 +2,13 @@ node_modules/
|
|||||||
.pnpm-store/
|
.pnpm-store/
|
||||||
.turbo/
|
.turbo/
|
||||||
dist/
|
dist/
|
||||||
|
packages/config/dist/
|
||||||
.next/
|
.next/
|
||||||
coverage/
|
coverage/
|
||||||
.env
|
.env
|
||||||
.env.*
|
|
||||||
!.env.example
|
!.env.example
|
||||||
|
.env.production
|
||||||
|
!.env.production.example
|
||||||
*.log
|
*.log
|
||||||
.DS_Store
|
.DS_Store
|
||||||
apps/miniapp/miniprogram_npm/
|
apps/miniapp/miniprogram_npm/
|
||||||
@@ -18,5 +20,14 @@ apps/admin/public/template-preview/
|
|||||||
|
|
||||||
apps/taro/test-results/
|
apps/taro/test-results/
|
||||||
apps/taro/playwright-report/
|
apps/taro/playwright-report/
|
||||||
|
media/
|
||||||
|
|
||||||
**/.swc/
|
**/.swc/
|
||||||
|
.codex-tasks/
|
||||||
|
!.codex-tasks/template-audit-execution/
|
||||||
|
!.codex-tasks/template-audit-execution/raw/
|
||||||
|
!.codex-tasks/template-audit-execution/raw/completion-evidence.json
|
||||||
|
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.
|
- 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.
|
- 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.
|
- 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.
|
- `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.
|
- 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.
|
- Keep personal-brand trust details explicit: biography, positioning, credentials, portfolio/proof, process, expectations, availability, contact methods, and clear follow-up status.
|
||||||
|
|||||||
@@ -1,104 +1,166 @@
|
|||||||
# Project Status
|
# Project Status
|
||||||
|
|
||||||
最后更新:2026-09-19
|
最后更新:2026-10-21
|
||||||
|
|
||||||
## 当前目标
|
|
||||||
|
|
||||||
先为餐饮摊主朋友交付一个真正能带来订单的个人品牌小程序,再根据真实使用把通用能力产品化。产品方的收益、运营和平台化目标不能牺牲朋友的实际使用效果。
|
|
||||||
|
|
||||||
## 当前阶段
|
## 当前阶段
|
||||||
|
|
||||||
后端基础、数据库环境和订单 API 已完成首轮验证,管理后台和小程序静态页面已接入首版结构,下一步进行真实资源与微信登录/预约联调。
|
系统已从“餐饮试点小程序”演进为多模板个人品牌平台。当前已完成统一模板契约收口、模板完成证据门禁、品牌与页面方案拆分、管理员登录态撤销和 release 版本一致性修复。
|
||||||
|
|
||||||
## 已完成
|
ADR 0033 已落地:
|
||||||
|
|
||||||
- 产品 PRD、原型规格、架构决策、数据/API 设计和实施计划。
|
- “表达方式”已从 Admin 源码移除。
|
||||||
- 餐饮试点画像与首轮需求访谈决策。
|
- “业务类型”和“页面方案”是两个独立概念。
|
||||||
- 可点击低保真原型:`prototype/index.html`。
|
- 新增“创建品牌”和“页面方案”页面。
|
||||||
- Git 仓库、`main` 分支和远程仓库。
|
- 创建品牌不会自动导入示例内容。
|
||||||
- pnpm workspace + Turborepo Monorepo。
|
- `linjing-editorial` 只兼容 `doors`,不再兼容 `personal`。
|
||||||
- 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 代码审查并修复关键认证和权限问题。
|
|
||||||
|
|
||||||
## 最近提交
|
## 当前能力
|
||||||
|
|
||||||
|
- 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 守卫。
|
||||||
|
- Gitea Actions CI 已在 `oracle_arm` 自托管 runner 上落地,`static` / `build` / `api` 三个 job 已完整通过(run 21);详见 `docs/ci.md`。
|
||||||
|
- 小程序构建、上传任务状态机、attempt lease 和失败记录。
|
||||||
|
- Admin/Customer token version:修改 admin 密码或调用 logout 后旧 token 立即失效;无 membership 的账号不会自动获得 owner 权限。
|
||||||
|
- `visualPresentation` 已进入唯一 `template.json` 契约,旧手写 visual manifest 优先路径已删除。
|
||||||
|
|
||||||
|
## 生产状态
|
||||||
|
|
||||||
|
当前生产 release:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
fee3c77 fix: 按设计图优化预约套餐数量和商品卡
|
20261021034700-adcaa12970af
|
||||||
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
|
|
||||||
```
|
```
|
||||||
|
|
||||||
远程:`https://git.app.que01.top/que01/persionalBrand.git`
|
该 release 由提交 `adcaa12` 构建,包含后台渲染异常上报(`POST /admin/client-errors`,含去重与限流)、Admin 列表接口运行时响应契约校验,以及前序 release 的创建品牌与页面方案交互修复、Admin 渲染错误边界和异常数据容忍。部署后已完成公开路由健康检查,并确认未登录调用异常上报接口返回 `401 HTTP_401`,说明新接口已进入生产路由。
|
||||||
|
|
||||||
## 下一步优先级
|
生产健康检查:
|
||||||
|
|
||||||
1. 接入真实品牌图片、电话和微信配置,并替换当前图片占位区域。
|
```text
|
||||||
2. 在微信开发者工具/真机完成 `wx.login`、预约提交、订单查询和取消联调。
|
api=online
|
||||||
3. 完善管理后台订单详情、筛选和状态处理视觉页面。
|
pm2-autostart=enabled
|
||||||
4. 继续补充页面截图回归和真实素材下的移动端溢出检查。
|
admin=active
|
||||||
|
database=running
|
||||||
## 未决问题
|
backups=7
|
||||||
|
/admin/ 200
|
||||||
- 普通套餐采用固定菜单、每日菜单,还是固定套餐加每日可用状态。
|
/template-preview/ 200
|
||||||
- 朋友最终品牌名称、图片、联系方式、营业时间和配送范围。
|
/api/health 200
|
||||||
- 微信小程序主体、AppID、服务类目和订阅消息模板是否可用。
|
/media/seed/food-package-02.jpg 200
|
||||||
- 生产部署使用哪家 PostgreSQL、对象存储和 API 托管服务。
|
/admin/client-errors(无登录态) 401
|
||||||
- 当前 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
|
|
||||||
```
|
```
|
||||||
|
|
||||||
有 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` 不出现林境页面方案。
|
||||||
|
- 切换业务类型后清除不兼容的页面方案选择,提交按钮禁用。
|
||||||
|
- 创建失败时保留用户输入并显示错误。
|
||||||
|
- 页面方案切换和升级提交正确版本、校验和与冲突保留参数。
|
||||||
|
- 操作成功后刷新工作区、页面方案选项和升级预览查询。
|
||||||
|
|
||||||
|
`apps/taro/test/browser/publication-release.spec.ts` 覆盖内容与发布流程:
|
||||||
|
|
||||||
|
- 发布按钮按 readiness 启用;空备注发布提交空 body,不写入 `note`。
|
||||||
|
- 备注提交前去除首尾空格。
|
||||||
|
- 发布失败时保留备注与确认弹窗,并显示服务端错误。
|
||||||
|
- 撤回当前版本、恢复历史版本分别提交正确路径与版本号。
|
||||||
|
- 小程序配置页从服务端回填设置,只提交用户新输入的私钥。
|
||||||
|
|
||||||
|
该回归同时发现并修复了 `MiniAppSettingsTab` 的 `Form` 实例归属问题:表单实例原本在父组件创建、子组件懒挂载,触发 antd `useForm` 未连接警告;现已下沉到配置页自身。
|
||||||
|
|
||||||
|
## Admin 渲染错误边界
|
||||||
|
|
||||||
|
后台此前没有任何 React error boundary:任一页面在渲染阶段抛错(例如接口返回了形状不符的数据)都会导致整页白屏,用户只能从控制台看到堆栈。现在按两级兜底:
|
||||||
|
|
||||||
|
- `Root` 上的整页边界:后台外壳自身渲染失败时显示错误页,提供「重新加载页面」和「返回概览」。
|
||||||
|
- `Dashboard` 内容区的页面边界:单个业务页面失败时保留侧边栏与顶部导航,提供「重试」和「重新加载页面」,切换路由后自动复位。
|
||||||
|
- 错误页展示可复制的错误编号,日志侧输出同一编号、堆栈与组件栈,便于把用户反馈和服务器日志对应起来。
|
||||||
|
- 开发环境额外显示原始错误信息;生产环境不暴露堆栈。
|
||||||
|
|
||||||
|
外壳数据不再直接信任接口形状:`apps/admin/src/lib/brand-switcher.ts` 只接受完整成员记录,跳过异常条目并对重复品牌、缺失名称和非字符串品牌名做稳定收敛,避免单条脏数据让整个后台外壳崩溃。错误边界只作为最后一道防线。
|
||||||
|
|
||||||
|
`apps/taro/test/browser/admin-error-boundary.spec.ts` 覆盖:
|
||||||
|
|
||||||
|
- 品牌成员与品牌名称返回异常结构时,后台外壳仍正常渲染。
|
||||||
|
- 业务页面数据异常时保留导航,重试仍失败保持错误页,重新加载后恢复。
|
||||||
|
|
||||||
|
`apps/admin/test/brand-switcher.test.mjs` 覆盖选项转换的异常条目、非数组、重复品牌、缺失名称与非字符串名称。
|
||||||
|
|
||||||
|
## Ant Design 6 弃用项
|
||||||
|
|
||||||
|
- `Alert` 统一使用 `title`,`Space` 统一使用 `orientation`。
|
||||||
|
- 提示与确认框改为 `App.useApp()` 实例,删除静态 `message` 转出口 `components/AdminMessage.ts`。
|
||||||
|
- `apps/admin/test/antd-deprecations.test.mjs` 作为静态门禁,阻止静态 `message`、`Modal.confirm`、`Alert.message`、`Space.direction` 回流。
|
||||||
|
- `List` 仍保留:`Listy` 是虚拟滚动组件,API 不兼容,当前仅用于小数据量场景;已记录在 `docs/adr/0034-antd6-static-api-and-list.md`,升级 Ant Design 7 前重新评估。
|
||||||
|
|
||||||
|
## 已验证门禁
|
||||||
|
|
||||||
|
- `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`
|
||||||
|
- `publication-release.spec.ts`
|
||||||
|
- `admin-error-boundary.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 记录在安全审计文档。
|
||||||
|
|
||||||
|
## 未决事项
|
||||||
|
|
||||||
|
- `miniprogram-ci` 上游发布修复版本后,需要移除对应的 audit ignore、风险登记和本地 patch。
|
||||||
|
- Gitea SSH 直连仍受 OCI 安全列表限制;当前本机通过 `oracle_arm` ProxyCommand 转发访问,不阻塞业务。
|
||||||
|
- CI 已加入 audit 和三套模板矩阵构建;后续可继续拆分更细粒度的 smoke/visual matrix。
|
||||||
@@ -3,3 +3,4 @@ VITE_API_BASE_URL=/api
|
|||||||
VITE_DEV_API_TARGET=http://localhost:3001
|
VITE_DEV_API_TARGET=http://localhost:3001
|
||||||
ADMIN_PORT=3000
|
ADMIN_PORT=3000
|
||||||
VITE_TEMPLATE_PREVIEW_URL=http://localhost:3002
|
VITE_TEMPLATE_PREVIEW_URL=http://localhost:3002
|
||||||
|
VITE_MEDIA_PROXY_TARGET=http://localhost:9000
|
||||||
@@ -0,0 +1,420 @@
|
|||||||
|
# Admin Design Language
|
||||||
|
|
||||||
|
本文件是 `@personal-brand/admin` 管理后台的视觉与交互规范,是后台 UI 的唯一设计来源。
|
||||||
|
|
||||||
|
设计目标:**简洁、干净**。留白充足、层级靠排版建立、装饰最少。信息架构与业务语义不在本文件范围内,如需变更请走产品文档。
|
||||||
|
|
||||||
|
适用范围:`apps/admin/src` 下所有页面、组件与样式。新增 UI 前先读本文件,冲突以本文件为准。
|
||||||
|
|
||||||
|
- 本文件同时作为 AI 设计工具的规范输入:在 MasterGo「AI 快搭」中直接上传本文件即可,无需重复描述视觉规则。生成提示词见 `docs/design/admin-mastergo-guide.md`。
|
||||||
|
- 技术约束:antd 6 + React 19 + React Router 7 + TanStack Query 5。不引入新的 UI 库、状态管理、校验或路由方案。
|
||||||
|
- 主题令牌统一在根节点通过 `ConfigProvider` 注入,页面与组件内不得写零散色值。
|
||||||
|
- 共享视觉元素放 `apps/admin/src/components/`,页面专属组件留在各自的 `features/` 目录。
|
||||||
|
- 中文界面。桌面优先,最小可用宽度 1024px;窄屏允许侧栏折叠,不提供移动端专用布局。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. 颜色
|
||||||
|
|
||||||
|
中性灰打底,只保留一个强调色。禁止渐变、彩色大面积色块、玻璃拟态。
|
||||||
|
|
||||||
|
### 基础色
|
||||||
|
|
||||||
|
| 用途 | 令牌 | 值 |
|
||||||
|
| ---------------------- | ---------------------- | --------- |
|
||||||
|
| 页面底色 | `colorBgLayout` | `#F7F8FA` |
|
||||||
|
| 卡片/容器底色 | `colorBgContainer` | `#FFFFFF` |
|
||||||
|
| 次级填充(表头、悬停) | `colorFillQuaternary` | `#FAFAFB` |
|
||||||
|
| 悬停底色 | `colorFillTertiary` | `#F7F8FA` |
|
||||||
|
| 容器边框 | `colorBorderSecondary` | `#E7E9EC` |
|
||||||
|
| 行分隔线 | `colorSplit` | `#F0F1F3` |
|
||||||
|
| 控件边框 | `colorBorder` | `#D8DBE0` |
|
||||||
|
|
||||||
|
### 文字色
|
||||||
|
|
||||||
|
| 用途 | 令牌 | 值 |
|
||||||
|
| ------------- | --------------------- | --------- |
|
||||||
|
| 主文字 | `colorText` | `#1C1F23` |
|
||||||
|
| 次要文字 | `colorTextSecondary` | `#6B7280` |
|
||||||
|
| 辅助/占位文字 | `colorTextTertiary` | `#9AA1AC` |
|
||||||
|
| 禁用文字 | `colorTextQuaternary` | `#C3C7CF` |
|
||||||
|
|
||||||
|
### 强调色
|
||||||
|
|
||||||
|
| 用途 | 令牌 | 值 |
|
||||||
|
| ------------- | -------------------- | --------- |
|
||||||
|
| 主色 | `colorPrimary` | `#2563EB` |
|
||||||
|
| 主色悬停 | `colorPrimaryHover` | `#1D4ED8` |
|
||||||
|
| 主色按下 | `colorPrimaryActive` | `#1E40AF` |
|
||||||
|
| 选中底色 | `colorPrimaryBg` | `#EFF4FF` |
|
||||||
|
| 选中/链接文字 | `colorLink` | `#2563EB` |
|
||||||
|
|
||||||
|
强调色只用于:主按钮、选中态、链接、关键数字、聚焦描边。不得用于大面积背景。
|
||||||
|
|
||||||
|
例外:小程序预览区(iframe / 模拟器内)显示的是模板自身的品牌色(例如餐饮模板的砖红 `#B54A2C`),与后台无关,不视为违规,也不要「修正」成后台强调色。
|
||||||
|
|
||||||
|
### 状态色
|
||||||
|
|
||||||
|
状态一律用「浅底 + 深字」,不使用 antd 的实心鲜艳 Tag。
|
||||||
|
|
||||||
|
| 语义 | 底色 | 边框 | 文字色 |
|
||||||
|
| ------------- | --------- | --------- | --------- |
|
||||||
|
| 成功 / 已发布 | `#ECFDF3` | `#ABEFC6` | `#067647` |
|
||||||
|
| 警告 / 进行中 | `#FFFAEB` | `#FEDF89` | `#B54708` |
|
||||||
|
| 错误 / 失败 | `#FEF3F2` | `#FBD5D1` | `#B42318` |
|
||||||
|
| 中性 / 草稿 | `#F2F4F7` | `#E7E9EC` | `#475467` |
|
||||||
|
| 信息 / 系统态 | `#EFF4FF` | `#B2CCFF` | `#2563EB` |
|
||||||
|
|
||||||
|
- 底色 + 边框 + 深色文字三件套同时用于 `StatusTag`、`Alert`、错误条与空状态,不得混用其他色阶。
|
||||||
|
- 需要中间调的场合(图标、进度条完成态)使用中间色:成功 `#12B76A`、警告 `#F79009`、错误 `#F04438`、信息 `#2563EB`。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. 排版
|
||||||
|
|
||||||
|
系统无衬线字体栈:`Inter`、`PingFang SC`、`Noto Sans SC`、`sans-serif`。
|
||||||
|
|
||||||
|
| 角色 | 字号 | 字重 | 行高 |
|
||||||
|
| ------------------ | ---- | ---- | ---- |
|
||||||
|
| 页面标题 | 20px | 600 | 1.4 |
|
||||||
|
| 区块/卡片标题 | 16px | 600 | 1.45 |
|
||||||
|
| 卡片内对象主标题 | 18px | 600 | 1.45 |
|
||||||
|
| 强调正文、品牌名 | 15px | 600 | 1.5 |
|
||||||
|
| 正文 | 14px | 400 | 1.5 |
|
||||||
|
| 表单标签、次要正文 | 13px | 400 | 1.5 |
|
||||||
|
| 辅助说明、时间戳 | 12px | 400 | 1.5 |
|
||||||
|
| 指标数值 | 28px | 600 | 1.2 |
|
||||||
|
|
||||||
|
- 层级靠字号与字重建立,不靠颜色、下划线、边框。
|
||||||
|
- 中文不使用斜体;英文与数字不加字距。
|
||||||
|
- 一段说明文字最长不超过 2 行,超出应改写或省略。
|
||||||
|
- 中英文与数字之间保留一个空格。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. 间距与布局
|
||||||
|
|
||||||
|
8pt 网格。间距只使用 `4 / 8 / 12 / 16 / 24 / 32`。
|
||||||
|
|
||||||
|
| 场景 | 值 |
|
||||||
|
| ---------------- | ------------ |
|
||||||
|
| 页面内容区内边距 | 24px |
|
||||||
|
| 内容最大宽度 | 1200px,居中 |
|
||||||
|
| 页面头部到主体 | 32px |
|
||||||
|
| 卡片内边距 | 20px |
|
||||||
|
| 卡片之间 | 16px |
|
||||||
|
| 表单字段之间 | 16px |
|
||||||
|
| 标签与输入框之间 | 6px |
|
||||||
|
| 行内元素之间 | 8px |
|
||||||
|
| 小节标题到内容 | 12px |
|
||||||
|
|
||||||
|
外壳尺寸:
|
||||||
|
|
||||||
|
- 侧栏宽 232px,折叠宽 0(`breakpoint="lg"`)。
|
||||||
|
- 顶栏高 56px,与侧栏品牌区对齐。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. 形状与层次
|
||||||
|
|
||||||
|
| 元素 | 圆角 | 说明 |
|
||||||
|
| ------------------ | ---- | ------------------------------- |
|
||||||
|
| 卡片 | 10px | 默认 1px `#E7E9EC` 边框,无阴影 |
|
||||||
|
| 弹窗 | 12px | 极轻阴影 |
|
||||||
|
| 按钮、输入框、下拉 | 6px | 统一 |
|
||||||
|
| 状态标签 | 6px | 高 24px,内边距 `2px 8px` |
|
||||||
|
| 图片/头像缩略图 | 8px | 头像用圆形 |
|
||||||
|
| 进度条 | 3px | 高 6px |
|
||||||
|
|
||||||
|
- 层次手段优先级:留白 > 字号字重 > 1px 浅边框 > 阴影。
|
||||||
|
- 阴影仅用于浮层:`0 1px 2px rgba(16, 24, 40, 0.04)`,弹窗可加 `0 8px 24px rgba(16, 24, 40, 0.08)`。
|
||||||
|
- 卡片不使用阴影,不叠加边框与阴影。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. 组件规范
|
||||||
|
|
||||||
|
### 侧栏导航
|
||||||
|
|
||||||
|
- 白底,右侧 1px `#E7E9EC` 分隔线。不使用深色主题(现有 `theme="dark"` 需移除)。
|
||||||
|
- 顶部品牌区:24x24 圆角 6px 标识 + 品牌名,高 56px。
|
||||||
|
- 分组标题:12px `#9AA1AC`,上下留白 8px,不加图标、不做大写英文。
|
||||||
|
- 菜单项:高 36px,圆角 6px,左侧 16px 线性图标(描边 1.5px),文字 14px。
|
||||||
|
- 三态:默认深灰文字无底色;悬停 `#F7F8FA`;选中 `#EFF4FF` 底 + `#2563EB` 文字与图标 + 字重 500。
|
||||||
|
|
||||||
|
### 顶栏
|
||||||
|
|
||||||
|
- 高 56px,白底,底部 1px 分隔线,左右内边距 24px。
|
||||||
|
- 左侧:品牌名 14px/600 + 灰色 13px「品牌工作区」+ 角色标签。
|
||||||
|
- 角色标签:负责人 `#EFF4FF`/`#2563EB`,内容编辑 `#F2F4F7`/`#475467`。
|
||||||
|
- 右侧:品牌切换下拉(尺寸 `small`、白底细边框)+ 「退出登录」文字按钮。
|
||||||
|
- 顶栏不随机滚动,内容区独立滚动。
|
||||||
|
|
||||||
|
### 页面头部
|
||||||
|
|
||||||
|
统一通过 `AdminPageHeader` 渲染:页面标题 20px/600 + 可选副标题 13px 次要色 + 右侧操作区。标题与副标题间距 6px,页头到主体 32px(明显大于卡片之间的 16px)。页面内不得再手写标题层级。
|
||||||
|
|
||||||
|
- 页面标题必须与侧栏导航用词一致,不额外添加「小程序内容:」这类前缀;页面职责写进副标题。
|
||||||
|
- 副标题一句话讲清这一页做什么,最长不超过 2 行;能由页面内文案表达的细节不要重复写在这里。
|
||||||
|
|
||||||
|
### 卡片
|
||||||
|
|
||||||
|
- 标题 16px/600,标题区底部间距 12px,标题右侧放次要操作(文字按钮)。
|
||||||
|
- 卡片只承载一个主题;一个页面最多两级卡片嵌套,避免再嵌套。
|
||||||
|
|
||||||
|
### 按钮
|
||||||
|
|
||||||
|
| 类型 | 场景 |
|
||||||
|
| -------------------- | ---------------------------------------- |
|
||||||
|
| 主按钮(实心强调色) | 每个页面/卡片最多一个,用于当前主流程 |
|
||||||
|
| 次按钮(白底细边框) | 并列的次要操作 |
|
||||||
|
| 文字按钮 | 表格行内操作、列表「去处理」、返回类操作 |
|
||||||
|
| 危险按钮 | 删除、撤回、卸载等不可逆操作 |
|
||||||
|
|
||||||
|
- 高度:默认 32px,主流程按钮 40px。
|
||||||
|
- 等待态用 `loading`,禁用态用 `disabled`,禁止用文字变形表达状态。
|
||||||
|
|
||||||
|
### 表单
|
||||||
|
|
||||||
|
- 标签在输入框上方,13px `#475467`,必填星号 `#B42318`。
|
||||||
|
- 帮助文本 12px `#9AA1AC`,错误文本 12px `#B42318`,都显示在字段下方。
|
||||||
|
- 输入框聚焦:1.5px `#2563EB` 描边 + `#EFF4FF` 2px 外发光。
|
||||||
|
- 提交失败必须保留用户输入,错误提示定位到字段或表单顶部,禁止弹窗后清空。
|
||||||
|
|
||||||
|
### 数据表格
|
||||||
|
|
||||||
|
- 无竖线;表头底色 `#FAFAFB`,13px `#6B7280`。
|
||||||
|
- 行高 52px(含头像/双行内容时 60px)。
|
||||||
|
- 行分隔线 `#F0F1F3`;悬停行底色 `#FAFAFB`。
|
||||||
|
- 操作列统一放最右,使用文字按钮,最多 2 个直接操作,更多收进「更多」下拉。
|
||||||
|
- 空数据不显示空表头,改用空状态组件。
|
||||||
|
|
||||||
|
### 状态标签
|
||||||
|
|
||||||
|
- 统一组件,按语义取色,默认 `尺寸 = 24px 高 / 12px 字`。
|
||||||
|
- 发布状态机映射:`building` 信息、`uploaded` 中性、`under_review` 警告、`approved` 成功、`rejected` 错误、`published` 成功、`failed` 错误、`superseded` 中性。
|
||||||
|
- 同一列表内标签宽度尽量对齐,避免视觉跳动。
|
||||||
|
|
||||||
|
### 弹窗
|
||||||
|
|
||||||
|
- 宽 480px(简单表单)或 560px(多字段),圆角 12px。
|
||||||
|
- 标题 16px/600,底部操作右对齐:次按钮在左、主按钮在右。
|
||||||
|
- 提交中禁用关闭与重复提交。
|
||||||
|
|
||||||
|
### 描述列表(键值展示)
|
||||||
|
|
||||||
|
用于咨询详情、版本信息等只读信息:字段名 13px `#6B7280`,值 14px `#1C1F23`,行间距 12px,不使用表格线。
|
||||||
|
|
||||||
|
落地:`<Descriptions className="admin-descriptions" column={1} size="small">`,字号与间距由 `admin.css` 与 `Descriptions` 令牌统一,不逐处传 `bordered`。
|
||||||
|
|
||||||
|
### Tabs
|
||||||
|
|
||||||
|
- 顶部 1px 分隔线,选中项底部 2px 强调色下划线 + 深色文字,未选中 14px `#6B7280`。
|
||||||
|
- 不超过 5 个 Tab,超出改用左侧分段导航。
|
||||||
|
|
||||||
|
### 切换控件选型
|
||||||
|
|
||||||
|
同一层级切换控件只允许两种,按范围选择,不得混用:
|
||||||
|
|
||||||
|
| 场景 | 控件 | 现状 |
|
||||||
|
| ---------------------------------------- | ----------- | ------------------------------ |
|
||||||
|
| 页面级分区(内容结构不同、各自独立成段) | `Tabs` | 配置与发布 |
|
||||||
|
| 区块内视图切换(同一份数据换视角) | `Segmented` | 小程序页面、业务提供项编辑弹窗 |
|
||||||
|
|
||||||
|
`Segmented` 用作「取值选择」(如能力状态降级/启用/停用)时按表单控件处理,不受本表约束。
|
||||||
|
|
||||||
|
### 标题层级
|
||||||
|
|
||||||
|
页面内标题只用三档,禁止再用 `Typography.Title level` 直接指定字号:
|
||||||
|
|
||||||
|
| 用途 | 类名 | 字号 |
|
||||||
|
| ---------------------- | --------------------- | ---------- |
|
||||||
|
| 区块标题 | `admin-section-title` | 16px / 600 |
|
||||||
|
| 面板内小标题、表单分组 | `admin-subhead` | 15px / 600 |
|
||||||
|
| 列表行、条目名称 | `admin-row-title` | 14px / 600 |
|
||||||
|
|
||||||
|
页面级标题只由 `AdminPageHeader` 输出(20px / 600),一个页面只出现一次。
|
||||||
|
|
||||||
|
### 进度
|
||||||
|
|
||||||
|
- 高 6px,圆角 3px,轨道 `#F0F1F3`,进度条强调色;完成态用成功色。
|
||||||
|
- 进度条上方 14px 文案说明当前含义,不允许只有一根进度条。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. 状态设计
|
||||||
|
|
||||||
|
每个远程数据页面必须显式实现四种状态,不得出现无反馈的白屏。
|
||||||
|
|
||||||
|
| 状态 | 规范 |
|
||||||
|
| -------- | ----------------------------------------------------------------------------------- |
|
||||||
|
| 加载中 | 骨架屏,形状与最终内容一致;不用居中转圈 |
|
||||||
|
| 空数据 | 居中:极简线性图形 + 15px/600 标题 + 13px 灰色说明 + 主操作按钮 |
|
||||||
|
| 请求失败 | 卡片内错误条:`#FEF3F2` 底 + 1px 浅红边框 + 圆角 8px + 文案 14px + 「重试」文字按钮 |
|
||||||
|
| 成功反馈 | 右上角轻量 toast,白底圆角 8px,280–320px 宽 |
|
||||||
|
|
||||||
|
- 行内操作使用按钮 `loading` 表达进行中,不用全局遮罩。
|
||||||
|
- 提交成功后:关闭弹窗、重置表单、刷新受影响列表;提交失败保持原状。
|
||||||
|
- 幂等写操作要防止重复点击(提交中禁用)。
|
||||||
|
|
||||||
|
落地约定:
|
||||||
|
|
||||||
|
- 空状态统一用 `EmptyState`(`components/EmptyState.tsx`);表格内用 `compact` 变体,整块区域用默认变体。禁止再使用 antd 默认 `Empty` 插画。
|
||||||
|
- 列表 / 表格加载统一用 `TableSkeleton`、`ListSkeleton`(`components/TableSkeleton.tsx`)替换内容区,不使用 antd `Table` 的转圈遮罩;卡片级加载用 `LoadingStack`。
|
||||||
|
- 卡片内的写操作只在「有未保存修改」时使用主按钮,其余状态用次要按钮并禁用,同时用 `StatusTag` 标明修改状态。
|
||||||
|
- 发布准备度、内容检查这类清单,条目文案只描述「检查什么」(中性名词),是否达标由「已完成 / 待完善」标签表达;帮助文案只在待完善时展示。禁止出现「已完成 · 请先完善…」这类自相矛盾的措辞。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 7. 页面结构
|
||||||
|
|
||||||
|
以下为各页面的视觉结构约定,业务逻辑不变。
|
||||||
|
|
||||||
|
| 页面 | 结构要点 |
|
||||||
|
| -------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| 登录 | 居中 400px 卡片,标识 + 说明 + 表单 + 通栏主按钮;错误态展示在字段下方 |
|
||||||
|
| 首次改密 | 同登录卡片形态,说明文案 + 三个密码字段 + 「保存新密码」 |
|
||||||
|
| 品牌概览 | 品牌卡 + 三张指标卡(等宽一行)+ 两栏(发布准备度 / 品牌内容检查) |
|
||||||
|
| 内容与发布 | 内容发布 / 小程序发布 / 小程序配置三个分区;内容发布含发布状态卡、草稿卡和历史版本表,不承载业务类型或页面方案选择 |
|
||||||
|
| 页面方案 | 当前业务类型与页面方案 + 升级预览 + 版本选择 + 配置恢复 + 高级示例内容导入 |
|
||||||
|
| 品牌管理 | 品牌列表与创建入口;创建品牌先选不可变的业务类型,再选兼容页面方案,创建时不导入示例内容 |
|
||||||
|
| 小程序页面 | 左右两栏:左 380px 编辑面板,右预览画布;预览内选中区域虚线高亮 + 区域名气泡 |
|
||||||
|
| 信任内容 | 列表行(类型图标或配图 + 标题 + 发布状态标签 + 类型/展示位置说明 + 两行摘要 + 行内操作),按模板类型顺序排列,不用表格 |
|
||||||
|
| 业务提供项 | 表格(名称 / 价格 / 状态开关 / 排序 / 操作)+ 新增弹窗 |
|
||||||
|
| 咨询记录 | 顶部三指标 + 左 380px 列表 + 右详情的主从布局 |
|
||||||
|
| 咨询表单与字段 | 咨询表单表(名称 / 版本 / 字段数 / 状态 / 操作)+ 新增与编辑弹窗(含选项编辑);高级自定义字段表 + 新增弹窗 |
|
||||||
|
| 能力插件 | 插件卡片列表(图标 + 名称 + 说明 + 开关),停用态降低对比度 |
|
||||||
|
| 团队成员 | 表格(成员 / 角色 / 状态 / 最近登录 / 操作)+ 邀请弹窗 |
|
||||||
|
|
||||||
|
两栏页面在小屏下折叠为单列,编辑/预览改为上下排列。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 8. 无障碍与细节
|
||||||
|
|
||||||
|
- 正文与背景对比度不低于 4.5:1;标签文字与标签底色不低于 4.5:1。
|
||||||
|
- 可点击元素最小热区 32x32px;纯图标按钮必须带 `aria-label`。
|
||||||
|
- 焦点可见:所有可交互元素保留 1.5px 强调色聚焦描边。
|
||||||
|
- 状态不能只靠颜色区分,需同时有文字。
|
||||||
|
- 数字使用等宽数字排版(`font-variant-numeric: tabular-nums`),避免指标和价格跳动。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 9. 禁止项
|
||||||
|
|
||||||
|
- 渐变、玻璃拟态、拟物纹理、装饰性插画铺满界面。
|
||||||
|
- 深色侧栏、彩色大面积色块、实心鲜艳 Tag。
|
||||||
|
- 重阴影、多重边框、卡片再套卡片超过两级。
|
||||||
|
- emoji 作为图标;图标与文字混排时不对齐基线。
|
||||||
|
- 页面内写死色值、圆角、间距魔法数字。
|
||||||
|
- 一个页面出现多个主按钮竞争视觉焦点。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 10. antd 令牌映射
|
||||||
|
|
||||||
|
落地时在 Admin 根节点用 `ConfigProvider` 注入,不逐页覆盖。
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const theme = {
|
||||||
|
token: {
|
||||||
|
colorPrimary: "#2563EB",
|
||||||
|
colorLink: "#2563EB",
|
||||||
|
colorText: "#1C1F23",
|
||||||
|
colorTextSecondary: "#6B7280",
|
||||||
|
colorTextTertiary: "#9AA1AC",
|
||||||
|
colorTextQuaternary: "#C3C7CF",
|
||||||
|
colorBgLayout: "#F7F8FA",
|
||||||
|
colorBgContainer: "#FFFFFF",
|
||||||
|
colorBorder: "#D8DBE0",
|
||||||
|
colorBorderSecondary: "#E7E9EC",
|
||||||
|
colorSplit: "#F0F1F3",
|
||||||
|
colorFillTertiary: "#F7F8FA",
|
||||||
|
colorFillQuaternary: "#FAFAFB",
|
||||||
|
colorSuccess: "#12B76A",
|
||||||
|
colorSuccessBg: "#ECFDF3",
|
||||||
|
colorSuccessBorder: "#ABEFC6",
|
||||||
|
colorSuccessText: "#067647",
|
||||||
|
colorWarning: "#F79009",
|
||||||
|
colorWarningBg: "#FFFAEB",
|
||||||
|
colorWarningBorder: "#FEDF89",
|
||||||
|
colorWarningText: "#B54708",
|
||||||
|
colorError: "#F04438",
|
||||||
|
colorErrorBg: "#FEF3F2",
|
||||||
|
colorErrorBorder: "#FBD5D1",
|
||||||
|
colorErrorText: "#B42318",
|
||||||
|
colorInfo: "#2563EB",
|
||||||
|
colorInfoBg: "#EFF4FF",
|
||||||
|
colorInfoBorder: "#B2CCFF",
|
||||||
|
colorInfoText: "#2563EB",
|
||||||
|
borderRadius: 6,
|
||||||
|
borderRadiusLG: 10,
|
||||||
|
borderRadiusSM: 4,
|
||||||
|
fontSize: 14,
|
||||||
|
fontFamily:
|
||||||
|
"Inter, 'PingFang SC', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
|
||||||
|
controlHeight: 32,
|
||||||
|
controlHeightLG: 40,
|
||||||
|
boxShadow: "0 1px 2px rgba(16, 24, 40, 0.04)",
|
||||||
|
boxShadowSecondary: "0 8px 24px rgba(16, 24, 40, 0.08)",
|
||||||
|
wireframe: false,
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
Layout: {
|
||||||
|
headerHeight: 56,
|
||||||
|
headerBg: "#FFFFFF",
|
||||||
|
headerPadding: "0 24px",
|
||||||
|
siderBg: "#FFFFFF",
|
||||||
|
bodyBg: "#F7F8FA",
|
||||||
|
triggerBg: "#FFFFFF",
|
||||||
|
triggerColor: "#475467",
|
||||||
|
triggerHeight: 40,
|
||||||
|
},
|
||||||
|
Menu: {
|
||||||
|
itemHeight: 36,
|
||||||
|
itemBorderRadius: 6,
|
||||||
|
itemBg: "transparent",
|
||||||
|
itemColor: "#475467",
|
||||||
|
itemHoverBg: "#F7F8FA",
|
||||||
|
itemHoverColor: "#1C1F23",
|
||||||
|
itemSelectedBg: "#EFF4FF",
|
||||||
|
itemSelectedColor: "#2563EB",
|
||||||
|
itemMarginInline: 8,
|
||||||
|
itemMarginBlock: 2,
|
||||||
|
groupTitleColor: "#9AA1AC",
|
||||||
|
groupTitleFontSize: 12,
|
||||||
|
collapsedWidth: 0,
|
||||||
|
subMenuItemBg: "transparent",
|
||||||
|
},
|
||||||
|
Card: { paddingLG: 20, headerFontSize: 16, headerHeight: 52, headerHeightSM: 44 },
|
||||||
|
Table: {
|
||||||
|
headerBg: "#FAFAFB",
|
||||||
|
headerColor: "#6B7280",
|
||||||
|
rowHoverBg: "#FAFAFB",
|
||||||
|
headerSplitColor: "transparent",
|
||||||
|
borderColor: "#F0F1F3",
|
||||||
|
cellPaddingBlock: 16,
|
||||||
|
headerBorderRadius: 8,
|
||||||
|
},
|
||||||
|
Button: { fontWeight: 500, primaryShadow: "none", defaultShadow: "none" },
|
||||||
|
Progress: { defaultColor: "#2563EB", remainingColor: "#F0F1F3", lineBorderRadius: 3 },
|
||||||
|
Tag: { defaultBg: "#F2F4F7", defaultColor: "#475467", borderRadiusSM: 6 },
|
||||||
|
Tabs: { inkBarColor: "#2563EB", itemSelectedColor: "#1C1F23", itemColor: "#6B7280" },
|
||||||
|
Form: { labelColor: "#475467", labelFontSize: 13, verticalLabelPadding: "0 0 6px" },
|
||||||
|
Modal: { borderRadiusLG: 12 },
|
||||||
|
Statistic: { titleFontSize: 12, contentFontSize: 28 },
|
||||||
|
Alert: { borderRadius: 8 },
|
||||||
|
Descriptions: {
|
||||||
|
labelBg: "#FAFAFB",
|
||||||
|
labelColor: "#6B7280",
|
||||||
|
contentColor: "#1C1F23",
|
||||||
|
itemPaddingBottom: 12,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
可执行来源是 `apps/admin/src/lib/theme.ts`,本块为同值快照;改令牌时两处一起改。
|
||||||
|
|
||||||
|
- 新增页面优先使用令牌与共享组件;禁止在 JSX 内写内联色值、字号、圆角(唯一的例外是通过 CSS 变量透传的数据色,例如视觉模板色板的 `--swatch-color`)。
|
||||||
|
- 共享视觉组件清单:`AdminPageHeader`、`AdminSection`、`StatusTag`、`EmptyState`、`TableSkeleton` / `ListSkeleton`、`MetricCard`、`QueryState`。
|
||||||
@@ -3,6 +3,10 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
<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>
|
<title>个人品牌后台</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@ant-design/icons": "^6.3.4",
|
||||||
"@personal-brand/api-client": "workspace:*",
|
"@personal-brand/api-client": "workspace:*",
|
||||||
"@tanstack/react-query": "^5.103.1",
|
"@tanstack/react-query": "^5.103.1",
|
||||||
"antd": "^6.6.4",
|
"antd": "^6.6.4",
|
||||||
|
|||||||
@@ -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) }),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import {
|
||||||
|
AppstoreOutlined,
|
||||||
|
BarsOutlined,
|
||||||
|
CloudUploadOutlined,
|
||||||
|
FormOutlined,
|
||||||
|
LayoutOutlined,
|
||||||
|
MessageOutlined,
|
||||||
|
MobileOutlined,
|
||||||
|
SafetyCertificateOutlined,
|
||||||
|
ShopOutlined,
|
||||||
|
TeamOutlined,
|
||||||
|
ThunderboltOutlined,
|
||||||
|
} from "@ant-design/icons";
|
||||||
|
import { useLocation, useNavigate } from "react-router-dom";
|
||||||
|
import { createApiClient } from "../lib/api.js";
|
||||||
|
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 { App } from "antd";
|
||||||
|
import { AdminButton } from "../components/AdminButton.js";
|
||||||
|
import { AdminSelect } from "../components/AdminSelect.js";
|
||||||
|
import { AdminLayout } from "../components/AdminLayout.js";
|
||||||
|
import { Route, Routes } from "react-router-dom";
|
||||||
|
import { AdminOverviewRedirect } from "./AdminRouter.js";
|
||||||
|
import { createBrandRouteElement } from "./route-access.js";
|
||||||
|
import { Suspense } from "react";
|
||||||
|
import { AdminErrorBoundary } from "../components/AdminErrorBoundary.js";
|
||||||
|
import { toBrandDisplayName, toBrandSwitcherOptions } from "../lib/brand-switcher.js";
|
||||||
|
|
||||||
|
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({
|
||||||
|
queryKey: ["admin-shell-brand"],
|
||||||
|
queryFn: () => createApiClient().getAdminBrand(),
|
||||||
|
});
|
||||||
|
const memberships = useQuery({
|
||||||
|
queryKey: ["admin-brand-memberships"],
|
||||||
|
queryFn: () => createApiClient().listAdminBrands(),
|
||||||
|
});
|
||||||
|
const switchBrand = async (brandId: string) => {
|
||||||
|
try {
|
||||||
|
await createApiClient().switchAdminBrand(brandId);
|
||||||
|
window.location.reload();
|
||||||
|
} catch (error) {
|
||||||
|
message.error(error instanceof Error ? error.message : "品牌切换失败");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const page = location.pathname.split("/")[2] || "overview";
|
||||||
|
const brandName = toBrandDisplayName(brand.data?.name, "当前品牌");
|
||||||
|
const brandOptions = toBrandSwitcherOptions(memberships.data);
|
||||||
|
const items = [
|
||||||
|
{
|
||||||
|
type: "group" as const,
|
||||||
|
label: "日常经营",
|
||||||
|
children: [
|
||||||
|
{ key: "overview", label: "当前品牌概览", icon: <AppstoreOutlined /> },
|
||||||
|
{ key: "publication", label: "内容与发布", icon: <CloudUploadOutlined /> },
|
||||||
|
{ key: "brand", label: "小程序页面", icon: <MobileOutlined /> },
|
||||||
|
{ key: "trust", label: "信任内容", icon: <SafetyCertificateOutlined /> },
|
||||||
|
{ key: "services", label: "业务提供项", icon: <BarsOutlined /> },
|
||||||
|
{ key: "inquiries", label: "咨询记录", icon: <MessageOutlined /> },
|
||||||
|
{ key: "workspace", label: "咨询表单与字段", icon: <FormOutlined /> },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
...(role === "editor"
|
||||||
|
? []
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
type: "group" as const,
|
||||||
|
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 /> }]
|
||||||
|
: []),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
];
|
||||||
|
return (
|
||||||
|
<AdminLayout className="admin-shell">
|
||||||
|
<AdminLayout.Sider className="admin-sider" breakpoint="lg" collapsedWidth={0} width={232}>
|
||||||
|
<div className="admin-sider-brand">
|
||||||
|
<BrandMark name={toBrandDisplayName(brand.data?.name, "")} />
|
||||||
|
<span className="admin-sider-brand-name">品牌工作区</span>
|
||||||
|
</div>
|
||||||
|
<AdminMenu
|
||||||
|
selectedKeys={[page]}
|
||||||
|
onClick={({ key }) => navigate(`/admin/${key}`)}
|
||||||
|
items={items}
|
||||||
|
/>
|
||||||
|
</AdminLayout.Sider>
|
||||||
|
<AdminLayout className="admin-main">
|
||||||
|
<AdminLayout.Header className="admin-header">
|
||||||
|
<div className="admin-header-left">
|
||||||
|
<span className="admin-header-brand">{brandName}</span>
|
||||||
|
<span className="admin-header-context">品牌工作区</span>
|
||||||
|
<StatusTag
|
||||||
|
tone={role === "owner" ? "info" : "neutral"}
|
||||||
|
label={role === "owner" ? "负责人" : "内容编辑"}
|
||||||
|
/>
|
||||||
|
<AdminSelect
|
||||||
|
size="small"
|
||||||
|
variant="outlined"
|
||||||
|
className="admin-brand-switcher"
|
||||||
|
value={brand.data?.id}
|
||||||
|
loading={memberships.isLoading}
|
||||||
|
onChange={(value: string | undefined) => {
|
||||||
|
if (value) void switchBrand(value);
|
||||||
|
}}
|
||||||
|
options={brandOptions}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<AdminButton type="text" onClick={onLogout}>
|
||||||
|
退出登录
|
||||||
|
</AdminButton>
|
||||||
|
</AdminLayout.Header>
|
||||||
|
<AdminLayout.Content className="admin-content">
|
||||||
|
<div className="admin-content-inner">
|
||||||
|
<AdminErrorBoundary key={location.pathname}>
|
||||||
|
<Suspense fallback={<LoadingStack />}>
|
||||||
|
<Routes>
|
||||||
|
<Route index element={<AdminOverviewRedirect />} />
|
||||||
|
<Route path="overview" element={<FeatureOverviewPage />} />
|
||||||
|
<Route path="publication" element={<FeaturePublicationPage />} />
|
||||||
|
<Route path="brand" element={<FeatureBrandPage />} />
|
||||||
|
<Route path="trust" element={<FeatureTrustContentPage />} />
|
||||||
|
<Route path="services" element={<FeatureServicesPage />} />
|
||||||
|
<Route path="inquiries" element={<FeatureInquiriesPage />} />
|
||||||
|
<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={<AdminOverviewRedirect />} />
|
||||||
|
</Routes>
|
||||||
|
</Suspense>
|
||||||
|
</AdminErrorBoundary>
|
||||||
|
</div>
|
||||||
|
</AdminLayout.Content>
|
||||||
|
</AdminLayout>
|
||||||
|
</AdminLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
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 { AdminRouter } from "./AdminRouter.js";
|
||||||
|
import { App } from "antd";
|
||||||
|
import { createApiClient } from "../lib/api.js";
|
||||||
|
import { LoadingStack } from "../components/LoadingStack.js";
|
||||||
|
import { AdminErrorBoundary } from "../components/AdminErrorBoundary.js";
|
||||||
|
|
||||||
|
type SessionState = Omit<AdminSession, "authenticated">;
|
||||||
|
|
||||||
|
export function Root() {
|
||||||
|
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("登录状态已失效,请重新登录");
|
||||||
|
setSession(null);
|
||||||
|
};
|
||||||
|
window.addEventListener("admin-auth-expired", expire);
|
||||||
|
return () => window.removeEventListener("admin-auth-expired", expire);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const logout = async () => {
|
||||||
|
try {
|
||||||
|
await createApiClient().logoutAdmin();
|
||||||
|
} catch {
|
||||||
|
message.warning("已退出本地会话;服务端撤销请求未完成");
|
||||||
|
} finally {
|
||||||
|
setSession(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (loading) return <LoadingStack />;
|
||||||
|
if (!session)
|
||||||
|
return (
|
||||||
|
<Login
|
||||||
|
onLogin={(current) => {
|
||||||
|
setSession(current);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
if (session.mustChangePassword)
|
||||||
|
return (
|
||||||
|
<ChangePassword
|
||||||
|
onComplete={async () => {
|
||||||
|
try {
|
||||||
|
setSession(await createApiClient().getAdminSession());
|
||||||
|
} catch {
|
||||||
|
setSession(null);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<AdminErrorBoundary variant="page">
|
||||||
|
<AdminRouter>
|
||||||
|
<Dashboard
|
||||||
|
onLogout={logout}
|
||||||
|
role={session.role}
|
||||||
|
platformTemplateRole={session.platformTemplateRole}
|
||||||
|
/>
|
||||||
|
</AdminRouter>
|
||||||
|
</AdminErrorBoundary>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -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 });
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export const FeatureInquiriesPage = React.lazy(() =>
|
||||||
|
import("../features/inquiries/InquiriesPage.js").then((module) => ({
|
||||||
|
default: module.InquiriesPage,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
export const FeatureTrustContentPage = React.lazy(() =>
|
||||||
|
import("../features/trust-content/TrustContentPage.js").then((module) => ({
|
||||||
|
default: module.TrustContentPage,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
export const FeatureServicesPage = React.lazy(() =>
|
||||||
|
import("../features/services/ServicesPage.js").then((module) => ({
|
||||||
|
default: module.ServicesPage,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
export const FeatureBrandPage = React.lazy(() =>
|
||||||
|
import("../features/brand/BrandPage.js").then((module) => ({ default: module.BrandPage })),
|
||||||
|
);
|
||||||
|
export const FeatureWorkspacePage = React.lazy(() =>
|
||||||
|
import("../features/workspace/WorkspacePage.js").then((module) => ({
|
||||||
|
default: module.WorkspacePage,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
export const FeatureOverviewPage = React.lazy(() =>
|
||||||
|
import("../features/overview/OverviewPage.js").then((module) => ({
|
||||||
|
default: module.OverviewPage,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
export const FeatureCapabilitiesPage = React.lazy(() =>
|
||||||
|
import("../features/capabilities/CapabilitiesPage.js").then((module) => ({
|
||||||
|
default: module.CapabilitiesPage,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
export const FeatureMembersPage = React.lazy(() =>
|
||||||
|
import("../features/team/MembersPage.js").then((module) => ({
|
||||||
|
default: module.MembersPage,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
export const FeaturePublicationPage = React.lazy(() =>
|
||||||
|
import("../features/publication/PublicationPage.js").then((module) => ({
|
||||||
|
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,
|
||||||
|
})),
|
||||||
|
);
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
|
import type { ButtonProps } from "antd";
|
||||||
|
|
||||||
|
export function AdminButton(props: ButtonProps) {
|
||||||
|
return <Button {...props} />;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { Card } from "antd";
|
||||||
|
import type { CardProps } from "antd";
|
||||||
|
|
||||||
|
export function AdminCard(props: CardProps) {
|
||||||
|
return <Card {...props} />;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { App, ConfigProvider } from "antd";
|
||||||
|
import type { ConfigProviderProps } from "antd";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export function AdminConfigProvider({
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: ConfigProviderProps & { children?: ReactNode }) {
|
||||||
|
return (
|
||||||
|
<ConfigProvider {...props}>
|
||||||
|
<App>{children}</App>
|
||||||
|
</ConfigProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
import { Component, type ErrorInfo, type ReactNode } from "react";
|
||||||
|
import { Button, Result, Space, Typography } from "antd";
|
||||||
|
import { createApiClient } from "../lib/api.js";
|
||||||
|
|
||||||
|
interface AdminErrorBoundaryProps {
|
||||||
|
children: ReactNode;
|
||||||
|
variant?: "page" | "content";
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AdminErrorBoundaryState {
|
||||||
|
error: Error | null;
|
||||||
|
errorId: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createErrorId(): string {
|
||||||
|
return `admin-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后台渲染错误边界:页面级兜底整页,内容级兜底单个业务页面且保留导航。
|
||||||
|
* React 只支持 class 组件捕获渲染异常,因此这里保留 class 实现。
|
||||||
|
*/
|
||||||
|
export class AdminErrorBoundary extends Component<
|
||||||
|
AdminErrorBoundaryProps,
|
||||||
|
AdminErrorBoundaryState
|
||||||
|
> {
|
||||||
|
override state: AdminErrorBoundaryState = { error: null, errorId: null };
|
||||||
|
private reportedErrorId: string | null = null;
|
||||||
|
|
||||||
|
static getDerivedStateFromError(error: Error): AdminErrorBoundaryState {
|
||||||
|
return { error, errorId: createErrorId() };
|
||||||
|
}
|
||||||
|
|
||||||
|
override componentDidCatch(error: Error, info: ErrorInfo) {
|
||||||
|
const errorId = this.state.errorId ?? createErrorId();
|
||||||
|
console.error("[admin] 页面渲染异常", errorId, error, info.componentStack);
|
||||||
|
if (this.reportedErrorId === errorId) return;
|
||||||
|
this.reportedErrorId = errorId;
|
||||||
|
// 上报失败不能影响错误页本身:只记录到控制台,不抛出、不改状态。
|
||||||
|
void createApiClient()
|
||||||
|
.reportAdminClientError({
|
||||||
|
errorId,
|
||||||
|
message: error.message.slice(0, 2000) || error.name,
|
||||||
|
route: `${window.location.pathname}${window.location.search}`.slice(0, 500),
|
||||||
|
...(info.componentStack ? { componentStack: info.componentStack.slice(0, 20000) } : {}),
|
||||||
|
})
|
||||||
|
.catch((reportError: unknown) => {
|
||||||
|
console.warn("[admin] 渲染异常上报失败", errorId, reportError);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private reset = () => {
|
||||||
|
this.setState({ error: null, errorId: null });
|
||||||
|
};
|
||||||
|
|
||||||
|
private reload = () => {
|
||||||
|
window.location.reload();
|
||||||
|
};
|
||||||
|
|
||||||
|
override render() {
|
||||||
|
const { error, errorId } = this.state;
|
||||||
|
if (!error) return this.props.children;
|
||||||
|
const isPage = this.props.variant === "page";
|
||||||
|
return (
|
||||||
|
<Result
|
||||||
|
status="error"
|
||||||
|
title="页面渲染出错"
|
||||||
|
subTitle={
|
||||||
|
isPage
|
||||||
|
? "后台页面无法显示。可以重新加载;如果问题持续,请把错误编号提供给管理员。"
|
||||||
|
: "这个页面无法显示,其他页面仍可正常使用。可以重试或重新加载页面。"
|
||||||
|
}
|
||||||
|
extra={
|
||||||
|
<Space wrap>
|
||||||
|
{isPage ? null : (
|
||||||
|
<Button type="primary" onClick={this.reset}>
|
||||||
|
重试
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Button type={isPage ? "primary" : "default"} onClick={this.reload}>
|
||||||
|
重新加载页面
|
||||||
|
</Button>
|
||||||
|
{isPage ? <Button href="/admin/overview">返回概览</Button> : null}
|
||||||
|
</Space>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Typography.Paragraph type="secondary" copyable={{ text: errorId ?? "" }}>
|
||||||
|
错误编号:{errorId}
|
||||||
|
</Typography.Paragraph>
|
||||||
|
{import.meta.env.DEV ? (
|
||||||
|
<Typography.Paragraph type="secondary">
|
||||||
|
开发环境错误信息:{error.message}
|
||||||
|
</Typography.Paragraph>
|
||||||
|
) : null}
|
||||||
|
</Result>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { Form as AdminForm, Input as AdminInput } from "antd";
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { Layout } from "antd";
|
||||||
|
import type { BasicProps } from "antd/es/layout/layout";
|
||||||
|
|
||||||
|
function AdminLayoutBase(props: BasicProps) {
|
||||||
|
return <Layout {...props} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const AdminLayout = Object.assign(AdminLayoutBase, {
|
||||||
|
Sider: Layout.Sider,
|
||||||
|
Header: Layout.Header,
|
||||||
|
Content: Layout.Content,
|
||||||
|
});
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { Menu } from "antd";
|
||||||
|
import type { MenuProps } from "antd";
|
||||||
|
|
||||||
|
export function AdminMenu(props: MenuProps) {
|
||||||
|
return <Menu {...props} />;
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import { Space, Typography } from "antd";
|
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
export function AdminPageHeader({
|
export function AdminPageHeader({
|
||||||
@@ -11,21 +10,12 @@ export function AdminPageHeader({
|
|||||||
extra?: ReactNode;
|
extra?: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Space
|
<header className="admin-page-header">
|
||||||
align="start"
|
<div className="admin-page-header-text">
|
||||||
style={{ width: "100%", justifyContent: "space-between", marginBottom: 24 }}
|
<h1 className="admin-page-header-title">{title}</h1>
|
||||||
>
|
{description ? <p className="admin-page-header-description">{description}</p> : null}
|
||||||
<div>
|
|
||||||
<Typography.Title level={2} style={{ margin: 0 }}>
|
|
||||||
{title}
|
|
||||||
</Typography.Title>
|
|
||||||
{description && (
|
|
||||||
<Typography.Paragraph type="secondary" style={{ margin: "8px 0 0" }}>
|
|
||||||
{description}
|
|
||||||
</Typography.Paragraph>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
{extra}
|
{extra}
|
||||||
</Space>
|
</header>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export function AdminSection({
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
extra,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
title?: ReactNode;
|
||||||
|
description?: ReactNode;
|
||||||
|
extra?: ReactNode;
|
||||||
|
children: ReactNode;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<section className="admin-section">
|
||||||
|
{title ? (
|
||||||
|
<div className="admin-section-head">
|
||||||
|
<div>
|
||||||
|
<h2 className="admin-section-title">{title}</h2>
|
||||||
|
{description ? <p className="admin-section-description">{description}</p> : null}
|
||||||
|
</div>
|
||||||
|
{extra}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
{children}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { Select } from "antd";
|
||||||
|
import type { SelectProps } from "antd";
|
||||||
|
|
||||||
|
export function AdminSelect(props: SelectProps) {
|
||||||
|
return <Select {...props} />;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { Skeleton } from "antd";
|
||||||
|
import type { SkeletonProps } from "antd";
|
||||||
|
|
||||||
|
export function AdminSkeleton(props: SkeletonProps) {
|
||||||
|
return <Skeleton {...props} />;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* 品牌标识:取品牌名首字渲染单字标记,未取到品牌时回落到中性字。
|
||||||
|
* 视觉规则见 apps/admin/design.md 的「侧栏导航」。
|
||||||
|
*/
|
||||||
|
export function BrandMark({
|
||||||
|
name,
|
||||||
|
fallback = "品",
|
||||||
|
className = "admin-sider-brand-mark",
|
||||||
|
}: {
|
||||||
|
name?: string | null | undefined;
|
||||||
|
fallback?: string;
|
||||||
|
className?: string;
|
||||||
|
}) {
|
||||||
|
const trimmed = name?.trim() ?? "";
|
||||||
|
const mark = Array.from(trimmed)[0] ?? fallback;
|
||||||
|
return <span className={className}>{mark}</span>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export function EmptyState({
|
||||||
|
icon,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
action,
|
||||||
|
compact = false,
|
||||||
|
}: {
|
||||||
|
icon?: ReactNode;
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
action?: ReactNode;
|
||||||
|
compact?: boolean;
|
||||||
|
}) {
|
||||||
|
const className = compact ? "admin-empty admin-empty--compact" : "admin-empty";
|
||||||
|
return (
|
||||||
|
<div className={className}>
|
||||||
|
{icon ? <span className="admin-empty__icon">{icon}</span> : null}
|
||||||
|
<p className="admin-empty__title">{title}</p>
|
||||||
|
{description ? <p className="admin-empty__description">{description}</p> : null}
|
||||||
|
{action ? <div className="admin-empty__action">{action}</div> : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,33 +1,138 @@
|
|||||||
import { Image, Input, Space, Typography } from "antd";
|
import { CloudUploadOutlined, DeleteOutlined, PictureOutlined } from "@ant-design/icons";
|
||||||
|
import { Alert, App, Button, Image, Popconfirm, Spin, Upload } from "antd";
|
||||||
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
import { apiBaseUrl, authenticatedFetch, createApiClient } from "../lib/api.js";
|
||||||
|
|
||||||
interface ImageUrlFieldProps {
|
interface ImageUrlFieldProps {
|
||||||
|
id?: string;
|
||||||
value?: string;
|
value?: string;
|
||||||
onChange?: (value: string) => void;
|
onChange?: (value: string) => void;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
|
scope?: "brand" | "offering" | "trust";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ImageUrlField({ value, onChange, placeholder }: ImageUrlFieldProps) {
|
export function ImageUrlField({ id, value, onChange, placeholder, scope }: ImageUrlFieldProps) {
|
||||||
|
const { message } = App.useApp();
|
||||||
const imageUrl = typeof value === "string" ? value.trim() : "";
|
const imageUrl = typeof value === "string" ? value.trim() : "";
|
||||||
|
const [uploading, setUploading] = useState(false);
|
||||||
|
const [storageStatus, setStorageStatus] = useState<
|
||||||
|
"loading" | "ok" | "unavailable" | "unconfigured"
|
||||||
|
>("loading");
|
||||||
|
const client = useMemo(() => createApiClient(), []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let active = true;
|
||||||
|
client
|
||||||
|
.getUploadConfig()
|
||||||
|
.then((config) => {
|
||||||
|
if (active) setStorageStatus(config.configured ? config.status : "unconfigured");
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
if (active) setStorageStatus("unavailable");
|
||||||
|
});
|
||||||
|
return () => {
|
||||||
|
active = false;
|
||||||
|
};
|
||||||
|
}, [client]);
|
||||||
|
|
||||||
|
async function upload(file: File) {
|
||||||
|
if (!file.type.startsWith("image/")) {
|
||||||
|
message.error("仅支持图片文件");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (file.size > 10 * 1024 * 1024) {
|
||||||
|
message.error("图片不能超过 10MB");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setUploading(true);
|
||||||
|
try {
|
||||||
|
const presign = await client.createPresignedUpload({
|
||||||
|
fileName: file.name,
|
||||||
|
contentType: file.type,
|
||||||
|
...(scope ? { scope } : {}),
|
||||||
|
});
|
||||||
|
const isLocalUpload = presign.mode === "local";
|
||||||
|
const uploadUrl = isLocalUpload
|
||||||
|
? `${apiBaseUrl.replace(/\/$/, "")}${presign.uploadUrl}`
|
||||||
|
: presign.uploadUrl;
|
||||||
|
const response = await authenticatedFetch(uploadUrl, {
|
||||||
|
method: "PUT",
|
||||||
|
headers: { "content-type": file.type },
|
||||||
|
body: file,
|
||||||
|
});
|
||||||
|
if (!response.ok) throw new Error(`upload failed: ${response.status}`);
|
||||||
|
onChange?.(presign.publicUrl);
|
||||||
|
} catch (error) {
|
||||||
|
message.error(error instanceof Error ? error.message : "图片上传失败,请重试");
|
||||||
|
} finally {
|
||||||
|
setUploading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Space direction="vertical" size={8} style={{ width: "100%" }}>
|
<div className="admin-field-stack-xs admin-block">
|
||||||
<Input
|
{storageStatus !== "ok" ? (
|
||||||
value={value}
|
<Alert
|
||||||
onChange={(event) => onChange?.(event.target.value)}
|
type={storageStatus === "loading" ? "info" : "warning"}
|
||||||
placeholder={placeholder ?? "粘贴图片地址"}
|
showIcon
|
||||||
|
title={
|
||||||
|
storageStatus === "loading"
|
||||||
|
? "正在检查媒体存储..."
|
||||||
|
: storageStatus === "unconfigured"
|
||||||
|
? "媒体存储未配置,请先设置对象存储"
|
||||||
|
: "媒体存储不可用,请检查对象存储配置"
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
) : null}
|
||||||
{imageUrl ? (
|
{imageUrl ? (
|
||||||
<Space align="start">
|
<div className="admin-media-preview">
|
||||||
<Image
|
<Image
|
||||||
src={imageUrl}
|
src={imageUrl}
|
||||||
width={96}
|
alt={placeholder ?? "图片预览"}
|
||||||
height={64}
|
width="100%"
|
||||||
|
height={180}
|
||||||
preview
|
preview
|
||||||
fallback="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="
|
fallback="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="
|
||||||
style={{ objectFit: "cover", borderRadius: 8, background: "#f5f5f5" }}
|
|
||||||
/>
|
/>
|
||||||
<Typography.Text type="secondary">预览图</Typography.Text>
|
<Popconfirm title="移除这张图片?" onConfirm={() => onChange?.("")}>
|
||||||
</Space>
|
<Button danger size="small" icon={<DeleteOutlined />} className="admin-thumb-remove">
|
||||||
|
移除
|
||||||
|
</Button>
|
||||||
|
</Popconfirm>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<Upload.Dragger
|
||||||
|
accept="image/*"
|
||||||
|
multiple={false}
|
||||||
|
showUploadList={false}
|
||||||
|
disabled={uploading || storageStatus !== "ok"}
|
||||||
|
beforeUpload={(file) => {
|
||||||
|
if (storageStatus === "ok") void upload(file);
|
||||||
|
return false;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<p className="ant-upload-drag-icon">{uploading ? <Spin /> : <PictureOutlined />}</p>
|
||||||
|
<p className="ant-upload-text">{uploading ? "上传中..." : "点击或拖拽上传图片"}</p>
|
||||||
|
<p className="ant-upload-hint">JPG、PNG、WebP 或 AVIF,最大 10MB</p>
|
||||||
|
</Upload.Dragger>
|
||||||
|
)}
|
||||||
|
{storageStatus === "unavailable" ? (
|
||||||
|
<Button
|
||||||
|
icon={<CloudUploadOutlined />}
|
||||||
|
onClick={() => {
|
||||||
|
setStorageStatus("loading");
|
||||||
|
client
|
||||||
|
.getUploadConfig()
|
||||||
|
.then((config) =>
|
||||||
|
setStorageStatus(config.configured ? config.status : "unconfigured"),
|
||||||
|
)
|
||||||
|
.catch(() => setStorageStatus("unavailable"));
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
重新检查存储
|
||||||
|
</Button>
|
||||||
) : null}
|
) : null}
|
||||||
</Space>
|
<input {...(id ? { id } : {})} type="hidden" value={imageUrl} />
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { AdminCard } from "./AdminCard.js";
|
||||||
|
import { AdminSkeleton } from "./AdminSkeleton.js";
|
||||||
|
|
||||||
|
export function LoadingStack({ rows = 3 }: { rows?: number }) {
|
||||||
|
return (
|
||||||
|
<div className="admin-loading-stack">
|
||||||
|
<AdminCard>
|
||||||
|
<AdminSkeleton active paragraph={{ rows: 2 }} title={false} />
|
||||||
|
</AdminCard>
|
||||||
|
{Array.from({ length: rows }).map((_, index) => (
|
||||||
|
<AdminCard key={index}>
|
||||||
|
<AdminSkeleton active paragraph={{ rows: 1 }} title={false} />
|
||||||
|
</AdminCard>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { Card } from "antd";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export function MetricCard({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
suffix,
|
||||||
|
extra,
|
||||||
|
}: {
|
||||||
|
label: ReactNode;
|
||||||
|
value: ReactNode;
|
||||||
|
suffix?: ReactNode;
|
||||||
|
extra?: ReactNode;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Card>
|
||||||
|
<div className="admin-metric-label">{label}</div>
|
||||||
|
<div className="admin-metric-value">
|
||||||
|
{value}
|
||||||
|
{suffix ? <span className="admin-metric-suffix">{suffix}</span> : null}
|
||||||
|
</div>
|
||||||
|
{extra}
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,5 +1,10 @@
|
|||||||
import { Alert, Button, Card, Empty, Result, Spin } from "antd";
|
import { Button } from "antd";
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
|
import { LoadingStack } from "./LoadingStack.js";
|
||||||
|
|
||||||
|
function errorMessage(error: unknown, fallback: string) {
|
||||||
|
return error instanceof Error ? error.message : fallback;
|
||||||
|
}
|
||||||
|
|
||||||
export function QueryState({
|
export function QueryState({
|
||||||
loading,
|
loading,
|
||||||
@@ -12,36 +17,31 @@ export function QueryState({
|
|||||||
onRetry?: () => void;
|
onRetry?: () => void;
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
if (loading)
|
if (loading) return <LoadingStack />;
|
||||||
return (
|
if (error) return <ErrorNote error={error} onRetry={onRetry} />;
|
||||||
<Card>
|
|
||||||
<Spin />
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
if (error) {
|
|
||||||
return (
|
|
||||||
<Result
|
|
||||||
status="error"
|
|
||||||
title="内容加载失败"
|
|
||||||
subTitle={error instanceof Error ? error.message : "请检查 API 服务后重试"}
|
|
||||||
extra={onRetry ? <Button onClick={onRetry}>重新加载</Button> : undefined}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function EmptyState({ description }: { description: string }) {
|
export function ErrorNote({
|
||||||
return <Empty description={description} image={Empty.PRESENTED_IMAGE_SIMPLE} />;
|
error,
|
||||||
|
onRetry,
|
||||||
|
}: {
|
||||||
|
error?: unknown;
|
||||||
|
onRetry?: (() => void) | undefined;
|
||||||
|
}) {
|
||||||
|
if (!error) return null;
|
||||||
|
return (
|
||||||
|
<div className="admin-error-note" role="alert">
|
||||||
|
<span>{errorMessage(error, "操作失败,请重试")}</span>
|
||||||
|
{onRetry ? (
|
||||||
|
<Button type="link" size="small" onClick={onRetry}>
|
||||||
|
重试
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function MutationError({ error }: { error?: unknown }) {
|
export function MutationError({ error }: { error?: unknown }) {
|
||||||
if (!error) return null;
|
return <ErrorNote error={error} />;
|
||||||
return (
|
|
||||||
<Alert
|
|
||||||
type="error"
|
|
||||||
showIcon
|
|
||||||
message={error instanceof Error ? error.message : "操作失败,请重试"}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,95 +1,42 @@
|
|||||||
import {
|
import { Alert, Button, Col, Form, Row, Space, Typography } from "antd";
|
||||||
Alert,
|
|
||||||
Button,
|
|
||||||
Col,
|
|
||||||
Form,
|
|
||||||
Input,
|
|
||||||
InputNumber,
|
|
||||||
Row,
|
|
||||||
Select,
|
|
||||||
Space,
|
|
||||||
Switch,
|
|
||||||
Typography,
|
|
||||||
message,
|
|
||||||
} from "antd";
|
|
||||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
||||||
import { useEffect, useMemo } from "react";
|
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import type {
|
import type { TemplateAdminSection } from "@personal-brand/api-client";
|
||||||
Offering,
|
|
||||||
TemplateAdminField,
|
|
||||||
TemplateAdminSection,
|
|
||||||
TrustContent,
|
|
||||||
} from "@personal-brand/api-client";
|
|
||||||
import { createApiClient } from "../lib/api.js";
|
|
||||||
import { ImageUrlField } from "./ImageUrlField.js";
|
|
||||||
import { TemplateListField } from "./TemplateListField.js";
|
import { TemplateListField } from "./TemplateListField.js";
|
||||||
|
import { TemplateFieldRenderer } from "./TemplateFieldRenderer.js";
|
||||||
import { MutationError } from "./QueryState.js";
|
import { MutationError } from "./QueryState.js";
|
||||||
import {
|
import { presentationFieldName } from "../lib/presentation/presentation-bindings.js";
|
||||||
applyPresentationValues,
|
import { useRecordContentEditorState } from "./record-content/useRecordContentEditorState.js";
|
||||||
applyStandardEntityValues,
|
import type { RecordContentEditorProps, RecordContentSource } from "./record-content/types.js";
|
||||||
presentationFieldName,
|
|
||||||
readPresentationValue,
|
|
||||||
type PresentationValues,
|
|
||||||
} from "../features/brand/presentation-bindings.js";
|
|
||||||
|
|
||||||
export type RecordContentSource = "offering" | "trust";
|
export type { RecordContentEditorProps, RecordContentSource };
|
||||||
|
|
||||||
export interface RecordContentEditorProps {
|
export function RecordContentFields({
|
||||||
source: RecordContentSource;
|
section,
|
||||||
record: Offering | TrustContent;
|
sectionKey = section.key,
|
||||||
|
}: {
|
||||||
section: TemplateAdminSection;
|
section: TemplateAdminSection;
|
||||||
context: "visual" | "services";
|
sectionKey?: string;
|
||||||
onDraft?: (values: PresentationValues) => void;
|
}) {
|
||||||
onSaved?: () => void;
|
|
||||||
visualSelection?: { targetKey: string; page: string };
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderField(field: TemplateAdminField) {
|
|
||||||
if (field.input === "textarea")
|
|
||||||
return (
|
|
||||||
<Input.TextArea
|
|
||||||
rows={3}
|
|
||||||
maxLength={field.maxLength}
|
|
||||||
showCount={!!field.maxLength}
|
|
||||||
placeholder={field.placeholder}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
if (field.input === "image")
|
|
||||||
return <ImageUrlField {...(field.placeholder ? { placeholder: field.placeholder } : {})} />;
|
|
||||||
if (field.input === "phone") return <Input type="tel" placeholder={field.placeholder} />;
|
|
||||||
if (field.input === "number") return <InputNumber min={0} placeholder={field.placeholder} />;
|
|
||||||
if (field.input === "boolean") return <Switch />;
|
|
||||||
if (field.input === "select")
|
|
||||||
return <Select options={(field.options ?? []).map((item) => ({ ...item }))} />;
|
|
||||||
if (field.input === "multi-select")
|
|
||||||
return (
|
|
||||||
<Select
|
|
||||||
mode="multiple"
|
|
||||||
options={(field.options ?? []).map((item) => ({ ...item }))}
|
|
||||||
placeholder={field.placeholder}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
return <Input placeholder={field.placeholder} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function RecordContentFields({ section }: { section: TemplateAdminSection }) {
|
|
||||||
return (
|
return (
|
||||||
<Row gutter={16}>
|
<Row gutter={16}>
|
||||||
{section.fields.map((field) => (
|
{section.fields.map((field) => (
|
||||||
<Col key={field.key} xs={24} md={24}>
|
<Col key={field.key} xs={24} md={24}>
|
||||||
{field.input === "list" ? (
|
{field.input === "list" ? (
|
||||||
<TemplateListField field={field} name={presentationFieldName(section.key, field.key)} />
|
<TemplateListField field={field} name={presentationFieldName(sectionKey, field.key)} />
|
||||||
) : (
|
) : (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name={presentationFieldName(section.key, field.key)}
|
name={presentationFieldName(sectionKey, field.key)}
|
||||||
label={field.label}
|
label={field.label}
|
||||||
|
htmlFor={presentationFieldName(sectionKey, field.key)}
|
||||||
{...(field.help ? { help: field.help } : {})}
|
{...(field.help ? { help: field.help } : {})}
|
||||||
{...(field.required
|
{...(field.required
|
||||||
? { rules: [{ required: true, message: `请填写${field.label}` }] }
|
? { rules: [{ required: true, message: `请填写${field.label}` }] }
|
||||||
: {})}
|
: {})}
|
||||||
>
|
>
|
||||||
{renderField(field)}
|
<TemplateFieldRenderer
|
||||||
|
field={field}
|
||||||
|
id={presentationFieldName(sectionKey, field.key)}
|
||||||
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
@@ -108,68 +55,28 @@ export function RecordContentEditor({
|
|||||||
visualSelection,
|
visualSelection,
|
||||||
}: RecordContentEditorProps) {
|
}: RecordContentEditorProps) {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [form] = Form.useForm<PresentationValues>();
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const recordName = "name" in record ? record.name : record.title;
|
const recordName = "name" in record ? record.name : record.title;
|
||||||
const initialValues = useMemo(
|
const { form, handleValuesChange, initialValues, save, submit } = useRecordContentEditorState({
|
||||||
() =>
|
|
||||||
Object.fromEntries(
|
|
||||||
section.fields.map((field) => [
|
|
||||||
presentationFieldName(section.key, field.key),
|
|
||||||
readPresentationValue(
|
|
||||||
record.config,
|
|
||||||
field.binding,
|
|
||||||
field,
|
|
||||||
record as unknown as Record<string, unknown>,
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
[record, section],
|
|
||||||
);
|
|
||||||
useEffect(() => form.setFieldsValue(initialValues), [form, initialValues]);
|
|
||||||
const save = useMutation({
|
|
||||||
mutationFn: async (values: PresentationValues): Promise<void> => {
|
|
||||||
const config = applyPresentationValues(record.config, [section], values);
|
|
||||||
const standard = applyStandardEntityValues(
|
|
||||||
record as unknown as Record<string, unknown>,
|
|
||||||
source,
|
source,
|
||||||
[section],
|
record,
|
||||||
values,
|
section,
|
||||||
);
|
...(onDraft ? { onDraft } : {}),
|
||||||
const changed = Object.fromEntries(
|
...(onSaved ? { onSaved } : {}),
|
||||||
Object.entries(standard).filter(
|
|
||||||
([key, value]) =>
|
|
||||||
key !== "config" && value !== (record as unknown as Record<string, unknown>)[key],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
const client = createApiClient();
|
|
||||||
if (source === "offering")
|
|
||||||
await client.updateAdminOffering(record.id, { ...changed, config });
|
|
||||||
else await client.updateAdminTrustContent(record.id, { ...changed, config });
|
|
||||||
},
|
|
||||||
onSuccess: () => {
|
|
||||||
message.success("已保存内容草稿,发布后访客才会看到更新");
|
|
||||||
onSaved?.();
|
|
||||||
void queryClient.invalidateQueries({
|
|
||||||
queryKey: [source === "offering" ? "admin-offerings" : "trust-content"],
|
|
||||||
});
|
|
||||||
void queryClient.invalidateQueries({ queryKey: ["admin-workspace"] });
|
|
||||||
void queryClient.invalidateQueries({ queryKey: ["admin-preview-workspace"] });
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
form={form}
|
form={form}
|
||||||
layout="vertical"
|
layout="vertical"
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
onValuesChange={(_, values) => onDraft?.(values)}
|
onValuesChange={handleValuesChange}
|
||||||
onFinish={(values) => save.mutate(values)}
|
onFinish={submit}
|
||||||
style={{ minHeight: 0, display: "flex", flexDirection: "column" }}
|
className="admin-form-column"
|
||||||
>
|
>
|
||||||
<Alert
|
<Alert
|
||||||
type="info"
|
type="info"
|
||||||
showIcon
|
showIcon
|
||||||
message={
|
title={
|
||||||
source === "offering"
|
source === "offering"
|
||||||
? `正在编辑业务提供项:${recordName}`
|
? `正在编辑业务提供项:${recordName}`
|
||||||
: `正在编辑信任内容:${recordName}`
|
: `正在编辑信任内容:${recordName}`
|
||||||
@@ -181,11 +88,11 @@ export function RecordContentEditor({
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{save.isPending ? <Typography.Text type="secondary">正在保存内容…</Typography.Text> : null}
|
{save.isPending ? <Typography.Text type="secondary">正在保存内容…</Typography.Text> : null}
|
||||||
<Typography.Paragraph type="secondary">{section.description}</Typography.Paragraph>
|
<p className="admin-section-description">{section.description}</p>
|
||||||
<div style={{ flex: 1 }}>
|
<div className="admin-flex-1">
|
||||||
<RecordContentFields section={section} />
|
<RecordContentFields section={section} />
|
||||||
</div>
|
</div>
|
||||||
<Space direction="vertical" style={{ width: "100%", marginTop: 24 }}>
|
<div className="admin-actions admin-offset-top-lg">
|
||||||
<MutationError error={save.error} />
|
<MutationError error={save.error} />
|
||||||
<Space wrap>
|
<Space wrap>
|
||||||
<Button type="primary" htmlType="submit" loading={save.isPending}>
|
<Button type="primary" htmlType="submit" loading={save.isPending}>
|
||||||
@@ -197,7 +104,7 @@ export function RecordContentEditor({
|
|||||||
onClick={() =>
|
onClick={() =>
|
||||||
navigate("/admin/brand", {
|
navigate("/admin/brand", {
|
||||||
state: {
|
state: {
|
||||||
targetKey: visualSelection?.targetKey ?? "linjing-editorial.offerings.item",
|
targetKey: visualSelection?.targetKey ?? "offering.list.item",
|
||||||
recordId: record.id,
|
recordId: record.id,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -207,7 +114,7 @@ export function RecordContentEditor({
|
|||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : null}
|
||||||
</Space>
|
</Space>
|
||||||
</Space>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
export type StatusTone = "success" | "warning" | "error" | "info" | "neutral";
|
||||||
|
|
||||||
|
const TONE_BY_STATUS: Record<string, StatusTone> = {
|
||||||
|
published: "success",
|
||||||
|
approved: "success",
|
||||||
|
completed: "success",
|
||||||
|
active: "success",
|
||||||
|
enabled: "success",
|
||||||
|
building: "info",
|
||||||
|
built: "neutral",
|
||||||
|
uploaded: "info",
|
||||||
|
pending: "neutral",
|
||||||
|
draft: "neutral",
|
||||||
|
superseded: "neutral",
|
||||||
|
disabled: "neutral",
|
||||||
|
review: "warning",
|
||||||
|
reviewing: "warning",
|
||||||
|
under_review: "warning",
|
||||||
|
processing: "warning",
|
||||||
|
rejected: "error",
|
||||||
|
failed: "error",
|
||||||
|
error: "error",
|
||||||
|
};
|
||||||
|
|
||||||
|
const LABELS: Record<string, string> = {
|
||||||
|
published: "已发布",
|
||||||
|
approved: "已通过",
|
||||||
|
completed: "已完成",
|
||||||
|
active: "已启用",
|
||||||
|
enabled: "已公开",
|
||||||
|
building: "构建中",
|
||||||
|
built: "待上传",
|
||||||
|
uploaded: "已上传微信",
|
||||||
|
pending: "待处理",
|
||||||
|
draft: "草稿",
|
||||||
|
superseded: "已过期",
|
||||||
|
disabled: "已停用",
|
||||||
|
review: "审核中",
|
||||||
|
reviewing: "审核中",
|
||||||
|
under_review: "审核中",
|
||||||
|
processing: "处理中",
|
||||||
|
rejected: "已拒绝",
|
||||||
|
failed: "失败",
|
||||||
|
error: "异常",
|
||||||
|
};
|
||||||
|
|
||||||
|
export function statusLabel(status: string | null | undefined, fallback = "未知"): string {
|
||||||
|
if (!status) return fallback;
|
||||||
|
return LABELS[status] ?? status;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function StatusTag({
|
||||||
|
status,
|
||||||
|
label,
|
||||||
|
tone,
|
||||||
|
}: {
|
||||||
|
status?: string | null;
|
||||||
|
label?: string;
|
||||||
|
tone?: StatusTone;
|
||||||
|
}) {
|
||||||
|
const resolvedTone = tone ?? (status ? TONE_BY_STATUS[status] : undefined) ?? "neutral";
|
||||||
|
return (
|
||||||
|
<span className="admin-status-tag" data-tone={resolvedTone}>
|
||||||
|
{label ?? statusLabel(status)}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { Skeleton } from "antd";
|
||||||
|
|
||||||
|
export function TableSkeleton({ rows = 4 }: { rows?: number }) {
|
||||||
|
return (
|
||||||
|
<div className="admin-table-skeleton" role="status" aria-live="polite">
|
||||||
|
{Array.from({ length: rows }).map((_, index) => (
|
||||||
|
<div key={index} className="admin-table-skeleton__row">
|
||||||
|
<Skeleton.Input active size="small" block />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ListSkeleton({ rows = 3 }: { rows?: number }) {
|
||||||
|
return (
|
||||||
|
<div className="admin-list-skeleton" role="status" aria-live="polite">
|
||||||
|
{Array.from({ length: rows }).map((_, index) => (
|
||||||
|
<div key={index} className="admin-list-skeleton__row">
|
||||||
|
<Skeleton.Input active size="small" className="admin-list-skeleton__thumb" />
|
||||||
|
<div className="admin-list-skeleton__body">
|
||||||
|
<Skeleton.Input active size="small" block />
|
||||||
|
<Skeleton.Input active size="small" block />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
import { Input, InputNumber, Select, Switch } from "antd";
|
||||||
|
import type { TemplateAdminField } from "@personal-brand/api-client";
|
||||||
|
import { ImageUrlField } from "./ImageUrlField.js";
|
||||||
|
|
||||||
|
export function TemplateFieldRenderer({
|
||||||
|
field,
|
||||||
|
id,
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
}: {
|
||||||
|
field: TemplateAdminField;
|
||||||
|
id?: string;
|
||||||
|
value?: unknown;
|
||||||
|
onChange?: (value: unknown) => void;
|
||||||
|
}) {
|
||||||
|
if (field.input === "textarea")
|
||||||
|
return (
|
||||||
|
<Input.TextArea
|
||||||
|
{...(id ? { id } : {})}
|
||||||
|
value={typeof value === "string" ? value : ""}
|
||||||
|
onChange={(event) => onChange?.(event.target.value)}
|
||||||
|
rows={3}
|
||||||
|
maxLength={field.maxLength}
|
||||||
|
showCount={!!field.maxLength}
|
||||||
|
placeholder={field.placeholder}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
if (field.input === "image")
|
||||||
|
return (
|
||||||
|
<ImageUrlField
|
||||||
|
{...(id ? { id } : {})}
|
||||||
|
{...(field.placeholder ? { placeholder: field.placeholder } : {})}
|
||||||
|
{...(typeof value === "string" ? { value } : {})}
|
||||||
|
{...(onChange ? { onChange: (next: string) => onChange(next) } : {})}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
if (field.input === "phone")
|
||||||
|
return (
|
||||||
|
<Input
|
||||||
|
{...(id ? { id } : {})}
|
||||||
|
type="tel"
|
||||||
|
placeholder={field.placeholder}
|
||||||
|
value={typeof value === "string" ? value : ""}
|
||||||
|
onChange={(event) => onChange?.(event.target.value)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
if (field.input === "number")
|
||||||
|
return (
|
||||||
|
<InputNumber
|
||||||
|
{...(id ? { id } : {})}
|
||||||
|
value={typeof value === "number" ? value : null}
|
||||||
|
onChange={(input) => onChange?.(input ?? undefined)}
|
||||||
|
min={0}
|
||||||
|
className="admin-block"
|
||||||
|
placeholder={field.placeholder}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
if (field.input === "boolean")
|
||||||
|
return (
|
||||||
|
<Switch
|
||||||
|
{...(id ? { id } : {})}
|
||||||
|
checked={Boolean(value)}
|
||||||
|
onChange={(checked) => onChange?.(checked)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
if (field.input === "select")
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
{...(id ? { id } : {})}
|
||||||
|
options={(field.options ?? []).map((item) => ({ ...item }))}
|
||||||
|
value={typeof value === "string" || typeof value === "number" ? value : undefined}
|
||||||
|
onChange={(selected) => onChange?.(selected)}
|
||||||
|
{...(field.placeholder ? { placeholder: field.placeholder } : {})}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
if (field.input === "multi-select")
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
{...(id ? { id } : {})}
|
||||||
|
mode="multiple"
|
||||||
|
options={(field.options ?? []).map((item) => ({ ...item }))}
|
||||||
|
value={Array.isArray(value) ? value.map(String) : []}
|
||||||
|
onChange={(selected) => onChange?.(selected)}
|
||||||
|
placeholder={field.placeholder}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<Input
|
||||||
|
{...(id ? { id } : {})}
|
||||||
|
value={typeof value === "string" ? value : ""}
|
||||||
|
onChange={(event) => onChange?.(event.target.value)}
|
||||||
|
maxLength={field.maxLength}
|
||||||
|
placeholder={field.placeholder}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,5 +1,12 @@
|
|||||||
import { Button, Form, Input, Space } from "antd";
|
import { Button, Card, Collapse, Form, Input, Space, Typography } from "antd";
|
||||||
|
import {
|
||||||
|
CaretDownOutlined,
|
||||||
|
CaretUpOutlined,
|
||||||
|
DeleteOutlined,
|
||||||
|
PlusOutlined,
|
||||||
|
} from "@ant-design/icons";
|
||||||
import type { TemplateAdminField } from "@personal-brand/api-client";
|
import type { TemplateAdminField } from "@personal-brand/api-client";
|
||||||
|
import { EmptyState } from "./EmptyState.js";
|
||||||
|
|
||||||
export function TemplateListField({
|
export function TemplateListField({
|
||||||
field,
|
field,
|
||||||
@@ -22,14 +29,76 @@ export function TemplateListField({
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{(rows, { add, remove, move }, { errors }) => (
|
{(rows, { add, remove, move }, { errors }) => (
|
||||||
<Space direction="vertical" style={{ width: "100%" }}>
|
<div className="admin-stack admin-stack-tight">
|
||||||
{rows.map((row, index) => (
|
{rows.length === 0 ? <EmptyState compact title={`还没有${field.label}内容`} /> : null}
|
||||||
<Space key={row.key} align="start" wrap>
|
{rows.map((row, index) => {
|
||||||
|
const titleField = field.itemFields?.[0];
|
||||||
|
const primaryTitle = titleField ? (
|
||||||
|
<Form.Item
|
||||||
|
noStyle
|
||||||
|
shouldUpdate={(prev: unknown, next: unknown) => {
|
||||||
|
const previous = Array.isArray(prev)
|
||||||
|
? (prev[row.name] as Record<string, unknown> | undefined)
|
||||||
|
: undefined;
|
||||||
|
const nextRow = Array.isArray(next)
|
||||||
|
? (next[row.name] as Record<string, unknown> | undefined)
|
||||||
|
: undefined;
|
||||||
|
return previous?.[titleField.key] !== nextRow?.[titleField.key];
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{({ getFieldValue }) => {
|
||||||
|
const value = String(
|
||||||
|
getFieldValue([...name, row.name, titleField.key] as const) ?? "",
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<Typography.Text
|
||||||
|
strong
|
||||||
|
>{`${index + 1}. ${value || titleField.label}`}</Typography.Text>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</Form.Item>
|
||||||
|
) : (
|
||||||
|
<Typography.Text strong>{`${index + 1}. ${field.label}`}</Typography.Text>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
key={row.key}
|
||||||
|
size="small"
|
||||||
|
title={primaryTitle}
|
||||||
|
extra={
|
||||||
|
<Space size={0}>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
aria-label={`上移第 ${index + 1} 项`}
|
||||||
|
icon={<CaretUpOutlined />}
|
||||||
|
disabled={index === 0}
|
||||||
|
onClick={() => move(index, index - 1)}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
aria-label={`下移第 ${index + 1} 项`}
|
||||||
|
icon={<CaretDownOutlined />}
|
||||||
|
disabled={index === rows.length - 1}
|
||||||
|
onClick={() => move(index, index + 1)}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
danger
|
||||||
|
size="small"
|
||||||
|
aria-label={`删除第 ${index + 1} 项`}
|
||||||
|
icon={<DeleteOutlined />}
|
||||||
|
onClick={() => remove(row.name)}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
}
|
||||||
|
>
|
||||||
{field.itemFields?.map((itemField) => (
|
{field.itemFields?.map((itemField) => (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
key={itemField.key}
|
key={itemField.key}
|
||||||
name={[row.name, itemField.key]}
|
name={[row.name, itemField.key]}
|
||||||
label={`${index + 1}. ${itemField.label}`}
|
label={itemField.label}
|
||||||
rules={
|
rules={
|
||||||
itemField.required === false
|
itemField.required === false
|
||||||
? []
|
? []
|
||||||
@@ -39,26 +108,30 @@ export function TemplateListField({
|
|||||||
{itemField.input === "textarea" ? <Input.TextArea rows={2} /> : <Input />}
|
{itemField.input === "textarea" ? <Input.TextArea rows={2} /> : <Input />}
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
))}
|
))}
|
||||||
<Button onClick={() => remove(row.name)}>删除</Button>
|
</Card>
|
||||||
<Button
|
);
|
||||||
aria-label={`上移第 ${index + 1} 项`}
|
})}
|
||||||
disabled={index === 0}
|
{rows.length > 1 ? (
|
||||||
onClick={() => move(index, index - 1)}
|
<Collapse
|
||||||
>
|
ghost
|
||||||
上移
|
items={[
|
||||||
</Button>
|
{
|
||||||
<Button
|
key: "sort-help",
|
||||||
aria-label={`下移第 ${index + 1} 项`}
|
label: "排序说明",
|
||||||
disabled={index === rows.length - 1}
|
children: (
|
||||||
onClick={() => move(index, index + 1)}
|
<Typography.Text type="secondary">
|
||||||
>
|
使用每张卡片右上角的箭头调整顺序,保存后预览也会按当前顺序展示。
|
||||||
下移
|
</Typography.Text>
|
||||||
</Button>
|
),
|
||||||
</Space>
|
},
|
||||||
))}
|
]}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
<Form.ErrorList errors={errors} />
|
<Form.ErrorList errors={errors} />
|
||||||
<Button onClick={() => add()}>新增{field.label}</Button>
|
<Button block icon={<PlusOutlined />} onClick={() => add()}>
|
||||||
</Space>
|
新增{field.label}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</Form.List>
|
</Form.List>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import type { Offering, TemplateAdminSection, TrustContent } from "@personal-brand/api-client";
|
||||||
|
import type { PresentationValues } from "../../lib/presentation/presentation-bindings.js";
|
||||||
|
|
||||||
|
export type RecordContentSource = "offering" | "trust";
|
||||||
|
|
||||||
|
export interface RecordContentEditorProps {
|
||||||
|
source: RecordContentSource;
|
||||||
|
record: Offering | TrustContent;
|
||||||
|
section: TemplateAdminSection;
|
||||||
|
context: "visual" | "services";
|
||||||
|
onDraft?: (values: PresentationValues) => void;
|
||||||
|
onSaved?: () => void;
|
||||||
|
visualSelection?: { targetKey: string; page: string };
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
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";
|
||||||
|
import type { Offering, TrustContent } from "@personal-brand/api-client";
|
||||||
|
import { createApiClient } from "../../lib/api.js";
|
||||||
|
import {
|
||||||
|
applyPresentationValues,
|
||||||
|
applyStandardEntityValues,
|
||||||
|
presentationFieldName,
|
||||||
|
readPresentationValue,
|
||||||
|
type PresentationValues,
|
||||||
|
} from "../../lib/presentation/presentation-bindings.js";
|
||||||
|
import type { RecordContentSource } from "./types.js";
|
||||||
|
|
||||||
|
function createInitialValues(
|
||||||
|
record: Offering | TrustContent,
|
||||||
|
section: TemplateAdminSection,
|
||||||
|
): PresentationValues {
|
||||||
|
return Object.fromEntries(
|
||||||
|
section.fields.map((field) => [
|
||||||
|
presentationFieldName(section.key, field.key),
|
||||||
|
readPresentationValue(
|
||||||
|
record.config,
|
||||||
|
field.binding,
|
||||||
|
field,
|
||||||
|
record as unknown as Record<string, unknown>,
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createChangedStandardValues(
|
||||||
|
record: Offering | TrustContent,
|
||||||
|
source: RecordContentSource,
|
||||||
|
section: TemplateAdminSection,
|
||||||
|
values: PresentationValues,
|
||||||
|
) {
|
||||||
|
const entity = record as unknown as Record<string, unknown>;
|
||||||
|
const standard = applyStandardEntityValues(entity, source, [section], values);
|
||||||
|
|
||||||
|
return Object.fromEntries(
|
||||||
|
Object.entries(standard).filter(
|
||||||
|
([key, value]) => key !== "config" && (key in entity || value !== entity[key]),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRecordContentEditorState({
|
||||||
|
source,
|
||||||
|
record,
|
||||||
|
section,
|
||||||
|
onDraft,
|
||||||
|
onSaved,
|
||||||
|
}: {
|
||||||
|
source: RecordContentSource;
|
||||||
|
record: Offering | TrustContent;
|
||||||
|
section: TemplateAdminSection;
|
||||||
|
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>(() =>
|
||||||
|
createInitialValues(record, section),
|
||||||
|
);
|
||||||
|
const initialValues = useMemo(() => createInitialValues(record, section), [record, section]);
|
||||||
|
|
||||||
|
useEffect(() => form.setFieldsValue(initialValues), [form, initialValues]);
|
||||||
|
|
||||||
|
const save = useMutation({
|
||||||
|
mutationFn: async (values: PresentationValues): Promise<void> => {
|
||||||
|
const config = applyPresentationValues(record.config, [section], values);
|
||||||
|
const changed = createChangedStandardValues(record, source, section, values);
|
||||||
|
const client = createApiClient();
|
||||||
|
|
||||||
|
if (source === "offering") {
|
||||||
|
await client.updateAdminOffering(record.id, { ...changed, config });
|
||||||
|
} else {
|
||||||
|
await client.updateAdminTrustContent(record.id, { ...changed, config });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
message.success("已保存内容草稿,发布后访客才会看到更新");
|
||||||
|
onSaved?.();
|
||||||
|
void queryClient.invalidateQueries({
|
||||||
|
queryKey: [source === "offering" ? "admin-offerings" : "trust-content"],
|
||||||
|
});
|
||||||
|
void queryClient.invalidateQueries({ queryKey: ["admin-workspace"] });
|
||||||
|
void queryClient.invalidateQueries({ queryKey: ["admin-preview-workspace"] });
|
||||||
|
if (source === "offering") {
|
||||||
|
void queryClient.invalidateQueries({ queryKey: ["admin-workspace-offering-fields"] });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const submit = (values: PresentationValues) => {
|
||||||
|
const currentValues = form.getFieldsValue(true) as PresentationValues;
|
||||||
|
save.mutate({ ...draftValues, ...values, ...currentValues });
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleValuesChange = (_values: PresentationValues) => {
|
||||||
|
const currentValues = form.getFieldsValue(true) as PresentationValues;
|
||||||
|
const next = { ...draftValues, ..._values, ...currentValues };
|
||||||
|
setDraftValues(next);
|
||||||
|
onDraft?.(next);
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
draftValues,
|
||||||
|
form,
|
||||||
|
handleValuesChange,
|
||||||
|
initialValues,
|
||||||
|
save,
|
||||||
|
submit,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import { App } from "antd";
|
||||||
|
import { createApiClient } from "../../lib/api.js";
|
||||||
|
import { BrandMark } from "../../components/BrandMark.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: 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);
|
||||||
|
onLogin(result);
|
||||||
|
} catch (error) {
|
||||||
|
message.error(error instanceof Error ? error.message : "登录失败");
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div className="admin-auth">
|
||||||
|
<AdminCard className="admin-auth-card">
|
||||||
|
<div className="admin-auth-brand">
|
||||||
|
<BrandMark />
|
||||||
|
<span className="admin-header-brand">个人品牌后台</span>
|
||||||
|
</div>
|
||||||
|
<p className="admin-auth-hint">管理你的品牌表达、内容发布与客户咨询。</p>
|
||||||
|
<AdminForm form={form} layout="vertical" onFinish={submit}>
|
||||||
|
<AdminForm.Item
|
||||||
|
name="username"
|
||||||
|
label="账号"
|
||||||
|
initialValue="admin"
|
||||||
|
rules={[{ required: true }]}
|
||||||
|
>
|
||||||
|
<AdminInput />
|
||||||
|
</AdminForm.Item>
|
||||||
|
<AdminForm.Item name="password" label="密码" rules={[{ required: true }]}>
|
||||||
|
<AdminInput.Password />
|
||||||
|
</AdminForm.Item>
|
||||||
|
<AdminButton type="primary" size="large" htmlType="submit" loading={loading} block>
|
||||||
|
登录
|
||||||
|
</AdminButton>
|
||||||
|
</AdminForm>
|
||||||
|
<p className="admin-auth-footnote">仅限授权成员访问。</p>
|
||||||
|
</AdminCard>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ChangePassword({ onComplete }: { onComplete: () => void }) {
|
||||||
|
const { message } = App.useApp();
|
||||||
|
const [form] = AdminForm.useForm<{
|
||||||
|
currentPassword: string;
|
||||||
|
newPassword: string;
|
||||||
|
confirmPassword: string;
|
||||||
|
}>();
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
async function submit(values: {
|
||||||
|
currentPassword: string;
|
||||||
|
newPassword: string;
|
||||||
|
confirmPassword: string;
|
||||||
|
}) {
|
||||||
|
if (values.newPassword !== values.confirmPassword) {
|
||||||
|
message.error("两次输入的新密码不一致");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
await createApiClient().changeAdminPassword(values.currentPassword, values.newPassword);
|
||||||
|
message.success("密码已更新");
|
||||||
|
onComplete();
|
||||||
|
} catch (error) {
|
||||||
|
message.error(error instanceof Error ? error.message : "密码更新失败");
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div className="admin-auth">
|
||||||
|
<AdminCard className="admin-auth-card">
|
||||||
|
<div className="admin-auth-brand">
|
||||||
|
<BrandMark />
|
||||||
|
<span className="admin-header-brand">首次登录需要修改密码</span>
|
||||||
|
</div>
|
||||||
|
<p className="admin-auth-hint">请先设置只有你本人知道的新密码。</p>
|
||||||
|
<AdminForm form={form} layout="vertical" onFinish={submit}>
|
||||||
|
<AdminForm.Item name="currentPassword" label="初始密码" rules={[{ required: true }]}>
|
||||||
|
<AdminInput.Password />
|
||||||
|
</AdminForm.Item>
|
||||||
|
<AdminForm.Item
|
||||||
|
name="newPassword"
|
||||||
|
label="新密码"
|
||||||
|
rules={[{ required: true, min: 8, message: "请输入至少 8 位新密码" }]}
|
||||||
|
>
|
||||||
|
<AdminInput.Password />
|
||||||
|
</AdminForm.Item>
|
||||||
|
<AdminForm.Item name="confirmPassword" label="确认密码" rules={[{ required: true }]}>
|
||||||
|
<AdminInput.Password />
|
||||||
|
</AdminForm.Item>
|
||||||
|
<AdminButton type="primary" size="large" htmlType="submit" loading={loading} block>
|
||||||
|
保存新密码
|
||||||
|
</AdminButton>
|
||||||
|
</AdminForm>
|
||||||
|
</AdminCard>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,19 +1,29 @@
|
|||||||
.brand-page__content {
|
|
||||||
max-width: 960px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.brand-page__content[hidden] {
|
.brand-page__content[hidden] {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.brand-page__toolbar {
|
.brand-page__toolbar {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 16px;
|
gap: 16px;
|
||||||
padding: 16px 0;
|
padding: 8px 12px;
|
||||||
border-bottom: 1px solid #e5e7eb;
|
border: 1px solid var(--admin-border);
|
||||||
margin-bottom: 20px;
|
border-radius: 10px;
|
||||||
|
background: var(--admin-fill-quiet);
|
||||||
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.brand-page__toolbar .ant-segmented {
|
||||||
|
background: var(--admin-surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand-page__toolbar-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 575px) {
|
@media (max-width: 575px) {
|
||||||
.brand-page__toolbar {
|
.brand-page__toolbar {
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
@@ -25,54 +35,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.brand-settings-section {
|
.brand-settings-section {
|
||||||
padding: 24px 0;
|
padding: 20px;
|
||||||
border-top: 1px solid #f0f0f0;
|
border: 1px solid var(--admin-border);
|
||||||
|
border-radius: 10px;
|
||||||
|
background: var(--admin-surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
.brand-settings-section:first-child {
|
.brand-settings-section + .brand-settings-section {
|
||||||
padding-top: 8px;
|
margin-top: 16px;
|
||||||
border-top: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.brand-settings-section__header {
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 16px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.brand-settings-section__header .ant-typography {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.brand-settings-section__header .ant-typography + .ant-typography {
|
|
||||||
display: block;
|
|
||||||
margin-top: 4px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.brand-page__template-note {
|
.brand-page__template-note {
|
||||||
margin-top: 24px;
|
margin-top: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 1199px) {
|
@media (max-width: 1199px) {
|
||||||
.brand-page__content {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.brand-page__template-note {
|
.brand-page__template-note {
|
||||||
position: static;
|
position: static;
|
||||||
margin-top: 24px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 575px) {
|
|
||||||
.brand-settings-section__header {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.brand-settings-section__header .ant-tag {
|
|
||||||
display: inline-block;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||