From 7e67f964b378b5ab259a14ee0b2e273bd9fc80ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= <2897217417@qq.com> Date: Wed, 15 May 2024 11:22:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E9=9C=80=E5=BC=95=E5=85=A5viewport?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 3 ++- src/modules/loginRegister/LoginRegisterPage.jsx | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/public/index.html b/public/index.html index ad802bc01..ab8c095b9 100755 --- a/public/index.html +++ b/public/index.html @@ -23,7 +23,8 @@ - + + diff --git a/src/modules/loginRegister/LoginRegisterPage.jsx b/src/modules/loginRegister/LoginRegisterPage.jsx index 24f74a455..2eaea2625 100644 --- a/src/modules/loginRegister/LoginRegisterPage.jsx +++ b/src/modules/loginRegister/LoginRegisterPage.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect } from "react"; import Login from "./Login"; import Register from "./Register"; import ResetPassword from "./ResetPassword"; @@ -9,9 +9,24 @@ import ball from './img/ball.png'; import img1 from './img/img1.png'; import img2 from './img/img2.png'; import '../loginRegister/LoginRegisterPage.scss'; +import { isPhone } from 'educoder'; function LoginRegisterPage(props){ const {mygetHelmetapi} = props; + + useEffect(()=>{ + let initialContent = undefined; + if(isPhone()){ + initialContent = document.querySelector('meta[name="viewport"]').getAttribute('content'); + document.querySelector('meta[name="viewport"]').setAttribute('content','width=device-width, user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0'); + } + return()=>{ + if(isPhone()){ + document.querySelector('meta[name="viewport"]').setAttribute('content', initialContent); + } + } + },[]) + return(