{"remainingRequest":"D:\\jenkins\\workspace\\yhxt-web\\node_modules\\thread-loader\\dist\\cjs.js!D:\\jenkins\\workspace\\yhxt-web\\node_modules\\babel-loader\\lib\\index.js!D:\\jenkins\\workspace\\yhxt-web\\node_modules\\cache-loader\\dist\\cjs.js??ref--0-0!D:\\jenkins\\workspace\\yhxt-web\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\yhxt-web\\src\\components\\scale-screen.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\yhxt-web\\src\\components\\scale-screen.vue","mtime":1706175428944},{"path":"D:\\jenkins\\workspace\\yhxt-web\\babel.config.js","mtime":1667326389982},{"path":"D:\\jenkins\\workspace\\yhxt-web\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\yhxt-web\\node_modules\\thread-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\yhxt-web\\node_modules\\babel-loader\\lib\\index.js","mtime":456789000000},{"path":"D:\\jenkins\\workspace\\yhxt-web\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\yhxt-web\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["import \"regenerator-runtime/runtime\";\nimport _asyncToGenerator from \"D:/jenkins/workspace/yhxt-web/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport _typeof from \"D:/jenkins/workspace/yhxt-web/node_modules/@babel/runtime/helpers/esm/typeof.js\";\nimport \"core-js/modules/es6.number.constructor\";\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\n/**\n * 防抖函数\n * @param {T} fn\n * @param {number} delay\n * @return\n */\nfunction debounce(fn, delay) {\n var timer = null;\n return function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n timer = setTimeout(function () {\n typeof fn === \"function\" && fn.apply(null, args);\n clearTimeout(timer);\n }, delay > 0 ? delay : 100);\n };\n}\nexport default {\n name: \"VScaleScreen\",\n props: {\n width: {\n type: [String, Number],\n default: 1920\n },\n height: {\n type: [String, Number],\n default: 1080\n },\n fullScreen: {\n type: Boolean,\n default: false\n },\n autoScale: {\n type: [Object, Boolean],\n default: true\n },\n selfAdaption: {\n type: Boolean,\n default: true\n },\n delay: {\n type: Number,\n default: 500\n },\n boxStyle: {\n type: Object,\n default: function _default() {\n return {};\n }\n },\n wrapperStyle: {\n type: Object,\n default: function _default() {\n return {};\n }\n }\n },\n data: function data() {\n return {\n currentWidth: 0,\n currentHeight: 0,\n originalWidth: 0,\n originalHeight: 0,\n onResize: null,\n observer: null\n };\n },\n watch: {\n selfAdaption: function selfAdaption(val) {\n if (val) {\n this.resize();\n this.addListener();\n } else {\n this.clearListener();\n this.clearStyle();\n }\n }\n },\n computed: {\n screenWrapper: function screenWrapper() {\n return this.$refs[\"screenWrapper\"];\n }\n },\n methods: {\n initSize: function initSize() {\n var _this = this;\n return new Promise(function (resolve, reject) {\n // console.log(\"初始化样式\");\n //给父元素设置 overflow:hidden\n _this.screenWrapper.parentNode.style.overflow = \"hidden\";\n _this.screenWrapper.parentNode.scrollLeft = 0;\n _this.screenWrapper.parentNode.scrollTop = 0;\n _this.$nextTick(function () {\n // region 获取大屏真实尺寸\n if (_this.width && _this.height) {\n _this.currentWidth = _this.width;\n _this.currentHeight = _this.height;\n } else {\n _this.currentWidth = _this.screenWrapper.clientWidth;\n _this.currentHeight = _this.screenWrapper.clientHeight;\n }\n // endregion\n // region 获取画布尺寸\n if (!_this.originalHeight || !_this.originalWidth) {\n _this.originalWidth = window.screen.width;\n _this.originalHeight = window.screen.height;\n }\n // endregion\n resolve();\n });\n });\n },\n updateSize: function updateSize() {\n if (this.currentWidth && this.currentHeight) {\n this.screenWrapper.style.width = \"\".concat(this.currentWidth, \"px\");\n this.screenWrapper.style.height = \"\".concat(this.currentHeight, \"px\");\n } else {\n this.screenWrapper.style.width = \"\".concat(this.originalWidth, \"px\");\n this.screenWrapper.style.height = \"\".concat(this.originalHeight, \"px\");\n }\n },\n handleAutoScale: function handleAutoScale(scale) {\n if (!this.autoScale) return;\n var screenWrapper = this.screenWrapper;\n var domWidth = screenWrapper.clientWidth;\n var domHeight = screenWrapper.clientHeight;\n var currentWidth = document.body.clientWidth;\n var currentHeight = document.body.clientHeight;\n screenWrapper.style.transform = \"scale(\".concat(scale, \",\").concat(scale, \") \");\n var mx = Math.max((currentWidth - domWidth * scale) / 2, 0);\n var my = Math.max((currentHeight - domHeight * scale) / 2, 0);\n if (_typeof(this.autoScale) === \"object\") {\n // @ts-ignore\n !this.autoScale.x && (mx = 0);\n // @ts-ignore\n !this.autoScale.y && (my = 0);\n }\n // console.log({\n // mx,\n // my,\n // currentWidth,\n // currentHeight,\n // domWidth,\n // domHeight,\n // scale,\n // });\n this.screenWrapper.style.margin = \"\".concat(my, \"px \").concat(mx, \"px\");\n },\n updateScale: function updateScale() {\n var screenWrapper = this.screenWrapper;\n // 获取真实视口尺寸\n var currentWidth = document.body.clientWidth;\n var currentHeight = document.body.clientHeight;\n // 获取大屏最终的宽高onResize\n var realWidth = this.currentWidth || this.originalWidth;\n var realHeight = this.currentHeight || this.originalHeight;\n // 计算缩放比例\n var widthScale = currentWidth / realWidth;\n var heightScale = currentHeight / realHeight;\n // console.log({currentWidth, currentHeight,realWidth,realHeight});\n\n // 若要铺满全屏,则按照各自比例缩放\n if (this.fullScreen) {\n screenWrapper.style.transform = \"scale(\".concat(widthScale, \",\").concat(heightScale, \")\");\n return false;\n }\n // 按照宽高最小比例进行缩放\n var scale = Math.min(widthScale, heightScale);\n this.handleAutoScale(scale);\n },\n initMutationObserver: function initMutationObserver() {\n var _this2 = this;\n var screenWrapper = this.screenWrapper;\n var observer = this.observer = new MutationObserver(function () {\n _this2.onResize();\n });\n observer.observe(screenWrapper, {\n attributes: true,\n attributeFilter: [\"style\"],\n attributeOldValue: true\n });\n },\n clearListener: function clearListener() {\n window.removeEventListener(\"resize\", this.onResize);\n },\n addListener: function addListener() {\n window.addEventListener(\"resize\", this.onResize);\n },\n clearStyle: function clearStyle() {\n // console.log(\"清除\");\n var screenWrapper = this.screenWrapper;\n screenWrapper.parentNode.style.overflow = \"auto\";\n screenWrapper.style = \"\";\n },\n resize: function () {\n var _resize = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n if (this.selfAdaption) {\n _context.next = 2;\n break;\n }\n return _context.abrupt(\"return\");\n case 2:\n _context.next = 4;\n return this.initSize();\n case 4:\n this.updateSize();\n this.updateScale();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this);\n }));\n function resize() {\n return _resize.apply(this, arguments);\n }\n return resize;\n }()\n },\n mounted: function mounted() {\n var _this3 = this;\n this.onResize = debounce(function () {\n _this3.resize();\n }, this.delay);\n this.$nextTick(function () {\n if (_this3.selfAdaption) {\n _this3.resize();\n _this3.addListener();\n }\n });\n },\n beforeDestroy: function beforeDestroy() {\n this.clearListener();\n // this.observer.disconnect()\n }\n};\n//",null]}