App.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <div id="app" :dir="dir">
  3. <router-view />
  4. <div class="userAgentTips" v-if="userAgentTipShow">
  5. <img src="./assets/userAgentWarning.png" width="32px" />
  6. <span>当前浏览器可能与网站不兼容!建议使用 chrome 浏览器获得最佳使用体验。 </span>
  7. <img src="./assets/userAgentClose.png" width="16px" @click="handleClickUserAgent" />
  8. </div>
  9. </div>
  10. </template>
  11. <script>
  12. export default {
  13. name: "App",
  14. data() {
  15. return {
  16. dir: "ltr",
  17. userAgentTipShow: false,
  18. };
  19. },
  20. created() {
  21. let lang_type = localStorage.getItem("language_type");
  22. if (lang_type == "AR") {
  23. this.dir = "rtl";
  24. }
  25. this.handleUserAgentRoot()
  26. },
  27. methods:{
  28. // 判断是否为chrome浏览器
  29. handleUserAgentRoot(){
  30. if(!sessionStorage.getItem("useragent_root_close") && navigator.userAgent.indexOf('Chrome') == -1){
  31. this.userAgentTipShow = true
  32. }
  33. },
  34. handleClickUserAgent(){
  35. sessionStorage.setItem("useragent_root_close", true);
  36. this.userAgentTipShow = false
  37. },
  38. }
  39. };
  40. </script>
  41. <style lang="scss" scoped>
  42. .userAgentTips{
  43. position: fixed;
  44. top: 62px;
  45. left: 50%;
  46. // width: 624px;
  47. margin-left: -312px;
  48. background: #FFFFFF;
  49. border-radius: 8px;
  50. padding: 12px 16px 12px 8px;
  51. display: flex;
  52. align-items: center;
  53. justify-content: space-between;
  54. font-size: 16px;
  55. line-height: 24px;
  56. :nth-child(1){
  57. margin-right: 8px;
  58. }
  59. :nth-child(3){
  60. cursor: pointer;
  61. }
  62. }
  63. </style>