Commit ff284073 authored by 蔺超's avatar 蔺超

feat: Add dark mode support to tools components

parent a7776a34
......@@ -46,7 +46,8 @@ const App = () => {
imageState,
setImageState,
timeState,
setTimeState
setTimeState,
isDarkMode
};
const menuItems = [
......
......@@ -7,7 +7,7 @@ import { AppContext } from '../App';
const { Text } = Typography;
const ImageTools = () => {
const { imageState, setImageState } = useContext(AppContext);
const { imageState, setImageState, isDarkMode } = useContext(AppContext);
const { imageUrl, imageFile, compressedImageUrl, quality, originalSize, compressedSize } = imageState;
const handleUpload = (info) => {
......@@ -53,7 +53,7 @@ const ImageTools = () => {
message.loading({ content: '正在压缩图片...', key: 'compressing' });
const options = {
maxSizeMB: 1,
maxSizeMB: Math.max(0.1, (quality / 100) * (imageFile.size / (1024 * 1024))),
maxWidthOrHeight: 1920,
useWebWorker: true,
maxIteration: 10,
......
......@@ -6,7 +6,7 @@ import { AppContext } from '../App';
const { TextArea } = Input;
const JsonTools = () => {
const { jsonState, setJsonState } = useContext(AppContext);
const { jsonState, setJsonState, isDarkMode } = useContext(AppContext);
const { inputValue, outputValue } = jsonState;
const formatJson = () => {
......@@ -46,7 +46,7 @@ const JsonTools = () => {
value={inputValue}
onChange={(e) => setJsonState({ ...jsonState, inputValue: e.target.value })}
placeholder="请输入JSON字符串"
style={{ backgroundColor: '#ffffff', color: '#000000' }}
style={{ backgroundColor: isDarkMode ? '#1f1f1f' : '#ffffff', color: isDarkMode ? '#ffffff' : '#000000' }}
/>
<Space>
<Button
......@@ -75,7 +75,7 @@ const JsonTools = () => {
value={outputValue}
readOnly
placeholder="格式化/压缩后的JSON将显示在这里"
style={{ backgroundColor: '#ffffff', color: '#000000' }}
style={{ backgroundColor: isDarkMode ? '#1f1f1f' : '#ffffff', color: isDarkMode ? '#ffffff' : '#000000' }}
/>
</Space>
</div>
......
......@@ -7,7 +7,7 @@ import dayjs from 'dayjs';
const { Text } = Typography;
const TimeTools = () => {
const { timeState, setTimeState } = useContext(AppContext);
const { timeState, setTimeState, isDarkMode } = useContext(AppContext);
const [currentTimestamp, setCurrentTimestamp] = useState('');
const [selectedDate, setSelectedDate] = useState(null);
const [selectedTime, setSelectedTime] = useState(null);
......@@ -86,7 +86,7 @@ const TimeTools = () => {
placeholder="请选择日期"
value={selectedDate}
onChange={handleDateChange}
style={{ width: '300px', backgroundColor: '#ffffff' }}
style={{ width: '300px', backgroundColor: 'inherit', color: isDarkMode ? '#ffffff' : '#000000' }}
format="YYYY-MM-DD"
popupStyle={{ maxHeight: '160px', top: '100px' }}
/>
......@@ -96,7 +96,7 @@ const TimeTools = () => {
placeholder="请选择时间"
value={selectedTime}
onChange={handleTimeChange}
style={{ width: '300px', backgroundColor: '#ffffff' }}
style={{ width: '300px', backgroundColor: 'inherit', color: isDarkMode ? '#ffffff' : '#000000' }}
format="HH:mm:ss"
popupStyle={{ maxHeight: '160px', top: '100px' }}
/>
......@@ -124,7 +124,7 @@ const TimeTools = () => {
placeholder="请输入时间戳(毫秒)"
value={inputTimestamp}
onChange={(e) => setInputTimestamp(e.target.value)}
style={{ width: '300px', backgroundColor: '#ffffff', color: '#000000' }}
style={{ width: '300px', backgroundColor: 'inherit', color: isDarkMode ? '#ffffff' : '#000000' }}
/>
<Space>
<Button
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment