docs: 更新文档和配置,移除未使用的权限和过时描述

This commit is contained in:
雨霖铃
2026-06-07 09:30:42 +08:00
parent 86870864a9
commit 3f73adc015
4 changed files with 65 additions and 70 deletions
+17
View File
@@ -0,0 +1,17 @@
# CI/CD 配置
## CI 步骤
严格顺序,任一步骤失败则停止并标记 CI 失败:
1. `setup`(安装依赖、`wxt prepare`
2. 并行运行 `lint``typecheck``test`(三者全部通过才继续)
3. `build`(仅当步骤 2 全部成功时执行)
## Pre-commit Hook
`.husky/pre-commit` 调用 `lint-staged`,任一步骤返回非零则终止提交:
1. 代码文件 (`*.{ts,tsx,js,jsx,mjs}`):运行 `eslint --fix --max-warnings=0 --no-warn-ignored`;若失败则终止并报告错误
2. 同一代码文件:运行 `prettier --write`
3. 其他文件 (`*.{json,css,scss,md}`):运行 `prettier --write`
+42
View File
@@ -0,0 +1,42 @@
# i18n 开发指南
## 概述
项目使用 Chrome 扩展标准的 `chrome.i18n` API 进行本地化,通过 `src/utils/chromeI18n.ts` 提供类型安全的 React Hook 包装。
## 配置
- **翻译文件**: `public/_locales/{zh_CN,en}/messages.json`Chrome 扩展标准格式)
- **默认语言**: `zh_CN`(在 `wxt.config.ts``manifest.default_locale` 中配置)
## 使用方式
```typescript
import { useI18n } from '@/utils/chromeI18n';
```
## 翻译键格式
- **直接 key**: `t('dashboard_title')` → 查找 `dashboard_title`
- **命名空间格式(兼容旧用法)**: `t('common:buttons.search')` → 查找 `common_buttons_search`
- **带命名空间参数**: `useI18n(['common', 'features'])`,会自动尝试 `common_key``features_key`
## 占位符支持
```typescript
t('router_notFoundDescription', { entryPointType: 'popup' });
```
## Hook 返回值
```typescript
{ t, i18n: { language, changeLanguage }, isLoaded }
```
## 回退策略
当翻译 key 未命中时,返回 key 本身(开发模式下在控制台记录 warning)
## 限制
`chrome.i18n` 无法动态切换语言,语言跟随浏览器设置,切换后需刷新页面