From ff992a8afdd5dcfcde4227f8fee70471c3ee2041 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Sun, 17 Apr 2022 10:47:19 +0800 Subject: [PATCH] feat: invoke system share API after share link is created --- src/component/Modals/CreateShare.js | 32 +++++++++++++++++++++-------- src/component/Navbar/Navbar.js | 10 +++++---- src/component/Setting/WebDAV.js | 13 ++++++++++-- 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/component/Modals/CreateShare.js b/src/component/Modals/CreateShare.js index 035823c..6312fe7 100644 --- a/src/component/Modals/CreateShare.js +++ b/src/component/Modals/CreateShare.js @@ -1,17 +1,15 @@ import React, { useCallback } from "react"; -import { - Checkbox, - FormControl, - makeStyles, - TextField, -} from "@material-ui/core"; import { Button, + Checkbox, + CircularProgress, Dialog, DialogActions, DialogContent, DialogTitle, - CircularProgress, + FormControl, + makeStyles, + TextField, } from "@material-ui/core"; import { toggleSnackbar } from "../../redux/explorer"; import { useDispatch } from "react-redux"; @@ -38,7 +36,6 @@ import OutlinedInput from "@material-ui/core/OutlinedInput"; import Tooltip from "@material-ui/core/Tooltip"; import MenuItem from "@material-ui/core/MenuItem"; import Select from "@material-ui/core/Select"; -import EyeIcon from "@material-ui/icons/RemoveRedEye"; import ToggleIcon from "material-ui-toggle-icon"; const useStyles = makeStyles((theme) => ({ @@ -184,6 +181,18 @@ export default function CreatShare(props) { }, 500); }; + const senLink = () => { + if (navigator.share) { + navigator.share({ + title: props.selected[0].name, + url: shareURL, + }); + } else if (navigator.clipboard) { + navigator.clipboard.writeText(shareURL); + ToggleSnackbar("top", "right", "分享链接已复制", "info"); + } + }; + const submitShare = (e) => { e.preventDefault(); props.setModalsLoading(true); @@ -436,6 +445,13 @@ export default function CreatShare(props) { )} + {shareURL !== "" && ( +
+ +
+ )} {shareURL === "" && ( diff --git a/src/component/Navbar/Navbar.js b/src/component/Navbar/Navbar.js index 6173ca9..e95f971 100644 --- a/src/component/Navbar/Navbar.js +++ b/src/component/Navbar/Navbar.js @@ -200,10 +200,12 @@ const styles = (theme) => ({ }, upDrawer: { overflowX: "hidden", - display: "flex", - flexDirection: "column", - height: "100%", - justifyContent: "space-between", + [theme.breakpoints.up("sm")]: { + display: "flex", + flexDirection: "column", + height: "100%", + justifyContent: "space-between", + }, }, drawerOpen: { width: drawerWidth, diff --git a/src/component/Setting/WebDAV.js b/src/component/Setting/WebDAV.js index 6fc86ac..81c3385 100644 --- a/src/component/Setting/WebDAV.js +++ b/src/component/Setting/WebDAV.js @@ -65,8 +65,17 @@ export default function WebDAV() { ); const copyToClipboard = (text) => { - navigator.clipboard.writeText(text); - ToggleSnackbar("top", "center", "已复制到剪切板", "success"); + if (navigator.clipboard) { + navigator.clipboard.writeText(text); + ToggleSnackbar("top", "center", "已复制到剪切板", "success"); + } else { + ToggleSnackbar( + "top", + "center", + "当前浏览器不支持,请手动复制", + "warning" + ); + } }; const loadList = () => {