This commit is contained in:
Zyronon
2025-11-23 22:18:18 +08:00
parent 1a8282088a
commit 5434ec975a
9 changed files with 121 additions and 43 deletions

View File

@@ -46,6 +46,7 @@ export function getDefaultArticle(val: Partial<Article> = {}): Article {
audioFileId: '',
lrcPosition: [],
questions: [],
nameList:[],
...cloneDeep(val)
}
}

13
src/types/global.d.ts vendored
View File

@@ -19,18 +19,25 @@ declare global {
}
}
console.json = function (v: any, space = 0) {
const json = JSON.stringify(
v,
(key, value) => {
if (Array.isArray(value)) {
if (Array.isArray(value) && key !== 'nameList') {
return `__ARRAY__${JSON.stringify(value)}`;
}
return value;
},
space
).replace(/"__ARRAY__(\[.*?\])"/g, (_, arr) => arr);
)
.replace(/"__ARRAY__(\[.*?\])"/g, (_, arr) => arr)
// 专门处理 nameList将其压缩成一行
.replace(/"nameList": \[\s*([^\]]+)\s*\]/g, (match, content) => {
// 移除数组内部的换行和多余空格,但保留字符串间的空格
const compressed = content.replace(/\s*\n\s*/g, ' ').trim();
return `"nameList": [${compressed}]`;
});
console.log(json);
return json;
}

View File

@@ -76,6 +76,7 @@ export interface Article {
audioSrc: string,
audioFileId: string,
lrcPosition: number[][],
nameList: string[],
questions: {
stem: string,
options: string[],