yangyin
2024-11-05 94ef796940807e666b0d82f0ef57b42a3e3b83a9
src/components/chat/components/playBar/PlayBar.vue
@@ -49,8 +49,10 @@
            class="relative align-bottom set-inputAnswer"
            type="textarea"
            resize="none"
            maxlength="1024"
            :autosize="{ minRows: 1, maxRows: 8 }"
            v-elInputFocus
            show-word-limit
            @keydown="keydownInput"
            @input="inputText"
            v-model="inputValue"
@@ -108,7 +110,13 @@
         @updateInputValue="updateInputValue"
         :isHome="isHome"
      />
      <CommonPhrases v-model:isShow="isShowPhrase" v-show="isShowPhrase" :isHome="isHome"/>
      <CommonPhrases
         v-model:isShow="isShowPhrase"
         v-show="isShowPhrase"
         :isHome="isHome"
         ref="commonPhrasesRef"
         @updateCommonChatInput="updateCommonChatInput"
      />
   </div>
</template>
@@ -118,14 +126,23 @@
import { ElMessage } from 'element-plus';
import _ from 'lodash';
import getCaretCoordinates from 'textarea-caret';
import { computed, nextTick, ref } from 'vue';
import { computed, nextTick, ref, toRefs, watch } from 'vue';
import InfoDetail from './InfoDetail.vue';
import CommonPhrases from './phrase/CommonPhrases.vue';
import VoicePage from './voicePage/VoicePage.vue';
import { getMetricsNames, querySimilarityHistory } from '/@/api/ai/chat';
import { activeGroupType, groupTypeList, groupTypeMapIcon } from '/@/stores/chatRoom';
const emits = defineEmits(['sendClick']);
const props = defineProps(['isTalking', 'isHome']);
const emits = defineEmits(['sendClick', 'showUpChatClick', 'showDownChatClick']);
const props = defineProps({
   isTalking: Boolean,
   isHome: Boolean,
   setCommonQuestionInfo: {
      type: Object,
      default: {},
   },
});
const { setCommonQuestionInfo } = toRefs(props);
const voicePageIsShow = defineModel('voicePageIsShow', {
   type: Boolean,
   default: false,
@@ -149,7 +166,9 @@
   if (props.isTalking) return;
   const isEnterInput = !e.shiftKey && e.key == 'Enter';
   const isDigitalInput = e.ctrlKey && e.code.startsWith('Digit') && tipIsShow.value;
   if (isEnterInput || isDigitalInput) {
   const arrowUp = e.key === 'ArrowUp';
   const arrowDown = e.key === 'ArrowDown';
   if (isEnterInput || isDigitalInput || arrowUp || arrowDown) {
      e.cancelBubble = true; //ie阻止冒泡行为
      e.stopPropagation(); //Firefox阻止冒泡行为
      e.preventDefault(); //取消事件的默认动作*换行
@@ -163,6 +182,10 @@
            inputValue.value = mapValue;
            triggerShow.value = false;
         }
      } else if (arrowUp) {
         emits('showUpChatClick');
      } else if (arrowDown) {
         emits('showDownChatClick');
      }
   }
};
@@ -415,11 +438,10 @@
//#region ====================== 当前应用场景 ======================
const currentGroupTypeIsShow = computed(() => !!activeGroupType.value);
const groupTypeClick = (item) => {
   activeGroupType.value = item;
   inputRef.value.focus();
   commonPhrasesRef.value.getCommonPhrases();
};
// 关闭当前 groupType 面板
@@ -429,9 +451,24 @@
//#endregion
//#region ====================== 常用语功能 ======================
const commonPhrasesRef = ref(null);
const commonPhrasesClick = () => {
   isShowPhrase.value = true;
};
const updateCommonChatInput = (val) => {
   inputValue.value = val;
   isShowPhrase.value = false;
};
watch(setCommonQuestionInfo, (val) => {
   if (!props.isHome) {
      let obj = {
         id: val?.historyId,
         question: val?.content.values,
      };
      commonPhrasesRef.value.commonChatByUser(obj);
      isShowPhrase.value = true;
   }
});
//#endregion
</script>
<style scoped lang="scss">