Skip to content

Commit

Permalink
狂轰滥炸
Browse files Browse the repository at this point in the history
✨ 支持禁言状态显示和对应的输入框禁用 <- #121
✨ 增加了退出群组按钮 <- #121
✨ 支持非分页模式加载消息 <- #120
🎨 将 UserFriendElem 和 UserGroupElem 抽离出了父类,纠正了类元素写反了的问题
💄 重置了消息通知的页面样式
💄 修正了用户列表头像未上下居中的问题
🐛 修正后端连接模式 SSL 协议错误的问题
🐛 修正在处理系统通知后未刷新列表的问题 <- #121
  • Loading branch information
Stapxs committed Aug 27, 2024
1 parent 88cbb78 commit a17c039
Show file tree
Hide file tree
Showing 23 changed files with 347 additions and 120 deletions.
16 changes: 16 additions & 0 deletions src/assets/css/append/append_new.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
height: 30px;
width: 30px;
}
.friend-body > div:nth-child(1) {
height: 34px;
}
.friend-body > div p {
font-size: 0.8rem;
}
Expand Down Expand Up @@ -687,6 +690,19 @@
font-size: 0.8rem;
}

.sys-not-list > div > div:first-child img {
width: 40px;
height: 40px;
}
.sys-not-list > div > div:first-child a {
font-size: 0.75rem;
}
.sys-not-list > div > div:last-child button {
width: 70px;
height: 30px;
font-size: 0.75rem;
}

@media (max-width: 700px) {
.main-body > ul {
background: var(--color-card-2) !important;
Expand Down
58 changes: 57 additions & 1 deletion src/assets/css/chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ input {
width: 100%;
border: 0;
}
.chat-pan > div.more > div:nth-child(2) > div > form > input:disabled,
.chat-pan > div.more > div:nth-child(2) > div > form > textarea:disabled {
background: var(--color-card);
outline: 1px solid var(--color-card-2);
color: var(--color-font-2);
opacity: 0.7;
text-align: center;
font-size: 0.8rem;
}
.chat-pan > div.more > div:nth-child(2) > div > div {
border-radius: 7px;
min-height: 40px;
Expand Down Expand Up @@ -281,11 +290,58 @@ input {
}

.sys-not-list {
margin-top: 10px;
}
.sys-not-list > div {
background: var(--color-card-1);
margin-bottom: 10px;
border-radius: 7px;
margin-top: 10px;
display: flex;
flex-direction: row;
align-items: center;
padding: 10px;
}
.sys-not-list > div > div:first-child {
display: flex;
flex-direction: row;
align-items: center;
flex: 1;
}
.sys-not-list > div > div:first-child img {
width: 50px;
height: 50px;
border-radius: 7px;
border: 2px solid var(--color-card-2);
margin-right: 10px;
}
.sys-not-list > div > div:first-child div {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
text-align: left;
}
.sys-not-list > div > div:first-child span {
color: var(--color-main);
font-weight: bold;
}
.sys-not-list > div > div:first-child a {
color: var(--color-font);
font-size: 0.9rem;
}
.sys-not-list > div > div:first-child a:last-child {
color: var(--color-font-2);
}
.sys-not-list > div > div:last-child button {
margin-right: 10px;
width: 90px;
height: 35px;
font-size: 0.9rem;
}
.sys-not-list > div > div:last-child button:first-child {
background: var(--color-card-2);
color: var(--color-font-1);
}

.more-detail {
transition: height .3s;
Expand Down
4 changes: 4 additions & 0 deletions src/assets/css/msg.css
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@
.note-base > a {
color: var(--color-font);
}
.note-ban > a {
color: var(--color-main);
font-weight: bold;
}
.note-time {
color: var(--color-font-2) !important;
display: block;
Expand Down
2 changes: 2 additions & 0 deletions src/assets/css/view.css
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ textarea:focus {
border-radius: 7px;
transform: translate(0, 0);
transition: background .2s, color .2s, transform .2s;
align-items: center;
}
.friend-body.active {
background: var(--color-main);
Expand Down Expand Up @@ -423,6 +424,7 @@ textarea:focus {
overflow: hidden;
}
.friend-body > div:nth-child(1) {
height: 54px;
flex: unset;
width: 4px;
background: var(--color-main);
Expand Down
2 changes: 0 additions & 2 deletions src/assets/l10n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@
"option_account_lnick": "Bio",
"option_account_lnick_tip": "Write something about you here",
"list_system_notice": "System Messages",
"sys_notice_new_friend_from": "Friend source: ",
"option_dev_debug": "Output debugging info",
"option_dev_debug_tip": "Helps you figure out the version you're on.",
"btn_yes": "OK",
Expand Down Expand Up @@ -260,7 +259,6 @@
"chat_chat_info_silence_all_tip": "Mute all members except the owner and admins in the group",
"btn_accept": "Agree",
"btn_reject": "Decline",
"sys_notice_new_friend": "New friend request",
"sys_notice": "System Messages",
"chat_msg_menu_remove": "Remove from group",
"sys_notice_new_group_nmember": "Join request",
Expand Down
2 changes: 0 additions & 2 deletions src/assets/l10n/zh-CAT.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@
"option_account_lnick": "爪印",
"option_account_lnick_tip": "小猫咪才没有到处写字的坏心思",
"list_system_notice": "系统猫叫",
"sys_notice_new_friend_from": "来源:",
"option_dev_debug": "输出调试信息",
"option_dev_debug_tip": "到底用的什么版本呢 ……",
"btn_yes": "确定",
Expand Down Expand Up @@ -251,7 +250,6 @@
"chat_chat_info_silence_all_tip": "你们是不整点活不开心是吧",
"btn_accept": "同意",
"btn_reject": "拒绝",
"sys_notice_new_friend": "新猫友",
"sys_notice": "系统猫话",
"chat_msg_menu_remove": "移出猫圈",
"sys_notice_new_group_nmember": "入圈申请",
Expand Down
16 changes: 14 additions & 2 deletions src/assets/l10n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@
"option_account_lnick": "签名",
"option_account_lnick_tip": "啊吧啊吧(智慧的眼神)",
"list_system_notice": "系统通知",
"sys_notice_new_friend_from": "来源:",
"option_dev_debug": "输出调试信息",
"option_dev_debug_tip": "到底用的什么版本呢 ……",
"btn_yes": "确定",
Expand Down Expand Up @@ -251,7 +250,6 @@
"btn_accept": "同意",
"btn_reject": "拒绝",
"btn_reflush": "刷新页面",
"sys_notice_new_friend": "新朋友",
"sys_notice": "系统消息",
"chat_msg_menu_remove": "移出群聊",
"sys_notice_new_group_nmember": "入群申请",
Expand Down Expand Up @@ -343,6 +341,20 @@
"log_con_backend": "使用后端连接模式",
"list_menu_notice": "开启通知",
"list_menu_notice_close": "关闭通知",
"chat_send_msg_watermark_ban": "已被禁言至:{time}",
"note_ban_you": "禁言了你",
"note_ban_others": "管理员禁言了",
"note_unban": "管理员解除了 {name} 的禁言",
"days": "",
"hours": "小时",
"minutes": "分钟",
"seconds": "",
"you": "",
"exit_group": "退出群聊",
"trust_leave_group": "确定要退出群聊吗?",
"sys_notice_message": "留言",
"sys_notice_new_friend": "请求加为好友",
"sys_notice_invite_group": "邀请你加入群聊",

"menu_about": "关于",
"menu_update": "检查更新…",
Expand Down
2 changes: 0 additions & 2 deletions src/assets/l10n/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@
"option_account_lnick": "簽名檔",
"option_account_lnick_tip": "啊吧啊吧(充滿智慧的眼神)",
"list_system_notice": "系統通知",
"sys_notice_new_friend_from": "聯絡人來源:",
"option_dev_debug": "輸出偵錯資訊",
"option_dev_debug_tip": "我在用的是什麼版本?",
"btn_yes": "確認",
Expand Down Expand Up @@ -254,7 +253,6 @@
"chat_chat_info_silence_all_tip": "禁止群組所有者和管理員以外的群組成員在群組內傳送訊息",
"btn_accept": "同意",
"btn_reject": "拒絕",
"sys_notice_new_friend": "新的聯絡人請求",
"sys_notice": "系統訊息",
"chat_msg_menu_remove": "移出群組",
"sys_notice_new_group_nmember": "入群請求",
Expand Down
2 changes: 0 additions & 2 deletions src/assets/l10n/zh-YUE.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@
"option_account_lnick": "Bio",
"option_account_lnick_tip": "自我介紹資訊",
"list_system_notice": "系統通知",
"sys_notice_new_friend_from": "Friend 來源:",
"option_dev_debug": "輸出",
"option_dev_debug_tip": "我喺度用緊乜嘢啊……",
"btn_yes": "確認",
Expand Down Expand Up @@ -260,7 +259,6 @@
"chat_chat_info_silence_all_tip": "開啓後除咗 group owner 同管理員之外嘅其他人都唔可以講嘢",
"btn_accept": "同意",
"btn_reject": "拒絕",
"sys_notice_new_friend": "新嘅 friend 請求",
"sys_notice": "系統訊息",
"chat_msg_menu_remove": "踢出群組",
"sys_notice_new_group_nmember": "入群請求",
Expand Down
19 changes: 19 additions & 0 deletions src/assets/pathMap/NapCat.Onebot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ message_list:
name: get_group_msg_history
private_name: get_friend_msg_history
source: $.data.messages[*]
pageed: false # 是否支持分页(id + count 获取)
type: $.data
message_type:
user: private
Expand Down Expand Up @@ -115,6 +116,24 @@ group_essence:
add_digest_nick: /add_digest_nick
add_digest_time: /add_digest_time
is_end: $.data.is_end
# 获取群成员信息
group_member_info:
name: get_group_member_info
source: $.data
list:
group_id: /group_id
user_id: /user_id
nickname: /nickname
card: /card
sex: /sex
age: /age
join_time: /join_time
last_sent_time: /last_sent_time
is_robot: /is_robot
shut_up_timestamp: /shut_up_timestamp
# 退出群聊
leave_group:
name: set_group_leave
# 获取收藏表情
roaming_stamp:
name: fetch_custom_face
Expand Down
68 changes: 50 additions & 18 deletions src/components/NoticeBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@

</div>
</div>
<div class="note-ban note-base" v-if="data.notice_type == 'group_ban'">
<template v-if="data.sub_type === 'ban'">
<template v-if="isMe(data.user_id)">
<span>{{ $t('chat_member_type_admin') }}</span>
<a>&nbsp;{{ getName(data.operator_id) }}&nbsp;</a>
<span>{{ $t('note_ban_you') }}</span>
<span>&nbsp;{{ fTime(data.duration) }}</span>
</template>
<template v-else>
<span>{{ $t('note_ban_others') }}</span>
<a>&nbsp;{{ getName(data.user_id) }}&nbsp;</a>
<span>{{ fTime(data.duration) }}</span>
</template>
</template>
<span v-else>{{ $t('note_unban', { name: isMe(data.user_id) ? $t('you') : getName(data.user_id) }) }}</span>
</div>
<div class="note-time note-base" v-if="data.sub_type === 'time'">
<a>{{
Intl.DateTimeFormat(trueLang, getTimeConfig(new Date(data.time * 1000)))
Expand All @@ -26,36 +42,52 @@
<script lang="ts">
import { defineComponent, ref } from 'vue'
import { runtimeData } from '@/function/msg'
import { getTrueLang } from '@/function/utils/systemUtil'
import { getTimeConfig, getTrueLang } from '@/function/utils/systemUtil'
export default defineComponent({
name: 'NoticeBody',
props: ['data'],
data() {
return {
trueLang: getTrueLang(),
getTimeConfig,
info: ref(this.data) as { [key: string]: any }
}
},
methods: {
getTimeConfig(date: Date) {
let base = { hour: 'numeric', minute: 'numeric', second: 'numeric' } as Intl.DateTimeFormatOptions
const nowDate = new Date()
const todayDate = new Date().setHours(0, 0, 0, 0)
const paramsDate = date.setHours(0, 0, 0, 0)
if(todayDate != paramsDate) {
if (nowDate.getFullYear() == date.getFullYear() && nowDate.getMonth() == date.getMonth()) {
base.weekday = 'short'
} else if(nowDate.getFullYear() == date.getFullYear()) {
base.day = 'numeric'
base.month = 'short'
} else {
base.day = 'numeric'
base.month = 'short'
base.year = 'numeric'
}
isMe(id: number) {
return runtimeData.loginInfo.uin === id
},
getName(id: number) {
const back = runtimeData.chatInfo.info.group_members.filter((item) => {
return item.user_id === id
})
if (back.length === 1) {
return back[0].card === '' || back[0].card == null ? back[0].nickname : back[0].card
}
return id
},
fTime(time: number) {
// 将秒数转换为可阅读的事件,最大单位天
const day = Math.floor(time / 86400)
const hour = Math.floor((time % 86400) / 3600)
const minute = Math.floor((time % 3600) / 60)
const second = time % 60
let back = ''
if (day > 0) {
back += `${day} ${this.$t('days')} `
}
if (hour > 0) {
back += `${hour} ${this.$t('hours')} `
}
if (minute > 0) {
back += `${minute} ${this.$t('minutes')} `
}
if (second > 0) {
back += `${second} ${this.$t('seconds')} `
}
return base
return back
}
},
mounted() {
Expand Down
3 changes: 3 additions & 0 deletions src/function/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ export class Connector {
static send(name: string, value: {[key: string]: any}, echo: string = name) {
// 构建 JSON
const json = JSON.stringify({ action: name, params: value, echo: echo } as BotActionElem)
this.sendRaw(json)
}
static sendRaw(json: string) {
// 发送
if(runtimeData.tags.isElectron) {
const reader = runtimeData.reader
Expand Down
15 changes: 8 additions & 7 deletions src/function/electron/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ export class Connector {
}
if(this.reconnectTimes < 5) {
setTimeout(() => {
if(e.code == 1015) {
// TSL 连接失败,尝试使用非加密连接
this.websocket = undefined
this.logger.warn('连接失败,尝试使用非加密连接...')
this.connect(url.replace('wss://', 'ws://'), token)
} else if(e.code == 1006) {
// 连接失败,尝试重连
if(e.code == 1006) {
// 连接失败,尝试轮替协议重连
if(url.indexOf('wss://') >= 0) {
url = url.replace('wss://', 'ws://')
} else {
url = url.replace('ws://', 'wss://')
}
this.logger.warn('连接失败,尝试重连...')
this.connect(url, token)
}
Expand All @@ -102,6 +102,7 @@ export class Connector {
}
}
this.websocket.onerror = (e) => {
this.websocket = undefined
this.logger.error('连接错误:', e)
}
}
Expand Down
Loading

0 comments on commit a17c039

Please sign in to comment.