点赞
This commit is contained in:
parent
9af53c8821
commit
8594fd4d09
@ -196,6 +196,31 @@ const postChatMessage: (chat_id: string, message: string) => Promise<any> = (cha
|
|||||||
return postStream(`/api/${prefix}/chat_message/${chat_id}`, { message })
|
return postStream(`/api/${prefix}/chat_message/${chat_id}`, { message })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点赞、点踩
|
||||||
|
* @param 参数
|
||||||
|
* application_id : string; chat_id : string; chat_record_id : string
|
||||||
|
* {
|
||||||
|
"vote_status": "string", // -1 0 1
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
const putChatVote: (
|
||||||
|
application_id: string,
|
||||||
|
chat_id: string,
|
||||||
|
chat_record_id: string,
|
||||||
|
vote_status: string,
|
||||||
|
loading?: Ref<boolean>
|
||||||
|
) => Promise<any> = (application_id, chat_id, chat_record_id, vote_status, loading) => {
|
||||||
|
return put(
|
||||||
|
`${prefix}/${application_id}/chat/${chat_id}/chat_record/${chat_record_id}/vote`,
|
||||||
|
{
|
||||||
|
vote_status
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
loading
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getAllAppilcation,
|
getAllAppilcation,
|
||||||
getApplication,
|
getApplication,
|
||||||
@ -210,5 +235,6 @@ export default {
|
|||||||
getAPIKey,
|
getAPIKey,
|
||||||
getAccessToken,
|
getAccessToken,
|
||||||
postAppAuthentication,
|
postAppAuthentication,
|
||||||
getProfile
|
getProfile,
|
||||||
|
putChatVote
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,8 @@ interface chatType {
|
|||||||
* 是否暂停
|
* 是否暂停
|
||||||
*/
|
*/
|
||||||
is_stop?: boolean
|
is_stop?: boolean
|
||||||
|
record_id: string
|
||||||
|
vote_status: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ChatRecordManage {
|
export class ChatRecordManage {
|
||||||
|
|||||||
@ -7,45 +7,85 @@
|
|||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-divider direction="vertical" />
|
<el-divider direction="vertical" />
|
||||||
<el-tooltip effect="dark" content="复制" placement="top">
|
<el-tooltip effect="dark" content="复制" placement="top">
|
||||||
<el-button text @click="copyClick(item?.answer_text)">
|
<el-button text @click="copyClick(data?.answer_text)">
|
||||||
<AppIcon iconName="app-copy"></AppIcon>
|
<AppIcon iconName="app-copy"></AppIcon>
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-divider direction="vertical" />
|
<el-divider direction="vertical" />
|
||||||
<el-tooltip effect="dark" content="赞同" placement="top">
|
<el-tooltip
|
||||||
<el-button text>
|
effect="dark"
|
||||||
|
content="赞同"
|
||||||
|
placement="top"
|
||||||
|
v-if="buttonData?.vote_status === '-1'"
|
||||||
|
>
|
||||||
|
<el-button text @click="voteHandle('1')" :disabled="loading">
|
||||||
<AppIcon iconName="app-like"></AppIcon>
|
<AppIcon iconName="app-like"></AppIcon>
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-tooltip effect="dark" content="取消赞同" placement="top">
|
<el-tooltip
|
||||||
<el-button text>
|
effect="dark"
|
||||||
|
content="取消赞同"
|
||||||
|
placement="top"
|
||||||
|
v-if="buttonData?.vote_status === '1'"
|
||||||
|
>
|
||||||
|
<el-button text @click="voteHandle('-1')" :disabled="loading">
|
||||||
<AppIcon iconName="app-like-color"></AppIcon>
|
<AppIcon iconName="app-like-color"></AppIcon>
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-divider direction="vertical" />
|
<el-divider direction="vertical" v-if="buttonData?.vote_status === '-1'" />
|
||||||
<el-tooltip effect="dark" content="反对" placement="top">
|
<el-tooltip
|
||||||
<el-button text>
|
effect="dark"
|
||||||
|
content="反对"
|
||||||
|
placement="top"
|
||||||
|
v-if="buttonData?.vote_status === '-1'"
|
||||||
|
>
|
||||||
|
<el-button text @click="voteHandle('0')" :disabled="loading">
|
||||||
<AppIcon iconName="app-oppose"></AppIcon>
|
<AppIcon iconName="app-oppose"></AppIcon>
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-tooltip effect="dark" content="取消反对" placement="top">
|
<el-tooltip
|
||||||
<el-button text>
|
effect="dark"
|
||||||
|
content="取消反对"
|
||||||
|
placement="top"
|
||||||
|
v-if="buttonData?.vote_status === '0'"
|
||||||
|
>
|
||||||
|
<el-button text @click="voteHandle('-1')" :disabled="loading">
|
||||||
<AppIcon iconName="app-oppose-color"></AppIcon>
|
<AppIcon iconName="app-oppose-color"></AppIcon>
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { reactive, ref, watch, onMounted } from 'vue'
|
||||||
import { copyClick } from '@/utils/clipboard'
|
import { copyClick } from '@/utils/clipboard'
|
||||||
|
import applicationApi from '@/api/application'
|
||||||
defineProps({
|
const props = defineProps({
|
||||||
data: {
|
data: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {}
|
default: () => {}
|
||||||
|
},
|
||||||
|
applicationId: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
chartId: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['update:data'])
|
const emit = defineEmits(['update:data'])
|
||||||
|
|
||||||
|
const buttonData = ref(props.data)
|
||||||
|
const loading = ref(false)
|
||||||
|
|
||||||
|
function voteHandle(val: string) {
|
||||||
|
applicationApi
|
||||||
|
.putChatVote(props.applicationId, props.chartId, props.data.record_id, val, loading)
|
||||||
|
.then((res) => {
|
||||||
|
buttonData.value['vote_status'] = val
|
||||||
|
emit('update:data', buttonData.value)
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped></style>
|
||||||
|
|||||||
@ -78,9 +78,9 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <div v-if="item.write_ed && props.appId">
|
<div v-if="item.write_ed && props.appId">
|
||||||
<OperationButton :data="item" />
|
<OperationButton :data="item" :applicationId="appId" :chartId="chartOpenId" />
|
||||||
</div> -->
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -109,10 +109,16 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, nextTick, onUpdated, computed } from 'vue'
|
import { ref, nextTick, onUpdated, computed } from 'vue'
|
||||||
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import OperationButton from './OperationButton.vue'
|
import OperationButton from './OperationButton.vue'
|
||||||
import applicationApi from '@/api/application'
|
import applicationApi from '@/api/application'
|
||||||
import { ChatManagement, type chatType } from '@/api/type/application'
|
import { ChatManagement, type chatType } from '@/api/type/application'
|
||||||
import { randomId } from '@/utils/utils'
|
import { randomId } from '@/utils/utils'
|
||||||
|
import useStore from '@/stores'
|
||||||
|
const route = useRoute()
|
||||||
|
const {
|
||||||
|
params: { accessToken }
|
||||||
|
} = route as any
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: {
|
data: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@ -120,6 +126,7 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
appId: String
|
appId: String
|
||||||
})
|
})
|
||||||
|
const { application } = useStore()
|
||||||
|
|
||||||
const scrollDiv = ref()
|
const scrollDiv = ref()
|
||||||
const dialogScrollbar = ref()
|
const dialogScrollbar = ref()
|
||||||
@ -171,7 +178,12 @@ function getChartOpenId() {
|
|||||||
chartOpenId.value = res.data
|
chartOpenId.value = res.data
|
||||||
chatMessage()
|
chatMessage()
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch((res) => {
|
||||||
|
if (res.response.status === 403) {
|
||||||
|
application.asyncAppAuthentication(accessToken).then(() => {
|
||||||
|
getChartOpenId()
|
||||||
|
})
|
||||||
|
}
|
||||||
loading.value = false
|
loading.value = false
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -199,7 +211,9 @@ function chatMessage() {
|
|||||||
answer_text: '',
|
answer_text: '',
|
||||||
buffer: [],
|
buffer: [],
|
||||||
write_ed: false,
|
write_ed: false,
|
||||||
is_stop: false
|
is_stop: false,
|
||||||
|
record_id: '',
|
||||||
|
vote_status: '-1'
|
||||||
})
|
})
|
||||||
applicationApi.postChatMessage(chartOpenId.value, problem_text).then(async (response) => {
|
applicationApi.postChatMessage(chartOpenId.value, problem_text).then(async (response) => {
|
||||||
inputValue.value = ''
|
inputValue.value = ''
|
||||||
@ -219,9 +233,10 @@ function chatMessage() {
|
|||||||
try {
|
try {
|
||||||
const decoder = new TextDecoder('utf-8')
|
const decoder = new TextDecoder('utf-8')
|
||||||
const str = decoder.decode(value, { stream: true })
|
const str = decoder.decode(value, { stream: true })
|
||||||
if (str && str.startsWith('data:')) {
|
|
||||||
const content = JSON?.parse(str.replace('data:', ''))?.content
|
|
||||||
|
|
||||||
|
if (str && str.startsWith('data:')) {
|
||||||
|
row.record_id = JSON?.parse(str.replace('data:', '')).id
|
||||||
|
const content = JSON?.parse(str.replace('data:', ''))?.content
|
||||||
if (content) {
|
if (content) {
|
||||||
ChatManagement.append(id, content)
|
ChatManagement.append(id, content)
|
||||||
}
|
}
|
||||||
@ -260,11 +275,15 @@ onUpdated(() => {
|
|||||||
&__content {
|
&__content {
|
||||||
width: 99%;
|
width: 99%;
|
||||||
padding-bottom: 96px;
|
padding-bottom: 96px;
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
.content {
|
.content {
|
||||||
padding-left: var(--padding-left);
|
padding-left: var(--padding-left);
|
||||||
|
:deep(ol) {
|
||||||
|
margin-left: 16px!important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.text {
|
.text {
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
|
|||||||
@ -55,7 +55,7 @@ instance.interceptors.response.use(
|
|||||||
router.push({ name: 'login' })
|
router.push({ name: 'login' })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err.response?.status === 403) {
|
if (err.response?.status === 403 && !err.response.config.url.includes('chat/open')) {
|
||||||
MsgError(
|
MsgError(
|
||||||
err.response.data && err.response.data.message ? err.response.data.message : '没有权限访问'
|
err.response.data && err.response.data.message ? err.response.data.message : '没有权限访问'
|
||||||
)
|
)
|
||||||
|
|||||||
@ -59,6 +59,9 @@ const useApplicationStore = defineStore({
|
|||||||
reject(error)
|
reject(error)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
async refreshAccessToken(token: string) {
|
||||||
|
this.asyncAppAuthentication(token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -155,7 +155,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
{{ datasetLoading }}
|
|
||||||
<AddDatasetDialog
|
<AddDatasetDialog
|
||||||
ref="AddDatasetDialogRef"
|
ref="AddDatasetDialogRef"
|
||||||
@addData="addDataset"
|
@addData="addDataset"
|
||||||
@ -254,6 +253,11 @@ function getDetail() {
|
|||||||
application.asyncGetApplicationDetail(id, loading).then((res: any) => {
|
application.asyncGetApplicationDetail(id, loading).then((res: any) => {
|
||||||
applicationForm.value = res.data
|
applicationForm.value = res.data
|
||||||
applicationForm.value.model_id = res.data.model
|
applicationForm.value.model_id = res.data.model
|
||||||
|
if (res.data?.example.length === 2) {
|
||||||
|
exampleList.value = res.data?.example
|
||||||
|
} else if (res.data?.example.length === 1) {
|
||||||
|
exampleList.value = [res.data?.example[0], '']
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="chat__main chat-width" v-loading="loading">
|
<div class="chat__main chat-width" v-loading="loading">
|
||||||
<AiDialog :data="applicationDetail" :appId="applicationDetail?.id"></AiDialog>
|
<AiDialog v-model:data="applicationDetail" :appId="applicationDetail?.id"></AiDialog>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user