App.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <script>
  2. import {
  3. mapGetters,
  4. mapActions,
  5. mapMutations
  6. } from 'vuex'
  7. import config from '@/admin.config.js'
  8. import {
  9. version
  10. } from './package.json'
  11. export default {
  12. created() {
  13. this.clear = undefined
  14. },
  15. methods: {
  16. ...mapActions({
  17. init: 'app/init'
  18. }),
  19. clearPlatform() {
  20. const keysOfPlatform = uni.getStorageInfoSync().keys.filter(key => key.indexOf('platform') > -1)
  21. keysOfPlatform.length && keysOfPlatform.forEach(key => uni.removeStorageSync(key))
  22. }
  23. },
  24. onPageNotFound(msg) {
  25. uni.redirectTo({
  26. url: config.error.url
  27. })
  28. },
  29. onLaunch: function() {
  30. // #ifdef H5
  31. console.log(
  32. `%c uni-admin %c v${version} `,
  33. 'background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff',
  34. 'background:#007aff ;padding: 1px; border-radius: 0 3px 3px 0; color: #fff; font-weight: bold;'
  35. )
  36. // #endif
  37. // 线上示例使用
  38. // console.log('%c uni-app官方团队诚邀优秀前端工程师加盟,一起打造更卓越的uni-app & uniCloud,欢迎投递简历到 hr2013@dcloud.io', 'color: red');
  39. console.log('App Launch')
  40. this.init()
  41. // 登录成功回调
  42. uni.$on('uni-id-pages-login-success', () => {
  43. // this.setToken()
  44. this.init()
  45. })
  46. },
  47. onShow: function() {
  48. console.log('App Show')
  49. this.clear = setInterval(() => this.clearPlatform(), 15*60*1000)
  50. },
  51. onHide: function() {
  52. console.log('App Hide')
  53. this.clear && clearInterval(this.clear)
  54. }
  55. }
  56. </script>
  57. <style lang="scss">
  58. @import '@/common/uni.css';
  59. @import '@/common/uni-icons.css';
  60. @import '@/common/admin-icons.css';
  61. @import '@/common/theme.scss';
  62. </style>