Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加webdav代理下载流量选项 #160

Merged
merged 1 commit into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions public/locales/en-US/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@
"action": "Action",
"readonlyOn": "Turn on readonly",
"readonlyOff": "Turn off readonly",
"useProxyOn": "Turn on reverse proxy",
"useProxyOff": "Turn off reverse proxy",
"delete": "Delete",
"listEmpty": "No records.",
"createNewAccount": "Create new account",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/en-US/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,8 @@
"allowDownloadShareDes": "If disabled, user cannot download shared files.",
"allowWabDAV": "WebDAV",
"allowWabDAVDes": "If disabled, users cannot connect to the storage via the WebDAV protocol",
"allowWabDAVProxy": "WebDAV Proxy",
"allowWabDAVProxyDes": "If enabled, users can configure the WebDAV to proxy traffic when downloading files",
"disableMultipleDownload": "Disable multiple download requests",
"disableMultipleDownloadDes": "Valid only for local storage policies. When disabled, users cannot use the multi-threaded download tool.",
"allowRemoteDownload": "Remote download",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/zh-CN/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@
"action": "操作",
"readonlyOn": "开启只读",
"readonlyOff": "关闭只读",
"useProxyOn": "开启反代",
"useProxyOff": "关闭反代",
"delete": "删除",
"listEmpty": "没有记录",
"createNewAccount": "创建新账号",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/zh-CN/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,8 @@
"allowDownloadShareDes": "关闭后,用户无法下载别人创建的文件分享",
"allowWabDAV": "WebDAV",
"allowWabDAVDes": "关闭后,用户无法通过 WebDAV 协议连接至网盘",
"allowWabDAVProxy": "WebDAV 代理",
"allowWabDAVProxyDes": "启用后, 用户可以配置 WebDAV 代理下载文件的流量",
"disableMultipleDownload": "禁止多次下载请求",
"disableMultipleDownloadDes": "只针对本机存储策略有效。开启后,用户无法使用多线程下载工具。",
"allowRemoteDownload": "离线下载",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/zh-TW/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@
"action": "操作",
"readonlyOn": "開啓只讀",
"readonlyOff": "關閉只讀",
"useProxyOn": "開啓反代",
"useProxyOff": "關閉反代",
"delete": "刪除",
"listEmpty": "沒有記錄",
"createNewAccount": "創建新帳號",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/zh-TW/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,8 @@
"allowDownloadShareDes": "關閉後,用戶無法下載別人創建的文件分享",
"allowWabDAV": "WebDAV",
"allowWabDAVDes": "關閉後,用戶無法通過 WebDAV 協議連接至網路硬碟",
"allowWabDAVProxy": "WebDAV 代理",
"allowWabDAVProxyDes": "啓用後, 用戶可以配置 WebDAV 代理下載文件的流量",
"disableMultipleDownload": "禁止多次下載請求",
"disableMultipleDownloadDes": "只針對本機儲存策略有效。開啟後,用戶無法使用多執行緒下載工具。",
"allowRemoteDownload": "離線下載",
Expand Down
1 change: 1 addition & 0 deletions src/component/Admin/Group/EditGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function EditGroupPreload() {
"archive_task",
"one_time_download",
"share_download",
"webdav_proxy",
"aria2",
"redirected_source",
"advance_delete"
Expand Down
25 changes: 25 additions & 0 deletions src/component/Admin/Group/GroupForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export default function GroupForm(props) {
"archive_task",
"one_time_download",
"share_download",
"webdav_proxy",
"aria2",
"redirected_source",
"advance_delete"
Expand Down Expand Up @@ -409,6 +410,30 @@ export default function GroupForm(props) {
</div>
)}

{group.ID !== 3 && group.WebDAVEnabled === "true" && (
<div className={classes.form}>
<FormControl fullWidth>
<FormControlLabel
control={
<Switch
checked={
group.OptionsSerialized.webdav_proxy ===
"true"
}
onChange={handleOptionCheckChange(
"webdav_proxy"
)}
/>
}
label={t("allowWabDAVProxy")}
/>
<FormHelperText id="component-helper-text">
{t("allowWabDAVProxyDes")}
</FormHelperText>
</FormControl>
</div>
)}

<div className={classes.form}>
<FormControl fullWidth>
<FormControlLabel
Expand Down
57 changes: 56 additions & 1 deletion src/component/Setting/WebDAV.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Alert from "@material-ui/lab/Alert";
import Auth from "../../middleware/Auth";
import API from "../../middleware/Api";
import IconButton from "@material-ui/core/IconButton";
import { Delete } from "@material-ui/icons";
import { Cloud, CloudOff, Delete } from "@material-ui/icons";
import CreateWebDAVAccount from "../Modals/CreateWebDAVAccount";
import TimeAgo from "timeago-react";
import Link from "@material-ui/core/Link";
Expand Down Expand Up @@ -130,6 +130,22 @@ export default function WebDAV() {
});
};

const toggleAccountUseProxy = (id) => {
const account = accounts[id];
API.patch("/webdav/accounts", {
id: account.ID,
use_proxy: !account.UseProxy,
})
.then((response) => {
account.UseProxy = response.data.use_proxy;
const accountCopy = [...accounts];
setAccounts(accountCopy);
})
.catch((error) => {
ToggleSnackbar("top", "right", error.message, "error");
});
};

const addAccount = (account) => {
setCreate(false);
API.post("/webdav/accounts", {
Expand Down Expand Up @@ -290,6 +306,45 @@ export default function WebDAV() {
/>
</IconButton>
</Tooltip>
{user.group.allowWebDAVProxy && (<Tooltip
placement="top"
title={
row.UseProxy
? t(
"setting.useProxyOff"
)
: t(
"setting.useProxyOn"
)
}
onClick={() =>
toggleAccountUseProxy(
id
)
}
>
<IconButton>
<ToggleIcon
on={
row.UseProxy
}
onIcon={
<CloudOff
fontSize={
"small"
}
/>
}
offIcon={
<Cloud
fontSize={
"small"
}
/>
}
/>
</IconButton>
</Tooltip>)}
<Tooltip
placement="top"
title={t(
Expand Down