@@ -5,10 +5,11 @@ import { RiErrorWarningLine } from "@remixicon/react";
55import { useShallow } from "zustand/shallow" ;
66
77import { useModalStore } from "@/store/modal" ;
8+ import { useSettings } from "@/store/settings" ;
89
9- type ConfirmModalType = "warning" | "danger" ;
10+ type ConfirmModalType = "warning" | "danger" | "primary" ;
1011
11- const colorMap : Record < ConfirmModalType , string > = {
12+ const colorMap : Record < Exclude < ConfirmModalType , "primary" > , string > = {
1213 warning : "#F5A524" ,
1314 danger : "#dc1258" ,
1415} ;
@@ -35,8 +36,17 @@ const ConfirmModal = () => {
3536 cancelText = "取消" ,
3637 } = confirmModalData || { } ;
3738
39+ const primaryColor = useSettings ( s => s . primaryColor ) ;
3840 const [ loading , setLoading ] = useState ( false ) ;
3941
42+ // 根据类型获取图标颜色
43+ const getIconColor = ( ) => {
44+ if ( type === "primary" ) {
45+ return primaryColor ;
46+ }
47+ return colorMap [ type as Exclude < ConfirmModalType , "primary" > ] ;
48+ } ;
49+
4050 const handleClose = ( ) => onConfirmModalOpenChange ( false ) ;
4151
4252 const handleConfirm = async ( ) => {
@@ -62,8 +72,8 @@ const ConfirmModal = () => {
6272 < ModalContent >
6373 { ( ) => (
6474 < >
65- < ModalHeader className = "flex items-center gap-1" >
66- < RiErrorWarningLine color = { colorMap [ type ] } />
75+ < ModalHeader className = "flex items-center gap-1 [&>span]:text-[var(--heroui-foreground)] " >
76+ < RiErrorWarningLine color = { getIconColor ( ) } />
6777 < span > { title } </ span >
6878 </ ModalHeader >
6979 { description ? (
@@ -75,7 +85,7 @@ const ConfirmModal = () => {
7585 < Button variant = "light" onPress = { handleClose } isDisabled = { loading } >
7686 { cancelText }
7787 </ Button >
78- < Button color = { type } onPress = { handleConfirm } isLoading = { loading } >
88+ < Button color = { type === "primary" ? "primary" : type } onPress = { handleConfirm } isLoading = { loading } >
7989 { confirmText }
8090 </ Button >
8191 </ ModalFooter >
0 commit comments