u
This commit is contained in:
parent
65a6126010
commit
d23a322428
21
unitool.js
21
unitool.js
@ -79,17 +79,20 @@ export default {
|
||||
const mylang = getApp()?.$store?.state?.i18n?.mylang // 不要用 pageNow.$store,防止在 App.vue 里无法获取当前页面。
|
||||
const pageNow = this.thisPage() // 需要兼顾在 App.vue 时无法获取当前页面的情况,因为如果在 topWindow 里调用本函数,getApp() 和 getCurrentPages()[getCurrentPages().length-1] 就是 undefined。
|
||||
|
||||
uni.setNavigationBarTitle({
|
||||
// 也会被用于浏览器的标签标题,因此要用 document.title 去覆盖
|
||||
title:
|
||||
pageTitle ||
|
||||
pageNow?.i18nText?.[mylang]?.tPageTitle || // 页面.vue 的 i18nText 对象
|
||||
pageNow?.i18nPageTitle?.[mylang] || // 页面.vue 的 i18nPageTitle 变量
|
||||
pagesJson?.pages?.find((page) => page.path === pageNow?.route)?.i18nPageTitle?.[mylang], // pages.json 的页面配置里
|
||||
})
|
||||
const navibarTitle =
|
||||
pageTitle ||
|
||||
pageNow?.i18nText?.[mylang]?.tPageTitle || // 页面.vue 的 i18nText 对象
|
||||
pageNow?.i18nPageTitle?.[mylang] || // 页面.vue 的 i18nPageTitle 变量
|
||||
pagesJson?.pages?.find((page) => page.path === pageNow?.route)?.i18nPageTitle?.[mylang] // pages.json 的页面配置里
|
||||
uni.setNavigationBarTitle({ title: navibarTitle })
|
||||
|
||||
// #ifdef H5
|
||||
document.title = windowTitle || wo?.envar?.callname?.[mylang] || pagesJson?.appInfo?.i18nText?.[mylang] || pagesJson?.globalStyle?.navigationBarTitleText // 必须放在 setNavigationBarTitle 之后,否则会被其覆盖掉。
|
||||
// navibarTitle 也会被用于浏览器的标签标题,因此要用 document.title 去覆盖。
|
||||
// 必须放在 setNavigationBarTitle 之后。
|
||||
document.title = `${windowTitle ||
|
||||
wo?.envar?.callname?.[mylang] ||
|
||||
pagesJson?.appInfo?.i18nText?.[mylang] ||
|
||||
pagesJson?.globalStyle?.navigationBarTitleText} - ${uni.getNavigationBarTitle()}`
|
||||
// #endif
|
||||
|
||||
// 必须要在有 tab 的页面里 setTabBarItem 才有效果
|
||||
|
Loading…
Reference in New Issue
Block a user