Skip to content

Commit

Permalink
咕噜噜噜噜
Browse files Browse the repository at this point in the history
✨ 现在你可以关闭群收纳盒,使群消息也全部显示在消息列表中 <- #185
🐛 修正 at 你、at 全体文本 i18n 异常的问题
🐛 修正消息列表排序刷新不及时的问题
  • Loading branch information
Stapxs committed Feb 13, 2025
1 parent d5e0a88 commit bf5f2f1
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 109 deletions.
11 changes: 9 additions & 2 deletions scripts/clear-dist.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
dirs=(
# web
"dist"
"stats.html"
# electron
"out"
"dist_electron"
# capacitor
"dist_capacitor"
"out"
# npx
"ssqq.npx-web-quick-start/bin"
"ssqq.npx-web-quick-start/node_modules"
"stats.html"
# android
"src/mobile/android/app/release"
"src/mobile/android/app/debug"
)

for dir in ${dirs[@]}; do
Expand Down
6 changes: 0 additions & 6 deletions src/renderer/src/assets/l10n/zh-CAT.po
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,6 @@ msgstr "喵喵喵喵喵!"
msgid "开发者选项"
msgstr "工程喵选项"

msgid "通知所有新消息"
msgstr "通知左右新喵喵"

msgid "让暴风雨来得更猛烈些吧!"
msgstr "让喵喵风暴来得更猛烈些吧!"

msgid "好嘛 …… 不烦你 ……"
msgstr "不可以喵喵!"

Expand Down
8 changes: 4 additions & 4 deletions src/renderer/src/assets/l10n/zh-CN.po
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ msgstr ""
msgid "ReferenceError: moYu is not defined"
msgstr ""

msgid "通知所有新消息"
msgid "关闭群收纳盒"
msgstr ""

msgid "让暴风雨来得更猛烈些吧!"
msgid "全都放出来!全都放出来!"
msgstr ""

msgid "禁用通知"
Expand Down Expand Up @@ -991,10 +991,10 @@ msgid "别划了别划了被看见了啦"
msgstr ""

msgid "[有人@你]"
msgstr ""
msgstr "[有人{'@'}你]"

msgid "[@全体]"
msgstr ""
msgstr "[{'@'}全体]"

msgid "[特別关心]"
msgstr ""
8 changes: 4 additions & 4 deletions src/renderer/src/assets/l10n/zh-TW.po
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@ msgstr "基本"
msgid "ReferenceError: moYu is not defined"
msgstr "ReferenceError: moYu is not defined"

msgid "通知所有新消息"
msgstr "通知所有新訊息"
msgid "关闭群收纳盒"
msgstr ""

msgid "让暴风雨来得更猛烈些吧!"
msgstr "讓暴風雨來得更猛烈些吧!"
msgid "全都放出来!全都放出来!"
msgstr ""

msgid "禁用通知"
msgstr "停用通知"
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/src/assets/l10n/zh-YUE.po
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@ msgstr "Info"
msgid "ReferenceError: moYu is not defined"
msgstr "小心老闆叫你 OT debug 囉"

msgid "通知所有新消息"
msgstr "通知所有訊息"
msgid "关闭群收纳盒"
msgstr ""

msgid "让暴风雨来得更猛烈些吧!"
msgstr "電 腦 大 爆 炸!!!"
msgid "全都放出来!全都放出来!"
msgstr ""

msgid "禁用通知"
msgstr "停用通知"
Expand Down
167 changes: 103 additions & 64 deletions src/renderer/src/function/msg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1471,9 +1471,10 @@ function newMsg(_: string, data: any) {
if (data.detail_type == 'guild') {
return
}
// 获取一些基础信息

const infoList = getMsgData('message_info', data, msgPath.message_info)
if (infoList != undefined) {
// 消息基础信息 ============================================
const info = infoList[0]
const id = info.group_id ?? info.private_id
const loginId = runtimeData.loginInfo.uin
Expand All @@ -1485,6 +1486,7 @@ function newMsg(_: string, data: any) {
})
const isImportant = senderInfo?.class_id == 9999

// 预发送消息填充 ============================================
// 列表内最近的一条 fake_msg(倒序查找)
let fakeIndex = -1
for (let i = runtimeData.messageList.length - 1; i > 0; i--) {
Expand Down Expand Up @@ -1515,7 +1517,7 @@ function newMsg(_: string, data: any) {
return
}

// 显示消息
// 显示消息 ============================================
if (id === showId || info.target_id == showId) {
// 保存消息
saveMsg(buildMsgList([data]), 'bottom')
Expand Down Expand Up @@ -1561,6 +1563,68 @@ function newMsg(_: string, data: any) {
)
data = list[0]
}

// 通知判定预处理 ============================================
// 对于其他不在消息里标记 atme、atall 的处理
if (data.atme == undefined || data.atall == undefined) {
data.message.forEach((item: any) => {
if (item.type == 'at' && item.qq == loginId) {
data.atme = true
}
})
}
// 临时会话名字的特殊处理
if (data.sub_type === 'group') {
data.sender.nickname = data.sender.user_id
}
// 检查群组有没有开启通知
let isGroupNotice = false
if (data.message_type === 'group') {
const noticeInfo = Option.get('notice_group') ?? {}
const list = noticeInfo[runtimeData.loginInfo.uin]
if (list) {
isGroupNotice = list.indexOf(id) >= 0
}
}

// 群收纳箱 ============================================
if(!runtimeData.sysConfig.bubble_sort_user) {
// 刷新群收纳箱列表
const getGroup = runtimeData.groupAssistList.filter((item, index) => {
if (Number(id) === item.group_id) {
runtimeData.groupAssistList[index].message_id = data.message_id
const name = data.sender.card && data.sender.card !== ''? data.sender.card: data.sender.nickname
runtimeData.groupAssistList[index].raw_msg = name + ': ' + getMsgRawTxt(data)
runtimeData.groupAssistList[index].raw_msg_base = getMsgRawTxt(data)
runtimeData.groupAssistList[index].time = getViewTime(Number(data.time))

// 重新排序
const newList = orderOnMsgList(runtimeData.groupAssistList)
runtimeData.groupAssistList = newList
return true
}
return false
})
// ( 如果 是群组消息 && 群组没有开启通知 && 不是置顶的 ) 这种情况下将群消息添加到群收纳盒中
if (getGroup.length != 1 && data.message_type === 'group' && !isGroupNotice) {
const getList = runtimeData.userList.filter((item) => {
return item.group_id === id
})
if (getList.length === 1) {
const showGroup = getList[0]
if (!showGroup.always_top) {
const formatted = formatMessageData(data, true)
Object.assign(showGroup, formatted)
runtimeData.groupAssistList.push(showGroup)
// 重新排序
const newList = orderOnMsgList(runtimeData.groupAssistList)
runtimeData.groupAssistList = newList
}
}
}
}

// 消息列表 ============================================
// 刷新消息列表
const get = runtimeData.onMsgList.filter((item, index) => {
if (
Expand All @@ -1580,6 +1644,9 @@ function newMsg(_: string, data: any) {
runtimeData.onMsgList[index].time = getViewTime(
Number(data.time),
)
if(data.atme) { runtimeData.onMsgList[index].highlight = $t('[有人@你]') }
if(data.atall) { runtimeData.onMsgList[index].highlight = $t('[@全体]') }
if(isImportant) { runtimeData.onMsgList[index].highlight = $t('[特別关心]') }

// 重新排序列表
const newList = orderOnMsgList(runtimeData.onMsgList)
Expand All @@ -1588,54 +1655,35 @@ function newMsg(_: string, data: any) {
}
return false
})
// 刷新群收纳箱列表
const getGroup = runtimeData.groupAssistList.filter((item, index) => {
if (Number(id) === item.group_id) {
runtimeData.groupAssistList[index].message_id = data.message_id
const name = data.sender.card && data.sender.card !== ''? data.sender.card: data.sender.nickname
runtimeData.groupAssistList[index].raw_msg = name + ': ' + getMsgRawTxt(data)
runtimeData.groupAssistList[index].raw_msg_base = getMsgRawTxt(data)
runtimeData.groupAssistList[index].time = getViewTime(Number(data.time))

// 重新排序
const newList = orderOnMsgList(runtimeData.groupAssistList)
runtimeData.groupAssistList = newList
return true
}
return false
})
// 对于其他不在消息里标记 atme、atall 的处理
if (data.atme == undefined || data.atall == undefined) {
data.message.forEach((item: any) => {
if (item.type == 'at' && item.qq == loginId) {
data.atme = true
// 如果禁用了群收纳箱,将群消息添加到消息列表里
if(runtimeData.sysConfig.bubble_sort_user) {
if (get.length !== 1 && data.message_type === 'group') {
const getList = runtimeData.userList.filter((item) => {
return item.group_id === id
})
if (getList.length === 1) {
const showGroup = getList[0]
const formatted = formatMessageData(data, true)
Object.assign(showGroup, formatted)
runtimeData.onMsgList.push(showGroup)
// 重新排序列表
const newList = orderOnMsgList(runtimeData.onMsgList)
runtimeData.onMsgList = newList
}
})
}
// 临时会话名字的特殊处理
if (data.sub_type === 'group') {
data.sender.nickname = data.sender.user_id
}
// 检查群组有没有开启通知
let isGroupNotice = false
if (data.message_type === 'group') {
const noticeInfo = Option.get('notice_group') ?? {}
const list = noticeInfo[runtimeData.loginInfo.uin]
if (list) {
isGroupNotice = list.indexOf(id) >= 0
}
}

// 通知判定 ============================================
// eslint-disable-next-line max-len
// (发送者不是自己 && (在特别关心列表里 || 发送者不是群组 || 群组 AT || 群组 AT 全体 || 群组开启了通知 || 打开了通知全部消息)) 这些情况需要进行新消息处理
// (发送者不是自己 && (在特别关心列表里 || 发送者不是群组 || 群组 AT || 群组 AT 全体 || 群组开启了通知)) 这些情况需要进行新消息处理
if (
sender != loginId &&
sender != 0 &&
(isImportant ||
data.message_type !== 'group' ||
data.atme ||
data.atall ||
isGroupNotice ||
Option.get('notice_all') === true)
isGroupNotice)
) {
logger.add(LogType.DEBUG, '通知判定:', {
notShow: id !== showId,
Expand Down Expand Up @@ -1708,16 +1756,23 @@ function newMsg(_: string, data: any) {
const getList = runtimeData.userList.filter((item) => {
return item.user_id === id || item.group_id === id
})
if (getList.length === 1) {
const showUser = getList[0]
const formatted = formatMessageData(data, data.message_type === 'group')
Object.assign(showUser, formatted)

if(data.atme) { showUser.highlight = $t('[有人@你]') }
if(data.atall) { showUser.highlight = $t('[@全体]') }
if(isImportant) { showUser.highlight = $t('[特別关心]') }
// 检查 onMsgList 里有没有这个人
const getOnMsg = runtimeData.onMsgList.filter((item) => {
return item.user_id === id || item.group_id === id
})

runtimeData.onMsgList.push(showUser)
if (getList.length === 1) {
if(getOnMsg.length === 0) {
const showUser = getList[0]
const formatted = formatMessageData(data, data.message_type === 'group')
Object.assign(showUser, formatted)
runtimeData.onMsgList.push(showUser)
} else {
const showUser = getOnMsg[0]
if(data.atme) { showUser.highlight = $t('[有人@你]') }
if(data.atall) { showUser.highlight = $t('[@全体]') }
if(isImportant) { showUser.highlight = $t('[特別关心]') }
}
}
}
}
Expand All @@ -1729,22 +1784,6 @@ function newMsg(_: string, data: any) {
}
})
}

// ( 如果 是群组消息 && 群组没有开启通知 && 不是置顶的 ) 这种情况下将群消息添加到群通知列表中
const close_group_assist = runtimeData.sysConfig.close_group_assist
if (!close_group_assist && getGroup.length != 1 && data.message_type === 'group' && !isGroupNotice) {
const getList = runtimeData.userList.filter((item) => {
return item.group_id === id
})
if (getList.length === 1) {
const showGroup = getList[0]
if (!showGroup.always_top) {
const formatted = formatMessageData(data, true)
Object.assign(showGroup, formatted)
runtimeData.groupAssistList.push(showGroup)
}
}
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/renderer/src/function/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
getPortableFileLang,
getTrueLang,
} from '@renderer/function/utils/systemUtil'
import { orderOnMsgList } from './utils/msgUtil'

let cacheConfigs: { [key: string]: any }

Expand Down Expand Up @@ -58,6 +59,17 @@ const configFunction: { [key: string]: (value: any) => void } = {
opt_revolve: viewRevolve,
opt_always_top: viewAlwaysTop,
opt_fast_animation: updateFarstAnimation,
bubble_sort_user: clearGroupAssist,
}

function clearGroupAssist() {
// 如果 GroupAssistList 里有东西,把它们全部挪到 OnMsgList 里然后清空
if (runtimeData.groupAssistList.length > 0) {
runtimeData.onMsgList.push(...runtimeData.groupAssistList)
runtimeData.groupAssistList = []
const newList = orderOnMsgList(runtimeData.onMsgList)
runtimeData.onMsgList = newList
}
}

function updateFarstAnimation(value: boolean) {
Expand Down
Loading

1 comment on commit bf5f2f1

@dev-soragoto
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好快的改!

Please sign in to comment.