mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-07-27 12:30:41 +08:00
chore: 清理旧文件并重构项目基础结构
- 删除大量废弃的旧代码、依赖和配置文件 - 新增基础项目配置、工具函数、页面模板和请求库 - 重构目录结构,统一项目规范 - 添加commitlint、husky等代码规范工具
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { t } from '@/locale'
|
||||
import { isCurrentPageTabbar } from '@/utils'
|
||||
import { isNativeTabbar, tabbarList } from './config'
|
||||
|
||||
// h5 中一直可以生效,小程序里面默认是无法动态切换的,这里借助vue模板自带响应式的方式
|
||||
// 直接替换 %xxx% 为 t('xxx')即可
|
||||
export function getI18nText(key: string) {
|
||||
// 获取 %xxx% 中的 xxx
|
||||
const match = key.match(/%(.+?)%/)
|
||||
if (match) {
|
||||
key = match[1]
|
||||
}
|
||||
console.log('设置多语言:', key)
|
||||
return t(key)
|
||||
}
|
||||
|
||||
export function setTabbarItem() {
|
||||
// 只有使用原生Tabbar才需要 setTabbarItem
|
||||
// 而且只有当前页是tabbar页才能设置
|
||||
console.log('设置多语言:setTabBarItem', isNativeTabbar, isCurrentPageTabbar())
|
||||
if (isNativeTabbar && isCurrentPageTabbar()) {
|
||||
tabbarList.forEach((item, index) => {
|
||||
uni.setTabBarItem({
|
||||
index,
|
||||
text: getI18nText(item.text),
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user