yuchao 4 years ago
parent
commit
63611532c7
2 changed files with 16 additions and 2 deletions
  1. 1 1
      old/code/public/index.html
  2. 15 1
      old/code/src/page/index.tsx

+ 1 - 1
old/code/public/index.html

@@ -18,5 +18,5 @@
     <noscript>You need to enable JavaScript to run this app.</noscript>
     <div id="root"></div>
   </body>
-  <img src="%PUBLIC_URL%/logo.jpg" width="0" height="0" />
+<!--  <img src="%PUBLIC_URL%/logo.jpg" width="0" height="0" />-->
 </html>

+ 15 - 1
old/code/src/page/index.tsx

@@ -1,5 +1,15 @@
 import React, { useEffect, useState } from "react";
 
+const isWeiXin = () => {
+	const ua = window.navigator.userAgent.toLowerCase();
+	// @ts-ignore
+	if (ua.match(/MicroMessenger/i) === 'micromessenger') {
+		return true;
+	} else {
+		return false;
+	}
+}
+
 export const Page = (props: any) => {
 	const [zoom, setZoom] = useState(0.5);
 	const [scale, setScale] = useState("");
@@ -15,7 +25,11 @@ export const Page = (props: any) => {
 			if (width > height) {
 				setScale(`scale(1,${scale})`)
 			} else {
-				setScale(`scale(${scale},1) rotate(90deg)`)
+				if (isWeiXin()) {
+					setScale(`scale(${scale},1) rotate(90deg)`)
+				} else {
+					setScale(`scale(${scale},${(1792 - 120)/1792}) rotate(90deg) translateX(${-60 * max * scale / 1792}px)`)
+				}
 			}
 		};
 		recalc()