Skip to content

Commit

Permalink
feat: 添加清空按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
Pylogmon committed May 25, 2023
1 parent 6ce44a5 commit e17c210
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/windows/Translator/components/SourceArea/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ContentCopyRoundedIcon from '@mui/icons-material/ContentCopyRounded';
import SmartButtonRoundedIcon from '@mui/icons-material/SmartButtonRounded';
import TranslateRoundedIcon from '@mui/icons-material/TranslateRounded';
import GraphicEqRoundedIcon from '@mui/icons-material/GraphicEqRounded';
import ClearAllRoundedIcon from '@mui/icons-material/ClearAllRounded';
import { writeText } from '@tauri-apps/api/clipboard';
import React, { useState, useEffect } from 'react';
import { appWindow } from '@tauri-apps/api/window';
Expand Down Expand Up @@ -116,6 +117,19 @@ export default function SourceArea() {
<SmartButtonRoundedIcon />
</Tooltip>
</IconButton>
<IconButton
sx={{
visibility: text == '' && 'hidden',
}}
onClick={() => {
setSourceText('');
setText('');
}}
>
<Tooltip title='清空'>
<ClearAllRoundedIcon />
</Tooltip>
</IconButton>
</Box>
<MuiButton
variant='contained'
Expand Down
2 changes: 2 additions & 0 deletions src/windows/Translator/components/TargetArea/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,14 @@ export default function TargetArea(props) {
<InputBase
multiline
fullWidth
readOnly
value={targetText}
sx={{ display: targetText == '' && 'none' }}
/>
<InputBase
multiline
fullWidth
readOnly
value={errMessage}
sx={{ color: 'red', display: errMessage == '' && 'none' }}
/>
Expand Down

0 comments on commit e17c210

Please sign in to comment.