Merge remote-tracking branch 'origin/master'

This commit is contained in:
HFO4 2022-07-20 20:04:01 +08:00
commit c6894ae238
5 changed files with 35 additions and 23 deletions

View File

@ -1,3 +1,3 @@
files:
- source: /public/locales/en-US/*.json
- source: /public/locales/zh-CN/*.json
translation: /public/locales/%locale%/%original_file_name%

View File

@ -669,7 +669,7 @@
"compressSize": "Maximum file size to be compressed",
"compressSizeDes": "The maximum total file size of compression jobs that can be created by the user, fill in 0 to indicate no limit.",
"decompressSize": "Maximum file size to be decompressed",
"decompressSizeDes": "The maximum total file size of decompression jobs that can be created by the user, fill in 0 to indicate no limit.",
"decompressSizeDes": "The maximum total file size of decompression jobs that can be created by the user, fill in 0 to indicate no limit."
},
"user": {
"deleted": "User deleted.",
@ -766,4 +766,4 @@
"lastProgress": "Last progress",
"errorMsg": "Error message"
}
}
}

View File

@ -668,7 +668,7 @@
"compressSize": "待压缩文件最大大小",
"compressSizeDes": "用户可创建的压缩任务的文件最大总大小,填写为 0 表示不限制",
"decompressSize": "待解压文件最大大小",
"decompressSizeDes": "用户可创建的解压缩任务的文件最大总大小,填写为 0 表示不限制",
"decompressSizeDes": "用户可创建的解压缩任务的文件最大总大小,填写为 0 表示不限制"
},
"user": {
"deleted": "用户已删除",
@ -765,4 +765,4 @@
"lastProgress": "最后进度",
"errorMsg": "错误信息"
}
}
}

View File

@ -1,22 +1,20 @@
import React, { useCallback, useState, useEffect, useRef } from "react";
import React, { useState, useEffect, useRef } from "react";
import {
Button,
CircularProgress,
Dialog,
DialogActions,
DialogContent,
DialogContentText,
DialogTitle,
makeStyles,
FormControl,
FormControlLabel,
Checkbox,
} from "@material-ui/core";
import { useDispatch } from "react-redux";
import TextField from "@material-ui/core/TextField";
import { useTranslation } from "react-i18next";
import { useInterval } from "ahooks";
import { useInterval, usePrevious, useGetState } from "ahooks";
import { cancelDirectoryDownload } from "../../redux/explorer/action";
import Auth from "../../middleware/Auth";
const useStyles = makeStyles((theme) => ({
contentFix: {
@ -39,13 +37,25 @@ export default function DirectoryDownloadDialog(props) {
const classes = useStyles();
const logRef = useRef();
const autoScroll = useRef(true);
const [autoScroll, setAutoScroll] = useState(
Auth.GetPreferenceWithDefault("autoScroll", true)
);
const previousLog = usePrevious(props.log, (prev, next) => true);
const [timer, setTimer] = useState(-1);
useInterval(() => {
if (autoScroll.current && !props.done && logRef.current) {
if (autoScroll && logRef.current && previousLog !== props.log) {
logRef.current.scrollIntoView({ behavior: "smooth", block: "end" });
}
}, 1000);
}, timer);
useEffect(() => {
if (props.done) {
setTimer(-1);
} else if (props.open) {
setTimer(1000);
}
}, [props.done, props.open]);
return (
<Dialog
@ -65,24 +75,25 @@ export default function DirectoryDownloadDialog(props) {
ref={logRef}
multiline
fullWidth
autoFocus
id="standard-basic"
/>
</DialogContent>
<DialogActions>
<FormControlLabel
control={
<Checkbox
checked={autoScroll.current}
onChange={() =>
(autoScroll.current = !autoScroll.current)
}
/>
control={<Checkbox />}
checked={autoScroll}
onChange={() =>
setAutoScroll((previous) => {
Auth.SetPreference("autoScroll", !previous);
return !previous;
})
}
label={t("modals.directoryDownloadAutoscroll")}
/>
<Button
onClick={props.done ? props.onClose : cancelDirectoryDownload}
onClick={
props.done ? props.onClose : cancelDirectoryDownload
}
>
{t("cancel", { ns: "common" })}
</Button>

View File

@ -458,6 +458,8 @@ export const startDirectoryDownload = (
share: any
): ThunkAction<any, any, any, any> => {
return async (dispatch, getState): Promise<void> => {
dispatch(changeContextMenu("file", false));
directoryDownloadAbortController = new AbortController();
if (!window.showDirectoryPicker || !window.isSecureContext) {
return;
@ -493,7 +495,6 @@ export const startDirectoryDownload = (
return;
}
dispatch(changeContextMenu("file", false));
const {
explorer: { selected },
navigator: { path },