App.vue 902 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <script>
  2. import config from './config'
  3. import { getToken } from '@/utils/auth'
  4. export default {
  5. onLaunch: function() {
  6. uni.removeStorageSync('filePath');
  7. uni.removeStorageSync('fileName');
  8. this.initApp()
  9. },
  10. mounted() {
  11. this.$root.$wsEventBus.$on('websocket-message', this.handleMessage);
  12. },
  13. methods: {
  14. handleMessage(data) {
  15. uni.showToast({
  16. title: '加载中',
  17. })
  18. },
  19. // 初始化应用
  20. initApp() {
  21. // 初始化应用配置
  22. this.initConfig()
  23. // 检查用户登录状态
  24. //#ifdef H5
  25. this.checkLogin()
  26. //#endif
  27. },
  28. initConfig() {
  29. this.globalData.config = config
  30. },
  31. checkLogin() {
  32. if (!getToken()) {
  33. this.$tab.reLaunch('/pages/login')
  34. }
  35. }
  36. }
  37. }
  38. </script>
  39. <style lang="scss">
  40. @import '@/static/scss/index.scss'
  41. </style>