Skip to content

Commit

Permalink
Merge pull request #152 from HereIsYui/master
Browse files Browse the repository at this point in the history
修复天气卡片显示
  • Loading branch information
adlered authored Oct 12, 2024
2 parents 191c4d4 + 3a6ce69 commit 0240d7c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -907,13 +907,14 @@ public void addChatRoomMsg(final RequestContext context) {
}
} else if (content.startsWith("[weather]") && content.endsWith("[/weather]")){
String weatherString = content.replaceAll("^\\[weather\\]", "").replaceAll("\\[/weather\\]$", "");

JSONObject weather = new JSONObject(weatherString);
weather.put("msgType","weather");
// 加活跃
incLiveness(userId);
// 聊天室内容保存到数据库
final Transaction transaction = chatRoomRepository.beginTransaction();
try {
msg.put(Common.CONTENT, weatherString);
msg.put(Common.CONTENT, weather.toString());
String oId = chatRoomRepository.add(new JSONObject().put("content", msg.toString()));
msg.put("oId", oId);
} catch (RepositoryException e) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/js/chat-room.js
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,7 @@ ${result.info.msg}
'</div>';
}
}
}else if(msgJSON.type === "weather"){
}else if(msgJSON.msgType === "weather"){
isWeather = true;
data.content = '<div id="weather_'+ data.oId +'" style="width: 300px;height:280px;" data-date="'+msgJSON.date+'" data-code="'+msgJSON.weatherCode+'" data-max="'+msgJSON.max+'" data-min="'+msgJSON.min+'" data-t="'+msgJSON.t+'" data-st="'+msgJSON.st+'"></div>';
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/skins/classic/index.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
<#assign text=msg.content>
<#if text?contains("\"msgType\":\"redPacket\"")>
[收到红包,请在完整版聊天室查看]
<#elseif text?contains("\"type\":\"weather\"")>
<#elseif text?contains("\"msgType\":\"weather\"")>
[天气卡片,请在完整版聊天室查看]
<#else>
${text}
Expand Down

0 comments on commit 0240d7c

Please sign in to comment.