feat: 完善编辑工作台保存与离开体验
This commit is contained in:
1 parent
860d9266fe
commit
fa6b492bce
7 files changed
+168
-15
No files matched your search
@@ -22,9 +22,12 @@ import { ImageUrlField } from "../../components/ImageUrlField.js";
|
||||
import { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
import { PresentationEditor } from "./PresentationEditor.js";
|
||||
import "./BrandPage.css";
|
||||
import { useEditorDraft } from "./use-editor-draft.js";
|
||||
|
||||
export function BrandPage() {
|
||||
const [panel, setPanel] = useState("pages");
|
||||
const [dirty, setDirty] = useState(false);
|
||||
useEditorDraft(dirty);
|
||||
const client = createApiClient();
|
||||
const queryClient = useQueryClient();
|
||||
const [form] = Form.useForm<BrandProfile>();
|
||||
@@ -45,8 +48,10 @@ export function BrandPage() {
|
||||
const save = useMutation({
|
||||
mutationFn: (values: Partial<BrandProfile>) => client.updateAdminBrand(values),
|
||||
onSuccess: () => {
|
||||
setDirty(false);
|
||||
message.success("品牌表达已保存");
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-brand"] });
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-preview-workspace"] });
|
||||
},
|
||||
});
|
||||
return (
|
||||
@@ -73,7 +78,9 @@ export function BrandPage() {
|
||||
]}
|
||||
/>
|
||||
<Space>
|
||||
<Tag>草稿工作区</Tag>
|
||||
<Tag color={dirty ? "orange" : "default"}>
|
||||
{dirty ? "品牌资料有未保存修改" : "草稿工作区"}
|
||||
</Tag>
|
||||
<Link to="/admin/publication">检查与发布 →</Link>
|
||||
</Space>
|
||||
</div>
|
||||
@@ -83,6 +90,7 @@ export function BrandPage() {
|
||||
form={form}
|
||||
layout="vertical"
|
||||
initialValues={brand.data}
|
||||
onValuesChange={() => setDirty(true)}
|
||||
onFinish={(values) => save.mutate(values)}
|
||||
>
|
||||
<section className="brand-settings-section" aria-labelledby="brand-identity-title">
|
||||
|
||||
Reference in new issue
Block a user