|
@@ -1,44 +1,70 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <div class="dialog-common-used">
|
|
|
|
|
- <div class="dialog-common-used-item" v-for="item in used_list" :key="item.value" @click="handleClick(item)">
|
|
|
|
|
- <img :src="item.icon" alt="" />
|
|
|
|
|
- <div class="dialog-common-used-item-text">{{ item.value }}</div>
|
|
|
|
|
|
|
+ <div class="dialog-common-tips">
|
|
|
|
|
+ <div class="dialog-common-used" v-if="!current_List_key">
|
|
|
|
|
+ <div
|
|
|
|
|
+ class="dialog-common-used-item"
|
|
|
|
|
+ ref="usedItemRefs"
|
|
|
|
|
+ v-for="item in used_list"
|
|
|
|
|
+ :key="item.value"
|
|
|
|
|
+ @click="handleClick(item)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <img :src="item.icon" alt="" />
|
|
|
|
|
+ <div class="dialog-common-used-item-text">{{ item.value }}</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div v-if="current_List_key" class="dialog-common_search_list" ref="searchListDialog">
|
|
|
|
|
+ <UsedSearchList :current_List_key="current_List_key" @quickSend="toSend"></UsedSearchList>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref } from 'vue';
|
|
|
|
|
|
|
+import { ref, onMounted, onUnmounted, nextTick } from 'vue';
|
|
|
import file_1 from '../../assets/chat/file-1.png';
|
|
import file_1 from '../../assets/chat/file-1.png';
|
|
|
import file_2 from '../../assets/chat/file-2.png';
|
|
import file_2 from '../../assets/chat/file-2.png';
|
|
|
import file_3 from '../../assets/chat/file-3.png';
|
|
import file_3 from '../../assets/chat/file-3.png';
|
|
|
import edit_1 from '../../assets/chat/edit-1.png';
|
|
import edit_1 from '../../assets/chat/edit-1.png';
|
|
|
|
|
+import UsedSearchList from './dialog-common-used/UsedSearchList.vue';
|
|
|
|
|
+
|
|
|
|
|
+const emit = defineEmits(['quickSend']);
|
|
|
|
|
|
|
|
-const emit = defineEmits(['updateAskTxt']);
|
|
|
|
|
const used_list = ref([
|
|
const used_list = ref([
|
|
|
- {
|
|
|
|
|
- value: '总结文本',
|
|
|
|
|
- icon: file_1
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- value: '帮我写',
|
|
|
|
|
- icon: edit_1
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- value: '方案构思',
|
|
|
|
|
- icon: file_2
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- value: '提供建议',
|
|
|
|
|
- icon: file_3
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ { value: '总结文本', icon: file_1, key: 'summary_text' },
|
|
|
|
|
+ { value: '帮我写', icon: edit_1, key: 'help_write' },
|
|
|
|
|
+ { value: '方案构思', icon: file_2, key: 'plan_concept' },
|
|
|
|
|
+ { value: '提供建议', icon: file_3, key: 'provide_suggest' }
|
|
|
]);
|
|
]);
|
|
|
-/**
|
|
|
|
|
- *
|
|
|
|
|
- * */
|
|
|
|
|
|
|
+
|
|
|
|
|
+const current_List_key = ref('');
|
|
|
|
|
+const searchListDialog = ref(null);
|
|
|
|
|
+const usedItemRefs = ref(null);
|
|
|
|
|
+
|
|
|
|
|
+// 点击 usedItem 时赋值并显示 UsedSearchList
|
|
|
const handleClick = (item) => {
|
|
const handleClick = (item) => {
|
|
|
- emit('updateAskTxt', item.value);
|
|
|
|
|
|
|
+ current_List_key.value = item.key;
|
|
|
};
|
|
};
|
|
|
|
|
+const toSend = (text) => {
|
|
|
|
|
+ emit('quickSend', text);
|
|
|
|
|
+};
|
|
|
|
|
+// 全局点击事件处理
|
|
|
|
|
+const handleGlobalClick = (event) => {
|
|
|
|
|
+ // 检查点击是否发生在 searchListDialog 和 usedItemRefs 以外的区域
|
|
|
|
|
+ const clickedOutsideUsedItems = !usedItemRefs.value.some((ref) => ref.contains(event.target));
|
|
|
|
|
+ console.log(clickedOutsideUsedItems);
|
|
|
|
|
+ if (searchListDialog.value && !searchListDialog.value.contains(event.target) && clickedOutsideUsedItems) {
|
|
|
|
|
+ current_List_key.value = ''; // 隐藏 UsedSearchList
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+// 添加全局点击事件监听
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ // 确保 DOM 更新完成后再添加事件监听
|
|
|
|
|
+ // document.addEventListener('click', handleGlobalClick);
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+// 移除全局点击事件监听
|
|
|
|
|
+onUnmounted(() => {
|
|
|
|
|
+ document.removeEventListener('click', handleGlobalClick);
|
|
|
|
|
+});
|
|
|
</script>
|
|
</script>
|
|
|
<style scoped>
|
|
<style scoped>
|
|
|
.dialog-common-used {
|
|
.dialog-common-used {
|