|
@@ -31,4 +31,32 @@ export function getQueryString(name) {
|
|
|
return theRequest;
|
|
|
}
|
|
|
|
|
|
+// webview打开缩放
|
|
|
+export function metaSetScalable(type = "yes") {
|
|
|
+ let setContent = "";
|
|
|
+ let meta = document.querySelector("meta[name='viewport']");
|
|
|
+ const content = meta.getAttribute("content");
|
|
|
+ if (type == "yes") {
|
|
|
+ if (!content.includes("user-scalable=no")) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ setContent = "width=device-width, initial-scale=1.0, minimum-scale=1.0";
|
|
|
+ } else {
|
|
|
+ if (
|
|
|
+ content.includes("user-scalable") &&
|
|
|
+ content.includes("user-scalable=no")
|
|
|
+ ) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var coverSupport =
|
|
|
+ "CSS" in window &&
|
|
|
+ typeof CSS.supports === "function" &&
|
|
|
+ (CSS.supports("top: env(a)") || CSS.supports("top: constant(a)"));
|
|
|
+ setContent = `width=device-width, initial-scale=1.0, user-scalable=no, initial-scale=1.0, maximum-scale=1.0${
|
|
|
+ coverSupport ? ", viewport-fit=cover" : ""
|
|
|
+ }`;
|
|
|
+ }
|
|
|
+ meta.content = setContent;
|
|
|
+}
|
|
|
+
|
|
|
export { togo };
|