feat: 在后台预览运行时工作空间

This commit is contained in:
que01 committed 2026-09-22 17:49:03 +08:00
1 parent 7dc72b4a48
commit cdce8227bc
2 files changed
+33 -1

No files matched your search

@@ -14,7 +14,11 @@ import {
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { createApiClient } from "../../lib/api.js";
import { ApiClientError } from "@personal-brand/api-client";
import type { BrandFieldDefinition, BrandModule } from "@personal-brand/api-client";
import type {
BrandFieldDefinition,
BrandModule,
PublicWorkspace,
} from "@personal-brand/api-client";
import { useState } from "react";
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { MutationError } from "../../components/QueryState.js";
@@ -30,6 +34,10 @@ export function WorkspacePage() {
queryKey: ["admin-workspace"],
queryFn: () => client.getAdminWorkspace(),
});
const runtimeQuery = useQuery({
queryKey: ["public-runtime-workspace"],
queryFn: () => client.getPublicWorkspace(),
});
const install = useMutation({
mutationFn: (key: "personal" | "food") => client.installAdminTemplate(key),
onSuccess: () => {
@@ -129,6 +137,29 @@ export function WorkspacePage() {
title="模板与设置"
description="用行业模板组织业务表达,同时保留个人品牌定位、信任内容和合作方式的长期扩展空间。"
/>
<Card title="运行时工作空间" loading={runtimeQuery.isLoading}>
{runtimeQuery.isError ? (
<Typography.Text type="danger">公开运行时工作空间暂时无法加载。</Typography.Text>
) : (
<Space direction="vertical" style={{ width: "100%" }}>
<Space wrap>
<Tag color="blue">Schema {runtimeQuery.data?.schemaVersion ?? "-"}</Tag>
<Tag>模块 {runtimeQuery.data?.runtimeModules?.length ?? 0}</Tag>
<Tag>能力 {runtimeQuery.data?.runtimeCapabilities?.length ?? 0}</Tag>
<Tag>
公开业务{" "}
{runtimeQuery.data?.runtimeOfferings?.length ??
runtimeQuery.data?.offerings?.length ??
0}
</Tag>
</Space>
<Typography.Paragraph type="secondary" style={{ marginBottom: 0 }}>
小程序和后台预览消费同一份 Runtime Workspace;模板 key
只用于安装和版本管理,不作为客户端业务分支。
</Typography.Paragraph>
</Space>
)}
</Card>
<Card
title="行业模板"
extra={
+1
View File
@@ -25,6 +25,7 @@
- [x] 集成测试覆盖运行时 schemaVersion、导航、模块、Offering、表单、能力和主题。
- [ ] 增加 API 授权、品牌隔离和 schema 版本测试。
- [ ] 让 Admin 工作空间预览读取同一运行时契约。
- [x] Admin 工作空间预览展示 Runtime Workspace 的 schema、模块、能力和公开业务统计。
- [x] 小程序首页和案例列表优先消费 `/public/workspace`,保留静态降级基线。
### 后续阶段