App.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div id="app">
  3. <div class="view-container">
  4. <AppHeader :visible="visible"></AppHeader>
  5. <transition :name="transitionName">
  6. <router-view />
  7. </transition>
  8. <AppBackTop></AppBackTop>
  9. </div>
  10. <el-dialog width="50%" title="系统规则" :visible.sync="dialogVisible">
  11. <!-- <div>座机:010-82783688转122</div>
  12. <div>邮箱:guowl@dgtis.com</div> -->
  13. <div v-html="htmlData"></div>
  14. </el-dialog>
  15. </div>
  16. </template>
  17. <script>
  18. import AppHeader from '@/components/AppHeader.vue';
  19. import AppBackTop from '@/components/AppBackTop.vue';
  20. import { lockStatus } from "@/api/allApi";
  21. export default {
  22. name: 'app',
  23. components: {
  24. AppHeader,
  25. AppBackTop
  26. },
  27. data() {
  28. return {
  29. htmlData:'',
  30. dialogVisible: false,
  31. transitionName: "",
  32. isGray: false,
  33. visible:true,
  34. };
  35. },
  36. created(){
  37. this.$store.dispatch('GetUserInfo');
  38. this.$nextTick(() => {
  39. // 1.禁用右键菜单
  40. document.oncontextmenu = new Function("event.returnValue=false");
  41. // 2.禁用鼠标选中
  42. document.onselectstart = new Function("event.returnValue=false");
  43. // 3.禁止键盘F12键
  44. document.addEventListener("keydown", function (e) {
  45. // 禁止 F12
  46. if (e.key === "F12") {
  47. e.preventDefault();
  48. }
  49. // 禁止 Ctrl + Shift + I 打开开发者工具
  50. if (e.ctrlKey && e.shiftKey && e.key === 'I') {
  51. e.preventDefault();
  52. }
  53. // 禁止 Ctrl + Shift + C 打开检查元素
  54. if (e.ctrlKey && e.shiftKey && e.key === 'C') {
  55. e.preventDefault();
  56. }
  57. });
  58. });
  59. },
  60. methods:{
  61. fatherMethod() {
  62. lockStatus().then(response=>{
  63. this.htmlData = response.data.errmsg;
  64. this.dialogVisible = true;
  65. })
  66. },
  67. // 保存滚动值,这是兼容的写法
  68. handleScroll () {
  69. var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
  70. //变量scrollTop是滚动条滚动时,距离顶部的距离
  71. // var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
  72. // //变量windowHeight是可视区的高度
  73. // var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
  74. // //变量windowHeight是可视区的高度
  75. // var scrollHeight =document.documentElement.scrollHeight || document.body.scrollHeight;
  76. // //滚动条到底部的条件
  77. // if(scrollTop + windowHeight == scrollHeight){
  78. // //你要触发的方法
  79. // }
  80. if(scrollTop >= 80){
  81. this.visible = false;
  82. }else{
  83. this.visible = true;
  84. }
  85. },
  86. },
  87. mounted () {
  88. window.addEventListener('scroll', this.handleScroll)
  89. },
  90. destroyed () {
  91. // 离开该页面需要移除这个监听的事件,不然会报错
  92. window.removeEventListener('scroll', this.handleScroll)
  93. },
  94. watch: {
  95.   //使用watch 监听$router的变化
  96.   $route(to, from) {
  97.     //如果to索引大于from索引,判断为前进状态,反之则为后退状态
  98.     console.log(to, "to");
  99.     console.log(from, "from");
  100.     if (to.meta.index > from.meta.index) {
  101.       //设置动画名称
  102.       this.transitionName = "slide-left";
  103.     } else {
  104.       this.transitionName = "slide-right";
  105.     }
  106.   },
  107. },
  108. }
  109. </script>
  110. <style>
  111. ::-webkit-scrollbar-track {
  112. background: rgba(0, 0, 0, 0.1);
  113. border-radius: 0;
  114. }
  115. ::-webkit-scrollbar {
  116. -webkit-appearance: none;
  117. width: 5px;
  118. height: 6px;
  119. }
  120. ::-webkit-scrollbar-thumb {
  121. cursor: pointer;
  122. border-radius: 5px;
  123. background: rgba(0, 0, 0, 0.15);
  124. transition: color 0.2s ease;
  125. }
  126. .el-card__body{
  127. padding: 0 10px !important;
  128. }
  129. .el-dialog__body{
  130. padding-top: 0px !important;
  131. }
  132. .view-container{
  133. position: relative;
  134. margin: 0 auto;
  135. width: 100%;
  136. max-width: 1200px;
  137. }
  138. .slide-right-enter-active,
  139. .slide-right-leave-active,
  140. .slide-left-enter-active,
  141. .slide-left-leave-active {
  142. will-change: transform;
  143. transition: all 80ms;
  144. position: fixed;
  145. }
  146. .slide-right-enter {
  147. opacity: 0;
  148. transform: translate3d(-100%, 0, 0);
  149. }
  150. .slide-right-leave-active {
  151. opacity: 0;
  152. transform: translate3d(100%, 0, 0);
  153. }
  154. .slide-left-enter {
  155. opacity: 0;
  156. transform: translate3d(100%, 0, 0);
  157. }
  158. .slide-left-leave-active {
  159. opacity: 0;
  160. transform: translate3d(-100%, 0, 0);
  161. }
  162. </style>
  163. <style scoped>
  164. ::v-deep .el-dialog {
  165. left: 50%;
  166. top: 5%;
  167. transform: translate(-50%, -5%);
  168. margin: 0px !important;
  169. border-radius: 8px;
  170. }
  171. ::v-deep .el-dialog__title,::v-deep .el-dialog__headerbtn{
  172. font-size: 24px;
  173. }
  174. ::v-deep .el-dialog__header {
  175. -webkit-box-shadow: 0 1px 4px 0 rgba(31, 45, 61, .12);
  176. box-shadow: 0 1px 4px 0 rgba(31, 45, 61, .12);
  177. }
  178. ::v-deep .el-dialog__body{
  179. overflow: auto;
  180. overflow-x: hidden;
  181. max-height: 70vh!important;
  182. }
  183. ::v-deep .el-dialog__footer {
  184. border-top: 1px solid #d7d9dc;
  185. }
  186. </style>