西藏巴青项目

tabPage.js 1019B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { ensureTabBarEntry, isTabBarPage, syncTabBarText } from '@/utils/tabBar'
  2. /**
  3. * Tab 子页共用:根节点语言 class、导航标题、底部 tab 文案与 i18n 同步
  4. * 页面需在 data 中提供 navTitleKey,如 'nav.home'
  5. */
  6. export default {
  7. data() {
  8. return {
  9. layoutKey: 0
  10. }
  11. },
  12. computed: {
  13. lang() {
  14. return this.$i18n.locale
  15. },
  16. pageRootClass() {
  17. return this.lang === 'bo' ? 'lang-bo' : 'lang-zh'
  18. }
  19. },
  20. onShow() {
  21. const applyTabPageUi = () => {
  22. if (!isTabBarPage()) {
  23. return
  24. }
  25. syncTabBarText((k) => this.$t(k))
  26. const key = this.navTitleKey
  27. if (key) {
  28. const p = uni.setNavigationBarTitle({
  29. title: this.$t(key)
  30. })
  31. if (p && typeof p.catch === 'function') {
  32. p.catch(() => {})
  33. }
  34. }
  35. }
  36. if (isTabBarPage()) {
  37. applyTabPageUi()
  38. return
  39. }
  40. ensureTabBarEntry().then((ok) => {
  41. if (ok) {
  42. applyTabPageUi()
  43. }
  44. })
  45. }
  46. }