ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<script lang="ts" setup>
import { computed, reactive, ref, toRefs } from 'vue';
 
import AiChat from './AiChat.vue';
import Contacts from './Contacts.vue';
import Reply from './Reply.vue';
 
defineOptions({ name: 'ChatModal' });
 
defineProps({
  isTwinkle: { type: Boolean, default: false },
});
 
const emit = defineEmits(['toggleTwinkle']);
 
defineExpose({
  openModal,
  closeModal,
});
 
interface State {
  visible: boolean;
  fullScreen: boolean;
  activeLeftKey: string;
}
 
const tabList = [
  {
    id: '1',
    icon: 'icon-ym icon-ym-ai',
    checkedIcon: 'icon-ym icon-ym-ai',
    fullName: '大迈AI智能助手',
  },
  {
    id: '2',
    icon: 'icon-ym icon-ym-contacts',
    checkedIcon: 'icon-ym icon-ym-contacts-checked',
    fullName: '通讯录',
  },
  {
    id: '3',
    icon: 'icon-ym icon-ym-chat',
    checkedIcon: 'icon-ym icon-ym-chat-checked',
    fullName: '内部聊天',
  },
];
 
const state = reactive<State>({
  visible: false,
  fullScreen: false,
  activeLeftKey: '1',
});
const { visible, activeLeftKey, fullScreen } = toRefs(state);
const replyRef = ref(null);
 
const getModalTitle = computed(() => {
  const index = tabList.findIndex((o) => o.id === state.activeLeftKey);
  return tabList[index]?.fullName;
});
 
function openModal() {
  if (state.visible) return;
  state.fullScreen = false;
  state.activeLeftKey = '1';
  state.visible = true;
}
function closeModal() {
  state.visible = false;
}
function handleFullScreen() {
  state.fullScreen = !state.fullScreen;
}
function toggleTab(id) {
  if (state.activeLeftKey === id) return;
  state.activeLeftKey = id;
}
function toReply(data) {
  state.activeLeftKey = '3';
  (replyRef.value as any)?.addNewChat(data);
}
function toggleTwinkle(boo) {
  emit('toggleTwinkle', boo);
}
</script>
<template>
  <div class="jnpf-chat-modal" :class="{ 'jnpf-chat-modal-fullScreen': fullScreen }" v-if="visible">
    <div class="chat-modal-left-pane">
      <div class="chat-tabs">
        <div
          class="chat-tab-item"
          v-for="item in tabList"
          :key="item.id"
          :class="{ 'chat-tab-item__active': activeLeftKey === item.id }"
          @click="toggleTab(item.id)">
          <i :class="item.checkedIcon" v-if="activeLeftKey === item.id"></i>
          <i :class="item.icon" v-else></i>
        </div>
      </div>
    </div>
    <div class="chat-modal-center-pane">
      <div class="chat-modal-center-pane__header">
        <div class="chat-header-title">{{ getModalTitle }}</div>
        <div class="chat-header-actions">
          <a-tooltip title="缩小" :z-index="1000000" v-if="fullScreen">
            <i class="icon-ym icon-ym-reduce chat-header-actions-item" @click="handleFullScreen"></i>
          </a-tooltip>
          <a-tooltip title="放大" :z-index="1000000" v-else>
            <i class="icon-ym icon-ym-enlarge chat-header-actions-item" @click="handleFullScreen"></i>
          </a-tooltip>
          <a-tooltip title="关闭" :z-index="1000000">
            <i class="icon-ym icon-ym-fail chat-header-actions-item" @click="closeModal"></i>
          </a-tooltip>
        </div>
      </div>
      <div class="chat-modal-center-pane__main">
        <AiChat v-show="activeLeftKey === '1'" />
        <Contacts v-show="activeLeftKey === '2'" @to-reply="toReply" />
        <Reply ref="replyRef" @toggle-twinkle="toggleTwinkle" v-show="activeLeftKey === '3'" />
      </div>
    </div>
  </div>
</template>
<style lang="scss">
@use './style/index.scss' as *;
</style>