From 88cbb782d634f91b79da6506b7cec1b8142cdbb2 Mon Sep 17 00:00:00 2001 From: stapxs <1007028430.stapx@gmail.com> Date: Fri, 23 Aug 2024 18:30:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=AF=20BUG=20=E6=80=BB=E4=BC=9A=E8=A2=AB?= =?UTF-8?q?=E4=BF=AE=E6=8E=89=E7=9A=84.png=20:art:=20=E4=BC=98=E5=8C=96=20?= =?UTF-8?q?options=20=E4=BF=9D=E5=AD=98=E8=AF=BB=E5=8F=96=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=AF=B9=20object=20=E7=9A=84=E5=A4=84=E7=90=86=20:bu?= =?UTF-8?q?g:=20=E6=B7=BB=E5=8A=A0=E5=95=86=E5=9F=8E=E8=A1=A8=E6=83=85?= =?UTF-8?q?=E5=90=8E=E5=88=97=E8=A1=A8=E6=9C=AA=E8=A2=AB=E5=88=B7=E6=96=B0?= =?UTF-8?q?=20:bug:=20=E5=90=8E=E7=AB=AF=E8=BF=9E=E6=8E=A5=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E5=89=8D=E7=AB=AF=E5=88=B7=E6=96=B0=E5=90=8E?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E9=87=8D=E8=BF=9E=20:bug:?= =?UTF-8?q?=20=E6=B6=88=E6=81=AF=E8=8F=9C=E5=8D=95=E5=9C=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=9B=9E=E5=BA=94=E5=8A=9F=E8=83=BD=E5=90=8E=E5=8F=B3?= =?UTF-8?q?=E4=BE=A7=E5=87=BA=E7=95=8C=E5=88=A4=E6=96=AD=E9=94=99=E8=AF=AF?= =?UTF-8?q?=EF=BC=8C=E7=94=B1=20b1c880b=20=E6=8D=9F=E5=9D=8F=20:bug:=20?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=88=97=E8=A1=A8=E5=8F=B3=E5=87=BB=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E5=BA=95=E9=83=A8=E5=87=BA=E7=95=8C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/assets/css/view.css | 2 +- src/components/FacePan.vue | 8 ++++++-- src/function/electron/connector.ts | 5 +++++ src/function/option.ts | 13 +++++-------- src/pages/Chat.vue | 21 ++++++++++++--------- src/pages/Messages.vue | 22 ++++++++++++++++++++++ 7 files changed, 52 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 964c0171..a6db6136 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "serve": "vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint", + "clear": "rm -rf dist && rm -rf dist_electron", "lint:fix": "vue-cli-service lint --fix", "electron:build": "vue-cli-service electron:build", "electron:serve": "vue-cli-service electron:serve", diff --git a/src/assets/css/view.css b/src/assets/css/view.css index 9eb2c255..55495ce7 100644 --- a/src/assets/css/view.css +++ b/src/assets/css/view.css @@ -505,7 +505,7 @@ textarea:focus { padding: 10px; } .msg-menu-body.topOut { - transition: transform .1s, margin-top .1s; + transition: transform .1s, margin-top .2s; } .msg-menu-body.show { transform: scaleY(1); diff --git a/src/components/FacePan.vue b/src/components/FacePan.vue index 5a9d8387..50fa1088 100644 --- a/src/components/FacePan.vue +++ b/src/components/FacePan.vue @@ -84,13 +84,13 @@ export default defineComponent({ }, getStoreFaceList() { - this.storeFace = JSON.parse(decodeURIComponent(Option.getRaw('store_face') || '[]')) + this.storeFace = Option.get('store_face') ?? [] }, removeMface(data: any) { const index = this.storeFace.findIndex((face) => face.emoji_id === data.emoji_id) if (index !== -1) { this.storeFace.splice(index, 1) - Option.save('store_face', JSON.stringify(this.storeFace)) + Option.save('store_face', this.storeFace) } } }, @@ -104,6 +104,10 @@ export default defineComponent({ } } this.getStoreFaceList() + // 监听表情商店列表 + this.$watch(() => runtimeData.sysConfig.store_face.length, () => { + this.getStoreFaceList() + }) } }) diff --git a/src/function/electron/connector.ts b/src/function/electron/connector.ts index 7ab9f7a8..b3ded329 100644 --- a/src/function/electron/connector.ts +++ b/src/function/electron/connector.ts @@ -37,6 +37,11 @@ export class Connector { if(!this.websocket) { this.logger.info('正在连接到:', url) this.websocket = new WebSocket(url + '?access_token=' + token) + } else { + // 如果前端发起了连接请求,说明前端在未连接状态;断开已有连接,重新连接 + // PS:这种情况一般不会发生,大部分情况是因为 debug 模式前端热重载导致的 + this.websocket.close(1000) + this.connect(url, token) } this.websocket.onopen = () => { diff --git a/src/function/option.ts b/src/function/option.ts index 8cd7d1f5..367db13c 100644 --- a/src/function/option.ts +++ b/src/function/option.ts @@ -318,16 +318,13 @@ function loadOptData(data: { [key: string]: any }) { options[key] = value === 'true' } else if (value === 'null') { options[key] = null - } else if (key == 'top_info') { - // 特殊处理 top_info - try { - options[key] = JSON.parse(decodeURIComponent(value)) - } catch (e) { - // 无法解析的数据,初始化为空对象 - options[key] = {} - } } else if(typeof value == 'string') { options[key] = decodeURIComponent(value) + try { + options[key] = JSON.parse(options[key]) + } catch(e: unknown) { + // + } } else { options[key] = value } diff --git a/src/pages/Chat.vue b/src/pages/Chat.vue index f0862c11..6f5d3a07 100644 --- a/src/pages/Chat.vue +++ b/src/pages/Chat.vue @@ -129,7 +129,7 @@
- {{ selectedMsg === null ? '' : (selectedMsg.sender.nickname + ': ' + (selectedMsg.raw_message ?? fun.getMsgRawTxt(selectedMsg.message))) + {{ selectedMsg === null ? '' : (selectedMsg.sender.nickname + ': ' + fun.getMsgRawTxt(selectedMsg.message)) }}
@@ -799,10 +799,15 @@ export default defineComponent({ menu.style.marginLeft = pointX + 'px' menu.style.marginTop = pointY + 'px' // 出界判定 - const menuWidth = menu.clientWidth + let menuWidth = menu.clientWidth + if(this.tags.menuDisplay.showRespond) { + // 如果有回应功能,获取回应功能的宽度;它比菜单长 + const item = menu.children[0] as HTMLDivElement + menuWidth = item.clientWidth + } const msgWidth = msg.offsetWidth if (pointX + menuWidth > msgWidth + 27) { - menu.style.marginLeft = (msgWidth + 27 - menuWidth) + 'px' + menu.style.marginLeft = (msgWidth + 7 - menuWidth) + 'px' } // 显示菜单 this.tags.showMsgMenu = true @@ -811,12 +816,11 @@ export default defineComponent({ // 出界判定 const menuHeight = menu.clientHeight const bodyHeight = document.body.clientHeight - if (pointY + menuHeight > bodyHeight + 10) { + if (pointY + menuHeight > bodyHeight - 20) { menu.classList.add('topOut') menu.style.marginTop = (bodyHeight - menuHeight - 10) + 'px' - // menu.classList.remove('topOut') } - }, 90) + }, 100) // 设置消息背景 this.tags.openedMenuMsg = msg msg.style.background = '#00000008' @@ -971,8 +975,7 @@ export default defineComponent({ const msg = this.selectedMsg if (msg !== null) { const mface = msg.message[0] - const storeFace = option.get('store_face') ?? '[]' - const storeFaceList = JSON.parse(storeFace) + const storeFaceList = option.get('store_face') ?? [] const face = storeFaceList.find((item: any) => { return item.emoji_package_id == mface.emoji_package_id && item.emoji_id == mface.emoji_id @@ -981,7 +984,7 @@ export default defineComponent({ popInfo.add(PopType.INFO, this.$t('pop_chat_msg_menu_store_face_exist')) } else { storeFaceList.push(mface) - option.save('store_face', JSON.stringify(storeFaceList)) + option.save('store_face', storeFaceList) popInfo.add(PopType.INFO, this.$t('pop_chat_msg_menu_store_face_success')) } } diff --git a/src/pages/Messages.vue b/src/pages/Messages.vue index 34c5eb15..535a801c 100644 --- a/src/pages/Messages.vue +++ b/src/pages/Messages.vue @@ -212,6 +212,12 @@ export default defineComponent({ * @param id 选择的菜单 ID */ listMenuClose(id: string) { + const menu = document.getElementById('msg-menu-view-messages-menu')?.children[1] as HTMLDivElement + if(menu) { + setTimeout(() => { + menu.style.transition = 'transform .1s' + }, 200) + } this.listMenu.show = false const item = this.menu.select if(id) { @@ -345,6 +351,22 @@ export default defineComponent({ } this.listMenu = info this.menu.select = item + // 出界处理 + setTimeout(() => { + const menu = document.getElementById('msg-menu-view-messages-menu')?.children[1] as HTMLDivElement + if(menu) { + menu.style.transition = 'margin .2s, transform .1s' + const hight = menu.clientHeight + const top = menu.getBoundingClientRect().top + const docHight = document.documentElement.clientHeight + // 出界高度 + const dtHight = ( hight + top ) - docHight + 20 + if(dtHight > 0) { + menu.style.marginTop = (docHight - hight - 30) + 'px' + } + + } + }, 100) }, showMenuStart(event: TouchEvent, item: (UserFriendElem & UserGroupElem)) {