Skip to content

Commit

Permalink
feat:添加消息合并
Browse files Browse the repository at this point in the history
  • Loading branch information
Night-stars-1 committed Feb 12, 2024
1 parent 94fce4d commit 51d3f31
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 167 deletions.
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "QQ增强",
"slug": "qqpromote",
"description": "复读姬,二维码识别,时间显示,翻译,屏蔽更新,链接预览,ChatGPT,禁止回复自动AT,侧边栏管理,自动登录,屏蔽通话,群聊名称扩展",
"version": "1.4.0.1",
"version": "1.5.0",
"authors": [
{
"name": "Night-stars-1",
Expand All @@ -15,7 +15,7 @@
"repo": "Night-stars-1/LiteLoaderQQNT-Plugin-QQPromote",
"branch": "master",
"release": {
"tag": "v1.4.0.1"
"tag": "v1.5.0"
}
},
"platform": [
Expand Down
45 changes: 9 additions & 36 deletions src/config/message.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,67 +83,40 @@ video.qqpromote_video {
pointer-events: none;
}

/*

@keyframes nameHideAnimation {
0% { opacity: 1; }
100% { opacity: 0; display: none; }
}
@keyframes messageHideAnimation {
0% { opacity: 1; }
100% { opacity: 1; padding-bottom: 0; }
}
.name_hidden {
animation: nameHideAnimation 0.5s ease forwards;
}
.message_hidden {
animation: messageHideAnimation 0.5s ease forwards;
}
.merge-message .ml-root.q-scroll-view .ml-item.merge.merge-main .avatar-span {
display: grid;
position: absolute;
top: 0px;
}
.ml-root.q-scroll-view .ml-list,
.ml-root.q-scroll-view .avatar-span {
.message_merging .ml-root.q-scroll-view .ml-list,
.message_merging .ml-root.q-scroll-view .avatar-span {
overflow: unset;
}

.ml-list.list .message-container .avatar-span {
.message_merging .ml-list.list .message.main .message-container .avatar-span {
top: 0px;
position: absolute;
display: grid;
align-items: end;
}

.ml-list.list .message-container .avatar {
.message_merging .ml-list.list .message.main .message-container .avatar {
position: sticky !important;
bottom: 0px !important;
}

.ml-list.list .ml-item:not(.main) .avatar-span {
.message_merging .ml-list.list .message:not(.main) .avatar-span {
display: none;
}

.ml-list.list .ml-item:not(.main) .user-name {
.message_merging .ml-list.list .message:not(.main) .user-name {
display: none;
}

.ml-list.list .message__timestamp {
.message_merging .ml-list.list .message__timestamp {
display: none;
}

.ml-list.list .message {
.message_merging .ml-list.list .message {
padding-bottom: 0px;
}

.ml-list.list .message-container {
.message_merging .ml-list.list .message-container {
padding: 0px 20px;
}
*/
25 changes: 24 additions & 1 deletion src/config/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: Night-stars-1 [email protected]
* @Date: 2023-08-12 20:16:45
* @LastEditors: Night-stars-1 [email protected]
* @LastEditTime: 2024-02-02 20:33:34
* @LastEditTime: 2024-02-12 16:17:57
* @Description:
*
* Copyright (c) 2023 by Night-stars-1, All Rights Reserved.
Expand Down Expand Up @@ -284,6 +284,29 @@ <h2>文字转语言(未完成)</h2>
<span class="q-switch__handle"></span>
</div>
</div>
<hr class="horizontal-dividing-line">
<div class="vertical-list-item" @click="message_merging = !message_merging">
<div>
<h2>消息合并</h2>
<span class="secondary-text">消息合并(重启生效)</span>
</div>
<div class="switchBackgroundImage q-switch" :class="{ 'is-active': message_merging }">
<span class="q-switch__handle"></span>
</div>
</div>
<Transition duration="500" name="nested">
<div v-if="false">
<div class="vertical-list-item" @click="message_avatar_float = !message_avatar_float">
<div>
<h2>头像浮动</h2>
<span class="secondary-text">头像浮动</span>
</div>
<div class="switchBackgroundImage q-switch" :class="{ 'is-active': message_avatar_float }">
<span class="q-switch__handle"></span>
</div>
</div>
</div>
</Transition>
</div>

<div class="wrap" id="sidebar">
Expand Down
7 changes: 6 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: Night-stars-1 [email protected]
* @Date: 2023-08-12 15:41:47
* @LastEditors: Night-stars-1 [email protected]
* @LastEditTime: 2024-02-03 21:10:22
* @LastEditTime: 2024-02-07 15:53:53
* @Description:
*
* Copyright (c) 2023 by Night-stars-1, All Rights Reserved.
Expand All @@ -14,6 +14,7 @@ const { onLoad, setSettings } = require("./main/onLoad.js");
const { output, replaceArk, getEmojis } = require("./main/utils.js");

let emojiCallbackId = "";
let lastSenderUid = "";

function onBrowserWindowCreated(window) {
const pluginDataPath = LiteLoader.plugins.qqpromote.path.data;
Expand All @@ -30,6 +31,7 @@ function onBrowserWindowCreated(window) {
const msgList = args?.[1]?.msgList;
// 替换小程序卡片
msgList.forEach((msgItem) => {
if (!msgItem.qqpromote) msgItem.qqpromote = {}
let msg_seq = msgItem.msgSeq;
msgItem.elements.forEach((msgElement) => {
// output(msgItem.msgType, msgItem.subMsgType, msgElement.grayTipElement)
Expand Down Expand Up @@ -77,7 +79,10 @@ function onBrowserWindowCreated(window) {
};
}
});
msgItem.qqpromote.chatType = lastSenderUid === msgItem.senderUid? 'child':'main'
lastSenderUid = msgItem.senderUid
});
//msgList.reverse();
} else if (args?.[1]?.[0]?.cmdName === "nodeIKernelUnitedConfigListener/onUnitedConfigUpdate" && data.setting.not_updata) {
// 屏蔽更新
args[1][0].payload.configData.content = ""
Expand Down
5 changes: 2 additions & 3 deletions src/main/link_preview.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Date: 2024-02-03 16:15:39
* @LastEditors: Night-stars-1 [email protected]
* @LastEditTime: 2024-02-03 20:46:48
* LastEditors: Night-stars-1 [email protected]
* LastEditTime: 2024-02-12 16:06:07
*/
const axios = require('axios');

Expand All @@ -19,7 +19,6 @@ async function getLinkPreview(url) {
* @type {string[]} meta信息
*/
const metaMatches = headContent.match(/[<meta[\s\S]*?>|<title(.*)\/title>]/ig);
console.timeLog('headContent')
metaMatches.forEach(element => {
element.includes('</title>') && (data.title = element.match(/[<title>]?(.*)<\/title>/)[1])
|| element.includes('property="og:title"') && (data.title = element.match(/content="([\s\S]*)"/)[1])
Expand Down
2 changes: 1 addition & 1 deletion src/main/onLoad.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function onLoad() {
let data = {};
try {
data = await getUrlData(url)
if (!data) {
if (data) {
data = await getLinkPreview(url);
setUrlData(url, data)
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ const defaultSettings = {
name: '新年大龙',
value: false
}
}
},
message_merging: false,
message_avatar_float: false
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/renderer.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/*
* @Date: 2024-01-09 00:35:45
* @LastEditors: Night-stars-1 [email protected]
* @LastEditTime: 2024-02-03 20:12:24
* LastEditors: Night-stars-1 [email protected]
* LastEditTime: 2024-02-12 17:33:49
*/
import { domUpMessages } from "./renderer/domUpMessages.js"
import { changeHref, domUpNavItem } from "./renderer/changeHref.js"
import { userLogin } from "./renderer/userLogin.js"
import { setMessage } from "./renderer/setMessage.js"
import { addrepeatmsg_menu } from "./renderer/addRepeatMsgMenu.js"
import { setting_vue } from "./renderer/setVue.js"
import { hookVue3 } from "./renderer/vue.js"

const updateStyle = qqpromote.updateStyle;
const updateWebPageStyle = qqpromote.updateWebPageStyle;
Expand All @@ -17,6 +18,7 @@ let login_time = 3;

async function onLoad() {
const setting_data = await qqpromote.getSettings()
setting_data?.setting.message_merging ? document.body.classList.add('message_merging'):document.body.classList.remove('message_merging')
const plugin_path = LiteLoader.plugins.qqpromote.path.plugin;
const script = document.createElement("script");
script.id = "sweetalert2"
Expand Down Expand Up @@ -122,6 +124,7 @@ async function onSettingWindowCreated(view){
})
}

hookVue3()
onLoad()

export {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/addRepeatMsgMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function addrepeatmsg_menu(qContextMenu, message_element) {
if (setting_data?.setting.chatgpt) {
const chatgpt_msg = chatgpt_ele.cloneNode(true);
chatgpt_msg.addEventListener('click', async () => {
let msg = await chatgpt(content, setting_data.setting)
const msg = await chatgpt(content, setting_data.setting)
if (setting_data?.setting.chatgpt_add_reply) {
await LLAPI.set_editor(msg)
qContextMenu.childNodes.forEach((element) => {
Expand Down
Loading

0 comments on commit 51d3f31

Please sign in to comment.