♻️ 调整解析逻辑

This commit is contained in:
目棃
2024-09-02 13:30:27 +08:00
parent db018ba965
commit e7b176f9f4

View File

@@ -54,9 +54,26 @@ function getParsedData(data: TGApp.Plugins.Mys.SctPost.Base[]): TGApp.Plugins.My
continue;
}
const parsedText = getParsedText(tp);
for (const text of parsedText) {
child.push(text);
let check = 0;
for (let i = 0; i < parsedText.length; i++) {
const text = parsedText[i];
child.push(parsedText[i]);
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 = {
insert: "",
attributes: text.attributes,
@@ -66,16 +83,6 @@ function getParsedData(data: TGApp.Plugins.Mys.SctPost.Base[]): TGApp.Plugins.My
child = [];
}
}
// 可能没有换行符导致res为空
if (res.length === 0) {
cur = {
insert: "",
attributes: tp.attributes,
children: child,
};
res.push(cur);
child = [];
}
}
return res;
}