项目正常启动

This commit is contained in:
comlibmb
2026-01-22 08:54:47 +08:00
parent 9eb05253d3
commit 75fad97d5d
28 changed files with 1621 additions and 887 deletions

View File

@@ -0,0 +1,67 @@
# i18n 国际化模块
这是一个简化的 i18n 国际化模块,用于支持多语言切换。
## 功能特性
- 支持多语言切换
- 兼容 Vue I18n 的 API
- 支持在 Vue 组件中使用 `$t` 方法
- 支持通过 `tt` 工具函数进行翻译
## 使用方法
### 在 Vue 组件中使用
```vue
<template>
<view>
<text>{{ $t('user.login.title') }}</text>
</view>
</template>
```
### 在脚本中使用
```typescript
import i18n from '@/uni_modules/i18n/index.uts'
import { tt } from '@/utils/i18nfun.uts'
// 方式1直接使用 i18n
const text = i18n.global.t('user.login.title')
// 方式2使用工具函数
const text2 = tt('user.login.title')
```
### 切换语言
```typescript
import { switchLocale, getCurrentLocale } from '@/utils/utils.uts'
// 切换语言
switchLocale('en-US')
// 获取当前语言
const current = getCurrentLocale()
```
## 配置
默认语言为 `zh-CN`,可以在 `index.uts` 中修改 `defaultLocale` 常量。
## 注意事项
当前实现是简化版本,`t` 函数直接返回 key。实际项目中需要
1. 加载语言资源文件
2. 实现真正的翻译逻辑
3. 支持参数插值
## 文件结构
```
uni_modules/i18n/
├── index.uts # 主模块文件
├── package.json # 模块配置
└── README.md # 说明文档
```