Compare commits
44 Commits
Author | SHA1 | Date |
---|---|---|
|
1bafc24025 | |
|
2797313612 | |
|
e007c30235 | |
|
3675de66f5 | |
|
a679a8fc44 | |
|
5d7dc6fc80 | |
|
c812eaee5f | |
|
084da1f68d | |
|
7c377e0eaa | |
|
d954c88ec5 | |
|
a708eb59b5 | |
|
f02f6a8384 | |
|
95d2059b9b | |
|
f238e37fdd | |
|
03897d2aa5 | |
|
a01d7f08da | |
|
055746144d | |
|
06a2697ec2 | |
|
fd43dde733 | |
|
870ffb167a | |
|
0960599c73 | |
|
a5579d4091 | |
|
d5c17eb17f | |
|
f5c9cdc9de | |
|
b5f43f1a37 | |
|
e27f7e0018 | |
|
df906c52f6 | |
|
7a64625567 | |
|
f033155cc1 | |
|
b3b1dde262 | |
|
cbb3971c9b | |
|
327e7d78ad | |
|
e97ff8e147 | |
|
38227cc282 | |
|
433161ef13 | |
|
0b2ed540b8 | |
|
0af53f82f0 | |
|
38df362a86 | |
|
0beae0b035 | |
|
159cb75ca9 | |
|
c69bc91185 | |
|
66bc555445 | |
|
35d8bdf13f | |
|
ba1a4a3abe |
|
@ -6,11 +6,11 @@ directories:
|
||||||
win:
|
win:
|
||||||
executableName: 文枢课堂
|
executableName: 文枢课堂
|
||||||
icon: resources/logo2.ico
|
icon: resources/logo2.ico
|
||||||
target:
|
# target:
|
||||||
- target: nsis
|
# - target: nsis
|
||||||
arch:
|
# arch:
|
||||||
- x64
|
# - x64
|
||||||
- ia32
|
# - ia32
|
||||||
files:
|
files:
|
||||||
- '!**/.vscode/*'
|
- '!**/.vscode/*'
|
||||||
- '!src/*'
|
- '!src/*'
|
||||||
|
|
|
@ -6,11 +6,11 @@ directories:
|
||||||
win:
|
win:
|
||||||
executableName: 永川中小学AI教学系统
|
executableName: 永川中小学AI教学系统
|
||||||
icon: resources/yc-logo.png
|
icon: resources/yc-logo.png
|
||||||
target:
|
# target:
|
||||||
- target: nsis
|
# - target: nsis
|
||||||
arch:
|
# arch:
|
||||||
- x64
|
# - x64
|
||||||
- ia32
|
# - ia32
|
||||||
files:
|
files:
|
||||||
- '!**/.vscode/*'
|
- '!**/.vscode/*'
|
||||||
- '!src/*'
|
- '!src/*'
|
||||||
|
|
|
@ -6,11 +6,11 @@ directories:
|
||||||
win:
|
win:
|
||||||
executableName: 实训教学
|
executableName: 实训教学
|
||||||
icon: resources/yc-logo.png
|
icon: resources/yc-logo.png
|
||||||
target:
|
# target:
|
||||||
- target: nsis
|
# - target: nsis
|
||||||
arch:
|
# arch:
|
||||||
- x64
|
# - x64
|
||||||
- ia32
|
# - ia32
|
||||||
files:
|
files:
|
||||||
- '!**/.vscode/*'
|
- '!**/.vscode/*'
|
||||||
- '!src/*'
|
- '!src/*'
|
||||||
|
|
|
@ -6,11 +6,11 @@ directories:
|
||||||
win:
|
win:
|
||||||
executableName: 育人酉数平台
|
executableName: 育人酉数平台
|
||||||
icon: resources/yy-logo.png
|
icon: resources/yy-logo.png
|
||||||
target:
|
# target:
|
||||||
- target: nsis
|
# - target: nsis
|
||||||
arch:
|
# arch:
|
||||||
- x64
|
# - x64
|
||||||
- ia32
|
# - ia32
|
||||||
files:
|
files:
|
||||||
- '!**/.vscode/*'
|
- '!**/.vscode/*'
|
||||||
- '!src/*'
|
- '!src/*'
|
||||||
|
|
|
@ -13,11 +13,11 @@ asarUnpack:
|
||||||
win:
|
win:
|
||||||
executableName: AIx
|
executableName: AIx
|
||||||
icon: resources/logo2.ico
|
icon: resources/logo2.ico
|
||||||
target:
|
# target:
|
||||||
- target: nsis
|
# - target: nsis
|
||||||
arch:
|
# arch:
|
||||||
- x64
|
# - x64
|
||||||
- ia32
|
# - ia32
|
||||||
nsis:
|
nsis:
|
||||||
oneClick: false
|
oneClick: false
|
||||||
allowToChangeInstallationDirectory: true
|
allowToChangeInstallationDirectory: true
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "aix-win-ws",
|
"name": "aix-win-ws",
|
||||||
"version": "2.5.16",
|
"version": "2.5.20",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "./out/main/index.js",
|
"main": "./out/main/index.js",
|
||||||
"author": "上海交大重庆人工智能研究院",
|
"author": "上海交大重庆人工智能研究院",
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
"@vue-office/excel": "^1.7.11",
|
"@vue-office/excel": "^1.7.11",
|
||||||
"@vue-office/pdf": "^2.0.2",
|
"@vue-office/pdf": "^2.0.2",
|
||||||
"@vueuse/core": "^10.11.0",
|
"@vueuse/core": "^10.11.0",
|
||||||
"aix-plugins-aitools": "^1.1.5",
|
"aix-plugins-aitools": "^1.1.24",
|
||||||
"animate.css": "^4.1.1",
|
"animate.css": "^4.1.1",
|
||||||
"circular-json": "^0.5.9",
|
"circular-json": "^0.5.9",
|
||||||
"clipboard": "^2.0.11",
|
"clipboard": "^2.0.11",
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 79 KiB |
|
@ -94,7 +94,7 @@ const insertImageElementaudio = (files: FileList) => {
|
||||||
const imageFile = files[0]
|
const imageFile = files[0]
|
||||||
if (!imageFile) return
|
if (!imageFile) return
|
||||||
PPTApi.toRousrceUrl(imageFile).then(data=>{
|
PPTApi.toRousrceUrl(imageFile).then(data=>{
|
||||||
videoSrc.value=data
|
audioSrc.value=data
|
||||||
insertAudio()
|
insertAudio()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ provide(injectKeySlideScale, scale)
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.slide-item {
|
.slide-item {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
@ -198,7 +198,7 @@ export default (isLoader?: boolean = true) => {
|
||||||
const touchInfo = ref<{ x: number; y: number; } | null>(null)
|
const touchInfo = ref<{ x: number; y: number; } | null>(null)
|
||||||
|
|
||||||
const touchStartListener = (e: TouchEvent) => {
|
const touchStartListener = (e: TouchEvent) => {
|
||||||
e.preventDefault() // 阻止默认事件
|
// e.preventDefault() // 阻止默认事件
|
||||||
touchInfo.value = {
|
touchInfo.value = {
|
||||||
// x: e.changedTouches[0].pageX,
|
// x: e.changedTouches[0].pageX,
|
||||||
// y: e.changedTouches[0].pageY,
|
// y: e.changedTouches[0].pageY,
|
||||||
|
@ -208,6 +208,7 @@ export default (isLoader?: boolean = true) => {
|
||||||
}
|
}
|
||||||
const touchEndListener = (e: TouchEvent) => {
|
const touchEndListener = (e: TouchEvent) => {
|
||||||
if (!touchInfo.value) return
|
if (!touchInfo.value) return
|
||||||
|
// window.scrollTo(0, 0) // 滚动到顶部
|
||||||
const offsetX = Math.abs(touchInfo.value.x - e.changedTouches[0].clientX)
|
const offsetX = Math.abs(touchInfo.value.x - e.changedTouches[0].clientX)
|
||||||
const offsetY = e.changedTouches[0].clientY - touchInfo.value.y
|
const offsetY = e.changedTouches[0].clientY - touchInfo.value.y
|
||||||
if ( Math.abs(offsetY) > offsetX && Math.abs(offsetY) > 50 ) {
|
if ( Math.abs(offsetY) > offsetX && Math.abs(offsetY) > 50 ) {
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
declare module '@/api/file' {
|
||||||
|
// 定义 uploadFile 函数的类型
|
||||||
|
// export function uploadFile(file: File): Promise<any>;
|
||||||
|
export function sessionToken(): Promise<any>;
|
||||||
|
export function uploadSingleFileToEos(data: SingleUploadData): Promise<any>;
|
||||||
|
}
|
|
@ -110,3 +110,11 @@ export const sessionToken = () => {
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const uploadSingleFileToEos = (params) => {
|
||||||
|
return request({
|
||||||
|
url: '/common/uploadSingleFileToEos',
|
||||||
|
method: 'post',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: "iconfont"; /* Project id 4723712 */
|
font-family: "iconfont"; /* Project id 4723712 */
|
||||||
src: url('iconfont.woff2?t=1737434703828') format('woff2'),
|
src: url('iconfont.woff2?t=1739948469020') format('woff2'),
|
||||||
url('iconfont.woff?t=1737434703828') format('woff'),
|
url('iconfont.woff?t=1739948469020') format('woff'),
|
||||||
url('iconfont.ttf?t=1737434703828') format('truetype');
|
url('iconfont.ttf?t=1739948469020') format('truetype');
|
||||||
}
|
}
|
||||||
|
|
||||||
.iconfont {
|
.iconfont {
|
||||||
|
@ -13,6 +13,10 @@
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon-zhongxinshiyang:before {
|
||||||
|
content: "\e67b";
|
||||||
|
}
|
||||||
|
|
||||||
.icon-siweidaotu:before {
|
.icon-siweidaotu:before {
|
||||||
content: "\e606";
|
content: "\e606";
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -5,6 +5,13 @@
|
||||||
"css_prefix_text": "icon-",
|
"css_prefix_text": "icon-",
|
||||||
"description": "",
|
"description": "",
|
||||||
"glyphs": [
|
"glyphs": [
|
||||||
|
{
|
||||||
|
"icon_id": "4320365",
|
||||||
|
"name": "重新试样",
|
||||||
|
"font_class": "zhongxinshiyang",
|
||||||
|
"unicode": "e67b",
|
||||||
|
"unicode_decimal": 59003
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"icon_id": "11685410",
|
"icon_id": "11685410",
|
||||||
"name": "思维导图",
|
"name": "思维导图",
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 21 KiB |
|
@ -1,78 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<!-- <form @submit.prevent="submitForm" enctype="multipart/form-data">-->
|
|
||||||
<form action="https://wzyzoss.eos-chongqing-3.cmecloud.cn" method="post" enctype="multipart/form-data">
|
|
||||||
<!-- action 是具体要上传的地址 -->
|
|
||||||
<!--
|
|
||||||
|
|
||||||
上传后文件(Object)名:
|
|
||||||
<input type="input" name="key" :value="uploadData.key" placeholder="文件名" style="width: 400px"/><br/><br/>
|
|
||||||
|
|
||||||
ACL:
|
|
||||||
<input type="hidden" name="acl" :value="uploadData.acl" placeholder="文件 ACL" style="width: 400px"/><br/><br/>
|
|
||||||
|
|
||||||
Content-Type:
|
|
||||||
<input type="input" name="Content-Type" :value="uploadData['Content-Type']" placeholder="文件类型" style="width: 400px"/><br/><br/>
|
|
||||||
|
|
||||||
X-Amz-Credential:
|
|
||||||
<input type="text" name="X-Amz-Credential" :value="uploadData['x-amz-credential']" placeholder="X-Amz-Credential,从后端程序返回中获取" style="width: 400px"/><br/><br/>
|
|
||||||
|
|
||||||
X-Amz-Algorithm:
|
|
||||||
<input type="text" name="X-Amz-Algorithm" :value="uploadData['x-amz-algorithm']" placeholder="X-Amz-Algorithm, 从后端程序返回中获取" style="width: 400px"/><br/><br/>
|
|
||||||
|
|
||||||
X-Amz-Date:
|
|
||||||
<input type="text" name="X-Amz-Date" :value="uploadData['x-amz-date']" placeholder="X-Amz-Date 从后端程序返回中获取" style="width: 400px"><br/><br/>
|
|
||||||
|
|
||||||
Policy:
|
|
||||||
<input type="text" name="Policy" :value="uploadData.policy" placeholder="Policy 从后端程序返回中获取" style="width: 400px"/><br/><br/>
|
|
||||||
|
|
||||||
X-Amz-Signature:
|
|
||||||
<input type="text" name="X-Amz-Signature" :value="uploadData['x-amz-signature']" placeholder="X-Amz-Signature 从后端程序返回中获取" style="width: 400px"/><br/><br/>
|
|
||||||
-->
|
|
||||||
|
|
||||||
选择文件(Object)
|
|
||||||
<input type="file" name="file" @change="handleFileChange" style="width: 400px"/> <br/><br/>
|
<input type="file" name="file" @change="handleFileChange" style="width: 400px"/> <br/><br/>
|
||||||
<input type="submit" name="submit" value="上传到 EOS" style="width: 400px"/><br/><br/>
|
|
||||||
<el-button @click="uploadFile">上传</el-button>
|
<el-button @click="uploadFile">上传</el-button>
|
||||||
</form>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {ref, onMounted} from "vue"
|
import {ref, onMounted} from "vue"
|
||||||
import {createSignature, sessionToken} from "@/api/file";
|
import {sessionToken} from "@/api/file";
|
||||||
import axios from "axios"
|
import {uploadSingleToEos} from '@/utils/fileUpload'
|
||||||
|
|
||||||
const url = "https://wzyzoss.eos-chongqing-3.cmecloud.cn"
|
|
||||||
const uploadData = ref({
|
|
||||||
"bucket": "wzyzoss",
|
|
||||||
"x-amz-date": "20250113T061000Z",
|
|
||||||
"x-amz-signature": "2d6fba9f27544bfc7414d660e2e73aafdaf02fe3de45e68f59d580276239cd07",
|
|
||||||
"acl": "private",
|
|
||||||
"x-amz-algorithm": "AWS4-HMAC-SHA256",
|
|
||||||
"key": "wzyzossa",
|
|
||||||
"x-amz-credential": "07ICFAF4IWWZP6RH0WCG/20250113/us-east-1/s3/aws4_request",
|
|
||||||
"Content-Type": null,
|
|
||||||
"policy": "eyJleHBpcmF0aW9uIjoiMjAyNS0wMS0xM1QwNzoxMDowMC42NzVaIiwiY29uZGl0aW9ucyI6W3sieC1hbXotZGF0ZSI6IjIwMjUwMTEzVDA2MTAwMFoifSx7ImFjbCI6InByaXZhdGUifSx7ImJ1Y2tldCI6Ind6eXpvc3MifSxbInN0YXJ0cy13aXRoIiwiJGtleSIsInd6eXpvc3NhIl0sWyJzdGFydHMtd2l0aCIsIiRDb250ZW50LVR5cGUiLCJudWxsIl0seyJ4LWFtei1hbGdvcml0aG0iOiJBV1M0LUhNQUMtU0hBMjU2In0seyJ4LWFtei1jcmVkZW50aWFsIjoiMDdJQ0ZBRjRJV1daUDZSSDBXQ0cvMjAyNTAxMTMvdXMtZWFzdC0xL3MzL2F3czRfcmVxdWVzdCJ9LFsiY29udGVudC1sZW5ndGgtcmFuZ2UiLDEsMTAwMDAwXV19"
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const submitForm = ()=> {
|
|
||||||
let formData = new FormData();
|
|
||||||
for (const formDataKey in formData) {
|
|
||||||
formData.append(formDataKey, formData[formDataKey]);
|
|
||||||
}
|
|
||||||
axios.post(url, formData, {
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'multipart/form-data'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
console.log('表单提交成功,服务器响应:', response.data);
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.log('表单提交失败:', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const S3Data = {
|
const S3Data = {
|
||||||
apiVersion: "2006-03-01",
|
apiVersion: "2006-03-01",
|
||||||
|
@ -92,32 +26,24 @@ const handleFileChange = (event)=> {
|
||||||
|
|
||||||
const uploadMessage = ref(null)
|
const uploadMessage = ref(null)
|
||||||
|
|
||||||
|
const callUploadSuccess = (e)=> {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
const callProgress = (e,p)=> {
|
||||||
|
console.log(e,p)
|
||||||
|
}
|
||||||
|
|
||||||
const uploadFile = ()=>{
|
const uploadFile = ()=>{
|
||||||
if (selectedFile) {
|
if (selectedFile) {
|
||||||
console.log(S3Data)
|
let res = uploadSingleToEos(selectedFile, null,{callUploadSuccess,callProgress})
|
||||||
// 创建一个 AWS.S3 实例
|
console.log(res)
|
||||||
const s3 = new AWS.S3(S3Data);
|
|
||||||
let params = {
|
|
||||||
Key: selectedFile.name,
|
|
||||||
Bucket: "wzyzoss",
|
|
||||||
ContentType: selectedFile.type,
|
|
||||||
Body: selectedFile
|
|
||||||
}
|
|
||||||
console.log(params)
|
|
||||||
s3.putObject(params, function (err, data) {
|
|
||||||
console.log(err,data)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(()=>{
|
onMounted(()=>{
|
||||||
console.log(AWS)
|
|
||||||
/*createSignature({objectName:"123.jpg",contentType:"image/png"}).then(res=>{
|
|
||||||
uploadData.value = res.body
|
|
||||||
})*/
|
|
||||||
sessionToken().then(res=>{
|
sessionToken().then(res=>{
|
||||||
uploadMessage.value = res.data
|
uploadMessage.value = res.data
|
||||||
console.log(res.data)
|
|
||||||
S3Data.accessKeyId = res.data.accessKeyId
|
S3Data.accessKeyId = res.data.accessKeyId
|
||||||
// S3Data.accessKeyId = "kzOm2cc7nT12ao907Tc"
|
// S3Data.accessKeyId = "kzOm2cc7nT12ao907Tc"
|
||||||
S3Data.secretAccessKey = res.data.secretAccessKey
|
S3Data.secretAccessKey = res.data.secretAccessKey
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
<template #default="{ node, data }">
|
<template #default="{ node, data }">
|
||||||
<div v-if="props.isClassTask && (data.bookId == '' || data.bookId == '0')" class="tree-label-wrap">
|
<div v-if="props.isClassTask && (data.bookId == '' || data.bookId == '0')" class="tree-label-wrap">
|
||||||
<el-tooltip effect="light" placement="right" >
|
<el-tooltip effect="light" placement="right" >
|
||||||
<template #content> {{ node.label }}<br /><span style="color: red;">-该单元章节无自主试题-</span> </template>
|
<!-- <template #content> {{ node.label }}<br /><span style="color: red;">-该单元章节无自主试题-</span> </template> -->
|
||||||
|
<template #content> {{ node.label }}</template>
|
||||||
<div class="tree-label" style="color: #A5B3CA" >
|
<div class="tree-label" style="color: #A5B3CA" >
|
||||||
{{ node.label }}
|
{{ node.label }}
|
||||||
</div>
|
</div>
|
||||||
|
@ -195,6 +196,12 @@ const handleNodeClick = (data) => {
|
||||||
},
|
},
|
||||||
node: nodeData
|
node: nodeData
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 章节数据里面的rootid 为bookId
|
||||||
|
* 因为部分数据源的rootid 有问题 这里需要重复赋值一下
|
||||||
|
*/
|
||||||
|
curData.node.rootid = curBook.data.id
|
||||||
// 本地存储:electron-store
|
// 本地存储:electron-store
|
||||||
let defaultExpandedKeys = parentNode ? [parentNode.id] : [nodeData.id]
|
let defaultExpandedKeys = parentNode ? [parentNode.id] : [nodeData.id]
|
||||||
sessionStore.set('subject.defaultExpandedKeys', defaultExpandedKeys)
|
sessionStore.set('subject.defaultExpandedKeys', defaultExpandedKeys)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<el-dialog v-model="isDialog" :show-close="false" width="800" append-to-body destroy-on-close>
|
<el-dialog v-model="model" :show-close="false" width="800" append-to-body destroy-on-close>
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="custom-header flex">
|
<div class="custom-header flex">
|
||||||
<span>{{ item.name }}</span>
|
<span>{{ item.name }}</span>
|
||||||
<i class="iconfont icon-guanbi" @click="isDialog = false"></i>
|
<i class="iconfont icon-guanbi" @click="model = false"></i>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div class="dialog-content">
|
<div class="dialog-content">
|
||||||
|
@ -15,7 +15,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-start flex" v-else>
|
<div class="flex-start flex" v-else>
|
||||||
<div class="flex" v-loading="!item.msg">
|
<div class="flex" v-loading="!item.msg">
|
||||||
<div class="chart-item robot">{{ item.msg }}</div>
|
<div class="chart-item robot">
|
||||||
|
<v-md-editor v-model="item.msg" mode="preview" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-end replace-item">
|
<div class="flex flex-end replace-item">
|
||||||
<span @click="saveAdjust(item)"><i class="iconfont icon-tihuan"></i>替换分析结果</span>
|
<span @click="saveAdjust(item)"><i class="iconfont icon-tihuan"></i>替换分析结果</span>
|
||||||
|
@ -54,7 +56,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive, onMounted, onUnmounted } from 'vue'
|
import { ref, reactive, onMounted, watch, onUnmounted } from 'vue'
|
||||||
import { completion, docList } from '@/api/mode/index'
|
import { completion, docList } from '@/api/mode/index'
|
||||||
import { sessionStore } from '@/utils/store'
|
import { sessionStore } from '@/utils/store'
|
||||||
import { dataSetJson } from '@/utils/comm.js'
|
import { dataSetJson } from '@/utils/comm.js'
|
||||||
|
@ -66,7 +68,7 @@ const userInfo = useUserStore().user
|
||||||
|
|
||||||
const textarea = ref('')
|
const textarea = ref('')
|
||||||
|
|
||||||
const isDialog = defineModel()
|
const model = defineModel()
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
item: {
|
item: {
|
||||||
|
@ -89,6 +91,12 @@ const props = defineProps({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(model, (newVal) =>{
|
||||||
|
if(newVal){
|
||||||
|
msgList.value.length = 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['saveEdit'])
|
const emit = defineEmits(['saveEdit'])
|
||||||
|
|
||||||
const loaded = ref(false)
|
const loaded = ref(false)
|
||||||
|
@ -148,7 +156,7 @@ const getCompletion = async (val) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveAdjust = (item) =>{
|
const saveAdjust = (item) =>{
|
||||||
isDialog.value = false
|
model.value = false
|
||||||
emitter.emit('onSaveAdjust', item.msg)
|
emitter.emit('onSaveAdjust', item.msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,12 +166,17 @@ const dataset_id = ref('')
|
||||||
const fileList = ref([])
|
const fileList = ref([])
|
||||||
const getList = () =>{
|
const getList = () =>{
|
||||||
docList({
|
docList({
|
||||||
userId: userInfo.userId,
|
createUser: userInfo.userId,
|
||||||
dataset_id: dataset_id.value
|
datasetId: dataset_id.value,
|
||||||
|
edustage: curNode.edustage,
|
||||||
|
edusubject: curNode.edusubject
|
||||||
}).then( res =>{
|
}).then( res =>{
|
||||||
|
if(res.rows.length){
|
||||||
fileList.value = res.rows
|
fileList.value = res.rows
|
||||||
|
|
||||||
Object.assign(curFile, fileList.value[0])
|
Object.assign(curFile, fileList.value[0])
|
||||||
params.document_ids = fileList.value[0].docId
|
params.document_ids = fileList.value[0].docId
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
emitter.on('changeCurFile', (item) =>{
|
emitter.on('changeCurFile', (item) =>{
|
||||||
|
@ -239,6 +252,7 @@ onUnmounted(() => {
|
||||||
.robot {
|
.robot {
|
||||||
background: #409EFF;
|
background: #409EFF;
|
||||||
color: #FFF;
|
color: #FFF;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
.replace-item{
|
.replace-item{
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
@ -332,4 +346,13 @@ onUnmounted(() => {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.v-md-editor){
|
||||||
|
background-color: #409EFF;
|
||||||
|
}
|
||||||
|
:deep(.github-markdown-body) {
|
||||||
|
font-size: 14px;
|
||||||
|
padding: 10px;
|
||||||
|
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<el-input v-model="form.name" />
|
<el-input v-model="form.name" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="提示词" v-if="item.ex3 == '1' ? false : true">
|
<el-form-item label="提示词" v-if="item.ex3 == '1' ? false : true">
|
||||||
<el-input v-model="form.prompt" type="textarea" />
|
<el-input v-model="form.prompt" type="textarea" autosize :rows="2" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -137,7 +137,9 @@ const curFile = reactive({})
|
||||||
const getList = () => {
|
const getList = () => {
|
||||||
docList({
|
docList({
|
||||||
createUser: userInfo.userId,
|
createUser: userInfo.userId,
|
||||||
datasetId: dataset_id.value
|
datasetId: dataset_id.value,
|
||||||
|
edustage: curNode.edustage,
|
||||||
|
edusubject: curNode.edusubject
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
fileList.value = [...res.rows]
|
fileList.value = [...res.rows]
|
||||||
if(res.rows.length){
|
if(res.rows.length){
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
<div class="container-right-header flex">
|
<div class="container-right-header flex">
|
||||||
<el-dropdown @command="changeTemplate" :hide-on-click="false">
|
<el-dropdown @command="changeTemplate" :hide-on-click="false">
|
||||||
<span class="el-dropdown-link">
|
<span class="el-dropdown-link">
|
||||||
{{ curTemplate.name }}
|
{{ curTemplate.ex3 ? `${curTemplate.name}(平台)` : `${curTemplate.name}(个人)` }}
|
||||||
<i class="iconfont icon-xiangxia"></i>
|
<i class="iconfont icon-xiangxia"></i>
|
||||||
</span>
|
</span>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<el-dropdown-item v-for="item in templateList" :command="item" :key="item.id">{{ item.name
|
<el-dropdown-item v-for="item in templateList" :command="item" :key="item.id">{{ item.ex3 ? `${item.name}(平台)` : `${item.name}(个人)`
|
||||||
}}</el-dropdown-item>
|
}}</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
|
@ -18,20 +18,20 @@
|
||||||
<el-select v-model="curMode" placeholder="Select" class="mr-4 w-30">
|
<el-select v-model="curMode" placeholder="Select" class="mr-4 w-30">
|
||||||
<el-option v-for="item in modeOptions" :key="item.value" :disabled="item.disabled" :label="item.label" :value="item.value" />
|
<el-option v-for="item in modeOptions" :key="item.value" :disabled="item.disabled" :label="item.label" :value="item.value" />
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-button type="danger" link :disabled="!(templateList.length)" @click="removeItem(curTemplate, false)">
|
<el-button type="danger" link :disabled="!(templateList.length)" @click="removeItem(curTemplate, false)" v-if="curTemplate.ex3 != 1">
|
||||||
删除
|
删除
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" link :disabled="!(templateList.length)" @click="onAdd">
|
<el-button type="primary" link :disabled="!(templateList.length)" @click="onAdd">
|
||||||
<i class="iconfont icon-jiahao"></i>
|
<i class="iconfont icon-jiahao"></i>
|
||||||
添加提示词
|
{{ curTemplate.ex3 == 1 ? '复制并创建个人模板' : '添加提示词' }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" :disabled="!(childTempList.length)" @click="getCompletion">一键研读</el-button>
|
<el-button type="primary" :disabled="!(childTempList.length)" @click="getModelResult('')">一键研读</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!--List-->
|
<!--List-->
|
||||||
<div class="container-right-list" ref="listRef">
|
<div class="container-right-list" ref="outerContainer">
|
||||||
<template v-for="(item, index) in childTempList">
|
<template v-for="(item, index) in childTempList" >
|
||||||
<div class="template-item" v-loading="item.loading">
|
<div class="template-item" v-loading="item.loading" ref="messageElements">
|
||||||
<div class="item-header">
|
<div class="item-header">
|
||||||
<div>
|
<div>
|
||||||
<span class="blue">#</span>{{ item.name }}
|
<span class="blue">#</span>{{ item.name }}
|
||||||
|
@ -50,18 +50,26 @@
|
||||||
<div class="item-text">
|
<div class="item-text">
|
||||||
{{ item.prompt }}
|
{{ item.prompt }}
|
||||||
</div>
|
</div>
|
||||||
<div class="item-text text-answer" v-if="item.answer">
|
<div class="item-text text-answer">
|
||||||
<div class="item-icon">
|
<div class="item-icon">
|
||||||
<i class="iconfont icon-ai"></i>
|
<i class="iconfont icon-ai"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="item-answer">
|
<div class="item-answer">
|
||||||
<TypingEffect v-if="isStarted[index]" :text="item.answer" :delay="10" :aiShow="item.aiShow"
|
<!-- <TypingEffect v-if="isStarted[index]" :text="item.answer" :delay="10" :aiShow="item.aiShow"
|
||||||
@complete="handleCompleteText($event, index)" @updateScroll="scrollToBottom($event, index)" />
|
@complete="handleCompleteText($event, index)" @updateScroll="scrollToBottom($event, index)" /> -->
|
||||||
|
<TypingEffect
|
||||||
|
:text="item.answer"
|
||||||
|
:showTypewriter="item.showTypewriter"
|
||||||
|
:speed="30"
|
||||||
|
:charsPerFrame="15"
|
||||||
|
@scroll="handleScroll(index)"
|
||||||
|
@done="handleDone(index)"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ai-btn" v-if="item.answer">
|
<div class="ai-btn" v-if="item.answer">
|
||||||
<el-button type="primary" link @click="againResult(index, item)">
|
<el-button type="primary" link @click="getModelResult(index, item)">
|
||||||
<i class="iconfont icon-ai1"></i>
|
<i class="iconfont icon-zhongxinshiyang"></i>
|
||||||
重新研读
|
重新研读
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" link @click="onAdjust(index, item)">
|
<el-button type="primary" link @click="onAdjust(index, item)">
|
||||||
|
@ -99,7 +107,6 @@ import TypingEffect from '@/components/typing-effect/index.vue'
|
||||||
import useUserStore from '@/store/modules/user'
|
import useUserStore from '@/store/modules/user'
|
||||||
import emitter from '@/utils/mitt';
|
import emitter from '@/utils/mitt';
|
||||||
import { dataSetJson } from '@/utils/comm.js'
|
import { dataSetJson } from '@/utils/comm.js'
|
||||||
import { cloneDeep } from 'lodash'
|
|
||||||
|
|
||||||
const props = defineProps(['type'])
|
const props = defineProps(['type'])
|
||||||
const { user } = useUserStore()
|
const { user } = useUserStore()
|
||||||
|
@ -120,6 +127,10 @@ const modeOptions = ref([
|
||||||
label: '知识库模型',
|
label: '知识库模型',
|
||||||
value: 2,
|
value: 2,
|
||||||
disabled: false
|
disabled: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'deepseek模型',
|
||||||
|
value: 3,
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -172,61 +183,253 @@ const getTemplateList = () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const getChildTemplate = () => {
|
const getChildTemplate = (val) => {
|
||||||
tempLoading.value = true
|
tempLoading.value = true
|
||||||
modelList({ model: props.type, type: 2, parentId: curTemplate.id, ex1: curNode.edustage, ex2: curNode.edusubject }).then(res => {
|
modelList({ model: props.type, type: 2, parentId: curTemplate.id, ex1: curNode.edustage, ex2: curNode.edusubject }).then(res => {
|
||||||
childTempList.value = res.rows
|
childTempList.value = res.rows
|
||||||
if (childTempList.value.length) {
|
if (childTempList.value.length) {
|
||||||
childTempList.value.forEach(item => item.answer = '')
|
childTempList.value.forEach(item => {
|
||||||
|
item.answer = '';
|
||||||
|
item.showTypewriter = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
getTempResult()
|
|
||||||
|
// 获取研读结果
|
||||||
|
getTempResult(val)
|
||||||
|
|
||||||
|
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
tempLoading.value = false
|
tempLoading.value = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const isStarted = ref([]);
|
|
||||||
const listRef = ref()
|
|
||||||
// 查询模板结果
|
// 查询模板结果
|
||||||
const getTempResult = () => {
|
const getTempResult = (val) => {
|
||||||
tempResult({ mainModelId: curTemplate.id, pageNum: 1, pageSize: 10000, ex1: curNode.id }).then(res => {
|
tempResult({ mainModelId: curTemplate.id, pageNum: 1, pageSize: 10000, ex1: curNode.id }).then(async res => {
|
||||||
let rows = res.rows
|
let rows = res.rows
|
||||||
childTempList.value.forEach(item => {
|
childTempList.value.forEach(item => {
|
||||||
rows.forEach(el => {
|
rows.forEach(el => {
|
||||||
if (item.id == el.modelId) {
|
if (item.id == el.modelId) {
|
||||||
item.answer = getResult(el.content)
|
item.answer = el.content
|
||||||
item.resultId = el.id
|
item.resultId = el.id
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
if (rows.length > 0) {
|
// val : true 新增的子模板 然后研读
|
||||||
isStarted.value = new Array(rows.length).fill(true)
|
if(val){
|
||||||
}
|
// 添加了一个子模板 要等dom 更新完成 不然滚动无效
|
||||||
|
await nextTick()
|
||||||
|
|
||||||
|
// 研读最后一个
|
||||||
|
let lastIndex = childTempList.value.length - 1
|
||||||
|
getModelResult(lastIndex, childTempList.value[lastIndex], true)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const scrollToBottom = (height, index) => {
|
const prompt = ref('')
|
||||||
|
|
||||||
if (listRef.value) {
|
// 是否重新研读
|
||||||
let sum = 0
|
const isAgain = ref(false)
|
||||||
let listDom = listRef.value.children
|
|
||||||
|
|
||||||
if (index == 0) {
|
// 研读
|
||||||
// 220 去掉头部
|
const getModelResult = async (index, item, isLast) => {
|
||||||
let screenHeight = window.innerHeight - 220
|
/**
|
||||||
if (height > screenHeight) {
|
*
|
||||||
listRef.value.scrollTop = (height - screenHeight + 50)
|
* index: 当前项索引
|
||||||
|
* item: 当前项
|
||||||
|
* isLast: 是否最后一项 用于添加子模板后研读
|
||||||
|
*/
|
||||||
|
let str = prompt.value
|
||||||
|
// 重新研读
|
||||||
|
if(index !== ''){
|
||||||
|
isAgain.value = true
|
||||||
|
// 清空研读结果
|
||||||
|
childTempList.value[index].answer = ''
|
||||||
|
// 设置需要打字机效果
|
||||||
|
childTempList.value[index].showTypewriter = true
|
||||||
|
// 滚动到该项的位置
|
||||||
|
if (messageElements.value[index]) {
|
||||||
|
messageElements.value[index].scrollIntoView({
|
||||||
|
behavior: 'smooth',
|
||||||
|
block: 'start',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
// 设置当前模板prompt
|
||||||
|
str = str.replace('{模板标题}',item.name)
|
||||||
|
str = str.replace('{模板内容}',item.prompt)
|
||||||
|
params.prompt = str
|
||||||
|
params.template = item.prompt
|
||||||
|
// 请求数据
|
||||||
|
try {
|
||||||
|
childTempList.value[index].loading = true
|
||||||
|
const data = await requestModelData()
|
||||||
|
childTempList.value[index].answer = data.answer;
|
||||||
|
if(isLast){
|
||||||
|
await onSaveTemp(childTempList.value[index])
|
||||||
|
}else{
|
||||||
|
// 保存重新研读后的结果
|
||||||
|
onEditResult(data.answer, index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
childTempList.value[index].loading = false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// 一键研读
|
||||||
|
else{
|
||||||
|
// 清空所有模板结果
|
||||||
|
childTempList.value.forEach(item => {
|
||||||
|
if (item.answer) {
|
||||||
|
item.answer = ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 设置滚动到第一个位置
|
||||||
|
messageElements.value[0].scrollIntoView({
|
||||||
|
behavior: 'smooth',
|
||||||
|
block: 'start',
|
||||||
|
})
|
||||||
|
|
||||||
|
processNext(0)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打字机效果完成 后继续研读下一个
|
||||||
|
const processNext = async (index) =>{
|
||||||
|
let str = prompt.value
|
||||||
|
// 当前项
|
||||||
|
const item = childTempList.value[index]
|
||||||
|
item.loading = true
|
||||||
|
str = str.replace('{模板标题}',item.name)
|
||||||
|
str = str.replace('{模板内容}',item.prompt)
|
||||||
|
params.prompt = str
|
||||||
|
params.template = item.prompt
|
||||||
|
// 请求数据
|
||||||
|
try {
|
||||||
|
const data = await requestModelData()
|
||||||
|
item.answer = data.answer
|
||||||
|
item.showTypewriter = true
|
||||||
|
|
||||||
|
|
||||||
|
// 保存
|
||||||
|
await onSaveTemp(item)
|
||||||
|
} finally {
|
||||||
|
item.loading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打字机完成后触发
|
||||||
|
const handleDone = (index) =>{
|
||||||
|
if(isAgain.value){
|
||||||
|
isAgain.value = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(index == childTempList.value.length - 1) return
|
||||||
|
outerContainer.value.scrollTo({
|
||||||
|
top: outerContainer.value.scrollHeight,
|
||||||
|
behavior: 'smooth',
|
||||||
|
});
|
||||||
|
processNext(index + 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置一个延迟函数 ms: 毫秒
|
||||||
|
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
|
||||||
|
// 请求大模型接口获取模板研读结果 知识库模型 or 教学大模型
|
||||||
|
const requestModelData = async () =>{
|
||||||
|
// 教学大模型
|
||||||
|
let data = null
|
||||||
|
if (curMode.value == 1) {
|
||||||
|
const res = await sendChart({
|
||||||
|
content: params.prompt,
|
||||||
|
conversationId: conversation_id.value,
|
||||||
|
stream: false
|
||||||
|
})
|
||||||
|
// 一键研读 设置一个1s 延迟 防止百度千帆请求过于频繁
|
||||||
|
if(!isAdjust.value){
|
||||||
|
await delay(1000); // 每个请求之间延迟 1 秒
|
||||||
|
}
|
||||||
|
data = res.data
|
||||||
|
}
|
||||||
|
// 知识库模型
|
||||||
else {
|
else {
|
||||||
for (let i = 0; i < index; i++) {
|
if (curMode.value == 3) {
|
||||||
sum += listDom[i].clientHeight
|
params.llm = 'deepseek-r1:8b'
|
||||||
}
|
}
|
||||||
listRef.value.scrollTop = sum + height
|
const res = await completion(params)
|
||||||
|
data = res.data
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const messageElements = ref([]); // 存储所有消息元素的引用
|
||||||
|
// 处理页面滚动
|
||||||
|
// const animationId = ref(null)
|
||||||
|
const animationIDs = ref([])
|
||||||
|
|
||||||
|
const outerContainer = ref()
|
||||||
|
let lastScrollTime = 0;
|
||||||
|
const scrollInterval = 200
|
||||||
|
const handleScroll = (index) => {
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - lastScrollTime >= scrollInterval) {
|
||||||
|
const container = document.querySelector('.container-right-list');
|
||||||
|
if(isAgain.value){
|
||||||
|
scrollToTmp(index)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
if (container) {
|
||||||
|
if(index == 0){
|
||||||
|
const item = messageElements.value[index]
|
||||||
|
if(item.clientHeight > outerContainer.value.clientHeight ){
|
||||||
|
item.scrollIntoView({ behavior: 'smooth', block: 'end' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// 平滑滚动到底部
|
||||||
|
const id = requestAnimationFrame(() => {
|
||||||
|
container.scrollTo({
|
||||||
|
top: container.scrollHeight,
|
||||||
|
behavior: 'smooth',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
animationIDs.value.push(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastScrollTime = now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理重新研读 滚动
|
||||||
|
const scrollToTmp = (index) =>{
|
||||||
|
// 最后一个 滚到底部
|
||||||
|
if(index == childTempList.value.length - 1){
|
||||||
|
const id = requestAnimationFrame(() => {
|
||||||
|
outerContainer.value.scrollTo({
|
||||||
|
top: outerContainer.value.scrollHeight,
|
||||||
|
behavior: 'smooth',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
animationIDs.value.push(id)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
const item = messageElements.value[index]
|
||||||
|
if(item.clientHeight > outerContainer.value.clientHeight ){
|
||||||
|
item.scrollIntoView({ behavior: 'smooth', block: 'end' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 模板切换
|
// 模板切换
|
||||||
const changeTemplate = (val) => {
|
const changeTemplate = (val) => {
|
||||||
ElMessageBox.confirm(
|
ElMessageBox.confirm(
|
||||||
|
@ -294,116 +497,10 @@ const onEdit = (index, item) => {
|
||||||
isEdit.value = true
|
isEdit.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重新研读
|
// 保存编辑后的研读内容
|
||||||
|
const onEditResult = async (answer, index) => {
|
||||||
|
|
||||||
const prompt = ref('')
|
|
||||||
|
|
||||||
// 重新研读
|
|
||||||
const isAgain = ref(false)
|
|
||||||
const againResult = async (index, item) => {
|
|
||||||
isAgain.value = true
|
|
||||||
isStarted.value[index] = false
|
|
||||||
childTempList.value[index].answer = ''
|
|
||||||
|
|
||||||
if (index == 0) {
|
|
||||||
listRef.value.scrollTop = 0
|
|
||||||
|
|
||||||
} else {
|
|
||||||
scrollToBottom(50, index)
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await nextTick()
|
|
||||||
childTempList.value[index].loading = true
|
|
||||||
item.aiShow = true
|
|
||||||
|
|
||||||
let str = cloneDeep(prompt.value)
|
|
||||||
str = str.replace('{模板标题}',item.name)
|
|
||||||
str = str.replace('{模板内容}',item.prompt)
|
|
||||||
params.prompt = str
|
|
||||||
params.template = item.prompt
|
|
||||||
|
|
||||||
let data = null;
|
|
||||||
// 教学大模型
|
|
||||||
if (curMode.value == 1) {
|
|
||||||
const res = await sendChart({
|
|
||||||
content: params.prompt,
|
|
||||||
conversationId: conversation_id.value,
|
|
||||||
stream: false
|
|
||||||
})
|
|
||||||
data = res.data
|
|
||||||
} else {
|
|
||||||
// 知识库模型
|
|
||||||
const res = await completion(params)
|
|
||||||
data = res.data
|
|
||||||
}
|
|
||||||
|
|
||||||
childTempList.value[index].answer = getResult(data.answer);
|
|
||||||
isStarted.value[index] = true
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
childTempList.value[index].loading = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
||||||
// 一键研读
|
|
||||||
const getCompletion = async () => {
|
|
||||||
isStarted.value = new Array(childTempList.length).fill(false)
|
|
||||||
isStarted.value[0] = true
|
|
||||||
|
|
||||||
childTempList.value.forEach(item => {
|
|
||||||
if (item.answer) {
|
|
||||||
item.answer = ''
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
for (let item of childTempList.value) {
|
|
||||||
try {
|
|
||||||
item.loading = true
|
|
||||||
item.aiShow = true
|
|
||||||
let str = cloneDeep(prompt.value)
|
|
||||||
str = str.replace('{模板标题}',item.name)
|
|
||||||
str = str.replace('{模板内容}',item.prompt)
|
|
||||||
params.prompt = str
|
|
||||||
params.template = item.prompt
|
|
||||||
// 教学大模型
|
|
||||||
let data = null
|
|
||||||
if (curMode.value == 1) {
|
|
||||||
const res = await sendChart({
|
|
||||||
content: params.prompt,
|
|
||||||
conversationId: conversation_id.value,
|
|
||||||
stream: false
|
|
||||||
})
|
|
||||||
await delay(1000); // 每个请求之间延迟 1 秒
|
|
||||||
data = res.data
|
|
||||||
}
|
|
||||||
// 知识库模型
|
|
||||||
else {
|
|
||||||
const res = await completion(params)
|
|
||||||
data = res.data
|
|
||||||
}
|
|
||||||
|
|
||||||
item.answer = getResult(data.answer)
|
|
||||||
onSaveTemp(item)
|
|
||||||
} finally {
|
|
||||||
item.loading = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleCompleteText = async (answer, index) => {
|
|
||||||
if (index < childTempList.value.length - 1) {
|
|
||||||
isStarted.value[index + 1] = true; // 开始显示下一个文本
|
|
||||||
}
|
|
||||||
if (isAgain.value) {
|
|
||||||
try {
|
|
||||||
await editTempResult({ id: childTempList.value[index].resultId, content: answer })
|
await editTempResult({ id: childTempList.value[index].resultId, content: answer })
|
||||||
} finally {
|
|
||||||
isAgain.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 替换分析结果
|
// 替换分析结果
|
||||||
|
@ -436,18 +533,13 @@ const onSaveTemp = async (item) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 去掉字符串中的 ### **
|
|
||||||
let getResult = (str) => {
|
|
||||||
let newStr = str.replace(/#+|(\*\*)/g, '');
|
|
||||||
return newStr
|
|
||||||
}
|
|
||||||
|
|
||||||
// 操作之后获取字模板
|
// 操作之后获取子模板
|
||||||
emitter.on('onGetChild', () => {
|
emitter.on('onGetChild', () => {
|
||||||
getChildTemplate()
|
getChildTemplate(true)
|
||||||
})
|
})
|
||||||
// 操作之后获取主模板
|
// 操作之后获取主模板
|
||||||
emitter.on('onGetMain', () => {
|
emitter.on('onGetMain====》', () => {
|
||||||
getTemplateList()
|
getTemplateList()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -513,7 +605,11 @@ onUnmounted(() => {
|
||||||
emitter.off('onGetMain');
|
emitter.off('onGetMain');
|
||||||
emitter.off('onGetChild');
|
emitter.off('onGetChild');
|
||||||
emitter.off('onSaveAdjust');
|
emitter.off('onSaveAdjust');
|
||||||
|
// 组件卸载时取消动画帧
|
||||||
|
animationIDs.value.forEach(id => cancelAnimationFrame(id))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -605,14 +701,15 @@ onUnmounted(() => {
|
||||||
|
|
||||||
.iconfont {
|
.iconfont {
|
||||||
margin-right: 3px;
|
margin-right: 3px;
|
||||||
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-button) {
|
:deep(.el-button) {
|
||||||
font-size: 13px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-ai1 {
|
.icon-zhongxinshiyang {
|
||||||
font-size: 18px;
|
font-size: 20px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,72 +1,109 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="typing-effect" ref="typingEffectRef">
|
<div class="typing-effect" ref="typingEffectRef">
|
||||||
<!-- <span v-html="displayedText"></span> -->
|
<!-- <span v-html="displayedText"></span> -->
|
||||||
<el-input
|
<!-- <el-input
|
||||||
v-model="displayedText"
|
v-model="currentText"
|
||||||
:autosize="{ minRows: 2 }"
|
:autosize="{ minRows: 2 }"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
readonly
|
readonly
|
||||||
resize="none"
|
resize="none"
|
||||||
style="width: 100%;"
|
style="width: 100%;"
|
||||||
input-style="border:none;outline: none;box-shadow:none;color:000;fontSize:14px"
|
input-style="border:none;outline: none;box-shadow:none;color:000;fontSize:14px"
|
||||||
/>
|
/> -->
|
||||||
|
<v-md-editor v-model="currentText" mode="preview" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, watch, nextTick } from 'vue';
|
import { ref, onMounted, watch, onUnmounted } from 'vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
text: {
|
text: {
|
||||||
type: [String, Object],
|
type: String,
|
||||||
required: true
|
required: true,
|
||||||
},
|
},
|
||||||
delay: {
|
speed: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 100 // 默认每个字符出现的延迟时间,单位是毫秒
|
default: 50, // 默认每个字符的展示间隔时间(毫秒)
|
||||||
|
},
|
||||||
|
charsPerFrame: {
|
||||||
|
type: Number,
|
||||||
|
default: 1, // 默认每次展示的字符数
|
||||||
|
},
|
||||||
|
showTypewriter: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true, // 是否展示打字机效果
|
||||||
},
|
},
|
||||||
aiShow: {
|
|
||||||
type: [Boolean] // 为true 只展示
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
const typingEffectRef = ref(null);
|
|
||||||
const emit = defineEmits(['complete', 'updateScroll']);
|
|
||||||
const displayedText = ref('');
|
|
||||||
const index = ref(0);
|
|
||||||
|
|
||||||
const type = async () => {
|
// 定义 emits
|
||||||
await nextTick()
|
const emit = defineEmits(['scroll','done']);
|
||||||
if(!props.aiShow) {
|
|
||||||
displayedText.value = props.text
|
// 数据
|
||||||
return
|
const currentText = ref(''); // 当前展示的文本
|
||||||
}
|
const currentCharIndex = ref(0); // 当前展示到的字符索引
|
||||||
if (index.value <= props.text.length) {
|
const isTyping = ref(false); // 是否正在展示
|
||||||
displayedText.value += props.text.charAt(index.value);
|
const animationFrameId = ref(null); // 用于存储 requestAnimationFrame 的 ID
|
||||||
index.value++;
|
|
||||||
|
// 打字机效果逻辑
|
||||||
|
const typeText = () => {
|
||||||
|
|
||||||
|
if (currentCharIndex.value < props.text.length) {
|
||||||
|
// 每次展示 charsPerFrame 个字符
|
||||||
|
currentText.value += props.text.slice(
|
||||||
|
currentCharIndex.value,
|
||||||
|
currentCharIndex.value + props.charsPerFrame
|
||||||
|
);
|
||||||
|
currentCharIndex.value += props.charsPerFrame;
|
||||||
|
emit('scroll'); // 触发滚动事件
|
||||||
|
// 使用 requestAnimationFrame 递归调用
|
||||||
|
animationFrameId.value = requestAnimationFrame(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
type();
|
typeText();
|
||||||
emit('updateScroll', typingEffectRef.value.clientHeight); // 每次添加新字符后滚动到底部
|
}, props.speed);
|
||||||
}, props.delay);
|
});
|
||||||
} else {
|
} else {
|
||||||
// 当所有字符都显示完毕时,触发 complete 事件
|
isTyping.value = false;
|
||||||
emit('complete',displayedText.value);
|
emit('done')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
// 直接展示全部内容
|
||||||
resetAndType();
|
const showFullText = () =>{
|
||||||
});
|
currentText.value = props.text
|
||||||
|
|
||||||
const resetAndType = () =>{
|
|
||||||
displayedText.value = '';
|
|
||||||
index.value = 0;
|
|
||||||
type();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监听 props 的变化,以便当传入的 text 或 delay 发生改变时重新开始打字机效果
|
// 启动打字机效果
|
||||||
watch([() => props.text, () => props.delay], resetAndType);
|
const startTypeWriter = () => {
|
||||||
|
isTyping.value = true;
|
||||||
|
currentText.value = '';
|
||||||
|
currentCharIndex.value = 0;
|
||||||
|
typeText();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 监听 text 的变化
|
||||||
|
watch(
|
||||||
|
() => props.text,
|
||||||
|
() => {
|
||||||
|
if(props.showTypewriter && props.text){
|
||||||
|
startTypeWriter();
|
||||||
|
} else {
|
||||||
|
showFullText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// 组件挂载时启动打字机效果
|
||||||
|
onMounted(() => {
|
||||||
|
// startTypeWriter();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 组件卸载时取消动画帧
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (animationFrameId.value) {
|
||||||
|
cancelAnimationFrame(animationFrameId.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -74,4 +111,12 @@ watch([() => props.text, () => props.delay], resetAndType);
|
||||||
:deep(.el-textarea__inner:hover){
|
:deep(.el-textarea__inner:hover){
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.typing-effect{
|
||||||
|
:deep(.github-markdown-body){
|
||||||
|
padding: 0;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
|
@ -23,7 +23,7 @@
|
||||||
</li>
|
</li>
|
||||||
<li v-if="computedregistertype!=4" :class="computedregistertype==1 || computedregistertype==2 ? '':'pointer-events'" @click="onUserTo('/joinSchool')">加入学校</li>
|
<li v-if="computedregistertype!=4" :class="computedregistertype==1 || computedregistertype==2 ? '':'pointer-events'" @click="onUserTo('/joinSchool')">加入学校</li>
|
||||||
<li @click="onUserTo('/profile')">个人中心</li>
|
<li @click="onUserTo('/profile')">个人中心</li>
|
||||||
<li v-if="isStadium() !== true" @click="onUserTo('/schoolManagement')">学校管理</li>
|
<li v-if="isStadium() !== true && checkRole(['admin','headmaster'])" @click="onUserTo('/schoolManagement')">学校管理</li>
|
||||||
<li v-if="isStadium() !== true" @click="onUserTo('/class')">班级中心</li>
|
<li v-if="isStadium() !== true" @click="onUserTo('/class')">班级中心</li>
|
||||||
<li @click="logout">退出登录</li>
|
<li @click="logout">退出登录</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -65,7 +65,7 @@ import pkc from "../../../../../package.json"
|
||||||
import defaultUserImg from '@/assets/images/img-avatar.png'
|
import defaultUserImg from '@/assets/images/img-avatar.png'
|
||||||
import { sessionStore } from '@/utils/store'
|
import { sessionStore } from '@/utils/store'
|
||||||
import {toLinkLeftWeb} from "@/utils/tool"
|
import {toLinkLeftWeb} from "@/utils/tool"
|
||||||
|
import { checkRole } from '@/utils/permission'
|
||||||
|
|
||||||
const { ipcRenderer } = window.electron || {}
|
const { ipcRenderer } = window.electron || {}
|
||||||
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
|
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
|
||||||
|
@ -86,6 +86,7 @@ const defaultImg = ['/img/avatar-default.jpg','/images/img-avatar.png','/src/ass
|
||||||
|
|
||||||
//是否是基地人员
|
//是否是基地人员
|
||||||
const isStadium = () => {
|
const isStadium = () => {
|
||||||
|
// console.log('isStadium',userStore.roles )
|
||||||
let user = userStore.user
|
let user = userStore.user
|
||||||
let roles = user.roles
|
let roles = user.roles
|
||||||
return roles.some(item => item.roleKey === 'stadium')
|
return roles.some(item => item.roleKey === 'stadium')
|
||||||
|
|
|
@ -25,7 +25,7 @@ import log from 'electron-log/renderer' // 渲染进程日志-文件记录
|
||||||
import customComponent from '@/components/common' // 自定义组件
|
import customComponent from '@/components/common' // 自定义组件
|
||||||
import plugins from './plugins' // plugins插件
|
import plugins from './plugins' // plugins插件
|
||||||
import useUserStore from '@/store/modules/user'
|
import useUserStore from '@/store/modules/user'
|
||||||
import aiAudio from 'aix-plugins-aitools' // 文字转语音插件
|
import aiTools from 'aix-plugins-aitools' // 文字转语音插件
|
||||||
import '../../../node_modules/aix-plugins-aitools/aitools.css'
|
import '../../../node_modules/aix-plugins-aitools/aitools.css'
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ app.use(router)
|
||||||
.use(plugins)
|
.use(plugins)
|
||||||
.use(Icon)
|
.use(Icon)
|
||||||
.use(Directive)
|
.use(Directive)
|
||||||
.use(aiAudio)
|
.use(aiTools)
|
||||||
.use(VMdEditor)
|
.use(VMdEditor)
|
||||||
.mount('#app')
|
.mount('#app')
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,160 @@
|
||||||
|
import {sessionToken, uploadSingleFileToEos} from "@/api/file";
|
||||||
|
import CryptoJS from 'crypto-js'
|
||||||
|
import {ElMessageBox} from "element-plus";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 回调函数
|
||||||
|
* @param {Function} callGetToken - 获取token回调
|
||||||
|
* @param {Function} callUpload - 成功上传EOS回调
|
||||||
|
* @param {Function} callProgress - 上传进度回调
|
||||||
|
* @param {Function} callUploadSuccess - 完全上传成功回调
|
||||||
|
*/
|
||||||
|
type CallBack = {
|
||||||
|
callGetToken?: (e:any)=>any;
|
||||||
|
callUploadFile?: (e:any)=>any;
|
||||||
|
callProgress?: (e:any,p:number)=>any;
|
||||||
|
callUploadSuccess?: (e:any)=>any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 简单文件上传参数
|
||||||
|
* @param {string} _bucket - 文件桶
|
||||||
|
* @param {string} id - 文件id
|
||||||
|
* @param {string} filePath - 文件路径
|
||||||
|
* @param {string} fileMd5 - 文件MD5
|
||||||
|
* @param {string} fileNewName - 文件新名字
|
||||||
|
* @param {string} fileName - 文件名
|
||||||
|
* @param {string} fileSize - 文件大小
|
||||||
|
* @param {string} fileSuffix - 文件后缀
|
||||||
|
* @param {string} fileType - 文件类型
|
||||||
|
*/
|
||||||
|
type SingleUploadData = {
|
||||||
|
_bucket?: string,
|
||||||
|
id?: string,
|
||||||
|
filePath?: string,
|
||||||
|
fileMd5?: string,
|
||||||
|
fileNewName?: string,
|
||||||
|
fileName?: string,
|
||||||
|
fileSize?: number,
|
||||||
|
fileSuffix?: string,
|
||||||
|
fileType?: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
const S3Data = {
|
||||||
|
apiVersion: "2006-03-01",
|
||||||
|
accessKeyId: "", // 服务端获取到的 access key ID
|
||||||
|
secretAccessKey: "", // 服务端获取到的 secret access key
|
||||||
|
endpoint: "",
|
||||||
|
sessionToken: '',
|
||||||
|
signatureVersion: "v2",
|
||||||
|
sslEnabled: true // 是否启用 HTTPS 连接
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 上传
|
||||||
|
* @param file 文件实体
|
||||||
|
* @param {SingleUploadData} uploadData 文件上传参数
|
||||||
|
* @param {CallBack} callBack - 回调函数
|
||||||
|
*/
|
||||||
|
const uploadSingleToEos = async (file:File, uploadData: SingleUploadData, callBack?: CallBack) => {
|
||||||
|
console.log(file)
|
||||||
|
//去服务端拿授权
|
||||||
|
let res = await sessionToken().catch((err:any)=>{
|
||||||
|
ElMessageBox.alert(err)
|
||||||
|
});
|
||||||
|
S3Data.accessKeyId = res.data.accessKeyId
|
||||||
|
S3Data.secretAccessKey = res.data.secretAccessKey
|
||||||
|
S3Data.endpoint = res.data.endPoint
|
||||||
|
S3Data.sessionToken = res.data.sessionToken
|
||||||
|
|
||||||
|
uploadData = uploadData?uploadData:{}
|
||||||
|
uploadData._bucket = res.data.bucket
|
||||||
|
//如果文件名不存在,则使用时间戳为名字
|
||||||
|
uploadData.id = crypto.randomUUID();
|
||||||
|
uploadData.fileMd5 = await getFileMD5(file);
|
||||||
|
uploadData.fileName = file.name?file.name:(new Date().getTime()+"");
|
||||||
|
if (uploadData.fileName.lastIndexOf(".") === -1) {
|
||||||
|
uploadData.fileSuffix = ""
|
||||||
|
uploadData.fileNewName = uploadData.id
|
||||||
|
}else {
|
||||||
|
uploadData.fileSuffix = uploadData.fileName.substring(uploadData.fileName.lastIndexOf(".")+1)
|
||||||
|
uploadData.fileNewName = uploadData.id + "." + uploadData.fileSuffix
|
||||||
|
}
|
||||||
|
uploadData.filePath = getEosFileKey(uploadData.id, uploadData.fileSuffix);
|
||||||
|
uploadData.fileSize = file.size
|
||||||
|
uploadData.fileType = file.type
|
||||||
|
console.log(uploadData)
|
||||||
|
//回调获取token
|
||||||
|
callBack?.callGetToken && callBack.callGetToken(res.data)
|
||||||
|
|
||||||
|
//将文件上传到EOS
|
||||||
|
let uploadRes = await uploadFile(file,uploadData,callBack).catch((err)=>{
|
||||||
|
ElMessageBox.alert(err)
|
||||||
|
});
|
||||||
|
if (!uploadRes) return
|
||||||
|
//回调成功上传EOS
|
||||||
|
callBack?.callGetToken && callBack.callGetToken(uploadRes)
|
||||||
|
|
||||||
|
//去服务端确认是否已经完成上传,并保存文件上传信息
|
||||||
|
let saveUploadRes = await uploadSingleFileToEos(uploadData)
|
||||||
|
//回调整个文件上传完成
|
||||||
|
callBack?.callUploadSuccess && callBack.callUploadSuccess(saveUploadRes)
|
||||||
|
return saveUploadRes
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description 上传文件
|
||||||
|
* @param file 文件实体
|
||||||
|
* @param uploadData 上传文件参数
|
||||||
|
* @param callBack 回调函数
|
||||||
|
*/
|
||||||
|
const uploadFile = (file:File, uploadData: SingleUploadData,callBack?:CallBack) =>{
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const s3 = new AWS.S3(S3Data);
|
||||||
|
let params = {
|
||||||
|
Key: uploadData.filePath,
|
||||||
|
Bucket: uploadData._bucket,
|
||||||
|
ContentType: file.type,
|
||||||
|
Body: file
|
||||||
|
}
|
||||||
|
s3.putObject(params, function (err:any, data:any) {
|
||||||
|
if (err) {
|
||||||
|
reject(data)
|
||||||
|
}else {
|
||||||
|
resolve(data)
|
||||||
|
}
|
||||||
|
}).on('httpUploadProgress', function(evt:any) {
|
||||||
|
//回调上传进度
|
||||||
|
callBack?.callProgress && callBack.callProgress(evt,Math.round((evt.loaded / evt.total) * 100));
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 生成EOS文件key
|
||||||
|
* @param uuid 文件id
|
||||||
|
* @param suffix 文件后缀
|
||||||
|
*/
|
||||||
|
const getEosFileKey = (uuid:string, suffix:string) => {
|
||||||
|
let date = new Date()
|
||||||
|
let year = date.getFullYear()
|
||||||
|
let month = date.getMonth() + 1
|
||||||
|
let day = date.getDate()
|
||||||
|
return year + "/" + month + "/" + day + "/" + uuid + "." + suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 生成文件MD5
|
||||||
|
* @param file
|
||||||
|
*/
|
||||||
|
const getFileMD5 = (file:File):Promise<string> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let reader = new FileReader();
|
||||||
|
reader.readAsArrayBuffer(file);
|
||||||
|
reader.onload = function () {
|
||||||
|
let buffer = reader.result as ArrayBuffer;
|
||||||
|
let md5 = CryptoJS.MD5(buffer).toString();
|
||||||
|
resolve(md5)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export {uploadSingleToEos}
|
|
@ -0,0 +1,51 @@
|
||||||
|
import useUserStore from '@/store/modules/user'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字符权限校验
|
||||||
|
* @param {Array} value 校验值
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
export function checkPermi(value) {
|
||||||
|
if (value && value instanceof Array && value.length > 0) {
|
||||||
|
const permissions = useUserStore().permissions
|
||||||
|
const permissionDatas = value
|
||||||
|
const all_permission = "*:*:*";
|
||||||
|
|
||||||
|
const hasPermission = permissions.some(permission => {
|
||||||
|
return all_permission === permission || permissionDatas.includes(permission)
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!hasPermission) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色权限校验
|
||||||
|
* @param {Array} value 校验值
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
export function checkRole(value) {
|
||||||
|
if (value && value instanceof Array && value.length > 0) {
|
||||||
|
const roles = useUserStore().roles
|
||||||
|
const permissionRoles = value
|
||||||
|
const super_admin = "admin";
|
||||||
|
|
||||||
|
const hasRole = roles.some(role => {
|
||||||
|
return super_admin === role || permissionRoles.includes(role)
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!hasRole) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
console.error(`need roles! Like checkRole="['admin','editor']"`)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
<el-tab-pane :label="item.label" style="text-align:left" stretch="true">
|
<el-tab-pane :label="item.label" style="text-align:left" stretch="true">
|
||||||
<template v-if="item.stuList.length > 0">
|
<template v-if="item.stuList.length > 0">
|
||||||
<template v-for="(stuItem,stuIndex) in item.stuList" :key="stuIndex">
|
<template v-for="(stuItem,stuIndex) in item.stuList" :key="stuIndex">
|
||||||
<el-tag style="margin:5px 10px 0 0" type="primary">{{ stuItem.studentname }}:{{ stuItem.getScore }}分</el-tag>
|
<el-tag style="margin:5px 10px 0 0" type="primary">{{ stuItem.studentname }}:{{ stuItem.point }}分</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
|
@ -93,6 +93,8 @@ watch(() => useOverview.tableList, () => {
|
||||||
}else{
|
}else{
|
||||||
hasStudents.value = useOverview.tableList.filter(item => useOverview.allData[0].hasAnswers.includes(item.studentid)).map(item => item);
|
hasStudents.value = useOverview.tableList.filter(item => useOverview.allData[0].hasAnswers.includes(item.studentid)).map(item => item);
|
||||||
}
|
}
|
||||||
|
console.log(hasStudents.value,'hasStudents.value');
|
||||||
|
|
||||||
showStudents(0)
|
showStudents(0)
|
||||||
},{deep: true})
|
},{deep: true})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -376,12 +376,12 @@ const getClassWorkStudentList = (rowId) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const allScore = evalarray.reduce((acc, cur) => acc + cur.score, 0)
|
const allScore = evalarray.reduce((acc, cur) => acc + cur.teacherRating, 0)
|
||||||
//console.log(evalarray, 'evalarray------------------------------------')
|
//console.log(evalarray, 'evalarray------------------------------------')
|
||||||
if (feedcount > 0) {
|
if (feedcount > 0) {
|
||||||
// 多个题目的总得分率: 正确题数/(题目数*100)
|
// 多个题目的总得分率: 正确题数/(题目数*100)
|
||||||
response.rows[i].scoingRate = ((score / allScore) * 100).toFixed(0) + '%'
|
response.rows[i].scoingRate = ((score / allScore) * 100).toFixed(0) + '%'
|
||||||
response.rows[i].getScore = score
|
response.rows[i].getScore = allScore
|
||||||
} else {
|
} else {
|
||||||
response.rows[i].scoingRate = '0%'
|
response.rows[i].scoingRate = '0%'
|
||||||
response.rows[i].getScore = 0
|
response.rows[i].getScore = 0
|
||||||
|
|
|
@ -1,267 +1,91 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="page-mindmap flex flex-col h-full">
|
<aiMindMap
|
||||||
<div class="mindmap-header flex items-center justify-between pl-5">
|
@exportImg="exportImg"
|
||||||
<div class="flex w-1/2 items-center justify-between">
|
@createMindMap="createMindMap"
|
||||||
<div>
|
@reloadMindMap="reloadMindMap"
|
||||||
<b>AI思维导图</b> <span class="ml-5">《{{ curNode.itemtitle }}》</span>
|
ref="mindMapRef"
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<template v-if="isEdit">
|
|
||||||
<el-button class="mr-3" @click="isEdit = false">取消</el-button>
|
|
||||||
<el-button type="success" class="mr-3" @click="isEdit = false">保存</el-button>
|
|
||||||
</template>
|
|
||||||
<!-- <el-button v-else type="primary" class="mr-3" @click="isEdit = true">编辑</el-button>-->
|
|
||||||
<!-- <el-select v-model="curMode" class="mr-3 w-30">
|
|
||||||
<el-option
|
|
||||||
v-for="item in modeOptions"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
/>
|
||||||
</el-select>-->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
导出清晰度:<el-input-number v-model="scale" :min="1" :max="10" />数字越大越清晰,但图片大小会越大
|
|
||||||
<el-button @click="outputImg" type="primary">导出图片</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="mindmap-main flex flex-1" style="overflow: auto;">
|
|
||||||
<div class="w-1/3 h-full p-3 main-left flex flex-col" v-loading="loadingAnswer" style="overflow: auto;">
|
|
||||||
<div class="flex flex-1" style="overflow: auto;">
|
|
||||||
<v-md-editor v-model="resMarkdown" :mode="isEdit ? 'edit' : 'preview'" />
|
|
||||||
</div>
|
|
||||||
<div class="main-left-ipt">
|
|
||||||
<el-input
|
|
||||||
v-model="textVal"
|
|
||||||
style="max-width: 600px"
|
|
||||||
placeholder="请输入信息对内容进一步调整"
|
|
||||||
class="input-with-select"
|
|
||||||
>
|
|
||||||
<template #append>
|
|
||||||
<el-icon size="20" style="cursor: pointer;" @click="sendMessage"><Position /></el-icon>
|
|
||||||
</template>
|
|
||||||
</el-input>
|
|
||||||
<!-- <el-input style="float: left;" v-model="textVal" size="large" placeholder="请输入信息对内容进一步调整" /><el-button>发送</el-button>-->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="w-2/3 h-full main-right">
|
|
||||||
<mindmap v-if="rootData" :timetravel="true" :drag="true" :zoom="true" :edit="true"
|
|
||||||
:center-btn="true" :fit-btn="true" :ctm="true" :add-node-btn="true"
|
|
||||||
v-model="rootData"></mindmap>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive, onMounted, computed, watch } from 'vue'
|
import {onMounted, ref} from "vue";
|
||||||
import { Position } from "@element-plus/icons-vue"
|
// import aiMindMap from './mindMapAITools.vue'
|
||||||
import { sessionStore } from '@/utils/store'
|
import {sessionStore} from "@/utils/store";
|
||||||
import { modelList, completion, modelChat } from '@/api/mode/index.js'
|
import {editTempResult, modelList, tempResult, tempSave} from "@/api/mode";
|
||||||
import { createChart, sendChart } from '@/api/ai/index'
|
import {exportImg64File} from "@/utils/talkFile";
|
||||||
import { Transformer } from 'markmap-lib'
|
import useUserStore from '@/store/modules/user'
|
||||||
import mindmap from 'vue3-mindmap'
|
const { user } = useUserStore()
|
||||||
import html2canvas from 'html2canvas'
|
|
||||||
import 'vue3-mindmap/dist/style.css'
|
|
||||||
import {exportImg64File} from "@/utils/talkFile";
|
|
||||||
import axios from 'axios'
|
|
||||||
|
|
||||||
const transformer = new Transformer()
|
const showMap = ref(false)
|
||||||
|
const prompt = ref('')
|
||||||
// 当前节点
|
const url = ref("https://ai.ysaix.com:7865/chat")
|
||||||
const curNode = reactive({})
|
|
||||||
|
|
||||||
const textVal = ref(``)
|
|
||||||
|
|
||||||
const loadingAnswer = ref(false)
|
|
||||||
|
|
||||||
const scale = ref(5)
|
|
||||||
|
|
||||||
// const textVal = computed(() => {
|
|
||||||
// return `生成${curNode.itemtitle}的教学思维导图,按照markdown的格式编写,只返回markdown的部分`
|
|
||||||
// })
|
|
||||||
|
|
||||||
const curMode = ref(2)
|
|
||||||
const modeOptions = ref([
|
|
||||||
{
|
|
||||||
label: '教学大模型',
|
|
||||||
value: 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '知识库模型',
|
|
||||||
value: 2,
|
|
||||||
}
|
|
||||||
])
|
|
||||||
|
|
||||||
const isEdit = ref(false)
|
|
||||||
|
|
||||||
// AI 对话
|
|
||||||
const resMarkdown = ref(``)
|
|
||||||
const params = reactive({
|
|
||||||
prompt: '',
|
|
||||||
dataset_id: '',
|
|
||||||
template: ''
|
|
||||||
})
|
|
||||||
const messages = ref([
|
|
||||||
{
|
|
||||||
role: 'user',
|
|
||||||
content: ''
|
|
||||||
}
|
|
||||||
])
|
|
||||||
const aiConversation = async () => {
|
|
||||||
console.log(prompt.value)
|
|
||||||
// return
|
|
||||||
// params.prompt = prompt.value.replace(/{模板名称}/g, '')
|
|
||||||
// 暂时用死数据
|
|
||||||
// let str = '针对高中语文必修上册-人教版《静女》这一课根据设置情境、引导学习进行课件教学PPT内容设计,只需要涉及到设置情境、引导学习的内容即可,不需要封面、结尾和其它内容。'
|
|
||||||
// messages.value[0].content = str
|
|
||||||
params.prompt = prompt.value
|
|
||||||
// 教学大模型
|
|
||||||
loadingAnswer.value = true
|
|
||||||
if (curMode.value == 1) {
|
|
||||||
const res = await sendChart({
|
|
||||||
content: params.prompt,
|
|
||||||
conversationId: conversation_id.value,
|
|
||||||
stream: false
|
|
||||||
})
|
|
||||||
resMarkdown.value = res.data.answer.replaceAll('```markdown','').replaceAll('```', '')
|
|
||||||
}
|
|
||||||
// 知识库模型
|
|
||||||
else {
|
|
||||||
let data = {
|
|
||||||
"messages": [
|
|
||||||
{
|
|
||||||
"role": "user",
|
|
||||||
"content": params.prompt
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
const res = await text2mindmap(data).finally(() => {
|
|
||||||
loadingAnswer.value = false
|
|
||||||
})
|
|
||||||
console.log(res)
|
|
||||||
resMarkdown.value = res.data.answer.content.replaceAll('```markdown','').replaceAll('```', '')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const sendMessage = async () => {
|
|
||||||
loadingAnswer.value = true
|
|
||||||
rootData.value = null
|
|
||||||
let data = {
|
|
||||||
"messages": [
|
|
||||||
{
|
|
||||||
"role":"assiatant",
|
|
||||||
"content": resMarkdown.value
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"role": "user",
|
|
||||||
"content": `${textVal.value},${prompt.value}`
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
let res = await text2mindmap(data).finally(() => {
|
|
||||||
loadingAnswer.value = false
|
|
||||||
})
|
|
||||||
resMarkdown.value = res.data.answer.content.replaceAll('```markdown','').replaceAll('```', '')
|
|
||||||
}
|
|
||||||
|
|
||||||
const text2mindmap =(data)=> {
|
|
||||||
return axios({
|
|
||||||
url: "https://ai.ysaix.com:7865/chat",
|
|
||||||
method: "post",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
Accept: "*/*",
|
|
||||||
},
|
|
||||||
data:data
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询prompt 替换
|
|
||||||
const prompt = ref('')
|
|
||||||
const getPrompt = async () => {
|
|
||||||
const { rows } = await modelList({ model: 5 })
|
|
||||||
let str = rows.find((item) => item.name.indexOf('思维导图') != -1).prompt
|
|
||||||
|
|
||||||
|
let curNode = sessionStore.get('subject.curNode')
|
||||||
|
const title = ref(curNode.itemtitle)
|
||||||
|
let curModel = ref({})
|
||||||
|
const getPrompt = async () => {
|
||||||
|
let str = curModel.value.prompt
|
||||||
str = str.replace('{学段}', curNode.edustage)
|
str = str.replace('{学段}', curNode.edustage)
|
||||||
str = str.replace('{学科}', curNode.edusubject)
|
str = str.replace('{学科}', curNode.edusubject)
|
||||||
let bookV = curNode.roottitle + '版'
|
let bookV = curNode.roottitle + '版'
|
||||||
str = str.replace('{教材版本}', bookV)
|
str = str.replace('{教材版本}', bookV)
|
||||||
str = str.replace('{课程名称}', `《${curNode.itemtitle}》`)
|
str = str.replace('{课程名称}', `《${curNode.itemtitle}》`)
|
||||||
prompt.value = str
|
prompt.value = str
|
||||||
}
|
|
||||||
|
|
||||||
// 千帆创建对话
|
|
||||||
const conversation_id = ref('')
|
|
||||||
const getChartId = async () => {
|
|
||||||
const res = await createChart()
|
|
||||||
conversation_id.value = res.data.conversation_id
|
|
||||||
// ai 对话
|
|
||||||
aiConversation()
|
|
||||||
}
|
|
||||||
|
|
||||||
const rootData = ref(null)
|
|
||||||
|
|
||||||
const degure = (item) => {
|
|
||||||
item.name = item.content.replace(/<[^>]*>/g, '');;
|
|
||||||
if (item.children && item.children.length) {
|
|
||||||
item.children.forEach(item2 => {
|
|
||||||
degure(item2)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const outputImg = () => {
|
const exportImg = (data) => {
|
||||||
let svg = window.document.getElementById('Mindmap_svg-wrapper_fgvb6')
|
exportImg64File(data, `${curNode.itemtitle}思维导图`)
|
||||||
// let das = svg.querySelectorAll('.Mindmap_root_fgvb6')[0]
|
}
|
||||||
html2canvas(svg,{
|
|
||||||
scale: scale.value
|
const createMindMap = async (data) => {
|
||||||
}).then((canvas) => {
|
if (tempData.value) {
|
||||||
const dataUrl = canvas.toDataURL()
|
tempData.value.content = data
|
||||||
exportImg64File(dataUrl, `${curNode.itemtitle}思维导图`)
|
await editTempResult(tempData.value)
|
||||||
|
}else {
|
||||||
|
const item = {
|
||||||
|
mainModelId: 5,
|
||||||
|
modelId: curModel.value.id,
|
||||||
|
content: data,
|
||||||
|
ex1: curNode.id
|
||||||
|
}
|
||||||
|
await tempSave(item)
|
||||||
|
await getTempData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const reloadMindMap = async (data) => {
|
||||||
|
tempData.value.content = data
|
||||||
|
await editTempResult(tempData.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const getTempData = async () => {
|
||||||
|
const { rows } = await tempResult({
|
||||||
|
mainModelId: 5,
|
||||||
|
modelId: curModel.value.id,
|
||||||
|
ex1: curNode.id,
|
||||||
|
createUser: user.userId
|
||||||
})
|
})
|
||||||
// mm.value.fit()
|
tempData.value = rows?rows[0]:null
|
||||||
}
|
}
|
||||||
// 初始化
|
|
||||||
onMounted(() => {
|
|
||||||
let data = sessionStore.get('subject.curNode')
|
|
||||||
Object.assign(curNode, data)
|
|
||||||
|
|
||||||
// 获取提示词
|
const reloadData = ref('')
|
||||||
getPrompt()
|
const tempData = ref(null)
|
||||||
// 获取百度千帆会话ID
|
const mindMapRef = ref(null)
|
||||||
getChartId()
|
onMounted(async () => {
|
||||||
|
const { rows } = await modelList({ model: 5 })
|
||||||
})
|
curModel.value = rows.find((item) => item.name.indexOf('思维导图') != -1)
|
||||||
// 监听 initValue 的变化
|
await getTempData()
|
||||||
watch(() => resMarkdown.value, () => {
|
reloadData.value = tempData.value?tempData.value.content:'';
|
||||||
const { root } = transformer.transform(resMarkdown.value)
|
await getPrompt()
|
||||||
degure(root)
|
mindMapRef.value.initData({
|
||||||
rootData.value = [root]
|
reloadData: reloadData.value,
|
||||||
console.log(rootData.value)
|
title: title.value,
|
||||||
})
|
prompt: prompt.value,
|
||||||
|
url: url.value
|
||||||
|
})
|
||||||
|
// showMap.value = true
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.mindmap-header {
|
|
||||||
background: #fff;
|
|
||||||
height: 45px;
|
|
||||||
border-radius: 5px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
.main-left {
|
|
||||||
background: #fff;
|
|
||||||
border-radius: 5px;
|
|
||||||
.main-left-ipt {
|
|
||||||
height: 40px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.main-right{
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
svg {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -0,0 +1,267 @@
|
||||||
|
<template>
|
||||||
|
<div class="page-mindmap flex flex-col h-full">
|
||||||
|
<div class="mindmap-header flex items-center justify-between pl-5">
|
||||||
|
<div class="flex w-1/2 items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<b>AI思维导图</b> <span class="ml-5">《{{ curNode.itemtitle }}》</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<template v-if="isEdit">
|
||||||
|
<el-button class="mr-3" @click="isEdit = false">取消</el-button>
|
||||||
|
<el-button type="success" class="mr-3" @click="isEdit = false">保存</el-button>
|
||||||
|
</template>
|
||||||
|
<!-- <el-button v-else type="primary" class="mr-3" @click="isEdit = true">编辑</el-button>-->
|
||||||
|
<!-- <el-select v-model="curMode" class="mr-3 w-30">
|
||||||
|
<el-option
|
||||||
|
v-for="item in modeOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
导出清晰度:<el-input-number v-model="scale" :min="1" :max="10" />数字越大越清晰,但图片大小会越大
|
||||||
|
<el-button @click="outputImg" type="primary">导出图片</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mindmap-main flex flex-1" style="overflow: auto;">
|
||||||
|
<div class="w-1/3 h-full p-3 main-left flex flex-col" v-loading="loadingAnswer" style="overflow: auto;">
|
||||||
|
<div class="flex flex-1" style="overflow: auto;">
|
||||||
|
<v-md-editor v-model="resMarkdown" :mode="isEdit ? 'edit' : 'preview'" />
|
||||||
|
</div>
|
||||||
|
<div class="main-left-ipt">
|
||||||
|
<el-input
|
||||||
|
v-model="textVal"
|
||||||
|
style="max-width: 600px"
|
||||||
|
placeholder="请输入信息对内容进一步调整"
|
||||||
|
class="input-with-select"
|
||||||
|
>
|
||||||
|
<template #append>
|
||||||
|
<el-icon size="20" style="cursor: pointer;" @click="sendMessage"><Position /></el-icon>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
<!-- <el-input style="float: left;" v-model="textVal" size="large" placeholder="请输入信息对内容进一步调整" /><el-button>发送</el-button>-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="w-2/3 h-full main-right">
|
||||||
|
<mindmap v-if="rootData" :timetravel="true" :drag="true" :zoom="true" :edit="true"
|
||||||
|
:center-btn="true" :fit-btn="true" :ctm="true" :add-node-btn="true"
|
||||||
|
v-model="rootData"></mindmap>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, reactive, onMounted, computed, watch } from 'vue'
|
||||||
|
import { Position } from "@element-plus/icons-vue"
|
||||||
|
import { sessionStore } from '@/utils/store'
|
||||||
|
import { modelList, completion, modelChat } from '@/api/mode/index.js'
|
||||||
|
import { createChart, sendChart } from '@/api/ai/index'
|
||||||
|
import { Transformer } from 'markmap-lib'
|
||||||
|
import mindmap from 'vue3-mindmap'
|
||||||
|
import html2canvas from 'html2canvas'
|
||||||
|
import 'vue3-mindmap/dist/style.css'
|
||||||
|
import {exportImg64File} from "@/utils/talkFile";
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
|
const transformer = new Transformer()
|
||||||
|
|
||||||
|
// 当前节点
|
||||||
|
const curNode = reactive({})
|
||||||
|
|
||||||
|
const textVal = ref(``)
|
||||||
|
|
||||||
|
const loadingAnswer = ref(false)
|
||||||
|
|
||||||
|
const scale = ref(5)
|
||||||
|
|
||||||
|
// const textVal = computed(() => {
|
||||||
|
// return `生成${curNode.itemtitle}的教学思维导图,按照markdown的格式编写,只返回markdown的部分`
|
||||||
|
// })
|
||||||
|
|
||||||
|
const curMode = ref(2)
|
||||||
|
const modeOptions = ref([
|
||||||
|
{
|
||||||
|
label: '教学大模型',
|
||||||
|
value: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '知识库模型',
|
||||||
|
value: 2,
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
const isEdit = ref(false)
|
||||||
|
|
||||||
|
// AI 对话
|
||||||
|
const resMarkdown = ref(``)
|
||||||
|
const params = reactive({
|
||||||
|
prompt: '',
|
||||||
|
dataset_id: '',
|
||||||
|
template: ''
|
||||||
|
})
|
||||||
|
const messages = ref([
|
||||||
|
{
|
||||||
|
role: 'user',
|
||||||
|
content: ''
|
||||||
|
}
|
||||||
|
])
|
||||||
|
const aiConversation = async () => {
|
||||||
|
console.log(prompt.value)
|
||||||
|
// return
|
||||||
|
// params.prompt = prompt.value.replace(/{模板名称}/g, '')
|
||||||
|
// 暂时用死数据
|
||||||
|
// let str = '针对高中语文必修上册-人教版《静女》这一课根据设置情境、引导学习进行课件教学PPT内容设计,只需要涉及到设置情境、引导学习的内容即可,不需要封面、结尾和其它内容。'
|
||||||
|
// messages.value[0].content = str
|
||||||
|
params.prompt = prompt.value
|
||||||
|
// 教学大模型
|
||||||
|
loadingAnswer.value = true
|
||||||
|
if (curMode.value == 1) {
|
||||||
|
const res = await sendChart({
|
||||||
|
content: params.prompt,
|
||||||
|
conversationId: conversation_id.value,
|
||||||
|
stream: false
|
||||||
|
})
|
||||||
|
resMarkdown.value = res.data.answer.replaceAll('```markdown','').replaceAll('```', '')
|
||||||
|
}
|
||||||
|
// 知识库模型
|
||||||
|
else {
|
||||||
|
let data = {
|
||||||
|
"messages": [
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": params.prompt
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
const res = await text2mindmap(data).finally(() => {
|
||||||
|
loadingAnswer.value = false
|
||||||
|
})
|
||||||
|
console.log(res)
|
||||||
|
resMarkdown.value = res.data.answer.content.replaceAll('```markdown','').replaceAll('```', '')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const sendMessage = async () => {
|
||||||
|
loadingAnswer.value = true
|
||||||
|
rootData.value = null
|
||||||
|
let data = {
|
||||||
|
"messages": [
|
||||||
|
{
|
||||||
|
"role":"assiatant",
|
||||||
|
"content": resMarkdown.value
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": `${textVal.value},${prompt.value}`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
let res = await text2mindmap(data).finally(() => {
|
||||||
|
loadingAnswer.value = false
|
||||||
|
})
|
||||||
|
resMarkdown.value = res.data.answer.content.replaceAll('```markdown','').replaceAll('```', '')
|
||||||
|
}
|
||||||
|
|
||||||
|
const text2mindmap =(data)=> {
|
||||||
|
return axios({
|
||||||
|
url: "https://ai.ysaix.com:7865/chat",
|
||||||
|
method: "post",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Accept: "*/*",
|
||||||
|
},
|
||||||
|
data:data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询prompt 替换
|
||||||
|
const prompt = ref('')
|
||||||
|
const getPrompt = async () => {
|
||||||
|
const { rows } = await modelList({ model: 5 })
|
||||||
|
let str = rows.find((item) => item.name.indexOf('思维导图') != -1).prompt
|
||||||
|
|
||||||
|
str = str.replace('{学段}', curNode.edustage)
|
||||||
|
str = str.replace('{学科}', curNode.edusubject)
|
||||||
|
let bookV = curNode.roottitle + '版'
|
||||||
|
str = str.replace('{教材版本}', bookV)
|
||||||
|
str = str.replace('{课程名称}', `《${curNode.itemtitle}》`)
|
||||||
|
prompt.value = str
|
||||||
|
}
|
||||||
|
|
||||||
|
// 千帆创建对话
|
||||||
|
const conversation_id = ref('')
|
||||||
|
const getChartId = async () => {
|
||||||
|
const res = await createChart()
|
||||||
|
conversation_id.value = res.data.conversation_id
|
||||||
|
// ai 对话
|
||||||
|
aiConversation()
|
||||||
|
}
|
||||||
|
|
||||||
|
const rootData = ref(null)
|
||||||
|
|
||||||
|
const degure = (item) => {
|
||||||
|
item.name = item.content.replace(/<[^>]*>/g, '');;
|
||||||
|
if (item.children && item.children.length) {
|
||||||
|
item.children.forEach(item2 => {
|
||||||
|
degure(item2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const outputImg = () => {
|
||||||
|
let svg = window.document.getElementById('Mindmap_svg-wrapper_fgvb6')
|
||||||
|
// let das = svg.querySelectorAll('.Mindmap_root_fgvb6')[0]
|
||||||
|
html2canvas(svg,{
|
||||||
|
scale: scale.value
|
||||||
|
}).then((canvas) => {
|
||||||
|
const dataUrl = canvas.toDataURL()
|
||||||
|
exportImg64File(dataUrl, `${curNode.itemtitle}思维导图`)
|
||||||
|
})
|
||||||
|
// mm.value.fit()
|
||||||
|
}
|
||||||
|
// 初始化
|
||||||
|
onMounted(() => {
|
||||||
|
let data = sessionStore.get('subject.curNode')
|
||||||
|
Object.assign(curNode, data)
|
||||||
|
|
||||||
|
// 获取提示词
|
||||||
|
getPrompt()
|
||||||
|
// 获取百度千帆会话ID
|
||||||
|
getChartId()
|
||||||
|
|
||||||
|
})
|
||||||
|
// 监听 initValue 的变化
|
||||||
|
watch(() => resMarkdown.value, () => {
|
||||||
|
const { root } = transformer.transform(resMarkdown.value)
|
||||||
|
degure(root)
|
||||||
|
rootData.value = [root]
|
||||||
|
console.log(rootData.value)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.mindmap-header {
|
||||||
|
background: #fff;
|
||||||
|
height: 45px;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.main-left {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 5px;
|
||||||
|
.main-left-ipt {
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.main-right{
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
svg {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -0,0 +1,276 @@
|
||||||
|
<!--
|
||||||
|
initData参数:
|
||||||
|
{
|
||||||
|
prompt: 思维导图prompt数据,
|
||||||
|
title: 标题
|
||||||
|
url: 请求地址
|
||||||
|
reloadData: 初始化数据,如果为空则默认去获取
|
||||||
|
}
|
||||||
|
|
||||||
|
回调函数
|
||||||
|
emits: {
|
||||||
|
exportImg: 导出图片按钮回调
|
||||||
|
createMindMap: 创建思维导图回调,初始化生成
|
||||||
|
reloadMindMap: 重新加载思维导图回调,对话重新生成
|
||||||
|
}
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<div class="page-mindmap">
|
||||||
|
<div class="mindmap-header">
|
||||||
|
<div class="mindmap-title">
|
||||||
|
<div>
|
||||||
|
<b>AI思维导图</b> <span class="">《{{ props.title }}》</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<template v-if="isEdit">
|
||||||
|
<el-button class="" @click="isEdit = false">取消</el-button>
|
||||||
|
<el-button type="success" class="" @click="isEdit = false">保存</el-button>
|
||||||
|
</template>
|
||||||
|
<!-- <el-button v-else type="primary" class="mr-3" @click="isEdit = true">编辑</el-button>-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
导出清晰度:<el-input-number v-model="scale" :min="1" :max="10" />数字越大越清晰,但图片大小会越大
|
||||||
|
<el-button @click="outputImg" type="primary">导出图片</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mindmap-main" style="overflow: auto;">
|
||||||
|
<div class="mindmap-main-left" v-loading="loadingAnswer" style="overflow: auto;">
|
||||||
|
<div class="main-left-content" style="overflow: auto;">
|
||||||
|
<v-md-editor v-model="resMarkdown" :mode="isEdit ? 'edit' : 'preview'" />
|
||||||
|
</div>
|
||||||
|
<div class="main-left-ipt">
|
||||||
|
<el-input
|
||||||
|
v-model="textVal"
|
||||||
|
style="max-width: 600px"
|
||||||
|
placeholder="请输入信息对内容进一步调整"
|
||||||
|
class="input-with-select"
|
||||||
|
>
|
||||||
|
<template #append>
|
||||||
|
<el-icon size="20" style="cursor: pointer;" @click="reConversation"><Position /></el-icon>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
<!-- <el-input style="float: left;" v-model="textVal" size="large" placeholder="请输入信息对内容进一步调整" /><el-button>发送</el-button>-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mindmap-main-right">
|
||||||
|
<mindmap v-if="rootData" :timetravel="true" :drag="true" :zoom="true" :edit="true"
|
||||||
|
:center-btn="true" :fit-btn="true" :ctm="true" :add-node-btn="true"
|
||||||
|
v-model="rootData"></mindmap>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'aiMindMap'
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script setup>
|
||||||
|
import { ref, reactive, onMounted, watch, defineExpose } from 'vue'
|
||||||
|
import { Position } from "@element-plus/icons-vue"
|
||||||
|
import { Transformer } from 'markmap-lib'
|
||||||
|
import mindmap from 'vue3-mindmap'
|
||||||
|
import html2canvas from 'html2canvas'
|
||||||
|
import 'vue3-mindmap/dist/style.css'
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
|
const transformer = new Transformer()
|
||||||
|
const emits = defineEmits(['exportImg', 'createMindMap', 'reloadMindMap'])
|
||||||
|
const props = reactive({
|
||||||
|
prompt: '',
|
||||||
|
url: '',
|
||||||
|
title: '',
|
||||||
|
reloadData: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const textVal = ref(``)
|
||||||
|
|
||||||
|
const loadingAnswer = ref(false)
|
||||||
|
|
||||||
|
const scale = ref(5)
|
||||||
|
|
||||||
|
const modeOptions = ref([
|
||||||
|
{
|
||||||
|
label: '教学大模型',
|
||||||
|
value: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '知识库模型',
|
||||||
|
value: 2,
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
const isEdit = ref(false)
|
||||||
|
|
||||||
|
// AI 对话
|
||||||
|
const resMarkdown = ref(``)
|
||||||
|
const params = reactive({
|
||||||
|
prompt: '',
|
||||||
|
dataset_id: '',
|
||||||
|
template: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const messages = ref([
|
||||||
|
{
|
||||||
|
role: 'user',
|
||||||
|
content: ''
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
const aiConversation = async () => {
|
||||||
|
params.prompt = props.prompt
|
||||||
|
loadingAnswer.value = true
|
||||||
|
let data = {
|
||||||
|
"messages": [
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": params.prompt
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
const res = await text2mindmap(data).finally(() => {
|
||||||
|
loadingAnswer.value = false
|
||||||
|
})
|
||||||
|
resMarkdown.value = res.data.answer.content.replaceAll('```markdown','').replaceAll('```', '')
|
||||||
|
emits('createMindMap', resMarkdown.value, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
const reConversation = async () => {
|
||||||
|
loadingAnswer.value = true
|
||||||
|
rootData.value = null
|
||||||
|
let data = {
|
||||||
|
"messages": [
|
||||||
|
{
|
||||||
|
"role":"assiatant",
|
||||||
|
"content": resMarkdown.value
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": `${textVal.value},${props.prompt}`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
let res = await text2mindmap(data).finally(() => {
|
||||||
|
loadingAnswer.value = false
|
||||||
|
})
|
||||||
|
resMarkdown.value = res.data.answer.content.replaceAll('```markdown','').replaceAll('```', '')
|
||||||
|
emits('reloadMindMap', resMarkdown.value, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
const text2mindmap =(data)=> {
|
||||||
|
return axios({
|
||||||
|
url: props.url,
|
||||||
|
method: "post",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Accept: "*/*",
|
||||||
|
},
|
||||||
|
data:data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const rootData = ref(null)
|
||||||
|
|
||||||
|
const degure = (item) => {
|
||||||
|
item.name = item.content.replace(/<[^>]*>/g, '');;
|
||||||
|
if (item.children && item.children.length) {
|
||||||
|
item.children.forEach(item2 => {
|
||||||
|
degure(item2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const outputImg = () => {
|
||||||
|
let svg = window.document.getElementById('Mindmap_svg-wrapper_fgvb6')
|
||||||
|
html2canvas(svg,{
|
||||||
|
scale: scale.value
|
||||||
|
}).then((canvas) => {
|
||||||
|
const dataUrl = canvas.toDataURL()
|
||||||
|
emits('exportImg', dataUrl)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const initData = (datas) => {
|
||||||
|
Object.assign(props, datas)
|
||||||
|
// 获取提示词
|
||||||
|
if (props.reloadData) {
|
||||||
|
resMarkdown.value = props.reloadData
|
||||||
|
}else {
|
||||||
|
aiConversation()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
initData,
|
||||||
|
outputImg,
|
||||||
|
aiConversation,
|
||||||
|
reConversation
|
||||||
|
})
|
||||||
|
|
||||||
|
// 初始化
|
||||||
|
onMounted(() => {
|
||||||
|
// initData()
|
||||||
|
})
|
||||||
|
|
||||||
|
// 监听 initValue 的变化
|
||||||
|
watch(() => resMarkdown.value, () => {
|
||||||
|
const { root } = transformer.transform(resMarkdown.value)
|
||||||
|
degure(root)
|
||||||
|
rootData.value = [root]
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.page-mindmap{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex: 1;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.mindmap-header {
|
||||||
|
background: #fff;
|
||||||
|
height: 45px;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding: 0 20px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mindmap-main{
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
flex-direction: row;
|
||||||
|
.mindmap-main-left {
|
||||||
|
background: #fff;
|
||||||
|
flex-basis: 34%;
|
||||||
|
border-radius: 5px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
.main-left-content{
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.main-left-ipt {
|
||||||
|
height: 50px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.mindmap-main-right{
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
flex-basis: 66%;
|
||||||
|
svg {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
|
@ -438,17 +438,23 @@ const toRousrceUrl = async (o) => {
|
||||||
if (!!o.src) { // 如果有src就转换
|
if (!!o.src) { // 如果有src就转换
|
||||||
const isBase64 = /^data:image\/(\w+);base64,/.test(o.src)
|
const isBase64 = /^data:image\/(\w+);base64,/.test(o.src)
|
||||||
const isBlobUrl = /^blob:/.test(o.src)
|
const isBlobUrl = /^blob:/.test(o.src)
|
||||||
let onLineUrl = '' // 线上地址
|
let onLineUrl = '', typeExt = '' // 线上地址|文件后缀
|
||||||
if (!!o.zipPath) onLineUrl = pptMedia[o.zipPath] || '' // 是否已上传过
|
if (!!o.zipPath) {
|
||||||
|
onLineUrl = pptMedia[o.zipPath] || '' // 是否已上传过
|
||||||
|
typeExt = o.zipPath.split('.').pop()
|
||||||
|
}
|
||||||
if (onLineUrl) o.src = onLineUrl // 已存在线上地址直接赋值
|
if (onLineUrl) o.src = onLineUrl // 已存在线上地址直接赋值
|
||||||
else { // 不存在重新上传
|
else { // 不存在重新上传
|
||||||
if (isBase64) { // 相同资源处理
|
if (isBase64) { // 相同资源处理
|
||||||
const url = await getOnlineFileUrl(o.src)
|
if(!typeExt) typeExt = 'png'
|
||||||
|
const url = await getOnlineFileUrl(o.src, typeExt)
|
||||||
|
url &&(o.src = url)
|
||||||
url && o.zipPath && (pptMedia[o.zipPath] = url) // 缓存
|
url && o.zipPath && (pptMedia[o.zipPath] = url) // 缓存
|
||||||
} else if (isBlobUrl) { // 视频和音频
|
} else if (isBlobUrl) { // 视频和音频
|
||||||
|
if(!typeExt) typeExt = o.type=='video'?'mp4':'mp3'
|
||||||
const res = await fetch(o.src)
|
const res = await fetch(o.src)
|
||||||
const blob = await res.blob()
|
const blob = await res.blob()
|
||||||
const url = await getOnlineFileUrl(blob, o.type=='video'?'mp4':'mp3')
|
const url = await getOnlineFileUrl(blob, typeExt)
|
||||||
URL.revokeObjectURL(o.src) // 释放内存
|
URL.revokeObjectURL(o.src) // 释放内存
|
||||||
url &&(o.src = url)
|
url &&(o.src = url)
|
||||||
url && o.zipPath && (pptMedia[o.zipPath] = url) // 缓存
|
url && o.zipPath && (pptMedia[o.zipPath] = url) // 缓存
|
||||||
|
|
|
@ -653,17 +653,23 @@ export default {
|
||||||
if (!!o.src) { // 如果有src就转换
|
if (!!o.src) { // 如果有src就转换
|
||||||
const isBase64 = /^data:image\/(\w+);base64,/.test(o.src)
|
const isBase64 = /^data:image\/(\w+);base64,/.test(o.src)
|
||||||
const isBlobUrl = /^blob:/.test(o.src)
|
const isBlobUrl = /^blob:/.test(o.src)
|
||||||
let onLineUrl = '' // 线上地址
|
let onLineUrl = '', typeExt = '' // 线上地址|文件后缀
|
||||||
if (!!o.zipPath) onLineUrl = this.pptMedia[o.zipPath] || '' // 是否已上传过
|
if (!!o.zipPath) {
|
||||||
|
onLineUrl = this.pptMedia[o.zipPath] || '' // 是否已上传过
|
||||||
|
typeExt = o.zipPath.split('.').pop()
|
||||||
|
}
|
||||||
if (onLineUrl) o.src = onLineUrl // 已存在线上地址直接赋值
|
if (onLineUrl) o.src = onLineUrl // 已存在线上地址直接赋值
|
||||||
else { // 不存在重新上传
|
else { // 不存在重新上传
|
||||||
if (isBase64) { // 相同资源处理
|
if (isBase64) { // 相同资源处理
|
||||||
const url = await this.getOnlineFileUrl(o.src)
|
if(!typeExt) typeExt = 'png'
|
||||||
|
const url = await this.getOnlineFileUrl(o.src, typeExt)
|
||||||
|
url &&(o.src = url)
|
||||||
url && o.zipPath && (this.pptMedia[o.zipPath] = url) // 缓存
|
url && o.zipPath && (this.pptMedia[o.zipPath] = url) // 缓存
|
||||||
} else if (isBlobUrl) { // 视频和音频
|
} else if (isBlobUrl) { // 视频和音频
|
||||||
|
if(!typeExt) typeExt = o.type=='video'?'mp4':'mp3'
|
||||||
const res = await fetch(o.src)
|
const res = await fetch(o.src)
|
||||||
const blob = await res.blob()
|
const blob = await res.blob()
|
||||||
const url = await this.getOnlineFileUrl(blob, o.type=='video'?'mp4':'mp3')
|
const url = await this.getOnlineFileUrl(blob, typeExt)
|
||||||
URL.revokeObjectURL(o.src) // 释放内存
|
URL.revokeObjectURL(o.src) // 释放内存
|
||||||
url &&(o.src = url)
|
url &&(o.src = url)
|
||||||
url && o.zipPath && (this.pptMedia[o.zipPath] = url) // 缓存
|
url && o.zipPath && (this.pptMedia[o.zipPath] = url) // 缓存
|
||||||
|
|
Loading…
Reference in New Issue