feat: 收口多品牌与模板构建基础
This commit is contained in:
1 parent
0425a1c672
commit
77224ea51f
317 files changed
+11290
-1158
No files matched your search
@@ -8,6 +8,7 @@ import type {
|
||||
} from "@personal-brand/types";
|
||||
export type { PublicOffering } from "@personal-brand/types";
|
||||
export type { BookingStatus } from "@personal-brand/types";
|
||||
export type { BrandTemplateKey } from "@personal-brand/types";
|
||||
|
||||
export interface BrandProfile {
|
||||
id: string;
|
||||
@@ -30,7 +31,34 @@ export interface AdminBrandMembership {
|
||||
role: string;
|
||||
brand: Pick<BrandProfile, "id" | "name" | "templateKey"> & { slug?: string };
|
||||
}
|
||||
export interface AdminBrandMember {
|
||||
id: string;
|
||||
role: string;
|
||||
isEnabled: boolean;
|
||||
adminUser: {
|
||||
id: string;
|
||||
username: string;
|
||||
displayName: string;
|
||||
isEnabled: boolean;
|
||||
};
|
||||
}
|
||||
export type BrandUpdate = Partial<Omit<BrandProfile, "id">>;
|
||||
export interface BrandReleaseSummary {
|
||||
id: string;
|
||||
version: number;
|
||||
status: string;
|
||||
note: string | null;
|
||||
actorId: string;
|
||||
createdAt: string;
|
||||
revokedAt: string | null;
|
||||
revokedBy?: string | null;
|
||||
}
|
||||
export type BrandPresentationUpdate = Partial<
|
||||
Record<
|
||||
"identity" | "home" | "offerings" | "detail" | "profile" | "inquiry" | "success" | "records",
|
||||
Record<string, string>
|
||||
>
|
||||
>;
|
||||
export interface OfferingUpdate {
|
||||
name?: string;
|
||||
description?: string;
|
||||
@@ -227,6 +255,7 @@ export interface PublicWorkspace {
|
||||
key: string;
|
||||
version: string;
|
||||
name: string;
|
||||
supportedIndustryTemplates: BrandTemplateKey[];
|
||||
variants: Record<string, string>;
|
||||
} | null;
|
||||
visualTemplateManifest?: {
|
||||
@@ -278,6 +307,7 @@ export interface PublicWorkspace {
|
||||
inquiryForm: InquiryForm | null;
|
||||
runtimeOfferings?: Array<Record<string, unknown>>;
|
||||
inquiryForms?: Array<Record<string, unknown>>;
|
||||
trustPresentation?: Record<string, unknown>;
|
||||
runtimeCapabilities?: Array<{ key: string; version: string; status?: string }>;
|
||||
plugins?: Array<{
|
||||
key: string;
|
||||
@@ -392,9 +422,23 @@ export class ApiClient {
|
||||
cancelCustomerBooking(id: string): Promise<Booking> {
|
||||
return this.request(`/customer/bookings/${encodeURIComponent(id)}/cancel`, { method: "POST" });
|
||||
}
|
||||
loginAdmin(username: string, password: string): Promise<{ token: string; displayName: string }> {
|
||||
loginAdmin(
|
||||
username: string,
|
||||
password: string,
|
||||
): Promise<{
|
||||
token: string;
|
||||
displayName: string;
|
||||
mustChangePassword: boolean;
|
||||
role: string;
|
||||
}> {
|
||||
return this.request("/admin/session/login", { method: "POST", body: { username, password } });
|
||||
}
|
||||
changeAdminPassword(currentPassword: string, newPassword: string): Promise<{ changed: true }> {
|
||||
return this.request("/admin/session/change-password", {
|
||||
method: "POST",
|
||||
body: { currentPassword, newPassword },
|
||||
});
|
||||
}
|
||||
listAdminBookings(
|
||||
filters: { status?: BookingStatus; unreadOnly?: boolean; tagId?: string } = {},
|
||||
): Promise<AdminBooking[]> {
|
||||
@@ -441,6 +485,26 @@ export class ApiClient {
|
||||
): Promise<{ token: string; brand: AdminBrandMembership["brand"] }> {
|
||||
return this.request(`/admin/brands/${encodeURIComponent(brandId)}/switch`, { method: "POST" });
|
||||
}
|
||||
listAdminMembers(): Promise<AdminBrandMember[]> {
|
||||
return this.request("/admin/brands/members");
|
||||
}
|
||||
createAdminMember(body: {
|
||||
username: string;
|
||||
displayName: string;
|
||||
password: string;
|
||||
role: "owner" | "editor";
|
||||
}): Promise<AdminBrandMember> {
|
||||
return this.request("/admin/brands/members", { method: "POST", body });
|
||||
}
|
||||
updateAdminMember(
|
||||
id: string,
|
||||
body: Partial<Pick<AdminBrandMember, "role" | "isEnabled">>,
|
||||
): Promise<AdminBrandMember> {
|
||||
return this.request(`/admin/brands/members/${encodeURIComponent(id)}`, {
|
||||
method: "PATCH",
|
||||
body,
|
||||
});
|
||||
}
|
||||
getAdminVisualTemplatePreview(): Promise<{
|
||||
current: {
|
||||
key: string;
|
||||
@@ -464,6 +528,11 @@ export class ApiClient {
|
||||
updateAdminBrand(body: BrandUpdate): Promise<BrandProfile> {
|
||||
return this.request("/admin/config/brand", { method: "PATCH", body });
|
||||
}
|
||||
updateAdminBrandPresentation(body: BrandPresentationUpdate): Promise<{
|
||||
visualPresentation: Record<string, Record<string, string>>;
|
||||
}> {
|
||||
return this.request("/admin/config/presentation", { method: "PATCH", body });
|
||||
}
|
||||
getPublicTemplate(key: BrandTemplateKey): Promise<BrandTemplateDefinition> {
|
||||
return this.request(`/public/templates/${key}`);
|
||||
}
|
||||
@@ -474,11 +543,47 @@ export class ApiClient {
|
||||
version: string;
|
||||
name: string;
|
||||
description: string;
|
||||
supportedIndustryTemplates: BrandTemplateKey[];
|
||||
variants: Record<string, string>;
|
||||
theme: { colors: Record<string, string> };
|
||||
}>;
|
||||
}> {
|
||||
return this.request("/public/templates");
|
||||
return this.request<{
|
||||
industries: BrandTemplateDefinition[];
|
||||
visuals: Array<{
|
||||
key: string;
|
||||
version: string;
|
||||
name: string;
|
||||
description: string;
|
||||
supportedIndustryTemplates?: unknown;
|
||||
variants?: unknown;
|
||||
theme?: unknown;
|
||||
}>;
|
||||
}>("/public/templates").then((catalog) => ({
|
||||
industries: Array.isArray(catalog.industries) ? catalog.industries : [],
|
||||
visuals: Array.isArray(catalog.visuals)
|
||||
? catalog.visuals.map((visual) => ({
|
||||
key: String(visual.key ?? ""),
|
||||
version: String(visual.version ?? ""),
|
||||
name: String(visual.name ?? "未命名视觉模板"),
|
||||
description: String(visual.description ?? ""),
|
||||
supportedIndustryTemplates: Array.isArray(visual.supportedIndustryTemplates)
|
||||
? visual.supportedIndustryTemplates.filter(
|
||||
(item): item is BrandTemplateKey =>
|
||||
item === "personal" || item === "food" || item === "doors",
|
||||
)
|
||||
: [],
|
||||
variants:
|
||||
visual.variants && typeof visual.variants === "object"
|
||||
? (visual.variants as Record<string, string>)
|
||||
: {},
|
||||
theme:
|
||||
visual.theme && typeof visual.theme === "object"
|
||||
? (visual.theme as { colors: Record<string, string> })
|
||||
: { colors: {} },
|
||||
}))
|
||||
: [],
|
||||
}));
|
||||
}
|
||||
previewPublicTemplateCombination(
|
||||
industry: string,
|
||||
@@ -490,6 +595,7 @@ export class ApiClient {
|
||||
version: string;
|
||||
name: string;
|
||||
description: string;
|
||||
supportedIndustryTemplates: BrandTemplateKey[];
|
||||
variants: Record<string, string>;
|
||||
theme: { colors: Record<string, string> };
|
||||
};
|
||||
@@ -516,9 +622,10 @@ export class ApiClient {
|
||||
key: string;
|
||||
version: string;
|
||||
name: string;
|
||||
supportedIndustryTemplates: BrandTemplateKey[];
|
||||
variants: Record<string, string>;
|
||||
} | null;
|
||||
installations: unknown[];
|
||||
installations: Array<{ id: string; templateKey: BrandTemplateKey; templateVersion: string }>;
|
||||
modules: BrandModule[];
|
||||
fields: BrandFieldDefinition[];
|
||||
offerings: Offering[];
|
||||
@@ -526,6 +633,32 @@ export class ApiClient {
|
||||
}> {
|
||||
return this.request("/admin/workspace");
|
||||
}
|
||||
listAdminReleases(): Promise<BrandReleaseSummary[]> {
|
||||
return this.request("/admin/releases");
|
||||
}
|
||||
getAdminReleaseReadiness(): Promise<{
|
||||
ready: boolean;
|
||||
checks: Array<{ key: string; label: string; passed: boolean }>;
|
||||
}> {
|
||||
return this.request("/admin/releases/readiness");
|
||||
}
|
||||
publishAdminRelease(note?: string): Promise<BrandReleaseSummary> {
|
||||
return this.request("/admin/releases/publish", {
|
||||
method: "POST",
|
||||
body: note === undefined ? {} : { note },
|
||||
});
|
||||
}
|
||||
rollbackAdminRelease(version: number, note?: string): Promise<BrandReleaseSummary> {
|
||||
return this.request(`/admin/releases/${version}/rollback`, {
|
||||
method: "POST",
|
||||
body: note === undefined ? {} : { note },
|
||||
});
|
||||
}
|
||||
revokeAdminRelease(): Promise<
|
||||
Pick<BrandReleaseSummary, "id" | "version" | "status" | "revokedAt">
|
||||
> {
|
||||
return this.request("/admin/releases/revoke", { method: "POST" });
|
||||
}
|
||||
installAdminTemplate(templateKey: "personal" | "food" | "doors"): Promise<unknown> {
|
||||
return this.request("/admin/workspace/install", { method: "POST", body: { templateKey } });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user