From 50ee7232f3c98fe24a1f2e31dba9508cfec14887 Mon Sep 17 00:00:00 2001 From: gjj <Ganjj@probim.com.cn> Date: Fri, 21 Feb 2025 17:35:39 +0800 Subject: [PATCH] 模型预览 --- src/components/SizeAdapter.vue | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-) diff --git a/src/components/SizeAdapter.vue b/src/components/SizeAdapter.vue new file mode 100644 index 0000000..f070971 --- /dev/null +++ b/src/components/SizeAdapter.vue @@ -0,0 +1,45 @@ +<template> + <div id="sizeAdapterWrapper"> + <slot></slot> + </div> +</template> + +<script> + export default { + name: "SizeAdapter", + props: { + originDeviceInfo: { + type: Object, + default: () => { + return { + width: window.innerWidth, + height: window.innerHeight, + }; + }, + }, + }, + created() { + window.addEventListener("resize", this.adapteSlot); + }, + mounted() { + // this.adapteSlot(); + }, + beforeDestroy() { + window.removeEventListener("resize", this.adapteSlot); + }, + methods: { + adapteSlot() { + const nowWidth = window.innerWidth; + const nowHeight = window.innerHeight; + + const { width, height } = this.originDeviceInfo; + + const xScale = nowWidth / width; + const yScale = nowHeight / height; + this.$scopedSlots.default()[0].elm.style.transform = `scale3d(${xScale},${yScale},1)`; + }, + }, + }; +</script> + +<style lang="scss" scoped></style> -- Gitblit v1.9.3