mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-18 03:33:24 +00:00
perf: 再次点击消息图标闪动未读对话
This commit is contained in:
parent
68af686139
commit
405e5aa03a
@ -262,6 +262,9 @@ export default {
|
|||||||
|
|
||||||
case 'dialog':
|
case 'dialog':
|
||||||
location = {name: 'manage-messenger', params: {dialogAction: 'dialog'}};
|
location = {name: 'manage-messenger', params: {dialogAction: 'dialog'}};
|
||||||
|
if (this.routeName === 'manage-messenger') {
|
||||||
|
Store.set('clickAgainDialog', true);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'contacts':
|
case 'contacts':
|
||||||
|
|||||||
@ -160,6 +160,7 @@ import {mapState} from "vuex";
|
|||||||
import DialogWrapper from "./components/DialogWrapper";
|
import DialogWrapper from "./components/DialogWrapper";
|
||||||
import ScrollerY from "../../components/ScrollerY";
|
import ScrollerY from "../../components/ScrollerY";
|
||||||
import longpress from "../../directives/longpress";
|
import longpress from "../../directives/longpress";
|
||||||
|
import {Store} from "le5le-store";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {ScrollerY, DialogWrapper},
|
components: {ScrollerY, DialogWrapper},
|
||||||
@ -191,6 +192,8 @@ export default {
|
|||||||
operateItem: {},
|
operateItem: {},
|
||||||
operateStyles: {},
|
operateStyles: {},
|
||||||
operateVisible: false,
|
operateVisible: false,
|
||||||
|
|
||||||
|
clickAgainSubscribe: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -199,6 +202,16 @@ export default {
|
|||||||
if (id > 0) {
|
if (id > 0) {
|
||||||
this.openDialog(id)
|
this.openDialog(id)
|
||||||
}
|
}
|
||||||
|
this.clickAgainSubscribe = Store.subscribe('clickAgainDialog', this.shakeUnread);
|
||||||
|
},
|
||||||
|
|
||||||
|
beforeDestroy() {
|
||||||
|
if (this.clickAgainSubscribe) {
|
||||||
|
this.clickAgainSubscribe.unsubscribe();
|
||||||
|
this.clickAgainSubscribe = null;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
document.removeEventListener('keydown', this.shortcutEvent);
|
||||||
},
|
},
|
||||||
|
|
||||||
activated() {
|
activated() {
|
||||||
@ -484,22 +497,26 @@ export default {
|
|||||||
}
|
}
|
||||||
if (this.dialogActive == type) {
|
if (this.dialogActive == type) {
|
||||||
// 再次点击滚动到未读条目
|
// 再次点击滚动到未读条目
|
||||||
let index = this.dialogList.findIndex(dialog => $A.getDialogNum(dialog) > 0)
|
this.shakeUnread()
|
||||||
if (index === -1) {
|
|
||||||
index = this.dialogList.findIndex(dialog => $A.getDialogUnread(dialog, true) > 0)
|
|
||||||
}
|
|
||||||
if (index > -1) {
|
|
||||||
const el = this.$refs[`dialog_${this.dialogList[index]?.id}`][0]
|
|
||||||
$A.scrollToView(el, {behavior: "smooth", block, inline: "nearest"})
|
|
||||||
requestAnimationFrame(_ => {
|
|
||||||
$A(el).addClass("common-shake")
|
|
||||||
setTimeout(_ => $A(el).removeClass("common-shake"), 1000)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.dialogActive = type
|
this.dialogActive = type
|
||||||
},
|
},
|
||||||
|
|
||||||
|
shakeUnread() {
|
||||||
|
let index = this.dialogList.findIndex(dialog => $A.getDialogNum(dialog) > 0)
|
||||||
|
if (index === -1) {
|
||||||
|
index = this.dialogList.findIndex(dialog => $A.getDialogUnread(dialog, true) > 0)
|
||||||
|
}
|
||||||
|
if (index > -1) {
|
||||||
|
const el = this.$refs[`dialog_${this.dialogList[index]?.id}`][0]
|
||||||
|
if (el) {
|
||||||
|
$A.scrollIntoViewIfNeeded(el)
|
||||||
|
el.classList.remove("common-shake")
|
||||||
|
requestAnimationFrame(_ => el.classList.add("common-shake"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
dialogClass(dialog) {
|
dialogClass(dialog) {
|
||||||
if (this.dialogKey) {
|
if (this.dialogKey) {
|
||||||
return null
|
return null
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user