book-index-ui 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -1
- package/dist/index.cjs +64 -64
- package/dist/index.d.ts +2636 -1840
- package/dist/index.js +8865 -7521
- package/dist/{storage-entry-E80UAT7b.js → storage-entry-BezDJLqe.js} +45 -40
- package/dist/{storage-entry-le9dwVgw.cjs → storage-entry-DPsx0DgD.cjs} +2 -2
- package/dist/storage.cjs +1 -1
- package/dist/storage.d.ts +2 -0
- package/dist/storage.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,7 +40,9 @@ import 'book-index-ui/styles' // CSS(用到组件时引入)
|
|
|
40
40
|
| `VersionLineageView` / `VersionLineageGraph` | 版本传承图(dagre + xyflow) |
|
|
41
41
|
| `FeedbackButton` / `FeedbackList` / `FeedbackForm` | 反馈组件 |
|
|
42
42
|
| `LocaleProvider` / `LocaleToggle` | 繁简切换 |
|
|
43
|
-
| `
|
|
43
|
+
| `useI18n` / `getT` | **统一 i18n 入口**:界面文字 `t(key)`、数据文字 `convert`,见下「界面文字与繁简」 |
|
|
44
|
+
| `useT` / `useConvert` | 旧 hook(整本字典 / 繁简转换),新代码用 `useI18n` |
|
|
45
|
+
| `findTraditionalChars` | 简体模式残留繁体字检测(vitest 与网站 e2e 共用) |
|
|
44
46
|
|
|
45
47
|
### 统一阅读器(`TextReader`,overview#307)
|
|
46
48
|
|
|
@@ -98,6 +100,22 @@ import 'book-index-ui/styles' // CSS(用到组件时引入)
|
|
|
98
100
|
|
|
99
101
|
数据层还导出 `encodeId / decodeId / smartDecode / extractType / shardOf / scoreEntry / rankByRelevance / cleanName` 等纯函数工具。
|
|
100
102
|
|
|
103
|
+
### 界面文字与繁简(overview#337)
|
|
104
|
+
|
|
105
|
+
两类文字,两条路:
|
|
106
|
+
|
|
107
|
+
| 类别 | 例 | 怎么写 |
|
|
108
|
+
|---|---|---|
|
|
109
|
+
| 界面固定文字 | 标题、按钮、aria-label、单位、「展開其餘 {n} 冊」 | `const { t } = useI18n(); t('detail.moreN', { n })` |
|
|
110
|
+
| 数据文字 | 书名、作者、提要、分类名、版本名、sections.json 里的分区名 | `const { convert } = useI18n(); convert(data.title)` |
|
|
111
|
+
|
|
112
|
+
- 字典按区域分文件:`src/i18n/messages/<区域>.ts`,`defineMessages(繁体栏, 简体栏, 英文栏?)`,繁简两栏键必须一一对应(tsc 检查);早期的整块字典 `locales/zh-Hant.ts`/`zh-Hans.ts` 仍可用。
|
|
113
|
+
- 键是带类型的点路径(`MessageKey`),写错 tsc 报错;当前语言缺键回落到繁体。
|
|
114
|
+
- 没包 `LocaleProvider` 时按繁体。网站务必在最外层包 `LocaleProvider`(或网站的 `BimLocaleProvider`),否则组件一律显示繁体。
|
|
115
|
+
- 组件外(Next.js `generateMetadata` 等服务端):`getT(locale)('…')`,数据文字用同一个转换函数(`LocaleProvider` 的 `converter` 或内置 opencc)。
|
|
116
|
+
- 加英文:`Locale` 加 `'en'`,各字典填英文栏(可部分,缺的回落繁体);数据文字的英文另议。
|
|
117
|
+
- 检测:`tests/unit/zh-hans-leak.test.tsx` 在简体模式下渲染各页,用 `findTraditionalChars`(常用繁体字表 + 专名白名单)断言正文无繁体残留;`tests/unit/i18n-dictionaries.test.ts` 检查字典繁简同形、简体栏无繁体。
|
|
118
|
+
|
|
101
119
|
### 类型
|
|
102
120
|
|
|
103
121
|
`IndexEntry` / `IndexDetailData` / `WorkDetailData` / `BookDetailData` / `CollectionDetailData` / `EntityDetailData` / `IndexType` / `IndexStatus` / `LineageGraph` / `CollatedEditionIndex` / `ResourceCatalog` 等。
|