Skip to content

Commit

Permalink
fix: json 后面出现 string 内容
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Jul 24, 2024
1 parent cb81e37 commit 7d417b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion main/src/helpers/forwardHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default {
const resId = jsonObj.meta?.detail?.resid;
const fileName = jsonObj.meta?.detail?.uniseq;
if (resId) {
return { type: 'forward', resId };
return { type: 'forward', resId, fileName };
}
else {
return { type: 'text', text: '[解析转发消息时出错:没有 resId]' };
Expand Down
12 changes: 8 additions & 4 deletions main/src/services/ForwardService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ export default class ForwardService {
messageHeader = '';
}
};
const useForward = async (resId: string) => {
const useForward = async (resId: string, fileName?: string) => {
if (env.CRV_API) {
try {
const messages = await pair.qq.getForwardMsg(resId);
const messages = await pair.qq.getForwardMsg(resId, fileName);
message = helper.generateForwardBrief(messages);
const hash = md5Hex(resId);
const viewerUrl = env.CRV_VIEWER_APP ? `${env.CRV_VIEWER_APP}?startapp=${hash}` : `${env.CRV_API}/?hash=${hash}`;
Expand Down Expand Up @@ -188,7 +188,8 @@ export default class ForwardService {
type: 'image',
};
}
let url: string;
let url: string,
shouldBreak = false;
switch (elem.type) {
case 'text': {
// 判断微信文章
Expand Down Expand Up @@ -367,9 +368,10 @@ export default class ForwardService {
message = helper.htmlEscape(result.text);
break;
case 'forward':
await useForward(result.resId);
await useForward(result.resId, result.fileName);
break;
}
shouldBreak = true;
break;
}
case 'xml': {
Expand All @@ -393,6 +395,7 @@ export default class ForwardService {
await useForward(result.resId);
break;
}
shouldBreak = true;
break;
}
case 'rps':
Expand All @@ -406,6 +409,7 @@ export default class ForwardService {
message = `[<i>位置</i>] ${helper.htmlEscape(elem.name)}\n${helper.htmlEscape(elem.address)}`;
break;
}
if (shouldBreak) break;
}
message = message.trim();

Expand Down

0 comments on commit 7d417b7

Please sign in to comment.