feat: file share custom password support

This commit is contained in:
wintbit 2025-06-15 20:04:00 +08:00
parent 1c87bc1c16
commit 5b9fb5828c
7 changed files with 34 additions and 1 deletions

View File

@ -469,6 +469,8 @@
"createShareLink": "Create share link",
"privateShare": "Hide from public",
"privateShareDes": "If selected, other people cannot see this share link on your homepage.",
"passwordPrefix": "Share link password: ",
"passwordAutoGenerate": "Auto generate",
"shareView": "Share view setting",
"shareViewDes": "If selected, other users can see your view setting (layout, sorting, etc.) saved on the server server when accessing this shared folder.",
"expireAfterDownload": "Expire after being downloaded",

View File

@ -470,6 +470,8 @@
"createShareLink": "共有リンク作成",
"privateShare": "共有を非表示",
"privateShareDes": "チェックを入れると他の人はあなたのプロフィールページでこの共有リンクを見ることができません。",
"passwordPrefix": "共有リンクパスワード:",
"passwordAutoGenerate": "自動生成",
"expireAfterDownload": "ダウンロード後に自動的に期限切れ",
"sharePassword": "共有パスワード",
"randomlyGenerate": "ランダム生成",

View File

@ -469,6 +469,8 @@
"createShareLink": "创建分享链接",
"privateShare": "隐藏分享",
"privateShareDes": "勾选后,其他人无法在你的个人主页看到此分享链接。",
"passwordPrefix": "分享密码: ",
"passwordAutoGenerate": "自动生成",
"expireAfterDownload": "下载后自动过期",
"sharePassword": "分享密码",
"randomlyGenerate": "随机生成",

View File

@ -465,6 +465,8 @@
"createShareLink": "建立分享連結",
"privateShare": "隱藏分享",
"privateShareDes": "勾選後,其他人無法在你的個人主頁看到此分享連結。",
"passwordPrefix": "分享密碼:",
"passwordAutoGenerate": "自動生成",
"expireAfterDownload": "下載後自動過期",
"sharePassword": "分享密碼",
"randomlyGenerate": "隨機生成",

View File

@ -275,6 +275,7 @@ export interface ShareCreateService {
uri: string;
downloads?: number;
is_private?: boolean;
password?: string;
expire?: number;
share_view?: boolean;
}

View File

@ -1,5 +1,6 @@
import {
Autocomplete,
Box,
Checkbox,
createFilterOptions,
FormControl,
@ -70,6 +71,7 @@ const StyledListItemButton = styled(ListItemButton)(() => ({}));
export interface ShareSetting {
is_private?: boolean;
password?: string;
share_view?: boolean;
downloads?: boolean;
expires?: boolean;
@ -150,7 +152,28 @@ const ShareSettingContent = ({ setting, file, editing, onSettingChange }: ShareS
</ListItemSecondaryAction>
</StyledListItemButton>
</AccordionSummary>
<AccordionDetails>{t("application:modals.privateShareDes")}</AccordionDetails>
<AccordionDetails sx={{ display: "flex", flexDirection: "column", alignItems: "center" }}>
<Typography>{t("application:modals.privateShareDes")}</Typography>
{setting.is_private && (
<Box sx={{ display: "flex", alignItems: "center", width: "100%" }}>
<Typography>{t("application:modals.passwordPrefix")}</Typography>
<FormControl
variant="standard"
sx={{ mx: 1, flex: 1 }}
>
<TextField
variant="standard"
value={setting.password ?? ""}
onChange={(e) => {
onSettingChange({ ...setting, password: e.target.value });
}}
placeholder={t("application:modals.passwordAutoGenerate")}
fullWidth
/>
</FormControl>
</Box>
)}
</AccordionDetails>
</Accordion>
{file?.type == FileType.folder && (
<Accordion expanded={expanded === "share_view"} onChange={handleExpand("share_view")}>

View File

@ -20,6 +20,7 @@ export function createOrUpdateShareLink(
const req: ShareCreateService = {
uri: file.path,
is_private: setting.is_private,
password: setting.password,
share_view: setting.share_view,
downloads: setting.downloads && setting.downloads_val.value > 0 ? setting.downloads_val.value : undefined,
expire: setting.expires && setting.expires_val.value > 0 ? setting.expires_val.value : undefined,