App.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div id="app" :dir="dir">
  3. <keep-alive>
  4. <router-view v-if="$route.meta.keepAlive" />
  5. </keep-alive>
  6. <router-view v-if="!$route.meta.keepAlive" />
  7. <div class="userAgentTips" v-if="userAgentTipShow">
  8. <img src="./assets/userAgentWarning.png" width="32px" />
  9. <span
  10. >当前浏览器可能与网站不兼容!建议使用 chrome 浏览器获得最佳使用体验。
  11. </span>
  12. <img
  13. src="./assets/userAgentClose.png"
  14. width="16px"
  15. @click="handleClickUserAgent"
  16. />
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. export default {
  22. name: "App",
  23. data() {
  24. return {
  25. dir: "ltr",
  26. userAgentTipShow: false,
  27. };
  28. },
  29. created() {
  30. let lang_type = localStorage.getItem("language_type");
  31. if (lang_type == "AR") {
  32. this.dir = "rtl";
  33. }
  34. if (
  35. localStorage.getItem("useragent_root_type") &&
  36. localStorage.getItem("useragent_root_type") !== "true" &&
  37. !localStorage.getItem("useragent_root_close")
  38. ) {
  39. this.userAgentTipShow = true;
  40. } else {
  41. this.handleUserAgentRoot();
  42. }
  43. },
  44. methods: {
  45. // 判断是否为chrome浏览器
  46. handleUserAgentRoot() {
  47. if (
  48. !sessionStorage.getItem("useragent_root_close") &&
  49. navigator.userAgent.indexOf("Chrome") == -1
  50. ) {
  51. this.userAgentTipShow = true;
  52. }
  53. },
  54. handleClickUserAgent() {
  55. sessionStorage.setItem("useragent_root_close", true);
  56. this.userAgentTipShow = false;
  57. },
  58. },
  59. };
  60. </script>
  61. <style>
  62. * {
  63. margin: 0;
  64. padding: 0;
  65. }
  66. html,
  67. body {
  68. width: 100%;
  69. height: 100%;
  70. }
  71. #app {
  72. width: 100%;
  73. height: 100%;
  74. min-width: 1200px;
  75. }
  76. </style>
  77. <style lang="scss" scoped>
  78. .userAgentTips {
  79. position: fixed;
  80. top: 62px;
  81. left: 50%;
  82. // width: 624px;
  83. margin-left: -312px;
  84. background: #ffffff;
  85. border-radius: 8px;
  86. padding: 12px 16px 12px 8px;
  87. display: flex;
  88. align-items: center;
  89. justify-content: space-between;
  90. font-size: 16px;
  91. line-height: 24px;
  92. :nth-child(1) {
  93. margin-right: 8px;
  94. }
  95. :nth-child(3) {
  96. cursor: pointer;
  97. }
  98. }
  99. </style>