|
|
@@ -1,4 +1,4 @@
|
|
|
-import React from 'react';
|
|
|
+import React, { useState } from 'react';
|
|
|
import { Button, Flex, Divider } from 'antd';
|
|
|
import '@/themes/truncateText.css';
|
|
|
import { useDispatch } from 'react-redux';
|
|
|
@@ -20,7 +20,24 @@ const FunctionButton = ({
|
|
|
}) => {
|
|
|
const dispatch = useDispatch();
|
|
|
const themeType = useAppSelector((state) => state.theme.themeType);
|
|
|
+ const currentAction = useAppSelector((state) => state.functionArea.action);
|
|
|
const { disabled } = useButtonAvailability(action);
|
|
|
+ const isActive = currentAction === action;
|
|
|
+ const [isHovered, setIsHovered] = useState(false);
|
|
|
+
|
|
|
+ // 根据状态计算Icon的样式
|
|
|
+ const getIconStyle = () => {
|
|
|
+ if (disabled) {
|
|
|
+ return { opacity: 0.4, filter: 'grayscale(1)' };
|
|
|
+ }
|
|
|
+ if (isActive) {
|
|
|
+ return { color: '#1890ff' }; // 蓝色高亮(激活状态)
|
|
|
+ }
|
|
|
+ if (isHovered) {
|
|
|
+ return { color: '#40a9ff' }; // 浅蓝色(悬停状态)
|
|
|
+ }
|
|
|
+ return {}; // 默认颜色
|
|
|
+ };
|
|
|
|
|
|
const handleButtonClick = () => {
|
|
|
if (disabled) {
|
|
|
@@ -61,6 +78,8 @@ const FunctionButton = ({
|
|
|
return (
|
|
|
<Button
|
|
|
onClick={handleButtonClick}
|
|
|
+ onMouseEnter={() => setIsHovered(true)}
|
|
|
+ onMouseLeave={() => setIsHovered(false)}
|
|
|
disabled={disabled}
|
|
|
icon={
|
|
|
<Icon
|
|
|
@@ -69,13 +88,16 @@ const FunctionButton = ({
|
|
|
userId="base"
|
|
|
theme={themeType}
|
|
|
size="2x"
|
|
|
- state="normal"
|
|
|
+ state={isActive ? "down" : "normal"}
|
|
|
+ style={getIconStyle()}
|
|
|
/>
|
|
|
}
|
|
|
style={{
|
|
|
width: '1.5rem',
|
|
|
height: '1.5rem',
|
|
|
padding: 0, // 关键
|
|
|
+ border: isHovered ? '1px solid #40a9ff' : '1px solid transparent',
|
|
|
+ backgroundColor: isHovered ? '#e6f7ff' : 'transparent',
|
|
|
//minWidth: 44, // 保险
|
|
|
//overflow: 'hidden', // 超出的文字裁掉
|
|
|
}}
|