From 19d57cb1e7dc72754f54b2662f83993d882130d9 Mon Sep 17 00:00:00 2001 From: zhiweio Date: Fri, 29 Nov 2024 23:15:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20EXIF=20=E5=AF=BC=E5=87=BA=E4=BD=9C?= =?UTF-8?q?=E4=B8=BA=E5=8F=AF=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 14 ++++++++++++-- src/hooks/useImageHandlers.ts | 4 ++-- src/styles/App.css | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 92a7628..e056fd7 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,6 @@ import type { ExifParamsForm } from './types' import { createFromIconfontCN, DownloadOutlined, PlusOutlined } from '@ant-design/icons' -import { Button, Divider, Flex, Form, Input, Select, Slider, Space, Typography, Upload } from 'antd' +import { Button, Divider, Flex, Form, Input, Select, Slider, Space, Switch, Tooltip, Typography, Upload } from 'antd' import { useEffect, useRef, useState } from 'react' import { useImageHandlers } from './hooks/useImageHandlers' @@ -24,6 +24,7 @@ function App() { const formRef = useRef() const { imgRef, imgUrl, setImgUrl, formValue, setFormValue, handleAdd, handleDownload, handleFormChange, handleFontSizeChange, handleFontWeightChange, handleFontFamilyChange, handleScaleChange, handleExhibitionClick } = useImageHandlers(formRef, DefaultPictureExif) const [wasmLoaded, setWasmLoaded] = useState(false) + const [exifEnable, setExifEnable] = useState(false) const formValueRef = useRef(DefaultPictureExif) @@ -155,7 +156,7 @@ function App() { type="primary" shape="round" icon={} - onClick={handleDownload} + onClick={() => handleDownload(exifEnable)} > 导出照片 @@ -168,6 +169,15 @@ function App() { 参数
+ + 导出 EXIF + + setExifEnable(!exifEnable)} + /> + +
=> { + const handleDownload = async (exifEnable: boolean): Promise => { const previewDom = document.getElementById('preview') const zoomRatio = 4 @@ -72,7 +72,7 @@ export function useImageHandlers(formRef: any, initialFormValue: ExifParamsForm) } const link = document.createElement('a') - if (exifBlob) { + if (exifEnable && exifBlob) { if (uploadImgType === 'image/jpeg' || uploadImgType === 'image/jpg') { console.log('embed exif in jpg') const imgBlob = dataURLtoBlob(dataUrl) diff --git a/src/styles/App.css b/src/styles/App.css index 8794bd1..9d20611 100644 --- a/src/styles/App.css +++ b/src/styles/App.css @@ -230,3 +230,37 @@ background-color: #0056b3; /* Darker blue on hover */ transform: translateY(-2px); /* Lift effect on hover */ } + +/* Switch Styles */ +.switch-title { + color: #aaa; /* Light gray color for the title */ + font-family: var(--current-font-family), system-ui; + font-size: 12px; /* Font size for the title */ +} + +.ant-switch { + border-radius: 20px; /* Rounded corners for a modern look */ + background-color: #e0e0e0; /* Light gray background color */ + transition: background-color 0.3s ease; /* Smooth transition for background color */ +} + +.ant-switch-checked { + background-color: #a0c4ff; /* Light blue background color when checked */ +} + +.ant-switch-checked:hover { + background-color: #8ab8ff; /* Lighter shade on hover when checked */ +} + +/* Tooltip Styles */ +.ant-tooltip { + border-radius: 8px; /* Rounded corners for tooltips */ + background-color: #f0f0f0; /* Light background for better contrast */ + color: #333; /* Dark text for readability */ + padding: 8px; /* Padding for better spacing */ + font-size: 14px; /* Font size for tooltip text */ +} + +.ant-tooltip-arrow { + border-color: #f0f0f0; /* Match arrow color with tooltip background */ +}