mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-15 09:48:14 +08:00
♻️ 调整解析逻辑
This commit is contained in:
@@ -54,9 +54,26 @@ function getParsedData(data: TGApp.Plugins.Mys.SctPost.Base[]): TGApp.Plugins.My
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const parsedText = getParsedText(tp);
|
const parsedText = getParsedText(tp);
|
||||||
for (const text of parsedText) {
|
let check = 0;
|
||||||
child.push(text);
|
for (let i = 0; i < parsedText.length; i++) {
|
||||||
|
const text = parsedText[i];
|
||||||
|
child.push(parsedText[i]);
|
||||||
if (text.insert === "\n") {
|
if (text.insert === "\n") {
|
||||||
|
cur = {
|
||||||
|
insert: "",
|
||||||
|
attributes: text.attributes,
|
||||||
|
children: child,
|
||||||
|
};
|
||||||
|
res.push(cur);
|
||||||
|
check += child.length;
|
||||||
|
child = [];
|
||||||
|
}
|
||||||
|
if (i === parsedText.length - 1 && check !== parsedText.length) {
|
||||||
|
if (child.length === 1) {
|
||||||
|
res.push(child[0]);
|
||||||
|
child = [];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
cur = {
|
cur = {
|
||||||
insert: "",
|
insert: "",
|
||||||
attributes: text.attributes,
|
attributes: text.attributes,
|
||||||
@@ -66,16 +83,6 @@ function getParsedData(data: TGApp.Plugins.Mys.SctPost.Base[]): TGApp.Plugins.My
|
|||||||
child = [];
|
child = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 可能没有换行符,导致res为空
|
|
||||||
if (res.length === 0) {
|
|
||||||
cur = {
|
|
||||||
insert: "",
|
|
||||||
attributes: tp.attributes,
|
|
||||||
children: child,
|
|
||||||
};
|
|
||||||
res.push(cur);
|
|
||||||
child = [];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user