App.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div id="app" :class="$route.path == '/codeHtml'?'codeHtmlPage':''"
  3. :style="$route.path == '/codeHtml'?'width:'+innerWidth+'px!important;height:'+innerHeight+'px!important;':''">
  4. <router-view/>
  5. </div>
  6. </template>
  7. <script>
  8. import axios from 'axios'
  9. import { MessageBox } from 'element-ui'
  10. export default {
  11. name: 'App',
  12. data(){
  13. return{
  14. innerHeight:window.innerHeight,
  15. innerWidth:window.innerWidth,
  16. timer:null,
  17. }
  18. },
  19. metaInfo() {
  20. return {
  21. title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
  22. titleTemplate: title => {
  23. return title ? `${title} - ${process.env.VUE_APP_TITLE}` : process.env.VUE_APP_TITLE
  24. },
  25. }
  26. },
  27. mounted(){
  28. this.banZoom();
  29. //根据当前浏览器宽度与额定尺寸计算transform缩放值
  30. document.getElementById('app').style.transform = `scale(${document.documentElement.clientWidth / 1920})`;
  31. //根据当前浏览器宽度与额定尺寸计算当前浏览器可观看尺寸高度
  32. document.getElementById('app').style.height = (window.innerHeight/(document.documentElement.clientWidth / 1920*100))*100+'px';
  33. //当尺寸改变后从新计算
  34. window.onresize = () => {
  35. return (() => {
  36. document.getElementById('app').style.transform = `scale(${document.documentElement.clientWidth / 1920})`;
  37. document.getElementById('app').style.height = (window.innerHeight/(document.documentElement.clientWidth / 1920*100))*100+'px';
  38. })();
  39. };
  40. // this.inspectRenewal();
  41. },
  42. methods:{
  43. banZoom(){
  44. // 禁止通过 ctrl + +/- 和 ctrl + 滚轮 对页面进行缩放
  45. document.addEventListener('keydown', function (event) {
  46. if ((event.ctrlKey === true || event.metaKey === true) &&
  47. (event.which === 61 || event.which === 107 ||
  48. event.which === 173 || event.which === 109 ||
  49. event.which === 187 || event.which === 189)) {
  50. event.preventDefault()
  51. }
  52. }, false)
  53. // Chrome IE 360
  54. window.addEventListener('mousewheel', function (event) {
  55. if (event.ctrlKey === true || event.metaKey) {
  56. event.preventDefault()
  57. }
  58. }, {
  59. passive: false
  60. })
  61. // firefox
  62. window.addEventListener('DOMMouseScroll', function (event) {
  63. if (event.ctrlKey === true || event.metaKey) {
  64. event.preventDefault()
  65. }
  66. }, {
  67. passive: false
  68. })
  69. },
  70. },
  71. beforeDestroy() {
  72. //清除定时器
  73. clearInterval(this.timer);
  74. },
  75. }
  76. </script>
  77. <style>
  78. .el-drawer__container,.el-dialog__wrapper,.el-message-box__wrapper{
  79. background: rgba(0,0,0,0.4);
  80. }
  81. .codeHtmlPage{
  82. transform: scale(1)!important;
  83. }
  84. @font-face {
  85. font-family: 'alimmFonts';
  86. src: url('./assets/fonts/alimm.ttf') format('truetype'); /* 根据实际路径调整 */
  87. font-weight: normal;
  88. font-style: normal;
  89. }
  90. @font-face {
  91. font-family: 'ysFonts';
  92. src: url('./assets/fonts/ys.ttf') format('truetype'); /* 根据实际路径调整 */
  93. font-weight: normal;
  94. font-style: normal;
  95. }
  96. @font-face {
  97. font-family: 'AlimamaShuHeiTi';
  98. src: url('./assets/fonts/AlimamaShuHeiTi-Bold.ttf') format('truetype'); /* 标题 */
  99. font-weight: normal;
  100. font-style: normal;
  101. /*
  102. font-family: AlimamaShuHeiTi;
  103. */
  104. }
  105. @font-face {
  106. font-family: 'YouSheBiaoTiHei';
  107. src: url('./assets/fonts/YouSheBiaoTiHei.ttf') format('truetype'); /* 数字 */
  108. font-weight: normal;
  109. font-style: normal;
  110. /*
  111. font-family: YouSheBiaoTiHei;
  112. */
  113. }
  114. @font-face {
  115. font-family: 'SOURCEHANSANSCN';
  116. src: url('./assets/fonts/SOURCEHANSANSCN.OTF') format('truetype'); /* 正文 */
  117. font-weight: normal;
  118. font-style: normal;
  119. /*
  120. font-family: SOURCEHANSANSCN;
  121. */
  122. }
  123. </style>