feat: add custom api examples

This commit is contained in:
Gabe
2025-10-16 23:51:49 +08:00
parent 74ce6f2f1f
commit 32c6d45cb0
7 changed files with 135 additions and 14 deletions

View File

@@ -98,8 +98,9 @@ const parseAIRes = (raw) => {
try {
const jsonString = extractJson(raw);
const data = JSON.parse(jsonString);
if (!jsonString) return [];
const data = JSON.parse(jsonString);
if (Array.isArray(data.translations)) {
// todo: 考虑序号id可能会打乱
return data.translations.map((item) => [
@@ -925,7 +926,7 @@ export const handleTranslate = async (
userMsg,
...apiSetting,
});
if (!Array.isArray(result)) {
if (!result?.length) {
throw new Error("tranlate got an unexpected result");
}