Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06619a191f | ||
|
|
3a0099e674 |
No files matched your search
@@ -33,7 +33,7 @@ import {
|
||||
} from "./routes.js";
|
||||
import { LoadingStack } from "../components/LoadingStack.js";
|
||||
import { AdminMenu } from "../components/AdminMenu.js";
|
||||
import { adminMessage as message } from "../components/AdminMessage.js";
|
||||
import { App } from "antd";
|
||||
import { AdminButton } from "../components/AdminButton.js";
|
||||
import { AdminSelect } from "../components/AdminSelect.js";
|
||||
import { AdminLayout } from "../components/AdminLayout.js";
|
||||
@@ -51,6 +51,7 @@ export function Dashboard({
|
||||
role: string;
|
||||
platformTemplateRole: "none" | "template_admin";
|
||||
}) {
|
||||
const { message } = App.useApp();
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const brand = useQuery({
|
||||
|
||||
@@ -3,13 +3,14 @@ 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 { App } from "antd";
|
||||
import { createApiClient } from "../lib/api.js";
|
||||
import { LoadingStack } from "../components/LoadingStack.js";
|
||||
|
||||
type SessionState = Omit<AdminSession, "authenticated">;
|
||||
|
||||
export function Root() {
|
||||
const { message } = App.useApp();
|
||||
const [session, setSession] = useState<SessionState | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export { message as adminMessage } from "antd";
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CloudUploadOutlined, DeleteOutlined, PictureOutlined } from "@ant-design/icons";
|
||||
import { Alert, Button, Image, Popconfirm, Spin, Upload, message } from "antd";
|
||||
import { Alert, App, Button, Image, Popconfirm, Spin, Upload } from "antd";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { apiBaseUrl, authenticatedFetch, createApiClient } from "../lib/api.js";
|
||||
|
||||
@@ -12,6 +12,7 @@ interface ImageUrlFieldProps {
|
||||
}
|
||||
|
||||
export function ImageUrlField({ id, value, onChange, placeholder, scope }: ImageUrlFieldProps) {
|
||||
const { message } = App.useApp();
|
||||
const imageUrl = typeof value === "string" ? value.trim() : "";
|
||||
const [uploading, setUploading] = useState(false);
|
||||
const [storageStatus, setStorageStatus] = useState<
|
||||
@@ -74,7 +75,7 @@ export function ImageUrlField({ id, value, onChange, placeholder, scope }: Image
|
||||
<Alert
|
||||
type={storageStatus === "loading" ? "info" : "warning"}
|
||||
showIcon
|
||||
message={
|
||||
title={
|
||||
storageStatus === "loading"
|
||||
? "正在检查媒体存储..."
|
||||
: storageStatus === "unconfigured"
|
||||
|
||||
@@ -76,7 +76,7 @@ export function RecordContentEditor({
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message={
|
||||
title={
|
||||
source === "offering"
|
||||
? `正在编辑业务提供项:${recordName}`
|
||||
: `正在编辑信任内容:${recordName}`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Form, message } from "antd";
|
||||
import { App, Form } from "antd";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import type { TemplateAdminSection } from "@personal-brand/api-client";
|
||||
@@ -59,6 +59,7 @@ export function useRecordContentEditorState({
|
||||
onDraft?: ((values: PresentationValues) => void) | undefined;
|
||||
onSaved?: (() => void) | undefined;
|
||||
}) {
|
||||
const { message } = App.useApp();
|
||||
const [form] = Form.useForm<PresentationValues>();
|
||||
const queryClient = useQueryClient();
|
||||
const [draftValues, setDraftValues] = useState<PresentationValues>(() =>
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { useState } from "react";
|
||||
import { App } from "antd";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { BrandMark } from "../../components/BrandMark.js";
|
||||
import { adminMessage as message } from "../../components/AdminMessage.js";
|
||||
import { AdminButton } from "../../components/AdminButton.js";
|
||||
import { AdminCard } from "../../components/AdminCard.js";
|
||||
import { AdminForm, AdminInput } from "../../components/AdminForm.js";
|
||||
import type { AdminLoginSession } from "@personal-brand/api-client";
|
||||
|
||||
export function Login({ onLogin }: { onLogin: (session: AdminLoginSession) => void }) {
|
||||
const { message } = App.useApp();
|
||||
const [form] = AdminForm.useForm();
|
||||
const [loading, setLoading] = useState(false);
|
||||
async function submit(values: { username: string; password: string }) {
|
||||
@@ -52,6 +53,7 @@ export function Login({ onLogin }: { onLogin: (session: AdminLoginSession) => vo
|
||||
}
|
||||
|
||||
export function ChangePassword({ onComplete }: { onComplete: () => void }) {
|
||||
const { message } = App.useApp();
|
||||
const [form] = AdminForm.useForm<{
|
||||
currentPassword: string;
|
||||
newPassword: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Alert, Button, Col, Form, Input, Row, Segmented, message } from "antd";
|
||||
import { Alert, App, Button, Col, Form, Input, Row, Segmented } from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useState } from "react";
|
||||
import { Link, useLocation } from "react-router-dom";
|
||||
@@ -14,6 +14,7 @@ import "./BrandPage.css";
|
||||
import { useEditorDraft } from "./use-editor-draft.js";
|
||||
|
||||
export function BrandPage() {
|
||||
const { message } = App.useApp();
|
||||
const location = useLocation();
|
||||
const initialSelection = location.state as PreviewSelection | undefined;
|
||||
const [panel, setPanel] = useState("pages");
|
||||
@@ -219,7 +220,7 @@ export function BrandPage() {
|
||||
className="brand-page__template-note"
|
||||
type="info"
|
||||
showIcon
|
||||
message={`当前页面方案:${workspace.data?.templateContent?.displayName ?? template.data.name}`}
|
||||
title={`当前页面方案:${workspace.data?.templateContent?.displayName ?? template.data.name}`}
|
||||
description={`适用场景:${template.data.serviceCategories.join("、") || "通用品牌展示"}`}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
@@ -205,7 +205,7 @@ export function ComponentTemplatePreview({
|
||||
return () => window.removeEventListener("keydown", clear);
|
||||
}, [onTargetSelected]);
|
||||
if (!Renderer)
|
||||
return <Alert type="warning" showIcon message="此模板尚无组件预览,请使用页面预览" />;
|
||||
return <Alert type="warning" showIcon title="此模板尚无组件预览,请使用页面预览" />;
|
||||
return (
|
||||
<div className="component-template-preview-shell">
|
||||
<div
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Alert, Button, Form, Input, Select, Space, Switch, message } from "antd";
|
||||
import { Alert, App, Button, Form, Input, Select, Space, Switch } from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useEffect } from "react";
|
||||
import type { RuntimeWorkspace } from "@personal-brand/api-client";
|
||||
@@ -18,6 +18,7 @@ export function InquiryPreviewEditor({
|
||||
onDraft: (fields: RuntimeInquiryForm["fields"]) => void;
|
||||
onSaved?: () => void;
|
||||
}) {
|
||||
const { message } = App.useApp();
|
||||
const [form] = Form.useForm<Record<string, unknown>>();
|
||||
const cache = useQueryClient();
|
||||
const query = useQuery({
|
||||
@@ -59,7 +60,7 @@ export function InquiryPreviewEditor({
|
||||
return (
|
||||
<Alert
|
||||
type="error"
|
||||
message="表单读取失败"
|
||||
title="表单读取失败"
|
||||
action={<Button onClick={() => void query.refetch()}>重试</Button>}
|
||||
/>
|
||||
);
|
||||
@@ -67,10 +68,10 @@ export function InquiryPreviewEditor({
|
||||
return (
|
||||
<Alert
|
||||
type="info"
|
||||
message={query.isPending ? "正在读取表单" : "未找到对应表单,请刷新后重试"}
|
||||
title={query.isPending ? "正在读取表单" : "未找到对应表单,请刷新后重试"}
|
||||
/>
|
||||
);
|
||||
if (!field) return <Alert type="warning" message="字段已不存在" />;
|
||||
if (!field) return <Alert type="warning" title="字段已不存在" />;
|
||||
return (
|
||||
<Form<Record<string, unknown>>
|
||||
form={form}
|
||||
|
||||
@@ -311,12 +311,12 @@ export function PresentationEditor({
|
||||
</div>
|
||||
{templateContent ? <StatusTag tone="info" label={templateContent.displayName} /> : null}
|
||||
</div>
|
||||
{loading ? <Alert type="info" showIcon message="正在读取当前页面方案的编辑项目" /> : null}
|
||||
{loading ? <Alert type="info" showIcon title="正在读取当前页面方案的编辑项目" /> : null}
|
||||
{error ? (
|
||||
<Alert type="warning" showIcon message="页面方案编辑项目读取失败,请刷新后重试。" />
|
||||
<Alert type="warning" showIcon title="页面方案编辑项目读取失败,请刷新后重试。" />
|
||||
) : null}
|
||||
{!loading && !error && !templateContent ? (
|
||||
<Alert type="warning" showIcon message="当前页面方案暂未提供可编辑的页面内容。" />
|
||||
<Alert type="warning" showIcon title="当前页面方案暂未提供可编辑的页面内容。" />
|
||||
) : null}
|
||||
{templateContent ? (
|
||||
<>
|
||||
@@ -454,7 +454,7 @@ export function PresentationEditor({
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="详情页由所选业务内容动态生成"
|
||||
title="详情页由所选业务内容动态生成"
|
||||
description="选择业务内容预览详情,记录内容在业务提供项中维护;公共标题和按钮文案可从左侧区域列表配置,对全部详情生效。"
|
||||
action={
|
||||
<Button
|
||||
@@ -480,7 +480,7 @@ export function PresentationEditor({
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="这是一个组合区域"
|
||||
title="这是一个组合区域"
|
||||
description={
|
||||
<Space wrap>
|
||||
{(selectedTarget.children ?? []).map((childKey) => {
|
||||
@@ -542,7 +542,7 @@ export function PresentationEditor({
|
||||
? "error"
|
||||
: "info"
|
||||
}
|
||||
message={
|
||||
title={
|
||||
(
|
||||
selectedRecordSource === "offering"
|
||||
? offeringsQuery.isError
|
||||
@@ -583,7 +583,7 @@ export function PresentationEditor({
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="此区域尚未配置内容"
|
||||
title="此区域尚未配置内容"
|
||||
description="创建并启用对应内容后,即可在预览中点选编辑。"
|
||||
action={
|
||||
<Button
|
||||
|
||||
@@ -89,7 +89,7 @@ export function PresentationFormPanel({
|
||||
type="info"
|
||||
showIcon
|
||||
className="admin-offset-bottom-lg"
|
||||
message="这个页面还有关联内容"
|
||||
title="这个页面还有关联内容"
|
||||
description={
|
||||
<Space wrap>
|
||||
{relevantPageLinks.map((item) => (
|
||||
|
||||
@@ -124,7 +124,7 @@ export function TemplatePreview({
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="页面预览暂不可用"
|
||||
title="页面预览暂不可用"
|
||||
description="请确认模板预览资源已构建并发布,或本地预览服务正在运行。"
|
||||
/>
|
||||
);
|
||||
@@ -150,7 +150,7 @@ export function TemplatePreview({
|
||||
</div>
|
||||
) : null}
|
||||
{error ? (
|
||||
<Alert type="error" showIcon message="页面预览加载失败" description={error} />
|
||||
<Alert type="error" showIcon title="页面预览加载失败" description={error} />
|
||||
) : null}
|
||||
<iframe
|
||||
key={url}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Form, message } from "antd";
|
||||
import { App, Form } from "antd";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import type { QueryClient } from "@tanstack/react-query";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
@@ -108,6 +108,7 @@ export function useBrandSaveMutation({
|
||||
queryClient,
|
||||
onSaved,
|
||||
}: BrandSaveMutationOptions) {
|
||||
const { message } = App.useApp();
|
||||
return useMutation({
|
||||
mutationFn: (values: PresentationValues) => {
|
||||
const nextConfig = applyPresentationValues(config, sections, values);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { useEffect } from "react";
|
||||
import { Modal } from "antd";
|
||||
import { App } from "antd";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
export function useEditorDraft(dirty: boolean) {
|
||||
const { modal } = App.useApp();
|
||||
const navigate = useNavigate();
|
||||
useEffect(() => {
|
||||
if (!dirty) return;
|
||||
@@ -22,7 +23,7 @@ export function useEditorDraft(dirty: boolean) {
|
||||
return;
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
Modal.confirm({
|
||||
modal.confirm({
|
||||
title: "有尚未保存的修改",
|
||||
content: "离开工作台会丢失未保存内容。请先保存,或确认放弃修改。",
|
||||
okText: "放弃修改并继续",
|
||||
@@ -40,7 +41,7 @@ export function useEditorDraft(dirty: boolean) {
|
||||
}, [dirty, navigate]);
|
||||
return (action: () => void) => {
|
||||
if (!dirty) return action();
|
||||
Modal.confirm({
|
||||
modal.confirm({
|
||||
title: "有尚未保存的修改",
|
||||
content: "切换后当前内容可能丢失。请先保存,或确认放弃修改。",
|
||||
okText: "放弃修改并继续",
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { Alert, Button, Card, Col, Row, Space } from "antd";
|
||||
import { Alert, App, Button, Card, Col, Row, Space } from "antd";
|
||||
import { PlusOutlined } from "@ant-design/icons";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { 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";
|
||||
@@ -12,6 +11,7 @@ import { StatusTag } from "../../components/StatusTag.js";
|
||||
const client = createApiClient();
|
||||
|
||||
export function BrandsPage({ canCreate }: { canCreate: boolean }) {
|
||||
const { message } = App.useApp();
|
||||
const navigate = useNavigate();
|
||||
const brands = useQuery({
|
||||
queryKey: ["admin-brand-memberships"],
|
||||
@@ -58,7 +58,7 @@ export function BrandsPage({ canCreate }: { canCreate: boolean }) {
|
||||
className="admin-offset-bottom"
|
||||
type="info"
|
||||
showIcon
|
||||
message="切换品牌会进入对应品牌的工作区"
|
||||
title="切换品牌会进入对应品牌的工作区"
|
||||
description="品牌之间的业务内容、成员、发布记录和页面方案相互隔离。"
|
||||
/>
|
||||
{brands.data?.length ? (
|
||||
@@ -88,7 +88,7 @@ export function BrandsPage({ canCreate }: { canCreate: boolean }) {
|
||||
</Button>,
|
||||
]}
|
||||
>
|
||||
<Space direction="vertical" size={8}>
|
||||
<Space orientation="vertical" size={8}>
|
||||
<span className="admin-section-description">
|
||||
小程序地址标识:{membership.brand.slug}
|
||||
</span>
|
||||
|
||||
@@ -122,12 +122,12 @@ export function CreateBrandPage() {
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="当前业务类型还没有可用的页面方案"
|
||||
title="当前业务类型还没有可用的页面方案"
|
||||
description="请先联系平台管理员发布兼容的页面方案。"
|
||||
/>
|
||||
)
|
||||
) : (
|
||||
<Alert type="info" showIcon message="选择业务类型后,将只显示兼容的页面方案" />
|
||||
<Alert type="info" showIcon title="选择业务类型后,将只显示兼容的页面方案" />
|
||||
)}
|
||||
</AdminSection>
|
||||
|
||||
@@ -141,7 +141,7 @@ export function CreateBrandPage() {
|
||||
rules={[{ required: true, message: "请选择页面方案" }]}
|
||||
>
|
||||
<Radio.Group className="admin-stack">
|
||||
<Space direction="vertical" size={12} className="admin-full-width">
|
||||
<Space orientation="vertical" size={12} className="admin-full-width">
|
||||
{schemes.map((scheme) => (
|
||||
<Radio.Button
|
||||
key={scheme.templatePackageVersionId}
|
||||
@@ -180,7 +180,7 @@ export function CreateBrandPage() {
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="创建品牌不会自动导入示例内容"
|
||||
title="创建品牌不会自动导入示例内容"
|
||||
description="新品牌会从空白内容开始,避免把示例品牌、案例或联系方式误当成真实信息发布。"
|
||||
/>
|
||||
<MutationError error={create.error} />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { message } from "antd";
|
||||
import { App } from "antd";
|
||||
import { createApiClient } from "../../../lib/api.js";
|
||||
import { readAdminCapability } from "../types.js";
|
||||
import type { CapabilityValues } from "../types.js";
|
||||
@@ -17,6 +17,7 @@ export function useCapabilityQuery() {
|
||||
}
|
||||
|
||||
export function useCapabilityMutation() {
|
||||
const { message } = App.useApp();
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({ key, ...values }: { key: string } & CapabilityValues) =>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Badge, Button, Descriptions, Drawer, Select, Space, Table, message, Input } from "antd";
|
||||
import { App, Badge, Button, Descriptions, Drawer, Select, Space, Table, Input } from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import type { AdminBooking, InquirySubmission } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
@@ -51,6 +51,7 @@ const statusTones: Record<string, StatusTone> = {
|
||||
};
|
||||
|
||||
export function InquiriesPage() {
|
||||
const { message } = App.useApp();
|
||||
const client = createApiClient();
|
||||
const queryClient = useQueryClient();
|
||||
const [status, setStatus] = useState<string>();
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Alert, Button, Card, Collapse, Descriptions, Empty, List, Modal, Space, Tag } from "antd";
|
||||
import { Alert, App, Button, Card, Collapse, Descriptions, Empty, List, Space, Tag } from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { 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";
|
||||
@@ -11,6 +10,7 @@ import { StatusTag } from "../../components/StatusTag.js";
|
||||
const client = createApiClient();
|
||||
|
||||
export function PageSchemePage() {
|
||||
const { message, modal } = App.useApp();
|
||||
const queryClient = useQueryClient();
|
||||
const [selectedVersionId, setSelectedVersionId] = useState<string>();
|
||||
const [samplePreview, setSamplePreview] = useState<Awaited<
|
||||
@@ -135,7 +135,7 @@ export function PageSchemePage() {
|
||||
const target = compatibleSchemes.find(
|
||||
(scheme) => scheme.templatePackageVersionId === templatePackageVersionId,
|
||||
);
|
||||
Modal.confirm({
|
||||
modal.confirm({
|
||||
title: "切换页面方案版本",
|
||||
content: target
|
||||
? `将当前品牌切换到「${target.name}」版本 ${target.version}。现有品牌内容会保留。`
|
||||
@@ -147,7 +147,7 @@ export function PageSchemePage() {
|
||||
};
|
||||
const confirmUpgrade = () => {
|
||||
const preview = upgradePreview.data;
|
||||
Modal.confirm({
|
||||
modal.confirm({
|
||||
title: "升级页面方案",
|
||||
content:
|
||||
preview && preview.conflicts.length
|
||||
@@ -159,7 +159,7 @@ export function PageSchemePage() {
|
||||
});
|
||||
};
|
||||
const confirmRollback = () => {
|
||||
Modal.confirm({
|
||||
modal.confirm({
|
||||
title: "恢复上一版配置基线",
|
||||
content: "此操作只恢复上一版页面方案配置,不会删除品牌内容、业务提供项或咨询记录。",
|
||||
okText: "确认恢复",
|
||||
@@ -212,7 +212,7 @@ export function PageSchemePage() {
|
||||
>
|
||||
<Card>
|
||||
{upgradePreview.data?.canUpgrade ? (
|
||||
<Space direction="vertical" size={12} className="admin-full-width">
|
||||
<Space orientation="vertical" size={12} className="admin-full-width">
|
||||
<div className="admin-row-line">
|
||||
<strong>可升级到版本 {upgradePreview.data.latestVersion}</strong>
|
||||
<Tag color="blue">建议先预览</Tag>
|
||||
@@ -235,11 +235,11 @@ export function PageSchemePage() {
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message={`发现 ${upgradePreview.data.conflicts.length} 项自定义内容与新版布局存在差异`}
|
||||
title={`发现 ${upgradePreview.data.conflicts.length} 项自定义内容与新版布局存在差异`}
|
||||
description="升级时会全部保留现有内容,不会逐项覆盖。请确认后再执行升级。"
|
||||
/>
|
||||
) : (
|
||||
<Alert type="success" showIcon message="未发现内容绑定冲突" />
|
||||
<Alert type="success" showIcon title="未发现内容绑定冲突" />
|
||||
)}
|
||||
<Button type="primary" onClick={confirmUpgrade} loading={upgrade.isPending}>
|
||||
升级到 {upgradePreview.data.latestVersion}
|
||||
@@ -318,11 +318,11 @@ export function PageSchemePage() {
|
||||
key: "sample-content",
|
||||
label: "高级:导入示例内容",
|
||||
children: (
|
||||
<Space direction="vertical" size={12} className="admin-full-width">
|
||||
<Space orientation="vertical" size={12} className="admin-full-width">
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="此操作会写入当前品牌内容"
|
||||
title="此操作会写入当前品牌内容"
|
||||
description="仅导入当前缺失的内容,不会覆盖已有品牌资料。创建品牌时不会自动执行。"
|
||||
/>
|
||||
<Space>
|
||||
|
||||
@@ -125,7 +125,7 @@ export function MiniAppReleaseCard({
|
||||
return (
|
||||
<Card size="small" styles={{ body: { padding: 16 } }}>
|
||||
<Flex justify="space-between" align="flex-start" gap={12} wrap>
|
||||
<Space direction="vertical" size={4}>
|
||||
<Space orientation="vertical" size={4}>
|
||||
<Space wrap size={8} align="center">
|
||||
<Typography.Text strong>品牌内容 v{task.version}</Typography.Text>
|
||||
<StatusTag label={status.label} tone={status.tone} />
|
||||
|
||||
@@ -37,7 +37,7 @@ export function MiniAppSettingsTab({
|
||||
type="warning"
|
||||
showIcon
|
||||
className="admin-offset-bottom"
|
||||
message="小程序构建参数未就绪"
|
||||
title="小程序构建参数未就绪"
|
||||
description={settings.buildError}
|
||||
/>
|
||||
) : (
|
||||
@@ -45,7 +45,7 @@ export function MiniAppSettingsTab({
|
||||
type="info"
|
||||
showIcon
|
||||
className="admin-offset-bottom"
|
||||
message={`请求域名 ${settings?.requestDomain ?? "未确认"}`}
|
||||
title={`请求域名 ${settings?.requestDomain ?? "未确认"}`}
|
||||
description="该域名在构建时写入小程序包,必须与微信后台“开发设置 → 服务器域名 → request 合法域名”一致;不一致会导致小程序打开即加载失败。"
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -277,7 +277,7 @@ export function PublicationPage() {
|
||||
{confirmAction === "revoke" ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
message="撤回后,小程序将显示品牌尚未发布,新的咨询和预约会停止受理。"
|
||||
title="撤回后,小程序将显示品牌尚未发布,新的咨询和预约会停止受理。"
|
||||
/>
|
||||
) : (
|
||||
<div className="admin-stack">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { message } from "antd";
|
||||
import { App } from "antd";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
|
||||
const client = createApiClient();
|
||||
@@ -17,6 +17,7 @@ export function usePublicationMutations({
|
||||
onNoteClear,
|
||||
onRollbackClose,
|
||||
}: MutationOptions) {
|
||||
const { message } = App.useApp();
|
||||
const queryClient = useQueryClient();
|
||||
const publish = useMutation({
|
||||
mutationFn: (note: string) => client.publishAdminRelease(note || undefined),
|
||||
|
||||
@@ -75,7 +75,7 @@ export function OfferingEditorModal({
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message={previewPage === "offerings" ? "正在核对列表展示" : "正在核对详情展示"}
|
||||
title={previewPage === "offerings" ? "正在核对列表展示" : "正在核对详情展示"}
|
||||
description={
|
||||
previewPage === "offerings"
|
||||
? "右侧「列表展示」字段修改后,会实时反映在当前卡片。"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import type { Offering } from "@personal-brand/api-client";
|
||||
import { message } from "antd";
|
||||
import { App } from "antd";
|
||||
import { useMemo } from "react";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import {
|
||||
@@ -46,6 +46,7 @@ export function useOfferingMutations(options: {
|
||||
templateFields: ReturnType<typeof offeringTemplateFields>;
|
||||
onSuccess: () => void;
|
||||
}) {
|
||||
const { message } = App.useApp();
|
||||
const client = createApiClient();
|
||||
const queryClient = useQueryClient();
|
||||
const invalidateAfterSave = () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Alert, Button, Card, Form, Input, Modal, Select, Space, Table, message } from "antd";
|
||||
import { Alert, App, Button, Card, Form, Input, Modal, Select, Space, Table } from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import type { AdminBrandMember } from "@personal-brand/api-client";
|
||||
import { useState } from "react";
|
||||
@@ -16,6 +16,7 @@ const roleLabels: Record<string, string> = {
|
||||
};
|
||||
|
||||
export function MembersPage() {
|
||||
const { message } = App.useApp();
|
||||
const client = createApiClient();
|
||||
const queryClient = useQueryClient();
|
||||
const [addOpen, setAddOpen] = useState(false);
|
||||
@@ -71,7 +72,7 @@ export function MembersPage() {
|
||||
type="info"
|
||||
showIcon
|
||||
className="admin-offset-bottom"
|
||||
message="请将初始账号和密码安全地交给成员"
|
||||
title="请将初始账号和密码安全地交给成员"
|
||||
description="当前采用负责人手动添加方式;系统不会再次显示成员初始密码。"
|
||||
/>
|
||||
<Table
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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 { Alert, App, Button, List, Modal, Table, Tag, Typography } from "antd";
|
||||
import { EyeOutlined, ReloadOutlined, UploadOutlined } from "@ant-design/icons";
|
||||
import type { TemplatePackageVersion } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
@@ -31,6 +31,7 @@ function formatBytes(value: unknown): string {
|
||||
}
|
||||
|
||||
export function TemplateManagementPage() {
|
||||
const { message } = App.useApp();
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
@@ -110,7 +111,7 @@ export function TemplateManagementPage() {
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="导入规则"
|
||||
title="导入规则"
|
||||
description="系统会校验文件路径、链接、文件数量、解压体积、template.json、package.json 和 checksums.json;包内脚本不会被执行。"
|
||||
/>
|
||||
{importing.isError ? <ErrorNote error={importing.error} /> : null}
|
||||
@@ -118,7 +119,7 @@ export function TemplateManagementPage() {
|
||||
<Alert
|
||||
type="success"
|
||||
showIcon
|
||||
message={importing.data.idempotent ? "模板版本已存在,未重复写入" : "模板版本导入成功"}
|
||||
title={importing.data.idempotent ? "模板版本已存在,未重复写入" : "模板版本导入成功"}
|
||||
description={`${importing.data.version.packageKey}@${importing.data.version.version}`}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
@@ -78,7 +78,7 @@ export function TemplatePackagePreviewModal({
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="模板演示预览"
|
||||
title="模板演示预览"
|
||||
description="演示内容不属于真实品牌,咨询提交和客户记录读取已禁用。"
|
||||
/>
|
||||
{!industry ? (
|
||||
@@ -92,12 +92,7 @@ export function TemplatePackagePreviewModal({
|
||||
{data ? (
|
||||
<>
|
||||
{data.preview.diagnostics.map((diagnostic) => (
|
||||
<Alert
|
||||
key={diagnostic.code}
|
||||
type="warning"
|
||||
showIcon
|
||||
message={diagnostic.message}
|
||||
/>
|
||||
<Alert key={diagnostic.code} type="warning" showIcon title={diagnostic.message} />
|
||||
))}
|
||||
<Typography.Text type="secondary">
|
||||
演示数据:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { message } from "antd";
|
||||
import { App } from "antd";
|
||||
import type { TrustContent, TrustContentInput } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../../lib/api.js";
|
||||
|
||||
@@ -10,6 +10,7 @@ export function useTrustContentMutations({
|
||||
editing: TrustContent | null;
|
||||
closeEditor: () => void;
|
||||
}) {
|
||||
const { message } = App.useApp();
|
||||
const client = createApiClient();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { message } from "antd";
|
||||
import { App } from "antd";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import type { FormInstance } from "antd";
|
||||
import type { BrandFieldDefinition, InquiryForm } from "@personal-brand/api-client";
|
||||
@@ -19,6 +19,7 @@ export function useFieldMutations({
|
||||
queryClient,
|
||||
onClose,
|
||||
}: FieldMutationOptions) {
|
||||
const { message } = App.useApp();
|
||||
const createField = useMutation({
|
||||
mutationFn: (values: Omit<BrandFieldDefinition, "id" | "source">) =>
|
||||
client.createAdminField(values),
|
||||
@@ -49,6 +50,7 @@ export function useInquiryFormMutations({
|
||||
};
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const { message } = App.useApp();
|
||||
const createForm = useMutation({
|
||||
mutationFn: (values: {
|
||||
name: string;
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readdir, readFile, access } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { test } from "node:test";
|
||||
|
||||
const sourceRoot = path.resolve(import.meta.dirname, "../src");
|
||||
|
||||
async function listSourceFiles(directory) {
|
||||
const entries = await readdir(directory, { withFileTypes: true });
|
||||
const files = await Promise.all(
|
||||
entries.map(async (entry) => {
|
||||
const absolute = path.join(directory, entry.name);
|
||||
if (entry.isDirectory()) return listSourceFiles(absolute);
|
||||
return /\.(?:ts|tsx)$/.test(entry.name) ? [absolute] : [];
|
||||
}),
|
||||
);
|
||||
return files.flat();
|
||||
}
|
||||
|
||||
function readTag(source, start) {
|
||||
let index = start;
|
||||
let quote = null;
|
||||
while (index < source.length) {
|
||||
const char = source[index];
|
||||
if (quote) {
|
||||
if (char === quote) quote = null;
|
||||
} else if (char === '"' || char === "'" || char === "`") {
|
||||
quote = char;
|
||||
} else if (char === ">") {
|
||||
return source.slice(start, index + 1);
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
return source.slice(start);
|
||||
}
|
||||
|
||||
function tagsNamed(source, name) {
|
||||
const tags = [];
|
||||
for (const match of source.matchAll(new RegExp("<" + name + "\\b", "g"))) {
|
||||
tags.push(readTag(source, match.index));
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
test("Admin 源码不使用 Ant Design 6 已弃用的静态提示 API", async () => {
|
||||
const files = await listSourceFiles(sourceRoot);
|
||||
const violations = [];
|
||||
for (const file of files) {
|
||||
const source = await readFile(file, "utf8");
|
||||
const relative = path.relative(sourceRoot, file);
|
||||
if (/import\s*\{[^}]*\bmessage\b[^}]*\}\s*from\s*"antd"/.test(source)) {
|
||||
violations.push(`${relative}: 仍从 antd 导入静态 message`);
|
||||
}
|
||||
if (/\bModal\.confirm\s*\(/.test(source)) {
|
||||
violations.push(`${relative}: 仍调用静态 Modal.confirm`);
|
||||
}
|
||||
for (const tag of tagsNamed(source, "Alert")) {
|
||||
if (/(?<![\w.])message\s*=/.test(tag)) {
|
||||
violations.push(`${relative}: Alert 仍使用 message 属性`);
|
||||
}
|
||||
}
|
||||
for (const tag of tagsNamed(source, "Space")) {
|
||||
if (/(?<![\w.])direction\s*=/.test(tag)) {
|
||||
violations.push(`${relative}: Space 仍使用 direction 属性`);
|
||||
}
|
||||
}
|
||||
}
|
||||
assert.deepEqual(violations, []);
|
||||
});
|
||||
|
||||
test("Admin 不再保留静态 message 转出口", async () => {
|
||||
const legacyBridge = path.resolve(sourceRoot, "components/AdminMessage.ts");
|
||||
await assert.rejects(access(legacyBridge));
|
||||
});
|
||||
@@ -0,0 +1,48 @@
|
||||
# 0034 Ant Design 6 弃用项收口
|
||||
|
||||
- 状态:已采纳
|
||||
- 日期:2026-10-21
|
||||
|
||||
## Context
|
||||
|
||||
Admin 升级到 Ant Design 6.6 后,开发态控制台持续出现弃用提示:
|
||||
|
||||
- `Alert.message` 已改名为 `title`。
|
||||
- `Space.direction` 已改名为 `orientation`。
|
||||
- 静态 `message.*` 与 `Modal.confirm` 无法读取 `ConfigProvider` 的动态主题上下文。
|
||||
- `List` 标记为 deprecated,官方建议 6.6+ 改用 `Listy`。
|
||||
|
||||
这些提示不影响功能,但会淹没真正有价值的新警告,也让后续升级到 Ant Design 7 时缺少明确清单。
|
||||
|
||||
## Decision
|
||||
|
||||
1. `Alert` 统一使用 `title`;正文仍用 `description`。
|
||||
2. `Space` 统一使用 `orientation`。
|
||||
3. 所有提示与确认框改为 `App.useApp()` 取得的实例:
|
||||
- 组件与自定义 hook 在函数体首部声明 `const { message } = App.useApp();`。
|
||||
- 确认框改为 `const { modal } = App.useApp();` 后调用 `modal.confirm`。
|
||||
- 删除 `components/AdminMessage.ts` 这一静态转出口,避免再次绕过上下文。
|
||||
4. 暂不迁移 `List` → `Listy`:
|
||||
- `Listy` 是虚拟滚动列表,API 与 `List` 不兼容(需要 `itemHeight`、`renderItem` 等)。
|
||||
- 当前 `List` 仅用于审计日志、失败计数和模板模块清单等小数据量场景,最大条数受分页或模板规模限制。
|
||||
- 用 `Listy` 替换属于渲染行为变更,需要单独的可视回归,不应混在机械迁移里。
|
||||
|
||||
## Alternatives
|
||||
|
||||
- 保留静态 `message` / `Modal.confirm`:提示不继承动态主题,且 Ant Design 7 会移除,拒绝。
|
||||
- 用自建单例桥接 `App` 上下文:等于重新发明静态 API,并引入第二种提示模式,拒绝。
|
||||
- 本轮直接把 `List` 换成 `Listy`:改动面大、收益低,且缺少分页与固定高度语义,推迟。
|
||||
|
||||
## Consequences
|
||||
|
||||
- Admin 源码不再出现 `Alert.message`、`Space.direction`、静态 `message` 和 `Modal.confirm`。
|
||||
- 提示与确认框跟随 `ConfigProvider` 主题与国际化。
|
||||
- `List` 的弃用提示仍会出现在开发态控制台,作为已知技术债登记。
|
||||
- 触发迁移 `List` → `Listy` 的条件:Ant Design 7 升级,或某个 `List` 数据源增长到需要虚拟滚动的规模。
|
||||
|
||||
## Migration plan
|
||||
|
||||
1. 机械迁移 `Alert` 与 `Space` 属性,跑 `typecheck`、`lint`、`test`、`build`。
|
||||
2. 把静态提示 API 改为 `App.useApp()`,删除静态转出口。
|
||||
3. 用 Admin 浏览器回归验证创建品牌、页面方案和会话过期提示流程。
|
||||
4. 升级 Ant Design 7 前重新评估 `List` 的使用点。
|
||||
Reference in new issue
Block a user