app.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { computed } from 'vue'
  2. import { useStore, mapGetters } from 'vuex'
  3. import { styleObj2Str } from '@/core/app'
  4. import store from '@/store/index'
  5. import platform from '@/core/platform'
  6. export default {
  7. data() {
  8. return {
  9. platform
  10. }
  11. },
  12. computed: {
  13. appTheme: () => store.getters.appTheme,
  14. appThemeStyle: () => styleObj2Str(store.getters.appTheme)
  15. },
  16. mounted() {
  17. // #ifdef H5
  18. // 微信公众号端隐藏 navigationBar (解决双标题栏问题)
  19. if (this.platform === 'WXOFFICIAL') {
  20. this.hideNavigationBar()
  21. }
  22. // #endif
  23. },
  24. methods: {
  25. // #ifdef H5
  26. // 隐藏 navigationBar
  27. hideNavigationBar() {
  28. this.$nextTick(() => {
  29. const navTitleDom = document.getElementsByTagName('uni-page-head')
  30. if (navTitleDom.length) {
  31. navTitleDom[0].style.display = 'none'
  32. document.body.style.setProperty('--window-top', '0px');
  33. }
  34. })
  35. },
  36. // #endif
  37. // 自定义主题样式
  38. customThemeStyle(styleObj) {
  39. return styleObj2Str({ ...store.getters.appTheme, ...styleObj })
  40. }
  41. }
  42. }