Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
083a323c1f |
No files matched your search
@@ -1,260 +0,0 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"scope": "模板完成证据登记,保留命令、日志与产物哈希",
|
||||
"generatedAt": "2026-10-20T09:00:52.740+00:00",
|
||||
"templates": {
|
||||
"acheng-campus-food": {
|
||||
"real-manifest-interaction": {
|
||||
"status": "passed",
|
||||
"commands": [
|
||||
"pnpm --filter @personal-brand/api test:integration",
|
||||
"ADMIN_URL=http://localhost: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": "775950266c3ec796f5af6eafabedae91a1fa6c1d4c71b29ca8d5b589b4846473"
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
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)
|
||||
@@ -1,18 +0,0 @@
|
||||
|
||||
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)
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
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)
|
||||
@@ -1,18 +0,0 @@
|
||||
|
||||
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)
|
||||
@@ -1,440 +0,0 @@
|
||||
|
||||
> @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
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
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)
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
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)
|
||||
|
Before Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 94 KiB |
|
Before Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 95 KiB |
|
Before Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 104 KiB |
|
Before Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 89 KiB |
@@ -6,11 +6,9 @@ POSTGRES_DB=personal_brand
|
||||
POSTGRES_PORT=5432
|
||||
API_PORT=3001
|
||||
API_PREFIX=
|
||||
CORS_ORIGINS=http://localhost:3000
|
||||
ADMIN_PORT=3000
|
||||
SESSION_SECRET=replace-with-a-long-random-value
|
||||
DEFAULT_BRAND_ID=00000000-0000-0000-0000-000000000001
|
||||
TEMPLATE_ARTIFACT_ROOT=/var/lib/personal-brand/template-artifacts
|
||||
SEED_ADMIN_PASSWORD=change-me-now-123
|
||||
OBJECT_STORAGE_ENDPOINT=http://localhost:9000
|
||||
OBJECT_STORAGE_PUBLIC_URL=http://localhost:9000/personal-brand-media
|
||||
|
||||
@@ -12,7 +12,6 @@ SEED_MODE=skip
|
||||
|
||||
API_PORT=3001
|
||||
API_PREFIX=
|
||||
CORS_ORIGINS=
|
||||
|
||||
LOCAL_MEDIA_ROOT=/home/ubuntu/persional-brand/media
|
||||
LOCAL_MEDIA_BASE_URL=/media
|
||||
|
||||
@@ -24,12 +24,6 @@ jobs:
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm check
|
||||
- run: pnpm test:api-routes
|
||||
- run: pnpm audit --prod --registry=https://registry.npmjs.org
|
||||
- run: pnpm validate:templates
|
||||
- run: pnpm template:compatibility
|
||||
- run: pnpm --filter @personal-brand/api exec tsx --test test/template-preview-matrix.test.ts
|
||||
- run: pnpm template:conformance
|
||||
- run: pnpm template:doctor
|
||||
|
||||
build:
|
||||
@@ -46,9 +40,7 @@ jobs:
|
||||
node-version: 24
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm build
|
||||
- run: pnpm build:admin:preview
|
||||
- run: pnpm validate:template-release
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: admin-dist
|
||||
@@ -75,9 +67,6 @@ jobs:
|
||||
--health-retries 12
|
||||
env:
|
||||
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/personal_brand
|
||||
DEFAULT_BRAND_ID: 00000000-0000-0000-0000-000000000001
|
||||
SESSION_SECRET: ci-integration-session-secret-0123456789abcdef
|
||||
SEED_ADMIN_PASSWORD: ci-integration-admin-password
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
@@ -88,64 +77,12 @@ jobs:
|
||||
node-version: 24
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- name: Prepare API test env
|
||||
working-directory: apps/api
|
||||
run: |
|
||||
cat > .env <<EOF
|
||||
DATABASE_URL=$DATABASE_URL
|
||||
DEFAULT_BRAND_ID=$DEFAULT_BRAND_ID
|
||||
SESSION_SECRET=$SESSION_SECRET
|
||||
SEED_ADMIN_PASSWORD=$SEED_ADMIN_PASSWORD
|
||||
EOF
|
||||
- run: pnpm --filter @personal-brand/api test:integration
|
||||
|
||||
taro:
|
||||
name: Taro builds
|
||||
runs-on: ubuntu-latest
|
||||
needs: [static]
|
||||
strategy:
|
||||
matrix:
|
||||
template: [acheng-campus-food, atelier-solopreneur, linjing-editorial]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9.15.0
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: TEMPLATE_KEY=acheng-campus-food pnpm --filter @personal-brand/taro build:h5
|
||||
env:
|
||||
TEMPLATE_KEY: ${{ matrix.template }}
|
||||
- run: TEMPLATE_KEY=acheng-campus-food pnpm --filter @personal-brand/taro build:weapp
|
||||
env:
|
||||
TEMPLATE_KEY: ${{ matrix.template }}
|
||||
|
||||
browser:
|
||||
name: Browser regression
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build, taro]
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
env:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: personal_brand
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
--health-cmd "pg_isready -U postgres -d personal_brand"
|
||||
--health-interval 5s
|
||||
--health-timeout 5s
|
||||
--health-retries 12
|
||||
env:
|
||||
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/personal_brand
|
||||
DEFAULT_BRAND_ID: 00000000-0000-0000-0000-000000000001
|
||||
SESSION_SECRET: ci-integration-session-secret-0123456789abcdef
|
||||
SEED_ADMIN_PASSWORD: ci-integration-admin-password
|
||||
needs: [build]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
@@ -157,24 +94,13 @@ jobs:
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm --filter @personal-brand/taro exec playwright install --with-deps chromium
|
||||
- name: Prepare API test env
|
||||
working-directory: apps/api
|
||||
run: |
|
||||
cat > .env <<EOF
|
||||
DATABASE_URL=$DATABASE_URL
|
||||
DEFAULT_BRAND_ID=$DEFAULT_BRAND_ID
|
||||
SESSION_SECRET=$SESSION_SECRET
|
||||
SEED_ADMIN_PASSWORD=$SEED_ADMIN_PASSWORD
|
||||
EOF
|
||||
- run: pnpm --filter @personal-brand/api db:migrate:deploy
|
||||
- run: pnpm --filter @personal-brand/api db:seed
|
||||
- run: pnpm --filter @personal-brand/api test:integration
|
||||
env:
|
||||
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/personal_brand
|
||||
- name: Start API
|
||||
run: pnpm --filter @personal-brand/api start > /tmp/api.log 2>&1 &
|
||||
env:
|
||||
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/personal_brand
|
||||
DEFAULT_BRAND_ID: 00000000-0000-0000-0000-000000000001
|
||||
SESSION_SECRET: browser-ci-session-secret-0123456789abcdef
|
||||
NODE_ENV: development
|
||||
- name: Start mini program preview
|
||||
run: pnpm --filter @personal-brand/taro dev:h5 > /tmp/taro.log 2>&1 &
|
||||
@@ -194,5 +120,3 @@ jobs:
|
||||
curl --retry 30 --retry-delay 1 --retry-connrefused -fsS http://localhost:3002
|
||||
curl --retry 30 --retry-delay 1 --retry-connrefused -fsS http://localhost:3000
|
||||
- run: pnpm --filter @personal-brand/taro exec playwright test --config=playwright.config.ts --reporter=line
|
||||
env:
|
||||
ADMIN_URL: http://localhost:3000
|
||||
@@ -26,5 +26,3 @@ media/
|
||||
.codex-tasks/
|
||||
docker-compose.override.yml
|
||||
.env.production
|
||||
|
||||
apps/api/storage/
|
||||
@@ -8,7 +8,6 @@
|
||||
- The food template is supported, but it is an example template rather than the product definition.
|
||||
- Backend configuration is the source of truth for brand content, services, template selection, trust-building content, and industry-specific fields. The mini program only renders configuration and submits user input.
|
||||
- Template packages are the source of truth for template manifests, visual structure, default/sample content, field declarations, assets, and capabilities. Do not copy every template's sample data into Prisma seed or global database tables. A template's sample content may be copied into the database only when an administrator explicitly imports it for one specific brand; the resulting rows are brand content, not template registration.
|
||||
- Templates have exactly one active package manifest/runtime contract. Do not add legacy readers, dual-write paths, inferred defaults, aliases, or silent fallbacks. Convert existing persisted data with a one-time, auditable migration that fails on ambiguity, then remove the old representation.
|
||||
- `apps/api/prisma/seed.ts` may contain a small, explicit development fixture for the seeded demo brands, but it must never become the catalog of all templates or require one seed block per production template. New templates must be discoverable and validated from their package manifest without editing global seed data.
|
||||
- Any delivered backend endpoint must have an automated test covering its authorization and successful behavior before it is considered complete.
|
||||
- Keep personal-brand trust details explicit: biography, positioning, credentials, portfolio/proof, process, expectations, availability, contact methods, and clear follow-up status.
|
||||
|
||||
@@ -1,77 +1,104 @@
|
||||
# Project Status
|
||||
|
||||
最后更新:2026-10-20
|
||||
最后更新:2026-09-19
|
||||
|
||||
## 当前目标
|
||||
|
||||
先为餐饮摊主朋友交付一个真正能带来订单的个人品牌小程序,再根据真实使用把通用能力产品化。产品方的收益、运营和平台化目标不能牺牲朋友的实际使用效果。
|
||||
|
||||
## 当前阶段
|
||||
|
||||
系统已从“餐饮试点小程序”演进为多模板个人品牌平台。当前分支完成了统一模板契约收口、模板完成证据门禁、管理员登录态撤销和 release 版本一致性修复。
|
||||
后端基础、数据库环境和订单 API 已完成首轮验证,管理后台和小程序静态页面已接入首版结构,下一步进行真实资源与微信登录/预约联调。
|
||||
|
||||
## 当前能力
|
||||
## 已完成
|
||||
|
||||
- NestJS + Fastify API、Prisma PostgreSQL、全局 DTO 校验、统一错误响应和 `requestId`。
|
||||
- 多品牌 Admin、品牌 membership、角色边界、品牌切换和品牌隔离。
|
||||
- 模板包发现、确定性打包、导入、校验、发布、预览、安装、升级和回滚。
|
||||
- 三套已交付模板:
|
||||
- `acheng-campus-food@1.0.3`
|
||||
- `atelier-solopreneur@1.3.2`
|
||||
- `linjing-editorial@1.0.7`
|
||||
- Taro Runtime、Admin 组件预览、真实 manifest 驱动编辑、草稿/发布隔离。
|
||||
- 依赖 override 的运行时兼容性通过 `miniprogram-ci` / Jimp / image-size / uuid smoke test 守卫。
|
||||
- 小程序构建、上传任务状态机、attempt lease 和失败记录。
|
||||
- Admin/Customer token version:修改 admin 密码或调用 logout 后旧 token 立即失效;无 membership 的账号不会自动获得 owner 权限。
|
||||
- `visualPresentation` 已进入唯一 `template.json` 契约,旧手写 visual manifest 优先路径已删除。
|
||||
- 产品 PRD、原型规格、架构决策、数据/API 设计和实施计划。
|
||||
- 餐饮试点画像与首轮需求访谈决策。
|
||||
- 可点击低保真原型:`prototype/index.html`。
|
||||
- Git 仓库、`main` 分支和远程仓库。
|
||||
- pnpm workspace + Turborepo Monorepo。
|
||||
- TypeScript 严格配置、ESLint、Prettier、EditorConfig、环境变量模板。
|
||||
- NestJS + Fastify API 骨架。
|
||||
- Prisma PostgreSQL schema:品牌、服务、客户身份、订单、订单明细、标签、管理员。
|
||||
- 微信官方 `jscode2session` 登录交换边界。
|
||||
- 客户登录 token、客户订单提交/查询/取消。
|
||||
- 普通套餐价格快照和私厨需求人工报价模型。
|
||||
- 管理员账号密码登录和角色 token。
|
||||
- 管理员订单列表、状态、未读、标签和内部备忘能力。
|
||||
- DTO 校验、全局异常响应、请求 ID和订单状态流转规则。
|
||||
- Docker PostgreSQL Compose、seed 和 Prisma 脚本说明。
|
||||
- 初始 Prisma migration,已在本地 PostgreSQL 应用并验证数据库 schema up to date。
|
||||
- seed 已写入品牌、服务、标签和管理员数据,并完成数量核验。
|
||||
- 管理员订单详情、状态/未读/标签筛选和未读数量接口。
|
||||
- API 自动化业务规则测试:订单创建、客户取消、状态流转和标签品牌隔离,共 6 项通过。
|
||||
- 修复 ESM 下 `bcryptjs` 导入和 Fastify 请求 ID middleware 的运行时问题。
|
||||
- API 已通过真实 HTTP 验证:健康检查、公开品牌/服务读取和管理员登录。
|
||||
- HTTP 集成测试:公开接口、管理员登录、错误密码、管理员权限边界、客户会话、预约 DTO 校验、创建/取消和状态流转,共 8 项通过。
|
||||
- OpenAPI 3.1 契约:`docs/openapi.yaml`,覆盖当前公开、客户和管理员接口。
|
||||
- 类型化 `@personal-brand/api-client`:支持公开内容、客户预约、管理员订单和统一错误处理,并有 2 项客户端测试。
|
||||
- 已根据 `/home/que01/桌面/个人品牌设计图/` 确认 C 端页面视觉规范:暖白、米黄、砖红、深炭黑,16px 卡片圆角和大字号优先。
|
||||
- 小程序已完成首页、服务列表、预约套餐和我的订单静态页面,页面标题使用微信原生导航栏。
|
||||
- 已配置小程序 AppID:`wxd75d946d6978d183`。
|
||||
- 服务分类、预约数量步进器、订单状态卡和底部导航已按设计图完成首版还原。
|
||||
- 已执行多轮 Codex 代码审查并修复关键认证和权限问题。
|
||||
|
||||
## 完成证据
|
||||
|
||||
`.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
|
||||
fee3c77 fix: 按设计图优化预约套餐数量和商品卡
|
||||
13ead2d fix: 对齐服务分类和订单视觉结构
|
||||
255756c feat: 增加小程序品牌首页
|
||||
本次工作:数据库初始化、订单管理接口、业务规则测试和运行时修复
|
||||
f2687c5 chore: prepare portable postgres development environment
|
||||
0e8b8e1 feat: add api http conventions and booking state rules
|
||||
0d4caab feat: add admin order tags and read state
|
||||
bb5ccb1 feat: add admin authentication
|
||||
b89853b fix: harden api authentication and validation
|
||||
```
|
||||
|
||||
## 已验证门禁
|
||||
远程:`https://git.app.que01.top/que01/persionalBrand.git`
|
||||
|
||||
- `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 build`
|
||||
- `pnpm template:doctor`
|
||||
- Playwright:
|
||||
- `template-preview-media.spec.ts`
|
||||
- `admin-editor.spec.ts`
|
||||
## 下一步优先级
|
||||
|
||||
本机数据库已应用全部 46 个 Prisma migration,`prisma migrate status` 为 up to date。
|
||||
1. 接入真实品牌图片、电话和微信配置,并替换当前图片占位区域。
|
||||
2. 在微信开发者工具/真机完成 `wx.login`、预约提交、订单查询和取消联调。
|
||||
3. 完善管理后台订单详情、筛选和状态处理视觉页面。
|
||||
4. 继续补充页面截图回归和真实素材下的移动端溢出检查。
|
||||
|
||||
## 安全审计
|
||||
## 未决问题
|
||||
|
||||
- `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 记录在安全审计文档。
|
||||
- 普通套餐采用固定菜单、每日菜单,还是固定套餐加每日可用状态。
|
||||
- 朋友最终品牌名称、图片、联系方式、营业时间和配送范围。
|
||||
- 微信小程序主体、AppID、服务类目和订阅消息模板是否可用。
|
||||
- 生产部署使用哪家 PostgreSQL、对象存储和 API 托管服务。
|
||||
- 当前 token 是开发阶段的签名 Bearer token;生产前应替换为带撤销能力的正式 session/Cookie 方案。
|
||||
|
||||
## 本机数据状态
|
||||
## 当前明确不做
|
||||
|
||||
- 本机数据库 schema 已 up to date。
|
||||
- 当前三个新版本已通过模板导入服务导入并发布:
|
||||
- `acheng-campus-food@1.0.3`
|
||||
- `atelier-solopreneur@1.3.2`
|
||||
- `linjing-editorial@1.0.7`
|
||||
- 既有品牌安装仍锁定各自原版本,需通过 Admin 的显式升级流程升级,不在本任务中静默变更。
|
||||
- 支付、退款、发票、财务对账。
|
||||
- 复杂库存、自动配送判断和每日菜单编排。
|
||||
- 多商户注册、套餐计费、会员和营销系统。
|
||||
- 自动发布微信小程序。
|
||||
|
||||
## 未决事项
|
||||
## 跨电脑恢复
|
||||
|
||||
- 生产发布仍需按 `docs/deployment.md` 配置真实环境变量并执行部署后健康检查。
|
||||
- `miniprogram-ci` 上游发布修复版本后,需要移除对应的 audit ignore、风险登记和本地 patch。
|
||||
- CI 已加入 audit 和三套模板矩阵构建;后续可继续拆分更细粒度的 smoke/visual matrix。
|
||||
```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 的机器再执行:
|
||||
|
||||
```bash
|
||||
docker compose up -d postgres
|
||||
pnpm install
|
||||
pnpm db:migrate
|
||||
pnpm db:seed
|
||||
```
|
||||
|
||||
## 更新规则
|
||||
|
||||
每完成一个可验证的开发任务,更新“当前阶段”“已完成”“最近提交”和“下一步优先级”。只记录已经发生或已经确认的事实;未确认内容放入“未决问题”。
|
||||
@@ -270,21 +270,19 @@
|
||||
|
||||
以下为各页面的视觉结构约定,业务逻辑不变。
|
||||
|
||||
| 页面 | 结构要点 |
|
||||
| -------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
||||
| 登录 | 居中 400px 卡片,标识 + 说明 + 表单 + 通栏主按钮;错误态展示在字段下方 |
|
||||
| 首次改密 | 同登录卡片形态,说明文案 + 三个密码字段 + 「保存新密码」 |
|
||||
| 品牌概览 | 品牌卡 + 三张指标卡(等宽一行)+ 两栏(发布准备度 / 品牌内容检查) |
|
||||
| 内容与发布 | 内容发布 / 小程序发布 / 小程序配置三个分区;内容发布含发布状态卡、草稿卡和历史版本表,不承载业务类型或页面方案选择 |
|
||||
| 页面方案 | 当前业务类型与页面方案 + 升级预览 + 版本选择 + 配置恢复 + 高级示例内容导入 |
|
||||
| 品牌管理 | 品牌列表与创建入口;创建品牌先选不可变的业务类型,再选兼容页面方案,创建时不导入示例内容 |
|
||||
| 小程序页面 | 左右两栏:左 380px 编辑面板,右预览画布;预览内选中区域虚线高亮 + 区域名气泡 |
|
||||
| 信任内容 | 列表行(类型图标或配图 + 标题 + 发布状态标签 + 类型/展示位置说明 + 两行摘要 + 行内操作),按模板类型顺序排列,不用表格 |
|
||||
| 业务提供项 | 表格(名称 / 价格 / 状态开关 / 排序 / 操作)+ 新增弹窗 |
|
||||
| 咨询记录 | 顶部三指标 + 左 380px 列表 + 右详情的主从布局 |
|
||||
| 咨询表单与字段 | 咨询表单表(名称 / 版本 / 字段数 / 状态 / 操作)+ 新增与编辑弹窗(含选项编辑);高级自定义字段表 + 新增弹窗 |
|
||||
| 能力插件 | 插件卡片列表(图标 + 名称 + 说明 + 开关),停用态降低对比度 |
|
||||
| 团队成员 | 表格(成员 / 角色 / 状态 / 最近登录 / 操作)+ 邀请弹窗 |
|
||||
| 页面 | 结构要点 |
|
||||
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 登录 | 居中 400px 卡片,标识 + 说明 + 表单 + 通栏主按钮;错误态展示在字段下方 |
|
||||
| 首次改密 | 同登录卡片形态,说明文案 + 三个密码字段 + 「保存新密码」 |
|
||||
| 品牌概览 | 品牌卡 + 三张指标卡(等宽一行)+ 两栏(发布准备度 / 品牌内容检查) |
|
||||
| 配置与发布 | 三 Tab(内容发布 / 小程序发布 / 小程序配置);内容发布含「选择表达方式」(行业模板 + 视觉模板 + 版本升级/回滚)+ 发布状态卡 + 草稿卡 + 历史版本表 |
|
||||
| 小程序页面 | 左右两栏:左 380px 编辑面板,右预览画布;预览内选中区域虚线高亮 + 区域名气泡 |
|
||||
| 信任内容 | 列表行(类型图标或配图 + 标题 + 发布状态标签 + 类型/展示位置说明 + 两行摘要 + 行内操作),按模板类型顺序排列,不用表格 |
|
||||
| 业务提供项 | 表格(名称 / 价格 / 状态开关 / 排序 / 操作)+ 新增弹窗 |
|
||||
| 咨询记录 | 顶部三指标 + 左 380px 列表 + 右详情的主从布局 |
|
||||
| 咨询表单与字段 | 咨询表单表(名称 / 版本 / 字段数 / 状态 / 操作)+ 新增与编辑弹窗(含选项编辑);高级自定义字段表 + 新增弹窗 |
|
||||
| 能力插件 | 插件卡片列表(图标 + 名称 + 说明 + 开关),停用态降低对比度 |
|
||||
| 团队成员 | 表格(成员 / 角色 / 状态 / 最近登录 / 操作)+ 邀请弹窗 |
|
||||
|
||||
两栏页面在小屏下折叠为单列,编辑/预览改为上下排列。
|
||||
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="default-src 'self'; img-src 'self' data: blob:; media-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; font-src 'self' data:; connect-src 'self' ws: wss:; script-src 'self'; object-src 'none'; base-uri 'none'; form-action 'self'"
|
||||
/>
|
||||
<title>个人品牌后台</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import { createElement, type ReactNode } from "react";
|
||||
import { Navigate, Route, Routes } from "react-router-dom";
|
||||
|
||||
export function AdminOverviewRedirect() {
|
||||
return createElement(Navigate, { to: "/admin/overview", replace: true });
|
||||
}
|
||||
|
||||
export function AdminRouter({ children }: { children: ReactNode }) {
|
||||
return createElement(
|
||||
Routes,
|
||||
null,
|
||||
createElement(Route, { path: "/admin/*", element: children }),
|
||||
createElement(Route, { path: "*", element: createElement(AdminOverviewRedirect) }),
|
||||
);
|
||||
}
|
||||
@@ -4,11 +4,9 @@ import {
|
||||
BarsOutlined,
|
||||
CloudUploadOutlined,
|
||||
FormOutlined,
|
||||
LayoutOutlined,
|
||||
MessageOutlined,
|
||||
MobileOutlined,
|
||||
SafetyCertificateOutlined,
|
||||
ShopOutlined,
|
||||
TeamOutlined,
|
||||
ThunderboltOutlined,
|
||||
} from "@ant-design/icons";
|
||||
@@ -18,15 +16,11 @@ 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,
|
||||
@@ -37,20 +31,10 @@ import { adminMessage as message } from "../components/AdminMessage.js";
|
||||
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 { Navigate, Route, Routes } from "react-router-dom";
|
||||
import { Suspense } from "react";
|
||||
|
||||
export function Dashboard({
|
||||
onLogout,
|
||||
role,
|
||||
platformTemplateRole,
|
||||
}: {
|
||||
onLogout: () => void;
|
||||
role: string;
|
||||
platformTemplateRole: "none" | "template_admin";
|
||||
}) {
|
||||
export function Dashboard({ onLogout, role }: { onLogout: () => void; role: string }) {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const brand = useQuery({
|
||||
@@ -63,7 +47,8 @@ export function Dashboard({
|
||||
});
|
||||
const switchBrand = async (brandId: string) => {
|
||||
try {
|
||||
await createApiClient().switchAdminBrand(brandId);
|
||||
const result = await createApiClient().switchAdminBrand(brandId);
|
||||
localStorage.setItem("adminToken", result.token);
|
||||
window.location.reload();
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : "品牌切换失败");
|
||||
@@ -76,7 +61,7 @@ export function Dashboard({
|
||||
label: "日常经营",
|
||||
children: [
|
||||
{ key: "overview", label: "当前品牌概览", icon: <AppstoreOutlined /> },
|
||||
{ key: "publication", label: "内容与发布", icon: <CloudUploadOutlined /> },
|
||||
{ key: "publication", label: "配置与发布", icon: <CloudUploadOutlined /> },
|
||||
{ key: "brand", label: "小程序页面", icon: <MobileOutlined /> },
|
||||
{ key: "trust", label: "信任内容", icon: <SafetyCertificateOutlined /> },
|
||||
{ key: "services", label: "业务提供项", icon: <BarsOutlined /> },
|
||||
@@ -89,15 +74,10 @@ export function Dashboard({
|
||||
: [
|
||||
{
|
||||
type: "group" as const,
|
||||
label: "品牌设置",
|
||||
label: "系统管理",
|
||||
children: [
|
||||
{ key: "brands", label: "品牌管理", icon: <ShopOutlined /> },
|
||||
{ key: "page-scheme", label: "页面方案", icon: <LayoutOutlined /> },
|
||||
{ key: "capabilities", label: "能力插件", icon: <ThunderboltOutlined /> },
|
||||
{ key: "members", label: "团队成员", icon: <TeamOutlined /> },
|
||||
...(platformTemplateRole === "template_admin"
|
||||
? [{ key: "templates", label: "模板管理", icon: <AppstoreOutlined /> }]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
]),
|
||||
@@ -130,7 +110,7 @@ export function Dashboard({
|
||||
className="admin-brand-switcher"
|
||||
value={brand.data?.id}
|
||||
loading={memberships.isLoading}
|
||||
onChange={(value: string | undefined) => {
|
||||
onChange={(value) => {
|
||||
if (value) void switchBrand(value);
|
||||
}}
|
||||
options={(memberships.data ?? []).map((item) => ({
|
||||
@@ -147,9 +127,12 @@ export function Dashboard({
|
||||
<div className="admin-content-inner">
|
||||
<Suspense fallback={<LoadingStack />}>
|
||||
<Routes>
|
||||
<Route index element={<AdminOverviewRedirect />} />
|
||||
<Route path="/" element={<Navigate to="overview" replace />} />
|
||||
<Route path="overview" element={<FeatureOverviewPage />} />
|
||||
<Route path="publication" element={<FeaturePublicationPage />} />
|
||||
<Route
|
||||
path="publication"
|
||||
element={<FeaturePublicationPage canManageTemplate={role !== "editor"} />}
|
||||
/>
|
||||
<Route path="brand" element={<FeatureBrandPage />} />
|
||||
<Route path="trust" element={<FeatureTrustContentPage />} />
|
||||
<Route path="services" element={<FeatureServicesPage />} />
|
||||
@@ -157,23 +140,11 @@ export function Dashboard({
|
||||
<Route path="workspace" element={<FeatureWorkspacePage />} />
|
||||
{role === "editor" ? null : (
|
||||
<>
|
||||
<Route
|
||||
path="brands"
|
||||
element={<FeatureBrandsPage canCreate={role === "owner"} />}
|
||||
/>
|
||||
<Route
|
||||
path="brands/new"
|
||||
element={createBrandRouteElement(role, <FeatureCreateBrandPage />)}
|
||||
/>
|
||||
<Route path="page-scheme" element={<FeaturePageSchemePage />} />
|
||||
<Route path="capabilities" element={<FeatureCapabilitiesPage />} />
|
||||
<Route path="members" element={<FeatureMembersPage />} />
|
||||
{platformTemplateRole === "template_admin" ? (
|
||||
<Route path="templates" element={<FeatureTemplateManagementPage />} />
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
<Route path="*" element={<AdminOverviewRedirect />} />
|
||||
<Route path="*" element={<Navigate to="overview" replace />} />
|
||||
</Routes>
|
||||
</Suspense>
|
||||
</div>
|
||||
|
||||
@@ -1,83 +1,38 @@
|
||||
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 { adminMessage as message } from "../components/AdminMessage.js";
|
||||
import { createApiClient } from "../lib/api.js";
|
||||
import { LoadingStack } from "../components/LoadingStack.js";
|
||||
|
||||
type SessionState = Omit<AdminSession, "authenticated">;
|
||||
|
||||
export function Root() {
|
||||
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;
|
||||
};
|
||||
}, []);
|
||||
|
||||
const [loggedIn, setLoggedIn] = useState(Boolean(localStorage.getItem("adminToken")));
|
||||
const [role, setRole] = useState(localStorage.getItem("adminRole") || "owner");
|
||||
const [mustChangePassword, setMustChangePassword] = useState(
|
||||
localStorage.getItem("adminMustChangePassword") === "true",
|
||||
);
|
||||
React.useEffect(() => {
|
||||
const expire = () => {
|
||||
message.warning("登录状态已失效,请重新登录");
|
||||
setSession(null);
|
||||
setLoggedIn(false);
|
||||
};
|
||||
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);
|
||||
}
|
||||
const logout = () => {
|
||||
localStorage.removeItem("adminToken");
|
||||
localStorage.removeItem("adminRole");
|
||||
localStorage.removeItem("adminMustChangePassword");
|
||||
setLoggedIn(false);
|
||||
};
|
||||
|
||||
if (loading) return <LoadingStack />;
|
||||
if (!session)
|
||||
if (!loggedIn)
|
||||
return (
|
||||
<Login
|
||||
onLogin={(current) => {
|
||||
setSession(current);
|
||||
onLogin={(session) => {
|
||||
setRole(session.role);
|
||||
setMustChangePassword(session.mustChangePassword);
|
||||
setLoggedIn(true);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
if (session.mustChangePassword)
|
||||
return (
|
||||
<ChangePassword
|
||||
onComplete={async () => {
|
||||
try {
|
||||
setSession(await createApiClient().getAdminSession());
|
||||
} catch {
|
||||
setSession(null);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<AdminRouter>
|
||||
<Dashboard
|
||||
onLogout={logout}
|
||||
role={session.role}
|
||||
platformTemplateRole={session.platformTemplateRole}
|
||||
/>
|
||||
</AdminRouter>
|
||||
);
|
||||
if (mustChangePassword) return <ChangePassword onComplete={() => setMustChangePassword(false)} />;
|
||||
return <Dashboard onLogout={logout} role={role} />;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { createElement, type ReactNode } from "react";
|
||||
import { Navigate } from "react-router-dom";
|
||||
|
||||
export const createBrandFallbackPath = "/admin/brands";
|
||||
|
||||
export function canCreateBrand(role: string) {
|
||||
return role === "owner";
|
||||
}
|
||||
|
||||
export function createBrandRouteElement(role: string, content: ReactNode) {
|
||||
return canCreateBrand(role)
|
||||
? content
|
||||
: createElement(Navigate, { to: createBrandFallbackPath, replace: true });
|
||||
}
|
||||
@@ -43,23 +43,3 @@ export const FeaturePublicationPage = React.lazy(() =>
|
||||
default: module.PublicationPage,
|
||||
})),
|
||||
);
|
||||
export const FeatureTemplateManagementPage = React.lazy(() =>
|
||||
import("../features/template-management/TemplateManagementPage.js").then((module) => ({
|
||||
default: module.TemplateManagementPage,
|
||||
})),
|
||||
);
|
||||
export const FeatureBrandsPage = React.lazy(() =>
|
||||
import("../features/brands/BrandsPage.js").then((module) => ({
|
||||
default: module.BrandsPage,
|
||||
})),
|
||||
);
|
||||
export const FeatureCreateBrandPage = React.lazy(() =>
|
||||
import("../features/brands/CreateBrandPage.js").then((module) => ({
|
||||
default: module.CreateBrandPage,
|
||||
})),
|
||||
);
|
||||
export const FeaturePageSchemePage = React.lazy(() =>
|
||||
import("../features/page-scheme/PageSchemePage.js").then((module) => ({
|
||||
default: module.PageSchemePage,
|
||||
})),
|
||||
);
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CloudUploadOutlined, DeleteOutlined, PictureOutlined } from "@ant-design/icons";
|
||||
import { Alert, Button, Image, Popconfirm, Spin, Upload, message } from "antd";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { apiBaseUrl, authenticatedFetch, createApiClient } from "../lib/api.js";
|
||||
import { apiBaseUrl, createApiClient } from "../lib/api.js";
|
||||
|
||||
interface ImageUrlFieldProps {
|
||||
id?: string;
|
||||
@@ -54,9 +54,14 @@ export function ImageUrlField({ id, value, onChange, placeholder, scope }: Image
|
||||
const uploadUrl = isLocalUpload
|
||||
? `${apiBaseUrl.replace(/\/$/, "")}${presign.uploadUrl}`
|
||||
: presign.uploadUrl;
|
||||
const response = await authenticatedFetch(uploadUrl, {
|
||||
const response = await fetch(uploadUrl, {
|
||||
method: "PUT",
|
||||
headers: { "content-type": file.type },
|
||||
headers: {
|
||||
"content-type": file.type,
|
||||
...(isLocalUpload
|
||||
? { authorization: `Bearer ${localStorage.getItem("adminToken") ?? ""}` }
|
||||
: {}),
|
||||
},
|
||||
body: file,
|
||||
});
|
||||
if (!response.ok) throw new Error(`upload failed: ${response.status}`);
|
||||
|
||||
@@ -5,15 +5,21 @@ import { adminMessage as message } from "../../components/AdminMessage.js";
|
||||
import { AdminButton } from "../../components/AdminButton.js";
|
||||
import { AdminCard } from "../../components/AdminCard.js";
|
||||
import { AdminForm, AdminInput } from "../../components/AdminForm.js";
|
||||
import type { AdminLoginSession } from "@personal-brand/api-client";
|
||||
|
||||
export function Login({ onLogin }: { onLogin: (session: AdminLoginSession) => void }) {
|
||||
export function Login({
|
||||
onLogin,
|
||||
}: {
|
||||
onLogin: (session: { role: string; mustChangePassword: boolean }) => void;
|
||||
}) {
|
||||
const [form] = AdminForm.useForm();
|
||||
const [loading, setLoading] = useState(false);
|
||||
async function submit(values: { username: string; password: string }) {
|
||||
setLoading(true);
|
||||
try {
|
||||
const result = await createApiClient().loginAdmin(values.username, values.password);
|
||||
localStorage.setItem("adminToken", result.token);
|
||||
localStorage.setItem("adminRole", result.role);
|
||||
localStorage.setItem("adminMustChangePassword", String(result.mustChangePassword));
|
||||
onLogin(result);
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : "登录失败");
|
||||
@@ -70,6 +76,7 @@ export function ChangePassword({ onComplete }: { onComplete: () => void }) {
|
||||
setLoading(true);
|
||||
try {
|
||||
await createApiClient().changeAdminPassword(values.currentPassword, values.newPassword);
|
||||
localStorage.setItem("adminMustChangePassword", "false");
|
||||
message.success("密码已更新");
|
||||
onComplete();
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Alert, Button, Col, Form, Input, Row, Segmented, message } from "antd";
|
||||
import { Alert, Button, Col, Form, Input, Row, Select, Segmented, message } from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useState } from "react";
|
||||
import { Link, useLocation } from "react-router-dom";
|
||||
@@ -36,6 +36,10 @@ export function BrandPage() {
|
||||
queryFn: () => client.getPublicTemplate(brand.data!.templateKey),
|
||||
enabled: Boolean(brand.data?.templateKey),
|
||||
});
|
||||
const templateCatalog = useQuery({
|
||||
queryKey: ["template-catalog"],
|
||||
queryFn: () => client.listPublicTemplates(),
|
||||
});
|
||||
const save = useMutation({
|
||||
mutationFn: (values: Partial<BrandProfile>) => client.updateAdminBrand(values),
|
||||
onSuccess: () => {
|
||||
@@ -56,12 +60,7 @@ export function BrandPage() {
|
||||
? `先让访客理解你是谁、服务谁,以及为什么值得信任。${template.data.description}`
|
||||
: "先让访客理解你是谁、服务谁,以及为什么值得信任。"
|
||||
}
|
||||
extra={
|
||||
<StatusTag
|
||||
tone="info"
|
||||
label={workspace.data?.templateContent?.displayName ?? "当前页面方案"}
|
||||
/>
|
||||
}
|
||||
extra={<StatusTag tone="info" label={template.data?.name ?? "当前模板"} />}
|
||||
/>
|
||||
<div className="brand-page__toolbar">
|
||||
<Segmented
|
||||
@@ -170,20 +169,25 @@ export function BrandPage() {
|
||||
<div className="admin-section-head">
|
||||
<div>
|
||||
<h2 id="brand-visual-title" className="admin-section-title">
|
||||
品牌视觉
|
||||
模板与品牌视觉
|
||||
</h2>
|
||||
<p className="admin-section-description">
|
||||
头像和封面会用于品牌身份展示;页面结构和资源位由页面方案统一管理。
|
||||
模板负责业务表达,品牌信息仍由你统一维护。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<Form.Item label="当前页面方案">
|
||||
<div>
|
||||
<strong>{workspace.data?.templateContent?.displayName ?? "尚未安装"}</strong>
|
||||
<p className="admin-section-description">
|
||||
页面方案的版本、升级和资源位由品牌负责人统一维护。
|
||||
</p>
|
||||
</div>
|
||||
<Form.Item
|
||||
name="templateKey"
|
||||
label="业务表达模板"
|
||||
help="模板只改变业务表达,不改变个人品牌主线。"
|
||||
>
|
||||
<Select
|
||||
disabled
|
||||
options={(templateCatalog.data?.industries ?? []).map((item) => ({
|
||||
value: item.key,
|
||||
label: item.name,
|
||||
}))}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Row gutter={16}>
|
||||
<Col xs={24} md={12}>
|
||||
@@ -219,7 +223,7 @@ export function BrandPage() {
|
||||
className="brand-page__template-note"
|
||||
type="info"
|
||||
showIcon
|
||||
message={`当前页面方案:${workspace.data?.templateContent?.displayName ?? template.data.name}`}
|
||||
message={`当前使用:${template.data.name}`}
|
||||
description={`适用场景:${template.data.serviceCategories.join("、") || "通用品牌展示"}`}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
@@ -168,6 +168,6 @@
|
||||
display: block;
|
||||
}
|
||||
|
||||
.component-template-preview__overlay-host > .component-template-preview__composite-select {
|
||||
.component-template-preview__overlay-host > * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
@@ -3,19 +3,15 @@ import type { RuntimeWorkspace } from "@personal-brand/api-client";
|
||||
import { Alert } from "antd";
|
||||
import { resolveTemplateRenderer } from "./component-renderers.jsx";
|
||||
import type { PreviewSelection, PreviewTarget } from "./preview-selection.js";
|
||||
import { TemplatePreviewAssetsContext } from "./preview-assets.js";
|
||||
import "./ComponentTemplatePreview.css";
|
||||
|
||||
type PreviewProps = {
|
||||
workspace: RuntimeWorkspace;
|
||||
page: string;
|
||||
offeringId?: string;
|
||||
assetFiles?: Record<string, { sha256: string; dataUrl: string }>;
|
||||
selection?: PreviewSelection;
|
||||
targets: PreviewTarget[];
|
||||
onTargetSelected: (selection?: PreviewSelection) => void;
|
||||
onPageSelected?: (page: string) => void;
|
||||
onOfferingSelected?: (offeringId: string) => void;
|
||||
};
|
||||
|
||||
type Outline = { top: number; left: number; width: number; height: number; label: string };
|
||||
@@ -25,12 +21,9 @@ export function ComponentTemplatePreview({
|
||||
workspace,
|
||||
page,
|
||||
offeringId,
|
||||
assetFiles,
|
||||
selection,
|
||||
targets,
|
||||
onTargetSelected,
|
||||
onPageSelected = () => undefined,
|
||||
onOfferingSelected = () => undefined,
|
||||
}: PreviewProps) {
|
||||
const Renderer = resolveTemplateRenderer(workspace);
|
||||
const root = useRef<HTMLDivElement>(null);
|
||||
@@ -38,26 +31,6 @@ export function ComponentTemplatePreview({
|
||||
const [mode, setMode] = useState<"edit" | "browse">("edit");
|
||||
const [hovered, setHovered] = useState<HTMLElement | null>(null);
|
||||
const overlay = useRef<HTMLDivElement>(null);
|
||||
// 将 renderer 里的 Taro CTA 导航转换为画布内页面/记录切换。
|
||||
useEffect(() => {
|
||||
const navigate = (event: Event) => {
|
||||
const detail = (event as CustomEvent<{ method?: string; options?: { url?: string } }>).detail;
|
||||
const url = detail?.options?.url;
|
||||
if (typeof url !== "string") return;
|
||||
const match = /^\/pages\/([a-z]+)\/index(?:\?(.*))?$/.exec(url);
|
||||
if (!match) return;
|
||||
const nextPage = match[1];
|
||||
if (!nextPage) return;
|
||||
const query = match[2];
|
||||
if (nextPage === "detail") {
|
||||
const id = new URLSearchParams(query ?? "").get("id");
|
||||
if (id) onOfferingSelected(id);
|
||||
}
|
||||
onPageSelected(nextPage);
|
||||
};
|
||||
window.addEventListener("template-preview-navigate", navigate);
|
||||
return () => window.removeEventListener("template-preview-navigate", navigate);
|
||||
}, [onOfferingSelected, onPageSelected]);
|
||||
const targetFor = useCallback(
|
||||
(element: Element | null): HTMLElement | null => {
|
||||
let candidate = element?.closest<HTMLElement>("[data-editor-target]");
|
||||
@@ -259,9 +232,7 @@ export function ComponentTemplatePreview({
|
||||
}}
|
||||
>
|
||||
<div ref={canvas} className="component-template-preview__canvas">
|
||||
<TemplatePreviewAssetsContext.Provider value={assetFiles}>
|
||||
<Renderer workspace={workspace} page={page} {...(offeringId ? { offeringId } : {})} />
|
||||
</TemplatePreviewAssetsContext.Provider>
|
||||
<Renderer workspace={workspace} page={page} {...(offeringId ? { offeringId } : {})} />
|
||||
<div
|
||||
ref={overlay}
|
||||
className={`component-template-preview__overlay-host ${
|
||||
|
||||
@@ -2,7 +2,11 @@ import { Alert, Button, Grid, Select, Segmented, Space, Typography } from "antd"
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import type { AdminTemplateContent, RuntimeWorkspace } from "@personal-brand/api-client";
|
||||
import type {
|
||||
AdminTemplateContent,
|
||||
RuntimeWorkspace,
|
||||
TemplateAdminSection,
|
||||
} from "@personal-brand/api-client";
|
||||
import type { BrandProfile } from "@personal-brand/api-client";
|
||||
import { StatusTag } from "../../components/StatusTag.js";
|
||||
import { RecordContentEditor } from "../../components/RecordContentEditor.js";
|
||||
@@ -14,7 +18,10 @@ import {
|
||||
type PreviewSelection,
|
||||
type PreviewTarget,
|
||||
} from "./preview-selection.js";
|
||||
import { filterSectionsForPreviewTarget } from "../../lib/presentation/presentation-bindings.js";
|
||||
import {
|
||||
filterSectionsForPreviewTarget,
|
||||
type PresentationValues,
|
||||
} from "../../lib/presentation/presentation-bindings.js";
|
||||
import "./PresentationEditor.css";
|
||||
import { useEditorDraft } from "./use-editor-draft.js";
|
||||
import {
|
||||
@@ -206,14 +213,7 @@ export function PresentationEditor({
|
||||
: pageLinks;
|
||||
const formState = useBrandPresentationForm({ brand, config, sections });
|
||||
const { form, initialValues } = formState;
|
||||
const save = useBrandSaveMutation({
|
||||
...formState,
|
||||
brand,
|
||||
config,
|
||||
sections,
|
||||
queryClient,
|
||||
onSaved: () => setBrandDirty(false),
|
||||
});
|
||||
const save = useBrandSaveMutation({ ...formState, brand, config, sections, queryClient });
|
||||
|
||||
useEffect(() => {
|
||||
const initialPage =
|
||||
@@ -311,12 +311,12 @@ export function PresentationEditor({
|
||||
</div>
|
||||
{templateContent ? <StatusTag tone="info" label={templateContent.displayName} /> : null}
|
||||
</div>
|
||||
{loading ? <Alert type="info" showIcon message="正在读取当前页面方案的编辑项目" /> : null}
|
||||
{loading ? <Alert type="info" showIcon message="正在读取当前模板的编辑项目" /> : null}
|
||||
{error ? (
|
||||
<Alert type="warning" showIcon message="页面方案编辑项目读取失败,请刷新后重试。" />
|
||||
<Alert type="warning" showIcon message="模板编辑项目读取失败,请刷新后重试。" />
|
||||
) : null}
|
||||
{!loading && !error && !templateContent ? (
|
||||
<Alert type="warning" showIcon message="当前页面方案暂未提供可编辑的页面内容。" />
|
||||
<Alert type="warning" showIcon message="当前模板暂未提供可编辑的页面内容。" />
|
||||
) : null}
|
||||
{templateContent ? (
|
||||
<>
|
||||
|
||||
@@ -7,7 +7,6 @@ import { TemplateAssetContext } from "./taro-web-components.jsx";
|
||||
const templateRenderers = import.meta.glob("../../../../../packages/template-*/taro/index.tsx", {
|
||||
eager: true,
|
||||
});
|
||||
const resolvedRenderers = new Map();
|
||||
|
||||
function pageContent({ workspace, page }) {
|
||||
if (page === "inquiry") return <Inquiry workspace={workspace} preview />;
|
||||
@@ -17,20 +16,21 @@ function pageContent({ workspace, page }) {
|
||||
}
|
||||
|
||||
export function resolveTemplateRenderer(workspace) {
|
||||
const key = workspace?.visualTemplate?.key;
|
||||
const config = workspace?.brand?.config;
|
||||
const key =
|
||||
config && typeof config === "object" && !Array.isArray(config)
|
||||
? config.visualTemplateKey
|
||||
: undefined;
|
||||
if (typeof key !== "string") return null;
|
||||
if (resolvedRenderers.has(key)) return resolvedRenderers.get(key);
|
||||
const suffix = `/template-${key}/taro/index.tsx`;
|
||||
const entry = Object.entries(templateRenderers).find(([path]) => path.endsWith(suffix));
|
||||
const TemplatePage = entry?.[1]?.TemplatePage;
|
||||
if (!TemplatePage) return null;
|
||||
function TemplatePreview(props) {
|
||||
return function TemplatePreview(props) {
|
||||
return (
|
||||
<TemplateAssetContext.Provider value={key}>
|
||||
<TemplatePage {...props}>{pageContent(props)}</TemplatePage>
|
||||
</TemplateAssetContext.Provider>
|
||||
);
|
||||
}
|
||||
resolvedRenderers.set(key, TemplatePreview);
|
||||
return TemplatePreview;
|
||||
};
|
||||
}
|
||||
@@ -46,8 +46,8 @@ export function useBrandPresentationSections(
|
||||
return [
|
||||
...[...new Set(declaredTemplateFields.map((field) => field.page ?? "home"))].map((page) => ({
|
||||
key: `template-data:${page}`,
|
||||
title: "页面方案专属内容",
|
||||
description: "这些字段由当前页面方案定义,保存后发布才会对外展示。",
|
||||
title: "模板专属内容",
|
||||
description: "这些字段由当前小程序模板定义,保存后发布才会对外展示。",
|
||||
page,
|
||||
target: "brand" as const,
|
||||
fields: declaredTemplateFields.filter((field) => (field.page ?? "home") === page),
|
||||
@@ -98,7 +98,6 @@ interface BrandSaveMutationOptions extends BrandPresentationFormState {
|
||||
config: Record<string, unknown> | null | undefined;
|
||||
sections: TemplateAdminSection[];
|
||||
queryClient: QueryClient;
|
||||
onSaved: () => void;
|
||||
}
|
||||
|
||||
export function useBrandSaveMutation({
|
||||
@@ -106,11 +105,12 @@ export function useBrandSaveMutation({
|
||||
config,
|
||||
sections,
|
||||
queryClient,
|
||||
onSaved,
|
||||
}: BrandSaveMutationOptions) {
|
||||
return useMutation({
|
||||
mutationFn: (values: PresentationValues) => {
|
||||
const nextConfig = applyPresentationValues(config, sections, values);
|
||||
const contentConfig = { ...nextConfig };
|
||||
delete contentConfig.visualTemplateKey;
|
||||
const standard = applyStandardBrandValues(
|
||||
brand as unknown as Record<string, unknown>,
|
||||
sections,
|
||||
@@ -122,10 +122,9 @@ export function useBrandSaveMutation({
|
||||
key !== "config" && value !== (brand as unknown as Record<string, unknown>)[key],
|
||||
),
|
||||
);
|
||||
return createApiClient().updateAdminBrand({ ...changed, config: nextConfig });
|
||||
return createApiClient().updateAdminBrand({ ...changed, config: contentConfig });
|
||||
},
|
||||
onSuccess: () => {
|
||||
onSaved();
|
||||
message.success("页面内容已保存为草稿,发布后小程序才会更新");
|
||||
window.dispatchEvent(new Event("template-preview-refresh"));
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-brand"] });
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import { createContext } from "react";
|
||||
|
||||
export const TemplatePreviewAssetsContext = createContext<
|
||||
Record<string, { sha256: string; dataUrl: string }> | undefined
|
||||
>(undefined);
|
||||
@@ -1,5 +1,4 @@
|
||||
import React from "react";
|
||||
import { TemplatePreviewAssetsContext } from "./preview-assets.js";
|
||||
|
||||
export const TemplateAssetContext = React.createContext("");
|
||||
const templateAssets = import.meta.glob("../../../../../packages/template-*/miniapp/assets/**/*", {
|
||||
@@ -100,17 +99,10 @@ export function Checkbox({ value, checked }) {
|
||||
export const Label = element("label");
|
||||
export const Image = React.forwardRef(({ mode, src, style, ...props }, ref) => {
|
||||
const key = React.useContext(TemplateAssetContext);
|
||||
const assets = React.useContext(TemplatePreviewAssetsContext);
|
||||
return React.createElement("img", {
|
||||
...props,
|
||||
ref,
|
||||
src:
|
||||
assets && typeof src === "string" && src.startsWith("/assets/")
|
||||
? // 导入包资源以 /assets 开头;本地多模板预览的 renderer 可能额外携带包 key 前缀。
|
||||
(assets[src]?.dataUrl ??
|
||||
assets[src.replace(`/assets/${key}/`, "/assets/")]?.dataUrl ??
|
||||
src)
|
||||
: resolveImageSource(src, key),
|
||||
src: resolveImageSource(src, key),
|
||||
style: { objectFit: mode === "aspectFit" ? "contain" : "cover", ...style },
|
||||
});
|
||||
});
|
||||
@@ -2,27 +2,13 @@ import React from "react";
|
||||
const noop = () => Promise.resolve();
|
||||
export const useRouter = () => ({ params: {} });
|
||||
export const useDidShow = (callback) => React.useEffect(callback, []);
|
||||
// Admin 画布监听该事件完成画布内路由;真实 Taro 端仍使用原始 API。
|
||||
const emitPreviewNavigation = (method, options) => {
|
||||
if (typeof window === "undefined") return;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent("template-preview-navigate", { detail: { method, options } }),
|
||||
);
|
||||
};
|
||||
|
||||
const Taro = {
|
||||
setStorageSync() {},
|
||||
getStorageSync() {
|
||||
return undefined;
|
||||
},
|
||||
removeStorageSync() {},
|
||||
switchTab(options) {
|
||||
emitPreviewNavigation("switchTab", options);
|
||||
return Promise.resolve();
|
||||
},
|
||||
navigateTo(options) {
|
||||
emitPreviewNavigation("navigateTo", options);
|
||||
return Promise.resolve();
|
||||
},
|
||||
switchTab: noop,
|
||||
navigateTo: noop,
|
||||
};
|
||||
export default Taro;
|
||||
@@ -8,7 +8,10 @@ import type {
|
||||
TrustContent,
|
||||
} from "@personal-brand/api-client";
|
||||
import { projectBrandAliases, projectTrustPresentation } from "@personal-brand/api-client";
|
||||
import { presentationFieldName } from "../../lib/presentation/presentation-bindings.js";
|
||||
import {
|
||||
presentationFieldName,
|
||||
type PresentationValues,
|
||||
} from "../../lib/presentation/presentation-bindings.js";
|
||||
import type { RecordDraft } from "./presentation-editor-record-preview.js";
|
||||
|
||||
interface DraftWorkspaceInput {
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
import { Alert, Button, Card, Col, Row, Space } from "antd";
|
||||
import { PlusOutlined } from "@ant-design/icons";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { adminMessage as message } from "../../components/AdminMessage.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { EmptyState } from "../../components/EmptyState.js";
|
||||
import { QueryState } from "../../components/QueryState.js";
|
||||
import { StatusTag } from "../../components/StatusTag.js";
|
||||
|
||||
const client = createApiClient();
|
||||
|
||||
export function BrandsPage({ canCreate }: { canCreate: boolean }) {
|
||||
const navigate = useNavigate();
|
||||
const brands = useQuery({
|
||||
queryKey: ["admin-brand-memberships"],
|
||||
queryFn: () => client.listAdminBrands(),
|
||||
});
|
||||
const current = useQuery({
|
||||
queryKey: ["admin-shell-brand"],
|
||||
queryFn: () => client.getAdminBrand(),
|
||||
});
|
||||
const switchBrand = async (brandId: string) => {
|
||||
try {
|
||||
await client.switchAdminBrand(brandId);
|
||||
window.location.assign("/admin/overview");
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : "品牌切换失败,请重试");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<QueryState
|
||||
loading={brands.isLoading || current.isLoading}
|
||||
error={brands.error || current.error}
|
||||
onRetry={() => {
|
||||
void brands.refetch();
|
||||
void current.refetch();
|
||||
}}
|
||||
>
|
||||
<AdminPageHeader
|
||||
title="品牌管理"
|
||||
description="每个品牌拥有独立的业务类型、页面方案、内容与发布记录。"
|
||||
extra={
|
||||
canCreate ? (
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<PlusOutlined />}
|
||||
onClick={() => navigate("/admin/brands/new")}
|
||||
>
|
||||
创建品牌
|
||||
</Button>
|
||||
) : null
|
||||
}
|
||||
/>
|
||||
<Alert
|
||||
className="admin-offset-bottom"
|
||||
type="info"
|
||||
showIcon
|
||||
message="切换品牌会进入对应品牌的工作区"
|
||||
description="品牌之间的业务内容、成员、发布记录和页面方案相互隔离。"
|
||||
/>
|
||||
{brands.data?.length ? (
|
||||
<Row gutter={[16, 16]} className="admin-equal-height">
|
||||
{brands.data.map((membership) => {
|
||||
const isCurrent = membership.brand.id === current.data?.id;
|
||||
return (
|
||||
<Col key={membership.brand.id} xs={24} lg={12}>
|
||||
<Card
|
||||
title={membership.brand.name}
|
||||
extra={
|
||||
<StatusTag
|
||||
tone={isCurrent ? "success" : "neutral"}
|
||||
label={
|
||||
isCurrent ? "当前品牌" : membership.role === "owner" ? "负责人" : "编辑"
|
||||
}
|
||||
/>
|
||||
}
|
||||
actions={[
|
||||
<Button
|
||||
key="switch"
|
||||
type={isCurrent ? "default" : "primary"}
|
||||
disabled={isCurrent}
|
||||
onClick={() => void switchBrand(membership.brand.id)}
|
||||
>
|
||||
{isCurrent ? "正在使用" : "进入此品牌"}
|
||||
</Button>,
|
||||
]}
|
||||
>
|
||||
<Space direction="vertical" size={8}>
|
||||
<span className="admin-section-description">
|
||||
小程序地址标识:{membership.brand.slug}
|
||||
</span>
|
||||
{membership.role === "owner" ? (
|
||||
<span className="admin-section-description">
|
||||
你可以在该品牌中管理页面方案、成员和发布。
|
||||
</span>
|
||||
) : (
|
||||
<span className="admin-section-description">
|
||||
你在该品牌中的角色是内容编辑,不能管理页面方案或成员。
|
||||
</span>
|
||||
)}
|
||||
</Space>
|
||||
</Card>
|
||||
</Col>
|
||||
);
|
||||
})}
|
||||
</Row>
|
||||
) : (
|
||||
<Card>
|
||||
<EmptyState
|
||||
title="还没有可管理的品牌"
|
||||
description={
|
||||
canCreate ? "创建第一个品牌后即可开始配置内容。" : "请联系品牌负责人邀请你加入。"
|
||||
}
|
||||
action={
|
||||
canCreate ? (
|
||||
<Button type="primary" onClick={() => navigate("/admin/brands/new")}>
|
||||
创建品牌
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
</Card>
|
||||
)}
|
||||
</QueryState>
|
||||
);
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
import { Alert, Button, Col, Form, Input, Radio, Row, Space } from "antd";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import type {
|
||||
BrandCreationOptionBusiness,
|
||||
BrandCreationOptionPageScheme,
|
||||
CreateBrandInput,
|
||||
} from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { AdminSection } from "../../components/AdminSection.js";
|
||||
import { EmptyState } from "../../components/EmptyState.js";
|
||||
import { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
import { StatusTag } from "../../components/StatusTag.js";
|
||||
|
||||
const client = createApiClient();
|
||||
|
||||
function compatibleSchemes(
|
||||
schemes: BrandCreationOptionPageScheme[],
|
||||
businessType?: CreateBrandInput["businessType"],
|
||||
) {
|
||||
return businessType
|
||||
? schemes.filter((scheme) => scheme.supportedBusinessTypes.includes(businessType))
|
||||
: [];
|
||||
}
|
||||
|
||||
export function CreateBrandPage() {
|
||||
const navigate = useNavigate();
|
||||
const [form] = Form.useForm<CreateBrandInput>();
|
||||
const businessType = Form.useWatch("businessType", form);
|
||||
const options = useQuery({
|
||||
queryKey: ["admin-brand-creation-options"],
|
||||
queryFn: () => client.getAdminBrandCreationOptions(),
|
||||
});
|
||||
const create = useMutation({
|
||||
mutationFn: (values: CreateBrandInput) => client.createAdminBrand(values),
|
||||
onSuccess: () => {
|
||||
// 创建接口会切换品牌会话;完整导航确保所有查询重新绑定到新品牌。
|
||||
window.location.assign("/admin/overview");
|
||||
},
|
||||
});
|
||||
const schemes = compatibleSchemes(options.data?.pageSchemes ?? [], businessType);
|
||||
|
||||
return (
|
||||
<QueryState
|
||||
loading={options.isLoading}
|
||||
error={options.error}
|
||||
onRetry={() => void options.refetch()}
|
||||
>
|
||||
<AdminPageHeader
|
||||
title="创建品牌"
|
||||
description="先确定业务类型,再选择与该业务兼容的页面方案。业务类型创建后不可更改。"
|
||||
/>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
onFinish={(values) => create.mutate(values)}
|
||||
onValuesChange={(changed: Partial<CreateBrandInput>) => {
|
||||
if (!changed.businessType) return;
|
||||
const nextSchemes = compatibleSchemes(
|
||||
options.data?.pageSchemes ?? [],
|
||||
changed.businessType,
|
||||
);
|
||||
const selected = form.getFieldValue("templatePackageVersionId") as unknown;
|
||||
if (!nextSchemes.some((scheme) => scheme.templatePackageVersionId === selected)) {
|
||||
form.setFieldValue("templatePackageVersionId", undefined);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="admin-stack">
|
||||
<AdminSection title="品牌身份" description="这些信息会展示给访客,之后仍可继续完善。">
|
||||
<Row gutter={16}>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item
|
||||
name="name"
|
||||
label="品牌名称"
|
||||
rules={[{ required: true, message: "请输入品牌名称" }]}
|
||||
>
|
||||
<Input size="large" maxLength={80} placeholder="例如:林境建筑" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item
|
||||
name="slug"
|
||||
label="小程序地址标识"
|
||||
help="用于生成和识别公开品牌地址,只能使用小写字母、数字和连字符。"
|
||||
rules={[
|
||||
{ required: true, message: "请输入小程序地址标识" },
|
||||
{
|
||||
pattern: /^[a-z0-9]+(?:-[a-z0-9]+)*$/,
|
||||
message: "只能使用小写字母、数字和连字符",
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input size="large" maxLength={80} placeholder="例如:linjing-architecture" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
</AdminSection>
|
||||
|
||||
<AdminSection
|
||||
title="业务类型"
|
||||
description="业务类型决定品牌需要填写哪些内容。不同业务类型的字段和能力不同,创建后不能修改。"
|
||||
>
|
||||
<Form.Item name="businessType" rules={[{ required: true, message: "请选择业务类型" }]}>
|
||||
<Radio.Group className="admin-stack">
|
||||
<Row gutter={[12, 12]}>
|
||||
{(options.data?.businesses ?? []).map((business: BrandCreationOptionBusiness) => (
|
||||
<Col key={business.key} xs={24} lg={8}>
|
||||
<Radio.Button value={business.key} className="admin-choice-card">
|
||||
<strong>{business.name}</strong>
|
||||
<span>{business.description}</span>
|
||||
</Radio.Button>
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
{businessType ? (
|
||||
schemes.length ? null : (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="当前业务类型还没有可用的页面方案"
|
||||
description="请先联系平台管理员发布兼容的页面方案。"
|
||||
/>
|
||||
)
|
||||
) : (
|
||||
<Alert type="info" showIcon message="选择业务类型后,将只显示兼容的页面方案" />
|
||||
)}
|
||||
</AdminSection>
|
||||
|
||||
<AdminSection
|
||||
title="页面方案"
|
||||
description="页面方案决定页面结构、视觉和资源位。版本可在创建后继续升级或切换。"
|
||||
>
|
||||
{schemes.length ? (
|
||||
<Form.Item
|
||||
name="templatePackageVersionId"
|
||||
rules={[{ required: true, message: "请选择页面方案" }]}
|
||||
>
|
||||
<Radio.Group className="admin-stack">
|
||||
<Space direction="vertical" size={12} className="admin-full-width">
|
||||
{schemes.map((scheme) => (
|
||||
<Radio.Button
|
||||
key={scheme.templatePackageVersionId}
|
||||
value={scheme.templatePackageVersionId}
|
||||
className="admin-choice-card admin-choice-card--wide"
|
||||
>
|
||||
<span className="admin-row-line">
|
||||
<strong>{scheme.name}</strong>
|
||||
<StatusTag
|
||||
tone={scheme.isLatestForPackage ? "success" : "neutral"}
|
||||
label={
|
||||
scheme.isLatestForPackage
|
||||
? `最新版 ${scheme.version}`
|
||||
: `版本 ${scheme.version}`
|
||||
}
|
||||
/>
|
||||
</span>
|
||||
<span>{scheme.description}</span>
|
||||
</Radio.Button>
|
||||
))}
|
||||
</Space>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
) : (
|
||||
<EmptyState
|
||||
title={businessType ? "没有兼容的页面方案" : "先选择业务类型"}
|
||||
description={
|
||||
businessType
|
||||
? "平台尚未发布适配该业务类型的页面方案。"
|
||||
: "选择业务类型后,这里会列出可用的页面结构和视觉方案。"
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</AdminSection>
|
||||
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="创建品牌不会自动导入示例内容"
|
||||
description="新品牌会从空白内容开始,避免把示例品牌、案例或联系方式误当成真实信息发布。"
|
||||
/>
|
||||
<MutationError error={create.error} />
|
||||
<Space>
|
||||
<Button onClick={() => navigate("/admin/brands")}>取消</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
htmlType="submit"
|
||||
size="large"
|
||||
loading={create.isPending}
|
||||
disabled={!businessType || schemes.length === 0}
|
||||
>
|
||||
创建并进入品牌
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</Form>
|
||||
</QueryState>
|
||||
);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ export function CapabilitiesPage() {
|
||||
<QueryState loading={query.isLoading} error={query.error} onRetry={() => void query.refetch()}>
|
||||
<AdminPageHeader
|
||||
title="能力插件"
|
||||
description="以经营者视角调整当前页面方案提供的业务能力;保存后进入草稿,发布后生效。"
|
||||
description="以经营者视角调整模板能力的开关与展示设置;保存后进入草稿,发布后生效。"
|
||||
/>
|
||||
{query.data?.length ? (
|
||||
<Row gutter={[16, 16]} className="admin-equal-height">
|
||||
@@ -29,9 +29,9 @@ export function CapabilitiesPage() {
|
||||
<Card>
|
||||
<EmptyState
|
||||
icon={<AppstoreOutlined />}
|
||||
title="当前页面方案没有可配置能力"
|
||||
description="能力由品牌当前使用的业务类型和页面方案决定。"
|
||||
action={<Button onClick={() => navigate("/admin/page-scheme")}>查看页面方案</Button>}
|
||||
title="当前模板没有可配置能力"
|
||||
description="能力的开关由品牌当前使用的行业模板决定;更换行业模板不在本版本范围内。"
|
||||
action={<Button onClick={() => navigate("/admin/publication")}>查看模板与发布</Button>}
|
||||
/>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
@@ -8,12 +8,12 @@ import { CapabilityStatusControl, CapabilityStatusTag } from "./CapabilityStatus
|
||||
|
||||
const sourceLabels = {
|
||||
brand: "品牌覆盖",
|
||||
template: "方案默认",
|
||||
template: "模板默认",
|
||||
} as const;
|
||||
|
||||
const disablePolicyLabels = {
|
||||
allowed: "该能力允许停用,保存后进入草稿。",
|
||||
disabled: "该能力为页面方案必需项,保存后进入草稿。",
|
||||
disabled: "该能力为模板必需项,保存后进入草稿。",
|
||||
} as const;
|
||||
|
||||
const updatedTimeFormatter = new Intl.DateTimeFormat("zh-CN", {
|
||||
@@ -143,7 +143,7 @@ export function CapabilityCard({ capability }: { capability: AdminCapability })
|
||||
) : null}
|
||||
<Typography.Text type="secondary">
|
||||
{capability.source === "template"
|
||||
? "当前使用页面方案默认设置;修改后保存会创建品牌覆盖。"
|
||||
? "当前使用模板默认设置;修改后保存会创建品牌覆盖。"
|
||||
: "当前已创建品牌覆盖;修改后保存会更新草稿。"}
|
||||
{capability.updatedAt
|
||||
? ` 最近更新:${updatedTimeFormatter.format(new Date(capability.updatedAt))}`
|
||||
|
||||
@@ -213,7 +213,7 @@ export function InquiriesPage() {
|
||||
</AdminSection>
|
||||
<AdminSection
|
||||
title={`动态咨询提交${submissions.data ? `(${submissions.data.length})` : ""}`}
|
||||
description="按咨询表单提交的记录,字段随表单配置变化。"
|
||||
description="按模板表单提交的咨询记录,字段随表单配置变化。"
|
||||
extra={
|
||||
<Button onClick={() => void submissions.refetch()} loading={submissions.isFetching}>
|
||||
刷新提交记录
|
||||
@@ -248,7 +248,7 @@ export function InquiriesPage() {
|
||||
<EmptyState
|
||||
compact
|
||||
title="暂无动态咨询提交"
|
||||
description="按咨询表单提交的内容会汇总在这里。"
|
||||
description="按模板表单提交的咨询会汇总在这里。"
|
||||
/>
|
||||
),
|
||||
}}
|
||||
|
||||
@@ -90,7 +90,7 @@ export function OverviewPage() {
|
||||
<p className="admin-brand-tagline">{brand?.tagline || "还没有设置一句话定位"}</p>
|
||||
<StatusTag
|
||||
tone="info"
|
||||
label={`当前页面方案:${workspace?.templateContent?.displayName ?? "尚未安装页面方案"}`}
|
||||
label={`当前模板:${workspace?.templateContent?.displayName ?? "尚未安装模板"}`}
|
||||
/>
|
||||
</Card>
|
||||
<Row gutter={[16, 16]}>
|
||||
|
||||
@@ -1,375 +0,0 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Alert, Button, Card, Collapse, Descriptions, Empty, List, Modal, Space, Tag } from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { adminMessage as message } from "../../components/AdminMessage.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { AdminSection } from "../../components/AdminSection.js";
|
||||
import { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
import { StatusTag } from "../../components/StatusTag.js";
|
||||
|
||||
const client = createApiClient();
|
||||
|
||||
export function PageSchemePage() {
|
||||
const queryClient = useQueryClient();
|
||||
const [selectedVersionId, setSelectedVersionId] = useState<string>();
|
||||
const [samplePreview, setSamplePreview] = useState<Awaited<
|
||||
ReturnType<typeof client.previewAdminSampleContent>
|
||||
> | null>(null);
|
||||
const workspace = useQuery({
|
||||
queryKey: ["page-scheme-workspace"],
|
||||
queryFn: () => client.getAdminWorkspace(),
|
||||
});
|
||||
const options = useQuery({
|
||||
queryKey: ["admin-page-scheme-options"],
|
||||
queryFn: () => client.getAdminPageSchemeOptions(),
|
||||
});
|
||||
const upgradePreview = useQuery({
|
||||
queryKey: ["page-scheme-upgrade-preview"],
|
||||
queryFn: () => client.getAdminTemplateUpgradePreview(),
|
||||
});
|
||||
const installation = workspace.data?.installations[0];
|
||||
const currentVersionId = installation?.templatePackageVersionId;
|
||||
const currentScheme = options.data?.pageSchemes.find(
|
||||
(scheme) => scheme.templatePackageVersionId === currentVersionId,
|
||||
);
|
||||
const business = options.data?.business;
|
||||
const compatibleSchemes = options.data?.pageSchemes ?? [];
|
||||
|
||||
useEffect(() => {
|
||||
if (currentVersionId) setSelectedVersionId(currentVersionId);
|
||||
}, [currentVersionId]);
|
||||
|
||||
const refresh = () => {
|
||||
for (const queryKey of [
|
||||
"page-scheme-workspace",
|
||||
"page-scheme-upgrade-preview",
|
||||
"admin-workspace",
|
||||
"admin-preview-workspace",
|
||||
"admin-overview-workspace",
|
||||
"publication-workspace",
|
||||
"publication-readiness",
|
||||
]) {
|
||||
void queryClient.invalidateQueries({ queryKey: [queryKey] });
|
||||
}
|
||||
};
|
||||
|
||||
const selectVersion = useMutation({
|
||||
mutationFn: (templatePackageVersionId: string) =>
|
||||
client.selectAdminTemplateVersion({
|
||||
templatePackageVersionId,
|
||||
expectedCurrentPackageVersionId: currentVersionId ?? null,
|
||||
confirm: true,
|
||||
}),
|
||||
onSuccess: () => {
|
||||
message.success("页面方案版本已切换");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const upgrade = useMutation({
|
||||
mutationFn: async () => {
|
||||
const preview = upgradePreview.data;
|
||||
if (
|
||||
!preview?.canUpgrade ||
|
||||
!preview.targetPackageVersionId ||
|
||||
!preview.targetContentChecksum
|
||||
) {
|
||||
throw new Error("当前没有可升级的页面方案版本,请刷新后重试");
|
||||
}
|
||||
return client.upgradeAdminTemplate({
|
||||
templatePackageVersionId: preview.targetPackageVersionId,
|
||||
expectedContentChecksum: preview.targetContentChecksum,
|
||||
expectedCurrentVersion: preview.currentVersion,
|
||||
expectedCurrentPackageVersionId: preview.currentPackageVersionId,
|
||||
confirm: true,
|
||||
preservedBindings: preview.conflicts.map(({ key, binding }) => ({
|
||||
key,
|
||||
binding,
|
||||
action: "preserve",
|
||||
})),
|
||||
});
|
||||
},
|
||||
onSuccess: () => {
|
||||
message.success("页面方案已升级,现有内容已全部保留");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const rollback = useMutation({
|
||||
mutationFn: () => {
|
||||
const preview = upgradePreview.data;
|
||||
if (!preview?.canRollback) throw new Error("当前没有可恢复的上一版配置基线");
|
||||
return client.rollbackAdminTemplate({
|
||||
expectedCurrentVersion: preview.currentVersion,
|
||||
confirm: true,
|
||||
});
|
||||
},
|
||||
onSuccess: () => {
|
||||
message.success("已恢复上一版页面方案配置基线");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const previewSample = useMutation({
|
||||
mutationFn: () =>
|
||||
client.previewAdminSampleContent({
|
||||
...(currentVersionId ? { templatePackageVersionId: currentVersionId } : {}),
|
||||
strategy: "missing_only",
|
||||
}),
|
||||
onSuccess: (data) => setSamplePreview(data),
|
||||
});
|
||||
const importSample = useMutation({
|
||||
mutationFn: () =>
|
||||
client.importAdminSampleContent({
|
||||
...(currentVersionId ? { templatePackageVersionId: currentVersionId } : {}),
|
||||
strategy: "missing_only",
|
||||
confirm: true,
|
||||
}),
|
||||
onSuccess: () => {
|
||||
message.success("示例内容已按缺失项导入,现有内容未被覆盖");
|
||||
setSamplePreview(null);
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
|
||||
const confirmSelect = (templatePackageVersionId: string) => {
|
||||
const target = compatibleSchemes.find(
|
||||
(scheme) => scheme.templatePackageVersionId === templatePackageVersionId,
|
||||
);
|
||||
Modal.confirm({
|
||||
title: "切换页面方案版本",
|
||||
content: target
|
||||
? `将当前品牌切换到「${target.name}」版本 ${target.version}。现有品牌内容会保留。`
|
||||
: "将切换当前品牌使用的页面方案版本。现有品牌内容会保留。",
|
||||
okText: "确认切换",
|
||||
cancelText: "取消",
|
||||
onOk: () => selectVersion.mutateAsync(templatePackageVersionId),
|
||||
});
|
||||
};
|
||||
const confirmUpgrade = () => {
|
||||
const preview = upgradePreview.data;
|
||||
Modal.confirm({
|
||||
title: "升级页面方案",
|
||||
content:
|
||||
preview && preview.conflicts.length
|
||||
? `将升级到版本 ${preview.latestVersion},并全部保留 ${preview.conflicts.length} 项现有内容。`
|
||||
: `将升级到版本 ${preview?.latestVersion ?? "最新版"},现有品牌内容会保留。`,
|
||||
okText: "确认升级",
|
||||
cancelText: "取消",
|
||||
onOk: () => upgrade.mutateAsync(),
|
||||
});
|
||||
};
|
||||
const confirmRollback = () => {
|
||||
Modal.confirm({
|
||||
title: "恢复上一版配置基线",
|
||||
content: "此操作只恢复上一版页面方案配置,不会删除品牌内容、业务提供项或咨询记录。",
|
||||
okText: "确认恢复",
|
||||
cancelText: "取消",
|
||||
onOk: () => rollback.mutateAsync(),
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<QueryState
|
||||
loading={workspace.isLoading || options.isLoading || upgradePreview.isLoading}
|
||||
error={workspace.error || options.error || upgradePreview.error}
|
||||
onRetry={() => {
|
||||
void workspace.refetch();
|
||||
void options.refetch();
|
||||
void upgradePreview.refetch();
|
||||
}}
|
||||
>
|
||||
<AdminPageHeader
|
||||
title="页面方案"
|
||||
description="页面方案决定小程序有哪些页面、页面结构、视觉和资源位。它可以独立于内容发布进行升级或版本切换。"
|
||||
/>
|
||||
<div className="admin-stack">
|
||||
<AdminSection
|
||||
title="当前方案"
|
||||
description="业务类型创建后固定;页面方案和版本可以继续调整。"
|
||||
>
|
||||
<Descriptions column={{ xs: 1, md: 2 }} bordered>
|
||||
<Descriptions.Item label="业务类型">{business?.name ?? "未识别"}</Descriptions.Item>
|
||||
<Descriptions.Item label="页面方案">
|
||||
{currentScheme?.name ?? workspace.data?.templateContent?.displayName ?? "尚未安装"}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="当前状态">
|
||||
<StatusTag
|
||||
tone={installation ? "info" : "neutral"}
|
||||
label={
|
||||
installation ? `正在使用版本 ${installation.templateVersion}` : "尚未安装页面方案"
|
||||
}
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
{business?.description ? (
|
||||
<p className="admin-section-description admin-offset-top">{business.description}</p>
|
||||
) : null}
|
||||
</AdminSection>
|
||||
|
||||
<AdminSection
|
||||
title="升级预览"
|
||||
description="升级前先查看页面、模块、资源和绑定的变化;冲突项默认保留现有内容。"
|
||||
>
|
||||
<Card>
|
||||
{upgradePreview.data?.canUpgrade ? (
|
||||
<Space direction="vertical" size={12} className="admin-full-width">
|
||||
<div className="admin-row-line">
|
||||
<strong>可升级到版本 {upgradePreview.data.latestVersion}</strong>
|
||||
<Tag color="blue">建议先预览</Tag>
|
||||
</div>
|
||||
<Descriptions column={{ xs: 1, md: 2 }} size="small">
|
||||
<Descriptions.Item label="新增页面">
|
||||
{upgradePreview.data.changes.pages.added.length}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="变更页面">
|
||||
{upgradePreview.data.changes.pages.changed.length}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="新增字段绑定">
|
||||
{upgradePreview.data.changes.templateBindings.added.length}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="需要保留的冲突">
|
||||
{upgradePreview.data.conflicts.length}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
{upgradePreview.data.conflicts.length ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message={`发现 ${upgradePreview.data.conflicts.length} 项自定义内容与新版布局存在差异`}
|
||||
description="升级时会全部保留现有内容,不会逐项覆盖。请确认后再执行升级。"
|
||||
/>
|
||||
) : (
|
||||
<Alert type="success" showIcon message="未发现内容绑定冲突" />
|
||||
)}
|
||||
<Button type="primary" onClick={confirmUpgrade} loading={upgrade.isPending}>
|
||||
升级到 {upgradePreview.data.latestVersion}
|
||||
</Button>
|
||||
</Space>
|
||||
) : (
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description="当前已是可用的最新页面方案版本,暂无可升级版本。"
|
||||
/>
|
||||
)}
|
||||
<MutationError error={upgrade.error} />
|
||||
</Card>
|
||||
</AdminSection>
|
||||
|
||||
<AdminSection
|
||||
title="选择版本"
|
||||
description="可切换到同一业务类型下的其他已发布版本。切换会保留品牌内容。"
|
||||
>
|
||||
<List
|
||||
dataSource={compatibleSchemes}
|
||||
locale={{ emptyText: "没有可切换的页面方案版本" }}
|
||||
renderItem={(scheme) => {
|
||||
const isCurrent = scheme.templatePackageVersionId === currentVersionId;
|
||||
return (
|
||||
<List.Item
|
||||
actions={[
|
||||
<Button
|
||||
key="select"
|
||||
type={isCurrent ? "default" : "primary"}
|
||||
disabled={isCurrent}
|
||||
loading={
|
||||
selectVersion.isPending &&
|
||||
selectedVersionId === scheme.templatePackageVersionId
|
||||
}
|
||||
onClick={() => {
|
||||
setSelectedVersionId(scheme.templatePackageVersionId);
|
||||
confirmSelect(scheme.templatePackageVersionId);
|
||||
}}
|
||||
>
|
||||
{isCurrent ? "当前版本" : "切换到此版本"}
|
||||
</Button>,
|
||||
]}
|
||||
>
|
||||
<List.Item.Meta
|
||||
title={
|
||||
<Space>
|
||||
<span>{scheme.name}</span>
|
||||
<Tag color={scheme.isLatestForPackage ? "green" : "default"}>
|
||||
{scheme.isLatestForPackage ? "最新版" : `版本 ${scheme.version}`}
|
||||
</Tag>
|
||||
</Space>
|
||||
}
|
||||
description={`${scheme.description} · 版本 ${scheme.version}`}
|
||||
/>
|
||||
</List.Item>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<MutationError error={selectVersion.error} />
|
||||
</AdminSection>
|
||||
|
||||
<AdminSection
|
||||
title="配置恢复"
|
||||
description="恢复上一版页面方案配置基线,仅用于升级后出现配置问题时回退。"
|
||||
>
|
||||
<Button danger onClick={confirmRollback} disabled={!upgradePreview.data?.canRollback}>
|
||||
恢复上一版配置
|
||||
</Button>
|
||||
<MutationError error={rollback.error} />
|
||||
</AdminSection>
|
||||
|
||||
<Collapse
|
||||
items={[
|
||||
{
|
||||
key: "sample-content",
|
||||
label: "高级:导入示例内容",
|
||||
children: (
|
||||
<Space direction="vertical" size={12} className="admin-full-width">
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="此操作会写入当前品牌内容"
|
||||
description="仅导入当前缺失的内容,不会覆盖已有品牌资料。创建品牌时不会自动执行。"
|
||||
/>
|
||||
<Space>
|
||||
<Button
|
||||
onClick={() => previewSample.mutate()}
|
||||
loading={previewSample.isPending}
|
||||
>
|
||||
预览将导入的内容
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
danger
|
||||
disabled={!samplePreview}
|
||||
loading={importSample.isPending}
|
||||
onClick={() => importSample.mutate()}
|
||||
>
|
||||
确认导入缺失内容
|
||||
</Button>
|
||||
</Space>
|
||||
<MutationError error={previewSample.error || importSample.error} />
|
||||
{samplePreview ? (
|
||||
<Descriptions bordered size="small" column={{ xs: 1, md: 2 }}>
|
||||
<Descriptions.Item label="品牌资料">
|
||||
{samplePreview.counts.brandConfig}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="业务提供项">
|
||||
{samplePreview.counts.offerings}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="信任内容">
|
||||
{samplePreview.counts.trustContent}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="字段">
|
||||
{samplePreview.counts.fields}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="咨询表单">
|
||||
{samplePreview.counts.inquiryForms}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="是否已导入">
|
||||
{samplePreview.alreadyImported ? "是" : "否"}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
) : null}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</QueryState>
|
||||
);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import type { StatusTone } from "../../components/StatusTag.js";
|
||||
|
||||
type ReleaseStatus = MiniAppReleaseTask["status"];
|
||||
|
||||
const STALE_BUILDING_MS = 30 * 60 * 1000;
|
||||
const STALE_BUILDING_MS = 15 * 60 * 1000;
|
||||
|
||||
function isStaleBuilding(task: MiniAppReleaseTask): boolean {
|
||||
if (task.buildStatus !== "building") return false;
|
||||
@@ -29,27 +29,6 @@ const statusView: Record<ReleaseStatus, { label: string; tone: StatusTone; hint:
|
||||
failed: { label: "失败", tone: "error", hint: "上次构建或上传失败,可直接重试。" },
|
||||
};
|
||||
|
||||
const uploadStatusView: Record<
|
||||
NonNullable<MiniAppReleaseTask["uploadStatus"]>,
|
||||
{ label: string; tone: StatusTone }
|
||||
> = {
|
||||
idle: { label: "未上传", tone: "neutral" },
|
||||
uploading: { label: "上传中", tone: "warning" },
|
||||
uploaded: { label: "上传完成", tone: "success" },
|
||||
failed: { label: "上传失败", tone: "error" },
|
||||
timed_out: { label: "上传超时", tone: "error" },
|
||||
};
|
||||
|
||||
const reviewStatusView: Record<
|
||||
NonNullable<MiniAppReleaseTask["reviewStatus"]>,
|
||||
{ label: string; tone: StatusTone }
|
||||
> = {
|
||||
not_submitted: { label: "未提交审核", tone: "neutral" },
|
||||
under_review: { label: "审核中", tone: "warning" },
|
||||
approved: { label: "审核通过", tone: "success" },
|
||||
rejected: { label: "审核驳回", tone: "error" },
|
||||
};
|
||||
|
||||
function formatTime(value: string): string {
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return value;
|
||||
@@ -76,8 +55,6 @@ export function MiniAppReleaseCard({
|
||||
const logRef = useRef<HTMLPreElement>(null);
|
||||
const logs = task.buildLogs ?? [];
|
||||
const status = statusView[task.status];
|
||||
const uploadStatus = task.uploadStatus ? uploadStatusView[task.uploadStatus] : null;
|
||||
const reviewStatus = task.reviewStatus ? reviewStatusView[task.reviewStatus] : null;
|
||||
const building = task.buildStatus === "building";
|
||||
const staleBuilding = isStaleBuilding(task);
|
||||
|
||||
@@ -132,19 +109,12 @@ export function MiniAppReleaseCard({
|
||||
{building && (
|
||||
<StatusTag tone="warning" label={staleBuilding ? "构建已中断" : "构建中"} />
|
||||
)}
|
||||
{!building && task.buildStatus === "success" && (
|
||||
<StatusTag tone="success" label="构建完成" />
|
||||
)}
|
||||
{uploadStatus && <StatusTag tone={uploadStatus.tone} label={uploadStatus.label} />}
|
||||
{reviewStatus && reviewStatusView[task.reviewStatus ?? "not_submitted"] && (
|
||||
<StatusTag tone={reviewStatus.tone} label={reviewStatus.label} />
|
||||
)}
|
||||
{task.weappUploadId && (
|
||||
<Typography.Text type="secondary">微信版本 {task.weappUploadId}</Typography.Text>
|
||||
)}
|
||||
</Space>
|
||||
<span className="admin-text-xs">
|
||||
{staleBuilding ? "超过 30 分钟没有新的构建输出,可能已中断;可直接重试。" : status.hint}
|
||||
{staleBuilding ? "超过 15 分钟没有新的构建输出,可能已中断;可直接重试。" : status.hint}
|
||||
</span>
|
||||
<Tooltip title={`创建于 ${formatTime(task.createdAt)}`}>
|
||||
<span className="admin-text-xs-quiet">更新于 {formatTime(task.updatedAt)}</span>
|
||||
|
||||
@@ -1,30 +1,48 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { Alert, Button, Divider, Form, Input, Modal, Space, Tabs, Typography } from "antd";
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Divider,
|
||||
Input,
|
||||
Modal,
|
||||
Form,
|
||||
Select,
|
||||
Space,
|
||||
Spin,
|
||||
Tabs,
|
||||
Typography,
|
||||
message,
|
||||
} from "antd";
|
||||
import type { BrandTemplateKey } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { AdminSection } from "../../components/AdminSection.js";
|
||||
import { EmptyState } from "../../components/EmptyState.js";
|
||||
import { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
import { ErrorNote, MutationError, QueryState } from "../../components/QueryState.js";
|
||||
import { StatusTag, statusLabel } from "../../components/StatusTag.js";
|
||||
import { MiniAppReleaseCard } from "./MiniAppReleaseCard.js";
|
||||
import { MiniAppSettingsTab, type MiniAppSettingsValues } from "./MiniAppSettingsTab.js";
|
||||
import { usePublicationQueries } from "./use-publication-queries.js";
|
||||
import { usePublicationMutations } from "./use-publication-mutations.js";
|
||||
|
||||
const client = createApiClient();
|
||||
|
||||
const destinations: Record<string, string> = {
|
||||
brand: "/admin/brand",
|
||||
positioning: "/admin/brand",
|
||||
template: "/admin/page-scheme",
|
||||
visual: "/admin/page-scheme",
|
||||
template: "/admin/publication",
|
||||
visual: "/admin/publication",
|
||||
offerings: "/admin/services",
|
||||
forms: "/admin/workspace",
|
||||
trust: "/admin/trust",
|
||||
};
|
||||
|
||||
export function PublicationPage() {
|
||||
export function PublicationPage({ canManageTemplate }: { canManageTemplate: boolean }) {
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
const [industryTarget, setIndustryTarget] = useState<BrandTemplateKey | null>(null);
|
||||
const [confirmAction, setConfirmAction] = useState<"publish" | "revoke" | null>(null);
|
||||
const [rollbackVersion, setRollbackVersion] = useState<number | null>(null);
|
||||
const [note, setNote] = useState("");
|
||||
@@ -32,11 +50,15 @@ export function PublicationPage() {
|
||||
const [miniAppSettingsForm] = Form.useForm<MiniAppSettingsValues>();
|
||||
const queries = usePublicationQueries(miniAppSettingsForm);
|
||||
const {
|
||||
brand,
|
||||
workspace,
|
||||
catalog,
|
||||
sample,
|
||||
readiness,
|
||||
releases,
|
||||
miniAppReleases,
|
||||
miniAppSettings,
|
||||
templatePreview,
|
||||
loading,
|
||||
error,
|
||||
retry,
|
||||
@@ -45,10 +67,11 @@ export function PublicationPage() {
|
||||
for (const key of [
|
||||
"publication-brand",
|
||||
"publication-workspace",
|
||||
"publication-sample",
|
||||
"publication-readiness",
|
||||
"publication-template-preview",
|
||||
"publication-releases",
|
||||
"publication-miniapp-releases",
|
||||
"publication-miniapp-settings",
|
||||
"admin-shell-brand",
|
||||
"admin-workspace",
|
||||
"public-runtime-workspace",
|
||||
@@ -58,11 +81,18 @@ export function PublicationPage() {
|
||||
};
|
||||
const mutations = usePublicationMutations({
|
||||
refresh,
|
||||
brandConfig: brand.data?.config,
|
||||
onInstallClose: () => setIndustryTarget(null),
|
||||
onPublishClose: () => setConfirmAction(null),
|
||||
onNoteClear: () => setNote(""),
|
||||
onRollbackClose: () => setRollbackVersion(null),
|
||||
});
|
||||
const {
|
||||
install,
|
||||
upgradeTemplate,
|
||||
rollbackTemplate,
|
||||
selectVisual,
|
||||
importSample,
|
||||
publish,
|
||||
revoke,
|
||||
rollback,
|
||||
@@ -71,6 +101,20 @@ export function PublicationPage() {
|
||||
uploadMiniAppRelease,
|
||||
updateMiniAppStatus,
|
||||
} = mutations;
|
||||
const industryKey =
|
||||
workspace.data?.installations[0]?.templateKey ??
|
||||
workspace.data?.brand?.templateKey ??
|
||||
brand.data?.templateKey ??
|
||||
catalog.data?.industries[0]?.key ??
|
||||
null;
|
||||
const visuals = (catalog.data?.visuals ?? []).filter(
|
||||
(item) =>
|
||||
typeof industryKey === "string" && item.supportedIndustryTemplates.includes(industryKey),
|
||||
);
|
||||
const visualKey =
|
||||
typeof brand.data?.config?.visualTemplateKey === "string"
|
||||
? brand.data.config.visualTemplateKey
|
||||
: (visuals[0]?.key ?? null);
|
||||
const currentRelease = releases.data?.find((item) => item.status === "published");
|
||||
const publishedHistory = (releases.data ?? []).filter(
|
||||
(item) => item.status === "published" || item.status === "superseded",
|
||||
@@ -82,12 +126,100 @@ export function PublicationPage() {
|
||||
isEnabled: boolean;
|
||||
}>;
|
||||
|
||||
const contentTab = null;
|
||||
const miniAppSettingsTab = (
|
||||
<div className="admin-stack admin-stack-lg">
|
||||
<AdminSection
|
||||
title="小程序上传配置"
|
||||
description="AppID 用于服务端调用微信官方上传工具;上传私钥保存前会使用 AES-256-GCM 加密。"
|
||||
>
|
||||
{miniAppSettings.data?.buildError ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
className="admin-offset-bottom"
|
||||
message="小程序构建参数未就绪"
|
||||
description={miniAppSettings.data.buildError}
|
||||
/>
|
||||
) : (
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
className="admin-offset-bottom"
|
||||
message={`请求域名 ${miniAppSettings.data?.requestDomain ?? "未确认"}`}
|
||||
description="该域名在构建时写入小程序包,必须与微信后台“开发设置 → 服务器域名 → request 合法域名”一致;不一致会导致小程序打开即加载失败。"
|
||||
/>
|
||||
)}
|
||||
<Form
|
||||
form={miniAppSettingsForm}
|
||||
layout="vertical"
|
||||
onFinish={(values) => saveMiniAppSettings.mutate(values)}
|
||||
>
|
||||
<Form.Item
|
||||
name="appId"
|
||||
label="微信 AppID"
|
||||
rules={[{ required: true, message: "请输入微信 AppID" }]}
|
||||
>
|
||||
<Input maxLength={100} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="apiBaseUrl"
|
||||
label="小程序请求地址"
|
||||
rules={[
|
||||
{ required: true, message: "请输入小程序请求地址" },
|
||||
{
|
||||
validator: (_rule, value: string) =>
|
||||
!value || /^https:\/\/[^/]+/.test(value)
|
||||
? Promise.resolve()
|
||||
: Promise.reject(
|
||||
new Error(
|
||||
"公网地址必须以 https:// 开头,例如 https://wechat.app.que01.top/api",
|
||||
),
|
||||
),
|
||||
},
|
||||
]}
|
||||
extra="构建时写入小程序包,必须与微信后台“开发设置 → 服务器域名 → request 合法域名”一致。修改后需重新构建并上传代码才生效。"
|
||||
>
|
||||
<Input maxLength={200} placeholder="https://wechat.app.que01.top/api" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="privateKey"
|
||||
label="上传私钥"
|
||||
help={
|
||||
miniAppSettings.data?.hasStoredCredentials
|
||||
? "已加密保存。留空保持现有私钥,输入新值可替换。"
|
||||
: "粘贴微信开发者工具导出的 private.<appid>.key 全文,必须保留换行。"
|
||||
}
|
||||
>
|
||||
<Input.TextArea
|
||||
rows={5}
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
placeholder={"-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----"}
|
||||
className="admin-code-input"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Space>
|
||||
<Button type="primary" loading={saveMiniAppSettings.isPending} htmlType="submit">
|
||||
保存上传配置
|
||||
</Button>
|
||||
{miniAppSettings.data?.hasStoredCredentials ? (
|
||||
<StatusTag tone="success" label="已加密保存上传凭据" />
|
||||
) : (
|
||||
<StatusTag tone="warning" label="未配置上传私钥" />
|
||||
)}
|
||||
</Space>
|
||||
<MutationError error={saveMiniAppSettings.error} />
|
||||
</Form>
|
||||
</AdminSection>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<QueryState loading={loading} error={error} onRetry={retry}>
|
||||
<AdminPageHeader
|
||||
title="内容与发布"
|
||||
description="检查当前草稿并发布品牌内容;页面方案与内容发布互不混用。"
|
||||
extra={<Button onClick={() => navigate("/admin/page-scheme")}>管理页面方案</Button>}
|
||||
title="配置与发布"
|
||||
description="编辑内容不会立即影响小程序;确认后统一发布当前品牌。"
|
||||
/>
|
||||
<Tabs
|
||||
activeKey={activeTab}
|
||||
@@ -96,175 +228,321 @@ export function PublicationPage() {
|
||||
{
|
||||
key: "content",
|
||||
label: "内容发布",
|
||||
children: (
|
||||
<div className="admin-stack">
|
||||
<AdminSection
|
||||
title="发布前检查"
|
||||
description="请先处理未完成的检查项,再发布当前草稿。发布不会自动修改页面方案。"
|
||||
>
|
||||
{draftOfferings.length || draftForms.length ? (
|
||||
<p className="admin-section-description">
|
||||
当前草稿包含 {draftOfferings.length} 个启用中的业务提供项和{" "}
|
||||
{draftForms.length} 个咨询表单。
|
||||
</p>
|
||||
) : null}
|
||||
<ul className="admin-list">
|
||||
{(readiness.data?.checks ?? []).map((check) => (
|
||||
<li key={check.key} className="admin-row">
|
||||
<div className="admin-row-main">
|
||||
<div className="admin-row-line">
|
||||
<StatusTag
|
||||
tone={check.passed ? "success" : "warning"}
|
||||
label={check.passed ? "已完成" : "待完善"}
|
||||
/>
|
||||
<span className="admin-row-title">{check.label}</span>
|
||||
{!check.passed && check.help ? (
|
||||
<span className="admin-row-meta">{check.help}</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
{!check.passed ? (
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
onClick={() =>
|
||||
navigate(
|
||||
check.destination ?? destinations[check.key] ?? "/admin/overview",
|
||||
)
|
||||
}
|
||||
>
|
||||
去处理
|
||||
</Button>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Space wrap className="admin-offset-top">
|
||||
<Button
|
||||
type="primary"
|
||||
disabled={!readiness.data?.ready}
|
||||
onClick={() => setConfirmAction("publish")}
|
||||
>
|
||||
发布当前草稿
|
||||
</Button>
|
||||
{currentRelease && (
|
||||
<Button danger onClick={() => setConfirmAction("revoke")}>
|
||||
撤回当前版本
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
<MutationError error={publish.error || revoke.error} />
|
||||
<Divider className="admin-divider" />
|
||||
<h3 className="admin-section-title">发布记录</h3>
|
||||
{releases.data?.length ? (
|
||||
<ul className="admin-list admin-offset-top-xs">
|
||||
{releases.data.map((item) => (
|
||||
<li key={item.id} className="admin-row">
|
||||
<div className="admin-row-main">
|
||||
<div className="admin-row-line">
|
||||
<span className="admin-row-title">v{item.version}</span>
|
||||
<StatusTag
|
||||
tone={item.status === "published" ? "success" : "neutral"}
|
||||
label={statusLabel(item.status)}
|
||||
/>
|
||||
<span className="admin-row-meta">
|
||||
{new Date(item.createdAt).toLocaleString("zh-CN")}
|
||||
</span>
|
||||
{item.note ? (
|
||||
<span className="admin-row-meta">{item.note}</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
{item.status === "superseded" && publishedHistory.length > 1 ? (
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
onClick={() => setRollbackVersion(item.version)}
|
||||
>
|
||||
恢复此版本
|
||||
</Button>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<EmptyState
|
||||
compact
|
||||
title="暂无发布记录"
|
||||
description="完成检查并发布后,这里会保留每个版本的记录。"
|
||||
/>
|
||||
)}
|
||||
<MutationError error={rollback.error} />
|
||||
</AdminSection>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: "miniapp",
|
||||
label: "小程序发布",
|
||||
children: (
|
||||
<div className="admin-stack admin-stack-lg">
|
||||
<AdminSection
|
||||
title="小程序代码发布"
|
||||
description="使用微信官方工具上传代码;审核与发布状态需按微信平台结果人工确认。"
|
||||
extra={
|
||||
<Space wrap>
|
||||
<Button
|
||||
type="primary"
|
||||
disabled={!currentRelease}
|
||||
loading={uploadLatestMiniAppRelease.isPending}
|
||||
onClick={() => uploadLatestMiniAppRelease.mutate()}
|
||||
>
|
||||
上传当前版本到微信
|
||||
</Button>
|
||||
{miniAppSettings.data?.hasStoredCredentials ? (
|
||||
<StatusTag tone="success" label="已配置上传凭据" />
|
||||
) : (
|
||||
<StatusTag tone="warning" label="未配置上传凭据" />
|
||||
)}
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
{miniAppReleases.data?.length ? (
|
||||
<div className="admin-stack admin-stack-tight">
|
||||
{miniAppReleases.data.map((task) => (
|
||||
<MiniAppReleaseCard
|
||||
key={task.id}
|
||||
task={task}
|
||||
uploading={uploadMiniAppRelease.isPending}
|
||||
onUpload={() => uploadMiniAppRelease.mutate(task.id)}
|
||||
onStatusChange={(status) =>
|
||||
updateMiniAppStatus.mutate({ id: task.id, status })
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState
|
||||
compact
|
||||
title="暂无小程序发布任务"
|
||||
description="先发布品牌内容,再上传当前版本到微信。"
|
||||
/>
|
||||
)}
|
||||
</AdminSection>
|
||||
</div>
|
||||
),
|
||||
children: contentTab,
|
||||
},
|
||||
{ key: "miniapp", label: "小程序发布", children: null },
|
||||
{
|
||||
key: "settings",
|
||||
label: "小程序配置",
|
||||
children: (
|
||||
<MiniAppSettingsTab
|
||||
form={miniAppSettingsForm}
|
||||
settings={miniAppSettings.data}
|
||||
saving={saveMiniAppSettings.isPending}
|
||||
error={saveMiniAppSettings.error}
|
||||
onSave={(values) => saveMiniAppSettings.mutate(values)}
|
||||
/>
|
||||
),
|
||||
children:
|
||||
activeTab === "settings" ? (
|
||||
<MiniAppSettingsTab
|
||||
form={miniAppSettingsForm}
|
||||
settings={miniAppSettings.data}
|
||||
saving={saveMiniAppSettings.isPending}
|
||||
error={saveMiniAppSettings.error}
|
||||
onSave={(values) => saveMiniAppSettings.mutate(values)}
|
||||
/>
|
||||
) : null,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
{activeTab === "content" && (
|
||||
<div className="admin-stack">
|
||||
<AdminSection
|
||||
title="选择表达方式"
|
||||
description="行业模板决定内容结构,视觉模板决定小程序的排版风格。"
|
||||
>
|
||||
<Space wrap>
|
||||
<Select
|
||||
aria-label="行业模板"
|
||||
className="admin-field-w-xl"
|
||||
value={industryKey}
|
||||
disabled={!canManageTemplate || Boolean(workspace.data?.installations.length)}
|
||||
options={(catalog.data?.industries ?? []).map((item) => ({
|
||||
value: item.key,
|
||||
label: item.name,
|
||||
}))}
|
||||
onChange={(key: BrandTemplateKey) => setIndustryTarget(key)}
|
||||
/>
|
||||
<Select
|
||||
aria-label="视觉模板"
|
||||
className="admin-field-w-xl"
|
||||
value={visualKey}
|
||||
disabled={!canManageTemplate}
|
||||
loading={selectVisual.isPending}
|
||||
options={visuals.map((item) => ({ value: item.key, label: item.name }))}
|
||||
onChange={(key) => selectVisual.mutate(key)}
|
||||
/>
|
||||
</Space>
|
||||
{industryKey ? (
|
||||
<div className="admin-offset-top-sm">
|
||||
<Space wrap>
|
||||
<StatusTag
|
||||
tone="neutral"
|
||||
label={`当前版本 ${templatePreview.data?.currentVersion ?? "加载中"}`}
|
||||
/>
|
||||
<StatusTag
|
||||
tone="info"
|
||||
label={`最新版本 ${templatePreview.data?.latestVersion ?? "加载中"}`}
|
||||
/>
|
||||
{templatePreview.data?.canUpgrade ? (
|
||||
<Button
|
||||
type="primary"
|
||||
size="small"
|
||||
disabled={!canManageTemplate}
|
||||
loading={upgradeTemplate.isPending}
|
||||
onClick={() => upgradeTemplate.mutate()}
|
||||
>
|
||||
升级模板
|
||||
</Button>
|
||||
) : (
|
||||
<StatusTag tone="success" label="已是最新版本" />
|
||||
)}
|
||||
{templatePreview.data?.canRollback ? (
|
||||
<Button
|
||||
danger
|
||||
size="small"
|
||||
disabled={!canManageTemplate}
|
||||
loading={rollbackTemplate.isPending}
|
||||
onClick={() => rollbackTemplate.mutate()}
|
||||
>
|
||||
回滚到上一版
|
||||
</Button>
|
||||
) : null}
|
||||
</Space>
|
||||
<p className="admin-section-description admin-offset-top-sm">
|
||||
行业模板随品牌身份固定,只能升级版本、不能更换行业;升级只补充字段与模块,不覆盖已有内容。视觉模板只替换排版风格。
|
||||
</p>
|
||||
<MutationError
|
||||
error={templatePreview.error || upgradeTemplate.error || rollbackTemplate.error}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
<MutationError error={install.error || selectVisual.error} />
|
||||
<Divider className="admin-divider" />
|
||||
<Space wrap>
|
||||
<Typography.Text>示例内容</Typography.Text>
|
||||
{sample.isLoading && <Spin size="small" />}
|
||||
{sample.data && (
|
||||
<StatusTag
|
||||
tone={sample.data.alreadyImported ? "success" : "info"}
|
||||
label={sample.data.alreadyImported ? "已导入" : "可导入"}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
disabled={!canManageTemplate || !sample.data || sample.data.alreadyImported}
|
||||
loading={importSample.isPending}
|
||||
onClick={() => importSample.mutate()}
|
||||
>
|
||||
导入示例内容
|
||||
</Button>
|
||||
{sample.isError && <Button onClick={() => void sample.refetch()}>重试</Button>}
|
||||
</Space>
|
||||
{sample.isError && (
|
||||
<div className="admin-offset-top-sm">
|
||||
<ErrorNote error={sample.error} onRetry={() => void sample.refetch()} />
|
||||
</div>
|
||||
)}
|
||||
{sample.data && !sample.data.alreadyImported && (
|
||||
<p className="admin-section-description admin-offset-top-sm">
|
||||
将向草稿添加{" "}
|
||||
{Object.entries(sample.data.counts)
|
||||
.map(([key, count]) => `${key} ${count} 项`)
|
||||
.join("、")}
|
||||
;发布前请替换示例文案和图片。
|
||||
</p>
|
||||
)}
|
||||
<MutationError error={importSample.error} />
|
||||
</AdminSection>
|
||||
<AdminSection
|
||||
title="核对草稿内容"
|
||||
description="此处核对的是待发布内容,不是小程序视觉预览。"
|
||||
>
|
||||
<ul className="admin-list">
|
||||
<li className="admin-row">
|
||||
<div className="admin-row-main">
|
||||
<div className="admin-row-line">
|
||||
<span className="admin-row-title">{brand.data?.name || "未命名品牌"}</span>
|
||||
<span className="admin-row-meta">
|
||||
{brand.data?.tagline || "尚未填写品牌定位"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li className="admin-row">
|
||||
<div className="admin-row-main">
|
||||
<div className="admin-row-line">
|
||||
<span className="admin-row-title">已启用业务项</span>
|
||||
<span className="admin-row-meta">
|
||||
{draftOfferings.map((item) => item.name).join("、") || "无"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li className="admin-row">
|
||||
<div className="admin-row-main">
|
||||
<div className="admin-row-line">
|
||||
<span className="admin-row-title">已启用咨询表单</span>
|
||||
<span className="admin-row-meta">
|
||||
{draftForms
|
||||
.filter((item) => item.isEnabled)
|
||||
.map((item) => item.name)
|
||||
.join("、") || "无"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<Space wrap className="admin-offset-top">
|
||||
<Button onClick={() => navigate("/admin/brand")}>编辑小程序页面</Button>
|
||||
<Button onClick={() => navigate("/admin/services")}>编辑业务展示和详情</Button>
|
||||
<Button onClick={() => navigate("/admin/trust")}>编辑信任证明</Button>
|
||||
</Space>
|
||||
</AdminSection>
|
||||
<AdminSection
|
||||
title="检查并发布"
|
||||
extra={
|
||||
<Space wrap>
|
||||
<StatusTag
|
||||
tone={currentRelease ? "success" : "neutral"}
|
||||
label={currentRelease ? `已发布 v${currentRelease.version}` : "尚未发布"}
|
||||
/>
|
||||
<Button onClick={() => void readiness.refetch()}>重新检查</Button>
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
<ul className="admin-list">
|
||||
{(readiness.data?.checks ?? []).map((check) => (
|
||||
<li key={check.key} className="admin-row">
|
||||
<div className="admin-row-main">
|
||||
<div className="admin-row-line">
|
||||
<StatusTag
|
||||
tone={check.passed ? "success" : "warning"}
|
||||
label={check.passed ? "已完成" : "待完善"}
|
||||
/>
|
||||
<span className="admin-row-title">{check.label}</span>
|
||||
{!check.passed && check.help ? (
|
||||
<span className="admin-row-meta">{check.help}</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
{!check.passed ? (
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
onClick={() =>
|
||||
navigate(check.destination ?? destinations[check.key] ?? "/admin/overview")
|
||||
}
|
||||
>
|
||||
去处理
|
||||
</Button>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Space wrap className="admin-offset-top">
|
||||
<Button
|
||||
type="primary"
|
||||
disabled={!readiness.data?.ready}
|
||||
onClick={() => setConfirmAction("publish")}
|
||||
>
|
||||
发布当前草稿
|
||||
</Button>
|
||||
{currentRelease && (
|
||||
<Button danger onClick={() => setConfirmAction("revoke")}>
|
||||
撤回当前版本
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
<MutationError error={publish.error || revoke.error} />
|
||||
<Divider className="admin-divider" />
|
||||
<h3 className="admin-section-title">发布记录</h3>
|
||||
{releases.data?.length ? (
|
||||
<ul className="admin-list admin-offset-top-xs">
|
||||
{releases.data.map((item) => (
|
||||
<li key={item.id} className="admin-row">
|
||||
<div className="admin-row-main">
|
||||
<div className="admin-row-line">
|
||||
<span className="admin-row-title">v{item.version}</span>
|
||||
<StatusTag
|
||||
tone={item.status === "published" ? "success" : "neutral"}
|
||||
label={statusLabel(item.status)}
|
||||
/>
|
||||
<span className="admin-row-meta">
|
||||
{new Date(item.createdAt).toLocaleString("zh-CN")}
|
||||
</span>
|
||||
{item.note ? <span className="admin-row-meta">{item.note}</span> : null}
|
||||
</div>
|
||||
</div>
|
||||
{item.status === "superseded" && publishedHistory.length > 1 ? (
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
onClick={() => setRollbackVersion(item.version)}
|
||||
>
|
||||
恢复此版本
|
||||
</Button>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<EmptyState
|
||||
compact
|
||||
title="暂无发布记录"
|
||||
description="完成检查并发布后,这里会保留每个版本的记录。"
|
||||
/>
|
||||
)}
|
||||
<MutationError error={rollback.error} />
|
||||
</AdminSection>
|
||||
</div>
|
||||
)}
|
||||
{activeTab === "miniapp" && (
|
||||
<div className="admin-stack admin-stack-lg">
|
||||
<AdminSection
|
||||
title="小程序代码发布"
|
||||
description="使用微信官方工具上传代码;审核与发布状态需按微信平台结果人工确认。"
|
||||
extra={
|
||||
<Space wrap>
|
||||
<Button
|
||||
type="primary"
|
||||
disabled={!currentRelease}
|
||||
loading={uploadLatestMiniAppRelease.isPending}
|
||||
onClick={() => uploadLatestMiniAppRelease.mutate()}
|
||||
>
|
||||
上传当前版本到微信
|
||||
</Button>
|
||||
{miniAppSettings.data?.hasStoredCredentials ? (
|
||||
<StatusTag tone="success" label="已配置上传凭据" />
|
||||
) : (
|
||||
<StatusTag tone="warning" label="未配置上传凭据" />
|
||||
)}
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
{miniAppReleases.data?.length ? (
|
||||
<div className="admin-stack admin-stack-tight">
|
||||
{miniAppReleases.data.map((task) => (
|
||||
<MiniAppReleaseCard
|
||||
key={task.id}
|
||||
task={task}
|
||||
uploading={uploadMiniAppRelease.isPending}
|
||||
onUpload={() => uploadMiniAppRelease.mutate(task.id)}
|
||||
onStatusChange={(status) => updateMiniAppStatus.mutate({ id: task.id, status })}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState
|
||||
compact
|
||||
title="暂无小程序发布任务"
|
||||
description="先发布品牌内容,再上传当前版本到微信。"
|
||||
/>
|
||||
)}
|
||||
</AdminSection>
|
||||
</div>
|
||||
)}
|
||||
<Modal
|
||||
title={confirmAction === "revoke" ? "确认撤回品牌" : "确认发布品牌"}
|
||||
open={confirmAction !== null}
|
||||
@@ -300,6 +578,15 @@ export function PublicationPage() {
|
||||
>
|
||||
将 v{rollbackVersion} 重新发布为新版本;当前草稿不会被覆盖。
|
||||
</Modal>
|
||||
<Modal
|
||||
title="确认安装行业模板"
|
||||
open={industryTarget !== null}
|
||||
onCancel={() => setIndustryTarget(null)}
|
||||
onOk={() => industryTarget && install.mutate(industryTarget)}
|
||||
confirmLoading={install.isPending}
|
||||
>
|
||||
模板会更新当前品牌的草稿结构,不会立即改变已发布的小程序。请安装后核对业务内容与视觉模板。
|
||||
</Modal>
|
||||
</QueryState>
|
||||
);
|
||||
}
|
||||
@@ -1,11 +1,14 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { message } from "antd";
|
||||
import type { BrandTemplateKey } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
|
||||
const client = createApiClient();
|
||||
|
||||
interface MutationOptions {
|
||||
refresh: () => void;
|
||||
brandConfig: Record<string, unknown> | null | undefined;
|
||||
onInstallClose: () => void;
|
||||
onPublishClose: () => void;
|
||||
onNoteClear: () => void;
|
||||
onRollbackClose: () => void;
|
||||
@@ -13,11 +16,56 @@ interface MutationOptions {
|
||||
|
||||
export function usePublicationMutations({
|
||||
refresh,
|
||||
onInstallClose,
|
||||
onPublishClose,
|
||||
onNoteClear,
|
||||
onRollbackClose,
|
||||
brandConfig,
|
||||
}: MutationOptions) {
|
||||
const queryClient = useQueryClient();
|
||||
const install = useMutation({
|
||||
mutationFn: (key: BrandTemplateKey) => client.installAdminTemplate(key),
|
||||
onSuccess: () => {
|
||||
onInstallClose();
|
||||
message.success("行业模板已安装");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const upgradeTemplate = useMutation({
|
||||
mutationFn: () => client.upgradeAdminTemplate(),
|
||||
onSuccess: () => {
|
||||
message.success("行业模板已升级,现有内容未被覆盖");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const rollbackTemplate = useMutation({
|
||||
mutationFn: () => client.rollbackAdminTemplate(),
|
||||
onSuccess: () => {
|
||||
message.success("行业模板配置基线已回滚");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const selectVisual = useMutation({
|
||||
mutationFn: (key: string) =>
|
||||
client.updateAdminBrand({
|
||||
config: { ...(brandConfig ?? {}), visualTemplateKey: key },
|
||||
}),
|
||||
onSuccess: () => {
|
||||
message.success("视觉模板已保存到草稿");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const importSample = useMutation<Awaited<ReturnType<typeof client.importAdminSampleContent>>>({
|
||||
mutationFn: () => client.importAdminSampleContent(),
|
||||
onSuccess: ({ counts }) => {
|
||||
message.success(
|
||||
counts.inquiryForms
|
||||
? "示例内容和客户咨询表单已导入草稿"
|
||||
: "示例内容已导入草稿,现有客户咨询表单已保留",
|
||||
);
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const publish = useMutation({
|
||||
mutationFn: (note: string) => client.publishAdminRelease(note || undefined),
|
||||
onSuccess: () => {
|
||||
@@ -88,6 +136,11 @@ export function usePublicationMutations({
|
||||
});
|
||||
|
||||
return {
|
||||
install,
|
||||
upgradeTemplate,
|
||||
rollbackTemplate,
|
||||
selectVisual,
|
||||
importSample,
|
||||
publish,
|
||||
revoke,
|
||||
rollback,
|
||||
|
||||
@@ -20,6 +20,15 @@ export function usePublicationQueries(
|
||||
queryKey: ["publication-workspace"],
|
||||
queryFn: () => client.getAdminWorkspace(),
|
||||
});
|
||||
const catalog = useQuery<Awaited<ReturnType<typeof client.listPublicTemplates>>>({
|
||||
queryKey: ["publication-catalog"],
|
||||
queryFn: () => client.listPublicTemplates(),
|
||||
});
|
||||
const sample = useQuery<Awaited<ReturnType<typeof client.previewAdminSampleContent>>>({
|
||||
queryKey: ["publication-sample"],
|
||||
queryFn: () => client.previewAdminSampleContent(),
|
||||
enabled: Boolean(workspace.data),
|
||||
});
|
||||
const readiness = useQuery<Awaited<ReturnType<typeof client.getAdminReleaseReadiness>>>({
|
||||
queryKey: ["publication-readiness"],
|
||||
queryFn: () => client.getAdminReleaseReadiness(),
|
||||
@@ -36,6 +45,12 @@ export function usePublicationQueries(
|
||||
queryKey: ["publication-miniapp-settings"],
|
||||
queryFn: () => client.getAdminMiniAppSettings(),
|
||||
});
|
||||
const templatePreview = useQuery<
|
||||
Awaited<ReturnType<typeof client.getAdminTemplateUpgradePreview>>
|
||||
>({
|
||||
queryKey: ["publication-template-preview"],
|
||||
queryFn: () => client.getAdminTemplateUpgradePreview(),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!miniAppSettings.data) return;
|
||||
@@ -50,22 +65,35 @@ export function usePublicationQueries(
|
||||
const building = miniAppReleases.data?.find(
|
||||
(task) =>
|
||||
task.buildStatus === "building" &&
|
||||
Date.now() - new Date(task.updatedAt).getTime() < 30 * 60 * 1000,
|
||||
Date.now() - new Date(task.updatedAt).getTime() < 15 * 60 * 1000,
|
||||
);
|
||||
if (!building) return;
|
||||
const timer = setInterval(() => void miniAppReleases.refetch(), 1500);
|
||||
return () => clearInterval(timer);
|
||||
}, [miniAppReleases]);
|
||||
|
||||
const loading = [brand, workspace, readiness, releases, miniAppReleases, miniAppSettings].some(
|
||||
(query) => query.isLoading,
|
||||
);
|
||||
const error = [brand, workspace, readiness, releases, miniAppReleases, miniAppSettings].find(
|
||||
(query) => query.isError,
|
||||
)?.error;
|
||||
const loading = [
|
||||
brand,
|
||||
workspace,
|
||||
catalog,
|
||||
readiness,
|
||||
releases,
|
||||
miniAppReleases,
|
||||
miniAppSettings,
|
||||
].some((query) => query.isLoading);
|
||||
const error = [
|
||||
brand,
|
||||
workspace,
|
||||
catalog,
|
||||
readiness,
|
||||
releases,
|
||||
miniAppReleases,
|
||||
miniAppSettings,
|
||||
].find((query) => query.isError)?.error;
|
||||
const retry = () => {
|
||||
void brand.refetch();
|
||||
void workspace.refetch();
|
||||
void catalog.refetch();
|
||||
void readiness.refetch();
|
||||
void releases.refetch();
|
||||
void miniAppReleases.refetch();
|
||||
@@ -75,10 +103,13 @@ export function usePublicationQueries(
|
||||
return {
|
||||
brand,
|
||||
workspace,
|
||||
catalog,
|
||||
sample,
|
||||
readiness,
|
||||
releases,
|
||||
miniAppReleases,
|
||||
miniAppSettings,
|
||||
templatePreview,
|
||||
loading,
|
||||
error,
|
||||
retry,
|
||||
|
||||
@@ -20,7 +20,7 @@ export function useOfferingEditor(templateFields: TemplateAdminField[]) {
|
||||
const templateFieldSection = useMemo<TemplateAdminSection>(
|
||||
() => ({
|
||||
key: "offering",
|
||||
title: "页面方案内容",
|
||||
title: "模板内容",
|
||||
description: "",
|
||||
page: "detail",
|
||||
target: "offering",
|
||||
|
||||
@@ -1,317 +0,0 @@
|
||||
import { useRef, useState } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { Alert, Button, List, Modal, Table, Tag, Typography, message } from "antd";
|
||||
import { EyeOutlined, ReloadOutlined, UploadOutlined } from "@ant-design/icons";
|
||||
import type { TemplatePackageVersion } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { AdminSection } from "../../components/AdminSection.js";
|
||||
import { EmptyState } from "../../components/EmptyState.js";
|
||||
import { ErrorNote, QueryState } from "../../components/QueryState.js";
|
||||
import { TemplatePackagePreviewModal } from "./TemplatePackagePreviewModal.js";
|
||||
|
||||
const client = createApiClient();
|
||||
|
||||
const failureActionLabels: Record<string, string> = {
|
||||
import: "模板导入失败",
|
||||
preview: "模板预览失败",
|
||||
install: "模板安装失败",
|
||||
upgrade: "模板升级失败",
|
||||
rollback: "模板回滚失败",
|
||||
install_conflict: "模板操作冲突",
|
||||
build: "小程序构建失败",
|
||||
upload: "小程序上传失败",
|
||||
};
|
||||
|
||||
function formatBytes(value: unknown): string {
|
||||
const bytes = typeof value === "number" ? value : 0;
|
||||
if (bytes < 1024) return `${bytes} B`;
|
||||
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
||||
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
||||
}
|
||||
|
||||
export function TemplateManagementPage() {
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
const [auditId, setAuditId] = useState<string | null>(null);
|
||||
const [previewVersion, setPreviewVersion] = useState<TemplatePackageVersion | null>(null);
|
||||
const queryClient = useQueryClient();
|
||||
const packages = useQuery({
|
||||
queryKey: ["admin-template-packages", page, pageSize],
|
||||
queryFn: () => client.listAdminTemplatePackages({ page, pageSize }),
|
||||
});
|
||||
const audit = useQuery({
|
||||
queryKey: ["admin-template-package-audit", auditId],
|
||||
queryFn: () => client.listAdminTemplatePackageAudit(auditId as string),
|
||||
enabled: Boolean(auditId),
|
||||
});
|
||||
const metrics = useQuery({
|
||||
queryKey: ["admin-template-operation-failures", 30],
|
||||
queryFn: () => client.getAdminTemplateOperationFailures({ days: 30 }),
|
||||
});
|
||||
const lifecycle = useMutation({
|
||||
mutationFn: async ({ id, action }: { id: string; action: "publish" | "retire" }) =>
|
||||
action === "publish"
|
||||
? client.publishAdminTemplatePackage(id)
|
||||
: client.retireAdminTemplatePackage(id),
|
||||
onSuccess: (result) => {
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-template-packages"] });
|
||||
message.success(result.changed ? "模板目录状态已更新" : "模板目录状态未变化");
|
||||
},
|
||||
});
|
||||
const importing = useMutation({
|
||||
mutationFn: (file: File) => {
|
||||
const form = new FormData();
|
||||
form.append("archive", file, file.name);
|
||||
return client.importAdminTemplatePackage(form);
|
||||
},
|
||||
onSuccess: () => {
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-template-packages"] });
|
||||
},
|
||||
});
|
||||
const chooseFile = () => inputRef.current?.click();
|
||||
const onFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = event.target.files?.[0];
|
||||
event.target.value = "";
|
||||
if (!file) return;
|
||||
if (!file.name.endsWith(".tar.gz")) {
|
||||
importing.reset();
|
||||
return;
|
||||
}
|
||||
importing.mutate(file);
|
||||
};
|
||||
const rows = packages.data?.items ?? [];
|
||||
return (
|
||||
<div className="admin-stack admin-stack-lg">
|
||||
<AdminPageHeader
|
||||
title="模板管理"
|
||||
description="导入通过本地模板检查的确定性 archive,登记版本、校验摘要并供后续预览与安装使用。"
|
||||
extra={
|
||||
<>
|
||||
<input
|
||||
ref={inputRef}
|
||||
type="file"
|
||||
accept=".tar.gz,application/gzip"
|
||||
onChange={onFileChange}
|
||||
hidden
|
||||
/>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<UploadOutlined />}
|
||||
loading={importing.isPending}
|
||||
onClick={chooseFile}
|
||||
>
|
||||
导入模板包
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="导入规则"
|
||||
description="系统会校验文件路径、链接、文件数量、解压体积、template.json、package.json 和 checksums.json;包内脚本不会被执行。"
|
||||
/>
|
||||
{importing.isError ? <ErrorNote error={importing.error} /> : null}
|
||||
{importing.isSuccess ? (
|
||||
<Alert
|
||||
type="success"
|
||||
showIcon
|
||||
message={importing.data.idempotent ? "模板版本已存在,未重复写入" : "模板版本导入成功"}
|
||||
description={`${importing.data.version.packageKey}@${importing.data.version.version}`}
|
||||
/>
|
||||
) : null}
|
||||
{lifecycle.isError ? <ErrorNote error={lifecycle.error} /> : null}
|
||||
<AdminSection title="近 30 天失败概览" description="按操作类别统计失败次数。">
|
||||
<QueryState
|
||||
loading={metrics.isLoading}
|
||||
error={metrics.error}
|
||||
onRetry={() => void metrics.refetch()}
|
||||
>
|
||||
<List
|
||||
size="small"
|
||||
grid={{ gutter: 16, column: 4 }}
|
||||
dataSource={metrics.data?.failures ?? []}
|
||||
renderItem={(item) => (
|
||||
<List.Item>
|
||||
<Typography.Text>
|
||||
{failureActionLabels[item.action] ?? "其他操作失败"}:
|
||||
<Typography.Text strong>{item.count}</Typography.Text>
|
||||
</Typography.Text>
|
||||
</List.Item>
|
||||
)}
|
||||
/>
|
||||
</QueryState>
|
||||
</AdminSection>
|
||||
<AdminSection
|
||||
title="已导入版本"
|
||||
description="同一 package key 的不同版本并列保留,发布品牌时再选择安装版本。"
|
||||
>
|
||||
<QueryState
|
||||
loading={packages.isLoading}
|
||||
error={packages.error}
|
||||
onRetry={() => void packages.refetch()}
|
||||
>
|
||||
{rows.length ? (
|
||||
<Table<TemplatePackageVersion>
|
||||
rowKey="id"
|
||||
dataSource={rows}
|
||||
pagination={{
|
||||
current: packages.data?.page ?? page,
|
||||
pageSize: packages.data?.pageSize ?? pageSize,
|
||||
total: packages.data?.total ?? 0,
|
||||
showSizeChanger: true,
|
||||
onChange: (nextPage, nextPageSize) => {
|
||||
setPage(nextPageSize === pageSize ? nextPage : 1);
|
||||
setPageSize(nextPageSize);
|
||||
},
|
||||
}}
|
||||
scroll={{ x: 980 }}
|
||||
columns={[
|
||||
{
|
||||
title: "模板",
|
||||
key: "template",
|
||||
render: (_, item) => (
|
||||
<div>
|
||||
<Typography.Text strong>{item.displayName}</Typography.Text>
|
||||
<div className="admin-muted-text">{item.packageKey}</div>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{ title: "版本", dataIndex: "version", key: "version" },
|
||||
{
|
||||
title: "状态",
|
||||
dataIndex: "status",
|
||||
key: "status",
|
||||
render: (value: TemplatePackageVersion["status"]) => (
|
||||
<Tag
|
||||
color={
|
||||
value === "published" ? "green" : value === "imported" ? "blue" : "default"
|
||||
}
|
||||
>
|
||||
{value === "published"
|
||||
? "已发布"
|
||||
: value === "imported"
|
||||
? "待发布"
|
||||
: value === "retired"
|
||||
? "已撤回"
|
||||
: "已停用"}
|
||||
</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "文件",
|
||||
key: "report",
|
||||
render: (_, item) => {
|
||||
const report = item.validationReport;
|
||||
return `${typeof report.fileCount === "number" ? report.fileCount : "-"} 个,${formatBytes(report.extractedBytes)}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "内容 checksum",
|
||||
dataIndex: "contentChecksum",
|
||||
key: "contentChecksum",
|
||||
render: (value: string) => (
|
||||
<Typography.Text copyable>{value.slice(0, 16)}…</Typography.Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "导入人",
|
||||
key: "importedBy",
|
||||
render: (_, item) => item.importedBy.displayName,
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
key: "actions",
|
||||
render: (_, item) => (
|
||||
<span>
|
||||
<Button
|
||||
type="link"
|
||||
icon={<EyeOutlined />}
|
||||
onClick={() => setPreviewVersion(item)}
|
||||
disabled={
|
||||
item.status === "retired" ||
|
||||
item.status === "disabled" ||
|
||||
!item.manifestSummary?.supportedIndustryTemplates?.length
|
||||
}
|
||||
>
|
||||
预览
|
||||
</Button>
|
||||
<Button
|
||||
type="link"
|
||||
loading={lifecycle.isPending && lifecycle.variables?.id === item.id}
|
||||
onClick={() =>
|
||||
lifecycle.mutate({
|
||||
id: item.id,
|
||||
action: item.status === "published" ? "retire" : "publish",
|
||||
})
|
||||
}
|
||||
disabled={item.status === "disabled"}
|
||||
>
|
||||
{item.status === "published" ? "撤回" : "发布"}
|
||||
</Button>
|
||||
<Button type="link" onClick={() => setAuditId(item.id)}>
|
||||
审计
|
||||
</Button>
|
||||
</span>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
) : (
|
||||
<EmptyState
|
||||
title="还没有导入模板"
|
||||
description="从本地执行 template:pack 后导入 tar.gz。"
|
||||
/>
|
||||
)}
|
||||
</QueryState>
|
||||
</AdminSection>
|
||||
{packages.isError ? (
|
||||
<Button icon={<ReloadOutlined />} onClick={() => void packages.refetch()}>
|
||||
重试加载
|
||||
</Button>
|
||||
) : null}
|
||||
<Modal
|
||||
title="模板版本审计"
|
||||
open={Boolean(auditId)}
|
||||
footer={null}
|
||||
onCancel={() => setAuditId(null)}
|
||||
>
|
||||
<QueryState
|
||||
loading={audit.isLoading}
|
||||
error={audit.error}
|
||||
onRetry={() => void audit.refetch()}
|
||||
>
|
||||
<List
|
||||
dataSource={audit.data ?? []}
|
||||
locale={{ emptyText: "暂无审计记录" }}
|
||||
renderItem={(item) => (
|
||||
<List.Item>
|
||||
<List.Item.Meta
|
||||
title={`${item.action === "previewed" ? "预览模板" : item.action} · ${item.actor.displayName}`}
|
||||
description={
|
||||
item.action === "previewed"
|
||||
? `行业 ${typeof item.metadata?.industry === "string" ? item.metadata.industry : "-"} · ${new Date(item.createdAt).toLocaleString()}`
|
||||
: `${item.fromStatus ?? "-"} -> ${item.toStatus ?? "-"} · ${new Date(item.createdAt).toLocaleString()}`
|
||||
}
|
||||
/>
|
||||
</List.Item>
|
||||
)}
|
||||
/>
|
||||
</QueryState>
|
||||
</Modal>
|
||||
{previewVersion ? (
|
||||
<TemplatePackagePreviewModal
|
||||
version={previewVersion}
|
||||
onClose={() => {
|
||||
setPreviewVersion(null);
|
||||
void queryClient.invalidateQueries({
|
||||
queryKey: ["admin-template-package-audit", previewVersion.id],
|
||||
});
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { Alert, Collapse, List, Modal, Select, Tag, Typography } from "antd";
|
||||
import type { TemplatePackageVersion } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { QueryState } from "../../components/QueryState.js";
|
||||
import { EmptyState } from "../../components/EmptyState.js";
|
||||
import { ComponentTemplatePreview } from "../brand/ComponentTemplatePreview.js";
|
||||
|
||||
const pageLabels: Record<string, string> = {
|
||||
home: "首页",
|
||||
offerings: "业务列表",
|
||||
service: "服务",
|
||||
profile: "我的 / 主理人",
|
||||
detail: "业务详情",
|
||||
inquiry: "咨询表单",
|
||||
records: "咨询记录",
|
||||
success: "提交结果",
|
||||
};
|
||||
|
||||
export function TemplatePackagePreviewModal({
|
||||
version,
|
||||
onClose,
|
||||
}: {
|
||||
version: TemplatePackageVersion;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const [industry, setIndustry] = useState(version.manifestSummary?.supportedIndustryTemplates[0]);
|
||||
const [page, setPage] = useState("home");
|
||||
const [offeringId, setOfferingId] = useState<string>();
|
||||
const client = createApiClient();
|
||||
// 按 key 保存短期 token,避免 queryFn 引用自身 query 造成循环初始化。
|
||||
const sessionTokens = useRef(new Map<string, string>());
|
||||
const preview = useQuery({
|
||||
queryKey: ["admin-template-package-preview", version.id, industry],
|
||||
queryFn: () =>
|
||||
client.previewAdminTemplatePackage(
|
||||
version.id,
|
||||
industry!,
|
||||
sessionTokens.current.get(industry!),
|
||||
),
|
||||
enabled: Boolean(industry),
|
||||
retry: false,
|
||||
gcTime: 0,
|
||||
});
|
||||
const data = preview.data;
|
||||
useEffect(() => {
|
||||
if (preview.isError) {
|
||||
sessionTokens.current.delete(industry ?? "");
|
||||
}
|
||||
if (data && industry) {
|
||||
sessionTokens.current.set(industry, data.preview.session.token);
|
||||
}
|
||||
}, [data, industry, preview.isError]);
|
||||
return (
|
||||
<Modal
|
||||
title={`${version.displayName} · ${version.version} 版本预览`}
|
||||
open
|
||||
footer={null}
|
||||
width={960}
|
||||
onCancel={onClose}
|
||||
>
|
||||
<div className="admin-stack">
|
||||
<Select
|
||||
aria-label="预览行业"
|
||||
value={industry}
|
||||
placeholder="选择行业"
|
||||
options={(version.manifestSummary?.supportedIndustryTemplates ?? []).map((value) => ({
|
||||
label: value,
|
||||
value,
|
||||
}))}
|
||||
onChange={(value) => {
|
||||
setIndustry(value);
|
||||
setPage("home");
|
||||
setOfferingId(undefined);
|
||||
}}
|
||||
/>
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="模板演示预览"
|
||||
description="演示内容不属于真实品牌,咨询提交和客户记录读取已禁用。"
|
||||
/>
|
||||
{!industry ? (
|
||||
<EmptyState title="没有可预览的行业" description="请检查模板包的行业兼容声明。" />
|
||||
) : (
|
||||
<QueryState
|
||||
loading={preview.isLoading}
|
||||
error={preview.error}
|
||||
onRetry={() => void preview.refetch()}
|
||||
>
|
||||
{data ? (
|
||||
<>
|
||||
{data.preview.diagnostics.map((diagnostic) => (
|
||||
<Alert
|
||||
key={diagnostic.code}
|
||||
type="warning"
|
||||
showIcon
|
||||
message={diagnostic.message}
|
||||
/>
|
||||
))}
|
||||
<Typography.Text type="secondary">
|
||||
演示数据:
|
||||
{data.preview.fixtureSource === "previewFixture"
|
||||
? "独立预览内容"
|
||||
: "兼容起始内容"}
|
||||
</Typography.Text>
|
||||
<Typography.Paragraph type="secondary">
|
||||
{data.industry.name} · Runtime {data.compatibility.runtimeContract} · renderer{" "}
|
||||
{data.compatibility.renderer.key}@{data.compatibility.renderer.version}
|
||||
</Typography.Paragraph>
|
||||
<Select
|
||||
aria-label="预览页面"
|
||||
value={page}
|
||||
options={data.template.pages.map((value) => ({
|
||||
value,
|
||||
label:
|
||||
data.template.navigation.find((tab) => tab.page === value)?.label ??
|
||||
pageLabels[value] ??
|
||||
value,
|
||||
}))}
|
||||
onChange={setPage}
|
||||
/>
|
||||
{page === "detail" ? (
|
||||
<Select
|
||||
aria-label="预览业务记录"
|
||||
value={offeringId ?? data.workspace.offerings[0]?.id}
|
||||
options={data.workspace.offerings.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
}))}
|
||||
onChange={setOfferingId}
|
||||
/>
|
||||
) : null}
|
||||
<Collapse
|
||||
items={[
|
||||
{
|
||||
key: "modules",
|
||||
label: "页面模块与字段来源",
|
||||
children: (
|
||||
<List
|
||||
dataSource={
|
||||
data.preview.pages.find((item) => item.key === page)?.modules ?? []
|
||||
}
|
||||
locale={{ emptyText: "此页面由 Runtime 提供,不包含模板编辑模块" }}
|
||||
renderItem={(item) => (
|
||||
<List.Item>
|
||||
<div>
|
||||
<Typography.Text strong>{item.title}</Typography.Text>
|
||||
<Typography.Paragraph type="secondary">
|
||||
{item.bindings.join("、")}
|
||||
</Typography.Paragraph>
|
||||
</div>
|
||||
</List.Item>
|
||||
)}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: "assets",
|
||||
label: "资源诊断",
|
||||
children: (
|
||||
<List
|
||||
dataSource={data.preview.assets}
|
||||
locale={{ emptyText: "模板未声明资源槽位" }}
|
||||
renderItem={(item) => (
|
||||
<List.Item>
|
||||
<div>
|
||||
{item.label}{" "}
|
||||
<Tag color={item.status === "missing" ? "warning" : "default"}>
|
||||
{item.status === "missing"
|
||||
? "内容缺失"
|
||||
: item.status === "ready"
|
||||
? "包内资源已验证"
|
||||
: "可用性待验证"}
|
||||
</Tag>
|
||||
{item.required ? "必需" : "可选"} · 已配置 {item.populated}/
|
||||
{item.total}
|
||||
<Typography.Paragraph type="secondary">
|
||||
{item.binding}
|
||||
</Typography.Paragraph>
|
||||
</div>
|
||||
</List.Item>
|
||||
)}
|
||||
/>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<ComponentTemplatePreview
|
||||
key={`${version.id}:${industry}:${page}`}
|
||||
workspace={data.workspace}
|
||||
assetFiles={data.preview.assetFiles}
|
||||
page={page}
|
||||
{...((offeringId ?? data.workspace.offerings[0]?.id)
|
||||
? { offeringId: offeringId ?? data.workspace.offerings[0]!.id }
|
||||
: {})}
|
||||
targets={[]}
|
||||
onTargetSelected={() => undefined}
|
||||
onPageSelected={setPage}
|
||||
onOfferingSelected={setOfferingId}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
</QueryState>
|
||||
)}
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ export function TrustContentPage() {
|
||||
}
|
||||
/>
|
||||
<AdminSection
|
||||
title="当前页面方案需要配置的内容"
|
||||
title="当前模板需要配置的内容"
|
||||
description="标记为「发布必填」的项目需要填写完整后,才能发布小程序。"
|
||||
>
|
||||
<TrustRequirementsList
|
||||
|
||||
@@ -137,7 +137,7 @@ function sharesMeaningfulOverlap(label: string, token: string): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 列表按页面方案声明的类型顺序排列,与「当前页面方案需要配置的内容」保持一致。
|
||||
// 列表按模板声明的类型顺序排列,与「当前模板需要配置的内容」保持一致。
|
||||
export function sortTrustContentByTypeOrder(
|
||||
items: TrustContent[],
|
||||
availableTypes: TrustTypeOption[],
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
import { ApiClient } from "@personal-brand/api-client";
|
||||
|
||||
export const apiBaseUrl = import.meta.env.VITE_API_BASE_URL ?? "/api";
|
||||
|
||||
export async function authenticatedFetch(
|
||||
input: RequestInfo | URL,
|
||||
init?: RequestInit,
|
||||
): Promise<Response> {
|
||||
const response = await fetch(input, init);
|
||||
if (response.status === 401) window.dispatchEvent(new Event("admin-auth-expired"));
|
||||
if (response.status === 401) {
|
||||
localStorage.removeItem("adminToken");
|
||||
window.dispatchEvent(new Event("admin-auth-expired"));
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
export function createApiClient(): ApiClient {
|
||||
return new ApiClient({ baseUrl: apiBaseUrl, fetcher: authenticatedFetch });
|
||||
const token = localStorage.getItem("adminToken");
|
||||
return new ApiClient({
|
||||
baseUrl: apiBaseUrl,
|
||||
...(token ? { token } : {}),
|
||||
fetcher: authenticatedFetch,
|
||||
});
|
||||
}
|
||||
@@ -156,44 +156,6 @@ body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.admin-full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.admin-choice-card.ant-radio-button-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 104px;
|
||||
padding: 16px;
|
||||
white-space: normal;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.admin-choice-card--wide.ant-radio-button-wrapper {
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.admin-choice-card.ant-radio-button-wrapper > span:last-child {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.admin-choice-card .ant-radio-button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.admin-choice-card span {
|
||||
color: var(--admin-text-secondary);
|
||||
}
|
||||
|
||||
.admin-choice-card strong {
|
||||
color: var(--admin-text);
|
||||
}
|
||||
|
||||
.admin-content {
|
||||
flex: 1;
|
||||
padding: 24px;
|
||||
|
||||