fix: 修复代码审查发现的所有 bug

Critical 级别:
- zhipu.ts: 添加 API 响应边界检查
- DictionaryClient.tsx: 添加 entries 数组边界检查
- subtitleParser.ts: 修复 getNearestIndex 逻辑错误

High 级别:
- text-speaker/page.tsx: 修复非空断言和 ref 检查
- folder-repository.ts: 添加 user 关系 null 检查

Medium 级别:
- InFolder.tsx: 修复 throw result.message 为 throw new Error()
- localStorageOperators.ts: 返回类型改为 T | null,添加 schema 验证
- SaveList.tsx: 处理 data 可能为 null 的情况
This commit is contained in:
2026-03-09 19:11:49 +08:00
parent 020744b353
commit c83aefabfa
8 changed files with 75 additions and 59 deletions

View File

@@ -48,8 +48,8 @@ export default function TextSpeakerPage() {
const handleEnded = () => {
if (autopause) {
setPause(true);
} else {
load(objurlRef.current!);
} else if (objurlRef.current) {
load(objurlRef.current);
play();
}
};
@@ -187,7 +187,7 @@ export default function TextSpeakerPage() {
theIPA = tmp_ipa;
}
const save = getFromLocalStorage();
const save = getFromLocalStorage() ?? [];
const oldIndex = save.findIndex((v) => v.text === textRef.current);
if (oldIndex !== -1) {
const oldItem = save[oldIndex];
@@ -293,7 +293,7 @@ export default function TextSpeakerPage() {
size="lg"
onClick={() => {
setAutopause(!autopause);
if (objurlRef) {
if (objurlRef.current) {
stop();
}
setPause(true);