myMain.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <div id="dv-full-screen-container" :ref="ref">
  3. <template v-if="ready">
  4. <slot></slot>
  5. </template>
  6. </div>
  7. </template>
  8. <script>
  9. import autoResize from './mixin/autoResize.js'
  10. export default {
  11. name: 'DvFullScreenContainer',
  12. mixins: [autoResize],
  13. data() {
  14. return {
  15. ref: 'full-screen-container',
  16. allWidth: 0,
  17. allHeight: 0,
  18. scale: 0,
  19. datavRoot: '',
  20. ready: false
  21. }
  22. },
  23. methods: {
  24. afterAutoResizeMixinInit() {
  25. const { initConfig, setAppScale } = this
  26. initConfig()
  27. setAppScale()
  28. this.ready = true
  29. },
  30. initConfig() {
  31. const { dom } = this
  32. // const { width } = screen
  33. let width = window.innerWidth
  34. let height = window.innerHeight
  35. this.allWidth = width
  36. this.allHeight = height
  37. dom.style.width = `${width}px`
  38. dom.style.height = `${height}px`
  39. },
  40. setAppScale() {
  41. const { allWidth, allHeight, dom } = this
  42. const currentWidth = window.outerWidth
  43. const currentHeight = window.innerHeight
  44. // dom.style.transform = `scale(${currentWidth / allWidth})`
  45. dom.style.transform = `scaleY(${currentHeight / allHeight}) scaleX(${currentWidth / allWidth})`
  46. },
  47. onResize() {
  48. const { setAppScale } = this
  49. setAppScale()
  50. }
  51. }
  52. }
  53. </script>