refactor: 提示与确认框改用 App 上下文实例
CI / Static checks (push) Has been cancelled
CI / Production build (push) Has been cancelled
CI / API integration (push) Has been cancelled
CI / Taro builds (acheng-campus-food) (push) Has been cancelled
CI / Taro builds (atelier-solopreneur) (push) Has been cancelled
CI / Taro builds (linjing-editorial) (push) Has been cancelled
CI / Browser regression (push) Has been cancelled
CI / Static checks (push) Has been cancelled
CI / Production build (push) Has been cancelled
CI / API integration (push) Has been cancelled
CI / Taro builds (acheng-campus-food) (push) Has been cancelled
CI / Taro builds (atelier-solopreneur) (push) Has been cancelled
CI / Taro builds (linjing-editorial) (push) Has been cancelled
CI / Browser regression (push) Has been cancelled
This commit is contained in:
1 parent
3a0099e674
commit
06619a191f
22 files changed
+167
-27
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<
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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"],
|
||||
|
||||
@@ -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: "确认恢复",
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user