App.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <div id="app">
  3. <div class="game-wrap">
  4. <game-nav></game-nav>
  5. <game-main></game-main>
  6. <game-table></game-table>
  7. <mod-footer></mod-footer>
  8. </div>
  9. </div>
  10. </template>
  11. <script>
  12. import gameNav from '@/components/nav/gameNav'
  13. import modFooter from '@/components/footer/modFooter'
  14. import gameMain from '@/components/game/gameMain'
  15. import gameTable from '@/components/table/tab'
  16. import ScatterJS from 'scatter-js/dist/scatter.esm'
  17. import Eos from 'eosjs'
  18. import { showError } from './util/util.js'
  19. import { mapActions } from 'vuex'
  20. export default {
  21. name: 'App',
  22. components: {
  23. gameNav,
  24. modFooter,
  25. gameMain,
  26. gameTable
  27. },
  28. methods: {
  29. ...mapActions([
  30. 'setScatter',
  31. 'setAccount',
  32. 'doScatterLogin'
  33. ])
  34. },
  35. async created () {
  36. // 连接scatter
  37. const connectionOptions = { initTimeout: 20000 }
  38. ScatterJS.scatter.connect('EOSGET_K3', connectionOptions).then(connected => {
  39. if (connected) {
  40. // 设置scatter
  41. this.setScatter(ScatterJS.scatter)
  42. window.__MeeChat.setScatterJS(ScatterJS)
  43. window.__MeeChat.setEos(Eos)
  44. // 清空全局scatter引用
  45. window.ScatterJS = null
  46. // 调起scatter授权登录
  47. this.doScatterLogin()
  48. } else {
  49. // 用户scatter未解锁
  50. showError(this.$t('installScatter'), 'Scatter')
  51. this.setAccount('NO_LOGINING')
  52. }
  53. })
  54. },
  55. mounted () {
  56. document.title = this.$t('pageTitle')
  57. }
  58. }
  59. </script>
  60. <style lang="scss">
  61. @import './style/global.scss';
  62. </style>