Skip to content

Commit

Permalink
写代码一时爽,重构火葬场
Browse files Browse the repository at this point in the history
✨ 支持显示群戳一戳信息
✨ 脚本页面增加一些内置脚本
✨ 对自己发送的表情回应进行了显示
🎨 优化消息处理分发代码,去除大量 switch
💩 移除历史遗留的分阶段获取视频消息的功能
  • Loading branch information
Stapxs committed Sep 2, 2024
1 parent d3ef80f commit 3179848
Show file tree
Hide file tree
Showing 10 changed files with 931 additions and 674 deletions.
11 changes: 11 additions & 0 deletions src/assets/css/msg.css
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,17 @@
margin: 0 5px;
}

.note-notify img {
display: inline-block;
width: 1rem;
margin: 0 3px;
}
.note-notify span {
margin: 0 3px;
color: var(--color-main);
font-weight: bold;
}

@media (max-width: 992px) {
/* 消息体 */
.message > img {
Expand Down
1 change: 1 addition & 0 deletions src/assets/l10n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@
"option_view_vibrancy_mode_tip": "怎么看光还要挑三拣四的",
"option_dev_restart_tip1": "此操作将在重启应用后生效,现在就要重启吗?",
"option_dev_restart_tip2": "此操作仅供娱乐,将会在下次关闭时恢复。",
"a_inner_script": "这是个内嵌示例脚本,你可以修改它并保存使用。",

"menu_about": "关于",
"menu_update": "检查更新…",
Expand Down
12 changes: 12 additions & 0 deletions src/assets/scripts/_scriptList.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"title": "自动回应",
"name": "autoResponse",
"condition": "message"
},
{
"title": "刷新特别关心",
"name": "createSpecialCare",
"condition": "userFlush"
}
]
11 changes: 11 additions & 0 deletions src/assets/scripts/autoResponse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
title: 自动回应
*/

const id = this.msgInfo.group_id ?? this.msgInfo.private_id
const blacklist = []

if (this.isMe && blacklist.indexOf(id) === -1) {
this.sendMsg('set_msg_emoji_like',
{ 'message_id': this.message.message_id, 'emoji_id': '66' })
}
22 changes: 22 additions & 0 deletions src/assets/scripts/createSpecialCare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
title: 刷新特别关心
discription: 有些框架获取分组可能不包含特别关心,
你可以用这个脚本来指定特别关心的用户;
享受特别关心的相关通知功能。
*/

const specialList = []
for (const user of this.runtimeData.userList) {
if (specialList.includes(user.user_id)) {
user.class_id = 9999
user.class_name = '特别关心'
const classInfo = this.runtimeData.tags.classes.find(
(item) => item.class_id == 9999)
if (classInfo == undefined) {
this.runtimeData.tags.classes.unshift({
class_id: 9999,
class_name: '特别关心'
})
}
}
}
18 changes: 1 addition & 17 deletions src/components/MsgBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@
</div>
</div>
<div v-else-if="item.type == 'video'" class="msg-video">
<video v-if="item.url" controls muted autoplay>
<video controls muted autoplay>
<source :src="item.url" type="video/mp4">
现在还有不支持 video tag 的浏览器吗?
</video>
<div v-else-if="!getVideo" :class="getVideoUrl(item, data.message_id)"></div>
</div>
<span v-else-if="item.type == 'forward'" class="msg-unknown" style="cursor: pointer;" @click="View.getForwardMsg(item.id)">{{ $t('chat_show_forward') }}</span>
<div v-else-if="item.type == 'reply'" @click="scrollToMsg(item.id)" :class="isMe ? (type == 'merge' ? 'msg-replay' : 'msg-replay me') : 'msg-replay'">
Expand Down Expand Up @@ -447,21 +446,6 @@ export default defineComponent({
}
},

/**
*
* @param msgId 消息 ID
* @param fid 文件 ID
*/
getVideoUrl(data: any, message_id: string) {
this.getVideo = true
Connector.send('get_video_url', {
id: runtimeData.chatInfo.show.id,
message_id: message_id,
fid: data.fid,
md5: data.md5
}, 'getVideoUrl_' + message_id)
},

/**
* 文本消息被点击
* @param event 事件
Expand Down
9 changes: 4 additions & 5 deletions src/components/NoticeBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
<div class="note-recall note-base" v-if="data.notice_type && data.notice_type.indexOf('recall') >= 0">
<a>{{ info.name }}</a>
<span>{{ $t('chat_notice_recall') }}</span>
<div>

</div>
<div></div>
</div>
<div class="note-ban note-base" v-if="data.notice_type == 'group_ban'">
<div v-if="data.notice_type == 'group_ban'" class="note-ban note-base">
<template v-if="data.sub_type === 'ban'">
<template v-if="isMe(data.user_id)">
<span>{{ $t('chat_member_type_admin') }}</span>
Expand All @@ -30,7 +28,8 @@
</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'">
<div v-if="data.sub_type === 'poke'" class="note-notify note-base" v-html="data.str"></div>
<div v-if="data.sub_type === 'time'" class="note-time note-base">
<a>{{
Intl.DateTimeFormat(trueLang, getTimeConfig(new Date(data.time * 1000)))
.format(new Date(data.time * 1000))
Expand Down
Loading

0 comments on commit 3179848

Please sign in to comment.