|
@@ -17,18 +17,6 @@
|
|
|
<div class="text-xl font-bold text-[#303133]" v-title>
|
|
|
{{ state.detail.name }}
|
|
|
</div>
|
|
|
- <!-- <el-tooltip-->
|
|
|
- <!-- :content="false ? '取消收藏' : '收藏'"-->
|
|
|
- <!-- effect="light"-->
|
|
|
- <!-- placement="top"-->
|
|
|
- <!-- >-->
|
|
|
- <!-- <SvgIcon-->
|
|
|
- <!-- name="star"-->
|
|
|
- <!-- size="20"-->
|
|
|
- <!-- class="__hover ml-auto"-->
|
|
|
- <!-- :active="false"-->
|
|
|
- <!-- />-->
|
|
|
- <!-- </el-tooltip>-->
|
|
|
</div>
|
|
|
<div class="flex gap-2 text-sm text-[#606266]">
|
|
|
<div>{{ state.detail.creatorName }}</div>
|
|
@@ -51,11 +39,8 @@
|
|
|
<SvgIcon name="clean" class="mr-1" />清除记录
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div
|
|
|
- class="mt-4 mr-2 flex flex-1 flex-col gap-4 overflow-y-auto pr-2"
|
|
|
- v-loading="state.history.loading"
|
|
|
- >
|
|
|
- <template v-for="(item, index) in state.history.data">
|
|
|
+ <div class="mt-4 mr-2 flex flex-1 flex-col gap-4 overflow-y-auto pr-2">
|
|
|
+ <template v-for="(item, index) in state.history">
|
|
|
<div
|
|
|
class="__hover flex items-center gap-2 rounded-lg p-2"
|
|
|
:style="{
|
|
@@ -78,7 +63,7 @@
|
|
|
<SvgIcon
|
|
|
name="czr_del"
|
|
|
class="__hover ml-auto"
|
|
|
- @click.stop="onDel(item)"
|
|
|
+ @click.stop="onDel(index)"
|
|
|
/>
|
|
|
</el-tooltip>
|
|
|
</div>
|
|
@@ -89,14 +74,19 @@
|
|
|
class="m-1 flex-1 overflow-hidden rounded-lg border-1 border-[var(--czr-main-color)]/5 shadow"
|
|
|
v-loading="state.chat.loading"
|
|
|
>
|
|
|
- <chat :online="state.chat.isOnline" :ID="state.ID" ref="ref_chat" />
|
|
|
+ <chat
|
|
|
+ :online="state.chat.isOnline"
|
|
|
+ :ID="state.ID"
|
|
|
+ ref="ref_chat"
|
|
|
+ @onStartChat="onAdd"
|
|
|
+ />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { nextTick, onMounted, reactive, ref } from 'vue'
|
|
|
+import { computed, nextTick, onMounted, reactive, ref } from 'vue'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import chat from '@/views/chat/index.vue'
|
|
|
import {
|
|
@@ -115,11 +105,9 @@ const colors = ['46, 155, 62', '0, 159, 188', '119, 69, 222', '255, 162, 84']
|
|
|
const state: any = reactive({
|
|
|
ID: route.params.id,
|
|
|
CODE: route.params.code,
|
|
|
+ LocalStoreKey: 'appPublic' + route.params.id,
|
|
|
detail: {},
|
|
|
- history: {
|
|
|
- loading: false,
|
|
|
- data: [],
|
|
|
- },
|
|
|
+ history: [],
|
|
|
chat: {
|
|
|
isOnline: false,
|
|
|
loading: false,
|
|
@@ -127,75 +115,66 @@ const state: any = reactive({
|
|
|
})
|
|
|
const ref_chat = ref()
|
|
|
const initHistory = () => {
|
|
|
- state.history.loading = true
|
|
|
- appConversationsSearch({
|
|
|
- appId: state.ID,
|
|
|
- page: 1,
|
|
|
- size: 100000,
|
|
|
- })
|
|
|
- .then(({ data }: any) => {
|
|
|
- state.history.data = data.records
|
|
|
- })
|
|
|
- .finally(() => {
|
|
|
- state.history.loading = false
|
|
|
+ const arr: any = []
|
|
|
+ const data = localStorage.getItem(state.LocalStoreKey)
|
|
|
+ if (data) {
|
|
|
+ data.split(',')?.forEach((v) => {
|
|
|
+ arr.push({ name: v })
|
|
|
})
|
|
|
+ }
|
|
|
+ state.history = arr
|
|
|
}
|
|
|
-const onDel = (row) => {
|
|
|
+const onDel = (index) => {
|
|
|
DialogStore.confirm({
|
|
|
title: '删除确认',
|
|
|
content: `请确认是否删除`,
|
|
|
onSubmit: () => {
|
|
|
- appConversationsDel(row.id, { appId: state.ID })
|
|
|
- .then(() => {
|
|
|
- ElMessage.success('删除成功!')
|
|
|
- })
|
|
|
- .catch(() => {})
|
|
|
- .finally(() => {
|
|
|
- initHistory()
|
|
|
- })
|
|
|
+ const arr = state.history.filter((v, i) => i !== index).map((v) => v.name)
|
|
|
+ localStorage.setItem(state.LocalStoreKey, arr.join(','))
|
|
|
+ ElMessage.success('删除成功!')
|
|
|
+ initHistory()
|
|
|
},
|
|
|
})
|
|
|
}
|
|
|
const onHistory = (row) => {
|
|
|
- ref_chat.value?.history(row.id)
|
|
|
+ ref_chat.value?.send(row.name)
|
|
|
}
|
|
|
const onClear = () => {
|
|
|
DialogStore.confirm({
|
|
|
title: '删除确认',
|
|
|
content: `请确认是否清除记录?`,
|
|
|
onSubmit: () => {
|
|
|
- appDelConversations(state.ID)
|
|
|
- .then(() => {
|
|
|
- ElMessage.success('清除记录成功!')
|
|
|
- })
|
|
|
- .catch(() => {})
|
|
|
- .finally(() => {
|
|
|
- initHistory()
|
|
|
- })
|
|
|
+ localStorage.removeItem(state.LocalStoreKey)
|
|
|
+ ElMessage.success('清除记录成功!')
|
|
|
+ initHistory()
|
|
|
},
|
|
|
})
|
|
|
}
|
|
|
+const onAdd = ({ ask }) => {
|
|
|
+ const arr = [ask, ...state.history.map((v) => v.name)]
|
|
|
+ localStorage.setItem(state.LocalStoreKey, arr.join(','))
|
|
|
+ initHistory()
|
|
|
+}
|
|
|
onMounted(() => {
|
|
|
initDetail()
|
|
|
})
|
|
|
const initDetail = () => {
|
|
|
- console.log(route)
|
|
|
- if (state.ID) {
|
|
|
- // state.chat.loading = true
|
|
|
- // appDetail(state.ID)
|
|
|
- // .then(({ data }: any) => {
|
|
|
- // state.detail = data
|
|
|
- // document.title = state.detail.name
|
|
|
- // state.chat.isOnline = state.detail.userInputMethod == 1
|
|
|
- // state.chat.loading = false
|
|
|
- // nextTick(() => {
|
|
|
- // ref_chat.value?.init()
|
|
|
- // })
|
|
|
- // initHistory()
|
|
|
- // })
|
|
|
- // .catch(() => {
|
|
|
- // router.push({ name: '4806d051-e037-4d9d-99a0-78aa2f2f362b' })
|
|
|
- // })
|
|
|
+ if (state.ID && state.CODE) {
|
|
|
+ state.chat.loading = true
|
|
|
+ appDetail(state.ID)
|
|
|
+ .then(({ data }: any) => {
|
|
|
+ state.detail = data
|
|
|
+ document.title = state.detail.name
|
|
|
+ state.chat.isOnline = state.detail.appModelConfig.userInputMethod == 1
|
|
|
+ state.chat.loading = false
|
|
|
+ nextTick(() => {
|
|
|
+ ref_chat.value?.init()
|
|
|
+ })
|
|
|
+ initHistory()
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ router.push({ name: '4806d051-e037-4d9d-99a0-78aa2f2f362b' })
|
|
|
+ })
|
|
|
} else {
|
|
|
router.push({ name: 'NotFound' })
|
|
|
}
|