i18n: add qiniu storage policy

This commit is contained in:
HFO4 2022-06-14 20:26:51 +08:00
parent a9f044a93d
commit 45a3e060e5
3 changed files with 166 additions and 108 deletions

View File

@ -358,6 +358,29 @@
"remoteAddress": "Slave node address",
"testCommunicationDes": "After completing the above steps, you can test if the communication is working by clicking the test button below.",
"testCommunication": "Test slave communication",
"pathMagicVarDesRemote": "Enter the physical path to the folder you want to store files. Either absolute or relative (relative to slave Cloudreve executable) path is supported. You can use magic variables in the path, which will be automatically replaced with the corresponding values when the file is uploaded; see <0>List of path magic variables</0> for available magic variables."
"pathMagicVarDesRemote": "Enter the physical path to the folder you want to store files. Either absolute or relative (relative to slave Cloudreve executable) path is supported. You can use magic variables in the path, which will be automatically replaced with the corresponding values when the file is uploaded; see <0>List of path magic variables</0> for available magic variables.",
"storageBucket": "Storage bucket",
"editQiniuStoragePolicy": "Edit Qiniu storage policy",
"addQiniuStoragePolicy": "Add Qiniu storage policy",
"qiniuSiteURLDes": "Before using the Qiniu policy, please make sure that the address you entered in Basic Settings - Site Information - Site URL matches the actual address and <0>can be accessed properly by WAN</0>.",
"createQiniuBucket": "Go to <0>Qiniu dashboard</0> to create a storage bucket.。",
"enterQiniuBucket": "Enter the \"bucket name\" you just created:",
"qiniuBucketName": "Bucket name",
"bucketTypeDes": "Select the type of bucket you just created. We recommend selecting \"Private bucket\" for higher security, private bucket does not support \"Get Source Link\" feature.",
"privateBucket": "Private bucket",
"publicBucket": "Public bucket",
"bucketCDNDes": "Fill in the CDN-accelerated domain name you have bound for the storage bucket.",
"bucketCDNDomain": "CDN domain",
"qiniuCredentialDes": "Go to Personal Center - Credential Management in the Qiniu dashboard and fill in the obtained AK, SK.",
"ak": "AK",
"sk": "SK",
"cannotEnableForPrivateBucket": "This feature is not supported under private bucket.",
"limitMimeType": "Do you want to limit MimeTypes of file that can be uploaded?",
"mimeTypeDes": "Enter the MimeType of the allowed files, and separate multiple MimeTypes with a comma. Qiniu will detect the file content to determine the MimeType, and allow the upload if the MimeType is presented in your list.",
"mimeTypeList": "MimeTypes list",
"chunkSizeLabelQiniu": "Specify the chunk size for resumable uploads. Allowed range is 1 MB - 1 GB.",
"createPlaceholderDes": "Do you want to create a placeholder file and deduct user capacity when users start uploading? If enabled, Cloudreve will prevent users from maliciously initiating multiple upload requests but not completing the upload.",
"createPlaceholder": "Create placeholder files",
"notCreatePlaceholder": "Don't create"
}
}

View File

@ -278,7 +278,7 @@
"policyAdded": "存储策略已添加",
"policySaved": "存储策略已保存",
"editLocalStoragePolicy": "修改本机存储策略",
"addLocalStoragePolicy": "添加存储策略",
"addLocalStoragePolicy": "添加本机存储策略",
"optional": "可选",
"pathMagicVarDes": "请在下方输入文件的存储目录路径,可以为绝对路径或相对路径(相对于 Cloudreve。路径中可以使用魔法变量文件在上传时会自动替换这些变量为相应值 可用魔法变量可参考 <0>路径魔法变量列表</0>。",
"pathOfFolderToStoreFiles": "存储目录",
@ -357,6 +357,29 @@
"remoteAddress": "从机地址",
"testCommunicationDes": "完成以上步骤后,你可以点击下方的测试按钮测试通信是否正常。",
"testCommunication": "测试从机通信",
"pathMagicVarDesRemote": "请在下方输入文件的存储目录路径,可以为绝对路径或相对路径(相对于 从机的 Cloudreve。路径中可以使用魔法变量文件在上传时会自动替换这些变量为相应值 可用魔法变量可参考 <0>路径魔法变量列表</0>。"
"pathMagicVarDesRemote": "请在下方输入文件的存储目录路径,可以为绝对路径或相对路径(相对于 从机的 Cloudreve。路径中可以使用魔法变量文件在上传时会自动替换这些变量为相应值 可用魔法变量可参考 <0>路径魔法变量列表</0>。",
"storageBucket": "存储空间",
"editQiniuStoragePolicy": "修改七牛存储策略",
"addQiniuStoragePolicy": "添加七牛存储策略",
"qiniuSiteURLDes": "在使用七牛存储策略前,请确保您在 参数设置 - 站点信息 - 站点URL 中填写的 地址与实际相符,并且 <0>能够被外网正常访问</0>。",
"createQiniuBucket": "前往 <0>七牛控制面板</0> 创建对象存储资源。",
"enterQiniuBucket": "在下方填写您在七牛创建存储空间时指定的“存储空间名称”:",
"qiniuBucketName": "存储空间名称",
"bucketTypeDes": "在下方选择您创建的空间类型,推荐选择“私有空间”以获得更高的安全性,私有空间无法开启“获取直链”功能。",
"privateBucket": "私有",
"publicBucket": "公有",
"bucketCDNDes": "填写您为存储空间绑定的 CDN 加速域名。",
"bucketCDNDomain": "CDN 加速域名",
"qiniuCredentialDes": "在七牛控制面板进入 个人中心 - 密钥管理,在下方填写获得到的 AK、SK。",
"ak": "AK",
"sk": "SK",
"cannotEnableForPrivateBucket": "私有空间无法开启此功能",
"limitMimeType": "是否限制上传文件 MimeType",
"mimeTypeDes": "输入允许上传的 MimeType多个请以半角逗号 , 隔开。七牛服务器会侦测文件内容以判断 MimeType再用判断值跟指定值进行匹配匹配成功则允许上传。",
"mimeTypeList": "MimeType 列表",
"chunkSizeLabelQiniu": "请指定分片上传时的分片大小,范围 1 MB - 1 GB。",
"createPlaceholderDes": "是否要再用户开始上传时就创建占位符文件并扣除用户容量?开启后,可以防止用户恶意发起多个上传请求但不完成上传。",
"createPlaceholder": "创建占位符文件",
"notCreatePlaceholder": "不创建"
}
}

View File

@ -21,6 +21,8 @@ import { getNumber } from "../../../../utils";
import DomainInput from "../../Common/DomainInput";
import SizeInput from "../../Common/SizeInput";
import MagicVar from "../../Dialogs/MagicVar";
import { Trans, useTranslation } from "react-i18next";
const useStyles = makeStyles((theme) => ({
stepContent: {
@ -68,28 +70,29 @@ const useStyles = makeStyles((theme) => ({
const steps = [
{
title: "存储空间",
title: "storageBucket",
optional: false,
},
{
title: "上传路径",
title: "storagePathStep",
optional: false,
},
{
title: "直链设置",
title: "sourceLinkStep",
optional: false,
},
{
title: "上传设置",
title: "uploadSettingStep",
optional: false,
},
{
title: "完成",
title: "finishStep",
optional: false,
},
];
export default function RemoteGuide(props) {
const { t } = useTranslation("dashboard", { keyPrefix: "policy" });
const classes = useStyles();
const history = useHistory();
@ -185,7 +188,7 @@ export default function RemoteGuide(props) {
ToggleSnackbar(
"top",
"right",
"存储策略已" + (props.policy ? "保存" : "添加"),
props.policy ? t("policySaved") : t("policyAdded"),
"success"
);
setActiveStep(5);
@ -203,7 +206,9 @@ export default function RemoteGuide(props) {
return (
<div>
<Typography variant={"h6"}>
{props.policy ? "修改" : "添加"} 七牛 存储策略
{props.policy
? t("editQiniuStoragePolicy")
: t("addQiniuStoragePolicy")}
</Typography>
<Stepper activeStep={activeStep}>
{steps.map((label, index) => {
@ -211,7 +216,10 @@ export default function RemoteGuide(props) {
const labelProps = {};
if (label.optional) {
labelProps.optional = (
<Typography variant="caption">可选</Typography>
<Typography variant="caption">
{" "}
{t("optional")}
</Typography>
);
}
if (isStepSkipped(index)) {
@ -219,7 +227,9 @@ export default function RemoteGuide(props) {
}
return (
<Step key={label.title} {...stepProps}>
<StepLabel {...labelProps}>{label.title}</StepLabel>
<StepLabel {...labelProps}>
{t(label.title)}
</StepLabel>
</Step>
);
})}
@ -239,9 +249,11 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
在使用七牛存储策略前请确保您在 参数设置 -
站点信息 - 站点URL 中填写的 地址与实际相符并且
<strong>能够被外网正常访问</strong>
<Trans
ns={"dashboard"}
i18nKey={"policy.qiniuSiteURLDes"}
components={[<strong key={0} />]}
/>
</Typography>
</div>
</div>
@ -252,14 +264,19 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
前往
<Link
href={"https://portal.qiniu.com/create"}
target={"_blank"}
>
七牛控制面板
</Link>
创建对象存储资源
<Trans
ns={"dashboard"}
i18nKey={"policy.createQiniuBucket"}
components={[
<Link
key={0}
href={
"https://portal.qiniu.com/create"
}
target={"_blank"}
/>,
]}
/>
</Typography>
</div>
</div>
@ -270,12 +287,12 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
在下方填写您在七牛创建存储空间时指定的存储空间名称
{t("enterQiniuBucket")}
</Typography>
<div className={classes.form}>
<FormControl fullWidth>
<InputLabel htmlFor="component-helper">
存储空间名称
{t("qiniuBucketName")}
</InputLabel>
<Input
required
@ -293,7 +310,7 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
在下方选择您创建的空间类型推荐选择私有空间以获得更高的安全性私有空间无法开启获取直链功能
{t("bucketTypeDes")}
</Typography>
<div className={classes.form}>
<FormControl required component="fieldset">
@ -308,14 +325,14 @@ export default function RemoteGuide(props) {
control={
<Radio color={"primary"} />
}
label="私有"
label={t("privateBucket")}
/>
<FormControlLabel
value={"false"}
control={
<Radio color={"primary"} />
}
label="公有"
label={t("publicBucket")}
/>
</RadioGroup>
</FormControl>
@ -329,14 +346,14 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
填写您为存储空间绑定的 CDN 加速域名
{t("bucketCDNDes")}
</Typography>
<div className={classes.form}>
<DomainInput
value={policy.BaseURL}
onChange={handleChange("BaseURL")}
required
label={"CDN 加速域名"}
label={t("bucketCDNDomain")}
/>
</div>
</div>
@ -348,13 +365,12 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
在七牛控制面板进入 个人中心 -
密钥管理在下方填写获得到的 AKSK
{t("qiniuCredentialDes")}
</Typography>
<div className={classes.form}>
<FormControl fullWidth>
<InputLabel htmlFor="component-helper">
AK
{t("ak")}
</InputLabel>
<Input
required
@ -366,7 +382,7 @@ export default function RemoteGuide(props) {
<div className={classes.form}>
<FormControl fullWidth>
<InputLabel htmlFor="component-helper">
SK
{t("sk")}
</InputLabel>
<Input
required
@ -385,7 +401,7 @@ export default function RemoteGuide(props) {
variant={"contained"}
color={"primary"}
>
下一步
{t("next")}
</Button>
</div>
</form>
@ -405,25 +421,23 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
请在下方输入文件的存储目录路径可以为绝对路径或相对路径相对于
从机的
Cloudreve路径中可以使用魔法变量文件在上传时会自动替换这些变量为相应值
可用魔法变量可参考{" "}
<Link
color={"secondary"}
onClick={(e) => {
e.preventDefault();
setMagicVar("path");
}}
>
路径魔法变量列表
</Link>{" "}
<Trans
ns={"dashboard"}
i18nKey={"policy.pathMagicVarDes"}
components={[
<Link
key={0}
color={"secondary"}
href={"javascript:void()"}
onClick={() => setMagicVar("path")}
/>,
]}
/>
</Typography>
<div className={classes.form}>
<FormControl fullWidth>
<InputLabel htmlFor="component-helper">
存储目录
{t("pathOfFolderToStoreFiles")}
</InputLabel>
<Input
required
@ -441,19 +455,18 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
是否需要对存储的物理文件进行重命名此处的重命名不会影响最终呈现给用户的
文件名文件名也可使用魔法变量
可用魔法变量可参考{" "}
<Link
color={"secondary"}
onClick={(e) => {
e.preventDefault();
setMagicVar("file");
}}
>
文件名魔法变量列表
</Link>{" "}
<Trans
ns={"dashboard"}
i18nKey={"policy.filePathMagicVarDes"}
components={[
<Link
key={0}
color={"secondary"}
href={"javascript:void()"}
onClick={() => setMagicVar("file")}
/>,
]}
/>
</Typography>
<div className={classes.form}>
<FormControl required component="fieldset">
@ -469,14 +482,14 @@ export default function RemoteGuide(props) {
control={
<Radio color={"primary"} />
}
label="开启重命名"
label={t("autoRenameStoredFile")}
/>
<FormControlLabel
value={"false"}
control={
<Radio color={"primary"} />
}
label="不开启"
label={t("keepOriginalFileName")}
/>
</RadioGroup>
</FormControl>
@ -486,7 +499,7 @@ export default function RemoteGuide(props) {
<div className={classes.form}>
<FormControl fullWidth>
<InputLabel htmlFor="component-helper">
命名规则
{t("renameRule")}
</InputLabel>
<Input
required={
@ -509,7 +522,7 @@ export default function RemoteGuide(props) {
className={classes.button}
onClick={() => setActiveStep(0)}
>
上一步
{t("back")}
</Button>
<Button
disabled={loading}
@ -517,7 +530,7 @@ export default function RemoteGuide(props) {
variant={"contained"}
color={"primary"}
>
下一步
{t("next")}
</Button>
</div>
</form>
@ -537,9 +550,9 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
是否允许获取文件永久直链
{t("enableGettingPermanentSourceLink")}
<br />
开启后用户可以请求获得能直接访问到文件内容的直链适用于图床应用或自用
{t("enableGettingPermanentSourceLinkDes")}
</Typography>
<div className={classes.form}>
@ -555,7 +568,9 @@ export default function RemoteGuide(props) {
ToggleSnackbar(
"top",
"right",
"私有空间无法开启此功能",
t(
"cannotEnableForPrivateBucket"
),
"warning"
);
return;
@ -571,14 +586,14 @@ export default function RemoteGuide(props) {
control={
<Radio color={"primary"} />
}
label="允许"
label={t("allowed")}
/>
<FormControlLabel
value={"false"}
control={
<Radio color={"primary"} />
}
label="禁止"
label={t("forbidden")}
/>
</RadioGroup>
</FormControl>
@ -592,7 +607,7 @@ export default function RemoteGuide(props) {
className={classes.button}
onClick={() => setActiveStep(1)}
>
上一步
{t("back")}
</Button>{" "}
<Button
disabled={loading}
@ -600,7 +615,7 @@ export default function RemoteGuide(props) {
variant={"contained"}
color={"primary"}
>
下一步
{t("next")}
</Button>
</div>
</form>
@ -620,7 +635,7 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
是否限制上传的单文件大小
{t("limitFileSize")}
</Typography>
<div className={classes.form}>
@ -652,14 +667,14 @@ export default function RemoteGuide(props) {
control={
<Radio color={"primary"} />
}
label="限制"
label={t("limit")}
/>
<FormControlLabel
value={"false"}
control={
<Radio color={"primary"} />
}
label="不限制"
label={t("notLimit")}
/>
</RadioGroup>
</FormControl>
@ -674,7 +689,7 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
输入限制
{t("enterSizeLimit")}
</Typography>
<div className={classes.form}>
<SizeInput
@ -697,7 +712,7 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
是否限制上传文件扩展名
{t("limitFileExt")}
</Typography>
<div className={classes.form}>
@ -737,14 +752,14 @@ export default function RemoteGuide(props) {
control={
<Radio color={"primary"} />
}
label="限制"
label={t("limit")}
/>
<FormControlLabel
value={"false"}
control={
<Radio color={"primary"} />
}
label="不限制"
label={t("notLimit")}
/>
</RadioGroup>
</FormControl>
@ -761,13 +776,12 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
输入允许上传的文件扩展名多个请以半角逗号 ,
隔开
{t("enterFileExt")}
</Typography>
<div className={classes.form}>
<FormControl fullWidth>
<InputLabel htmlFor="component-helper">
扩展名列表
{t("extList")}
</InputLabel>
<Input
value={
@ -795,7 +809,7 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
是否限制上传文件 MimeType
{t("limitMimeType")}
</Typography>
<div className={classes.form}>
@ -834,14 +848,14 @@ export default function RemoteGuide(props) {
control={
<Radio color={"primary"} />
}
label="限制"
label={t("limit")}
/>
<FormControlLabel
value={"false"}
control={
<Radio color={"primary"} />
}
label="不限制"
label={t("notLimit")}
/>
</RadioGroup>
</FormControl>
@ -862,14 +876,12 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
输入允许上传的 MimeType多个请以半角逗号 ,
隔开七牛服务器会侦测文件内容以判断
MimeType再用判断值跟指定值进行匹配匹配成功则允许上传
{t("mimeTypeDes")}
</Typography>
<div className={classes.form}>
<FormControl fullWidth>
<InputLabel htmlFor="component-helper">
MimeType 列表
{t("mimeTypeList")}
</InputLabel>
<Input
value={
@ -898,9 +910,9 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
请指定分片上传时的分片大小范围 1 MB - 1 GB
{t("chunkSizeLabelQiniu")}
<br />
启用分片上传后用户上传的文件将会被切分成分片逐个上传到存储端当上传中断后用户可以选择从上次上传的分片后继续开始上传
{t("chunkSizeDes")}
</Typography>
<div className={classes.form}>
<SizeInput
@ -908,7 +920,7 @@ export default function RemoteGuide(props) {
onChange={handleOptionChange("chunk_size")}
min={1 << 20}
max={1024 << 20}
label={"分片上传大小"}
label={t("chunkSize")}
/>
</div>
</div>
@ -926,7 +938,7 @@ export default function RemoteGuide(props) {
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
是否要再用户开始上传时就创建占位符文件并扣除用户容量开启后可以防止用户恶意发起多个上传请求但不完成上传
{t("createPlaceholderDes")}
</Typography>
<div className={classes.form}>
<FormControl required component="fieldset">
@ -947,14 +959,14 @@ export default function RemoteGuide(props) {
control={
<Radio color={"primary"} />
}
label="创建占位符文件"
label={t("createPlaceholder")}
/>
<FormControlLabel
value={"false"}
control={
<Radio color={"primary"} />
}
label="不创建"
label={t("notCreatePlaceholder")}
/>
</RadioGroup>
</FormControl>
@ -968,7 +980,7 @@ export default function RemoteGuide(props) {
className={classes.button}
onClick={() => setActiveStep(2)}
>
上一步
{t("back")}
</Button>{" "}
<Button
disabled={loading}
@ -976,7 +988,7 @@ export default function RemoteGuide(props) {
variant={"contained"}
color={"primary"}
>
下一步
{t("next")}
</Button>
</div>
</form>
@ -985,15 +997,15 @@ export default function RemoteGuide(props) {
{activeStep === 4 && (
<form className={classes.stepContent} onSubmit={submitPolicy}>
<div className={classes.subStepContainer}>
<div className={classes.stepNumberContainer}></div>
<div className={classes.stepNumberContainer} />
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
最后一步为此存储策略命名
{t("nameThePolicy")}
</Typography>
<div className={classes.form}>
<FormControl fullWidth>
<InputLabel htmlFor="component-helper">
存储策略名
{t("policyName")}
</InputLabel>
<Input
required
@ -1010,7 +1022,7 @@ export default function RemoteGuide(props) {
className={classes.button}
onClick={() => setActiveStep(3)}
>
上一步
{t("back")}
</Button>{" "}
<Button
disabled={loading}
@ -1018,7 +1030,7 @@ export default function RemoteGuide(props) {
variant={"contained"}
color={"primary"}
>
完成
{t("finish")}
</Button>
</div>
</form>
@ -1028,10 +1040,10 @@ export default function RemoteGuide(props) {
<>
<form className={classes.stepContent}>
<Typography>
存储策略已{props.policy ? "保存" : "添加"}
{props.policy ? t("policySaved") : t("policyAdded")}
</Typography>
<Typography variant={"body2"} color={"textSecondary"}>
要使用此存储策略请到用户组管理页面为相应用户组绑定此存储策略
{t("furtherActions")}
</Typography>
</form>
<div className={classes.stepFooter}>
@ -1040,7 +1052,7 @@ export default function RemoteGuide(props) {
className={classes.button}
onClick={() => history.push("/admin/policy")}
>
返回存储策略列表
{t("backToList")}
</Button>
</div>
</>