diff --git a/src/pages/user/Detail.less b/src/pages/user/Detail.less index 7d1d500..c174b99 100644 --- a/src/pages/user/Detail.less +++ b/src/pages/user/Detail.less @@ -1,3 +1,10 @@ .page-user-detail { - + .handles { + flex-wrap: wrap; + &-mobile { + button { + margin-bottom: 10px; + } + } + } } diff --git a/src/pages/user/Detail.tsx b/src/pages/user/Detail.tsx index 759f6e0..fa8ba26 100644 --- a/src/pages/user/Detail.tsx +++ b/src/pages/user/Detail.tsx @@ -1,229 +1,233 @@ -import React from 'react'; -import "./Detail.less" +import React from "react"; +import "./Detail.less"; import TankComponent from "../../common/component/TankComponent"; -import {Button, Tag} from 'antd'; +import { Button, Tag, Space } from "antd"; import InfoCell from "../widget/InfoCell"; import User from "../../common/model/user/User"; import Moon from "../../common/model/global/Moon"; import DateUtil from "../../common/util/DateUtil"; -import TankTitle from '../widget/TankTitle'; +import TankTitle from "../widget/TankTitle"; import TankContentCard from "../widget/TankContentCard"; -import {Link, RouteComponentProps} from "react-router-dom"; +import { Link, RouteComponentProps } from "react-router-dom"; import ImagePreviewer from "../widget/previewer/ImagePreviewer"; -import {UserRole, UserRoleMap} from "../../common/model/user/UserRole"; +import { UserRole, UserRoleMap } from "../../common/model/user/UserRole"; import FileUtil from "../../common/util/FileUtil"; -import {UserStatus, UserStatusMap} from "../../common/model/user/UserStatus"; +import { UserStatus, UserStatusMap } from "../../common/model/user/UserStatus"; import BrowserUtil from "../../common/util/BrowserUtil"; import SingleTextModal from "../widget/SingleTextModal"; import MessageBoxUtil from "../../common/util/MessageBoxUtil"; import ChangePasswordModal from "./widget/ChangePasswordModal"; -import {EditOutlined, UnlockOutlined, UserSwitchOutlined} from '@ant-design/icons'; +import { + EditOutlined, + UnlockOutlined, + UserSwitchOutlined, +} from "@ant-design/icons"; import TransfigurationModal from "./widget/TransfigurationModal"; -import {FileSyncOutlined, StopOutlined} from "@ant-design/icons/lib"; +import { FileSyncOutlined, StopOutlined } from "@ant-design/icons/lib"; import Lang from "../../common/model/global/Lang"; +import Sun from "../../common/model/global/Sun"; interface RouteParam { - uuid: string + uuid: string; } +interface IProps extends RouteComponentProps {} -interface IProps extends RouteComponentProps { - -} - -interface IState { - -} - -export default class Detail extends TankComponent { +interface IState {} +export default class Detail extends TankComponent { //登录的那个用户 - user: User = Moon.getSingleton().user + user: User = Moon.getSingleton().user; //当前页面正在编辑的用户 - currentUser: User = new User(this) + currentUser: User = new User(this); //sync loading. - syncLoading: boolean = false + syncLoading: boolean = false; constructor(props: IProps) { - super(props) - this.state = {} + super(props); + this.state = {}; } - componentDidMount() { - let that = this + let that = this; let match = this.props.match; this.currentUser.uuid = match.params.uuid; - this.currentUser.httpDetail() + this.currentUser.httpDetail(); } resetPassword() { - let that = this + let that = this; - SingleTextModal.open(Lang.t("user.enterNewPassword"), "", function (text: string) { + SingleTextModal.open(Lang.t("user.enterNewPassword"), "", function ( + text: string + ) { that.currentUser.httpResetPassword(text, function (response: any) { - MessageBoxUtil.success(Lang.t("operationSuccess")) - }) - }) - + MessageBoxUtil.success(Lang.t("operationSuccess")); + }); + }); } transfiguration() { - - let user: User = this.user - let currentUser: User = this.currentUser - TransfigurationModal.open(currentUser) - + let user: User = this.user; + let currentUser: User = this.currentUser; + TransfigurationModal.open(currentUser); } toggleStatus() { - let that = this - let user: User = this.user - let currentUser: User = this.currentUser + let that = this; + let user: User = this.user; + let currentUser: User = this.currentUser; currentUser.httpToggleStatus(function () { - MessageBoxUtil.success(Lang.t("operationSuccess")) - that.updateUI() - }) + MessageBoxUtil.success(Lang.t("operationSuccess")); + that.updateUI(); + }); } - syncPhysics() { - let that = this - let user: User = this.user - let currentUser: User = this.currentUser - this.syncLoading = true - currentUser.httpScan(function () { - MessageBoxUtil.success(Lang.t("operationSuccess")) - that.updateUI() - }, null, function () { - that.syncLoading = false - that.updateUI() - }) + let that = this; + let user: User = this.user; + let currentUser: User = this.currentUser; + this.syncLoading = true; + currentUser.httpScan( + function () { + MessageBoxUtil.success(Lang.t("operationSuccess")); + that.updateUI(); + }, + null, + function () { + that.syncLoading = false; + that.updateUI(); + } + ); } - changePassword() { - - let user: User = this.user - let currentUser: User = this.currentUser + let user: User = this.user; + let currentUser: User = this.currentUser; ChangePasswordModal.open(currentUser, function () { - MessageBoxUtil.success(Lang.t("operationSuccess")) - }) + MessageBoxUtil.success(Lang.t("operationSuccess")); + }); } render() { + const user: User = this.user; + const currentUser: User = this.currentUser; - let user: User = this.user - let currentUser: User = this.currentUser + const handles = ( + + {user.role === UserRole.ADMINISTRATOR && ( + + )} + + {user.role === UserRole.ADMINISTRATOR && ( + + )} + + {currentUser.uuid === user.uuid && ( + + )} + + + + + + {user.role === UserRole.ADMINISTRATOR && + currentUser.uuid !== user.uuid && ( + + )} + + {user.role === UserRole.ADMINISTRATOR && ( + + )} + + ); return ( -
- - - { - user.role === UserRole.ADMINISTRATOR && ( - - ) - } - - { - user.role === UserRole.ADMINISTRATOR && ( - - ) - } - - { - currentUser.uuid === user.uuid && ( - - ) - } - - - - - - { - (user.role === UserRole.ADMINISTRATOR && currentUser.uuid !== user.uuid) && ( - - ) - } - - { - (user.role === UserRole.ADMINISTRATOR && ( - - )) - } - + {!Sun.getSingleton().isMobile && handles} + {Sun.getSingleton().isMobile && handles} -
- avatar { - ImagePreviewer.showSinglePhoto(currentUser.getAvatarUrl(true)) - }}/> -
- {currentUser.username} -
+ avatar { + ImagePreviewer.showSinglePhoto(currentUser.getAvatarUrl(true)); + }} + /> +
{currentUser.username}
- - {UserRoleMap[currentUser.role].name} + + {UserRoleMap[currentUser.role].name} + - {FileUtil.humanFileSize(currentUser.sizeLimit)} - {FileUtil.humanFileSize(currentUser.totalSizeLimit)} - {FileUtil.humanFileSize(currentUser.totalSize)} - - {UserStatusMap[currentUser.status].name} + + {UserStatusMap[currentUser.status].name} + - {currentUser.lastIp} - {DateUtil.simpleDateTime(currentUser.lastTime)} @@ -232,21 +236,19 @@ export default class Detail extends TankComponent { {BrowserUtil.fullHost() + "/api/dav"} - { - currentUser.role === UserRole.ADMINISTRATOR && ( - - - https://tank-doc.eyeblue.cn - - - ) - } - + {currentUser.role === UserRole.ADMINISTRATOR && ( + + + https://tank-doc.eyeblue.cn + + + )}
- -
- ) + ); } } -