diff --git a/package.json b/package.json index 26b8a79..f6e2a74 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cloudreve-frontend", - "version": "3.5.2", + "version": "3.5.3", "private": true, "dependencies": { "@babel/core": "7.6.0", diff --git a/src/component/FileManager/FileIcon.js b/src/component/FileManager/FileIcon.js index 03ffc6b..06b81b9 100644 --- a/src/component/FileManager/FileIcon.js +++ b/src/component/FileManager/FileIcon.js @@ -125,6 +125,7 @@ const mapStateToProps = (state) => { return { path: state.navigator.path, selected: state.explorer.selected, + shareInfo: state.viewUpdate.shareInfo, }; }; @@ -200,9 +201,9 @@ class FileIconCompoment extends Component { )} src={ baseURL + - (isSharePage + (isSharePage && this.props.shareInfo ? "/share/thumb/" + - window.shareInfo.key + + this.props.shareInfo.key + "/" + this.props.file.id + "?path=" + diff --git a/src/component/FileManager/Navigator/Navigator.js b/src/component/FileManager/Navigator/Navigator.js index 96ee19a..aadfeab 100644 --- a/src/component/FileManager/Navigator/Navigator.js +++ b/src/component/FileManager/Navigator/Navigator.js @@ -475,7 +475,7 @@ class NavigatorComponent extends Component { ))}
- +
diff --git a/src/component/FileManager/Navigator/SubActions.js b/src/component/FileManager/Navigator/SubActions.js index 5db12d1..4770b61 100644 --- a/src/component/FileManager/Navigator/SubActions.js +++ b/src/component/FileManager/Navigator/SubActions.js @@ -33,11 +33,12 @@ const sortOptions = [ const paginationOption = ["50", "100", "200", "500", "1000"]; -export default function SubActions({ isSmall, share, inherit }) { +export default function SubActions({ isSmall, inherit }) { const dispatch = useDispatch(); const viewMethod = useSelector( (state) => state.viewUpdate.explorerViewMethod ); + const share = useSelector((state) => state.viewUpdate.shareInfo); const pageSize = useSelector((state) => state.viewUpdate.pagination.size); const OpenLoadingDialog = useCallback( (method) => dispatch(changeViewMethod(method)), diff --git a/src/component/FileManager/ObjectIcon.js b/src/component/FileManager/ObjectIcon.js index 362b32c..fc9dfd8 100644 --- a/src/component/FileManager/ObjectIcon.js +++ b/src/component/FileManager/ObjectIcon.js @@ -36,6 +36,7 @@ const useStyles = makeStyles(() => ({ export default function ObjectIcon(props) { const path = useSelector((state) => state.navigator.path); + const shareInfo = useSelector((state) => state.viewUpdate.shareInfo); const selected = useSelector((state) => state.explorer.selected); const viewMethod = useSelector( (state) => state.viewUpdate.explorerViewMethod @@ -109,7 +110,12 @@ export default function ObjectIcon(props) { } SelectFile(e); - if (props.file.type === "dir" && (!e.ctrlKey && !e.metaKey && !e.shiftKey)) { + if ( + props.file.type === "dir" && + !e.ctrlKey && + !e.metaKey && + !e.shiftKey + ) { enterFolder(); } }; @@ -123,7 +129,7 @@ export default function ObjectIcon(props) { return; } - OpenPreview(window.shareInfo); + OpenPreview(shareInfo); }; const handleIconClick = (e) => { diff --git a/src/component/Navbar/Navbar.js b/src/component/Navbar/Navbar.js index dda14b2..7f5782b 100644 --- a/src/component/Navbar/Navbar.js +++ b/src/component/Navbar/Navbar.js @@ -83,6 +83,7 @@ const mapStateToProps = (state) => { subTitle: state.viewUpdate.subTitle, loadUploader: state.viewUpdate.loadUploader, isLogin: state.viewUpdate.isLogin, + shareInfo: state.viewUpdate.shareInfo, registerEnabled: state.siteConfig.registerEnabled, audioPreviewPlayingName: state.explorer.audioPreview.playingName, audioPreviewIsOpen: state.explorer.audioPreview.isOpen, @@ -334,11 +335,11 @@ class NavbarCompoment extends Component { }; openDownload = () => { - this.props.startDownload(window.shareInfo, this.props.selected[0]); + this.props.startDownload(this.props.shareInfo, this.props.selected[0]); }; archiveDownload = (e) => { - this.props.startBatchDownload(window.shareInfo); + this.props.startBatchDownload(this.props.shareInfo); }; signOut = () => { @@ -503,7 +504,9 @@ class NavbarCompoment extends Component { this.props.history.push("/signup")} + onClick={() => + this.props.history.push("/signup") + } > @@ -635,7 +638,8 @@ class NavbarCompoment extends Component { color="inherit" onClick={() => this.props.openPreview( - window.shareInfo + this.props + .shareInfo ) } > @@ -798,7 +802,10 @@ class NavbarCompoment extends Component { {this.props.selected.length === 0 && } {this.props.selected.length === 0 && - pathHelper.isMobile() && } + pathHelper.isMobile() && + (isHomePage || this.props.shareInfo) && ( + + )} diff --git a/src/component/Share/SharedFolder.js b/src/component/Share/SharedFolder.js index d095d4f..3316740 100644 --- a/src/component/Share/SharedFolder.js +++ b/src/component/Share/SharedFolder.js @@ -16,6 +16,7 @@ import { showImgPreivew, toggleSnackbar, } from "../../redux/explorer"; +import { setShareInfo } from "../../redux/viewUpdate/action"; const styles = (theme) => ({ layout: { @@ -69,6 +70,9 @@ const mapDispatchToProps = (dispatch) => { setShareUserPopover: (e) => { dispatch(setShareUserPopover(e)); }, + setShareInfo: (s) => { + dispatch(setShareInfo(s)); + }, }; }; @@ -76,11 +80,11 @@ class SharedFolderComponent extends Component { state = {}; UNSAFE_componentWillMount() { - window.shareInfo = this.props.share; + this.props.setShareInfo(this.props.share); } componentWillUnmount() { - window.shareInfo = null; + this.props.setShareInfo(null); this.props.setSelectedTarget([]); } diff --git a/src/redux/viewUpdate/action.ts b/src/redux/viewUpdate/action.ts index 910d8c4..67d66e8 100644 --- a/src/redux/viewUpdate/action.ts +++ b/src/redux/viewUpdate/action.ts @@ -67,6 +67,13 @@ export const setPagination = (pagination) => { }; }; +export const setShareInfo = (shareInfo) => { + return { + type: "SET_SHARE_INFO", + shareInfo: shareInfo, + }; +}; + export const changePageSize = ( size: number ): ThunkAction => { diff --git a/src/redux/viewUpdate/reducer.ts b/src/redux/viewUpdate/reducer.ts index b660a87..731d751 100644 --- a/src/redux/viewUpdate/reducer.ts +++ b/src/redux/viewUpdate/reducer.ts @@ -348,6 +348,11 @@ const viewUpdate = (state: ViewUpdateState = initState, action: AnyAction) => { ...state, pagination: action.pagination, }; + case "SET_SHARE_INFO": + return { + ...state, + shareInfo: action.shareInfo, + }; default: return state; } diff --git a/src/utils/index.js b/src/utils/index.js index 69769cc..b227126 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -40,21 +40,6 @@ export const setGetParameter = (paramName, paramValue) => { window.history.pushState(null, null, url); }; -export const allowSharePreview = () => { - if (!window.isSharePage) { - return true; - } - if (window.isSharePage) { - if (window.shareInfo.allowPreview) { - return true; - } - if (window.userInfo.uid === -1) { - return false; - } - return true; - } -}; - export const checkGetParameters = (field) => { const url = window.location.href; if (url.indexOf("?" + field + "=") !== -1) return true;