diff --git a/src/App.js b/src/App.js index e3bf1fb..759fad5 100644 --- a/src/App.js +++ b/src/App.js @@ -30,7 +30,9 @@ import ResetForm from "./component/Login/ResetForm"; import Reset from "./component/Login/Reset"; import PageLoading from "./component/Placeholder/PageLoading"; import CodeViewer from "./component/Viewer/Code"; -const PDFViewer = React.lazy(() => import(/* webpackChunkName: "pdf" */ "./component/Viewer/PDF")); +const PDFViewer = React.lazy(() => + import(/* webpackChunkName: "pdf" */ "./component/Viewer/PDF") +); export default function App() { const themeConfig = useSelector(state => state.siteConfig.theme); @@ -101,10 +103,7 @@ export default function App() { - + @@ -117,7 +116,7 @@ export default function App() { - }> + }> @@ -137,11 +136,8 @@ export default function App() { - - + + @@ -197,7 +193,7 @@ export default function App() { - }> + }> diff --git a/src/actions/index.js b/src/actions/index.js index 7435295..035bdbd 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -1,30 +1,30 @@ -export * from './explorer' +export * from "./explorer"; export const setNavigator = (path, navigatorLoading) => { - return { - type: 'SET_NAVIGATOR', - path, - navigatorLoading - } -} + return { + type: "SET_NAVIGATOR", + path, + navigatorLoading + }; +}; export const navigateTo = path => { - return (dispatch, getState) => { - const state = getState() - const navigatorLoading = path !== state.navigator.path - dispatch(setNavigator(path, navigatorLoading)) - } + return (dispatch, getState) => { + const state = getState(); + const navigatorLoading = path !== state.navigator.path; + dispatch(setNavigator(path, navigatorLoading)); + }; }; export const navigateUp = () => { - return (dispatch, getState) => { - const state = getState() - const pathSplit = state.navigator.path.split("/"); - pathSplit.pop(); - const newPath = pathSplit.length===1? "/":pathSplit.join("/"); - const navigatorLoading = newPath !== state.navigator.path - dispatch(setNavigator(newPath, navigatorLoading)) - } + return (dispatch, getState) => { + const state = getState(); + const pathSplit = state.navigator.path.split("/"); + pathSplit.pop(); + const newPath = pathSplit.length === 1 ? "/" : pathSplit.join("/"); + const navigatorLoading = newPath !== state.navigator.path; + dispatch(setNavigator(newPath, navigatorLoading)); + }; }; export const drawerToggleAction = open => { @@ -34,11 +34,11 @@ export const drawerToggleAction = open => { }; }; -export const dragAndDrop = (source,target) => { +export const dragAndDrop = (source, target) => { return { type: "DRAG_AND_DROP", source: source, - target: target, + target: target }; }; @@ -49,9 +49,9 @@ export const changeViewMethod = method => { }; }; -export const toggleDaylightMode = ()=>{ +export const toggleDaylightMode = () => { return { - type: "TOGGLE_DAYLIGHT_MODE", + type: "TOGGLE_DAYLIGHT_MODE" }; }; @@ -110,10 +110,10 @@ export const openRenameDialog = () => { }; }; -export const openResaveDialog = (key) => { +export const openResaveDialog = key => { return { type: "OPEN_RESAVE_DIALOG", - key:key, + key: key }; }; @@ -135,21 +135,20 @@ export const openShareDialog = () => { }; }; -export const applyThemes = (theme)=>{ +export const applyThemes = theme => { return { - type:'APPLY_THEME', - theme:theme, + type: "APPLY_THEME", + theme: theme }; }; -export const setSessionStatus = (status)=>{ +export const setSessionStatus = status => { return { - type:'SET_SESSION_STATUS', - status:status, + type: "SET_SESSION_STATUS", + status: status }; }; - export const openMusicDialog = () => { return { type: "OPEN_MUSIC_DIALOG" @@ -192,11 +191,11 @@ export const openCopyDialog = () => { }; }; -export const openLoadingDialog = (text) => { +export const openLoadingDialog = text => { return { type: "OPEN_LOADING_DIALOG", - text: text, - } + text: text + }; }; export const closeAllModals = () => { @@ -265,4 +264,4 @@ export const setSiteConfig = config => { type: "SET_SITE_CONFIG", config: config }; -}; \ No newline at end of file +}; diff --git a/src/component/Admin/Common/SizeInput.js b/src/component/Admin/Common/SizeInput.js index 5628eca..f590caa 100644 --- a/src/component/Admin/Common/SizeInput.js +++ b/src/component/Admin/Common/SizeInput.js @@ -8,23 +8,34 @@ import React, { useCallback, useState } from "react"; import { useDispatch } from "react-redux"; import { toggleSnackbar } from "../../../actions"; -const unitTransform = (v)=>{ - if(v<1024){ - return [Math.round(v),1] +const unitTransform = v => { + if (v < 1024) { + return [Math.round(v), 1]; } - if(v<1024*1024){ - return [Math.round(v/1024),1024] + if (v < 1024 * 1024) { + return [Math.round(v / 1024), 1024]; } - if(v<1024*1024*1024){ - return [Math.round(v/(1024*1024)),1024*1024] + if (v < 1024 * 1024 * 1024) { + return [Math.round(v / (1024 * 1024)), 1024 * 1024]; } - if(v<1024*1024*1024*1024){ - return [Math.round(v/(1024*1024*1024)),1024*1024*1024] + if (v < 1024 * 1024 * 1024 * 1024) { + return [Math.round(v / (1024 * 1024 * 1024)), 1024 * 1024 * 1024]; } - return [Math.round(v/(1024*1024*1024*1024)),1024*1024*1024*1024] -} + return [ + Math.round(v / (1024 * 1024 * 1024 * 1024)), + 1024 * 1024 * 1024 * 1024 + ]; +}; -export default function SizeInput({onChange,min,value,required,label,max,suffix}){ +export default function SizeInput({ + onChange, + min, + value, + required, + label, + max, + suffix +}) { const dispatch = useDispatch(); const ToggleSnackbar = useCallback( (vertical, horizontal, msg, color) => @@ -32,67 +43,86 @@ export default function SizeInput({onChange,min,value,required,label,max,suffix} [dispatch] ); - - const [unit,setUnit] = useState(1); + const [unit, setUnit] = useState(1); let first = true; - const transform = useCallback(()=>{ + const transform = useCallback(() => { const res = unitTransform(value); - if(first && value !== 0){ + if (first && value !== 0) { setUnit(res[1]); first = false; } return res; - },[value]); + }, [value]); return ( - - {label} - + {label} { - if (e.target.value * unit < max){ + inputProps={{ min: min, step: 1 }} + onChange={e => { + if (e.target.value * unit < max) { onChange({ - target:{value:(e.target.value * unit).toString()} - }) - }else{ - ToggleSnackbar("top", "right", "超出最大尺寸限制", "warning"); + target: { + value: (e.target.value * unit).toString() + } + }); + } else { + ToggleSnackbar( + "top", + "right", + "超出最大尺寸限制", + "warning" + ); } - }} - required = {required} + required={required} endAdornment={ } /> - ) -} \ No newline at end of file + ); +} diff --git a/src/component/Admin/Dashboard.js b/src/component/Admin/Dashboard.js index 687f6cc..d73a46d 100644 --- a/src/component/Admin/Dashboard.js +++ b/src/component/Admin/Dashboard.js @@ -13,7 +13,24 @@ import ListItemText from "@material-ui/core/ListItemText"; import { lighten, makeStyles, useTheme } from "@material-ui/core/styles"; import Toolbar from "@material-ui/core/Toolbar"; import Typography from "@material-ui/core/Typography"; -import { Assignment, CloudDownload, Contacts, Group, Home, Image, InsertDriveFile, Language, ListAlt, Mail, Palette, Person, Settings, SettingsEthernet, Share, Storage } from "@material-ui/icons"; +import { + Assignment, + CloudDownload, + Contacts, + Group, + Home, + Image, + InsertDriveFile, + Language, + ListAlt, + Mail, + Palette, + Person, + Settings, + SettingsEthernet, + Share, + Storage +} from "@material-ui/icons"; import ChevronLeftIcon from "@material-ui/icons/ChevronLeft"; import ChevronRightIcon from "@material-ui/icons/ChevronRight"; import MenuIcon from "@material-ui/icons/Menu"; @@ -139,21 +156,21 @@ const useStyles = makeStyles(theme => ({ }, subMenu: { backgroundColor: theme.palette.background.default, - paddingTop:0, - paddingBottom:0, + paddingTop: 0, + paddingBottom: 0 }, active: { backgroundColor: lighten(theme.palette.primary.main, 0.8), color: theme.palette.primary.main, - "&:hover":{ - backgroundColor: lighten(theme.palette.primary.main, 0.7), - }, + "&:hover": { + backgroundColor: lighten(theme.palette.primary.main, 0.7) + } }, - activeText:{ - fontWeight: 500, + activeText: { + fontWeight: 500 }, - activeIcon:{ - color: theme.palette.primary.main, + activeIcon: { + color: theme.palette.primary.main } })); @@ -201,7 +218,7 @@ const items = [ title: "图像处理", path: "image", icon: - }, + } ] }, { @@ -242,9 +259,9 @@ const items = [ title: "常规任务", path: "task", icon: - }, - ], - }, + } + ] + } ]; export default function Dashboard({ content }) { @@ -339,19 +356,29 @@ export default function Dashboard({ content }) { } button className={clsx({ - [classes.active]: - location.pathname.startsWith("/admin/" + item.path) + [classes.active]: location.pathname.startsWith( + "/admin/" + item.path + ) })} key={item.title} > - {item.icon} - + + {item.icon} + + ); } @@ -384,16 +411,20 @@ export default function Dashboard({ content }) { } className={clsx({ [classes.sub]: open, - [classes.active]: - location.pathname.startsWith("/admin/" + sub.path) + [classes.active]: location.pathname.startsWith( + "/admin/" + sub.path + ) })} button key={sub.title} > - + {sub.icon} { e.preventDefault(); - const groupCopy = {...group}; + const groupCopy = { ...group }; groupCopy.time = parseInt(groupCopy.time) * 86400; groupCopy.price = parseInt(groupCopy.price) * 100; groupCopy.score = parseInt(groupCopy.score); - groupCopy.id = (new Date()).valueOf(); + groupCopy.id = new Date().valueOf(); groupCopy.des = groupCopy.des.split("\n"); onSubmit(groupCopy); }; @@ -218,7 +218,9 @@ export default function AddGroup({ open, onClose, onSubmit }) { control={ } label="突出展示" diff --git a/src/component/Admin/Dialogs/AddPack.js b/src/component/Admin/Dialogs/AddPack.js index 40cda88..e4cdeb1 100644 --- a/src/component/Admin/Dialogs/AddPack.js +++ b/src/component/Admin/Dialogs/AddPack.js @@ -10,16 +10,15 @@ import Input from "@material-ui/core/Input"; import FormHelperText from "@material-ui/core/FormHelperText"; import FormControl from "@material-ui/core/FormControl"; import SizeInput from "../Common/SizeInput"; -import {makeStyles} from "@material-ui/core/styles"; +import { makeStyles } from "@material-ui/core/styles"; const useStyles = makeStyles(() => ({ - formContainer: { - margin:"8px 0 8px 0", + margin: "8px 0 8px 0" } })); -export default function AddPack({ open, onClose,onSubmit }) { +export default function AddPack({ open, onClose, onSubmit }) { const classes = useStyles(); const [pack, setPack] = useState({ name: "", @@ -38,14 +37,14 @@ export default function AddPack({ open, onClose,onSubmit }) { const submit = e => { e.preventDefault(); - const packCopy = {...pack}; + const packCopy = { ...pack }; packCopy.size = parseInt(packCopy.size); packCopy.time = parseInt(packCopy.time) * 86400; packCopy.price = parseInt(packCopy.price) * 100; packCopy.score = parseInt(packCopy.score); - packCopy.id = (new Date()).valueOf(); + packCopy.id = new Date().valueOf(); onSubmit(packCopy); - } + }; return ( - 使用积分购买时的价格,填写为 0 表示不能使用积分购买 + 使用积分购买时的价格,填写为 0 + 表示不能使用积分购买 - diff --git a/src/component/Admin/Dialogs/AddRedeem.js b/src/component/Admin/Dialogs/AddRedeem.js index dad6aab..4de79b6 100644 --- a/src/component/Admin/Dialogs/AddRedeem.js +++ b/src/component/Admin/Dialogs/AddRedeem.js @@ -17,20 +17,19 @@ import { toggleSnackbar } from "../../../actions"; import API from "../../../middleware/Api"; const useStyles = makeStyles(() => ({ - formContainer: { - margin:"8px 0 8px 0", + margin: "8px 0 8px 0" } })); -export default function AddRedeem({ open, onClose,products ,onSuccess}) { +export default function AddRedeem({ open, onClose, products, onSuccess }) { const classes = useStyles(); const [input, setInput] = useState({ - num:1, - id:0, - time:1, + num: 1, + id: 0, + time: 1 }); - const [loading,setLoading] = useState(false); + const [loading, setLoading] = useState(false); const dispatch = useDispatch(); const ToggleSnackbar = useCallback( @@ -52,13 +51,13 @@ export default function AddRedeem({ open, onClose,products ,onSuccess}) { input.num = parseInt(input.num); input.id = parseInt(input.id); input.time = parseInt(input.time); - input.type=2; - for (let i=0;i { ToggleSnackbar("top", "right", error.message, "error"); - }).then(()=>{ + }) + .then(() => { setLoading(false); - }); - + }); }; return ( @@ -97,9 +96,9 @@ export default function AddRedeem({ open, onClose,products ,onSuccess}) { @@ -138,8 +143,8 @@ export default function AddRedeem({ open, onClose,products ,onSuccess}) { - - - - diff --git a/src/component/Admin/Dialogs/FileFilter.js b/src/component/Admin/Dialogs/FileFilter.js index 224dc78..3d8bb30 100644 --- a/src/component/Admin/Dialogs/FileFilter.js +++ b/src/component/Admin/Dialogs/FileFilter.js @@ -13,13 +13,13 @@ import { useDispatch } from "react-redux"; import { toggleSnackbar } from "../../../actions"; import API from "../../../middleware/Api"; -export default function FileFilter({setFilter,setSearch,open, onClose }) { - const [input,setInput] = useState({ - policy_id:"all", - user_id:"", +export default function FileFilter({ setFilter, setSearch, open, onClose }) { + const [input, setInput] = useState({ + policy_id: "all", + user_id: "" }); - const [policies,setPolicies] = useState([]); - const [keywords,setKeywords] = useState(""); + const [policies, setPolicies] = useState([]); + const [keywords, setKeywords] = useState(""); const dispatch = useDispatch(); const ToggleSnackbar = useCallback( @@ -29,10 +29,10 @@ export default function FileFilter({setFilter,setSearch,open, onClose }) { ); const handleChange = name => event => { - setInput({...input,[name]:event.target.value}) - } + setInput({ ...input, [name]: event.target.value }); + }; - useEffect(()=>{ + useEffect(() => { API.post("/admin/policy/list", { page: 1, page_size: 10000, @@ -45,25 +45,25 @@ export default function FileFilter({setFilter,setSearch,open, onClose }) { .catch(error => { ToggleSnackbar("top", "right", error.message, "error"); }); - },[]) + }, []); const submit = () => { const res = {}; - Object.keys(input).forEach(v=>{ - if(input[v] !== "all" && input[v] !== ""){ + Object.keys(input).forEach(v => { + if (input[v] !== "all" && input[v] !== "") { res[v] = input[v]; } - }) + }); setFilter(res); - if (keywords !== ""){ + if (keywords !== "") { setSearch({ - name:keywords, + name: keywords }); - }else{ + } else { setSearch({}); } onClose(); - } + }; return ( - - 过滤条件 - + 过滤条件 - 存储策略 + + 存储策略 + - - + + - - setKeywords(e.target.value)} id="standard-basic" label="搜索 文件名" /> + + setKeywords(e.target.value)} + id="standard-basic" + label="搜索 文件名" + /> diff --git a/src/component/Admin/Dialogs/MagicVar.js b/src/component/Admin/Dialogs/MagicVar.js index 178055d..a2b4a83 100644 --- a/src/component/Admin/Dialogs/MagicVar.js +++ b/src/component/Admin/Dialogs/MagicVar.js @@ -11,7 +11,7 @@ import TableHead from "@material-ui/core/TableHead"; import TableRow from "@material-ui/core/TableRow"; import React from "react"; -export default function MagicVar({isFile, open, onClose, isSlave }) { +export default function MagicVar({ isFile, open, onClose, isSlave }) { return ( - {isFile?"文件名魔法变量":"路径魔法变量"} + {isFile ? "文件名魔法变量" : "路径魔法变量"} @@ -34,77 +34,113 @@ export default function MagicVar({isFile, open, onClose, isSlave }) { - {"{randomkey16}"} + + {"{randomkey16}"} + 16位随机字符 N6IimT5XZP324ACK - {"{randomkey8}"} + + {"{randomkey8}"} + 8位随机字符 gWz78q30 - {"{timestamp}"} + + {"{timestamp}"} + 秒级时间戳 1582692933 - {"{timestamp_nano}"} + + {"{timestamp_nano}"} + 纳秒级时间戳 1582692933231834600 - {!isSlave && - {"{uid}"} - 用户ID - 1 - } - {isFile && - {"{originname}"} - 原始文件名 - MyPico.mp4 - } - {!isFile && !isSlave && - {"{path}"} - 用户上传路径 - /我的文件/学习资料/ - } + {!isSlave && ( + + + {"{uid}"} + + 用户ID + 1 + + )} + {isFile && ( + + + {"{originname}"} + + 原始文件名 + MyPico.mp4 + + )} + {!isFile && !isSlave && ( + + + {"{path}"} + + 用户上传路径 + /我的文件/学习资料/ + + )} - {"{date}"} + + {"{date}"} + 日期 20060102 - {"{datetime}"} + + {"{datetime}"} + 日期时间 20060102150405 - {"{year}"} + + {"{year}"} + 年份 2006 - {"{month}"} + + {"{month}"} + 月份 01 - {"{day}"} + + {"{day}"} + 02 - {"{hour}"} + + {"{hour}"} + 小时 15 - {"{minute}"} + + {"{minute}"} + 分钟 04 - {"{second}"} + + {"{second}"} + 05 diff --git a/src/component/Admin/Dialogs/ShareFilter.js b/src/component/Admin/Dialogs/ShareFilter.js index 7a118a7..b68d185 100644 --- a/src/component/Admin/Dialogs/ShareFilter.js +++ b/src/component/Admin/Dialogs/ShareFilter.js @@ -10,34 +10,34 @@ import Select from "@material-ui/core/Select"; import TextField from "@material-ui/core/TextField"; import React, { useState } from "react"; -export default function ShareFilter({setFilter,setSearch,open, onClose }) { - const [input,setInput] = useState({ - is_dir:"all", - user_id:"", +export default function ShareFilter({ setFilter, setSearch, open, onClose }) { + const [input, setInput] = useState({ + is_dir: "all", + user_id: "" }); - const [keywords,setKeywords] = useState(""); + const [keywords, setKeywords] = useState(""); const handleChange = name => event => { - setInput({...input,[name]:event.target.value}) - } + setInput({ ...input, [name]: event.target.value }); + }; const submit = () => { const res = {}; - Object.keys(input).forEach(v=>{ - if(input[v] !== "all" && input[v] !== ""){ + Object.keys(input).forEach(v => { + if (input[v] !== "all" && input[v] !== "") { res[v] = input[v]; } - }) + }); setFilter(res); - if (keywords !== ""){ + if (keywords !== "") { setSearch({ - source_name:keywords, + source_name: keywords }); - }else{ + } else { setSearch({}); } onClose(); - } + }; return ( - - 过滤条件 - + 过滤条件 - 源文件类型 + + 源文件类型 + - - + + - - setKeywords(e.target.value)} id="standard-basic" label="搜索 文件名" /> + + setKeywords(e.target.value)} + id="standard-basic" + label="搜索 文件名" + /> diff --git a/src/component/Admin/Dialogs/UserFilter.js b/src/component/Admin/Dialogs/UserFilter.js index 2b548c0..9e3a3e5 100644 --- a/src/component/Admin/Dialogs/UserFilter.js +++ b/src/component/Admin/Dialogs/UserFilter.js @@ -13,13 +13,13 @@ import { useDispatch } from "react-redux"; import { toggleSnackbar } from "../../../actions"; import API from "../../../middleware/Api"; -export default function UserFilter({setFilter,setSearch,open, onClose }) { - const [input,setInput] = useState({ - group_id:"all", - status:"all", +export default function UserFilter({ setFilter, setSearch, open, onClose }) { + const [input, setInput] = useState({ + group_id: "all", + status: "all" }); - const [groups,setGroups] = useState([]); - const [keywords,setKeywords] = useState(""); + const [groups, setGroups] = useState([]); + const [keywords, setKeywords] = useState(""); const dispatch = useDispatch(); const ToggleSnackbar = useCallback( @@ -29,10 +29,10 @@ export default function UserFilter({setFilter,setSearch,open, onClose }) { ); const handleChange = name => event => { - setInput({...input,[name]:event.target.value}) - } + setInput({ ...input, [name]: event.target.value }); + }; - useEffect(()=>{ + useEffect(() => { API.get("/admin/groups") .then(response => { setGroups(response.data); @@ -40,26 +40,26 @@ export default function UserFilter({setFilter,setSearch,open, onClose }) { .catch(error => { ToggleSnackbar("top", "right", error.message, "error"); }); - },[]) + }, []); const submit = () => { const res = {}; - Object.keys(input).forEach(v=>{ - if(input[v] !== "all"){ + Object.keys(input).forEach(v => { + if (input[v] !== "all") { res[v] = input[v]; } - }) + }); setFilter(res); - if (keywords !== ""){ + if (keywords !== "") { setSearch({ - nick:keywords, - email:keywords, + nick: keywords, + email: keywords }); - }else{ + } else { setSearch({}); } onClose(); - } + }; return ( - - 过滤条件 - + 过滤条件 - 用户组 + + 用户组 + - - 用户状态 + + + 用户状态 + - - setKeywords(e.target.value)} id="standard-basic" label="搜索 昵称 / 用户名" /> + + setKeywords(e.target.value)} + id="standard-basic" + label="搜索 昵称 / 用户名" + /> diff --git a/src/component/Admin/Group/EditGroup.js b/src/component/Admin/Group/EditGroup.js index 4a3d7d9..8569cd9 100644 --- a/src/component/Admin/Group/EditGroup.js +++ b/src/component/Admin/Group/EditGroup.js @@ -1,14 +1,14 @@ -import React, {useCallback, useEffect, useState} from "react"; -import {useParams} from "react-router"; +import React, { useCallback, useEffect, useState } from "react"; +import { useParams } from "react-router"; import API from "../../../middleware/Api"; -import {useDispatch} from "react-redux"; -import {toggleSnackbar} from "../../../actions"; +import { useDispatch } from "react-redux"; +import { toggleSnackbar } from "../../../actions"; import GroupForm from "./GroupForm"; -export default function EditGroupPreload( ) { - const [group,setGroup] = useState({}); +export default function EditGroupPreload() { + const [group, setGroup] = useState({}); - const {id } = useParams(); + const { id } = useParams(); const dispatch = useDispatch(); const ToggleSnackbar = useCallback( @@ -17,14 +17,13 @@ export default function EditGroupPreload( ) { [dispatch] ); - - useEffect(()=>{ + useEffect(() => { setGroup({}); API.get("/admin/group/" + id) .then(response => { // 布尔值转换 ["ShareEnabled", "WebDAVEnabled"].forEach(v => { - response.data[v] = response.data[v]?"true":"false"; + response.data[v] = response.data[v] ? "true" : "false"; }); [ "archive_download", @@ -33,8 +32,11 @@ export default function EditGroupPreload( ) { "share_download", "aria2" ].forEach(v => { - if (response.data.OptionsSerialized[v] !== undefined){ - response.data.OptionsSerialized[v] = response.data.OptionsSerialized[v]?"true":"false"; + if (response.data.OptionsSerialized[v] !== undefined) { + response.data.OptionsSerialized[v] = response.data + .OptionsSerialized[v] + ? "true" + : "false"; } }); @@ -42,40 +44,41 @@ export default function EditGroupPreload( ) { ["MaxStorage", "SpeedLimit"].forEach(v => { response.data[v] = response.data[v].toString(); }); - [ - "compress_size", - "decompress_size", - ].forEach(v => { - if (response.data.OptionsSerialized[v] !== undefined){ - response.data.OptionsSerialized[v] = response.data.OptionsSerialized[v].toString(); + ["compress_size", "decompress_size"].forEach(v => { + if (response.data.OptionsSerialized[v] !== undefined) { + response.data.OptionsSerialized[ + v + ] = response.data.OptionsSerialized[v].toString(); } }); response.data.PolicyList = response.data.PolicyList[0]; // JSON转换 - if(response.data.OptionsSerialized.aria2_options === undefined){ - response.data.OptionsSerialized.aria2_options = "{}" - }else{ + if ( + response.data.OptionsSerialized.aria2_options === undefined + ) { + response.data.OptionsSerialized.aria2_options = "{}"; + } else { try { - response.data.OptionsSerialized.aria2_options = JSON.stringify(response.data.OptionsSerialized.aria2_options); - }catch (e) { - ToggleSnackbar("top", "right", "Aria2 设置项格式错误", "warning"); + response.data.OptionsSerialized.aria2_options = JSON.stringify( + response.data.OptionsSerialized.aria2_options + ); + } catch (e) { + ToggleSnackbar( + "top", + "right", + "Aria2 设置项格式错误", + "warning" + ); return; } - } setGroup(response.data); }) .catch(error => { ToggleSnackbar("top", "right", error.message, "error"); }); - },[id]); + }, [id]); - return ( -
- {group.ID !== undefined && - - } -
- ); + return
{group.ID !== undefined && }
; } diff --git a/src/component/Admin/Group/Group.js b/src/component/Admin/Group/Group.js index 415ba87..91648ab 100644 --- a/src/component/Admin/Group/Group.js +++ b/src/component/Admin/Group/Group.js @@ -69,7 +69,6 @@ function useQuery() { return new URLSearchParams(useLocation().search); } - export default function Group() { const classes = useStyles(); const [groups, setGroups] = useState([]); @@ -91,37 +90,41 @@ export default function Group() { ); const loadList = () => { - API.post("/admin/group/list", { - page: page, - page_size: pageSize, - order_by: "id desc", - }) - .then(response => { - setGroups(response.data.items); - setStatics(response.data.statics); - setTotal(response.data.total); - setPolicies(response.data.policies); - }) - .catch(error => { - ToggleSnackbar("top", "right", error.message, "error"); - }); + API.post("/admin/group/list", { + page: page, + page_size: pageSize, + order_by: "id desc" + }) + .then(response => { + setGroups(response.data.items); + setStatics(response.data.statics); + setTotal(response.data.total); + setPolicies(response.data.policies); + }) + .catch(error => { + ToggleSnackbar("top", "right", error.message, "error"); + }); }; - useEffect(()=>{ - if(query.get("code") === "0"){ + useEffect(() => { + if (query.get("code") === "0") { ToggleSnackbar("top", "right", "授权成功", "success"); - }else if (query.get("msg") && query.get("msg")!==""){ - ToggleSnackbar("top", "right", query.get("msg") + ", "+ query.get("err"), "warning"); + } else if (query.get("msg") && query.get("msg") !== "") { + ToggleSnackbar( + "top", + "right", + query.get("msg") + ", " + query.get("err"), + "warning" + ); } - - },[location]) + }, [location]); useEffect(() => { loadList(); }, [page, pageSize]); - const deletePolicy = (id) =>{ - API.delete("/admin/group/" + id,) + const deletePolicy = id => { + API.delete("/admin/group/" + id) .then(() => { loadList(); ToggleSnackbar("top", "right", "用户组已删除", "success"); @@ -129,7 +132,7 @@ export default function Group() { .catch(error => { ToggleSnackbar("top", "right", error.message, "error"); }); - } + }; return (
@@ -156,7 +159,7 @@ export default function Group() { - + {columns.map(column => ( {row.ID} {row.Name} - {row.PolicyList !== null && row.PolicyList.map((pid,key)=>{ - let res = ""; - if (policies[pid]){ - res += policies[pid].Name; - } - if (key !== row.PolicyList.length-1){ - res += " / "; - } - return res - })} + {row.PolicyList !== null && + row.PolicyList.map((pid, key) => { + let res = ""; + if (policies[pid]) { + res += policies[pid].Name; + } + if ( + key !== + row.PolicyList.length - 1 + ) { + res += " / "; + } + return res; + })} {statics[row.ID] !== undefined && @@ -195,16 +202,28 @@ export default function Group() { - deletePolicy(row.ID)} size={"small"}> - + + deletePolicy(row.ID) + } + size={"small"} + > + - history.push("/admin/group/edit/" + row.ID)} size={"small"}> - + + history.push( + "/admin/group/edit/" + + row.ID + ) + } + size={"small"} + > + - ))} diff --git a/src/component/Admin/Group/GroupForm.js b/src/component/Admin/Group/GroupForm.js index 3492edc..5ca4f41 100644 --- a/src/component/Admin/Group/GroupForm.js +++ b/src/component/Admin/Group/GroupForm.js @@ -152,8 +152,9 @@ export default function GroupForm(props) { "share_download", "aria2" ].forEach(v => { - if (groupCopy.OptionsSerialized[v] !== undefined){ - groupCopy.OptionsSerialized[v] = groupCopy.OptionsSerialized[v] === "true"; + if (groupCopy.OptionsSerialized[v] !== undefined) { + groupCopy.OptionsSerialized[v] = + groupCopy.OptionsSerialized[v] === "true"; } }); @@ -161,19 +162,20 @@ export default function GroupForm(props) { ["MaxStorage", "SpeedLimit"].forEach(v => { groupCopy[v] = parseInt(groupCopy[v]); }); - [ - "compress_size", - "decompress_size", - ].forEach(v => { - if (groupCopy.OptionsSerialized[v] !== undefined){ - groupCopy.OptionsSerialized[v] = parseInt(groupCopy.OptionsSerialized[v]); + ["compress_size", "decompress_size"].forEach(v => { + if (groupCopy.OptionsSerialized[v] !== undefined) { + groupCopy.OptionsSerialized[v] = parseInt( + groupCopy.OptionsSerialized[v] + ); } }); groupCopy.PolicyList = [parseInt(groupCopy.PolicyList)]; // JSON转换 try { - groupCopy.OptionsSerialized.aria2_options = JSON.parse(groupCopy.OptionsSerialized.aria2_options); - }catch (e) { + groupCopy.OptionsSerialized.aria2_options = JSON.parse( + groupCopy.OptionsSerialized.aria2_options + ); + } catch (e) { ToggleSnackbar("top", "right", "Aria2 设置项格式错误", "warning"); return; } @@ -184,7 +186,12 @@ export default function GroupForm(props) { }) .then(() => { history.push("/admin/group"); - ToggleSnackbar("top", "right", "用户组已"+ (props.group ? "保存" : "添加"), "success"); + ToggleSnackbar( + "top", + "right", + "用户组已" + (props.group ? "保存" : "添加"), + "success" + ); }) .catch(error => { ToggleSnackbar("top", "right", error.message, "error"); @@ -192,7 +199,6 @@ export default function GroupForm(props) { .then(() => { setLoading(false); }); - }; return ( @@ -205,68 +211,71 @@ export default function GroupForm(props) {
+ {group.ID !== 3 && ( + <> +
+ + + 用户组名 + + + + 用户组的名称 + + +
- {group.ID !== 3 && <> -
- - - 用户组名 - - +
+ + + 存储策略 + + + + 指定用户组的存储策略。 + + +
+ +
+ + + - 用户组的名称 + 用户组下的用户初始可用最大容量 - -
- -
- - - 存储策略 - - - - 指定用户组的存储策略。 - - -
- -
- - - - - 用户组下的用户初始可用最大容量 - -
- } - +
+ + )}
@@ -286,27 +295,29 @@ export default function GroupForm(props) {
- {group.ID !== 3 &&
- - - } - label="允许创建分享" - /> - - 关闭后,用户无法创建分享链接 - - -
} - + {group.ID !== 3 && ( +
+ + + } + label="允许创建分享" + /> + + 关闭后,用户无法创建分享链接 + + +
+ )}
@@ -330,26 +341,30 @@ export default function GroupForm(props) {
- {group.ID !== 3 &&
- - - } - label="WebDAV" - /> - - 关闭后,用户无法通过 WebDAV 协议连接至网盘 - - -
} + {group.ID !== 3 && ( +
+ + + } + label="WebDAV" + /> + + 关闭后,用户无法通过 WebDAV + 协议连接至网盘 + + +
+ )}
@@ -374,28 +389,29 @@ export default function GroupForm(props) {
- {group.ID !== 3 &&
- - - } - label="离线下载" - /> - - 是否允许用户创建离线下载任务 - - -
} - + {group.ID !== 3 && ( +
+ + + } + label="离线下载" + /> + + 是否允许用户创建离线下载任务 + + +
+ )}
@@ -445,27 +461,29 @@ export default function GroupForm(props) {
- {group.ID !== 3 &&
- - - } - label="压缩/解压缩 任务" - /> - - 是否用户创建 压缩/解压缩 任务 - - -
} + {group.ID !== 3 && ( +
+ + + } + label="压缩/解压缩 任务" + /> + + 是否用户创建 压缩/解压缩 任务 + + +
+ )} { + const ResetSiteURL = () => { setOpen(false); - API.patch("/admin/setting",{ - options:[{ - key:"siteURL", - value:window.location.origin, - }], + API.patch("/admin/setting", { + options: [ + { + key: "siteURL", + value: window.location.origin + } + ] }) .then(() => { setSiteURL(window.location.origin); @@ -113,7 +135,7 @@ export default function Index() { .catch(error => { ToggleSnackbar("top", "right", error.message, "error"); }); - } + }; useEffect(() => { API.get("/admin/summary") @@ -136,7 +158,10 @@ export default function Index() { }); setVersion(response.data.version); setSiteURL(response.data.siteURL); - if (response.data.siteURL === "" || response.data.siteURL !== window.location.origin){ + if ( + response.data.siteURL === "" || + response.data.siteURL !== window.location.origin + ) { setOpen(true); } }) @@ -165,27 +190,36 @@ export default function Index() { setOpen(false)} + onClose={() => setOpen(false)} aria-labelledby="alert-dialog-title" aria-describedby="alert-dialog-description" > - {"确定站点URL设置"} + + {"确定站点URL设置"} + - {siteURL === "" && "您尚未设定站点URL,是否要将其设定为当前的 "+ window.location.origin + " ?"} - {siteURL !== "" && "您设置的站点URL与当前实际不一致,是否要将其设定为当前的 "+ window.location.origin + " ?"} + {siteURL === "" && + "您尚未设定站点URL,是否要将其设定为当前的 " + + window.location.origin + + " ?"} + {siteURL !== "" && + "您设置的站点URL与当前实际不一致,是否要将其设定为当前的 " + + window.location.origin + + " ?"} - 此设置非常重要,请确保其与您站点的实际地址一致。你可以在 参数设置 - 站点信息 中更改此设置。 + 此设置非常重要,请确保其与您站点的实际地址一致。你可以在 + 参数设置 - 站点信息 中更改此设置。 - + - - @@ -294,7 +328,10 @@ export default function Index() { Cloudreve - {version.backend} {version.is_pro === "true" && } + {version.backend}{" "} + {version.is_pro === "true" && ( + + )}
@@ -334,9 +371,7 @@ export default function Index() { - window.open( - "https://docs.cloudreve.org/" - ) + window.open("https://docs.cloudreve.org/") } > @@ -385,7 +420,7 @@ export default function Index() { ) } > - + @@ -400,58 +435,72 @@ export default function Index() { - {news && news.map((v) => ( - <> - window.open("https://forum.cloudreve.org/d/" + v.id)} - > - - - - - - {newsUsers[ + {news && + news.map(v => ( + <> + + window.open( + "https://forum.cloudreve.org/d/" + + v.id + ) + } + > + + + + + + {newsUsers[ v.relationships .startUser.data .id - ].username}{" "} - - 发表于{" "} - - - } - /> - - - - ))} + ] && + newsUsers[ + v.relationships + .startUser + .data.id + ].username}{" "} + + 发表于{" "} + + + } + /> + + + + ))} diff --git a/src/component/Admin/Policy/AddPolicy.js b/src/component/Admin/Policy/AddPolicy.js index bca62eb..fff9f6f 100644 --- a/src/component/Admin/Policy/AddPolicy.js +++ b/src/component/Admin/Policy/AddPolicy.js @@ -20,11 +20,10 @@ const useStyles = makeStyles(theme => ({ }, content: { padding: theme.spacing(2) - }, + } })); - -export default function AddPolicyParent( ) { +export default function AddPolicyParent() { const classes = useStyles(); const { type } = useParams(); @@ -32,14 +31,14 @@ export default function AddPolicyParent( ) { return (
- {type==="local"&&} - {type==="remote"&&} - {type==="qiniu"&&} - {type==="oss"&&} - {type==="upyun"&&} - {type==="cos"&&} - {type==="onedrive"&&} - {type==="s3"&&()} + {type === "local" && } + {type === "remote" && } + {type === "qiniu" && } + {type === "oss" && } + {type === "upyun" && } + {type === "cos" && } + {type === "onedrive" && } + {type === "s3" && }
); diff --git a/src/component/Admin/Policy/EditPolicy.js b/src/component/Admin/Policy/EditPolicy.js index f53d19c..e7b80ff 100644 --- a/src/component/Admin/Policy/EditPolicy.js +++ b/src/component/Admin/Policy/EditPolicy.js @@ -24,16 +24,15 @@ const useStyles = makeStyles(theme => ({ }, content: { padding: theme.spacing(2) - }, + } })); - -export default function EditPolicyPreload( ) { +export default function EditPolicyPreload() { const classes = useStyles(); - const [type,setType] = useState(""); - const [policy,setPolicy] = useState({}); + const [type, setType] = useState(""); + const [policy, setPolicy] = useState({}); - const { mode,id } = useParams(); + const { mode, id } = useParams(); const dispatch = useDispatch(); const ToggleSnackbar = useCallback( @@ -42,46 +41,52 @@ export default function EditPolicyPreload( ) { [dispatch] ); - - useEffect(()=>{ + useEffect(() => { setType(""); API.get("/admin/policy/" + id) .then(response => { - response.data.IsOriginLinkEnable = response.data.IsOriginLinkEnable ? "true" : "false"; - response.data.AutoRename = response.data.AutoRename ? "true" : "false"; - response.data.MaxSize = response.data.MaxSize.toString(); - response.data.IsPrivate = response.data.IsPrivate ? "true" : "false"; - response.data.OptionsSerialized.file_type = - response.data.OptionsSerialized.file_type ? - response.data.OptionsSerialized.file_type.join(","): - ""; + response.data.IsOriginLinkEnable = response.data + .IsOriginLinkEnable + ? "true" + : "false"; + response.data.AutoRename = response.data.AutoRename + ? "true" + : "false"; + response.data.MaxSize = response.data.MaxSize.toString(); + response.data.IsPrivate = response.data.IsPrivate + ? "true" + : "false"; + response.data.OptionsSerialized.file_type = response.data + .OptionsSerialized.file_type + ? response.data.OptionsSerialized.file_type.join(",") + : ""; setPolicy(response.data); setType(response.data.Type); }) .catch(error => { ToggleSnackbar("top", "right", error.message, "error"); }); - },[id]); + }, [id]); return (
- {mode === "guide" && + {mode === "guide" && ( <> - {type==="local"&&} - {type==="remote"&&} - {type==="qiniu"&&} - {type==="oss"&&} - {type==="upyun"&&} - {type==="cos"&&} - {type==="onedrive"&&} - {type==="s3"&&} + {type === "local" && } + {type === "remote" && } + {type === "qiniu" && } + {type === "oss" && } + {type === "upyun" && } + {type === "cos" && } + {type === "onedrive" && ( + + )} + {type === "s3" && } - } + )} - {mode === "pro" && type !== "" && - - } + {mode === "pro" && type !== "" && }
); diff --git a/src/component/Admin/Policy/Guid/COSGuide.js b/src/component/Admin/Policy/Guid/COSGuide.js index 9ad5cd0..d134bc5 100644 --- a/src/component/Admin/Policy/Guid/COSGuide.js +++ b/src/component/Admin/Policy/Guid/COSGuide.js @@ -67,16 +67,17 @@ const useStyles = makeStyles(theme => ({ marginRight: theme.spacing(1) }, viewButtonLabel: { textTransform: "none" }, - "@global":{ - "code":{ + "@global": { + code: { color: "rgba(0, 0, 0, 0.87)", display: "inline-block", padding: "2px 6px", - fontFamily:" Consolas, \"Liberation Mono\", Menlo, Courier, monospace", + fontFamily: + ' Consolas, "Liberation Mono", Menlo, Courier, monospace', borderRadius: "2px", - backgroundColor: "rgba(255,229,100,0.1)", - }, - }, + backgroundColor: "rgba(255,229,100,0.1)" + } + } })); const steps = [ @@ -119,25 +120,31 @@ export default function COSGuide(props) { const [skipped, setSkipped] = React.useState(new Set()); const [magicVar, setMagicVar] = useState(""); const [useCDN, setUseCDN] = useState("false"); - const [policy, setPolicy] = useState(props.policy?props.policy:{ - Type: "cos", - Name: "", - SecretKey: "", - AccessKey: "", - BaseURL: "", - Server: "", - IsPrivate: "true", - DirNameRule: "uploads/{year}/{month}/{day}", - AutoRename: "true", - FileNameRule: "{randomkey8}_{originname}", - IsOriginLinkEnable: "false", - MaxSize: "0", - OptionsSerialized: { - file_type: "", - } - }); - const [policyID,setPolicyID] = useState(props.policy?props.policy.ID:0); - const [region,setRegion] = useState("ap-chengdu"); + const [policy, setPolicy] = useState( + props.policy + ? props.policy + : { + Type: "cos", + Name: "", + SecretKey: "", + AccessKey: "", + BaseURL: "", + Server: "", + IsPrivate: "true", + DirNameRule: "uploads/{year}/{month}/{day}", + AutoRename: "true", + FileNameRule: "{randomkey8}_{originname}", + IsOriginLinkEnable: "false", + MaxSize: "0", + OptionsSerialized: { + file_type: "" + } + } + ); + const [policyID, setPolicyID] = useState( + props.policy ? props.policy.ID : 0 + ); + const [region, setRegion] = useState("ap-chengdu"); const handleChange = name => event => { setPolicy({ @@ -174,8 +181,8 @@ export default function COSGuide(props) { const policyCopy = { ...policy }; policyCopy.OptionsSerialized = { ...policyCopy.OptionsSerialized }; - if (useCDN === "false"){ - policyCopy.BaseURL = policy.Server + if (useCDN === "false") { + policyCopy.BaseURL = policy.Server; } // 类型转换 @@ -198,7 +205,12 @@ export default function COSGuide(props) { policy: policyCopy }) .then(response => { - ToggleSnackbar("top", "right", "存储策略已"+ (props.policy ? "保存" : "添加"), "success"); + ToggleSnackbar( + "top", + "right", + "存储策略已" + (props.policy ? "保存" : "添加"), + "success" + ); setActiveStep(4); setPolicyID(response.data); }) @@ -212,7 +224,7 @@ export default function COSGuide(props) { setLoading(false); }; - const createCORS = ()=>{ + const createCORS = () => { setLoading(true); API.post("/admin/policy/cors", { id: policyID @@ -227,14 +239,13 @@ export default function COSGuide(props) { .then(() => { setLoading(false); }); + }; - } - - const creatCallback = ()=>{ + const creatCallback = () => { setLoading(true); API.post("/admin/policy/scf", { id: policyID, - region:region, + region: region }) .then(() => { ToggleSnackbar("top", "right", "回调云函数已添加", "success"); @@ -246,11 +257,13 @@ export default function COSGuide(props) { .then(() => { setLoading(false); }); - } + }; return (
- {props.policy ? "修改" : "添加"} 腾讯云 COS 存储策略 + + {props.policy ? "修改" : "添加"} 腾讯云 COS 存储策略 + {steps.map((label, index) => { const stepProps = {}; @@ -279,15 +292,15 @@ export default function COSGuide(props) { setActiveStep(1); }} > -
0
- 在使用 腾讯云 COS 储策略前,请确保您在 参数设置 - 站点信息 - - 站点URL 中填写的 地址与实际相符,并且 + 在使用 腾讯云 COS 储策略前,请确保您在 参数设置 + - 站点信息 - 站点URL 中填写的 + 地址与实际相符,并且 能够被外网正常访问
@@ -301,7 +314,9 @@ export default function COSGuide(props) { 前往 COS 管理控制台 @@ -317,7 +332,8 @@ export default function COSGuide(props) {
- 转到所创建存储桶的基础配置页面,将空间名称填写在下方: + 转到所创建存储桶的基础配置页面,将 + 空间名称填写在下方:
@@ -326,8 +342,9 @@ export default function COSGuide(props) {
- 转到所创建 Bucket 的基础配置,填写基本信息栏目下 - 给出的 访问域名 + 转到所创建 Bucket 的基础配置,填写 + 基本信息栏目下 给出的{" "} + 访问域名
{ - setUseCDN(e.target.value) + onChange={e => { + setUseCDN(e.target.value); }} row > @@ -442,11 +460,17 @@ export default function COSGuide(props) {
前往 - + 腾讯云 CDN 管理控制台 - 创建 CDN 加速域名,并设定源站为刚创建的 COS 存储桶。在下方填写 - CDN 加速域名,并选择是否使用 HTTPS: + 创建 CDN 加速域名,并设定源站为刚创建的 COS + 存储桶。在下方填写 CDN + 加速域名,并选择是否使用 HTTPS:
-
{getNumber(6,[ - useCDN === "true" - ])}
+
+ {getNumber(6, [useCDN === "true"])} +
在腾讯云 - + 访问密钥 - 页面获取 一对访问密钥,并填写在下方。请确保这对密钥拥有 COS 和 SCF 服务的访问权限。 + 页面获取 + 一对访问密钥,并填写在下方。请确保这对密钥拥有 + COS 和 SCF 服务的访问权限。
@@ -482,8 +513,8 @@ export default function COSGuide(props) {
-
{getNumber(7,[ - useCDN === "true" - ])}
+
+ {getNumber(7, [useCDN === "true"])} +
@@ -567,9 +598,9 @@ export default function COSGuide(props) { 可用魔法变量可参考{" "} { - e.preventDefault() - setMagicVar("path") + onClick={e => { + e.preventDefault(); + setMagicVar("path"); }} > 路径魔法变量列表 @@ -602,9 +633,9 @@ export default function COSGuide(props) { 可用魔法变量可参考{" "} { - e.preventDefault() - setMagicVar("file") + onClick={e => { + e.preventDefault(); + setMagicVar("file"); }} > 文件名魔法变量列表 @@ -703,14 +734,22 @@ export default function COSGuide(props) { { - if (policy.IsPrivate === "true" && e.target.value==="true"){ - ToggleSnackbar("top", "right","私有空间无法开启此功能", "warning"); - return + onChange={e => { + if ( + policy.IsPrivate === "true" && + e.target.value === "true" + ) { + ToggleSnackbar( + "top", + "right", + "私有空间无法开启此功能", + "warning" + ); + return; } - handleChange( - "IsOriginLinkEnable" - )(e) + handleChange("IsOriginLinkEnable")( + e + ); }} row > @@ -755,10 +794,7 @@ export default function COSGuide(props) { )} {activeStep === 3 && ( -
+
1
@@ -952,11 +988,13 @@ export default function COSGuide(props) { {activeStep === 4 && (
-
+
- COS 存储桶 需要正确配置跨域策略后才能使用 Web 端上传文件,Cloudreve - 可以帮您自动设置,您也可以参考文档步骤手动设置。如果您已设置过此 Bucket 的跨域策略,此步骤可以跳过。 + COS 存储桶 需要正确配置跨域策略后才能使用 Web + 端上传文件,Cloudreve + 可以帮您自动设置,您也可以参考文档步骤手动设置。如果您已设置过此 + Bucket 的跨域策略,此步骤可以跳过。
{" "} @@ -996,16 +1036,28 @@ export default function COSGuide(props) { {activeStep === 5 && (
-
+
COS 存储桶 客户端直传需要借助腾讯云的 - 云函数 - 产品以确保上传回调可控。如果您打算将此存储策略自用,或者分配给可信赖用户组,此步骤可以跳过。 - 如果是作为公有使用,请务必创建回调云函数。

+ + 云函数 + + 产品以确保上传回调可控。如果您打算将此存储策略自用,或者分配给可信赖用户组,此步骤可以跳过。 + 如果是作为公有使用,请务必创建回调云函数。 +
+
+
+ + Cloudreve 可以尝试帮你自动创建回调云函数,请选择 + COS 存储桶 所在地域后继续。 + 创建可能会花费数秒钟,请耐心等待。创建前请确保您的腾讯云账号已开启云函数服务。 - Cloudreve 可以尝试帮你自动创建回调云函数,请选择 COS 存储桶 所在地域后继续。 - 创建可能会花费数秒钟,请耐心等待。创建前请确保您的腾讯云账号已开启云函数服务。
@@ -1014,19 +1066,41 @@ export default function COSGuide(props) {
@@ -1037,7 +1111,7 @@ export default function COSGuide(props) { color={"secondary"} variant={"contained"} className={classes.button} - onClick={()=>creatCallback()} + onClick={() => creatCallback()} classes={{ label: classes.viewButtonLabel }} > 让 Cloudreve 帮我创建 @@ -1049,16 +1123,18 @@ export default function COSGuide(props) { {" "} @@ -1069,7 +1145,9 @@ export default function COSGuide(props) { {activeStep === 6 && ( <> - 存储策略已{props.policy ? "保存" : "添加"}! + + 存储策略已{props.policy ? "保存" : "添加"}! + 要使用此存储策略,请到用户组管理页面,为相应用户组绑定此存储策略。 diff --git a/src/component/Admin/Policy/Guid/LocalGuide.js b/src/component/Admin/Policy/Guid/LocalGuide.js index 0b5307d..b193d17 100644 --- a/src/component/Admin/Policy/Guid/LocalGuide.js +++ b/src/component/Admin/Policy/Guid/LocalGuide.js @@ -104,7 +104,7 @@ export default function LocalGuide(props) { FileNameRule: "{randomkey8}_{originname}", IsOriginLinkEnable: "false", BaseURL: "", - IsPrivate:"true", + IsPrivate: "true", MaxSize: "0", OptionsSerialized: { file_type: "" @@ -249,9 +249,9 @@ export default function LocalGuide(props) { 可用魔法变量可参考{" "} { - e.preventDefault() - setMagicVar("path") + onClick={e => { + e.preventDefault(); + setMagicVar("path"); }} > 路径魔法变量列表 @@ -284,9 +284,9 @@ export default function LocalGuide(props) { 可用魔法变量可参考{" "} { - e.preventDefault() - setMagicVar("file") + onClick={e => { + e.preventDefault(); + setMagicVar("file"); }} > 文件名魔法变量列表 diff --git a/src/component/Admin/Policy/Guid/QiniuGuide.js b/src/component/Admin/Policy/Guid/QiniuGuide.js index 2b1d8f8..8b17255 100644 --- a/src/component/Admin/Policy/Guid/QiniuGuide.js +++ b/src/component/Admin/Policy/Guid/QiniuGuide.js @@ -95,26 +95,30 @@ export default function RemoteGuide(props) { const [activeStep, setActiveStep] = useState(0); const [loading, setLoading] = useState(false); - const [skipped,] = React.useState(new Set()); + const [skipped] = React.useState(new Set()); const [magicVar, setMagicVar] = useState(""); // const [useCDN, setUseCDN] = useState("false"); - const [policy, setPolicy] = useState(props.policy?props.policy:{ - Type: "qiniu", - Name: "", - SecretKey: "", - AccessKey: "", - BaseURL: "", - IsPrivate: "true", - DirNameRule: "uploads/{year}/{month}/{day}", - AutoRename: "true", - FileNameRule: "{randomkey8}_{originname}", - IsOriginLinkEnable: "false", - MaxSize: "0", - OptionsSerialized: { - file_type: "", - mimetype:"", - } - }); + const [policy, setPolicy] = useState( + props.policy + ? props.policy + : { + Type: "qiniu", + Name: "", + SecretKey: "", + AccessKey: "", + BaseURL: "", + IsPrivate: "true", + DirNameRule: "uploads/{year}/{month}/{day}", + AutoRename: "true", + FileNameRule: "{randomkey8}_{originname}", + IsOriginLinkEnable: "false", + MaxSize: "0", + OptionsSerialized: { + file_type: "", + mimetype: "" + } + } + ); const handleChange = name => event => { setPolicy({ @@ -171,7 +175,12 @@ export default function RemoteGuide(props) { policy: policyCopy }) .then(() => { - ToggleSnackbar("top", "right", "存储策略已"+ (props.policy ? "保存" : "添加"), "success"); + ToggleSnackbar( + "top", + "right", + "存储策略已" + (props.policy ? "保存" : "添加"), + "success" + ); setActiveStep(5); }) .catch(error => { @@ -186,7 +195,9 @@ export default function RemoteGuide(props) { return (
- {props.policy ? "修改" : "添加"} 七牛 存储策略 + + {props.policy ? "修改" : "添加"} 七牛 存储策略 + {steps.map((label, index) => { const stepProps = {}; @@ -215,15 +226,14 @@ export default function RemoteGuide(props) { setActiveStep(1); }} > -
0
- 在使用七牛存储策略前,请确保您在 参数设置 - 站点信息 - - 站点URL 中填写的 地址与实际相符,并且 + 在使用七牛存储策略前,请确保您在 参数设置 - + 站点信息 - 站点URL 中填写的 地址与实际相符,并且 能够被外网正常访问
@@ -394,9 +404,9 @@ export default function RemoteGuide(props) { 可用魔法变量可参考{" "} { - e.preventDefault() - setMagicVar("path") + onClick={e => { + e.preventDefault(); + setMagicVar("path"); }} > 路径魔法变量列表 @@ -429,9 +439,9 @@ export default function RemoteGuide(props) { 可用魔法变量可参考{" "} { - e.preventDefault() - setMagicVar("file") + onClick={e => { + e.preventDefault(); + setMagicVar("file"); }} > 文件名魔法变量列表 @@ -530,14 +540,22 @@ export default function RemoteGuide(props) { { - if (policy.IsPrivate === "true" && e.target.value==="true"){ - ToggleSnackbar("top", "right","私有空间无法开启此功能", "warning"); - return + onChange={e => { + if ( + policy.IsPrivate === "true" && + e.target.value === "true" + ) { + ToggleSnackbar( + "top", + "right", + "私有空间无法开启此功能", + "warning" + ); + return; } - handleChange( - "IsOriginLinkEnable" - )(e) + handleChange("IsOriginLinkEnable")( + e + ); }} row > @@ -762,9 +780,9 @@ export default function RemoteGuide(props) {
- {getNumber(3,[ + {getNumber(3, [ policy.MaxSize !== "0", - policy.OptionsSerialized.file_type !== "", + policy.OptionsSerialized.file_type !== "" ])}
@@ -789,8 +807,7 @@ export default function RemoteGuide(props) { ...policy, OptionsSerialized: { ...policy.OptionsSerialized, - mimetype: - "image/*" + mimetype: "image/*" } }); } else { @@ -829,16 +846,18 @@ export default function RemoteGuide(props) {
- {getNumber(4,[ + {getNumber(4, [ policy.MaxSize !== "0", - policy.OptionsSerialized.file_type !== "", + policy.OptionsSerialized.file_type !== + "" ])}
输入允许上传的 MimeType,多个请以半角逗号 , - 隔开。七牛服务器会侦测文件内容以判断 MimeType,再用判断值跟指定值进行匹配,匹配成功则允许上传 + 隔开。七牛服务器会侦测文件内容以判断 + MimeType,再用判断值跟指定值进行匹配,匹配成功则允许上传
@@ -925,7 +944,9 @@ export default function RemoteGuide(props) { {activeStep === 5 && ( <> - 存储策略已{props.policy ? "保存" : "添加"}! + + 存储策略已{props.policy ? "保存" : "添加"}! + 要使用此存储策略,请到用户组管理页面,为相应用户组绑定此存储策略。 diff --git a/src/component/Admin/Policy/Guid/RemoteGuide.js b/src/component/Admin/Policy/Guid/RemoteGuide.js index 37a59e8..5e50943 100644 --- a/src/component/Admin/Policy/Guid/RemoteGuide.js +++ b/src/component/Admin/Policy/Guid/RemoteGuide.js @@ -39,13 +39,13 @@ const useStyles = makeStyles(theme => ({ subStepContainer: { display: "flex", marginBottom: 20, - padding:10, + padding: 10, transition: theme.transitions.create("background-color", { easing: theme.transitions.easing.sharp, duration: theme.transitions.duration.leavingScreen }), - "&:focus-within":{ - backgroundColor:theme.palette.background.default, + "&:focus-within": { + backgroundColor: theme.palette.background.default } }, stepNumber: { @@ -57,35 +57,35 @@ const useStyles = makeStyles(theme => ({ borderRadius: " 50%" }, stepNumberContainer: { - marginRight: 10, + marginRight: 10 }, - stepFooter:{ - marginTop: 32, + stepFooter: { + marginTop: 32 }, button: { - marginRight: theme.spacing(1), + marginRight: theme.spacing(1) }, - "@global":{ - "code":{ + "@global": { + code: { color: "rgba(0, 0, 0, 0.87)", display: "inline-block", padding: "2px 6px", fontSize: "14px", - fontFamily:" Consolas, \"Liberation Mono\", Menlo, Courier, monospace", + fontFamily: + ' Consolas, "Liberation Mono", Menlo, Courier, monospace', borderRadius: "2px", - backgroundColor: "rgba(255,229,100,0.1)", + backgroundColor: "rgba(255,229,100,0.1)" }, - "pre":{ + pre: { margin: "24px 0", padding: "12px 18px", overflow: "auto", direction: "ltr", borderRadius: "4px", backgroundColor: "#272c34", - color:"#fff", + color: "#fff" } - }, - + } })); const steps = [ @@ -117,25 +117,29 @@ export default function RemoteGuide(props) { const [activeStep, setActiveStep] = useState(0); const [loading, setLoading] = useState(false); - const [skipped,] = React.useState(new Set()); - const [magicVar,setMagicVar] = useState(""); - const [useCDN,setUseCDN] = useState("false"); - const [policy, setPolicy] = useState(props.policy?props.policy:{ - Type:"remote", - Name:"", - Server:"https://example.com:5212", - SecretKey:randomStr(64), - DirNameRule: "uploads/{year}/{month}/{day}", - AutoRename: "true", - FileNameRule: "{randomkey8}_{originname}", - IsOriginLinkEnable:"false", - BaseURL:"", - IsPrivate:"true", - MaxSize:"0", - OptionsSerialized:{ - file_type:"", - }, - }); + const [skipped] = React.useState(new Set()); + const [magicVar, setMagicVar] = useState(""); + const [useCDN, setUseCDN] = useState("false"); + const [policy, setPolicy] = useState( + props.policy + ? props.policy + : { + Type: "remote", + Name: "", + Server: "https://example.com:5212", + SecretKey: randomStr(64), + DirNameRule: "uploads/{year}/{month}/{day}", + AutoRename: "true", + FileNameRule: "{randomkey8}_{originname}", + IsOriginLinkEnable: "false", + BaseURL: "", + IsPrivate: "true", + MaxSize: "0", + OptionsSerialized: { + file_type: "" + } + } + ); const handleChange = name => event => { setPolicy({ @@ -147,10 +151,10 @@ export default function RemoteGuide(props) { const handleOptionChange = name => event => { setPolicy({ ...policy, - OptionsSerialized:{ + OptionsSerialized: { ...policy.OptionsSerialized, [name]: event.target.value - }, + } }); }; @@ -165,13 +169,13 @@ export default function RemoteGuide(props) { [dispatch] ); - const testSlave = ()=>{ + const testSlave = () => { setLoading(true); // 测试路径是否可用 API.post("/admin/policy/test/slave", { server: policy.Server, - secret:policy.SecretKey, + secret: policy.SecretKey }) .then(() => { ToggleSnackbar("top", "right", "通信正常", "success"); @@ -188,21 +192,27 @@ export default function RemoteGuide(props) { e.preventDefault(); setLoading(true); - const policyCopy = {...policy}; - policyCopy.OptionsSerialized = {...policyCopy.OptionsSerialized}; + const policyCopy = { ...policy }; + policyCopy.OptionsSerialized = { ...policyCopy.OptionsSerialized }; // 处理存储策略 - if (useCDN === "false" || policy.IsOriginLinkEnable === "false"){ - policyCopy.BaseURL = "" + if (useCDN === "false" || policy.IsOriginLinkEnable === "false") { + policyCopy.BaseURL = ""; } // 类型转换 policyCopy.AutoRename = policyCopy.AutoRename === "true"; - policyCopy.IsOriginLinkEnable = policyCopy.IsOriginLinkEnable === "true"; + policyCopy.IsOriginLinkEnable = + policyCopy.IsOriginLinkEnable === "true"; policyCopy.MaxSize = parseInt(policyCopy.MaxSize); policyCopy.IsPrivate = policyCopy.IsPrivate === "true"; - policyCopy.OptionsSerialized.file_type = policyCopy.OptionsSerialized.file_type.split(","); - if (policyCopy.OptionsSerialized.file_type.length === 1 && policyCopy.OptionsSerialized.file_type[0] === ""){ + policyCopy.OptionsSerialized.file_type = policyCopy.OptionsSerialized.file_type.split( + "," + ); + if ( + policyCopy.OptionsSerialized.file_type.length === 1 && + policyCopy.OptionsSerialized.file_type[0] === "" + ) { policyCopy.OptionsSerialized.file_type = []; } @@ -210,7 +220,12 @@ export default function RemoteGuide(props) { policy: policyCopy }) .then(() => { - ToggleSnackbar("top", "right", "存储策略已" + (props.policy ? "保存" : "添加"), "success"); + ToggleSnackbar( + "top", + "right", + "存储策略已" + (props.policy ? "保存" : "添加"), + "success" + ); setActiveStep(5); }) .catch(error => { @@ -221,12 +236,13 @@ export default function RemoteGuide(props) { }); setLoading(false); - - } + }; return (
- {props.policy ? "修改" : "添加"}从机存储策略 + + {props.policy ? "修改" : "添加"}从机存储策略 + {steps.map((label, index) => { const stepProps = {}; @@ -250,14 +266,14 @@ export default function RemoteGuide(props) { {activeStep === 0 && ( { + onSubmit={e => { e.preventDefault(); setActiveStep(1); }} > - - 从机存储策略允许你使用同样运行了 Cloudreve 的服务器作为存储端, - 用户上传下载流量通过 HTTP 直传。 + + 从机存储策略允许你使用同样运行了 Cloudreve + 的服务器作为存储端, 用户上传下载流量通过 HTTP 直传。
@@ -266,7 +282,8 @@ export default function RemoteGuide(props) {
- 将和主站相同版本的 Cloudreve 程序拷贝至要作为从机的服务器上。 + 将和主站相同版本的 Cloudreve + 程序拷贝至要作为从机的服务器上。
@@ -288,7 +305,7 @@ export default function RemoteGuide(props) {
- 修改从机配置文件。
在从机端 Cloudreve 的同级目录下新建 - conf.ini文件,填入从机配置,启动/重启从机端 Cloudreve。 + 修改从机配置文件。 +
+ 在从机端 Cloudreve 的同级目录下新建 + conf.ini + 文件,填入从机配置,启动/重启从机端 Cloudreve。 以下为一个可供参考的配置例子,其中密钥部分已帮您填写为上一步所生成的。
-
-                                    [System]
- Mode = slave
- Listen = :5212
-
- [Slave]
- Secret = {policy.SecretKey}
-
- [CORS]
- AllowOrigins = *
- AllowMethods = OPTIONS,GET,POST
- AllowHeaders = *
-
+
+                                [System]
+                                
+ Mode = slave +
+ Listen = :5212 +
+
+ [Slave] +
+ Secret = {policy.SecretKey} +
+
+ [CORS] +
+ AllowOrigins = *
+ AllowMethods = OPTIONS,GET,POST +
+ AllowHeaders = *
+
从机端配置文件格式大致与主站端相同,区别在于:
    @@ -331,11 +358,15 @@ export default function RemoteGuide(props) { 字段必须更改为slave
  • - 必须指定Slave分区下的Secret + 必须指定Slave分区下的 + Secret 字段,其值为第二步里填写或生成的密钥。
  • -
  • 必须启动跨域配置,即CORS字段的内容, - 具体可参考上文范例或官方文档。如果配置不正确,用户将无法通过 Web 端向从机上传文件。 +
  • + 必须启动跨域配置,即CORS + 字段的内容, + 具体可参考上文范例或官方文档。如果配置不正确,用户将无法通过 + Web 端向从机上传文件。
@@ -348,8 +379,11 @@ export default function RemoteGuide(props) {
- 填写从机地址。
- 如果主站启用了 HTTPS,从机也需要启用,并在下方填入 HTTPS 协议的地址。 + 填写从机地址。 +
+ 如果主站启用了 + HTTPS,从机也需要启用,并在下方填入 HTTPS + 协议的地址。
@@ -379,7 +413,7 @@ export default function RemoteGuide(props) {
- )} {activeStep === 1 && (
{ + onSubmit={e => { e.preventDefault(); setActiveStep(2); }} @@ -418,13 +451,14 @@ export default function RemoteGuide(props) {
请在下方输入文件的存储目录路径,可以为绝对路径或相对路径(相对于 - 从机的 Cloudreve)。路径中可以使用魔法变量,文件在上传时会自动替换这些变量为相应值; + 从机的 + Cloudreve)。路径中可以使用魔法变量,文件在上传时会自动替换这些变量为相应值; 可用魔法变量可参考{" "} { - e.preventDefault() - setMagicVar("path") + onClick={e => { + e.preventDefault(); + setMagicVar("path"); }} > 路径魔法变量列表 @@ -457,9 +491,9 @@ export default function RemoteGuide(props) { 可用魔法变量可参考{" "} { - e.preventDefault() - setMagicVar("file") + onClick={e => { + e.preventDefault(); + setMagicVar("file"); }} > 文件名魔法变量列表 @@ -500,7 +534,9 @@ export default function RemoteGuide(props) { 命名规则 setActiveStep(0)} + onClick={() => setActiveStep(0)} > 上一步 @@ -535,9 +571,9 @@ export default function RemoteGuide(props) { {activeStep === 2 && ( { + onSubmit={e => { e.preventDefault(); - setActiveStep(3); + setActiveStep(3); }} >
@@ -590,7 +626,8 @@ export default function RemoteGuide(props) { 是否要对下载/直链使用 CDN?
- 开启后,用户访问文件时的 URL 中的域名部分会被替换为 CDN 域名。 + 开启后,用户访问文件时的 URL + 中的域名部分会被替换为 CDN 域名。
@@ -598,14 +635,16 @@ export default function RemoteGuide(props) { { - if (e.target.value === "false"){ + onChange={e => { + if ( + e.target.value === "false" + ) { setPolicy({ ...policy, BaseURL: "" }); } - setUseCDN(e.target.value) + setUseCDN(e.target.value); }} row > @@ -626,7 +665,6 @@ export default function RemoteGuide(props) {
-
@@ -644,26 +682,26 @@ export default function RemoteGuide(props) {
-
-
- {" "} + {" "}
- )} {activeStep === 3 && ( -
{ - e.preventDefault(); - setActiveStep(4) - }} + { + e.preventDefault(); + setActiveStep(4); + }} > -
1
@@ -698,17 +735,21 @@ export default function RemoteGuide(props) { { - if(e.target.value === "true"){ + value={ + policy.MaxSize === "0" + ? "false" + : "true" + } + onChange={e => { + if (e.target.value === "true") { setPolicy({ ...policy, - MaxSize: "10485760", + MaxSize: "10485760" }); - }else{ + } else { setPolicy({ ...policy, - MaxSize: "0", + MaxSize: "0" }); } }} @@ -752,15 +793,15 @@ export default function RemoteGuide(props) { label={"单文件大小限制"} />
-
-
-
{policy.MaxSize !== "0" ? "3" : "2"}
+
+ {policy.MaxSize !== "0" ? "3" : "2"} +
@@ -771,23 +812,29 @@ export default function RemoteGuide(props) { { - if(e.target.value === "true"){ + value={ + policy.OptionsSerialized + .file_type === "" + ? "false" + : "true" + } + onChange={e => { + if (e.target.value === "true") { setPolicy({ ...policy, OptionsSerialized: { ...policy.OptionsSerialized, - file_type:"jpg,png,mp4,zip,rar", - }, + file_type: + "jpg,png,mp4,zip,rar" + } }); - }else{ + } else { setPolicy({ ...policy, OptionsSerialized: { ...policy.OptionsSerialized, - file_type:"", - }, + file_type: "" + } }); } }} @@ -816,11 +863,14 @@ export default function RemoteGuide(props) {
-
{policy.MaxSize !== "0" ? "4" : "3"}
+
+ {policy.MaxSize !== "0" ? "4" : "3"} +
- 输入允许上传的文件扩展名,多个请以半角逗号 , 隔开 + 输入允许上传的文件扩展名,多个请以半角逗号 , + 隔开
@@ -828,28 +878,28 @@ export default function RemoteGuide(props) { 扩展名列表
-
-
- {" "} + {" "}
- )} {activeStep === 4 && (
-
- -
+
最后一步,为此存储策略命名: @@ -891,11 +938,10 @@ export default function RemoteGuide(props) { - {" "} + {" "}
- )} {activeStep === 5 && ( <> -
- - 存储策略已{props.policy ? "保存" : "添加"}! - - - 要使用此存储策略,请到用户组管理页面,为相应用户组绑定此存储策略。 - - +
+ + 存储策略已{props.policy ? "保存" : "添加"}! + + + 要使用此存储策略,请到用户组管理页面,为相应用户组绑定此存储策略。 + +
- - )} + + )} setAlertOpen(false)} + onClose={() => setAlertOpen(false)} title={"警告"} - msg={"S3 类型存储策略目前仅可用于自己使用,或者是给受信任的用户组使用。"} + msg={ + "S3 类型存储策略目前仅可用于自己使用,或者是给受信任的用户组使用。" + } /> {props.policy ? "修改" : "添加"} Amazon S3 存储策略 @@ -436,9 +438,11 @@ export default function S3Guide(props) { freeSolo value={policy.OptionsSerialized.region} onInputChange={(_, value) => - handleOptionChange("region")({target:{value:value}}) + handleOptionChange("region")({ + target: { value: value } + }) } - renderOption={(option) => ( + renderOption={option => ( {regions[option]} diff --git a/src/component/Admin/Policy/Guid/UpyunGuide.js b/src/component/Admin/Policy/Guid/UpyunGuide.js index fdb8305..8f8bec7 100644 --- a/src/component/Admin/Policy/Guid/UpyunGuide.js +++ b/src/component/Admin/Policy/Guid/UpyunGuide.js @@ -94,25 +94,29 @@ export default function UpyunGuide(props) { const [activeStep, setActiveStep] = useState(0); const [loading, setLoading] = useState(false); - const [skipped,] = React.useState(new Set()); + const [skipped] = React.useState(new Set()); const [magicVar, setMagicVar] = useState(""); - const [policy, setPolicy] = useState(props.policy?props.policy:{ - Type: "upyun", - Name: "", - SecretKey: "", - AccessKey: "", - BaseURL: "", - IsPrivate: "false", - DirNameRule: "uploads/{year}/{month}/{day}", - AutoRename: "true", - FileNameRule: "{randomkey8}_{originname}", - IsOriginLinkEnable: "false", - MaxSize: "0", - OptionsSerialized: { - file_type: "", - token:"", - } - }); + const [policy, setPolicy] = useState( + props.policy + ? props.policy + : { + Type: "upyun", + Name: "", + SecretKey: "", + AccessKey: "", + BaseURL: "", + IsPrivate: "false", + DirNameRule: "uploads/{year}/{month}/{day}", + AutoRename: "true", + FileNameRule: "{randomkey8}_{originname}", + IsOriginLinkEnable: "false", + MaxSize: "0", + OptionsSerialized: { + file_type: "", + token: "" + } + } + ); const handleChange = name => event => { setPolicy({ @@ -169,7 +173,12 @@ export default function UpyunGuide(props) { policy: policyCopy }) .then(() => { - ToggleSnackbar("top", "right", "存储策略已"+ (props.policy ? "保存" : "添加"), "success"); + ToggleSnackbar( + "top", + "right", + "存储策略已" + (props.policy ? "保存" : "添加"), + "success" + ); setActiveStep(5); }) .catch(error => { @@ -184,7 +193,9 @@ export default function UpyunGuide(props) { return (
- {props.policy ? "修改" : "添加"} 又拍云 存储策略 + + {props.policy ? "修改" : "添加"} 又拍云 存储策略 + {steps.map((label, index) => { const stepProps = {}; @@ -213,15 +224,14 @@ export default function UpyunGuide(props) { setActiveStep(1); }} > -
0
- 在使用又拍云存储策略前,请确保您在 参数设置 - 站点信息 - - 站点URL 中填写的 地址与实际相符,并且 + 在使用又拍云存储策略前,请确保您在 参数设置 - + 站点信息 - 站点URL 中填写的 地址与实际相符,并且 能够被外网正常访问
@@ -235,7 +245,9 @@ export default function UpyunGuide(props) { 前往 又拍云面板 @@ -309,7 +321,8 @@ export default function UpyunGuide(props) {
- 填写为云存储服务绑定的域名,并根据实际情况选择是否使用 HTTPS: + 填写为云存储服务绑定的域名,并根据实际情况选择是否使用 + HTTPS:
- 此步骤可保持默认并跳过,但是强烈建议您跟随此步骤操作。
- 前往所创建云存储服务的 功能配置 面板,转到 访问配置 选项卡,开启 Token 防盗链并设定密码。 + 此步骤可保持默认并跳过,但是强烈建议您跟随此步骤操作。 +
+ 前往所创建云存储服务的 功能配置 面板,转到 + 访问配置 选项卡,开启 Token 防盗链并设定密码。
@@ -362,9 +377,7 @@ export default function UpyunGuide(props) {
-
- 6 -
+
6
@@ -377,13 +390,14 @@ export default function UpyunGuide(props) {
@@ -391,7 +405,6 @@ export default function UpyunGuide(props) {
-
- + {columns.map(column => ( - deletePolicy(row.ID)} size={"small"}> - + + deletePolicy(row.ID) + } + size={"small"} + > + - { - setEditID(row.ID) - handleClick(e) - }} size={"small"}> - + { + setEditID(row.ID); + handleClick(e); + }} + size={"small"} + > + - ))} @@ -264,14 +274,22 @@ export default function Policy() { onClose={handleClose} keepMounted > - { - handleClose(e); - history.push("/admin/policy/edit/pro/"+editID); - }}>专家模式编辑 - { - handleClose(e); - history.push("/admin/policy/edit/guide/"+editID); - }}>向导模式编辑 + { + handleClose(e); + history.push("/admin/policy/edit/pro/" + editID); + }} + > + 专家模式编辑 + + { + handleClose(e); + history.push("/admin/policy/edit/guide/" + editID); + }} + > + 向导模式编辑 + ); diff --git a/src/component/Admin/Setting/Access.js b/src/component/Admin/Setting/Access.js index ef1153c..0e25758 100644 --- a/src/component/Admin/Setting/Access.js +++ b/src/component/Admin/Setting/Access.js @@ -320,7 +320,8 @@ export default function Access() { target={"_blank"} > 应用管理页面 - {" "}获取到的的 秘钥 + {" "} + 获取到的的 秘钥 diff --git a/src/component/Admin/Setting/Aria2.js b/src/component/Admin/Setting/Aria2.js index 602e381..24d438f 100644 --- a/src/component/Admin/Setting/Aria2.js +++ b/src/component/Admin/Setting/Aria2.js @@ -152,7 +152,9 @@ export default function Aria2() { Aria2 的配置文件中开启 RPC 服务。更多信息及指引请参考文档的{" "} 离线下载 diff --git a/src/component/Admin/Setting/Image.js b/src/component/Admin/Setting/Image.js index 13716fa..e933baa 100644 --- a/src/component/Admin/Setting/Image.js +++ b/src/component/Admin/Setting/Image.js @@ -36,18 +36,18 @@ export default function ImageSetting() { const classes = useStyles(); const [loading, setLoading] = useState(false); const [options, setOptions] = useState({ - gravatar_server:"", - avatar_path:"", - avatar_size:"", - avatar_size_l:"", - avatar_size_m:"", - avatar_size_s:"", - thumb_width:"", - thumb_height:"", - captcha_height:"1", - captcha_width:"1", - captcha_mode:"3", - captcha_CaptchaLen:"", + gravatar_server: "", + avatar_path: "", + avatar_size: "", + avatar_size_l: "", + avatar_size_m: "", + avatar_size_s: "", + thumb_width: "", + thumb_height: "", + captcha_height: "1", + captcha_width: "1", + captcha_mode: "3", + captcha_CaptchaLen: "" }); const handleChange = name => event => { @@ -77,34 +77,33 @@ export default function ImageSetting() { // eslint-disable-next-line }, []); - const submit = e => { e.preventDefault(); setLoading(true); const option = []; - Object.keys(options).forEach(k=>{ + Object.keys(options).forEach(k => { option.push({ - key:k, - value:options[k], + key: k, + value: options[k] }); - }) - API.patch("/admin/setting",{ - options:option, + }); + API.patch("/admin/setting", { + options: option }) .then(() => { ToggleSnackbar("top", "right", "设置已更改", "success"); }) .catch(error => { ToggleSnackbar("top", "right", error.message, "error"); - }).then(()=>{ + }) + .then(() => { setLoading(false); - }); + }); }; return (
-
头像 @@ -167,8 +166,8 @@ export default function ImageSetting() {
-
@@ -230,8 +228,8 @@ export default function ImageSetting() { -
@@ -276,8 +273,8 @@ export default function ImageSetting() {
- diff --git a/src/component/Admin/Setting/Mail.js b/src/component/Admin/Setting/Mail.js index e9ec11e..e0d597b 100644 --- a/src/component/Admin/Setting/Mail.js +++ b/src/component/Admin/Setting/Mail.js @@ -53,7 +53,7 @@ export default function Mail() { replyTo: "", smtpUser: "", smtpPass: "", - smtpEncryption:"", + smtpEncryption: "", mail_keepalive: "30", mail_activation_template: "", mail_reset_pwd_template: "" @@ -254,7 +254,7 @@ export default function Mail() { SMTP 端口
-
@@ -403,7 +402,6 @@ export default function Mail() {
-
diff --git a/src/component/Admin/Setting/SiteInformation.js b/src/component/Admin/Setting/SiteInformation.js index b6f9ac3..a03f520 100644 --- a/src/component/Admin/Setting/SiteInformation.js +++ b/src/component/Admin/Setting/SiteInformation.js @@ -76,28 +76,28 @@ export default function SiteInformation() { // eslint-disable-next-line }, []); - const submit = e => { e.preventDefault(); setLoading(true); const option = []; - Object.keys(options).forEach(k=>{ + Object.keys(options).forEach(k => { option.push({ - key:k, - value:options[k], + key: k, + value: options[k] }); - }) - API.patch("/admin/setting",{ - options:option, + }); + API.patch("/admin/setting", { + options: option }) .then(() => { ToggleSnackbar("top", "right", "设置已更改", "success"); }) .catch(error => { ToggleSnackbar("top", "right", error.message, "error"); - }).then(()=>{ + }) + .then(() => { setLoading(false); - }); + }); }; return ( @@ -254,7 +254,6 @@ export default function SiteInformation() { value={options.pwa_display} onChange={handleChange("pwa_display")} > - fullscreen diff --git a/src/component/Admin/Setting/Theme.js b/src/component/Admin/Setting/Theme.js index b6a740b..f4944f1 100644 --- a/src/component/Admin/Setting/Theme.js +++ b/src/component/Admin/Setting/Theme.js @@ -56,9 +56,9 @@ export default function Theme() { const [theme, setTheme] = useState({}); const [options, setOptions] = useState({ themes: "{}", - defaultTheme:"", - home_view_method:"icon", - share_view_method:"list", + defaultTheme: "", + home_view_method: "icon", + share_view_method: "list" }); const [themeConfig, setThemeConfig] = useState({}); const [themeConfigError, setThemeConfigError] = useState({}); @@ -72,39 +72,44 @@ export default function Theme() { ); const deleteTheme = color => { - if(color === options.defaultTheme){ + if (color === options.defaultTheme) { ToggleSnackbar("top", "right", "不能删除默认配色", "warning"); - return + return; } - if (Object.keys(theme).length <=1){ + if (Object.keys(theme).length <= 1) { ToggleSnackbar("top", "right", "请至少保留一个配色方案", "warning"); - return + return; } - const themeCopy = {...theme}; + const themeCopy = { ...theme }; delete themeCopy[color]; const resStr = JSON.stringify(themeCopy); setOptions({ ...options, - themes:resStr, - }) - } + themes: resStr + }); + }; const addTheme = newTheme => { setCreate(false); - if (theme[newTheme.palette.primary.main] !== undefined){ - ToggleSnackbar("top", "right", "主色调不能与已有配色重复", "warning"); - return + if (theme[newTheme.palette.primary.main] !== undefined) { + ToggleSnackbar( + "top", + "right", + "主色调不能与已有配色重复", + "warning" + ); + return; } const res = { ...theme, - [newTheme.palette.primary.main]:newTheme, + [newTheme.palette.primary.main]: newTheme }; const resStr = JSON.stringify(res); setOptions({ ...options, - themes:resStr, - }) - } + themes: resStr + }); + }; useEffect(() => { const res = JSON.parse(options.themes); @@ -165,7 +170,6 @@ export default function Theme() { return (
-
主题配色 @@ -236,14 +240,31 @@ export default function Theme() { const res = JSON.parse( e.target.value ); - if( - !('palette' in res) || - !('primary' in res.palette) || - !('main' in res.palette.primary) || - !('secondary' in res.palette) || - !('main' in res.palette.secondary) - ){ - throw e + if ( + !( + "palette" in + res + ) || + !( + "primary" in + res.palette + ) || + !( + "main" in + res.palette + .primary + ) || + !( + "secondary" in + res.palette + ) || + !( + "main" in + res.palette + .secondary + ) + ) { + throw e; } setTheme({ ...theme, @@ -267,7 +288,11 @@ export default function Theme() { /> - deleteTheme(k)}> + + deleteTheme(k) + } + > @@ -279,17 +304,19 @@ export default function Theme() {
- + - 完整的配置项可在 {" "} + 完整的配置项可在{" "} 默认主题 - Material-UI @@ -297,7 +324,6 @@ export default function Theme() { 查阅。 -
@@ -309,7 +335,7 @@ export default function Theme() { value={options.defaultTheme} onChange={handleChange("defaultTheme")} > - {Object.keys(theme).map(k=>( + {Object.keys(theme).map(k => (
@@ -347,7 +367,6 @@ export default function Theme() {
-
@@ -368,7 +387,9 @@ export default function Theme() { required > 大图标 - 小图标 + + 小图标 + 列表 @@ -390,7 +411,9 @@ export default function Theme() { required > 大图标 - 小图标 + + 小图标 + 列表 @@ -399,7 +422,6 @@ export default function Theme() { -
@@ -414,7 +436,11 @@ export default function Theme() {
- setCreate(false)}/> + setCreate(false)} + /> ); } diff --git a/src/component/Admin/Setting/UploadDownload.js b/src/component/Admin/Setting/UploadDownload.js index 7b9600b..b8576ca 100644 --- a/src/component/Admin/Setting/UploadDownload.js +++ b/src/component/Admin/Setting/UploadDownload.js @@ -37,26 +37,26 @@ export default function UploadDownload() { const [loading, setLoading] = useState(false); const [options, setOptions] = useState({ max_worker_num: "1", - max_parallel_transfer:"1", - temp_path:"", - maxEditSize:"0", - onedrive_chunk_retries:"0", - archive_timeout:"0", - download_timeout:"0", - preview_timeout:"0", - doc_preview_timeout:"0", - upload_credential_timeout:"0", - upload_session_timeout:"0", - slave_api_timeout:"0", - onedrive_monitor_timeout:"0", - share_download_session_timeout:"0", - onedrive_callback_check:"0", - reset_after_upload_failed:"0", - onedrive_source_timeout:"0", + max_parallel_transfer: "1", + temp_path: "", + maxEditSize: "0", + onedrive_chunk_retries: "0", + archive_timeout: "0", + download_timeout: "0", + preview_timeout: "0", + doc_preview_timeout: "0", + upload_credential_timeout: "0", + upload_session_timeout: "0", + slave_api_timeout: "0", + onedrive_monitor_timeout: "0", + share_download_session_timeout: "0", + onedrive_callback_check: "0", + reset_after_upload_failed: "0", + onedrive_source_timeout: "0" }); const handleCheckChange = name => event => { - const value= event.target.checked ? "1" : "0"; + const value = event.target.checked ? "1" : "0"; setOptions({ ...options, [name]: value @@ -90,57 +90,56 @@ export default function UploadDownload() { // eslint-disable-next-line }, []); - const submit = e => { e.preventDefault(); setLoading(true); const option = []; - Object.keys(options).forEach(k=>{ + Object.keys(options).forEach(k => { option.push({ - key:k, - value:options[k], + key: k, + value: options[k] }); - }) - API.patch("/admin/setting",{ - options:option, + }); + API.patch("/admin/setting", { + options: option }) .then(() => { ToggleSnackbar("top", "right", "设置已更改", "success"); }) .catch(error => { ToggleSnackbar("top", "right", error.message, "error"); - }).then(()=>{ + }) + .then(() => { setLoading(false); - }); + }); }; return (
-
存储与传输
-
- + Worker 数量 - 任务队列最多并行执行的任务数,保存后需要重启 Cloudreve 生效 + 任务队列最多并行执行的任务数,保存后需要重启 + Cloudreve 生效
@@ -153,11 +152,13 @@ export default function UploadDownload() { @@ -199,22 +200,25 @@ export default function UploadDownload() {
- + OneDrive 分片错误重试 - OneDrive 存储策略分片上传失败后重试的最大次数,只适用于服务端上传或中转 + OneDrive + 存储策略分片上传失败后重试的最大次数,只适用于服务端上传或中转
@@ -225,7 +229,8 @@ export default function UploadDownload() { control={
-
@@ -249,17 +253,16 @@ export default function UploadDownload() {
-
- + 打包下载
- + 下载会话
- + 预览链接
- + Office 文档预览连接
- + 上传凭证
- + 上传会话 @@ -362,15 +371,15 @@ export default function UploadDownload() {
- + 从机API请求
- + 分享下载会话 @@ -401,69 +414,77 @@ export default function UploadDownload() {
- + OneDrive 客户端上传监控间隔 - 每间隔所设定时间,Cloudreve 会向 OneDrive 请求检查客户端上传情况已确保客户端上传可控 + 每间隔所设定时间,Cloudreve 会向 OneDrive + 请求检查客户端上传情况已确保客户端上传可控
- + OneDrive 回调等待 - OneDrive 客户端上传完成后,等待回调的最大时间,如果超出会被认为上传失败 + OneDrive + 客户端上传完成后,等待回调的最大时间,如果超出会被认为上传失败
- + OneDrive 下载请求缓存 - OneDrive 获取文件下载 URL 后可将结果缓存,减轻热门文件下载API请求频率 + OneDrive 获取文件下载 URL + 后可将结果缓存,减轻热门文件下载API请求频率
-
diff --git a/src/component/Admin/User/EditUser.js b/src/component/Admin/User/EditUser.js index bc0ab2a..2c91918 100644 --- a/src/component/Admin/User/EditUser.js +++ b/src/component/Admin/User/EditUser.js @@ -1,14 +1,14 @@ -import React, {useCallback, useEffect, useState} from "react"; -import {useParams} from "react-router"; +import React, { useCallback, useEffect, useState } from "react"; +import { useParams } from "react-router"; import API from "../../../middleware/Api"; -import {useDispatch} from "react-redux"; -import {toggleSnackbar} from "../../../actions"; +import { useDispatch } from "react-redux"; +import { toggleSnackbar } from "../../../actions"; import UserForm from "./UserForm"; -export default function EditUserPreload( ) { - const [user,setUser] = useState({}); +export default function EditUserPreload() { + const [user, setUser] = useState({}); - const {id } = useParams(); + const { id } = useParams(); const dispatch = useDispatch(); const ToggleSnackbar = useCallback( @@ -17,8 +17,7 @@ export default function EditUserPreload( ) { [dispatch] ); - - useEffect(()=>{ + useEffect(() => { setUser({}); API.get("/admin/user/" + id) .then(response => { @@ -31,13 +30,7 @@ export default function EditUserPreload( ) { .catch(error => { ToggleSnackbar("top", "right", error.message, "error"); }); - },[id]); + }, [id]); - return ( -
- {user.ID !== undefined && - - } -
- ); + return
{user.ID !== undefined && }
; } diff --git a/src/component/Admin/User/UserForm.js b/src/component/Admin/User/UserForm.js index eb2d0da..e4ce713 100644 --- a/src/component/Admin/User/UserForm.js +++ b/src/component/Admin/User/UserForm.js @@ -43,7 +43,7 @@ export default function UserForm(props) { Nick: "", Password: "", // 为空时只读 Status: "0", // 转换类型 - GroupID: "2", // 转换类型 + GroupID: "2" // 转换类型 } ); const [groups, setGroups] = useState([]); @@ -76,21 +76,26 @@ export default function UserForm(props) { const submit = e => { e.preventDefault(); - const userCopy = {...user}; + const userCopy = { ...user }; // 整型转换 - ["Status", "GroupID","Score"].forEach(v => { + ["Status", "GroupID", "Score"].forEach(v => { userCopy[v] = parseInt(userCopy[v]); }); setLoading(true); API.post("/admin/user", { user: userCopy, - password:userCopy.Password, + password: userCopy.Password }) .then(() => { history.push("/admin/user"); - ToggleSnackbar("top", "right", "用户已"+ (props.user ? "保存" : "添加"), "success"); + ToggleSnackbar( + "top", + "right", + "用户已" + (props.user ? "保存" : "添加"), + "success" + ); }) .catch(error => { ToggleSnackbar("top", "right", error.message, "error"); @@ -110,7 +115,6 @@ export default function UserForm(props) {
-
@@ -162,9 +166,7 @@ export default function UserForm(props) { 正常 未激活 被封禁 - 超额使用被封禁 + + 超额使用被封禁 +
-
diff --git a/src/component/Common/Snackbar.js b/src/component/Common/Snackbar.js index b4fb928..bda7621 100644 --- a/src/component/Common/Snackbar.js +++ b/src/component/Common/Snackbar.js @@ -1,148 +1,153 @@ -import React, { Component } from 'react' -import PropTypes from 'prop-types'; -import { connect } from 'react-redux' +import React, { Component } from "react"; +import PropTypes from "prop-types"; +import { connect } from "react-redux"; +import {} from "../../actions"; +import classNames from "classnames"; +import ErrorIcon from "@material-ui/icons/Error"; +import InfoIcon from "@material-ui/icons/Info"; +import CloseIcon from "@material-ui/icons/Close"; +import CheckCircleIcon from "@material-ui/icons/CheckCircle"; +import WarningIcon from "@material-ui/icons/Warning"; + +import { green, amber } from "@material-ui/core/colors"; + import { - } from "../../actions" -import classNames from 'classnames'; -import ErrorIcon from '@material-ui/icons/Error'; -import InfoIcon from '@material-ui/icons/Info'; -import CloseIcon from '@material-ui/icons/Close'; -import CheckCircleIcon from '@material-ui/icons/CheckCircle'; -import WarningIcon from '@material-ui/icons/Warning'; - -import { green, amber } from '@material-ui/core/colors'; - -import { withStyles, SnackbarContent, Snackbar, IconButton } from '@material-ui/core'; + withStyles, + SnackbarContent, + Snackbar, + IconButton +} from "@material-ui/core"; const mapStateToProps = state => { return { - snackbar:state.viewUpdate.snackbar, - } -} + snackbar: state.viewUpdate.snackbar + }; +}; const mapDispatchToProps = () => { - return { - } -} + return {}; +}; const variantIcon = { success: CheckCircleIcon, warning: WarningIcon, error: ErrorIcon, - info: InfoIcon, - }; + info: InfoIcon +}; const styles1 = theme => ({ success: { - backgroundColor: green[600], - }, - error: { - backgroundColor: theme.palette.error.dark, - }, - info: { - backgroundColor: theme.palette.primary.dark, - }, - warning: { - backgroundColor: amber[700], - }, - icon: { - fontSize: 20, - }, - iconVariant: { + backgroundColor: green[600] + }, + error: { + backgroundColor: theme.palette.error.dark + }, + info: { + backgroundColor: theme.palette.primary.dark + }, + warning: { + backgroundColor: amber[700] + }, + icon: { + fontSize: 20 + }, + iconVariant: { opacity: 0.9, - marginRight: theme.spacing(1), - }, - message: { - display: 'flex', - alignItems: 'center', - }, -}) + marginRight: theme.spacing(1) + }, + message: { + display: "flex", + alignItems: "center" + } +}); function MySnackbarContent(props) { const { classes, className, message, onClose, variant, ...other } = props; const Icon = variantIcon[variant]; - + return ( - - - {message} - - } - action={[ - - - , - ]} - {...other} - /> + + + {message} + + } + action={[ + + + + ]} + {...other} + /> ); - } +} MySnackbarContent.propTypes = { - classes: PropTypes.object.isRequired, - className: PropTypes.string, - message: PropTypes.node, - onClose: PropTypes.func, - variant: PropTypes.oneOf(['success', 'warning', 'error', 'info']).isRequired, + classes: PropTypes.object.isRequired, + className: PropTypes.string, + message: PropTypes.node, + onClose: PropTypes.func, + variant: PropTypes.oneOf(["success", "warning", "error", "info"]).isRequired }; const MySnackbarContentWrapper = withStyles(styles1)(MySnackbarContent); const styles = theme => ({ margin: { - margin: theme.spacing(1), - }, -}) + margin: theme.spacing(1) + } +}); class SnackbarCompoment extends Component { + state = { + open: false + }; - state={ - open:false, - } - - UNSAFE_componentWillReceiveProps = (nextProps)=>{ - if(nextProps.snackbar.toggle !== this.props.snackbar.toggle){ - this.setState({open:true}); + UNSAFE_componentWillReceiveProps = nextProps => { + if (nextProps.snackbar.toggle !== this.props.snackbar.toggle) { + this.setState({ open: true }); } - } + }; + + handleClose = () => { + this.setState({ open: false }); + }; - handleClose= ()=>{ - this.setState({open:false}); - } - render() { - return ( - - + > + + ); } - } const AlertBar = connect( mapStateToProps, mapDispatchToProps -)( withStyles(styles)(SnackbarCompoment)) +)(withStyles(styles)(SnackbarCompoment)); -export default AlertBar \ No newline at end of file +export default AlertBar; diff --git a/src/component/Dial/Aria2.js b/src/component/Dial/Aria2.js index 37cee66..34eff8f 100644 --- a/src/component/Dial/Aria2.js +++ b/src/component/Dial/Aria2.js @@ -16,11 +16,10 @@ const useStyles = makeStyles(() => ({ left: "auto", zIndex: 5, position: "fixed" - }, + } })); export default function RemoteDownloadButton() { - const classes = useStyles(); const dispatch = useDispatch(); @@ -29,19 +28,18 @@ export default function RemoteDownloadButton() { [dispatch] ); - return ( <> - - - OpenRemoteDownloadDialog()} - > - - - - + + + OpenRemoteDownloadDialog()} + > + + + + ); } diff --git a/src/component/Dial/AutoHidden.js b/src/component/Dial/AutoHidden.js index 422b279..ab1e975 100644 --- a/src/component/Dial/AutoHidden.js +++ b/src/component/Dial/AutoHidden.js @@ -1,8 +1,7 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect } from "react"; import Zoom from "@material-ui/core/Zoom"; - -function AutoHidden ({ children, enable }){ +function AutoHidden({ children, enable }) { const [hidden, setHidden] = useState(false); let prev = window.scrollY; @@ -10,33 +9,29 @@ function AutoHidden ({ children, enable }){ const show = 50; useEffect(() => { - const handleNavigation = (e) => { + const handleNavigation = e => { const window = e.currentTarget; if (prev > window.scrollY) { - if (lastUpdate - window.scrollY > show){ + if (lastUpdate - window.scrollY > show) { lastUpdate = window.scrollY; setHidden(false); } } else if (prev < window.scrollY) { - if (window.scrollY - lastUpdate > show){ + if (window.scrollY - lastUpdate > show) { lastUpdate = window.scrollY; setHidden(true); } } prev = window.scrollY; }; - if (enable){ - window.addEventListener('scroll', e => handleNavigation(e)); + if (enable) { + window.addEventListener("scroll", e => handleNavigation(e)); } // eslint-disable-next-line - }, [enable]) + }, [enable]); - return ( - - {children} - - ) + return {children}; } -export default AutoHidden \ No newline at end of file +export default AutoHidden; diff --git a/src/component/Dial/Create.js b/src/component/Dial/Create.js index 387a55b..b77b759 100644 --- a/src/component/Dial/Create.js +++ b/src/component/Dial/Create.js @@ -5,12 +5,16 @@ import SpeedDialIcon from "@material-ui/lab/SpeedDialIcon"; import SpeedDialAction from "@material-ui/lab/SpeedDialAction"; import CreateNewFolderIcon from "@material-ui/icons/CreateNewFolder"; import PublishIcon from "@material-ui/icons/Publish"; -import { openCreateFileDialog, openCreateFolderDialog, toggleSnackbar } from "../../actions"; -import {useDispatch} from "react-redux"; +import { + openCreateFileDialog, + openCreateFolderDialog, + toggleSnackbar +} from "../../actions"; +import { useDispatch } from "react-redux"; import AutoHidden from "./AutoHidden"; -import statusHelper from "../../utils/page" +import statusHelper from "../../utils/page"; import Backdrop from "@material-ui/core/Backdrop"; -import {FolderUpload,FilePlus} from "mdi-material-ui"; +import { FolderUpload, FilePlus } from "mdi-material-ui"; const useStyles = makeStyles(() => ({ fab: { @@ -29,11 +33,11 @@ const useStyles = makeStyles(() => ({ zIndex: 9999, right: 7 }, - '@global': { - '.MuiSpeedDialAction-staticTooltipLabel': { - width:100, - }, - }, + "@global": { + ".MuiSpeedDialAction-staticTooltipLabel": { + width: 100 + } + } })); export default function UploadButton(props) { @@ -49,13 +53,11 @@ export default function UploadButton(props) { [dispatch] ); const OpenNewFolderDialog = useCallback( - () => - dispatch(openCreateFolderDialog()), + () => dispatch(openCreateFolderDialog()), [dispatch] ); const OpenNewFileDialog = useCallback( - () => - dispatch(openCreateFileDialog()), + () => dispatch(openCreateFileDialog()), [dispatch] ); @@ -63,20 +65,13 @@ export default function UploadButton(props) { setQueued(props.Queued); }, [props.Queued]); - const openUpload = id =>{ - const uploadButton = document.getElementsByClassName( - id - )[0]; - if (document.body.contains(uploadButton)) { - uploadButton.click(); - } else { - ToggleSnackbar( - "top", - "right", - "上传组件还未加载完成", - "warning" - ); - } + const openUpload = id => { + const uploadButton = document.getElementsByClassName(id)[0]; + if (document.body.contains(uploadButton)) { + uploadButton.click(); + } else { + ToggleSnackbar("top", "right", "上传组件还未加载完成", "warning"); + } }; const uploadClicked = () => { if (open) { @@ -112,44 +107,58 @@ export default function UploadButton(props) { ariaLabel="SpeedDial openIcon example" hidden={false} tooltipTitle="上传文件" - icon={} />} + icon={ + + } + /> + } onClose={handleClose} FabProps={{ - onClick: () => !statusHelper.isMobile() && uploadClicked(), - color: "secondary", + onClick: () => + !statusHelper.isMobile() && uploadClicked(), + color: "secondary" }} onOpen={handleOpen} open={open} > - {statusHelper.isMobile() && } - tooltipOpen - tooltipTitle="上传文件" - onClick= {() => uploadClicked()} - title={"上传文件"}/>} - {!statusHelper.isMobile() && } - tooltipOpen - tooltipTitle="上传目录" - onClick= {() => openUpload("uploadFolderForm")} - title={"上传目录"}/>} + {statusHelper.isMobile() && ( + } + tooltipOpen + tooltipTitle="上传文件" + onClick={() => uploadClicked()} + title={"上传文件"} + /> + )} + {!statusHelper.isMobile() && ( + } + tooltipOpen + tooltipTitle="上传目录" + onClick={() => openUpload("uploadFolderForm")} + title={"上传目录"} + /> + )} } tooltipOpen tooltipTitle="新建目录" - onClick= {() => OpenNewFolderDialog()} - title={"新建目录"}/> + onClick={() => OpenNewFolderDialog()} + title={"新建目录"} + /> } tooltipOpen tooltipTitle="新建文件" - onClick= {() => OpenNewFileDialog()} - title={"新建文件"}/> - + onClick={() => OpenNewFileDialog()} + title={"新建文件"} + /> diff --git a/src/component/Dial/Save.js b/src/component/Dial/Save.js index e9f2f53..a030501 100644 --- a/src/component/Dial/Save.js +++ b/src/component/Dial/Save.js @@ -1,7 +1,7 @@ import React from "react"; import { makeStyles } from "@material-ui/core"; import SaveIcon from "@material-ui/icons/Save"; -import CheckIcon from '@material-ui/icons/Check'; +import CheckIcon from "@material-ui/icons/Check"; import AutoHidden from "./AutoHidden"; import statusHelper from "../../utils/page"; import Fab from "@material-ui/core/Fab"; @@ -40,16 +40,16 @@ const useStyles = makeStyles(theme => ({ }, buttonSuccess: { backgroundColor: green[500], - '&:hover': { - backgroundColor: green[700], - }, - }, + "&:hover": { + backgroundColor: green[700] + } + } })); export default function SaveButton(props) { const classes = useStyles(); const buttonClassname = clsx({ - [classes.buttonSuccess]: props.status==="success", + [classes.buttonSuccess]: props.status === "success" }); return ( @@ -64,14 +64,19 @@ export default function SaveButton(props) { disabled={props.status === "loading"} aria-label="add" > - {props.status==="success" ? : } + {props.status === "success" ? ( + + ) : ( + + )} - {props.status === "loading"&&} - + {props.status === "loading" && ( + + )}
diff --git a/src/component/Download/Download.js b/src/component/Download/Download.js index 64ed5b8..45147fc 100644 --- a/src/component/Download/Download.js +++ b/src/component/Download/Download.js @@ -53,8 +53,8 @@ const styles = theme => ({ marginTop: "20px", marginBottom: "20px" }, - margin:{ - marginTop:theme.spacing(2), + margin: { + marginTop: theme.spacing(2) } }); const mapStateToProps = () => { @@ -101,8 +101,11 @@ class DownloadComponent extends Component { }); // 设定自动更新 clearTimeout(this.interval); - if(response.data.length > 0){ - this.interval = setTimeout(this.loadDownloading,1000 * response.data[0].interval); + if (response.data.length > 0) { + this.interval = setTimeout( + this.loadDownloading, + 1000 * response.data[0].interval + ); } }) .catch(error => { @@ -119,11 +122,13 @@ class DownloadComponent extends Component { this.setState({ loading: true }); - API - .get("/aria2/finished?page=" + ++this.page) + API.get("/aria2/finished?page=" + ++this.page) .then(response => { this.setState({ - finishedList: [...this.state.finishedList,...response.data], + finishedList: [ + ...this.state.finishedList, + ...response.data + ], loading: false, continue: response.data.length >= 10 }); @@ -142,7 +147,7 @@ class DownloadComponent extends Component { return (
- {user.group.allowRemoteDownload&& } + {user.group.allowRemoteDownload && } {this.state.downloading.map((value, k) => ( - + ))} {this.state.finishedList.map((value, k) => { if (value.files) { - return ( - - ) + return ; } - return null - + return null; })}
)} @@ -546,7 +602,7 @@ class ContextMenuCompoment extends Component { 重命名 - {this.props.keywords === "" && + {this.props.keywords === "" && ( this.props.openCopyDialog() @@ -559,13 +615,12 @@ class ContextMenuCompoment extends Component { 复制 - } - + )}
)} {isHomePage && (
- {this.props.keywords === "" && + {this.props.keywords === "" && ( this.props.openMoveDialog() @@ -578,7 +633,7 @@ class ContextMenuCompoment extends Component { 移动 - } + )} 200?1:0.4, - } + let { x, y } = currentOffset; + if (isSnapToGrid) { + x -= initialOffset.x; + y -= initialOffset.y; + [x, y] = snapToGrid(x, y); + x += initialOffset.x; + y += initialOffset.y; + } + const transform = `translate(${x}px, ${y}px)`; + return { + transform, + WebkitTransform: transform, + opacity: y > 200 ? 1 : 0.4 + }; } const CustomDragLayer = props => { - const { - itemType, - isDragging, - item, - initialOffset, - currentOffset, - } = useDragLayer(monitor => ({ - item: monitor.getItem(), - itemType: monitor.getItemType(), - initialOffset: monitor.getInitialSourceClientOffset(), - currentOffset: monitor.getSourceClientOffset(), - isDragging: monitor.isDragging(), - })) - function renderItem() { - switch (itemType) { - case "object": - return - default: - return null + const { + itemType, + isDragging, + item, + initialOffset, + currentOffset + } = useDragLayer(monitor => ({ + item: monitor.getItem(), + itemType: monitor.getItemType(), + initialOffset: monitor.getInitialSourceClientOffset(), + currentOffset: monitor.getSourceClientOffset(), + isDragging: monitor.isDragging() + })); + function renderItem() { + switch (itemType) { + case "object": + return ; + default: + return null; + } } - } - if (!isDragging) { - return null - } - return ( -
-
- {renderItem()} -
-
- ) -} -export default CustomDragLayer + if (!isDragging) { + return null; + } + return ( +
+
+ {renderItem()} +
+
+ ); +}; +export default CustomDragLayer; diff --git a/src/component/FileManager/DnD/DropWarpper.js b/src/component/FileManager/DnD/DropWarpper.js index 4921440..15b6333 100644 --- a/src/component/FileManager/DnD/DropWarpper.js +++ b/src/component/FileManager/DnD/DropWarpper.js @@ -1,19 +1,19 @@ import React from "react"; import { useDrop } from "react-dnd"; -import Folder from "../Folder" -export default function FolderDropWarpper({ folder}) { +import Folder from "../Folder"; +export default function FolderDropWarpper({ folder }) { const [{ canDrop, isOver }, drop] = useDrop({ accept: "object", drop: () => ({ folder }), collect: monitor => ({ isOver: monitor.isOver(), - canDrop: (monitor.canDrop()) + canDrop: monitor.canDrop() }) }); const isActive = canDrop && isOver; return (
-
+ +
); } - \ No newline at end of file diff --git a/src/component/FileManager/DnD/Preview.js b/src/component/FileManager/DnD/Preview.js index 92e92c1..02313dc 100644 --- a/src/component/FileManager/DnD/Preview.js +++ b/src/component/FileManager/DnD/Preview.js @@ -5,21 +5,21 @@ import { useSelector } from "react-redux"; import { makeStyles } from "@material-ui/core"; const useStyles = makeStyles(() => ({ - dragging:{ - width:"200px", + dragging: { + width: "200px" }, cardDragged: { position: "absolute", - "transform-origin": "bottom left", - }, + "transform-origin": "bottom left" + } })); -const diliverIcon = (object,viewMethod,classes)=>{ +const diliverIcon = (object, viewMethod, classes) => { return ( <> {object.type === "dir" && viewMethod !== "list" && (
- +
)} {object.type === "file" && viewMethod === "icon" && ( @@ -27,15 +27,14 @@ const diliverIcon = (object,viewMethod,classes)=>{ )} - {object.type === "file" && - viewMethod === "smallIcon" && ( -
+ {object.type === "file" && viewMethod === "smallIcon" && ( +
-
- )} +
+ )} - ) -} + ); +}; const Preview = props => { const selected = useSelector(state => state.explorer.selected); @@ -45,22 +44,24 @@ const Preview = props => { const classes = useStyles(); return ( <> - {selected.length === 0 && diliverIcon(props.object,viewMethod,classes)} - {selected.length>0&&<> - {selected.slice(0, 3).map((card, i) => ( -
- {diliverIcon(card,viewMethod,classes)} -
- ))} + {selected.length === 0 && + diliverIcon(props.object, viewMethod, classes)} + {selected.length > 0 && ( + <> + {selected.slice(0, 3).map((card, i) => ( +
+ {diliverIcon(card, viewMethod, classes)} +
+ ))} - } + )} ); }; diff --git a/src/component/FileManager/Explorer.js b/src/component/FileManager/Explorer.js index 5d6a950..c28ce63 100644 --- a/src/component/FileManager/Explorer.js +++ b/src/component/FileManager/Explorer.js @@ -1,4 +1,15 @@ -import { CircularProgress, Grid, Paper, Table, TableBody, TableCell, TableHead, TableRow, Typography, withStyles } from "@material-ui/core"; +import { + CircularProgress, + Grid, + Paper, + Table, + TableBody, + TableCell, + TableHead, + TableRow, + Typography, + withStyles +} from "@material-ui/core"; import TableSortLabel from "@material-ui/core/TableSortLabel"; import SadIcon from "@material-ui/icons/SentimentVeryDissatisfied"; import EmptyIcon from "@material-ui/icons/Unarchive"; @@ -8,8 +19,14 @@ import React, { Component } from "react"; import { configure, GlobalHotKeys } from "react-hotkeys"; import { connect } from "react-redux"; import { withRouter } from "react-router-dom"; -import { changeContextMenu, navigateTo, navigateUp, openRemoveDialog, setSelectedTarget } from "../../actions/index"; -import explorer from "../../redux/explorer" +import { + changeContextMenu, + navigateTo, + navigateUp, + openRemoveDialog, + setSelectedTarget +} from "../../actions/index"; +import explorer from "../../redux/explorer"; import { isMac } from "../../utils"; import pathHelper from "../../utils/page"; import ContextMenu from "./ContextMenu"; @@ -161,7 +178,7 @@ class ExplorerCompoment extends Component { super(); this.keyMap = { DELETE_FILE: "del", - SELECT_ALL: `${isMac() ? 'command' : 'ctrl'}+a` + SELECT_ALL: `${isMac() ? "command" : "ctrl"}+a` }; this.handlers = { @@ -187,8 +204,8 @@ class ExplorerCompoment extends Component { }; configure({ - ignoreTags: ['input', 'select', 'textarea'], - }) + ignoreTags: ["input", "select", "textarea"] + }); } contextMenu = e => { @@ -218,236 +235,198 @@ class ExplorerCompoment extends Component { const { classes } = this.props; const isHomePage = pathHelper.isHomePage(this.props.location.pathname); - const showView = !this.props.loading && (this.props.dirList.length !== 0 || - this.props.fileList.length !== 0) + const showView = + !this.props.loading && + (this.props.dirList.length !== 0 || + this.props.fileList.length !== 0); const listView = ( -
- - - - { - this.props.changeSort( - this.props.sortMethod === - "namePos" - ? "nameRev" - : "namePos" - ); - }} - > - 名称 - {this.props.sortMethod === - "namePos" || - this.props.sortMethod === - "nameRev" ? ( - - {this.props.sortMethod === - "nameRev" - ? "sorted descending" - : "sorted ascending"} - - ) : null} - - - - { - this.props.changeSort( - this.props.sortMethod === - "sizePos" - ? "sizeRes" - : "sizePos" - ); - }} - > - 大小 - {this.props.sortMethod === - "sizePos" || - this.props.sortMethod === - "sizeRes" ? ( - - {this.props.sortMethod === - "sizeRes" - ? "sorted descending" - : "sorted ascending"} - - ) : null} - - - - { - this.props.changeSort( - this.props.sortMethod === - "timePos" - ? "timeRev" - : "timePos" - ); - }} - > - 日期 - {this.props.sortMethod === - "timePos" || - this.props.sortMethod === - "timeRev" ? ( - - {this.props.sortMethod === - "sizeRes" - ? "sorted descending" - : "sorted ascending"} - - ) : null} - - - - - - {pathHelper.isMobile() && - this.props.path !== "/" && ( - - )} - {this.props.dirList.map((value, index) => ( - - ))} - {this.props.fileList.map((value, index) => ( - - ))} - -
- ) + + + + + { + this.props.changeSort( + this.props.sortMethod === "namePos" + ? "nameRev" + : "namePos" + ); + }} + > + 名称 + {this.props.sortMethod === "namePos" || + this.props.sortMethod === "nameRev" ? ( + + {this.props.sortMethod === "nameRev" + ? "sorted descending" + : "sorted ascending"} + + ) : null} + + + + { + this.props.changeSort( + this.props.sortMethod === "sizePos" + ? "sizeRes" + : "sizePos" + ); + }} + > + 大小 + {this.props.sortMethod === "sizePos" || + this.props.sortMethod === "sizeRes" ? ( + + {this.props.sortMethod === "sizeRes" + ? "sorted descending" + : "sorted ascending"} + + ) : null} + + + + { + this.props.changeSort( + this.props.sortMethod === "timePos" + ? "timeRev" + : "timePos" + ); + }} + > + 日期 + {this.props.sortMethod === "timePos" || + this.props.sortMethod === "timeRev" ? ( + + {this.props.sortMethod === "sizeRes" + ? "sorted descending" + : "sorted ascending"} + + ) : null} + + + + + + {pathHelper.isMobile() && this.props.path !== "/" && ( + + )} + {this.props.dirList.map((value, index) => ( + + ))} + {this.props.fileList.map((value, index) => ( + + ))} + +
+ ); const normalView = ( -
- {this.props.dirList.length !== 0 && - ( - <> - - 文件夹 - - - {this.props.dirList.map( - (value, index) => ( - - - - ) - )} - - - )} - {this.props.fileList.length !== 0 && - ( - <> - - 文件 - - - {this.props.fileList.map( - (value, index) => ( - - - - ) - )} - - - )} -
- ) - const view = this.props.viewMethod === "list" ? listView : normalView +
+ {this.props.dirList.length !== 0 && ( + <> + + 文件夹 + + + {this.props.dirList.map((value, index) => ( + + + + ))} + + + )} + {this.props.fileList.length !== 0 && ( + <> + + 文件 + + + {this.props.fileList.map((value, index) => ( + + + + ))} + + + )} +
+ ); + const view = this.props.viewMethod === "list" ? listView : normalView; return (
({ backgroundColor: theme.palette.background.paper, borderRadius: "90%", paddingTop: "2px", - color: theme.palette.text.secondary, + color: theme.palette.text.secondary }, hide: { display: "none" diff --git a/src/component/FileManager/FileManager.js b/src/component/FileManager/FileManager.js index 762f2b6..6434d64 100644 --- a/src/component/FileManager/FileManager.js +++ b/src/component/FileManager/FileManager.js @@ -1,17 +1,22 @@ -import React, { Component } from 'react' -import { DndProvider } from 'react-dnd' -import HTML5Backend from 'react-dnd-html5-backend' -import { connect } from "react-redux" -import { withRouter } from "react-router-dom" -import { closeAllModals, navigateTo, setSelectedTarget, toggleSnackbar } from "../../actions" +import React, { Component } from "react"; +import { DndProvider } from "react-dnd"; +import HTML5Backend from "react-dnd-html5-backend"; +import { connect } from "react-redux"; +import { withRouter } from "react-router-dom"; +import { + closeAllModals, + navigateTo, + setSelectedTarget, + toggleSnackbar +} from "../../actions"; import { changeSubTitle } from "../../redux/viewUpdate/action"; -import pathHelper from "../../utils/page" -import DragLayer from "./DnD/DragLayer" -import Explorer from "./Explorer" -import Modals from "./Modals" -import Navigator from "./Navigator/Navigator" +import pathHelper from "../../utils/page"; +import DragLayer from "./DnD/DragLayer"; +import Explorer from "./Explorer"; +import Modals from "./Modals"; +import Navigator from "./Navigator/Navigator"; -const mapStateToProps = ()=>({}); +const mapStateToProps = () => ({}); const mapDispatchToProps = dispatch => { return { @@ -27,14 +32,14 @@ const mapDispatchToProps = dispatch => { closeAllModals: () => { dispatch(closeAllModals()); }, - navigateTo:path=>{ + navigateTo: path => { dispatch(navigateTo(path)); - }, + } }; }; class FileManager extends Component { - constructor(props){ + constructor(props) { super(props); this.image = React.createRef(); } @@ -45,28 +50,28 @@ class FileManager extends Component { } componentDidMount() { - if (pathHelper.isHomePage(this.props.location.pathname)){ + if (pathHelper.isHomePage(this.props.location.pathname)) { this.props.changeSubTitle(null); } - } render() { return ( - - - - - + + + + + ); } - } -FileManager.propTypes = { -}; +FileManager.propTypes = {}; export default connect( mapStateToProps, mapDispatchToProps -)((withRouter(FileManager))); \ No newline at end of file +)(withRouter(FileManager)); diff --git a/src/component/FileManager/Folder.js b/src/component/FileManager/Folder.js index fe53e96..ab5bfdc 100644 --- a/src/component/FileManager/Folder.js +++ b/src/component/FileManager/Folder.js @@ -1,9 +1,9 @@ -import React from "react"; +import React from "react"; import FolderIcon from "@material-ui/icons/Folder"; import classNames from "classnames"; import { ButtonBase, Typography, Tooltip, makeStyles } from "@material-ui/core"; import { useSelector } from "react-redux"; -import {lighten} from "@material-ui/core/styles"; +import { lighten } from "@material-ui/core/styles"; const useStyles = makeStyles(theme => ({ container: { padding: "7px" @@ -46,7 +46,7 @@ const useStyles = makeStyles(theme => ({ backgroundColor: theme.palette.background.paper, borderRadius: "90%", paddingTop: "2px", - color: theme.palette.text.secondary, + color: theme.palette.text.secondary }, folderNameSelected: { color: @@ -65,12 +65,12 @@ const useStyles = makeStyles(theme => ({ overflow: "hidden", marginRight: "20px" }, - active:{ - border: "2px solid " + theme.palette.primary.light, - }, + active: { + border: "2px solid " + theme.palette.primary.light + } })); -export default function Folder({ folder,isActive }) { +export default function Folder({ folder, isActive }) { const selected = useSelector(state => state.explorer.selected); const classes = useStyles(); @@ -87,9 +87,9 @@ export default function Folder({ folder,isActive }) { { [classes.selected]: isSelected, [classes.notSelected]: !isSelected, - [classes.active]: isActive, + [classes.active]: isActive }, - classes.button, + classes.button )} >
({}); @@ -39,21 +39,22 @@ class ImagPreviewComponent extends Component { const items = []; let firstOne = 0; if (nextProps.first.id !== "") { - if (pathHelper.isSharePage(this.props.location.pathname) && !nextProps.first.path){ + if ( + pathHelper.isSharePage(this.props.location.pathname) && + !nextProps.first.path + ) { const newImg = { intro: nextProps.first.name, - src: - baseURL + - "/share/preview/" +nextProps.first.key + src: baseURL + "/share/preview/" + nextProps.first.key }; firstOne = 0; items.push(newImg); this.setState({ - photoIndex:firstOne, + photoIndex: firstOne, items: items, isOpen: true }); - return + return; } // eslint-disable-next-line nextProps.other.map(value => { @@ -63,21 +64,22 @@ class ImagPreviewComponent extends Component { .toLowerCase(); if (imgPreviewSuffix.indexOf(fileType) !== -1) { let src = ""; - if (pathHelper.isSharePage(this.props.location.pathname)){ - src = baseURL + - "/share/preview/" + value.key - src = src + "?path=" + encodeURIComponent( (value.path === "/" - ? value.path + value.name - : value.path + "/" + value.name)) - - }else{ - src = baseURL + - "/file/preview/" + - value.id + if (pathHelper.isSharePage(this.props.location.pathname)) { + src = baseURL + "/share/preview/" + value.key; + src = + src + + "?path=" + + encodeURIComponent( + value.path === "/" + ? value.path + value.name + : value.path + "/" + value.name + ); + } else { + src = baseURL + "/file/preview/" + value.id; } const newImg = { intro: value.name, - src:src, + src: src }; if ( value.path === nextProps.first.path && @@ -89,7 +91,7 @@ class ImagPreviewComponent extends Component { } }); this.setState({ - photoIndex:firstOne, + photoIndex: firstOne, items: items, isOpen: true }); @@ -104,22 +106,23 @@ class ImagPreviewComponent extends Component { }; render() { - const { photoIndex, isOpen,items } = this.state; + const { photoIndex, isOpen, items } = this.state; return (
- {isOpen && ( this.handleClose()} - index={photoIndex} - onIndexChange={(n) => - this.setState({ - photoIndex: n, - }) - } - - />)} + {isOpen && ( + this.handleClose()} + index={photoIndex} + onIndexChange={n => + this.setState({ + photoIndex: n + }) + } + /> + )}
); } diff --git a/src/component/FileManager/ImgPreview_old.js b/src/component/FileManager/ImgPreview_old.js index 21d7a13..5489b11 100644 --- a/src/component/FileManager/ImgPreview_old.js +++ b/src/component/FileManager/ImgPreview_old.js @@ -8,7 +8,7 @@ import { withStyles } from "@material-ui/core"; import Lightbox from "react-image-lightbox"; import "react-image-lightbox/style.css"; import pathHelper from "../../utils/page"; -import {withRouter} from "react-router"; +import { withRouter } from "react-router"; const styles = () => ({}); @@ -38,21 +38,22 @@ class ImgPreviewCompoment extends Component { const items = []; let firstOne = 0; if (nextProps.first !== null) { - if (pathHelper.isSharePage(this.props.location.pathname) && !nextProps.first.path){ + if ( + pathHelper.isSharePage(this.props.location.pathname) && + !nextProps.first.path + ) { const newImg = { title: nextProps.first.name, - src: - baseURL + - "/share/preview/" +nextProps.first.key + src: baseURL + "/share/preview/" + nextProps.first.key }; firstOne = 0; items.push(newImg); this.setState({ - photoIndex:firstOne, + photoIndex: firstOne, items: items, isOpen: true }); - return + return; } // eslint-disable-next-line nextProps.other.map(value => { @@ -62,21 +63,22 @@ class ImgPreviewCompoment extends Component { .toLowerCase(); if (imgPreviewSuffix.indexOf(fileType) !== -1) { let src = ""; - if (pathHelper.isSharePage(this.props.location.pathname)){ - src = baseURL + - "/share/preview/" + value.key - src = src + "?path=" + encodeURIComponent( (value.path === "/" - ? value.path + value.name - : value.path + "/" + value.name)) - - }else{ - src = baseURL + - "/file/preview/" + - value.id + if (pathHelper.isSharePage(this.props.location.pathname)) { + src = baseURL + "/share/preview/" + value.key; + src = + src + + "?path=" + + encodeURIComponent( + value.path === "/" + ? value.path + value.name + : value.path + "/" + value.name + ); + } else { + src = baseURL + "/file/preview/" + value.id; } const newImg = { title: value.name, - src:src, + src: src }; if ( value.path === nextProps.first.path && @@ -88,7 +90,7 @@ class ImgPreviewCompoment extends Component { } }); this.setState({ - photoIndex:firstOne, + photoIndex: firstOne, items: items, isOpen: true }); @@ -103,34 +105,42 @@ class ImgPreviewCompoment extends Component { }; render() { - const { photoIndex, isOpen,items } = this.state; + const { photoIndex, isOpen, items } = this.state; return (
- {isOpen && ( this.handleClose()} - imageLoadErrorMessage = "无法加载此图像" - imageCrossOrigin = "anonymous" - imageTitle = {items[photoIndex].title} - onMovePrevRequest={() => - this.setState({ - photoIndex: (photoIndex + items.length - 1) % items.length, - }) - } - reactModalStyle={{ - overlay:{ - zIndex:10000 - }, - }} - onMoveNextRequest={() => - this.setState({ - photoIndex: (photoIndex + 1) % items.length, - }) - } - />)} + {isOpen && ( + this.handleClose()} + imageLoadErrorMessage="无法加载此图像" + imageCrossOrigin="anonymous" + imageTitle={items[photoIndex].title} + onMovePrevRequest={() => + this.setState({ + photoIndex: + (photoIndex + items.length - 1) % + items.length + }) + } + reactModalStyle={{ + overlay: { + zIndex: 10000 + } + }} + onMoveNextRequest={() => + this.setState({ + photoIndex: (photoIndex + 1) % items.length + }) + } + /> + )}
); } diff --git a/src/component/FileManager/Modals.js b/src/component/FileManager/Modals.js index f1e620d..3e190ac 100644 --- a/src/component/FileManager/Modals.js +++ b/src/component/FileManager/Modals.js @@ -20,7 +20,7 @@ import { DialogContent, DialogTitle, DialogContentText, - CircularProgress, + CircularProgress } from "@material-ui/core"; import Loading from "../Modals/Loading"; import CopyDialog from "../Modals/Copy"; @@ -100,7 +100,7 @@ class ModalsCompoment extends Component { downloadURL: "", remoteDownloadPathSelect: false, source: "", - purchaseCallback:null, + purchaseCallback: null }; handleInputChange = e => { @@ -121,17 +121,25 @@ class ModalsCompoment extends Component { // 打包下载 if (nextProps.loading === true) { if (nextProps.loadingText === "打包中...") { - if (pathHelper.isSharePage(this.props.location.pathname) && this.props.share && this.props.share.score > 0){ + if ( + pathHelper.isSharePage(this.props.location.pathname) && + this.props.share && + this.props.share.score > 0 + ) { this.scoreHandler(this.archiveDownload); - return + return; } this.archiveDownload(); } else if (nextProps.loadingText === "获取下载地址...") { - if (pathHelper.isSharePage(this.props.location.pathname) && this.props.share && this.props.share.score > 0){ + if ( + pathHelper.isSharePage(this.props.location.pathname) && + this.props.share && + this.props.share.score > 0 + ) { this.scoreHandler(this.Download); - return + return; } - this.Download(); + this.Download(); } } return; @@ -165,9 +173,9 @@ class ModalsCompoment extends Component { } }; - scoreHandler = callback =>{ - callback(); - } + scoreHandler = callback => { + callback(); + }; Download = () => { let reqURL = ""; @@ -176,8 +184,8 @@ class ModalsCompoment extends Component { this.props.selected[0].path === "/" ? this.props.selected[0].path + this.props.selected[0].name : this.props.selected[0].path + - "/" + - this.props.selected[0].name; + "/" + + this.props.selected[0].name; reqURL = "/share/download/" + this.props.selected[0].key + @@ -213,7 +221,7 @@ class ModalsCompoment extends Component { } else { items.push(value.id); } - return null + return null; }); let reqURL = "/file/archive"; @@ -221,13 +229,9 @@ class ModalsCompoment extends Component { items: items, dirs: dirs }; - if (pathHelper.isSharePage( - this.props.location.pathname - )) { - reqURL = - "/share/archive/" + - window.shareInfo.key; - postBody["path"] = this.props.selected[0].path + if (pathHelper.isSharePage(this.props.location.pathname)) { + reqURL = "/share/archive/" + window.shareInfo.key; + postBody["path"] = this.props.selected[0].path; } API.post(reqURL, postBody) @@ -279,7 +283,7 @@ class ModalsCompoment extends Component { .then(response => { if (response.rawData.code === 0) { this.onClose(); - setTimeout(this.props.refreshFileList,500); + setTimeout(this.props.refreshFileList, 500); } else { this.props.toggleSnackbar( "top", @@ -401,10 +405,10 @@ class ModalsCompoment extends Component { // 检查重名 if ( - this.props.dirList.findIndex((value) => { + this.props.dirList.findIndex(value => { return value.name === newName; }) !== -1 || - this.props.fileList.findIndex((value) => { + this.props.fileList.findIndex(value => { return value.name === newName; }) !== -1 ) { @@ -442,7 +446,7 @@ class ModalsCompoment extends Component { e.preventDefault(); this.props.setModalsLoading(true); if ( - this.props.dirList.findIndex((value) => { + this.props.dirList.findIndex(value => { return value.name === this.state.newFolderName; }) !== -1 ) { @@ -483,7 +487,7 @@ class ModalsCompoment extends Component { e.preventDefault(); this.props.setModalsLoading(true); if ( - this.props.dirList.findIndex((value) => { + this.props.dirList.findIndex(value => { return value.name === this.state.newFileName; }) !== -1 ) { @@ -523,18 +527,18 @@ class ModalsCompoment extends Component { submitTorrentDownload = e => { e.preventDefault(); this.props.setModalsLoading(true); - API - .post("/aria2/torrent/" + this.props.selected[0].id, { - dst: this.state.selectedPath === "//" ? "/" : this.state.selectedPath - }) + API.post("/aria2/torrent/" + this.props.selected[0].id, { + dst: + this.state.selectedPath === "//" ? "/" : this.state.selectedPath + }) .then(() => { - this.props.toggleSnackbar( - "top", - "right", - "任务已创建", - "success" - ); - this.onClose(); + this.props.toggleSnackbar( + "top", + "right", + "任务已创建", + "success" + ); + this.onClose(); this.props.setModalsLoading(false); }) .catch(error => { @@ -551,19 +555,19 @@ class ModalsCompoment extends Component { submitDownload = e => { e.preventDefault(); this.props.setModalsLoading(true); - API - .post("/aria2/url", { - url: this.state.downloadURL, - dst: this.state.selectedPath === "//" ? "/" : this.state.selectedPath - }) + API.post("/aria2/url", { + url: this.state.downloadURL, + dst: + this.state.selectedPath === "//" ? "/" : this.state.selectedPath + }) .then(() => { - this.props.toggleSnackbar( - "top", - "right", - "任务已创建", - "success" - ); - this.onClose(); + this.props.toggleSnackbar( + "top", + "right", + "任务已创建", + "success" + ); + this.onClose(); this.props.setModalsLoading(false); }) .catch(error => { @@ -607,7 +611,7 @@ class ModalsCompoment extends Component { downloadURL: "", shareUrl: "", remoteDownloadPathSelect: false, - source: "", + source: "" }); this.newNameSuffix = ""; this.props.closeAllModals(); @@ -930,7 +934,7 @@ class ModalsCompoment extends Component { : "") : baseURL + "/file/preview/" + - this.props.selected[0].id + this.props.selected[0].id } /> )} diff --git a/src/component/FileManager/Navigator/DropDown.js b/src/component/FileManager/Navigator/DropDown.js index 053aeef..b6cb08f 100644 --- a/src/component/FileManager/Navigator/DropDown.js +++ b/src/component/FileManager/Navigator/DropDown.js @@ -1,41 +1,37 @@ import React from "react"; import DropDownItem from "./DropDownItem"; - export default function DropDown(props) { - let timer; let first = props.folders.length; const status = []; for (let index = 0; index < props.folders.length; index++) { status[index] = false; - } - const setActiveStatus = (id,value)=>{ + const setActiveStatus = (id, value) => { status[id] = value; - if (value){ + if (value) { clearTimeout(timer); - }else{ + } else { let shouldClose = true; status.forEach(element => { - if (element){ + if (element) { shouldClose = false; } }); - if (shouldClose){ - if (first<=0){ - timer = setTimeout(()=>{ + if (shouldClose) { + if (first <= 0) { + timer = setTimeout(() => { props.onClose(); - },100) - }else{ + }, 100); + } else { first--; } - } } console.log(status); - } + }; return ( <> @@ -45,7 +41,7 @@ export default function DropDown(props) { path={"/" + props.folders.slice(0, id).join("/")} navigateTo={props.navigateTo} id={id} - setActiveStatus = {setActiveStatus} + setActiveStatus={setActiveStatus} folder={folder} /> ))} diff --git a/src/component/FileManager/Navigator/DropDownItem.js b/src/component/FileManager/Navigator/DropDownItem.js index 5cb506b..bb0b949 100644 --- a/src/component/FileManager/Navigator/DropDownItem.js +++ b/src/component/FileManager/Navigator/DropDownItem.js @@ -1,11 +1,7 @@ import React, { useEffect } from "react"; import { makeStyles } from "@material-ui/core"; import FolderIcon from "@material-ui/icons/Folder"; -import { - MenuItem, - ListItemIcon, - ListItemText -} from "@material-ui/core"; +import { MenuItem, ListItemIcon, ListItemText } from "@material-ui/core"; import { useDrop } from "react-dnd"; import classNames from "classnames"; @@ -36,9 +32,9 @@ export default function DropDownItem(props) { const isActive = canDrop && isOver; useEffect(() => { - props.setActiveStatus(props.id,isActive); + props.setActiveStatus(props.id, isActive); // eslint-disable-next-line - }, [isActive]) + }, [isActive]); const classes = useStyles(); return ( diff --git a/src/component/FileManager/Navigator/Navigator.js b/src/component/FileManager/Navigator/Navigator.js index b2ecd43..a491991 100644 --- a/src/component/FileManager/Navigator/Navigator.js +++ b/src/component/FileManager/Navigator/Navigator.js @@ -21,9 +21,11 @@ import { openCreateFolderDialog, openShareDialog, drawerToggleAction, - setShareUserPopover, openResaveDialog, openCompressDialog + setShareUserPopover, + openResaveDialog, + openCompressDialog } from "../../../actions/index"; -import explorer from "../../../redux/explorer" +import explorer from "../../../redux/explorer"; import API from "../../../middleware/Api"; import { setCookie, setGetParameter, fixUrlHash } from "../../../utils/index"; import { @@ -40,11 +42,10 @@ import pathHelper from "../../../utils/page"; import classNames from "classnames"; import Auth from "../../../middleware/Auth"; import Avatar from "@material-ui/core/Avatar"; -import {Archive} from "@material-ui/icons"; +import { Archive } from "@material-ui/icons"; import { FilePlus } from "mdi-material-ui"; import { openCreateFileDialog } from "../../../actions"; - const mapStateToProps = state => { return { path: state.navigator.path, @@ -100,12 +101,12 @@ const mapDispatchToProps = dispatch => { setShareUserPopover: e => { dispatch(setShareUserPopover(e)); }, - openResave: (key) => { + openResave: key => { dispatch(openResaveDialog(key)); }, - openCompressDialog: ()=>{ - dispatch(openCompressDialog()) - }, + openCompressDialog: () => { + dispatch(openCompressDialog()); + } }; }; @@ -182,7 +183,7 @@ class NavigatorComponent extends Component { componentDidMount = () => { const url = new URL(fixUrlHash(window.location.href)); const c = url.searchParams.get("path"); - this.renderPath(c === null ? "/":c); + this.renderPath(c === null ? "/" : c); if (!this.props.isShare) { // 如果是在个人文件管理页,首次加载时打开侧边栏 @@ -330,7 +331,7 @@ class NavigatorComponent extends Component { const presentPath = this.props.path.split("/"); const newTarget = [ { - id:this.currentID, + id: this.currentID, type: "dir", name: presentPath.pop(), path: presentPath.length === 1 ? "/" : presentPath.join("/") @@ -384,7 +385,7 @@ class NavigatorComponent extends Component { render() { const { classes } = this.props; - const isHomePage = pathHelper.isHomePage(this.props.location.pathname); + const isHomePage = pathHelper.isHomePage(this.props.location.pathname); const user = Auth.GetUser(); const presentFolderMenu = ( @@ -401,45 +402,42 @@ class NavigatorComponent extends Component { 刷新 - {this.props.keywords === "" && - isHomePage && ( -
- + {this.props.keywords === "" && isHomePage && ( +
+ + this.performAction("share")}> + + + + 分享 + + {user.group.compress && ( this.performAction("share")} - > - - - - 分享 - - {user.group.compress && this.performAction("compress")} > 压缩 - } - - this.performAction("newfolder")} - > - - - - 创建文件夹 - this.performAction("newFile")} - > - - - - 创建文件 - -
- )} + )} + + this.performAction("newfolder")} + > + + + + 创建文件夹 + + this.performAction("newFile")}> + + + + 创建文件 + +
+ )} ); @@ -614,7 +612,11 @@ class NavigatorComponent extends Component { > )} diff --git a/src/component/FileManager/Navigator/PathButton.js b/src/component/FileManager/Navigator/PathButton.js index fb6ef13..e8346f4 100644 --- a/src/component/FileManager/Navigator/PathButton.js +++ b/src/component/FileManager/Navigator/PathButton.js @@ -1,4 +1,4 @@ -import React,{useEffect} from "react"; +import React, { useEffect } from "react"; import ExpandMore from "@material-ui/icons/ExpandMore"; import { Button } from "@material-ui/core"; import { makeStyles } from "@material-ui/core"; @@ -13,14 +13,14 @@ const useStyles = makeStyles(theme => ({ active: { border: "2px solid " + theme.palette.primary.light }, - button:{ - textTransform: "none", + button: { + textTransform: "none" } })); export default function PathButton(props) { - const inputRef = React.useRef(null) - + const inputRef = React.useRef(null); + const [{ canDrop, isOver }, drop] = useDrop({ accept: "object", drop: () => { @@ -45,35 +45,36 @@ export default function PathButton(props) { const isActive = canDrop && isOver; useEffect(() => { - if(props.more && isActive){ + if (props.more && isActive) { inputRef.current.click(); } // eslint-disable-next-line - }, [isActive]) + }, [isActive]); const classes = useStyles(); return ( - - - + + - ); } diff --git a/src/component/FileManager/ObjectIcon.js b/src/component/FileManager/ObjectIcon.js index bc45c71..9ad4a7e 100644 --- a/src/component/FileManager/ObjectIcon.js +++ b/src/component/FileManager/ObjectIcon.js @@ -99,12 +99,12 @@ export default function ObjectIcon(props) { }; const selectFile = e => { - dispatch(selectFileAction(props.file, e, props.index)) + dispatch(selectFileAction(props.file, e, props.index)); }; const enterFolder = () => { - NavitateTo( - path === "/" ? path + props.file.name : path + "/" + props.file.name - ); + NavitateTo( + path === "/" ? path + props.file.name : path + "/" + props.file.name + ); }; const handleClick = e => { if (props.file.type === "up") { @@ -156,18 +156,18 @@ export default function ObjectIcon(props) { if (isShare) { history.push( selected[0].key + - "/doc?name=" + - encodeURIComponent(selected[0].name) + - "&share_path=" + - encodeURIComponent(previewPath) + "/doc?name=" + + encodeURIComponent(selected[0].name) + + "&share_path=" + + encodeURIComponent(previewPath) ); return; } history.push( "/doc?p=" + - encodeURIComponent(previewPath) + - "&id=" + - selected[0].id + encodeURIComponent(previewPath) + + "&id=" + + selected[0].id ); return; case "audio": @@ -177,58 +177,73 @@ export default function ObjectIcon(props) { if (isShare) { history.push( selected[0].key + - "/video?name=" + - encodeURIComponent(selected[0].name) + - "&share_path=" + - encodeURIComponent(previewPath) + "/video?name=" + + encodeURIComponent(selected[0].name) + + "&share_path=" + + encodeURIComponent(previewPath) ); return; } history.push( "/video?p=" + - encodeURIComponent(previewPath) + - "&id=" + - selected[0].id + encodeURIComponent(previewPath) + + "&id=" + + selected[0].id ); return; case "edit": if (isShare) { history.push( selected[0].key + - "/text?name=" + - encodeURIComponent(selected[0].name) + - "&share_path=" + - encodeURIComponent(previewPath) + "/text?name=" + + encodeURIComponent(selected[0].name) + + "&share_path=" + + encodeURIComponent(previewPath) ); return; } - history.push("/text?p=" + encodeURIComponent(previewPath) + "&id=" + selected[0].id); + history.push( + "/text?p=" + + encodeURIComponent(previewPath) + + "&id=" + + selected[0].id + ); return; case "pdf": if (isShare) { history.push( selected[0].key + - "/pdf?name=" + - encodeURIComponent(selected[0].name) + - "&share_path=" + - encodeURIComponent(previewPath) + "/pdf?name=" + + encodeURIComponent(selected[0].name) + + "&share_path=" + + encodeURIComponent(previewPath) ); return; } - history.push("/pdf?p=" + encodeURIComponent(previewPath) + "&id=" + selected[0].id); + history.push( + "/pdf?p=" + + encodeURIComponent(previewPath) + + "&id=" + + selected[0].id + ); return; case "code": if (isShare) { history.push( selected[0].key + - "/code?name=" + - encodeURIComponent(selected[0].name) + - "&share_path=" + - encodeURIComponent(previewPath) + "/code?name=" + + encodeURIComponent(selected[0].name) + + "&share_path=" + + encodeURIComponent(previewPath) ); return; } - history.push("/code?p=" + encodeURIComponent(previewPath) + "&id=" + selected[0].id); + history.push( + "/code?p=" + + encodeURIComponent(previewPath) + + "&id=" + + selected[0].id + ); return; default: OpenLoadingDialog("获取下载地址..."); diff --git a/src/component/FileManager/PathSelector.js b/src/component/FileManager/PathSelector.js index f94e9bc..225e38f 100644 --- a/src/component/FileManager/PathSelector.js +++ b/src/component/FileManager/PathSelector.js @@ -1,13 +1,11 @@ -import React, { Component } from 'react' -import PropTypes from 'prop-types'; -import FolderIcon from '@material-ui/icons/Folder' -import RightIcon from "@material-ui/icons/KeyboardArrowRight" -import UpIcon from "@material-ui/icons/ArrowUpward" -import { connect } from 'react-redux' -import classNames from 'classnames'; -import { - toggleSnackbar, -} from "../../actions/index" +import React, { Component } from "react"; +import PropTypes from "prop-types"; +import FolderIcon from "@material-ui/icons/Folder"; +import RightIcon from "@material-ui/icons/KeyboardArrowRight"; +import UpIcon from "@material-ui/icons/ArrowUpward"; +import { connect } from "react-redux"; +import classNames from "classnames"; +import { toggleSnackbar } from "../../actions/index"; import { MenuList, @@ -16,130 +14,162 @@ import { ListItemIcon, ListItemText, withStyles, - ListItemSecondaryAction, -} from '@material-ui/core'; -import API from '../../middleware/Api' + ListItemSecondaryAction +} from "@material-ui/core"; +import API from "../../middleware/Api"; const mapStateToProps = state => { return { - keywords: state.explorer.keywords, - } -} + keywords: state.explorer.keywords + }; +}; const mapDispatchToProps = dispatch => { return { - toggleSnackbar:(vertical,horizontal,msg,color)=>{ - dispatch(toggleSnackbar(vertical,horizontal,msg,color)) - }, - } -} - + toggleSnackbar: (vertical, horizontal, msg, color) => { + dispatch(toggleSnackbar(vertical, horizontal, msg, color)); + } + }; +}; const styles = theme => ({ - iconWhite:{ - color: theme.palette.common.white, + iconWhite: { + color: theme.palette.common.white }, selected: { - backgroundColor: theme.palette.primary.main+"!important", - '& $primary, & $icon': { - color: theme.palette.common.white, - }, - }, + backgroundColor: theme.palette.primary.main + "!important", + "& $primary, & $icon": { + color: theme.palette.common.white + } + }, primary: {}, icon: {}, - buttonIcon:{}, - selector:{ - minWidth: "300px", + buttonIcon: {}, + selector: { + minWidth: "300px" }, - container:{ + container: { maxHeight: "330px", - overflowY:" auto", + overflowY: " auto" } -}) - +}); class PathSelectorCompoment extends Component { - state = { - presentPath:"/", - dirList:[], - selectedTarget:null, - } + presentPath: "/", + dirList: [], + selectedTarget: null + }; - componentDidMount= ()=>{ + componentDidMount = () => { const toBeLoad = this.props.presentPath; this.enterFolder(this.props.keywords === "" ? toBeLoad : "/"); - } + }; - back = ()=>{ + back = () => { const paths = this.state.presentPath.split("/"); paths.pop(); const toBeLoad = paths.join("/"); - this.enterFolder(toBeLoad===""?"/":toBeLoad); - } + this.enterFolder(toBeLoad === "" ? "/" : toBeLoad); + }; - enterFolder = (toBeLoad)=>{ - API.get((this.props.api ? this.props.api : '/directory')+encodeURIComponent(toBeLoad),) - .then( (response)=> { - const dirList = response.data.objects.filter( (x)=> { - return (x.type === "dir" && (this.props.selected.findIndex((value)=>{ - return (value.name === x.name )&&(value.path === x.path); - }))===-1); - }); - if(toBeLoad ==="/"){ - dirList.unshift({name:"/",path:""}) - } - this.setState({ - presentPath:toBeLoad, - dirList:dirList, - selectedTarget:null, + enterFolder = toBeLoad => { + API.get( + (this.props.api ? this.props.api : "/directory") + + encodeURIComponent(toBeLoad) + ) + .then(response => { + const dirList = response.data.objects.filter(x => { + return ( + x.type === "dir" && + this.props.selected.findIndex(value => { + return ( + value.name === x.name && value.path === x.path + ); + }) === -1 + ); + }); + if (toBeLoad === "/") { + dirList.unshift({ name: "/", path: "" }); + } + this.setState({ + presentPath: toBeLoad, + dirList: dirList, + selectedTarget: null + }); }) - }) - .catch((error) =>{ - this.props.toggleSnackbar("top","right",error.message,"warning"); - }); - } + .catch(error => { + this.props.toggleSnackbar( + "top", + "right", + error.message, + "warning" + ); + }); + }; - handleSelect = (index) =>{ - this.setState({selectedTarget:index}); + handleSelect = index => { + this.setState({ selectedTarget: index }); this.props.onSelect(this.state.dirList[index]); - } + }; render() { - - const { classes} = this.props; + const { classes } = this.props; return (
- - {this.state.presentPath!=="/"&& - - - - - - - } - {this.state.dirList.map((value,index)=>( - this.handleSelect(index)}> - - - - - {value.name!=="/"&& - this.enterFolder(value.path === "/"?value.path+value.name:value.path+"/"+value.name)}> - - - } - - ))} - - - + + {this.state.presentPath !== "/" && ( + + + + + + + )} + {this.state.dirList.map((value, index) => ( + this.handleSelect(index)} + > + + + + + {value.name !== "/" && ( + + + this.enterFolder( + value.path === "/" + ? value.path + value.name + : value.path + + "/" + + value.name + ) + } + > + + + + )} + + ))} +
); } @@ -147,12 +177,11 @@ class PathSelectorCompoment extends Component { PathSelectorCompoment.propTypes = { classes: PropTypes.object.isRequired, - presentPath:PropTypes.string.isRequired, - selected:PropTypes.array.isRequired, + presentPath: PropTypes.string.isRequired, + selected: PropTypes.array.isRequired }; export default connect( mapStateToProps, mapDispatchToProps - -)(withStyles(styles)(PathSelectorCompoment)) \ No newline at end of file +)(withStyles(styles)(PathSelectorCompoment)); diff --git a/src/component/FileManager/SmallIcon.js b/src/component/FileManager/SmallIcon.js index fafe1ec..ad5bf5e 100644 --- a/src/component/FileManager/SmallIcon.js +++ b/src/component/FileManager/SmallIcon.js @@ -1,43 +1,44 @@ -import React, { Component } from 'react' -import PropTypes from 'prop-types'; -import { connect } from 'react-redux' -import classNames from 'classnames'; -import { withStyles, ButtonBase, Typography, Tooltip } from '@material-ui/core'; +import React, { Component } from "react"; +import PropTypes from "prop-types"; +import { connect } from "react-redux"; +import classNames from "classnames"; +import { withStyles, ButtonBase, Typography, Tooltip } from "@material-ui/core"; import TypeIcon from "./TypeIcon"; -import {lighten} from "@material-ui/core/styles"; +import { lighten } from "@material-ui/core/styles"; const styles = theme => ({ container: { - padding: "7px", + padding: "7px" }, selected: { "&:hover": { - border: "1px solid #d0d0d0", + border: "1px solid #d0d0d0" }, backgroundColor: theme.palette.type === "dark" ? "#fff" - : lighten(theme.palette.primary.main,0.8), + : lighten(theme.palette.primary.main, 0.8) }, notSelected: { "&:hover": { backgroundColor: theme.palette.background.default, - border: "1px solid #d0d0d0", + border: "1px solid #d0d0d0" }, - backgroundColor: theme.palette.background.paper, + backgroundColor: theme.palette.background.paper }, button: { height: "50px", - border: "1px solid "+theme.palette.divider, + border: "1px solid " + theme.palette.divider, width: "100%", borderRadius: "6px", boxSizing: "border-box", - transition: "background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms", + transition: + "background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms", display: "flex", justifyContent: "left", - alignItems: "initial", + alignItems: "initial" }, icon: { margin: "10px 10px 10px 16px", @@ -46,83 +47,94 @@ const styles = theme => ({ backgroundColor: theme.palette.background.paper, borderRadius: "90%", paddingTop: "2px", - color: theme.palette.text.secondary, + color: theme.palette.text.secondary }, folderNameSelected: { - color: theme.palette.type === "dark" ? theme.palette.background.paper : theme.palette.primary.dark, - fontWeight: "500", + color: + theme.palette.type === "dark" + ? theme.palette.background.paper + : theme.palette.primary.dark, + fontWeight: "500" }, folderNameNotSelected: { - color: theme.palette.text.secondary, + color: theme.palette.text.secondary }, folderName: { marginTop: "15px", textOverflow: "ellipsis", whiteSpace: "nowrap", overflow: "hidden", - marginRight: "20px", - }, -}) + marginRight: "20px" + } +}); const mapStateToProps = state => { return { - selected: state.explorer.selected, - } -} + selected: state.explorer.selected + }; +}; const mapDispatchToProps = () => { - return { - } -} + return {}; +}; class SmallIconCompoment extends Component { - - state = { - } - + state = {}; render() { - const { classes } = this.props; - const isSelected = (this.props.selected.findIndex((value) => { - return value === this.props.file; - })) !== -1; + const isSelected = + this.props.selected.findIndex(value => { + return value === this.props.file; + }) !== -1; return ( - -
+
- - + +
+ + {this.props.file.name} - -
+ > + {this.props.file.name} + + + ); } } SmallIconCompoment.propTypes = { classes: PropTypes.object.isRequired, - file: PropTypes.object.isRequired, + file: PropTypes.object.isRequired }; - const SmallIcon = connect( mapStateToProps, mapDispatchToProps -)(withStyles(styles)(SmallIconCompoment)) +)(withStyles(styles)(SmallIconCompoment)); -export default SmallIcon \ No newline at end of file +export default SmallIcon; diff --git a/src/component/FileManager/TableRow.js b/src/component/FileManager/TableRow.js index 5e52eb1..258ab53 100644 --- a/src/component/FileManager/TableRow.js +++ b/src/component/FileManager/TableRow.js @@ -7,10 +7,10 @@ import classNames from "classnames"; import { sizeToString } from "../../utils/index"; import { withStyles, TableCell, TableRow, Typography } from "@material-ui/core"; import TypeIcon from "./TypeIcon"; -import {lighten} from "@material-ui/core/styles"; +import { lighten } from "@material-ui/core/styles"; import pathHelper from "../../utils/page"; -import {withRouter} from "react-router"; -import KeyboardReturnIcon from '@material-ui/icons/KeyboardReturn'; +import { withRouter } from "react-router"; +import KeyboardReturnIcon from "@material-ui/icons/KeyboardReturn"; const styles = theme => ({ selected: { @@ -18,20 +18,20 @@ const styles = theme => ({ backgroundColor: theme.palette.type === "dark" ? theme.palette.background.paper - : lighten(theme.palette.primary.main,0.8), + : lighten(theme.palette.primary.main, 0.8) }, selectedShared: { "&:hover": {}, backgroundColor: theme.palette.type === "dark" - ? lighten(theme.palette.background.paper,0.15) - : lighten(theme.palette.primary.main,0.8), + ? lighten(theme.palette.background.paper, 0.15) + : lighten(theme.palette.primary.main, 0.8) }, notSelected: { "&:hover": { - backgroundColor: theme.palette.background.default, + backgroundColor: theme.palette.background.default } }, icon: { @@ -39,12 +39,13 @@ const styles = theme => ({ marginRight: "20px", color: theme.palette.text.secondary }, - tableIcon:{ + tableIcon: { marginRight: "20px", - verticalAlign: "middle", + verticalAlign: "middle" }, folderNameSelected: { - color: theme.palette.type === "dark" ? "#fff" : theme.palette.primary.dark, + color: + theme.palette.type === "dark" ? "#fff" : theme.palette.primary.dark, fontWeight: "500", userSelect: "none" }, @@ -54,7 +55,7 @@ const styles = theme => ({ }, folderName: { marginRight: "20px", - display: "flex", + display: "flex" }, hideAuto: { [theme.breakpoints.down("sm")]: { @@ -86,10 +87,15 @@ class TableRowCompoment extends Component { let icon; if (this.props.file.type === "dir") { icon = ; - }else if (this.props.file.type === "up"){ - icon = + } else if (this.props.file.type === "up") { + icon = ; } else { - icon = + icon = ( + + ); } const isSelected = @@ -102,15 +108,17 @@ class TableRowCompoment extends Component { onContextMenu={this.props.contextMenu} onClick={this.props.handleClick} onDoubleClick={this.props.handleDoubleClick.bind(this)} - className={classNames( - { - [classes.selected]: isSelected&&!isShare, - [classes.selectedShared]: isSelected&&isShare, - [classes.notSelected]: !isSelected - } - )} + className={classNames({ + [classes.selected]: isSelected && !isShare, + [classes.selectedShared]: isSelected && isShare, + [classes.notSelected]: !isSelected + })} > - + - + {" "} - {this.props.file.type !== "dir" &&this.props.file.type !== "up"&& + {this.props.file.type !== "dir" && + this.props.file.type !== "up" && sizeToString(this.props.file.size)} - + @@ -133,7 +139,7 @@ const TypeIcon = props => { >
diff --git a/src/component/Login/Activication.js b/src/component/Login/Activication.js index cd5f5f8..9d319a5 100644 --- a/src/component/Login/Activication.js +++ b/src/component/Login/Activication.js @@ -1,19 +1,12 @@ import React, { useCallback, useState, useEffect } from "react"; import { useDispatch } from "react-redux"; import { makeStyles } from "@material-ui/core"; -import { - toggleSnackbar, -} from "../../actions/index"; +import { toggleSnackbar } from "../../actions/index"; import { useHistory } from "react-router-dom"; import API from "../../middleware/Api"; -import { - Button, - Paper, - Avatar, - Typography -} from "@material-ui/core"; +import { Button, Paper, Avatar, Typography } from "@material-ui/core"; import EmailIcon from "@material-ui/icons/EmailOutlined"; -import {useLocation} from "react-router"; +import { useLocation } from "react-router"; const useStyles = makeStyles(theme => ({ layout: { width: "auto", @@ -42,7 +35,7 @@ const useStyles = makeStyles(theme => ({ }, submit: { marginTop: theme.spacing(3) - }, + } })); function useQuery() { @@ -53,8 +46,8 @@ function Activation() { const query = useQuery(); const location = useLocation(); - const [success,setSuccess] = useState(false); - const [email,setEmail] = useState(""); + const [success, setSuccess] = useState(false); + const [email, setEmail] = useState(""); const dispatch = useDispatch(); const ToggleSnackbar = useCallback( @@ -66,10 +59,10 @@ function Activation() { const classes = useStyles(); - - useEffect(() => { - API.get("/user/activate/" + query.get("id") + "?sign=" + query.get("sign")) + API.get( + "/user/activate/" + query.get("id") + "?sign=" + query.get("sign") + ) .then(response => { setEmail(response.data); setSuccess(true); @@ -83,28 +76,29 @@ function Activation() { return (
- {success && - - - - - 激活成功 - - 您的账号已被成功激活。 - - - } - - + {success && ( + + + + + + 激活成功 + + + 您的账号已被成功激活。 + + + + )}
); } diff --git a/src/component/Login/ReCaptcha.js b/src/component/Login/ReCaptcha.js index e07f2c4..678ebc1 100644 --- a/src/component/Login/ReCaptcha.js +++ b/src/component/Login/ReCaptcha.js @@ -11,5 +11,5 @@ function getURL() { export default makeAsyncScriptLoader(getURL, { callbackName, - globalName, -})(ReCAPTCHA); \ No newline at end of file + globalName +})(ReCAPTCHA); diff --git a/src/component/Login/ReCaptchaWrapper.js b/src/component/Login/ReCaptchaWrapper.js index 7a8d21b..56c6623 100644 --- a/src/component/Login/ReCaptchaWrapper.js +++ b/src/component/Login/ReCaptchaWrapper.js @@ -57,7 +57,11 @@ export default class ReCAPTCHA extends React.Component { } explicitRender() { - if (this.props.grecaptcha && this.props.grecaptcha.render && this._widgetId === undefined) { + if ( + this.props.grecaptcha && + this.props.grecaptcha.render && + this._widgetId === undefined + ) { const wrapper = document.createElement("div"); this._widgetId = this.props.grecaptcha.render(wrapper, { sitekey: this.props.sitekey, @@ -70,11 +74,15 @@ export default class ReCAPTCHA extends React.Component { size: this.props.size, stoken: this.props.stoken, hl: this.props.hl, - badge: this.props.badge, + badge: this.props.badge }); this.captcha.appendChild(wrapper); } - if (this._executeRequested && this.props.grecaptcha && this._widgetId !== undefined) { + if ( + this._executeRequested && + this.props.grecaptcha && + this._widgetId !== undefined + ) { this._executeRequested = false; this.execute(); } @@ -152,7 +160,7 @@ ReCAPTCHA.propTypes = { size: PropTypes.oneOf(["compact", "normal", "invisible"]), stoken: PropTypes.string, hl: PropTypes.string, - badge: PropTypes.oneOf(["bottomright", "bottomleft", "inline"]), + badge: PropTypes.oneOf(["bottomright", "bottomleft", "inline"]) }; ReCAPTCHA.defaultProps = { // eslint-disable-next-line @typescript-eslint/no-empty-function @@ -161,5 +169,5 @@ ReCAPTCHA.defaultProps = { type: "image", tabindex: 0, size: "normal", - badge: "bottomright", -}; \ No newline at end of file + badge: "bottomright" +}; diff --git a/src/component/Login/ResetForm.js b/src/component/Login/ResetForm.js index 9f3bb3f..9b5a562 100644 --- a/src/component/Login/ResetForm.js +++ b/src/component/Login/ResetForm.js @@ -51,7 +51,7 @@ const useStyles = makeStyles(theme => ({ display: "flex", width: "100%", justifyContent: "space-between" - }, + } })); function useQuery() { @@ -68,9 +68,9 @@ function ResetForm() { const handleInputChange = name => e => { setInput({ ...input, - [name]:e.target.value - }) - } + [name]: e.target.value + }); + }; const dispatch = useDispatch(); const ToggleSnackbar = useCallback( (vertical, horizontal, msg, color) => @@ -81,15 +81,15 @@ function ResetForm() { const submit = e => { e.preventDefault(); - if (input.password !== input.password_repeat){ + if (input.password !== input.password_repeat) { ToggleSnackbar("top", "right", "两次密码输入不一致", "warning"); - return + return; } setLoading(true); API.patch("/user/reset", { secret: query.get("sign"), id: query.get("id"), - Password: input.password, + Password: input.password }) .then(() => { setLoading(false); @@ -100,7 +100,7 @@ function ResetForm() { setLoading(false); ToggleSnackbar("top", "right", error.message, "warning"); }); - } + }; const classes = useStyles(); diff --git a/src/component/Login/ResetPwdForm.js b/src/component/Login/ResetPwdForm.js index 23e3335..dab0e1c 100644 --- a/src/component/Login/ResetPwdForm.js +++ b/src/component/Login/ResetPwdForm.js @@ -1,8 +1,8 @@ -import React, { Component } from 'react' -import { connect } from 'react-redux' -import KeyIcon from '@material-ui/icons/VpnKeyOutlined'; -import { toggleSnackbar, } from "../../actions/index" -import axios from 'axios' +import React, { Component } from "react"; +import { connect } from "react-redux"; +import KeyIcon from "@material-ui/icons/VpnKeyOutlined"; +import { toggleSnackbar } from "../../actions/index"; +import axios from "axios"; import { withStyles, @@ -14,120 +14,138 @@ import { InputLabel, Paper, Avatar, - Typography, -} from '@material-ui/core'; + Typography +} from "@material-ui/core"; const styles = theme => ({ layout: { - width: 'auto', - marginTop: '110px', + width: "auto", + marginTop: "110px", marginLeft: theme.spacing(3), marginRight: theme.spacing(3), [theme.breakpoints.up(1100 + theme.spacing(3) * 2)]: { width: 400, - marginLeft: 'auto', - marginRight: 'auto', - }, + marginLeft: "auto", + marginRight: "auto" + } }, paper: { marginTop: theme.spacing(8), - display: 'flex', - flexDirection: 'column', - alignItems: 'center', - padding: `${theme.spacing(2)}px ${theme.spacing(3)}px ${theme.spacing(3)}px`, + display: "flex", + flexDirection: "column", + alignItems: "center", + padding: `${theme.spacing(2)}px ${theme.spacing(3)}px ${theme.spacing( + 3 + )}px` }, avatar: { margin: theme.spacing(1), - backgroundColor: theme.palette.secondary.main, + backgroundColor: theme.palette.secondary.main }, form: { - width: '100%', // Fix IE 11 issue. - marginTop: theme.spacing(1), + width: "100%", // Fix IE 11 issue. + marginTop: theme.spacing(1) }, submit: { - marginTop: theme.spacing(3), + marginTop: theme.spacing(3) }, link: { marginTop: "10px", - display:"flex", + display: "flex", width: "100%", - justifyContent: "space-between", + justifyContent: "space-between" }, - captchaContainer:{ - display:"flex", + captchaContainer: { + display: "flex", marginTop: "10px", [theme.breakpoints.down("sm")]: { - display: "block", - }, + display: "block" + } } -}) +}); const mapStateToProps = () => { - return { - } -} + return {}; +}; const mapDispatchToProps = dispatch => { return { toggleSnackbar: (vertical, horizontal, msg, color) => { - dispatch(toggleSnackbar(vertical, horizontal, msg, color)) - }, - } -} + dispatch(toggleSnackbar(vertical, horizontal, msg, color)); + } + }; +}; class ResetPwdFormCompoment extends Component { + state = { + pwd: "", + pwdRepeat: "", + loading: false + }; - state={ - pwd:"", - pwdRepeat:"", - loading:false, - } - - login = e=>{ + login = e => { e.preventDefault(); - if(this.state.pwdRepeat !== this.state.pwd){ - this.props.toggleSnackbar("top","right","两次密码输入不一致","warning"); + if (this.state.pwdRepeat !== this.state.pwd) { + this.props.toggleSnackbar( + "top", + "right", + "两次密码输入不一致", + "warning" + ); return; } this.setState({ - loading:true, + loading: true }); - axios.post('/Member/Reset',{ - pwd:this.state.pwd, - key:window.resetKey, - }).then( (response)=> { - if(response.data.code!=="200"){ + axios + .post("/Member/Reset", { + pwd: this.state.pwd, + key: window.resetKey + }) + .then(response => { + if (response.data.code !== "200") { + this.setState({ + loading: false + }); + this.props.toggleSnackbar( + "top", + "right", + response.data.message, + "warning" + ); + } else { + this.setState({ + loading: false, + pwd: "", + pwdRepeat: "" + }); + this.props.toggleSnackbar( + "top", + "right", + "密码重设成功", + "success" + ); + } + }) + .catch(error => { this.setState({ - loading:false, + loading: false }); - this.props.toggleSnackbar("top","right",response.data.message,"warning"); - }else{ - this.setState({ - loading:false, - pwd:"", - pwdRepeat:"", - }); - this.props.toggleSnackbar("top","right","密码重设成功","success"); - } - }) - .catch((error) =>{ - this.setState({ - loading:false, + this.props.toggleSnackbar( + "top", + "right", + error.message, + "error" + ); }); - this.props.toggleSnackbar("top","right",error.message,"error"); - - - }); - } + }; handleChange = name => event => { this.setState({ [name]: event.target.value }); }; - render() { const { classes } = this.props; - return (
@@ -140,25 +158,27 @@ class ResetPwdFormCompoment extends Component { 新密码 - + 重复新密码 - + -
-
- - 返回登录 - -
-
- - 注册账号 - -
+ {" "} + {" "} + +
+
+ 返回登录
- +
+ 注册账号 +
+
); } - } const ResetPwdForm = connect( mapStateToProps, mapDispatchToProps -)(withStyles(styles)(ResetPwdFormCompoment)) +)(withStyles(styles)(ResetPwdFormCompoment)); -export default ResetPwdForm +export default ResetPwdForm; diff --git a/src/component/Modals/AddTag.js b/src/component/Modals/AddTag.js index 171c67b..6b5a400 100644 --- a/src/component/Modals/AddTag.js +++ b/src/component/Modals/AddTag.js @@ -8,9 +8,7 @@ import { DialogTitle, CircularProgress } from "@material-ui/core"; -import { - toggleSnackbar, -} from "../../actions/index"; +import { toggleSnackbar } from "../../actions/index"; import PathSelector from "../FileManager/PathSelector"; import { useDispatch } from "react-redux"; import API from "../../middleware/Api"; @@ -35,7 +33,7 @@ import { RhombusOutline, Square, SquareOutline, - Triangle, + Triangle } from "mdi-material-ui"; const useStyles = makeStyles(theme => ({ @@ -148,12 +146,12 @@ export default function AddTag(props) { [dispatch] ); - const submitNewLink = ()=>{ + const submitNewLink = () => { setLoading(true); API.post("/tag/link", { path: input.path, - name:input.tagName + name: input.tagName }) .then(response => { setLoading(false); @@ -161,7 +159,7 @@ export default function AddTag(props) { props.onSuccess({ type: 1, name: input.tagName, - expression:input.path, + expression: input.path, color: theme.palette.text.secondary, icon: "FolderHeartOutline", id: response.data @@ -173,7 +171,7 @@ export default function AddTag(props) { .then(() => { setLoading(false); }); - } + }; const submitNewTag = () => { setLoading(true); @@ -203,19 +201,19 @@ export default function AddTag(props) { }); }; const submit = () => { - if (value === 0) { - submitNewTag(); - }else{ - submitNewLink(); - } + if (value === 0) { + submitNewTag(); + } else { + submitNewLink(); + } }; - const selectPath = ()=>{ + const selectPath = () => { setInput({ ...input, path: selectedPath === "//" ? "/" : selectedPath }); setPathSelectDialog(false); - } + }; const classes = useStyles(); @@ -232,13 +230,21 @@ export default function AddTag(props) { aria-labelledby="form-dialog-title" > 选择目录 - + - @@ -355,7 +361,7 @@ export default function AddTag(props) { className={classes.textField} /> - @@ -115,7 +123,11 @@ export default function CreateWebDAVAccount(props) { label="相对根目录" />
-
@@ -124,7 +136,11 @@ export default function CreateWebDAVAccount(props) {
- diff --git a/src/component/Modals/Decompress.js b/src/component/Modals/Decompress.js index bf780be..35947d5 100644 --- a/src/component/Modals/Decompress.js +++ b/src/component/Modals/Decompress.js @@ -9,14 +9,11 @@ import { DialogContentText, CircularProgress } from "@material-ui/core"; -import { - toggleSnackbar, - setModalsLoading, -} from "../../actions/index"; +import { toggleSnackbar, setModalsLoading } from "../../actions/index"; import PathSelector from "../FileManager/PathSelector"; import { useDispatch } from "react-redux"; import API from "../../middleware/Api"; -import {filePath} from "../../utils"; +import { filePath } from "../../utils"; const useStyles = makeStyles(theme => ({ contentFix: { @@ -68,7 +65,7 @@ export default function DecompressDialog(props) { } SetModalsLoading(true); API.post("/file/decompress", { - src:filePath(props.selected[0]), + src: filePath(props.selected[0]), dst: selectedPath === "//" ? "/" : selectedPath }) .then(() => { diff --git a/src/component/Modals/Loading.js b/src/component/Modals/Loading.js index 0a2c027..a434eb2 100644 --- a/src/component/Modals/Loading.js +++ b/src/component/Modals/Loading.js @@ -5,7 +5,7 @@ import DialogContent from "@material-ui/core/DialogContent"; import Dialog from "@material-ui/core/Dialog"; import DialogContentText from "@material-ui/core/DialogContentText"; import { blue } from "@material-ui/core/colors"; -import {useSelector} from "react-redux"; +import { useSelector } from "react-redux"; const useStyles = makeStyles({ avatar: { @@ -23,24 +23,17 @@ const useStyles = makeStyles({ export default function LoadingDialog() { const classes = useStyles(); - const open = useSelector( - state => state.viewUpdate.modals.loading, - ); - const text = useSelector( - state => state.viewUpdate.modals.loadingText, - ); - + const open = useSelector(state => state.viewUpdate.modals.loading); + const text = useSelector(state => state.viewUpdate.modals.loadingText); return ( -
- {text} -
+
{text}
); -} \ No newline at end of file +} diff --git a/src/component/Modals/SelectFile.js b/src/component/Modals/SelectFile.js index 2216454..1be8709 100644 --- a/src/component/Modals/SelectFile.js +++ b/src/component/Modals/SelectFile.js @@ -1,4 +1,4 @@ -import React, {useState, useEffect} from "react"; +import React, { useState, useEffect } from "react"; import { makeStyles } from "@material-ui/core"; import { Button, @@ -29,35 +29,37 @@ const useStyles = makeStyles(theme => ({ marginTop: -12, marginLeft: -12 }, - content:{ - padding:0, + content: { + padding: 0 } })); export default function SelectFileDialog(props) { - const [files,setFiles] = useState(props.files); + const [files, setFiles] = useState(props.files); - useEffect(()=>{ + useEffect(() => { setFiles(props.files); - },[props.files]); + }, [props.files]); - - const handleChange = index => event =>{ + const handleChange = index => event => { const filesCopy = [...files]; // eslint-disable-next-line - filesCopy.map((v,k)=>{ - if (v.index === index){ - filesCopy[k] = {...filesCopy[k],selected:event.target.checked ? "true" : "false"}; + filesCopy.map((v, k) => { + if (v.index === index) { + filesCopy[k] = { + ...filesCopy[k], + selected: event.target.checked ? "true" : "false" + }; } }); setFiles(filesCopy); }; - const submit = () =>{ + const submit = () => { const index = []; // eslint-disable-next-line - files.map(v=>{ - if(v.selected === "true"){ + files.map(v => { + if (v.selected === "true") { index.push(parseInt(v.index)); } }); @@ -77,25 +79,30 @@ export default function SelectFileDialog(props) { {files.map((v, k) => { return ( - - - } - label={v.path} - /> - + + + } + label={v.path} + /> + + ); })}
- - @@ -187,32 +161,36 @@ export default function Authn(props) { - {props.list.map((v) => ( + {props.list.map(v => ( <> - { - setConfirm(true); - setSelected(v.id); - }}> + { + setConfirm(true); + setSelected(v.id); + }} + > deleteCredential(v.id)} + onClick={() => deleteCredential(v.id)} className={classes.flexContainer} > - + ))} - addCredential()}> + addCredential()}> diff --git a/src/component/Setting/Profile.js b/src/component/Setting/Profile.js index beb2212..700138a 100644 --- a/src/component/Setting/Profile.js +++ b/src/component/Setting/Profile.js @@ -17,7 +17,7 @@ import { TableRow, Grid } from "@material-ui/core"; -import {withRouter} from "react-router"; +import { withRouter } from "react-router"; import Pagination from "@material-ui/lab/Pagination"; const styles = theme => ({ @@ -83,7 +83,7 @@ const styles = theme => ({ marginTop: "1px", fontSize: "25px", color: "#ffffff", - opacity: "0.81", + opacity: "0.81" }, th: { minWidth: "106px" @@ -97,7 +97,7 @@ const styles = theme => ({ cursor: "pointer" }, navigator: { - padding:theme.spacing(2), + padding: theme.spacing(2) }, pageInfo: { marginTop: "14px", @@ -110,8 +110,8 @@ const styles = theme => ({ infoContainer: { marginTop: "30px" }, - tableContainer:{ - overflowX:"auto", + tableContainer: { + overflowX: "auto" } }); const mapStateToProps = () => { @@ -131,8 +131,8 @@ class ProfileCompoment extends Component { listType: 0, shareList: [], page: 1, - user:null, - total:0, + user: null, + total: 0 }; handleChange = (event, listType) => { @@ -148,18 +148,29 @@ class ProfileCompoment extends Component { this.loadList(1, "default"); }; - loadList = (page,order) => { - API - .get("/user/profile/" + this.props.match.params.id + "?page=" + page + "&type=" + order) + loadList = (page, order) => { + API.get( + "/user/profile/" + + this.props.match.params.id + + "?page=" + + page + + "&type=" + + order + ) .then(response => { this.setState({ shareList: response.data.items, - user:response.data.user, - total:response.data.total, + user: response.data.user, + total: response.data.total }); }) .catch(error => { - this.props.toggleSnackbar("top", "right", error.message, "error"); + this.props.toggleSnackbar( + "top", + "right", + error.message, + "error" + ); }); }; @@ -182,17 +193,17 @@ class ProfileCompoment extends Component { return (
- {this.state.user === null && -
- } - {this.state.user !== null && + {this.state.user === null &&
} + {this.state.user !== null && (
@@ -303,88 +314,109 @@ class ProfileCompoment extends Component { this.state.listType === 1) && (
- - - - 文件名 - - 分享日期 - - - 下载次数 - - - 浏览次数 - - - - - {this.state.shareList.map((row,id) => ( - - this.props.history.push( - "/s/" + row.key - ) - } - > - - - {row.source?row.source.name:"[已失效]"} - +
+ + + 文件名 + + 分享日期 - {row.create_date} + 下载次数 - {row.downloads} - - - {row.views} + 浏览次数 - ))} - -
+ + + {this.state.shareList.map( + (row, id) => ( + + this.props.history.push( + "/s/" + row.key + ) + } + > + + + {row.source + ? row.source + .name + : "[已失效]"} + + + + {row.create_date} + + + {row.downloads} + + + {row.views} + + + ) + )} + +
{this.state.shareList.length !== 0 && - this.state.listType === 0 && ( -
- this.loadList( - v, - this.state.listType === 0 ? "default" : "hot" - )} - color="secondary" - /> -
- )} + this.state.listType === 0 && ( +
+ + this.loadList( + v, + this.state.listType === + 0 + ? "default" + : "hot" + ) + } + color="secondary" + /> +
+ )}
)} - } - + )}
); } diff --git a/src/component/Setting/Tasks.js b/src/component/Setting/Tasks.js index 7fe8fae..1d69c50 100644 --- a/src/component/Setting/Tasks.js +++ b/src/component/Setting/Tasks.js @@ -10,7 +10,7 @@ import TableCell from "@material-ui/core/TableCell"; import TableBody from "@material-ui/core/TableBody"; import API from "../../middleware/Api"; import TimeAgo from "timeago-react"; -import {getTaskProgress, getTaskStatus, getTaskType} from "../../config"; +import { getTaskProgress, getTaskStatus, getTaskType } from "../../config"; import Pagination from "@material-ui/lab/Pagination"; const useStyles = makeStyles(theme => ({ @@ -28,7 +28,7 @@ const useStyles = makeStyles(theme => ({ }, content: { marginTop: theme.spacing(4), - overflowX:"auto", + overflowX: "auto" }, cardContent: { padding: theme.spacing(2) @@ -39,11 +39,11 @@ const useStyles = makeStyles(theme => ({ create: { marginTop: theme.spacing(2) }, - noWrap:{ - wordBreak: "keepAll", + noWrap: { + wordBreak: "keepAll" }, - footer:{ - padding:theme.spacing(2), + footer: { + padding: theme.spacing(2) } })); @@ -60,33 +60,32 @@ export default function Tasks() { ); const loadList = page => { - API.get("/user/setting/tasks?page=" + page) - .then(response => { - setTasks(response.data.tasks); - setTotal(response.data.total); - }) - .catch(error => { - ToggleSnackbar("top", "right", error.message, "error"); - }); + API.get("/user/setting/tasks?page=" + page) + .then(response => { + setTasks(response.data.tasks); + setTotal(response.data.total); + }) + .catch(error => { + ToggleSnackbar("top", "right", error.message, "error"); + }); }; - + useEffect(() => { loadList(page); // eslint-disable-next-line }, [page]); const getError = error => { - if (error === ""){ - return "-" + if (error === "") { + return "-"; } try { - const res = JSON.parse(error) - return res.msg - }catch (e) { - return "未知" + const res = JSON.parse(error); + return res.msg; + } catch (e) { + return "未知"; } - - } + }; const classes = useStyles(); @@ -100,16 +99,26 @@ export default function Tasks() { 创建于 - 任务类型 - 状态 - 最后进度 + + 任务类型 + + + 状态 + + + 最后进度 + 错误信息 {tasks.map((row, id) => ( - + {getTaskType(row.type)} - {getTaskStatus(row.status)} - {getTaskProgress(row.type,row.progress)} + {getTaskStatus(row.status)} + + + {getTaskProgress(row.type, row.progress)} {getError(row.error)} - ))}
- setPage(v)} - color="secondary"/> + setPage(v)} + color="secondary" + />
diff --git a/src/component/Setting/UserSetting.js b/src/component/Setting/UserSetting.js index 0397ff6..33c5b8e 100644 --- a/src/component/Setting/UserSetting.js +++ b/src/component/Setting/UserSetting.js @@ -12,7 +12,12 @@ import NickIcon from "@material-ui/icons/PermContactCalendar"; import LockIcon from "@material-ui/icons/Lock"; import VerifyIcon from "@material-ui/icons/VpnKey"; import ColorIcon from "@material-ui/icons/Palette"; -import {applyThemes, changeViewMethod, toggleDaylightMode, toggleSnackbar} from "../../actions"; +import { + applyThemes, + changeViewMethod, + toggleDaylightMode, + toggleSnackbar +} from "../../actions"; import axios from "axios"; import FingerprintIcon from "@material-ui/icons/Fingerprint"; import ToggleButton from "@material-ui/lab/ToggleButton"; @@ -43,7 +48,7 @@ import API from "../../middleware/Api"; import Auth from "../../middleware/Auth"; import { withRouter } from "react-router"; import QRCode from "qrcode-react"; -import {Brightness3, ListAlt, PermContactCalendar} from "@material-ui/icons"; +import { Brightness3, ListAlt, PermContactCalendar } from "@material-ui/icons"; import { transformTime } from "../../utils"; import Authn from "./Authn"; @@ -136,18 +141,18 @@ const styles = theme => ({ paddingText: { paddingRight: theme.spacing(2) }, - qrcode:{ + qrcode: { width: 128, marginTop: 16, - marginRight: 16, - }, + marginRight: 16 + } }); const mapStateToProps = state => { return { title: state.siteConfig.title, - authn:state.siteConfig.authn, - viewMethod: state.viewUpdate.explorerViewMethod, + authn: state.siteConfig.authn, + viewMethod: state.viewUpdate.explorerViewMethod }; }; @@ -156,15 +161,15 @@ const mapDispatchToProps = dispatch => { toggleSnackbar: (vertical, horizontal, msg, color) => { dispatch(toggleSnackbar(vertical, horizontal, msg, color)); }, - applyThemes: (color) => { + applyThemes: color => { dispatch(applyThemes(color)); }, - toggleDaylightMode:()=>{ - dispatch(toggleDaylightMode()) + toggleDaylightMode: () => { + dispatch(toggleDaylightMode()); }, changeView: method => { dispatch(changeViewMethod(method)); - }, + } }; }; @@ -208,7 +213,7 @@ class UserSettingCompoment extends Component { two_fa_secret: "", prefer_theme: "", themes: {}, - authn:[], + authn: [] } }; @@ -432,10 +437,9 @@ class UserSettingCompoment extends Component { this.setState({ loading: "changeTheme" }); - API - .patch("/user/setting/theme", { - theme: this.state.chosenTheme - }) + API.patch("/user/setting/theme", { + theme: this.state.chosenTheme + }) .then(() => { this.props.toggleSnackbar( "top", @@ -507,7 +511,7 @@ class UserSettingCompoment extends Component { }; init2FA = () => { - if (this.state.settings.two_factor){ + if (this.state.settings.two_factor) { this.setState({ twoFactor: true }); return; } @@ -515,7 +519,7 @@ class UserSettingCompoment extends Component { .then(response => { this.setState({ two_fa_secret: response.data, - twoFactor: true, + twoFactor: true }); }) .catch(error => { @@ -533,8 +537,8 @@ class UserSettingCompoment extends Component { loading: "twoFactor" }); API.patch("/user/setting/2fa", { - code: this.state.authCode - }) + code: this.state.authCode + }) .then(() => { this.props.toggleSnackbar( "top", @@ -544,9 +548,9 @@ class UserSettingCompoment extends Component { ); this.setState({ loading: "", - settings:{ + settings: { ...this.state.settings, - two_factor:!this.state.settings.two_factor, + two_factor: !this.state.settings.two_factor } }); this.handleClose(); @@ -570,17 +574,17 @@ class UserSettingCompoment extends Component { handleAlignment = (event, chosenTheme) => this.setState({ chosenTheme }); - toggleThemeMode = (current) => { - if (current !== null){ + toggleThemeMode = current => { + if (current !== null) { this.props.toggleDaylightMode(); - Auth.SetPreference("theme_mode",null); + Auth.SetPreference("theme_mode", null); } - } + }; render() { const { classes } = this.props; const user = Auth.GetUser(); - const dark = Auth.GetPreference("theme_mode") + const dark = Auth.GetPreference("theme_mode"); return (
@@ -675,9 +679,7 @@ class UserSettingCompoment extends Component { - + @@ -779,30 +781,29 @@ class UserSettingCompoment extends Component { { - this.setState({ - settings:{ - ...this.state.settings, - authn: [...this.state.settings.authn,credential], - } - }) - } - } - remove={ - (id)=>{ - let credentials = [...this.state.settings.authn]; - credentials = credentials.filter((v)=>{ - return v.id !== id - }) - this.setState({ - settings:{ - ...this.state.settings, - authn: credentials, - } - }) - } - } + add={credential => { + this.setState({ + settings: { + ...this.state.settings, + authn: [ + ...this.state.settings.authn, + credential + ] + } + }); + }} + remove={id => { + let credentials = [...this.state.settings.authn]; + credentials = credentials.filter(v => { + return v.id !== id; + }); + this.setState({ + settings: { + ...this.state.settings, + authn: credentials + } + }); + }} />
- - this.toggleThemeMode(dark)}> + + this.toggleThemeMode(dark)} + > @@ -845,18 +849,22 @@ class UserSettingCompoment extends Component { className={classes.infoTextWithIcon} color="textSecondary" > - {dark&&(dark==="dark" - ? "偏好开启" - : "偏好关闭")} - {dark === null&&"跟随系统"} + {dark && + (dark === "dark" + ? "偏好开启" + : "偏好关闭")} + {dark === null && "跟随系统"} - - this.toggleViewMethod()}> + + this.toggleViewMethod()} + > @@ -869,9 +877,12 @@ class UserSettingCompoment extends Component { className={classes.infoTextWithIcon} color="textSecondary" > - {this.props.viewMethod === "icon" && "大图标"} - {this.props.viewMethod === "list" && "列表"} - {this.props.viewMethod === "smallIcon" && "小图标"} + {this.props.viewMethod === "icon" && + "大图标"} + {this.props.viewMethod === "list" && + "列表"} + {this.props.viewMethod === + "smallIcon" && "小图标"}
- {this.state.settings.two_factor?"关闭":"启用"}二步验证 + + {this.state.settings.two_factor ? "关闭" : "启用"} + 二步验证 +
- - {!this.state.settings.two_factor &&
- {this.state.settings.two_factor?"关闭":"启用"}二步验证 + {this.state.settings.two_factor ? "关闭" : "启用"} + 二步验证
@@ -1199,10 +1221,7 @@ class UserSettingCompoment extends Component { diff --git a/src/component/Setting/WebDAV.js b/src/component/Setting/WebDAV.js index d4b00eb..0f14d63 100644 --- a/src/component/Setting/WebDAV.js +++ b/src/component/Setting/WebDAV.js @@ -58,8 +58,8 @@ export default function WebDAV() { dispatch(toggleSnackbar(vertical, horizontal, msg, color)), [dispatch] ); - - const loadList = () =>{ + + const loadList = () => { API.get("/webdav/accounts") .then(response => { setAccounts(response.data.accounts); @@ -67,10 +67,10 @@ export default function WebDAV() { .catch(error => { ToggleSnackbar("top", "right", error.message, "error"); }); - } + }; useEffect(() => { - loadList(); - // eslint-disable-next-line + loadList(); + // eslint-disable-next-line }, []); const deleteAccount = id => { @@ -138,7 +138,9 @@ export default function WebDAV() { {tab === 0 && (
- WebDAV的地址为:{window.location.origin + "/dav"};登陆用户名统一为:{user.user_name}{" "} + WebDAV的地址为: + {window.location.origin + "/dav"} + ;登陆用户名统一为:{user.user_name}{" "} ;密码为所创建账号的密码。 diff --git a/src/component/Share/LockedFile.js b/src/component/Share/LockedFile.js index 2112685..fd45863 100644 --- a/src/component/Share/LockedFile.js +++ b/src/component/Share/LockedFile.js @@ -13,7 +13,7 @@ import { TextField, Avatar } from "@material-ui/core"; -import { withRouter} from "react-router"; +import { withRouter } from "react-router"; const styles = theme => ({ card: { @@ -57,9 +57,8 @@ class LockedFileCompoment extends Component { super(props); const query = new URLSearchParams(this.props.location.search); this.state = { - pwd: query.get("password"), + pwd: query.get("password") }; - } handleChange = name => event => { @@ -85,7 +84,9 @@ class LockedFileCompoment extends Component { } diff --git a/src/component/Share/MyShare.js b/src/component/Share/MyShare.js index 5510a16..595755f 100644 --- a/src/component/Share/MyShare.js +++ b/src/component/Share/MyShare.js @@ -34,7 +34,7 @@ import { VisibilityOff, VpnKey } from "@material-ui/icons"; import Select from "@material-ui/core/Select"; import MenuItem from "@material-ui/core/MenuItem"; import FormControl from "@material-ui/core/FormControl"; -import {withRouter} from "react-router-dom"; +import { withRouter } from "react-router-dom"; const styles = theme => ({ cardContainer: { @@ -79,9 +79,9 @@ const styles = theme => ({ marginLeft: theme.spacing(1), height: 17 }, - orderSelect:{ - textAlign:"right", - marginTop: 5, + orderSelect: { + textAlign: "right", + marginTop: 5 } }); const mapStateToProps = () => { @@ -102,11 +102,11 @@ class MyShareCompoment extends Component { total: 0, shareList: [], showPwd: null, - orderBy:"created_at DESC", + orderBy: "created_at DESC" }; componentDidMount = () => { - this.loadList(1,this.state.orderBy); + this.loadList(1, this.state.orderBy); }; showPwd = pwd => { @@ -117,31 +117,34 @@ class MyShareCompoment extends Component { this.setState({ showPwd: null }); }; - removeShare = (id) => { - API - .delete("/share/"+id) + removeShare = id => { + API.delete("/share/" + id) .then(() => { - let oldList = this.state.shareList; - oldList = oldList.filter(value => { - return value.key !== id; - }); - this.setState({ - shareList: oldList, - total:this.state.total-1, - }); - this.props.toggleSnackbar( - "top", - "right", - "分享已取消", - "success" - ); - if (oldList.length === 0){ - this.loadList(1,this.state.orderBy); - } - + let oldList = this.state.shareList; + oldList = oldList.filter(value => { + return value.key !== id; + }); + this.setState({ + shareList: oldList, + total: this.state.total - 1 + }); + this.props.toggleSnackbar( + "top", + "right", + "分享已取消", + "success" + ); + if (oldList.length === 0) { + this.loadList(1, this.state.orderBy); + } }) .catch(error => { - this.props.toggleSnackbar("top", "right", error.message, "error"); + this.props.toggleSnackbar( + "top", + "right", + error.message, + "error" + ); }); }; @@ -154,11 +157,10 @@ class MyShareCompoment extends Component { const shareIndex = oldList.findIndex(value => { return value.key === id; }); - API - .patch("/share/"+id, { - prop:"password", - value:oldList[shareIndex].password === "" ? newPwd : "", - }) + API.patch("/share/" + id, { + prop: "password", + value: oldList[shareIndex].password === "" ? newPwd : "" + }) .then(response => { oldList[shareIndex].password = response.data; this.setState({ @@ -166,7 +168,12 @@ class MyShareCompoment extends Component { }); }) .catch(error => { - this.props.toggleSnackbar("top", "right", error.message, "error"); + this.props.toggleSnackbar( + "top", + "right", + error.message, + "error" + ); }); }; @@ -175,11 +182,10 @@ class MyShareCompoment extends Component { const shareIndex = oldList.findIndex(value => { return value.key === id; }); - API - .patch("/share/"+id, { - prop:"preview_enabled", - value:oldList[shareIndex].preview?"false":"true", - }) + API.patch("/share/" + id, { + prop: "preview_enabled", + value: oldList[shareIndex].preview ? "false" : "true" + }) .then(response => { oldList[shareIndex].preview = response.data; this.setState({ @@ -187,13 +193,25 @@ class MyShareCompoment extends Component { }); }) .catch(error => { - this.props.toggleSnackbar("top", "right", error.message, "error"); + this.props.toggleSnackbar( + "top", + "right", + error.message, + "error" + ); }); }; - loadList = (page,orderBy) => { + loadList = (page, orderBy) => { const order = orderBy.split(" "); - API.get("/share?page=" + page + "&order_by=" + order[0] + "&order=" + order[1]) + API.get( + "/share?page=" + + page + + "&order_by=" + + order[0] + + "&order=" + + order[1] + ) .then(response => { if (response.data.items.length === 0) { this.props.toggleSnackbar( @@ -217,14 +235,14 @@ class MyShareCompoment extends Component { this.setState({ page: value }); - this.loadList(value,this.state.orderBy); + this.loadList(value, this.state.orderBy); }; - handleOrderChange = event => { + handleOrderChange = event => { this.setState({ - orderBy:event.target.value, + orderBy: event.target.value }); - this.loadList(this.state.page,event.target.value); + this.loadList(this.state.page, event.target.value); }; isExpired = share => { @@ -239,19 +257,34 @@ class MyShareCompoment extends Component { - 我的分享 - + - + + 创建日期由晚到早 + + + 创建日期由早到晚 + + + 下载次数由大到小 + + + 下载次数由小到大 + + + 浏览次数由大到小 + + + 浏览次数由小到大 + @@ -333,7 +366,14 @@ class MyShareCompoment extends Component { - this.props.history.push("/s/"+value.key + (value.password === "" ?"":"?password=" + value.password)) + this.props.history.push( + "/s/" + + value.key + + (value.password === "" + ? "" + : "?password=" + + value.password) + ) } > @@ -358,9 +398,7 @@ class MyShareCompoment extends Component { placement="top" title="查看密码" onClick={() => - this.showPwd( - value.password - ) + this.showPwd(value.password) } > @@ -374,9 +412,7 @@ class MyShareCompoment extends Component { placement="top" title="变更为私密分享" onClick={() => - this.changePermission( - value.key - ) + this.changePermission(value.key) } > @@ -392,9 +428,7 @@ class MyShareCompoment extends Component { : "允许预览" } onClick={() => - this.changePreviewOption( - value.key - ) + this.changePreviewOption(value.key) } > @@ -423,10 +457,10 @@ class MyShareCompoment extends Component {
+ count={Math.ceil(this.state.total / 18)} + onChange={this.handlePageChange} + color="secondary" + />
{" "} ({ - icon:{ - fontSize: "160px", +const useStyles = makeStyles(theme => ({ + icon: { + fontSize: "160px" }, emptyContainer: { bottom: "0", height: "300px", margin: "50px auto", width: "300px", - color: lighten(theme.palette.text.disabled,0.4), + color: lighten(theme.palette.text.disabled, 0.4), textAlign: "center", paddingTop: "20px" }, emptyInfoBig: { fontSize: "25px", - color: lighten(theme.palette.text.disabled,0.4), - }, + color: lighten(theme.palette.text.disabled, 0.4) + } })); export default function Notice(props) { const classes = useStyles(); return (
- -
- {props.msg} -
+ +
{props.msg}
- - ) -} \ No newline at end of file + ); +} diff --git a/src/component/Share/ReadMe.js b/src/component/Share/ReadMe.js index 7ed7ad4..cf476a5 100644 --- a/src/component/Share/ReadMe.js +++ b/src/component/Share/ReadMe.js @@ -1,5 +1,5 @@ import React, { useCallback, useEffect, useState } from "react"; -import { makeStyles, useTheme } from "@material-ui/core/styles"; +import { makeStyles, useTheme } from "@material-ui/core/styles"; import { MenuBook } from "@material-ui/icons"; import { Typography } from "@material-ui/core"; import Divider from "@material-ui/core/Divider"; @@ -14,8 +14,8 @@ const useStyles = makeStyles(theme => ({ readMeContainer: { marginTop: 30, [theme.breakpoints.down("sm")]: { - marginTop: theme.spacing(2), - }, + marginTop: theme.spacing(2) + } }, readMeHeader: { padding: "10px 16px", @@ -44,18 +44,24 @@ const useStyles = makeStyles(theme => ({ }, ".for-container .for-markdown-preview pre": { backgroundColor: theme.palette.background.default + "!important", - color: theme.palette.type ==="dark"?"#fff !important":"rgba(0, 0, 0, 0.87);!important", + color: + theme.palette.type === "dark" + ? "#fff !important" + : "rgba(0, 0, 0, 0.87);!important" }, ".for-container .for-markdown-preview code": { backgroundColor: theme.palette.background.default + "!important" }, ".for-container .for-markdown-preview a": { - color: theme.palette.type==="dark"?"#67aeff !important":"#0366d6 !important", - }, - ".for-container .for-markdown-preview table th":{ - backgroundColor: theme.palette.background.default + "!important", + color: + theme.palette.type === "dark" + ? "#67aeff !important" + : "#0366d6 !important" }, + ".for-container .for-markdown-preview table th": { + backgroundColor: theme.palette.background.default + "!important" + } } })); diff --git a/src/component/Share/SearchResult.js b/src/component/Share/SearchResult.js index a357660..1074449 100644 --- a/src/component/Share/SearchResult.js +++ b/src/component/Share/SearchResult.js @@ -1,5 +1,5 @@ import React, { useCallback, useEffect, useState } from "react"; -import { useDispatch } from "react-redux"; +import { useDispatch } from "react-redux"; import { toggleSnackbar } from "../../actions"; import OpenIcon from "@material-ui/icons/OpenInNew"; import Pagination from "@material-ui/lab/Pagination"; @@ -12,14 +12,14 @@ import { CardHeader, Typography, Grid, - IconButton, + IconButton } from "@material-ui/core"; import API from "../../middleware/Api"; import TypeIcon from "../FileManager/TypeIcon"; import Select from "@material-ui/core/Select"; import MenuItem from "@material-ui/core/MenuItem"; import FormControl from "@material-ui/core/FormControl"; -import {useHistory} from "react-router-dom"; +import { useHistory } from "react-router-dom"; import { makeStyles } from "@material-ui/core/styles"; import { useLocation } from "react-router"; import TimeAgo from "timeago-react"; @@ -126,13 +126,13 @@ export default function SearchResult() { }, []); useEffect(() => { - const keywords = query.get("keywords"); - if (keywords) { - search(keywords, page, orderBy); - } else { - ToggleSnackbar("top", "right", "请输入搜索关键词", "warning"); - } - }, [location]); + const keywords = query.get("keywords"); + if (keywords) { + search(keywords, page, orderBy); + } else { + ToggleSnackbar("top", "right", "请输入搜索关键词", "warning"); + } + }, [location]); const handlePageChange = (event, value) => { setPage(value); @@ -219,10 +219,7 @@ export default function SearchResult() { - history.push( - "/s/" + - value.key - ) + history.push("/s/" + value.key) } > @@ -248,10 +245,15 @@ export default function SearchResult() { } - subheader={分享于{" "}} + subheader={ + + 分享于{" "} + + + } /> diff --git a/src/component/Share/SharePreload.js b/src/component/Share/SharePreload.js index 35da695..ed33aed 100644 --- a/src/component/Share/SharePreload.js +++ b/src/component/Share/SharePreload.js @@ -41,12 +41,12 @@ export default function SharePreload() { } else { SetSubTitle(); } - }, [share,SetSubTitle,ToggleSnackbar]); + }, [share, SetSubTitle, ToggleSnackbar]); useEffect(() => { return () => { SetSubTitle(); - } + }; // eslint-disable-next-line }, []); @@ -69,12 +69,12 @@ export default function SharePreload() { ToggleSnackbar("top", "right", error.message, "error"); } }); - }, [id, password,ToggleSnackbar]); + }, [id, password, ToggleSnackbar]); return ( }> {share === undefined && } - {share === null && } + {share === null && } {share && share.locked && ( )} - {share&&!share.locked&&!share.is_dir&&} - {share&&!share.locked&&share.is_dir&&} + {share && !share.locked && !share.is_dir && ( + + )} + {share && !share.locked && share.is_dir && ( + + )} ); } diff --git a/src/component/Share/SharedFile.js b/src/component/Share/SharedFile.js index 644f93a..b6903db 100644 --- a/src/component/Share/SharedFile.js +++ b/src/component/Share/SharedFile.js @@ -2,7 +2,8 @@ import React, { Component } from "react"; import { connect } from "react-redux"; import { sizeToString, vhCheck } from "../../utils"; import { - openMusicDialog, openResaveDialog, + openMusicDialog, + openResaveDialog, setSelectedTarget, showImgPreivew, toggleSnackbar @@ -17,8 +18,7 @@ import { withRouter } from "react-router-dom"; import Creator from "./Creator"; import pathHelper from "../../utils/page"; - -vhCheck() +vhCheck(); const styles = theme => ({ layout: { width: "auto", @@ -113,9 +113,9 @@ const mapDispatchToProps = dispatch => { showImgPreivew: first => { dispatch(showImgPreivew(first)); }, - openResave: (key) => { + openResave: key => { dispatch(openResaveDialog(key)); - }, + } }; }; @@ -156,8 +156,8 @@ class SharedFileCompoment extends Component { case "msDoc": this.props.history.push( this.props.share.key + - "/doc?name=" + - encodeURIComponent(this.props.share.source.name) + "/doc?name=" + + encodeURIComponent(this.props.share.source.name) ); return; case "audio": @@ -177,20 +177,26 @@ class SharedFileCompoment extends Component { ); return; case "edit": - this.props.history.push(this.props.share.key + - "/text?name=" + - encodeURIComponent(this.props.share.source.name)); - return + this.props.history.push( + this.props.share.key + + "/text?name=" + + encodeURIComponent(this.props.share.source.name) + ); + return; case "pdf": - this.props.history.push(this.props.share.key + - "/pdf?name=" + - encodeURIComponent(this.props.share.source.name)); - return + this.props.history.push( + this.props.share.key + + "/pdf?name=" + + encodeURIComponent(this.props.share.source.name) + ); + return; case "code": - this.props.history.push(this.props.share.key + - "/code?name=" + - encodeURIComponent(this.props.share.source.name)); - return + this.props.history.push( + this.props.share.key + + "/code?name=" + + encodeURIComponent(this.props.share.source.name) + ); + return; default: this.props.toggleSnackbar( "top", @@ -237,7 +243,7 @@ class SharedFileCompoment extends Component {
- +
{this.props.share.preview && ( - - )} + + )}
-