Commit f169b8a3 authored by liujiangnan's avatar liujiangnan

feat

parent 9d944887
.edit-data{ html, body{
padding: 10px; height: 100%;
}
body{
margin: 0;
}
.page{
padding: 15px;
box-sizing: border-box;
height: 100vh;
background: #f5f7fa;
}
[v-cloak]{
display: none;
}
.split{
height: calc(100vh - 30px);
display: flex;
gap: 15px;
}
.split > .el-col{
float: none;
flex: 1;
max-width: none;
}
.panel{
background: #fff;
border-radius: 6px;
padding: 16px;
box-sizing: border-box;
height: 100%;
overflow: auto;
border: 1px solid #ebeef5;
}
.panel-title{
font-size: 16px;
font-weight: 600;
margin-bottom: 16px;
color: #303133;
}
.panel-actions{
margin-bottom: 12px;
}
.group-card{
padding: 12px;
border: 1px solid #ebeef5;
border-radius: 6px;
margin-bottom: 12px;
background: #fafafa;
}
.group-row{
display: flex;
align-items: center;
gap: 12px;
padding: 6px 4px;
flex-wrap: wrap;
}
.group-title{
font-size: 14px;
font-weight: 600;
color: #303133;
}
.group-row-item{
display: flex;
align-items: center;
}
.group-row-actions{
margin-left: auto;
display: flex;
gap: 8px;
}
.image-thumb{
width: 52px;
height: 52px;
border-radius: 4px;
object-fit: cover;
border: 1px solid #dcdfe6;
cursor: pointer;
}
.audio-icon{
width: 40px;
height: 40px;
border-radius: 50%;
background: #f2f6fc;
display: flex;
align-items: center;
justify-content: center;
color: #409eff;
border: 1px solid #dcdfe6;
cursor: pointer;
}
.audio-icon.playing{
background: #ecf5ff;
border-color: #b3d8ff;
}
.hidden-audio{
display: none;
}
.group-progress{
margin-top: 8px;
}
.group-detail{
margin-top: 8px;
}
.ai-tag-content{
margin-top: 8px;
font-size: 12px;
color: #606266;
background: #fff;
border: 1px dashed #dcdfe6;
border-radius: 4px;
padding: 8px;
line-height: 18px;
}
.ai-status{
font-size: 12px;
color: #409eff;
margin-bottom: 6px;
}
.ai-status.error{
color: #f56c6c;
}
.empty-text{
color: #909399;
}
.json-editor{
display: block;
}
.json-node{
margin-bottom: 6px;
}
.json-children{
padding-left: 12px;
border-left: 1px dashed #ebeef5;
margin-left: 4px;
}
.json-leaf{
display: flex;
align-items: center;
gap: 8px;
margin: 4px 0;
}
.json-label{
min-width: 90px;
color: #303133;
font-size: 12px;
word-break: break-all;
}
.json-table{
width: 100%;
border-collapse: collapse;
font-size: 12px;
}
.json-table th,
.json-table td{
border: 1px solid #ebeef5;
padding: 6px 8px;
vertical-align: top;
}
.json-col-index{
width: 60px;
text-align: center;
color: #606266;
}
.json-col-action{
width: 80px;
text-align: center;
}
.json-nested-hint{
color: #909399;
}
.json-table-detail td{
background: #fafafa;
}
.ai-dialog-table{
margin-top: 8px;
}
.ai-table{
width: 100%;
border-collapse: collapse;
font-size: 12px;
}
.ai-table th,
.ai-table td{
border: 1px solid #ebeef5;
padding: 6px 8px;
vertical-align: top;
}
.ai-col-index{
width: 60px;
text-align: center;
color: #606266;
}
.ai-col-text{
width: 180px;
}
.ai-col-time{
width: 110px;
}
.ai-subtable{
width: 100%;
border-collapse: collapse;
font-size: 12px;
}
.ai-subtable th,
.ai-subtable td{
border: 1px solid #ebeef5;
padding: 4px 6px;
}
.uploader .hint{
margin-left: 10px;
color: #909399;
font-size: 12px;
}
.upload-progress{
width: 100%;
}
.upload-progress .progress-info{
display: flex;
justify-content: space-between;
color: #606266;
font-size: 12px;
margin-bottom: 6px;
}
.image-preview{
width: 100%;
max-height: 260px;
object-fit: contain;
background: #f2f2f2;
cursor: pointer;
}
.audio-preview{
width: 100%;
}
.image-preview-dialog .el-message-box__content{
text-align: center;
}
.meta{
font-size: 13px;
color: #606266;
line-height: 22px;
}
.json-alert{
margin-top: 12px;
} }
\ No newline at end of file
...@@ -9,17 +9,209 @@ ...@@ -9,17 +9,209 @@
<script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/jquery-1.12.3.min.js"></script> <script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/jquery-1.12.3.min.js"></script>
<script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js"></script> <script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js"></script>
<script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/vue.min.js"></script> <script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/vue.min.js"></script>
<script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/crypto-js.min.js"></script>
<script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/aliyun-oss-sdk-6.18.1.min.js"></script>
<!-- 引入样式 --> <!-- 引入样式 -->
<link href="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/element-ui/theme-chalk/index.css" rel="stylesheet"> <link href="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/element-ui/theme-chalk/index.css" rel="stylesheet">
<!-- 引入组件库 --> <!-- 引入组件库 -->
<script src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/element-ui/index.js"></script> <script src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/element-ui/index.js"></script>
</head> </head>
<body> <body>
<div class="edit-data"> <div id="app" v-cloak class="page">
<!-- 简单的例子,一个输入框+一个按钮,保存输入框的信息 --> <el-row :gutter="0" class="split">
test: <input type="text" name="test" /> <el-col :span="12" class="panel">
<input id="save" type="button" value="保存" > <div class="panel-title">内容录入区</div>
</div> <el-form label-width="90px" size="small">
<el-form-item label="上传图片">
<el-upload
v-if="!imagePreviewUrl"
ref="imageUpload"
class="uploader"
:show-file-list="false"
:before-upload="beforeImageUpload"
:on-change="handleImageChange"
:on-error="handleUploadError"
accept="image/*">
<el-button type="primary" :disabled="uploading">选择图片</el-button>
<span class="hint">支持重复上传,会覆盖当前图片</span>
</el-upload>
<el-button
v-else
type="warning"
:disabled="uploading"
@click="confirmImageReupload">重新上传</el-button>
</el-form-item>
<el-form-item label="图片预览" v-if="imagePreviewUrl">
<img
class="image-preview"
:src="imagePreviewUrl"
alt="图片预览"
@click="openImagePreview"></img>
</el-form-item>
<el-form-item label="上传音频">
<el-upload
v-if="!audioPreviewUrl"
ref="audioUpload"
class="uploader"
:show-file-list="false"
:before-upload="beforeAudioUpload"
:on-change="handleAudioChange"
:on-error="handleUploadError"
accept="audio/*">
<el-button type="primary" :disabled="uploading">选择音频</el-button>
<span class="hint">支持重复上传,会覆盖当前音频</span>
</el-upload>
<el-button
v-else
type="warning"
:disabled="uploading"
@click="confirmAudioReupload">重新上传</el-button>
</el-form-item>
<el-form-item label="上传进度" v-if="uploading">
<div class="upload-progress">
<div class="progress-info">
<span>正在上传{{ currentUploadType === 'image' ? '图片' : '音频' }}...</span>
<span>{{ uploadProgress }}%</span>
</div>
<el-progress
:percentage="uploadProgress"
:stroke-width="8"
:show-text="false"
status="success">
</el-progress>
</div>
</el-form-item>
<el-form-item label="音频试听" v-if="audioPreviewUrl">
<audio
class="audio-preview"
controls
:src="audioPreviewUrl"></audio>
</el-form-item>
<el-form-item label="操作">
<el-button type="success" @click="handleAiTag">AI打点</el-button>
<el-button type="info" @click="openAiDialog">编辑AI打点内容</el-button>
<el-button type="success" plain @click="handleAiImage">AI图片理解</el-button>
<el-button type="info" plain @click="openAiImageDialog">编辑AI图片理解内容</el-button>
</el-form-item>
</el-form>
</el-col>
<el-dialog
title="打点信息"
:visible.sync="aiDialogVisible"
width="70%"
@close="closeAiDialog">
<div>
<div class="ai-status" v-if="aiLoading">AI打点处理中...</div>
<div class="ai-status error" v-else-if="aiError">{{ aiError }}</div>
<div v-if="aiTagData && aiTagData.length" class="ai-dialog-table">
<table class="ai-table">
<thead>
<tr>
<th class="ai-col-index">序号</th>
<th class="ai-col-text">文本</th>
<th class="ai-col-time">开始时间</th>
<th class="ai-col-time">结束时间</th>
<th class="ai-col-words">单词</th>
</tr>
</thead>
<tbody>
<tr v-for="(row, rowIndex) in aiTagData" :key="rowIndex">
<td class="ai-col-index">{{ rowIndex + 1 }}</td>
<td class="ai-col-text">
<el-input size="mini" v-model="row.text" @input="saveData"></el-input>
</td>
<td class="ai-col-time">
<el-input size="mini" v-model="row.start" @input="saveData"></el-input>
</td>
<td class="ai-col-time">
<el-input size="mini" v-model="row.end" @input="saveData"></el-input>
</td>
<td class="ai-col-words">
<table class="ai-subtable" v-if="row.words && row.words.length">
<thead>
<tr>
<th>单词</th>
<th>开始时间</th>
<th>结束时间</th>
</tr>
</thead>
<tbody>
<tr v-for="(word, wordIndex) in row.words" :key="wordIndex">
<td>
<el-input size="mini" v-model="word.word" @input="saveData"></el-input>
</td>
<td>
<el-input size="mini" v-model="word.start" @input="saveData"></el-input>
</td>
<td>
<el-input size="mini" v-model="word.end" @input="saveData"></el-input>
</td>
</tr>
</tbody>
</table>
<div v-else class="empty-text">暂无单词</div>
</td>
</tr>
</tbody>
</table>
</div>
<div v-else class="empty-text">暂无打点内容</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="closeAiDialog">取消</el-button>
<el-button type="primary" @click="saveAiDialog">保存</el-button>
</span>
</el-dialog>
<el-dialog
title="AI图片理解"
:visible.sync="aiImageDialogVisible"
width="60%"
@close="closeAiImageDialog">
<div>
<div class="ai-status" v-if="aiImageLoading">AI图片理解处理中...</div>
<div class="ai-status error" v-else-if="aiImageError">{{ aiImageError }}</div>
<el-input
type="textarea"
:rows="10"
v-model="aiImageContent"
placeholder="请输入 AI 图片理解内容"
></el-input>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="closeAiImageDialog">取消</el-button>
<el-button type="primary" @click="saveAiImageDialog">保存</el-button>
</span>
</el-dialog>
<el-col :span="12" class="panel">
<div class="panel-title">AI 编排脚本区</div>
<el-input
type="textarea"
:rows="16"
v-model="scriptText"
placeholder="请输入 JSON"></el-input>
<el-alert
v-if="jsonError"
type="error"
:closable="false"
class="json-alert"
:title="jsonError"></el-alert>
<el-alert
v-else
type="success"
:closable="false"
class="json-alert"
title="JSON 格式正确"></el-alert>
</el-col>
</el-row>
</div>
</body> </body>
<script src="./index.js"></script> <script src="./index.js"></script>
</html> </html>
\ No newline at end of file
/* /*
window.courseware.getData(callback, key); //用于获取数据
window.courseware.getData(callback,key); //用于获取数据 window.courseware.setData(data, callback, key); //用于存储数据
window.courseware.setData(data,callback,key); //用于存储数据
var uploadUrl = window.courseware.uploadUrl(); //上传文件的路径 var uploadUrl = window.courseware.uploadUrl(); //上传文件的路径
var uploadData = window.courseware.uploadData(); //上传文件必须要的参数 var uploadData = window.courseware.uploadData(); //上传文件必须要的参数
*/ */
//对应模板的名称,这个可以不写,但是最好是能写上,同时开发多个模板的情况下如果不写这个,本地缓存可能会存在混乱 var key = 'yl16_ai_cartoon';
var key = "h5_test";
$(function(){
window.courseware.getData(function(data){
//数据加载完,才算页面加载完成 var callServerMethod = function (method, data) {
//获取数据 return new Promise(function (resolve) {
if(data&&data.test){ window.courseware.onEvent(method, function (result, next) {
$("[name='test']").val(data.test); resolve(result);
} next();
}, key);
//绑定点击事件 window.courseware.sendEvent(method, data || {}, key);
$('#save').on('click',function(){ });
var test = $("[name='test']").val(); };
//保存新增或修改的数据 new Vue({
window.courseware.setData({test: test},function(){ el: '#app',
//保存数据也是异步的 data: function () {
alert("保存成功!"); return {
},key); imagePreviewUrl: '',
audioPreviewUrl: '',
}) aiTagData: [],
},key); aiLoading: false,
}) aiError: '',
\ No newline at end of file aiImageContent: '',
aiImageLoading: false,
aiImageError: '',
uploading: false,
uploadProgress: 0,
currentUploadId: 0,
currentUploadType: '',
audioPlaying: false,
aiDialogVisible: false,
aiImageDialogVisible: false,
scriptText: '',
jsonError: ''
};
},
watch: {
scriptText: function () {
this.validateJson();
this.saveData();
}
},
mounted: function () {
var _this = this;
if (window.courseware && window.courseware.getData) {
window.courseware.getData(function (data) {
if (window.air && window.air.hideAirClassLoading) {
window.air.hideAirClassLoading(key, data);
}
if (data) {
if (data.imageUrl) {
_this.imagePreviewUrl = data.imageUrl;
}
if (data.audioUrl) {
_this.audioPreviewUrl = data.audioUrl;
}
if (Array.isArray(data.aiTagData)) {
_this.aiTagData = data.aiTagData;
}
if (typeof data.aiImageContent === 'string') {
_this.aiImageContent = data.aiImageContent;
}
if (data.scriptText) {
_this.scriptText = data.scriptText;
}
}
_this.validateJson();
}, key);
} else {
this.validateJson();
}
},
methods: {
// 环境基地址
getApiBase() {
const host = (window.location && window.location.hostname || '').toLowerCase();
const isStaging = host.includes('staging') || host.includes('localhost') || host.includes('127.0.0.1');
return isStaging ? 'https://stagingopensource.iteachabc.com' : 'https://opensource.iteachabc.com';
},
openAiDialog: function () {
this.aiDialogVisible = true;
},
closeAiDialog: function () {
this.aiDialogVisible = false;
},
saveAiDialog: function () {
this.saveData();
this.closeAiDialog();
},
openAiImageDialog: function () {
this.aiImageDialogVisible = true;
},
closeAiImageDialog: function () {
this.aiImageDialogVisible = false;
},
saveAiImageDialog: function () {
this.saveData();
this.closeAiImageDialog();
},
getUploadInput: function (refName, index) {
var ref = this.$refs[refName];
if (!ref) {
return null;
}
var uploadRef = Array.isArray(ref) ? ref[0] : ref;
return uploadRef && uploadRef.$el ? uploadRef.$el.querySelector('input[type="file"]') : null;
},
beforeImageUpload: function (file) {
if (this.uploading) {
this.$message.warning('正在处理,请稍候再试');
return false;
}
if (!file || !file.type || file.type.indexOf('image/') !== 0) {
this.$message.error('只能上传图片文件');
return false;
}
this.currentUploadId += 1;
var uploadId = this.currentUploadId;
this.currentUploadType = 'image';
this.handleImageChange(file);
this.uploading = true;
this.uploadProgress = 0;
this.uploadToOssWithSignature(file, uploadId, 'image');
return false;
},
handleImageChange: function (file) {
var rawFile = file && file.raw ? file.raw : file;
if (!rawFile) {
return;
}
if (this.imagePreviewUrl && this.imagePreviewUrl.indexOf('blob:') === 0) {
URL.revokeObjectURL(this.imagePreviewUrl);
}
this.imagePreviewUrl = URL.createObjectURL(rawFile);
},
beforeAudioUpload: function (file) {
if (this.uploading) {
this.$message.warning('正在处理,请稍候再试');
return false;
}
if (!file || !file.type || file.type.indexOf('audio/') !== 0) {
this.$message.error('只能上传音频文件');
return false;
}
this.currentUploadId += 1;
var uploadId = this.currentUploadId;
this.currentUploadType = 'audio';
this.handleAudioChange(file);
this.uploading = true;
this.uploadProgress = 0;
this.uploadToOssWithSignature(file, uploadId, 'audio');
return false;
},
handleAudioChange: function (file) {
var rawFile = file && file.raw ? file.raw : file;
if (!rawFile) {
return;
}
if (this.audioPreviewUrl && this.audioPreviewUrl.indexOf('blob:') === 0) {
URL.revokeObjectURL(this.audioPreviewUrl);
}
this.audioPreviewUrl = URL.createObjectURL(rawFile);
},
handleUploadError: function (uploadId) {
if (uploadId && uploadId !== this.currentUploadId) {
return;
}
this.uploading = false;
this.uploadProgress = 0;
this.currentUploadType = '';
this.$message.error('上传失败,请重试');
},
confirmImageReupload: function () {
if (this.uploading) {
this.$message.warning('正在处理,请稍候再试');
return;
}
this.$confirm('重新上传会覆盖当前图片,确定继续吗?', '确认重新上传', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
this.reuploadImage();
}.bind(this)).catch(function () {});
},
reuploadImage: function () {
if (this.imagePreviewUrl && this.imagePreviewUrl.indexOf('blob:') === 0) {
URL.revokeObjectURL(this.imagePreviewUrl);
}
this.imagePreviewUrl = '';
this.saveData();
var input = this.getUploadInput('imageUpload');
if (input) {
input.value = '';
input.click();
}
},
confirmAudioReupload: function () {
if (this.uploading) {
this.$message.warning('正在处理,请稍候再试');
return;
}
this.$confirm('重新上传会覆盖当前音频,确定继续吗?', '确认重新上传', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
this.reuploadAudio();
}.bind(this)).catch(function () {});
},
reuploadAudio: function () {
if (this.audioPreviewUrl && this.audioPreviewUrl.indexOf('blob:') === 0) {
URL.revokeObjectURL(this.audioPreviewUrl);
}
this.audioPreviewUrl = '';
this.saveData();
var input = this.getUploadInput('audioUpload');
if (input) {
input.value = '';
input.click();
}
},
openImagePreview: function () {
if (!this.imagePreviewUrl) {
return;
}
this.$alert('<img src="' + this.imagePreviewUrl + '" style="width:100%;">', '图片预览', {
dangerouslyUseHTMLString: true,
customClass: 'image-preview-dialog'
});
},
toggleAudio: function () {},
onAudioEnded: function () {},
calculateMD5: function (file) {
return new Promise(function (resolve, reject) {
var reader = new FileReader();
reader.onload = function (e) {
try {
var wordArray = CryptoJS.lib.WordArray.create(e.target.result);
var hash = CryptoJS.MD5(wordArray);
resolve(hash.toString());
} catch (err) {
reject(err);
}
};
reader.onerror = function (error) {
reject(error);
};
reader.readAsArrayBuffer(file);
});
},
uploadToOssWithSignature: async function (file, uploadId, targetType) {
this.$message.info('正在获取上传凭证...');
try {
var ossSignature = await callServerMethod('getOSSSignature');
if (uploadId !== this.currentUploadId) {
return;
}
if (!ossSignature || !ossSignature.data) {
this.handleUploadError(uploadId);
return;
}
await this.uploadToOSS(file, ossSignature.data, uploadId, targetType);
} catch (err) {
this.handleUploadError(uploadId);
}
},
uploadToOSS: async function (file, ossConfig, uploadId, targetType) {
var client = new OSS({
region: ossConfig.region,
accessKeyId: ossConfig.accessKeyId,
accessKeySecret: ossConfig.accessKeySecret,
stsToken: ossConfig.securityToken,
bucket: ossConfig.bucket,
cors: true,
secure: true,
silent: true
});
this.$message.info('正在计算文件 MD5 值...');
try {
var md5 = await this.calculateMD5(file);
if (uploadId !== this.currentUploadId) {
return;
}
var ext = file.name.split('.').pop().toLowerCase();
var newFileName = md5 + '.' + ext;
await client.multipartUpload(newFileName, file, {
progress: function (p) {
if (uploadId === this.currentUploadId) {
this.uploadProgress = Math.floor(p * 100);
}
}.bind(this)
});
if (uploadId !== this.currentUploadId) {
return;
}
var url = (ossConfig.domain || '').replace('http://', 'https://') + newFileName;
this.uploadProgress = 100;
this.uploading = false;
this.currentUploadType = '';
if (targetType === 'image') {
if (this.imagePreviewUrl && this.imagePreviewUrl.indexOf('blob:') === 0) {
URL.revokeObjectURL(this.imagePreviewUrl);
}
this.imagePreviewUrl = url;
} else if (targetType === 'audio') {
if (this.audioPreviewUrl && this.audioPreviewUrl.indexOf('blob:') === 0) {
URL.revokeObjectURL(this.audioPreviewUrl);
}
this.audioPreviewUrl = url;
}
this.saveData();
this.$message.success('上传成功');
} catch (err) {
this.handleUploadError(uploadId);
}
},
handleAiTag: async function () {
if (!this.audioPreviewUrl) {
this.$message.warning('请先上传音频');
return;
}
var base = this.getApiBase();
this.aiLoading = true;
this.aiError = '';
var loadingInstance = this.$loading({
lock: true,
text: 'AI打点处理中...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.4)'
});
this.$message.info('AI打点处理中...');
try {
var resp = await fetch(base + '/open/api/ai/dpe/v1/audio/audiopoint', {
method: 'POST',
mode: 'cors',
cache: 'no-cache',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
audio_url: this.audioPreviewUrl
})
});
var json = await resp.json();
this.aiLoading = false;
if (json && json.code === 200 && json.data) {
this.aiTagData = Array.isArray(json.data.point_data) ? json.data.point_data : [];
if (json.data.audio_url) {
this.audioPreviewUrl = json.data.audio_url;
}
this.openAiDialog();
this.saveData();
this.$message.success('AI打点完成');
return;
}
this.aiError = (json && (json.msg || json.message)) ? (json.msg || json.message) : 'AI打点失败';
this.$message.error(this.aiError);
} catch (err) {
this.aiLoading = false;
this.aiError = 'AI打点请求失败';
this.$message.error(this.aiError);
} finally {
if (loadingInstance) {
loadingInstance.close();
}
}
},
handleAiImage: async function () {
if (!this.imagePreviewUrl) {
this.$message.warning('请先上传图片');
return;
}
var base = this.getApiBase();
this.aiImageLoading = true;
this.aiImageError = '';
var loadingInstance = this.$loading({
lock: true,
text: 'AI图片理解处理中...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.4)'
});
this.$message.info('AI图片理解处理中...');
try {
var resp = await fetch(base + '/open/api/ai/dpe/v1/imagethinking', {
method: 'POST',
mode: 'cors',
cache: 'no-cache',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
image_url: this.imagePreviewUrl,
prompt: "请根据图片内容,生成一段描述性文字,用于描述图片内容。"
})
});
var json = await resp.json();
this.aiImageLoading = false;
if (json && json.code === 200) {
this.aiImageContent = typeof json.data === 'string' ? json.data : '';
this.openAiImageDialog();
this.saveData();
this.$message.success('AI图片理解完成');
return;
}
this.aiImageError = (json && (json.msg || json.message)) ? (json.msg || json.message) : 'AI图片理解失败';
this.$message.error(this.aiImageError);
} catch (err) {
this.aiImageLoading = false;
this.aiImageError = 'AI图片理解请求失败';
this.$message.error(this.aiImageError);
} finally {
if (loadingInstance) {
loadingInstance.close();
}
}
},
saveData: function () {
if (!window.courseware || !window.courseware.setData) {
return;
}
var data = {
imageUrl: this.imagePreviewUrl,
audioUrl: this.audioPreviewUrl,
aiTagData: this.aiTagData,
aiImageContent: this.aiImageContent,
scriptText: this.scriptText
};
window.courseware.setData(data, function () {}, key);
},
validateJson: function () {
if (!this.scriptText) {
this.jsonError = '';
return;
}
try {
JSON.parse(this.scriptText);
this.jsonError = '';
} catch (err) {
this.jsonError = err.message || 'JSON 语法错误';
}
}
}
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment