App.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <div>
  3. <transition name="fade">
  4. <router-view />
  5. </transition>
  6. <el-dialog
  7. class="disclaimer-dialog"
  8. title="免责声明"
  9. :visible.sync="dialogVisible"
  10. :close-on-press-escape="false"
  11. :close-on-click-modal="false"
  12. :show-close="false"
  13. width="80%"
  14. >
  15. <span v-html="message" />
  16. <span
  17. slot="footer"
  18. class="dialog-footer"
  19. >
  20. <el-button @click="out">退出</el-button>
  21. <el-button
  22. type="primary"
  23. :disabled="time>0"
  24. @click="agree"
  25. >我已知晓<span
  26. v-if="time"
  27. style="padding-left: 4px"
  28. >{{ time }}</span></el-button>
  29. </span>
  30. </el-dialog>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. name: 'App',
  36. updated () {
  37. const loading = document.getElementById('loader-wrapper')
  38. if (loading) {
  39. document.body.removeChild(loading)
  40. }
  41. },
  42. data () {
  43. return {
  44. dialogVisible: false,
  45. message: '',
  46. timer: null,
  47. time: 10
  48. }
  49. },
  50. mounted () {
  51. this.init()
  52. },
  53. methods: {
  54. init () {
  55. // 如果不是演示环境或者已经阅读过免责声明,则不显示弹窗
  56. if ((!window?.SITE_CONFIG?.demoEnv) || sessionStorage.getItem('disclaimer') === 'read ') {
  57. return
  58. }
  59. this.dialogVisible = true
  60. // 新建是否阅读免责声明的本地存储
  61. sessionStorage.setItem('disclaimer', '')
  62. this.$dataRoomAxios.get('/dataroom/opensource/disclaimer').then(res => {
  63. this.message = res
  64. this.timer = setInterval(() => {
  65. if (this.time > 0) {
  66. this.time--
  67. } else {
  68. clearInterval(this.timer)
  69. }
  70. }, 1000)
  71. })
  72. },
  73. out () {
  74. try {
  75. window.close()
  76. } catch (e) {
  77. window.location.href = 'about:blank'
  78. }
  79. },
  80. agree () {
  81. sessionStorage.setItem('disclaimer', 'read ')
  82. this.dialogVisible = false
  83. }
  84. }
  85. }
  86. </script>
  87. <style lang="scss">
  88. @import '../packages/assets/style/bsTheme.scss';
  89. </style>