refactor(历史记录): 实现侧滑互斥:打开新项自动收起旧项
This commit is contained in:
parent
59d492dfb9
commit
909cf26549
|
|
@ -52,7 +52,7 @@
|
||||||
<view class="date-header">{{ group.id }}</view>
|
<view class="date-header">{{ group.id }}</view>
|
||||||
|
|
||||||
<view v-for="item in group.conversation" :key="item.id">
|
<view v-for="item in group.conversation" :key="item.id">
|
||||||
<uni-swipe-action ref="swipeActionRef">
|
<uni-swipe-action :ref="'swipe-' + item.id">
|
||||||
<uni-swipe-action-item
|
<uni-swipe-action-item
|
||||||
:disabled="isBatchDeleteMode"
|
:disabled="isBatchDeleteMode"
|
||||||
:threshold="0.3"
|
:threshold="0.3"
|
||||||
|
|
@ -123,7 +123,10 @@
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 批量删除操作栏 -->
|
<!-- 批量删除操作栏 -->
|
||||||
<view class="batch-actions" v-if="isBatchDeleteMode && currentHistoryItems.length">
|
<view
|
||||||
|
class="batch-actions"
|
||||||
|
v-if="isBatchDeleteMode && currentHistoryItems.length"
|
||||||
|
>
|
||||||
<view class="select-all-container" @click="toggleSelectAll">
|
<view class="select-all-container" @click="toggleSelectAll">
|
||||||
<view class="checkbox" :class="{ checked: selectAll }">
|
<view class="checkbox" :class="{ checked: selectAll }">
|
||||||
<text class="checkmark" v-if="selectAll">✓</text>
|
<text class="checkmark" v-if="selectAll">✓</text>
|
||||||
|
|
@ -164,6 +167,7 @@ export default {
|
||||||
chatHistoryAI: [], // ai咨询历史记录
|
chatHistoryAI: [], // ai咨询历史记录
|
||||||
chatHistoryTeacher: [], // 人工咨询历史记录
|
chatHistoryTeacher: [], // 人工咨询历史记录
|
||||||
openedItems: {}, // 记录每个项目的滑动状态
|
openedItems: {}, // 记录每个项目的滑动状态
|
||||||
|
openedSwipeId: "", // 当前展开的侧滑项 id
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -207,16 +211,9 @@ export default {
|
||||||
|
|
||||||
// 重置滑动状态
|
// 重置滑动状态
|
||||||
closeAllSwipeActions() {
|
closeAllSwipeActions() {
|
||||||
const swipeActionRefs = this.$refs.swipeActionRef || [];
|
const ids = this.currentHistoryItemIds || [];
|
||||||
const refs = Array.isArray(swipeActionRefs)
|
ids.forEach((id) => this.closeSwipeActionById(id));
|
||||||
? swipeActionRefs
|
this.openedSwipeId = "";
|
||||||
: [swipeActionRefs];
|
|
||||||
|
|
||||||
refs.forEach((ref) => {
|
|
||||||
if (ref && typeof ref.closeAll === "function") {
|
|
||||||
ref.closeAll();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 清空 openedItems 并调用 closeAllSwipeActions()
|
// 清空 openedItems 并调用 closeAllSwipeActions()
|
||||||
|
|
@ -225,6 +222,16 @@ export default {
|
||||||
this.closeAllSwipeActions();
|
this.closeAllSwipeActions();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
closeSwipeActionById(itemId) {
|
||||||
|
if (!itemId) return;
|
||||||
|
const swipeRef = this.$refs[`swipe-${itemId}`];
|
||||||
|
const ref = Array.isArray(swipeRef) ? swipeRef[0] : swipeRef;
|
||||||
|
if (ref && typeof ref.closeAll === "function") {
|
||||||
|
ref.closeAll();
|
||||||
|
}
|
||||||
|
this.$set(this.openedItems, itemId, "none");
|
||||||
|
},
|
||||||
|
|
||||||
// 获取ai历史记录
|
// 获取ai历史记录
|
||||||
async getChatHistoryList() {
|
async getChatHistoryList() {
|
||||||
this.$u.api.GetConversationPage().then((res) => {
|
this.$u.api.GetConversationPage().then((res) => {
|
||||||
|
|
@ -465,6 +472,16 @@ export default {
|
||||||
// 处理滑动操作变化
|
// 处理滑动操作变化
|
||||||
handleSwipeChange(e, itemId) {
|
handleSwipeChange(e, itemId) {
|
||||||
this.$set(this.openedItems, itemId, e);
|
this.$set(this.openedItems, itemId, e);
|
||||||
|
if (e === "right" || e === "left") {
|
||||||
|
if (this.openedSwipeId && this.openedSwipeId !== itemId) {
|
||||||
|
this.closeSwipeActionById(this.openedSwipeId);
|
||||||
|
}
|
||||||
|
this.openedSwipeId = itemId;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e === "none" && this.openedSwipeId === itemId) {
|
||||||
|
this.openedSwipeId = "";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 处理单个删除操作
|
// 处理单个删除操作
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue