App.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div id="app" :dir="dir">
  3. <router-view />
  4. <progress-bar />
  5. <div v-if="userAgentTipShow" class="userAgentTips">
  6. <img src="./assets/userAgentWarning.png" width="32px" />
  7. <span>当前浏览器可能与网站不兼容!建议使用 chrome 浏览器获得最佳使用体验。</span>
  8. <img src="./assets/userAgentClose.png" width="16px" @click="handleClickUserAgent" />
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. import { getConfig, getToken, removeToken } from '@/utils/auth';
  14. import Cookies from 'js-cookie';
  15. import ProgressBar from '@/common/progress_bar/index.vue';
  16. export default {
  17. components: {
  18. ProgressBar
  19. },
  20. provide() {
  21. return {
  22. $t: (key) => {
  23. return this.$t(key);
  24. }
  25. };
  26. },
  27. data() {
  28. return {
  29. dir: 'ltr',
  30. userAgentTipShow: false,
  31. timeout: null
  32. };
  33. },
  34. created() {
  35. this.handleUserAgentRoot();
  36. // ['click', 'mousewheel', 'mousemove'].forEach((item) => {
  37. // window.addEventListener(item, () => {
  38. // sessionStorage.setItem('lastClickTime', new Date().getTime());
  39. // });
  40. // });
  41. },
  42. mounted() {
  43. const { token: config, isHas: isConfigHas } = getConfig();
  44. // 有 config 信息时,设置 icon
  45. if (isConfigHas) {
  46. const link = document.querySelector("link[rel*='icon']") || document.createElement('link');
  47. link.type = 'image/x-icon';
  48. link.rel = 'shortcut icon';
  49. link.href = config.title_icon_url;
  50. document.getElementsByTagName('head')[0].appendChild(link);
  51. }
  52. },
  53. // mounted() {
  54. // sessionStorage.setItem('lastClickTime', new Date().getTime());
  55. // this.isTimeout();
  56. // },
  57. // beforeDestroy() {
  58. // clearInterval(this.timeout);
  59. // },
  60. methods: {
  61. handleUserAgentRoot() {
  62. if (!sessionStorage.getItem('useragent_root_close') && navigator.userAgent.indexOf('Chrome') === -1) {
  63. this.userAgentTipShow = true;
  64. }
  65. },
  66. handleClickUserAgent() {
  67. sessionStorage.setItem('useragent_root_close', true);
  68. this.userAgentTipShow = false;
  69. }
  70. // isTimeout() {
  71. // clearInterval(this.timeout);
  72. // this.timeout = setInterval(() => {
  73. // let nowTime = new Date().getTime();
  74. // let { token } = getConfig();
  75. // let { user_connection_timeout_duration, sys_home_url } = token;
  76. // if (nowTime - Number(sessionStorage.getItem('lastClickTime')) > 1000 * user_connection_timeout_duration) {
  77. // clearInterval(this.timeout);
  78. // sessionStorage.removeItem('SysList');
  79. // removeToken();
  80. // Cookies.remove('JSESSIONID');
  81. // sessionStorage.removeItem('useragent_root_close');
  82. // window.location.href = sys_home_url;
  83. // }
  84. // }, 1000);
  85. // }
  86. }
  87. };
  88. </script>
  89. <style lang="scss" scoped>
  90. .userAgentTips {
  91. position: fixed;
  92. top: 62px;
  93. left: 50%;
  94. display: flex;
  95. align-items: center;
  96. justify-content: space-between;
  97. padding: 12px 16px 12px 8px;
  98. margin-left: -312px;
  99. font-size: 16px;
  100. line-height: 24px;
  101. background: #fff;
  102. border-radius: 8px;
  103. :nth-child(1) {
  104. margin-right: 8px;
  105. }
  106. :nth-child(3) {
  107. cursor: pointer;
  108. }
  109. }
  110. </style>