From 9473427bd639cada86decb16d6e87e698a683bdd Mon Sep 17 00:00:00 2001 From: guofei Date: Mon, 18 Nov 2024 11:56:35 +0800 Subject: [PATCH] fix: add mobile fit --- src/App.css | 38 +++++++- src/App.js | 135 +++++++++++++-------------- src/Components/deviceFrame/index.css | 1 + src/Components/deviceFrame/index.js | 81 ++++++++++------ src/Components/pane/index.css | 55 ++++++++++- src/Components/pane/index.js | 119 +++++++++++++---------- src/apis/loginApi.js | 4 +- src/images/menu.png | Bin 0 -> 2137 bytes src/setupProxy.js | 16 ++-- 9 files changed, 280 insertions(+), 169 deletions(-) create mode 100644 src/images/menu.png diff --git a/src/App.css b/src/App.css index cc98f58..e25a953 100644 --- a/src/App.css +++ b/src/App.css @@ -15,6 +15,34 @@ } } +@media only screen and (orientation: landscape) { + #abc { + width: 200px; + height: 200px; + background-color: red; + } +} + +/* 竖屏 */ +@media only screen and (orientation: portrait) { + #abc { + width: 200px; + height: 200px; + background-color: blue; + } +} + +.pane_mobile { + position: fixed; + left: 0; + top: 0; + bottom: 0; + width: 200px; + height: 100vh; + background-color: #535353; + z-index: 1000; +} + .App-header { background-color: #282c34; min-height: 100vh; @@ -62,7 +90,7 @@ } .pane-btn.checked { - border: 3px solid #00DE7A; + border: 3px solid #00de7a; } .pane-btn + .pane-btn { @@ -94,8 +122,8 @@ .language-select-container .language-select { width: 156px; height: 42px; - background-color: #36383A; - color: #EEEEEE; + background-color: #36383a; + color: #eeeeee; font-size: 14px; display: flex; align-items: center; @@ -104,8 +132,8 @@ .language-select-warpper { position: relative; border-radius: 5px; - background: #36383A; - border: 1px solid #5B5B5B; + background: #36383a; + border: 1px solid #5b5b5b; box-shadow: 0px 3px 0px 0px rgba(0, 0, 0, 0.3); } diff --git a/src/App.js b/src/App.js index 17401e9..b1b941c 100644 --- a/src/App.js +++ b/src/App.js @@ -29,6 +29,8 @@ import { withTranslation } from "react-i18next"; import i18n from "i18next"; import languageImg from "./images/language.png"; import Arrow from './images/arrow.svg' +import logoPanePng from "./images/logo-pane.png"; + import SvgIcon from '@mui/material/SvgIcon'; @@ -40,11 +42,14 @@ function CustomIcon(props) { ); } +const isMobile = () => { + return /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) +} + class App extends React.Component { constructor(props) { super(); this.state = { - mode: "normal", projects: [], selectedProject: {}, selectedProjectName: "", @@ -61,10 +66,16 @@ class App extends React.Component { keepLogin: false, }, language: localStorage.getItem("lang") ?? "zh", + isMobile: isMobile(), }; this.t = props.t; } + componentDidMount() { + window.addEventListener('resize', () => { + this.setState({ isMobile: isMobile() }); + }) + const loginInfo = getLoginInfo(); var tenant = utils.getTenant(); const hideLogo = queryString.parseUrl(window.location.href)?.query @@ -161,12 +172,6 @@ class App extends React.Component { }); } - setMode(mode) { - this.setState({ - mode: mode, - }); - } - setLoginForm(form) { this.setState({ loginForm: { @@ -208,18 +213,7 @@ class App extends React.Component { } render() { - var { - mode, - device, - projects, - selectedProject, - dataUrl, - loading, - loginOpen, - loginForm, - hideLogo, - language, - } = this.state; + const { device, projects, dataUrl, loading, loginOpen, loginForm, hideLogo, language, isMobile } = this.state; const { t } = this.props; return ( @@ -277,44 +271,52 @@ class App extends React.Component { - this.setMode(_mode)} - projects={projects} - device={device} - loading={loading} - hideLogo={hideLogo} - onProjectSelect={(project) => { - this.setSelectedProject(project); - }} - onDeviceChange={(_device) => this.setDevice(_device)} - /> -
-
- - + + { + { + this.setSelectedProject(project); + }} + onDeviceChange={(_device) => this.setDevice(_device)} + /> + } + + { + !isMobile && +
+
+ + +
-
+ } + +
- {mode === "normal" ? ( - this.refreshQrCode()} - /> - ) : ( - this.UpdateSetting(value)} - /> - )} + this.refreshQrCode()} + />
); diff --git a/src/Components/deviceFrame/index.css b/src/Components/deviceFrame/index.css index 5c34e0d..5652748 100644 --- a/src/Components/deviceFrame/index.css +++ b/src/Components/deviceFrame/index.css @@ -15,6 +15,7 @@ right: 24px; bottom: 24px; cursor: pointer; + z-index: 1000; } .qrCode { diff --git a/src/Components/deviceFrame/index.js b/src/Components/deviceFrame/index.js index 5ba9942..6cacefe 100644 --- a/src/Components/deviceFrame/index.js +++ b/src/Components/deviceFrame/index.js @@ -85,6 +85,7 @@ function DeviceFrame(props) { var [cacheKey, setCacheKey] = useState(new Date().getTime()); var [openPopup, setOpenPopup] = useState(false); var [absoluteUrl, setAbsoluteUrl] = useState(""); + var [isMobile, setIsMobile] = useState(props.isMobile); const { t } = useTranslation(); useEffect(() => { @@ -134,8 +135,9 @@ function DeviceFrame(props) { return (
+ refresh refresh()} className="refreshButton" /> - {props.qrDataUrl && ( + {props.qrDataUrl && !isMobile && (
qr code

@@ -147,6 +149,8 @@ function DeviceFrame(props) {

)} + + setOpenPopup(false)} @@ -159,36 +163,57 @@ function DeviceFrame(props) { {t("copySuccess")} -
- background - {props.htmlUrl && ( -