mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: 修复语音播放无id问题
This commit is contained in:
parent
35f75727be
commit
03275469c2
|
|
@ -12,7 +12,7 @@
|
|||
<AppIcon iconName="app-video-play"></AppIcon>
|
||||
</el-button>
|
||||
<el-button v-else text @click="pausePlayAnswerText()">
|
||||
<el-icon ><VideoPause /></el-icon>
|
||||
<el-icon><VideoPause /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-divider direction="vertical" />
|
||||
|
|
@ -65,10 +65,9 @@ import { useRoute } from 'vue-router'
|
|||
|
||||
const route = useRoute()
|
||||
const {
|
||||
params: { id },
|
||||
params: { id }
|
||||
} = route as any
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
|
|
@ -118,7 +117,7 @@ const playAnswerText = (text: string) => {
|
|||
return
|
||||
}
|
||||
applicationApi
|
||||
.postTextToSpeech(id || props.applicationId as string, { text: text }, loading)
|
||||
.postTextToSpeech(id || (props.applicationId as string), { text: text }, loading)
|
||||
.then((res: any) => {
|
||||
// 假设我们有一个 MP3 文件的字节数组
|
||||
// 创建 Blob 对象
|
||||
|
|
|
|||
|
|
@ -8,11 +8,16 @@
|
|||
<!-- 语音播放 -->
|
||||
<span v-if="tts">
|
||||
<el-tooltip effect="dark" content="语音播放" placement="top">
|
||||
<el-button v-if="!audioPlayerStatus" text :disabled="!data?.write_ed" @click="playAnswerText(data?.answer_text)">
|
||||
<AppIcon iconName="app-video-play" ></AppIcon>
|
||||
<el-button
|
||||
v-if="!audioPlayerStatus"
|
||||
text
|
||||
:disabled="!data?.write_ed"
|
||||
@click="playAnswerText(data?.answer_text)"
|
||||
>
|
||||
<AppIcon iconName="app-video-play"></AppIcon>
|
||||
</el-button>
|
||||
<el-button v-else text :disabled="!data?.write_ed" @click="pausePlayAnswerText()">
|
||||
<el-icon ><VideoPause /></el-icon>
|
||||
<el-icon><VideoPause /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-divider direction="vertical" />
|
||||
|
|
@ -78,14 +83,14 @@
|
|||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { copyClick } from '@/utils/clipboard'
|
||||
import applicationApi from '@/api/application'
|
||||
import { datetimeFormat } from '@/utils/time'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
const route = useRoute()
|
||||
const {
|
||||
params: { id },
|
||||
params: { id }
|
||||
} = route as any
|
||||
|
||||
const props = defineProps({
|
||||
|
|
@ -130,26 +135,28 @@ function voteHandle(val: string) {
|
|||
}
|
||||
|
||||
function markdownToPlainText(md: string) {
|
||||
return md
|
||||
// 移除图片 
|
||||
.replace(/!\[.*?\]\(.*?\)/g, '')
|
||||
// 移除链接 [text](url)
|
||||
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')
|
||||
// 移除 Markdown 标题符号 (#, ##, ###)
|
||||
.replace(/^#{1,6}\s+/gm, '')
|
||||
// 移除加粗 **text** 或 __text__
|
||||
.replace(/\*\*(.*?)\*\*/g, '$1')
|
||||
.replace(/__(.*?)__/g, '$1')
|
||||
// 移除斜体 *text* 或 _text_
|
||||
.replace(/\*(.*?)\*/g, '$1')
|
||||
.replace(/_(.*?)_/g, '$1')
|
||||
// 移除行内代码 `code`
|
||||
.replace(/`(.*?)`/g, '$1')
|
||||
// 移除代码块 ```code```
|
||||
.replace(/```[\s\S]*?```/g, '')
|
||||
// 移除多余的换行符
|
||||
.replace(/\n{2,}/g, '\n')
|
||||
.trim();
|
||||
return (
|
||||
md
|
||||
// 移除图片 
|
||||
.replace(/!\[.*?\]\(.*?\)/g, '')
|
||||
// 移除链接 [text](url)
|
||||
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')
|
||||
// 移除 Markdown 标题符号 (#, ##, ###)
|
||||
.replace(/^#{1,6}\s+/gm, '')
|
||||
// 移除加粗 **text** 或 __text__
|
||||
.replace(/\*\*(.*?)\*\*/g, '$1')
|
||||
.replace(/__(.*?)__/g, '$1')
|
||||
// 移除斜体 *text* 或 _text_
|
||||
.replace(/\*(.*?)\*/g, '$1')
|
||||
.replace(/_(.*?)_/g, '$1')
|
||||
// 移除行内代码 `code`
|
||||
.replace(/`(.*?)`/g, '$1')
|
||||
// 移除代码块 ```code```
|
||||
.replace(/```[\s\S]*?```/g, '')
|
||||
// 移除多余的换行符
|
||||
.replace(/\n{2,}/g, '\n')
|
||||
.trim()
|
||||
)
|
||||
}
|
||||
|
||||
const playAnswerText = (text: string) => {
|
||||
|
|
@ -169,7 +176,7 @@ const playAnswerText = (text: string) => {
|
|||
return
|
||||
}
|
||||
applicationApi
|
||||
.postTextToSpeech(id || props.applicationId as string, { text: text }, loading)
|
||||
.postTextToSpeech((props.applicationId as string) || (id as string), { text: text }, loading)
|
||||
.then((res: any) => {
|
||||
// 假设我们有一个 MP3 文件的字节数组
|
||||
// 创建 Blob 对象
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@
|
|||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="flex" v-if="!item.answer_text">
|
||||
<div v-if="!item.answer_text">
|
||||
<el-card
|
||||
v-if="item.write_ed === undefined || item.write_ed === true"
|
||||
shadow="always"
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@
|
|||
<template #dropdown>
|
||||
<el-dropdown-menu style="width: 100px">
|
||||
<el-dropdown-item
|
||||
:class="filterMethod['is_active'] ? '' : 'is-active'"
|
||||
:class="filterMethod['is_active'] === '' ? 'is-active' : ''"
|
||||
:command="beforeCommand('is_active', '')"
|
||||
class="justify-center"
|
||||
>全部</el-dropdown-item
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
width="80%"
|
||||
class="paragraph-dialog"
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
>
|
||||
<el-row v-loading="loading">
|
||||
<el-col :span="18">
|
||||
|
|
@ -27,7 +29,7 @@
|
|||
</el-button>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="6" class="border-l" style="width: 300px;">
|
||||
<el-col :span="6" class="border-l" style="width: 300px">
|
||||
<!-- 关联问题 -->
|
||||
<ProblemComponent
|
||||
:problemId="problemId"
|
||||
|
|
@ -149,6 +151,4 @@ const handleDebounceClick = debounce(() => {
|
|||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scope>
|
||||
|
||||
</style>
|
||||
<style lang="scss" scope></style>
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
<el-form-item prop="name" :rules="base_form_data_rule.name">
|
||||
<template #label>
|
||||
<div class="flex align-center" style="display: inline-flex">
|
||||
<div class="flex-between mr-4">
|
||||
<div class="mr-4">
|
||||
<span>模型名称 </span>
|
||||
</div>
|
||||
<el-tooltip effect="dark" placement="right">
|
||||
|
|
@ -103,16 +103,10 @@
|
|||
<el-form-item prop="model_name" :rules="base_form_data_rule.model_name">
|
||||
<template #label>
|
||||
<div class="flex align-center" style="display: inline-flex">
|
||||
<div class="flex-between mr-4">
|
||||
<div class="mr-4">
|
||||
<span>基础模型 </span>
|
||||
<span class="danger">列表中没有列出的模型,直接输入模型名称,回车即可添加</span>
|
||||
</div>
|
||||
<el-tooltip effect="dark" placement="right">
|
||||
<template #content>
|
||||
<p>若下拉选项没有列出想要添加的LLM模型,自定义输入模型名称后回车即可</p>
|
||||
<p>注意,基础模型需要与供应商的模型名称一致</p>
|
||||
</template>
|
||||
<AppIcon iconName="app-warning" class="app-warning-icon"></AppIcon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
<el-select
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
<el-form-item prop="name" :rules="base_form_data_rule.name">
|
||||
<template #label>
|
||||
<div class="flex align-center" style="display: inline-flex">
|
||||
<div class="flex-between mr-4">
|
||||
<div class="mr-4">
|
||||
<span>模型名称 </span>
|
||||
</div>
|
||||
<el-tooltip effect="dark" placement="right">
|
||||
|
|
@ -96,16 +96,10 @@
|
|||
<el-form-item prop="model_name" :rules="base_form_data_rule.model_name">
|
||||
<template #label>
|
||||
<div class="flex align-center" style="display: inline-flex">
|
||||
<div class="flex-between mr-4">
|
||||
<div class="mr-4">
|
||||
<span>基础模型 </span>
|
||||
<span class="danger">列表中没有列出的模型,直接输入模型名称,回车即可添加</span>
|
||||
</div>
|
||||
<el-tooltip effect="dark" placement="right">
|
||||
<template #content>
|
||||
<p>若下拉选项没有列出想要添加的LLM模型,自定义输入模型名称后回车即可</p>
|
||||
<p>注意,基础模型需要与供应商的模型名称一致</p>
|
||||
</template>
|
||||
<AppIcon iconName="app-warning" class="app-warning-icon"></AppIcon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
<el-select
|
||||
|
|
|
|||
Loading…
Reference in New Issue