feat: confirm_before clear rules

This commit is contained in:
Gabe
2025-10-01 12:30:58 +08:00
parent a08c42db8b
commit d563521eb1
2 changed files with 26 additions and 6 deletions

View File

@@ -20,6 +20,7 @@ import { isValidWord } from "../../libs/utils";
import { kissLog } from "../../libs/log";
import { apiTranslate } from "../../apis";
import { OPT_TRANS_BAIDU, PHONIC_MAP } from "../../config";
import { useConfirm } from "../../hooks/Confirm";
function FavAccordion({ word, index }) {
const [expanded, setExpanded] = useState(false);
@@ -51,6 +52,7 @@ function FavAccordion({ word, index }) {
export default function FavWords() {
const i18n = useI18n();
const { favList, wordList, mergeWords, clearWords } = useFavWords();
const confirm = useConfirm();
const handleImport = (data) => {
try {
@@ -64,6 +66,16 @@ export default function FavWords() {
}
};
const handleClearWords = async () => {
const isConfirmed = await confirm({
confirmText: i18n("confirm_title"),
cancelText: i18n("cancel"),
});
if (isConfirmed) {
clearWords();
}
};
const handleTranslation = async () => {
const tranList = [];
for (const text of wordList) {
@@ -133,9 +145,7 @@ export default function FavWords() {
<Button
size="small"
variant="outlined"
onClick={() => {
clearWords();
}}
onClick={handleClearWords}
startIcon={<ClearAllIcon />}
>
{i18n("clear_all")}