unibest/src/utils/index.ts

27 lines
610 B
TypeScript
Raw Normal View History

2024-02-04 16:00:27 +08:00
import pagesJson from '@/pages.json'
import { translate as t } from '@/locale/index'
2024-01-29 18:53:57 +08:00
2024-02-04 16:00:27 +08:00
console.log(pagesJson)
/** 判断当前页面是否是tabbar页 */
export const getIsTabbar = () => {
if (!Object.keys(pagesJson).includes('tabBar')) {
return false
}
const pages = getCurrentPages()
const currPath = pages.at(-1).route
return !!pagesJson.tabBar.list.find((e) => e.pagePath === currPath)
}
2024-01-29 18:53:57 +08:00
/**
* test i18n in not .vue file
*/
export const testI18n = () => {
console.log(t('app.name'))
// 下面同样生效
2024-01-29 19:14:01 +08:00
uni.showModal({
title: 'i18n 测试',
content: t('app.name'),
})
2024-01-29 18:53:57 +08:00
}