核工业西南物理研究院知识库AI客户端
xiangpei
2025-03-28 3c5470a29757afee973e652edddc35bfdd64d1ed
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<template>
  <div class="index">
    <div class="common-op">
      <el-dropdown @command="handleCommand" trigger="click">
        <span class="el-dropdown-link">
          张三<i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="a">退出登录</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
    <div class="left">
      <div class="logo">
        <img style="width: 60px;height: 60px" src="@/assets/img/logo.png"/>
      </div>
      <div class="menu">
        <div class="add-chat">
          <i class="el-icon-plus"/>新建对话
        </div>
        <div :class="{tab: true, activeTab: this.$router.currentRoute.path == '/knowledge'}" style="margin-top: 2px" @click="changeTab()">
          <svg t="1743057471863" class="icon" viewBox="0 0 1029 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3047" width="16" height="16">
            <path fill="grey" d="M32.2592 294.4l409.6 211.2c19.2 12.8 44.8 12.8 70.4 12.8s51.2-6.4 70.4-12.8l409.6-211.2c38.4-19.2 38.4-51.2 0-70.4l-409.6-211.2c-19.2-6.4-44.8-12.8-70.4-12.8s-51.2 6.4-70.4 12.8l-409.6 211.2c-38.4 19.2-38.4 51.2 0 70.4z m441.6-204.8c12.8-6.4 25.6-6.4 38.4-6.4s32 6.4 38.4 6.4l339.2 172.8-339.2 172.8c-6.4 6.4-19.2 6.4-38.4 6.4-12.8 0-32-6.4-38.4-6.4l-339.2-172.8 339.2-172.8z" p-id="3048"></path>
            <path fill="grey" d="M19.4592 550.4l403.2 204.8c25.6 12.8 57.6 19.2 89.6 19.2s64-6.4 89.6-19.2l403.2-204.8c12.8-6.4 25.6-32 12.8-51.2s-32-32-51.2-19.2l-403.2 204.8c-32 12.8-83.2 12.8-108.8 0l-403.2-204.8c-12.8-12.8-25.6-12.8-38.4 0-6.4 12.8-12.8 25.6-12.8 38.4 0 19.2 6.4 25.6 19.2 32z" p-id="3049"></path>
            <path fill="grey" d="M1024.2592 748.8c-12.8-19.2-32-32-51.2-19.2l-403.2 204.8c-32 12.8-83.2 12.8-108.8 0l-403.2-204.8c-12.8-6.4-38.4 6.4-51.2 19.2-12.8 12.8-6.4 38.4 12.8 51.2l403.2 204.8c25.6 12.8 57.6 19.2 89.6 19.2s64-6.4 96-19.2l403.2-204.8c12.8-6.4 25.6-32 12.8-51.2z" p-id="3050"></path></svg>
          <span style="margin-left: 8px">知识库管理</span>
        </div>
      </div>
      <div class="session-list">
        <div :class="{session: true, 'active-session': currentSession == index}" v-for="(session, index) in sessionList" :key="'session' + index">
          <div style="width: 100%"  @mouseenter="activeSession = index" @mouseleave="activeSession = null">
            <div @click="sessionChange(session, index)">{{session.name}}</div>
            <div v-show="activeSession != null && activeSession == index" class="session-more">
              <el-dropdown @command="(command) => handleCommand(session, command)" trigger="click">
              <span class="el-dropdown-link">
                <svg t="1743058876802" class="icon more" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2795" width="12" height="12">
                  <path fill="gray" d="M480 320C533.184 320 576 277.184 576 224S533.184 128 480 128 384 170.816 384 224 426.816 320 480 320zM480 448C426.816 448 384 490.816 384 544S426.816 640 480 640 576 597.184 576 544 533.184 448 480 448zM480 768c-53.184 0-96 42.816-96 96S426.816 960 480 960 576 917.184 576 864c0-52.672-42.816-96-96-96z" p-id="2796"></path></svg>
              </span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item command="config">会话设置</el-dropdown-item>
                  <el-dropdown-item command="rename">重命名</el-dropdown-item>
                  <el-dropdown-item command="del">删除</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </div>
          </div>
        </div>
      </div>
<!--      <div class="setting">-->
<!--        <el-tabs v-model="activeSetting" @tab-click="tabSelect">-->
<!--          <el-tab-pane label="工具设置" name="util">-->
<!--            <div style="display: flex; align-items: center">-->
<!--              <el-checkbox v-model="enableAgent">启用Agent</el-checkbox>-->
<!--              <el-tooltip style="margin-left: 10px" content="Top center" placement="right" effect="light">-->
<!--                <svg t="1742971974478" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2969" width="16" height="16"><path d="M464 784.352c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" p-id="2970" fill="#515151"></path><path d="M512 960C264.96 960 64 759.04 64 512S264.96 64 512 64s448 200.96 448 448-200.96 448-448 448z m0-831.713c-211.584 0-383.713 172.129-383.713 383.713 0 211.552 172.129 383.713 383.713 383.713 211.552 0 383.713-172.16 383.713-383.713 0-211.584-172.161-383.713-383.713-383.713z" p-id="2971" fill="#515151"></path><path d="M512 673.695c-17.665 0-32-14.336-32-31.999v-54.112c0-52.353 39.999-92.352 75.327-127.648 25.887-25.92 52.672-52.672 52.672-74.016 0-53.344-43.072-96.736-95.999-96.736-53.823 0-96 41.536-96 94.56 0 17.664-14.335 31.999-32 31.999s-32-14.336-32-32c0-87.423 71.774-158.559 160-158.559S672 297.28 672 385.92c0 47.904-36.32 84.191-71.424 119.296-27.84 27.776-56.575 56.512-56.575 82.335v54.112c0 17.665-14.336 32.032-32.001 32.032z" p-id="2972" fill="#515151"></path></svg>-->
<!--              </el-tooltip>-->
<!--            </div>-->
<!--            <div style="margin-top: 15px">-->
<!--              <div class="normal-text">选择工具</div>-->
<!--              <div style="margin-top: 5px">-->
<!--                <el-select v-model="selectUtil" size="mini" placeholder="未选择" style="width: 100%">-->
<!--                  <el-option-->
<!--                      v-for="item in options"-->
<!--                      :key="item.value"-->
<!--                      :label="item.label"-->
<!--                      :value="item.value">-->
<!--                  </el-option>-->
<!--                </el-select>-->
<!--              </div>-->
<!--            </div>-->
<!--            <div style="margin-top: 15px">-->
<!--              <div class="normal-text" style="display: flex;align-items: center">-->
<!--                <div>上传附件</div>-->
<!--                <el-tooltip style="margin-left: 10px" content="单个文件不超过200M" placement="right" effect="light">-->
<!--                  <svg t="1742971974478" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2969" width="16" height="16"><path d="M464 784.352c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" p-id="2970" fill="#515151"></path><path d="M512 960C264.96 960 64 759.04 64 512S264.96 64 512 64s448 200.96 448 448-200.96 448-448 448z m0-831.713c-211.584 0-383.713 172.129-383.713 383.713 0 211.552 172.129 383.713 383.713 383.713 211.552 0 383.713-172.16 383.713-383.713 0-211.584-172.161-383.713-383.713-383.713z" p-id="2971" fill="#515151"></path><path d="M512 673.695c-17.665 0-32-14.336-32-31.999v-54.112c0-52.353 39.999-92.352 75.327-127.648 25.887-25.92 52.672-52.672 52.672-74.016 0-53.344-43.072-96.736-95.999-96.736-53.823 0-96 41.536-96 94.56 0 17.664-14.335 31.999-32 31.999s-32-14.336-32-32c0-87.423 71.774-158.559 160-158.559S672 297.28 672 385.92c0 47.904-36.32 84.191-71.424 119.296-27.84 27.776-56.575 56.512-56.575 82.335v54.112c0 17.665-14.336 32.032-32.001 32.032z" p-id="2972" fill="#515151"></path></svg>-->
<!--                </el-tooltip>-->
<!--              </div>-->
<!--              <div style="margin-top: 5px">-->
<!--                <el-upload-->
<!--                    class="upload"-->
<!--                    drag-->
<!--                    :on-change="handleChange"-->
<!--                    :before-upload="handleUpload"-->
<!--                    :file-list="fileList"-->
<!--                    multiple>-->
<!--                  <i class="el-icon-upload"></i>-->
<!--                  <div class="el-upload__text">-->
<!--                    <div>将文件拖到此处,或<em>点击上传</em></div>-->
<!--                  </div>-->
<!--                </el-upload>-->
<!--              </div>-->
<!--            </div>-->
<!--          </el-tab-pane>-->
<!--          <el-tab-pane label="会话设置" name="session"></el-tab-pane>-->
<!--        </el-tabs>-->
<!--      </div>-->
    </div>
    <div class="right">
      <router-view></router-view>
    </div>
    <session-config :session-name="sessionName" @saveConfig="saveConfig" ref="sessionConfig" />
 
    <el-dialog
        :title="'重命名对话'"
        :visible.sync="renameShow"
        :close-on-click-modal="false"
        :destroy-on-close="true"
        width="600px"
    >
        <el-input v-model="rename"/>
      <span slot="footer" class="dialog-footer">
          <el-button @click="renameSubmit" size="medium">确定</el-button>
        </span>
    </el-dialog>
    <login/>
  </div>
</template>
 
<script>
import SessionConfig from "@/components/SessionConfig";
import Login from "@/components/Login";
 
export default {
  name: "IndexView",
  components: {
    SessionConfig, Login
  },
  data() {
    return {
      renameShow: false,
      rename: '',
      sessionName: '',
      config: {
        chatType: 'kb',
        kb: 'kb1',
        hisChatNum: 3,
        matchKbNum: 3,
        matchKbScore: 1,
        returnMatchResult: false
      },
      sessionList: [
        {
          name: '会话1'
        },
        {
          name: '会话2'
        },
        {
          name: '会话3'
        },
      ],
      fileList: [],
      activeSession: null,
      currentSession: null,
      activeSetting: 'util',
      enableAgent: false,
      selectUtil: null,
      options: [{
        value: '选项1',
        label: '黄金糕'
      }, {
        value: '选项2',
        label: '双皮奶'
      }, {
        value: '选项3',
        label: '蚵仔煎'
      }, {
        value: '选项4',
        label: '龙须面'
      }, {
        value: '选项5',
        label: '北京烤鸭'
      }],
    }
  },
  mounted() {
 
  },
  methods: {
    sessionChange(session, index) {
      console.log("触发了吗")
      this.currentSession = index
      if (this.$router.currentRoute.path !== "/chat") {
        this.$router.push("/chat")
      }
    },
    renameSubmit() {
      // TODO 保存到对话中
      this.renameShow = false
      this.$message({
        type: 'success',
        message: '对话名称已修改'
      });
    },
    saveConfig(config) {
      // TODO 保存到对话中
      console.log(config, "父组件获取到配置了")
    },
    handleCommand(session, command) {
      console.log(session, command)
      if (command === 'config') {
        this.sessionName = session.name
        this.$refs.sessionConfig.setConfig(this.config)
        this.$refs.sessionConfig.setShow(true)
      } else if (command === 'rename') {
        this.rename = session.name
        this.renameShow = true
      } else if (command === 'del') {
        this.$alert(`确认要删除对话【${session.name}】吗?`, '删除提醒', {
          confirmButtonText: '确定',
          callback: action => {
            if (action == 'confirm') {
              // TODO 删除
              this.$message({
                type: 'success',
                message: '成功删除对话'
              });
            } else {
              this.$message({
                type: 'info',
                message: '已取消删除'
              });
            }
          }
        });
      }
    },
    handleUpload(file) {
      if (this.fileList.indexOf(file) === -1) {
        this.fileList.push(file)
      }
      return false
    },
    handleChange(file, fileList) {
      this.fileList = fileList;
    },
    tabSelect(tab, event) {
      console.log(tab, event)
    },
    changeTab() {
      if (this.$router.currentRoute.path !== "/knowledge") {
        this.$router.push("/knowledge")
      }
    },
  }
}
</script>
 
<style scoped>
.index {
  display: flex;
  position: relative;
}
.left {
  width: 250px;
  min-height: calc(100vh - 20px);
  height: calc(100vh);
  background-color: #f3f3f3;
  padding: 0px 40px;
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}
.right {
  width: 1600px;
}
.logo {
  width: 100%;
  height: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.menu {
  height: 150px;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-bottom: 1px solid lightgray;
}
.add-chat {
  width: 100%;
  height: 40px;
  line-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: white;
  border-radius: 8px;
  margin-top: 15px;
  margin-bottom: 15px;
  user-select: none;
  box-sizing: border-box;
}
.add-chat:hover {
  cursor: pointer;
  border: 1px solid lightgray;
}
.tab {
  width: 100%;
  line-height: 30px;
  padding-left: 16px;
  display: flex;
  justify-content: flex-start;
  border-radius: 8px;
  align-items: center;
  box-sizing: border-box;
}
.activeTab {
  background-color: #dcdcdc;
}
.tab:hover {
  cursor: pointer;
  background-color: #dcdcdc;
}
.session-list {
  margin-top: 20px;
  width: 100%;
}
.session {
  width: 100%;
  display: flex;
  height: 30px;
  line-height: 30px;
  align-items: center;
  border-radius: 8px;
  padding: 10px 10px;
  box-sizing: border-box;
  position: relative;
  margin-bottom: 4px;
}
.active-session {
  background-color: #dcdcdc;
}
.session:hover {
  background-color: #dcdcdc;
}
.session-more {
  position: absolute;
  right: 8px;
  top: 2px;
}
.more {
  width: 20px;
  height: 25px;
  display: flex;
  align-items: center;
}
.more:hover {
  border-radius: 50%;
  cursor: pointer;
  background-color: #e8e8e8;
}
.common-op {
  position: absolute;
  top: 20px;
  right: 50px;
}
.setting {
  margin-top: 20px;
}
.normal-text {
  color: #606266;
  font-size: 12px;
}
::v-deep(.el-upload-dragger) {
  width: 250px !important;
}
::v-deep(.el-dialog) {
  border-radius: 16px!important;
}
</style>