GamePortrait/node_modules/.cache/babel-loader/a36319c57e923b7a4d293246383e80fd7393dc3ff7724e9495a07bf7f37188df.json

1 line
6.2 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{"ast":null,"code":"import store from \"@/store\";\n// 挂载拖拽组件\nimport { createApp } from \"vue\";\nimport floatBtn from \"@/components/floatBtn\";\nconst showfloatBtn = options => {\n // 创建一个节点,并将组件挂载上去\n const mountNode = document.createElement(\"div\");\n document.documentElement.appendChild(mountNode);\n const app = createApp(floatBtn, {\n ...options,\n visible: true,\n remove() {\n app.unmount(mountNode); //创建完后要进行销毁\n document.body.removeChild(mountNode);\n }\n });\n return app.mount(mountNode);\n};\n\n// rem计算\nconst resizeWin = () => {\n const o = navigator.userAgent;\n const isAndroid = o.indexOf(\"Android\") > -1 || o.indexOf(\"Adr\") > -1; //android终端\n const isiOS = !!o.match(/\\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端\n let t = document,\n e,\n i,\n model;\n if (isAndroid) {\n // e = window.screen.width\n // i = window.screen.height\n e = t.documentElement.clientWidth;\n i = t.documentElement.clientHeight;\n model = \"android\";\n }\n if (isiOS == false && isAndroid == false) {\n e = t.documentElement.clientWidth - 30;\n i = t.documentElement.clientHeight - 30;\n model = \"pc\";\n }\n if (isiOS) {\n e = t.documentElement.clientWidth;\n i = t.documentElement.clientHeight;\n model = \"ios\";\n }\n Horizontal(e, i, model);\n};\n// 判断是否横屏\nconst Horizontal = (e, i, model) => {\n const landscape = `landscape_${model}`;\n const portrait = `portrait_${model}`;\n const appDome = document.getElementById(\"app\");\n function a(n, o) {\n return n.className.match(new RegExp(\"(\\\\s|^)\" + o + \"(\\\\s|$)\"));\n }\n function o(n, o) {\n a(n, o) || (n.className += \"\" + o);\n }\n function t(n, o) {\n if (a(n, o)) {\n var t = new RegExp(\"(\\\\s|^)\" + o + \"(\\\\s|$)\");\n n.className = n.className.replace(t, \"\");\n }\n }\n document.body.classList.remove(\"landscape_android\");\n document.body.classList.remove(\"portrait_android\");\n document.body.classList.remove(\"landscape_ios\");\n document.body.classList.remove(\"portrait_ios\");\n document.body.classList.remove(\"landscape_pc\");\n document.body.classList.remove(\"portrait_pc\");\n const n = window.orientation;\n let s = 0,\n screen = \"portrait\";\n if (model != \"pc\") {\n if (n == undefined || n == null) {\n location.reload();\n } else if (n == 0 || n == 180) {\n if (model == \"ios\") {\n s = e / 16;\n } else {\n s = e / 12;\n }\n t(document.body, landscape);\n o(document.body, portrait);\n sessionStorage.orientation = portrait;\n appDome.setAttribute(\"style\", `width: ${i}px;height: ${e}px;`);\n screen = \"portrait\";\n // console.log(\"竖屏\", i, e)\n } else {\n t(document.body, portrait);\n o(document.body, landscape);\n sessionStorage.orientation = landscape;\n s = i / 12;\n appDome.setAttribute(\"style\", `width: ${e}px;height: ${i}px;`);\n screen = \"landscape\";\n // console.log(\"横屏\", i, e)\n }\n } else {\n t(document.body, portrait);\n o(document.body, landscape);\n sessionStorage.orientation = landscape;\n s = i / 12;\n appDome.setAttribute(\"style\", `width: ${e}px;height: ${i}px;`);\n screen = \"landscape\";\n }\n isFullScreen(model);\n document.documentElement.style.fontSize = s + \"px\";\n store.commit(\"config/resizeView\", s);\n store.commit(\"config/phoneScreen\", screen);\n store.commit(\"config/phoneModel\", model);\n};\n\n// 函数魔法糖\nconst throttle = (fn, delay, that) => {\n var timer = null;\n return function () {\n var context = that,\n args = arguments;\n clearTimeout(timer);\n timer = setTimeout(function () {\n fn.apply(context, args);\n }, delay);\n };\n};\n\n// 全屏事件\nconst requestFullScreen = () => {\n var element = document.documentElement;\n if (element.requestFullscreen) {\n element.requestFullscreen();\n } else if (element.mozRequestFullScreen) {\n element.mozRequestFullScreen();\n } else if (element.webkitRequestFullscreen) {\n element.webkitRequestFullscreen();\n } else if (element.msRequestFullscreen) {\n element.msRequestFullscreen();\n }\n store.commit(\"config/checkFullscreen\", true);\n};\n//退出全屏\nconst exitFullscreen = () => {\n if (document.exitFullScreen) {\n document.requestFullscreen();\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen();\n } else if (document.webkitExitFullscreen) {\n document.webkitExitFullscreen();\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen();\n }\n store.commit(\"config/checkFullscreen\", false);\n};\nfunction isFullScreen(model) {\n if (model == \"ios\" || model == \"pc\") {\n store.commit(\"config/checkFullscreen\", true);\n } else {\n if (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement) {\n store.commit(\"config/checkFullscreen\", true);\n } else {\n store.commit(\"config/checkFullscreen\", false);\n }\n }\n}\nwindow.onresize = throttle(resizeWin, 100, this);\nresizeWin();\nfunction setupDocumentEvent() {\n // 禁止 ios 缩放屏幕\n document.addEventListener(\"gesturestart\", function (event) {\n event.preventDefault();\n });\n\n // 禁止移动端IOS双击页面变大\n let touchTime = 0;\n document.addEventListener(\"touchstart\", function (event) {\n if (event.touches.length > 1) {\n event.preventDefault();\n }\n });\n document.addEventListener(\"touchend\", function (event) {\n //记录当前点击的时间与下一次时间的间隔\n const nowTime = new Date();\n if (nowTime.getTime() - touchTime <= 300) {\n event.preventDefault();\n }\n touchTime = nowTime.getTime();\n }, false);\n}\nsetTimeout(() => {\n setupDocumentEvent();\n}, 2000);\n\n// document.documentElement.addEventListener(\n// \"touchstart\",\n// function (event) {\n// if (event.touches.length > 1) {\n// event.preventDefault()\n// }\n// },\n// false\n// )\n\nexport { resizeWin, throttle, requestFullScreen, exitFullscreen, showfloatBtn };","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}