From d880fc04870ba0648014909e8faefbfd371fda15 Mon Sep 17 00:00:00 2001 From: lishuang Date: Sun, 12 Jul 2020 23:32:31 +0800 Subject: [PATCH] Fix the share root uuid. --- src/pages/share/Detail.tsx | 61 ++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/pages/share/Detail.tsx b/src/pages/share/Detail.tsx index a2c7cdc..339c003 100644 --- a/src/pages/share/Detail.tsx +++ b/src/pages/share/Detail.tsx @@ -1,8 +1,8 @@ import React from "react"; import TankComponent from "../../common/component/TankComponent"; import TankTitle from "../widget/TankTitle"; -import { Button, Col, Empty, Input, Modal, Row, Space } from "antd"; -import { RouteComponentProps } from "react-router"; +import {Button, Col, Empty, Input, Modal, Row, Space} from "antd"; +import {RouteComponentProps} from "react-router"; import "./Detail.less"; import Share from "../../common/model/share/Share"; import Pager from "../../common/model/base/Pager"; @@ -13,7 +13,7 @@ import FrameLoading from "../widget/FrameLoading"; import Moon from "../../common/model/global/Moon"; import Sun from "../../common/model/global/Sun"; import MessageBoxUtil from "../../common/util/MessageBoxUtil"; -import { ExclamationCircleFilled, DownloadOutlined, StopOutlined, LinkOutlined } from "@ant-design/icons"; +import {DownloadOutlined, ExclamationCircleFilled, LinkOutlined, StopOutlined} from "@ant-design/icons"; import ShareDialogModal from "./widget/ShareDialogModal"; import DateUtil from "../../common/util/DateUtil"; import ShareMatterPanel from "./widget/ShareMatterPanel"; @@ -26,9 +26,11 @@ interface RouteParam { uuid: string; } -interface IProps extends RouteComponentProps {} +interface IProps extends RouteComponentProps { +} -interface IState {} +interface IState { +} export default class Detail extends TankComponent { // 默认分享详情中分页大小 @@ -46,13 +48,13 @@ export default class Detail extends TankComponent { constructor(props: IProps) { super(props); + this.pager.enableHistory(); } componentDidMount(): void { this.share.uuid = this.props.match.params.uuid; //如果query中有rootUuid那么就更新. - this.share.rootUuid = - BrowserUtil.getQueryByName("shareRootUuid") || this.share.rootUuid; + this.share.rootUuid = BrowserUtil.getQueryByName("shareRootUuid") || this.share.rootUuid; this.pager.enableHistory(); this.refresh(); @@ -60,13 +62,16 @@ export default class Detail extends TankComponent { componentWillReceiveProps(nextProps: Readonly, nextContext: any) { if (this.props.location.search !== nextProps.location.search) { - this.pager.enableHistory(); this.refresh(); } } refresh = () => { const puuid = BrowserUtil.getQueryByName("puuid") || Matter.MATTER_ROOT; + if (puuid === Matter.MATTER_ROOT) { + this.share.rootUuid = Matter.MATTER_ROOT + } + this.share.httpBrowse(puuid, this.share.rootUuid, () => { if (puuid === Matter.MATTER_ROOT) { this.pager.clear(); @@ -118,7 +123,7 @@ export default class Detail extends TankComponent { cancelShare = () => { Modal.confirm({ title: Lang.t("share.cancelPrompt"), - icon: , + icon: , onOk: () => { this.share.httpDel(() => { MessageBoxUtil.success(Lang.t("operationSuccess")); @@ -131,7 +136,7 @@ export default class Detail extends TankComponent { previewImage = (matter: Matter) => { let imageArray: string[] = []; let startIndex = -1; - const { share } = this; + const {share} = this; this.pager.data.forEach((item) => { if (item.isImage()) { imageArray.push(item.getSharePreviewUrl(share.uuid!, share.code!, share.rootUuid)); @@ -144,26 +149,26 @@ export default class Detail extends TankComponent { ImagePreviewer.showMultiPhoto(imageArray, startIndex); }; - goToDirectory = (id?: string) => { + goToDirectory = (matterUuid?: string) => { const paramId = this.props.match.params.uuid; - if (id) { + if (matterUuid) { //share.rootUuid 一旦设置好了,只要根文件夹不换,那么就一直不会变。 const puuid = BrowserUtil.getQueryByName("puuid"); if (!puuid || puuid === Matter.MATTER_ROOT) { - this.share.rootUuid = id; + this.share.rootUuid = matterUuid; this.pager.clear(); } - this.pager.setFilterValue("puuid", id); + this.pager.setFilterValue("puuid", matterUuid); this.pager.page = 0; const query = this.pager.getParams(); - Sun.navigateQueryTo({ path: `/share/detail/${paramId}`, query }); + Sun.navigateQueryTo({path: `/share/detail/${paramId}`, query}); } else { // 回到分享根目录,先将rootUuid交给根目录 this.share.rootUuid = Matter.MATTER_ROOT; this.pager.clear(); - Sun.navigateQueryTo({ path: `/share/detail/${paramId}` }); + Sun.navigateQueryTo({path: `/share/detail/${paramId}`}); } }; @@ -196,14 +201,12 @@ export default class Detail extends TankComponent { }; render() { - const { share, needShareCode, user, pager } = this; + const {share, needShareCode, user, pager} = this; - console.log(share); - - if (share.detailLoading && needShareCode) return ; + if (share.detailLoading && needShareCode) return ; return (
- + {needShareCode ? (
@@ -222,7 +225,7 @@ export default class Detail extends TankComponent {
- + {share.name} {share.hasExpired() ? ( @@ -235,20 +238,20 @@ export default class Detail extends TankComponent {
{user.uuid && user.uuid === share.userUuid ? ( <> @@ -269,15 +272,15 @@ export default class Detail extends TankComponent { {share.expireInfinity ? Lang.t("share.noExpire") : `${Lang.t( - "share.expireTime" - )}:${DateUtil.simpleDateHourMinute(share.expireTime)}`} + "share.expireTime" + )}:${DateUtil.simpleDateHourMinute(share.expireTime)}`}
- +
{pager.data.length ? ( @@ -291,7 +294,7 @@ export default class Detail extends TankComponent { /> )) ) : ( - + )}
)}