12345678910111213141516171819202122232425262728 |
- (() => {
- // const isMobile =
- // /(iPhone|iPad|iPod|iOS|Android|Linux armv8l|Linux armv7l|Linux aarch64)/i.test(
- // navigator.platform
- // );
- const isMobile =
- /(iPhone|iPad|iPod|iOS|Android|Linux armv8l|Linux armv7l|Linux aarch64)/i.test(
- navigator.userAgent
- );
- function resize() {
- const path = location.pathname;
- if (isMobile && !path.includes("mobile")) {
- location.href = location.href.replace(".html", "-mobile.html");
- }
- if (!isMobile && path.includes("mobile")) {
- location.href = location.href.replace("-mobile.html", ".html");
- }
- const htmlStyle = document.querySelector("html").style;
- htmlStyle.fontSize =
- (isMobile
- ? window.screen.availWidth / 375
- : window.innerWidth / window.screen.availWidth) *
- 16 +
- "px";
- }
- resize();
- window.addEventListener("resize", () => resize());
- })();
|