From ecfccf273e38021453e25a6d932dcf80d533c2f1 Mon Sep 17 00:00:00 2001 From: Yui <44658840+HereIsYui@users.noreply.github.com> Date: Sat, 12 Oct 2024 15:25:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=A9=E6=B0=94=E5=8D=A1?= =?UTF-8?q?=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../symphony/processor/ChatroomProcessor.java | 47 +- .../images/weather/svg/CLEAR_DAY.svg | 521 ++++++++++++++++++ .../images/weather/svg/CLEAR_NIGHT.svg | 503 +++++++++++++++++ .../resources/images/weather/svg/CLOUDY.svg | 500 +++++++++++++++++ .../resources/images/weather/svg/DUST.svg | 507 +++++++++++++++++ src/main/resources/images/weather/svg/FOG.svg | 503 +++++++++++++++++ .../images/weather/svg/HEAVY_HAZE.svg | 503 +++++++++++++++++ .../images/weather/svg/HEAVY_RAIN.svg | 91 +++ .../images/weather/svg/HEAVY_SNOW.svg | 166 ++++++ .../images/weather/svg/LIGHT_HAZE.svg | 501 +++++++++++++++++ .../images/weather/svg/LIGHT_RAIN.svg | 66 +++ .../images/weather/svg/LIGHT_SNOW.svg | 268 +++++++++ .../images/weather/svg/MODERATE_HAZE.svg | 502 +++++++++++++++++ .../images/weather/svg/MODERATE_RAIN.svg | 90 +++ .../images/weather/svg/MODERATE_SNOW.svg | 94 ++++ .../images/weather/svg/PARTLY_CLOUDY_DAY.svg | 176 ++++++ .../weather/svg/PARTLY_CLOUDY_NIGHT.svg | 198 +++++++ .../resources/images/weather/svg/SAND.svg | 511 +++++++++++++++++ .../images/weather/svg/STORM_RAIN.svg | 92 ++++ .../images/weather/svg/STORM_SNOW.svg | 225 ++++++++ .../resources/images/weather/svg/WIND.svg | 501 +++++++++++++++++ src/main/resources/js/channel.js | 3 + src/main/resources/js/chat-room.js | 233 ++++++++ src/main/resources/js/lib/echarts.min.js | 45 ++ .../resources/skins/classic/chat-room.ftl | 6 + src/main/resources/skins/classic/index.ftl | 2 + src/main/resources/skins/mobile/chat-room.ftl | 6 + 27 files changed, 6859 insertions(+), 1 deletion(-) create mode 100755 src/main/resources/images/weather/svg/CLEAR_DAY.svg create mode 100755 src/main/resources/images/weather/svg/CLEAR_NIGHT.svg create mode 100755 src/main/resources/images/weather/svg/CLOUDY.svg create mode 100755 src/main/resources/images/weather/svg/DUST.svg create mode 100755 src/main/resources/images/weather/svg/FOG.svg create mode 100755 src/main/resources/images/weather/svg/HEAVY_HAZE.svg create mode 100755 src/main/resources/images/weather/svg/HEAVY_RAIN.svg create mode 100755 src/main/resources/images/weather/svg/HEAVY_SNOW.svg create mode 100755 src/main/resources/images/weather/svg/LIGHT_HAZE.svg create mode 100755 src/main/resources/images/weather/svg/LIGHT_RAIN.svg create mode 100755 src/main/resources/images/weather/svg/LIGHT_SNOW.svg create mode 100755 src/main/resources/images/weather/svg/MODERATE_HAZE.svg create mode 100755 src/main/resources/images/weather/svg/MODERATE_RAIN.svg create mode 100755 src/main/resources/images/weather/svg/MODERATE_SNOW.svg create mode 100755 src/main/resources/images/weather/svg/PARTLY_CLOUDY_DAY.svg create mode 100755 src/main/resources/images/weather/svg/PARTLY_CLOUDY_NIGHT.svg create mode 100755 src/main/resources/images/weather/svg/SAND.svg create mode 100755 src/main/resources/images/weather/svg/STORM_RAIN.svg create mode 100755 src/main/resources/images/weather/svg/STORM_SNOW.svg create mode 100755 src/main/resources/images/weather/svg/WIND.svg create mode 100644 src/main/resources/js/lib/echarts.min.js diff --git a/src/main/java/org/b3log/symphony/processor/ChatroomProcessor.java b/src/main/java/org/b3log/symphony/processor/ChatroomProcessor.java index 42c5f154..dfc9aadb 100644 --- a/src/main/java/org/b3log/symphony/processor/ChatroomProcessor.java +++ b/src/main/java/org/b3log/symphony/processor/ChatroomProcessor.java @@ -905,7 +905,52 @@ public void addChatRoomMsg(final RequestContext context) { } catch (Exception e) { LOGGER.log(Level.INFO, "User " + userName + " failed to send a red packet."); } - } else if (content.startsWith("[setdiscuss]") && content.endsWith("[/setdiscuss]")) { + } else if (content.startsWith("[weather]") && content.endsWith("[/weather]")){ + String weatherString = content.replaceAll("^\\[weather\\]", "").replaceAll("\\[/weather\\]$", ""); + + JSONObject weatherJSON = new JSONObject(); + // 加活跃 + incLiveness(userId); + // 聊天室内容保存到数据库 + final Transaction transaction = chatRoomRepository.beginTransaction(); + try { + msg.put(Common.CONTENT, weatherString); + String oId = chatRoomRepository.add(new JSONObject().put("content", msg.toString())); + msg.put("oId", oId); + } catch (RepositoryException e) { + LOGGER.log(Level.ERROR, "Cannot save ChatRoom message to the database.", e); + } + transaction.commit(); + msg = msg.put("md", msg.optString(Common.CONTENT)).put(Common.CONTENT, processMarkdown(msg.optString(Common.CONTENT))); + final JSONObject pushMsg = JSONs.clone(msg); + pushMsg.put(Common.TIME, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(msg.optLong(Common.TIME))); + ChatroomChannel.notifyChat(pushMsg); + + context.renderJSON(StatusCodes.SUCC); + + try { + final List atUsers = atUsers(msg.optString(Common.CONTENT), userName); + if (Objects.nonNull(atUsers) && !atUsers.isEmpty()) { + for (JSONObject user : atUsers) { + final JSONObject notification = new JSONObject(); + notification.put(Notification.NOTIFICATION_USER_ID, user.optString("oId")); + notification.put(Notification.NOTIFICATION_DATA_ID, msg.optString("oId")); + notificationMgmtService.addChatRoomAtNotification(notification); + } + } + } catch (Exception e) { + LOGGER.log(Level.ERROR, "notify user failed", e); + } + + try { + final JSONObject user = userQueryService.getUser(userId); + user.put(UserExt.USER_LATEST_CMT_TIME, System.currentTimeMillis()); + userMgmtService.updateUser(userId, user); + } catch (final Exception e) { + LOGGER.log(Level.ERROR, "Update user latest comment time failed", e); + } + + } else if (content.startsWith("[setdiscuss]") && content.endsWith("[/setdiscuss]")) { // 扣钱 final boolean succ = null != pointtransferMgmtService.transfer(userId, Pointtransfer.ID_C_SYS, Pointtransfer.TRANSFER_TYPE_C_ACTIVITY_SET_DISCUSS, diff --git a/src/main/resources/images/weather/svg/CLEAR_DAY.svg b/src/main/resources/images/weather/svg/CLEAR_DAY.svg new file mode 100755 index 00000000..6996eccb --- /dev/null +++ b/src/main/resources/images/weather/svg/CLEAR_DAY.svg @@ -0,0 +1,521 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/CLEAR_NIGHT.svg b/src/main/resources/images/weather/svg/CLEAR_NIGHT.svg new file mode 100755 index 00000000..069dceba --- /dev/null +++ b/src/main/resources/images/weather/svg/CLEAR_NIGHT.svg @@ -0,0 +1,503 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/CLOUDY.svg b/src/main/resources/images/weather/svg/CLOUDY.svg new file mode 100755 index 00000000..1be5597c --- /dev/null +++ b/src/main/resources/images/weather/svg/CLOUDY.svg @@ -0,0 +1,500 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/DUST.svg b/src/main/resources/images/weather/svg/DUST.svg new file mode 100755 index 00000000..3ae04a78 --- /dev/null +++ b/src/main/resources/images/weather/svg/DUST.svg @@ -0,0 +1,507 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/FOG.svg b/src/main/resources/images/weather/svg/FOG.svg new file mode 100755 index 00000000..c3a2a748 --- /dev/null +++ b/src/main/resources/images/weather/svg/FOG.svg @@ -0,0 +1,503 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/HEAVY_HAZE.svg b/src/main/resources/images/weather/svg/HEAVY_HAZE.svg new file mode 100755 index 00000000..3f53c9e6 --- /dev/null +++ b/src/main/resources/images/weather/svg/HEAVY_HAZE.svg @@ -0,0 +1,503 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/HEAVY_RAIN.svg b/src/main/resources/images/weather/svg/HEAVY_RAIN.svg new file mode 100755 index 00000000..73e151c2 --- /dev/null +++ b/src/main/resources/images/weather/svg/HEAVY_RAIN.svg @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/HEAVY_SNOW.svg b/src/main/resources/images/weather/svg/HEAVY_SNOW.svg new file mode 100755 index 00000000..70872f28 --- /dev/null +++ b/src/main/resources/images/weather/svg/HEAVY_SNOW.svg @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/LIGHT_HAZE.svg b/src/main/resources/images/weather/svg/LIGHT_HAZE.svg new file mode 100755 index 00000000..6e3cab6e --- /dev/null +++ b/src/main/resources/images/weather/svg/LIGHT_HAZE.svg @@ -0,0 +1,501 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/LIGHT_RAIN.svg b/src/main/resources/images/weather/svg/LIGHT_RAIN.svg new file mode 100755 index 00000000..93d81f54 --- /dev/null +++ b/src/main/resources/images/weather/svg/LIGHT_RAIN.svg @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/LIGHT_SNOW.svg b/src/main/resources/images/weather/svg/LIGHT_SNOW.svg new file mode 100755 index 00000000..313c8da0 --- /dev/null +++ b/src/main/resources/images/weather/svg/LIGHT_SNOW.svg @@ -0,0 +1,268 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/MODERATE_HAZE.svg b/src/main/resources/images/weather/svg/MODERATE_HAZE.svg new file mode 100755 index 00000000..8987c167 --- /dev/null +++ b/src/main/resources/images/weather/svg/MODERATE_HAZE.svg @@ -0,0 +1,502 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/MODERATE_RAIN.svg b/src/main/resources/images/weather/svg/MODERATE_RAIN.svg new file mode 100755 index 00000000..cfd45a89 --- /dev/null +++ b/src/main/resources/images/weather/svg/MODERATE_RAIN.svg @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/MODERATE_SNOW.svg b/src/main/resources/images/weather/svg/MODERATE_SNOW.svg new file mode 100755 index 00000000..51f4246f --- /dev/null +++ b/src/main/resources/images/weather/svg/MODERATE_SNOW.svg @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/PARTLY_CLOUDY_DAY.svg b/src/main/resources/images/weather/svg/PARTLY_CLOUDY_DAY.svg new file mode 100755 index 00000000..9b27a532 --- /dev/null +++ b/src/main/resources/images/weather/svg/PARTLY_CLOUDY_DAY.svg @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/PARTLY_CLOUDY_NIGHT.svg b/src/main/resources/images/weather/svg/PARTLY_CLOUDY_NIGHT.svg new file mode 100755 index 00000000..113c8eca --- /dev/null +++ b/src/main/resources/images/weather/svg/PARTLY_CLOUDY_NIGHT.svg @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/SAND.svg b/src/main/resources/images/weather/svg/SAND.svg new file mode 100755 index 00000000..eeeb1038 --- /dev/null +++ b/src/main/resources/images/weather/svg/SAND.svg @@ -0,0 +1,511 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/STORM_RAIN.svg b/src/main/resources/images/weather/svg/STORM_RAIN.svg new file mode 100755 index 00000000..6a7f04e7 --- /dev/null +++ b/src/main/resources/images/weather/svg/STORM_RAIN.svg @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/STORM_SNOW.svg b/src/main/resources/images/weather/svg/STORM_SNOW.svg new file mode 100755 index 00000000..beba9e48 --- /dev/null +++ b/src/main/resources/images/weather/svg/STORM_SNOW.svg @@ -0,0 +1,225 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/images/weather/svg/WIND.svg b/src/main/resources/images/weather/svg/WIND.svg new file mode 100755 index 00000000..77be5660 --- /dev/null +++ b/src/main/resources/images/weather/svg/WIND.svg @@ -0,0 +1,501 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/js/channel.js b/src/main/resources/js/channel.js index 9c87d7cf..6c8bbbdd 100644 --- a/src/main/resources/js/channel.js +++ b/src/main/resources/js/channel.js @@ -493,6 +493,9 @@ var ChatRoomChannel = { if (newContent.indexOf("\"msgType\":\"redPacket\"") !== -1) { newContent = "[收到红包,请在完整版聊天室查看]"; } + if (newContent.indexOf("\"type\":\"weather\"") !== -1) { + newContent = "[天气卡片,请在完整版聊天室查看]"; + } $("#chatRoomIndex").prepend("" + "