feat: 对话日志

This commit is contained in:
wangdan-fit2cloud 2023-12-05 11:36:11 +08:00
parent 86ccb11d94
commit 2422d35a95
5 changed files with 159 additions and 44 deletions

View File

@ -221,6 +221,19 @@ const putChatVote: (
)
}
/**
*
* @param
* application_id, history_day
}
*/
const getChatLog: (
applicaiton_id: String,
history_day: number,
loading?: Ref<boolean>
) => Promise<Result<any>> = (applicaiton_id, history_day, loading) => {
return get(`${prefix}/${applicaiton_id}/chat`, { history_day }, loading)
}
export default {
getAllAppilcation,
getApplication,
@ -236,5 +249,6 @@ export default {
getAccessToken,
postAppAuthentication,
getProfile,
putChatVote
putChatVote,
getChatLog
}

View File

@ -1,6 +1,6 @@
<template>
<div class="app-table" :class="quickCreate ? 'table-quick-append' : ''">
<el-table v-bind="$attrs">
<el-table :max-height="tableHeight" v-bind="$attrs">
<template #append v-if="quickCreate">
<div v-if="showInput">
<el-input
@ -39,7 +39,7 @@
</div>
</template>
<script setup lang="ts">
import { ref, nextTick, watch, computed } from 'vue'
import { ref, nextTick, watch, computed, onMounted } from 'vue'
defineOptions({ name: 'AppTable' })
const props = defineProps({
@ -63,6 +63,7 @@ const quickInputRef = ref()
const loading = ref(false)
const showInput = ref(false)
const inputValue = ref('')
const tableHeight = ref(0)
watch(showInput, (bool) => {
if (!bool) {
@ -93,6 +94,15 @@ function handleCurrentChange() {
emit('changePage')
}
defineExpose({})
onMounted(() => {
tableHeight.value = window.innerHeight - 300
window.onresize = () => {
return (() => {
tableHeight.value = window.innerHeight - 300
})()
}
})
</script>
<style lang="scss" scoped>

View File

@ -18,12 +18,14 @@
<el-tag v-else class="warning-tag">已停用</el-tag>
</div>
</div>
<div class="active-button" @click.stop>
<el-switch />
</div>
<el-row class="mt-16">
<el-col :span="24">
<el-col :span="12">
<div class="flex">
<el-text type="info">公开访问链接</el-text>
<el-switch class="ml-8" inline-prompt active-text="" inactive-text="" />
</div>
<div class="mt-4">
<span class="vertical-middle lighter">
{{ shareUrl }}
@ -33,9 +35,16 @@
<AppIcon iconName="app-copy"></AppIcon>
</el-button>
</div>
<div class="mt-16">
<el-button type="primary"><a :href="shareUrl" target="_blank">演示</a></el-button>
<el-button @click="openDialog"> 嵌入第三方 </el-button>
</div>
</el-col>
<!-- <el-col :span="12">
<el-col :span="12">
<div class="flex">
<el-text type="info">API访问凭据</el-text>
<el-switch class="ml-8" inline-prompt active-text="" inactive-text="" />
</div>
<div class="mt-4">
<span class="vertical-middle lighter">
API Key: OGZmZThlZjYyYzU2MWE1OTlkYTVjZTBi
@ -45,25 +54,11 @@
<AppIcon iconName="app-copy"></AppIcon>
</el-button>
</div>
<div class="mt-4">
<span class="vertical-middle lighter"> API Secret: ************** </span>
<span>
<el-button type="primary" text>
<AppIcon iconName="app-copy"></AppIcon>
</el-button>
</span>
<span>
<el-button type="primary" text>
<AppIcon iconName="app-hide-password" />
</el-button>
</span>
</div>
</el-col> -->
</el-row>
<div class="mt-16">
<el-button type="primary"><a :href="shareUrl" target="_blank">演示</a></el-button>
<el-button @click="openDialog"> 嵌入第三方 </el-button>
<el-button @click="openDialog"> 获取密钥 </el-button>
</div>
</el-col>
</el-row>
</el-card>
</div>
<EmbedDialog ref="EmbedDialogRef" />
@ -79,15 +74,16 @@ import useStore from '@/stores'
const { application } = useStore()
const router = useRouter()
const route = useRoute()
const {
params: { id }
} = route as any
const EmbedDialogRef = ref()
const shareUrl = ref('')
const accessToken = ref('')
const detail = ref<any>(null)
const apiKey = ref<any>(null)
const {
params: { id }
} = route as any
const loading = ref(false)
@ -95,7 +91,7 @@ function openDialog() {
EmbedDialogRef.value.open(accessToken.value)
}
function getAccessToken() {
application.asyncGetAccessToken(id, loading).then((res) => {
application.asyncGetAccessToken(id, loading).then((res: any) => {
accessToken.value = res?.data?.access_token
shareUrl.value = application.location + res?.data?.access_token
})

View File

@ -1,8 +1,111 @@
<template>
<LayoutContainer header="对话日志">
<div class="p-24">
<div class="mb-16">
<el-select v-model="history_day" class="mr-12">
<el-option
v-for="item in dayOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<el-input v-model="search" placeholder="搜索" prefix-icon="Search" style="width: 240px" />
</div>
<app-table
:data="tableData"
:pagination-config="paginationConfig"
@sizeChange="handleSizeChange"
@changePage="handleCurrentChange"
>
<el-table-column prop="abstract" label="摘要" />
<el-table-column prop="chat_record_count" label="对话提问数" align="right" />
<el-table-column prop="star_num" label="用户反馈" align="right">
<template #default="{ row }">
<div>
对话日志
<AppIcon iconName="app-like-color"></AppIcon>
{{ row.star_num }}
<AppIcon iconName="app-oppose-color"></AppIcon>
{{ row.trample_num }}
</div>
</template>
</el-table-column>
<el-table-column prop="mark_sum" label="改进标注" align="right" />
<el-table-column label="时间" width="180">
<template #default="{ row }">
{{ datetimeFormat(row.create_time) }}
</template>
</el-table-column>
<el-table-column label="操作" width="70" align="center">
<template #default="{ row }">
<el-tooltip effect="dark" content="删除" placement="top">
<el-button type="primary" text>
<el-icon><Delete /></el-icon>
</el-button>
</el-tooltip>
</template>
</el-table-column>
</app-table>
</div>
</LayoutContainer>
</template>
<script setup lang="ts">
import { ref, onMounted, reactive } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import applicationApi from '@/api/application'
import { datetimeFormat } from '@/utils/time'
const route = useRoute()
const {
params: { id }
} = route
const dayOptions = [
{
value: 7,
label: '过去7天'
},
{
value: 30,
label: '过去30天'
},
{
value: 90,
label: '过去90天'
},
{
value: 188,
label: '过去半年'
}
]
const loading = ref(false)
const paginationConfig = reactive({
currentPage: 1,
pageSize: 10,
total: 0
})
const tableData = ref([])
const history_day = ref(7)
const search = ref('')
function handleSizeChange(val: number) {
console.log(`${val} items per page`)
}
function handleCurrentChange(val: number) {
console.log(`current page: ${val}`)
}
function getList() {
applicationApi.getChatLog(id as string, history_day.value, loading).then((res) => {
tableData.value = res.data
paginationConfig.total = res.data.length
})
}
onMounted(() => {
getList()
})
</script>
<style lang="scss" scoped></style>

View File

@ -28,7 +28,6 @@
@creatQuick="creatQuickHandle"
@row-click="rowClickHandle"
v-loading="loading"
:max-height="tableHeight"
>
<el-table-column prop="name" label="文件名称" min-width="280">
<template #default="{ row }">
@ -115,7 +114,6 @@ const loading = ref(false)
const filterText = ref('')
const documentData = ref<any[]>([])
const currentMouseId = ref(null)
const tableHeight = ref(0)
const paginationConfig = reactive({
currentPage: 1,
@ -229,12 +227,6 @@ function getList() {
}
onMounted(() => {
tableHeight.value = window.innerHeight - 300
window.onresize = () => {
return (() => {
tableHeight.value = window.innerHeight - 300
})()
}
getList()
})
</script>