mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 20:12:48 +00:00
feat: 优化对话搜索时的选择状态管理
This commit is contained in:
parent
e226f444f7
commit
0fb66358cc
@ -79,11 +79,7 @@
|
|||||||
:data-id="dialog.id"
|
:data-id="dialog.id"
|
||||||
data-type="dialog"
|
data-type="dialog"
|
||||||
:class="dialogClass(dialog)"
|
:class="dialogClass(dialog)"
|
||||||
@click="openDialog({
|
@click="handleDialogSelect(dialog)"
|
||||||
dialog_id: dialog.id,
|
|
||||||
dialog_msg_id: dialog.search_msg_id,
|
|
||||||
search_msg_id: dialog.search_msg_id,
|
|
||||||
})"
|
|
||||||
@pointerdown="handleOperation"
|
@pointerdown="handleOperation"
|
||||||
:style="{'background-color':dialog.color}">
|
:style="{'background-color':dialog.color}">
|
||||||
<template v-if="dialog.type=='group'">
|
<template v-if="dialog.type=='group'">
|
||||||
@ -310,6 +306,7 @@ export default {
|
|||||||
dialogSearchLoad: 0,
|
dialogSearchLoad: 0,
|
||||||
dialogSearchKey: '',
|
dialogSearchKey: '',
|
||||||
dialogSearchList: [],
|
dialogSearchList: [],
|
||||||
|
dialogSearchSelectedParams: null,
|
||||||
|
|
||||||
dialogActive: '',
|
dialogActive: '',
|
||||||
dialogMenus: navDatas.menus,
|
dialogMenus: navDatas.menus,
|
||||||
@ -582,6 +579,7 @@ export default {
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
this.dialogSearchList = [];
|
this.dialogSearchList = [];
|
||||||
|
this.dialogSearchSelectedParams = null;
|
||||||
if (val == '') {
|
if (val == '') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -620,6 +618,7 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.updateContactsList(1000);
|
this.updateContactsList(1000);
|
||||||
}
|
}
|
||||||
|
this.dialogSearchSelectedParams = null;
|
||||||
} else {
|
} else {
|
||||||
this.updateDialogs(1000);
|
this.updateDialogs(1000);
|
||||||
this.scrollToNav();
|
this.scrollToNav();
|
||||||
@ -639,6 +638,7 @@ export default {
|
|||||||
|
|
||||||
dialogActive(active) {
|
dialogActive(active) {
|
||||||
this.dialogSearchList = [];
|
this.dialogSearchList = [];
|
||||||
|
this.dialogSearchSelectedParams = null;
|
||||||
if (active == 'mark' && !this.dialogSearchKey) {
|
if (active == 'mark' && !this.dialogSearchKey) {
|
||||||
this.searchTagDialog()
|
this.searchTagDialog()
|
||||||
}
|
}
|
||||||
@ -729,17 +729,39 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
dialogClass(dialog) {
|
dialogClass(dialog) {
|
||||||
if (this.dialogSearchKey) {
|
const selected = this.dialogSearchSelectedParams;
|
||||||
return null
|
const hasSearchSelection = !!selected && (!!this.dialogSearchKey || dialog.is_search);
|
||||||
}
|
const selectedMsgId = selected ? (typeof selected.search_msg_id === 'undefined' ? null : selected.search_msg_id) : null;
|
||||||
|
const dialogSearchMsgId = typeof dialog.search_msg_id === 'undefined' ? null : dialog.search_msg_id;
|
||||||
|
const matchesSelection = hasSearchSelection && dialog.id == selected.dialog_id && dialogSearchMsgId == selectedMsgId;
|
||||||
|
const openedSelection = matchesSelection && this.dialogId == selected.dialog_id && (selectedMsgId == null || this.dialogMsgId == selectedMsgId);
|
||||||
return {
|
return {
|
||||||
top: dialog.top_at,
|
top: !this.dialogSearchKey && dialog.top_at,
|
||||||
active: dialog.id == this.dialogId && (dialog.search_msg_id == this.dialogMsgId || !this.dialogMsgId),
|
active: hasSearchSelection ? openedSelection : dialog.id == this.dialogId && (dialog.search_msg_id == this.dialogMsgId || !this.dialogMsgId || dialog.is_search),
|
||||||
operate: this.operateVisible && this.operateType === 'dialog' && dialog.id == this.operateItem.id,
|
operate: !this.dialogSearchKey && this.operateVisible && this.operateType === 'dialog' && dialog.id == this.operateItem.id,
|
||||||
completed: $A.dialogCompleted(dialog)
|
completed: $A.dialogCompleted(dialog)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleDialogSelect(dialog) {
|
||||||
|
if (this.operateVisible) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.dialogSearchKey || dialog.is_search) {
|
||||||
|
this.dialogSearchSelectedParams = {
|
||||||
|
dialog_id: dialog.id,
|
||||||
|
search_msg_id: typeof dialog.search_msg_id === 'undefined' ? null : dialog.search_msg_id,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.dialogSearchSelectedParams = null
|
||||||
|
}
|
||||||
|
this.openDialog({
|
||||||
|
dialog_id: dialog.id,
|
||||||
|
dialog_msg_id: dialog.search_msg_id,
|
||||||
|
search_msg_id: dialog.search_msg_id,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
dialogSort(a, b) {
|
dialogSort(a, b) {
|
||||||
// 根据置顶时间排序
|
// 根据置顶时间排序
|
||||||
if (a.top_at || b.top_at) {
|
if (a.top_at || b.top_at) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user