Commit a18a7083 by liimin

fix(ui,web-system): 弹窗与抽屉的取消/关闭按钮一律普通按钮

- UModal 封装强制 cancelButtonProps type=default(v6 Modal 仍支持,防调用方默认样式漂移)
- antd v6 Drawer 已无内置 footer 按钮 API,约定落调用点:
  AccountFormDrawer / RoleFormDrawer / RoleDetailDrawer 的取消、关闭显式 type=default
  (UButton 默认 type=primary,不显式写就是主色,这是三处漏成主色的根因)
1 parent 3d5eab21
...@@ -157,7 +157,7 @@ export function AccountFormDrawer({ ...@@ -157,7 +157,7 @@ export function AccountFormDrawer({
onClose={onClose} onClose={onClose}
footer={ footer={
<div style={footerStyle}> <div style={footerStyle}>
<UButton onClick={onClose}>取消</UButton> <UButton type="default" onClick={onClose}>取消</UButton>
<UButton type="primary" loading={saveMutation.isPending} onClick={() => form.submit()}> <UButton type="primary" loading={saveMutation.isPending} onClick={() => form.submit()}>
保存 保存
</UButton> </UButton>
......
...@@ -36,7 +36,7 @@ export function RoleDetailDrawer({ open, roleId, onClose }: RoleDetailDrawerProp ...@@ -36,7 +36,7 @@ export function RoleDetailDrawer({ open, roleId, onClose }: RoleDetailDrawerProp
title={detail ? `角色详情 · ${detail.roleName}` : '角色详情'} title={detail ? `角色详情 · ${detail.roleName}` : '角色详情'}
onClose={onClose} onClose={onClose}
footer={ footer={
<UButton style={{ float: 'right' }} onClick={onClose}> <UButton type="default" style={{ float: 'right' }} onClick={onClose}>
关闭 关闭
</UButton> </UButton>
} }
......
...@@ -132,7 +132,7 @@ export function RoleFormDrawer({ open, roleItem, onClose, onSuccess }: RoleFormD ...@@ -132,7 +132,7 @@ export function RoleFormDrawer({ open, roleItem, onClose, onSuccess }: RoleFormD
onClose={onClose} onClose={onClose}
footer={ footer={
<div style={footerStyle}> <div style={footerStyle}>
<UButton onClick={onClose}>取消</UButton> <UButton type="default" onClick={onClose}>取消</UButton>
<UButton type="primary" loading={saveMutation.isPending} onClick={() => form.submit()}> <UButton type="primary" loading={saveMutation.isPending} onClick={() => form.submit()}>
保存 保存
</UButton> </UButton>
......
...@@ -2,7 +2,11 @@ import { Drawer, type DrawerProps } from 'antd'; ...@@ -2,7 +2,11 @@ import { Drawer, type DrawerProps } from 'antd';
export type UDrawerProps = DrawerProps; export type UDrawerProps = DrawerProps;
/** Unified detail drawer; responsive width and lifecycle defaults remain overridable. */ /**
* Unified detail drawer; responsive width and lifecycle defaults remain overridable.
* 约定:footer 里的取消/关闭按钮一律 type="default"(UButton 默认 primary,
* 不显式写就是主色)—— antd v6 的 Drawer 已无内置 footer 按钮,约定只能落在调用点。
*/
export function UDrawer({ size = 760, destroyOnHidden = true, styles, ...props }: UDrawerProps) { export function UDrawer({ size = 760, destroyOnHidden = true, styles, ...props }: UDrawerProps) {
return ( return (
<Drawer <Drawer
......
...@@ -2,6 +2,7 @@ import { Modal, type ModalProps } from 'antd'; ...@@ -2,6 +2,7 @@ import { Modal, type ModalProps } from 'antd';
/** /**
* 项目统一弹窗。约定默认居中、关闭时销毁内容、确认按钮为主色。 * 项目统一弹窗。约定默认居中、关闭时销毁内容、确认按钮为主色。
* 取消按钮一律普通按钮(default),不随调用方默认样式漂移;
* 若需 Modal.confirm 等静态方法,后续可在此封装 UModal.confirm 包装器。 * 若需 Modal.confirm 等静态方法,后续可在此封装 UModal.confirm 包装器。
*/ */
export function UModal(props: ModalProps) { export function UModal(props: ModalProps) {
...@@ -12,6 +13,7 @@ export function UModal(props: ModalProps) { ...@@ -12,6 +13,7 @@ export function UModal(props: ModalProps) {
maskClosable, maskClosable,
mask, mask,
okButtonProps, okButtonProps,
cancelButtonProps,
...rest ...rest
} = props; } = props;
return ( return (
...@@ -20,6 +22,7 @@ export function UModal(props: ModalProps) { ...@@ -20,6 +22,7 @@ export function UModal(props: ModalProps) {
destroyOnHidden={destroyOnHidden} destroyOnHidden={destroyOnHidden}
mask={mask ?? (maskClosable === undefined ? { closable: false } : { closable: maskClosable })} mask={mask ?? (maskClosable === undefined ? { closable: false } : { closable: maskClosable })}
okButtonProps={{ type: 'primary', ...okButtonProps }} okButtonProps={{ type: 'primary', ...okButtonProps }}
cancelButtonProps={{ type: 'default', ...cancelButtonProps }}
{...rest} {...rest}
/> />
); );
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!