edit 框架设计

This commit is contained in:
lyc 2025-01-07 11:02:11 +08:00
parent 7be60a3d72
commit 586ce134f8
2 changed files with 34 additions and 19 deletions

View File

@ -20,8 +20,20 @@
</div> </div>
</div> </div>
<div class="center-con" v-loading="loading"> <div class="center-con" v-loading="loading">
<TypingEffect v-if="answer" :text="answer" :delay="10" :aiShow="aiShow"/> <!-- <TypingEffect v-if="answer" :text="answer" :delay="10" :aiShow="aiShow"/> -->
<el-empty v-if="!answer" description="请选择符合您需要的教学模式,生成教学大纲" /> <div style="font-size: 18px;color: #409eff;">封面页</div>
<div class="con-item mb-5">
<div class="item-name">标题{{ answer.title }}</div>
<div class="item-name">副标题{{answer.subTitle }}</div>
</div>
<div style="font-size: 18px;color: #409eff;">目录页</div>
<div class="con-item" v-for="(item,index) in answer.chapters">
<div class="item-name">{{index + 1}}{{ item.chapterTitle }}</div>
<div class="item-text">
<p v-for="(el,i) in item.chapterContents">{{ index + 1 }} - {{ i + 1}} : {{ el.chapterTitle }}</p>
</div>
</div>
<el-empty v-if="!answer.title" description="请选择符合您需要的教学模式,生成教学大纲" />
</div> </div>
</div> </div>
<EditDialog v-model="isEdit" :item="curItem" /> <EditDialog v-model="isEdit" :item="curItem" />
@ -37,7 +49,6 @@ import * as commUtils from '@/utils/comm.js'
import { createChart, sendChart } from '@/api/ai/index' import { createChart, sendChart } from '@/api/ai/index'
import { completion, addSyllabus, syllabuss, removeSyllabus } from '@/api/mode/index.js' import { completion, addSyllabus, syllabuss, removeSyllabus } from '@/api/mode/index.js'
import { createOutlineV2 } from '@/utils/ppt-request.js' import { createOutlineV2 } from '@/utils/ppt-request.js'
import TypingEffect from '@/components/typing-effect/index.vue'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
const curMode = ref(2) const curMode = ref(2)
@ -60,14 +71,14 @@ const modeOptions = ref([
// //
const selectedData = ref([]) const selectedData = ref([])
emitter.on('selected', (data)=>{ emitter.on('selected', (data)=>{
console.log(data,3000)
selectedData.value = data selectedData.value = data
}) })
// //
const curItem = reactive({}) const curItem = reactive({})
emitter.on('onShow', (data)=>{ emitter.on('onShow', (data)=>{
console.log(data)
aiShow.value = false aiShow.value = false
answer.value = getResult(data.outline) Object.assign(answer, JSON.parse(data.outline))
Object.assign(curItem, data) Object.assign(curItem, data)
curItem.answer = curItem.outline curItem.answer = curItem.outline
getDetails(data.id) getDetails(data.id)
@ -90,10 +101,9 @@ const params = reactive(
// //
const loading = ref(false) const loading = ref(false)
const answer = ref('') const answer = reactive({})
const createAi = async ()=>{ const createAi = async ()=>{
console.log(selectedData.value)
if(selectedData.value.length == 0){ if(selectedData.value.length == 0){
ElMessage.warning('请先选择教学环节后再生成教学大纲') ElMessage.warning('请先选择教学环节后再生成教学大纲')
return return
@ -126,14 +136,12 @@ const createAi = async ()=>{
} }
const res = await createOutlineV2({query: data.answer}) const res = await createOutlineV2({query: data.answer})
console.log(res) console.log(res)
emitter.emit('onResult', data.answer) emitter.emit('onResult', res)
answer.value = getResult(data.answer) Object.assign(answer, res.outline)
onSaveTemp(JSON.stringify(res.outline))
onSaveTemp(data.answer)
} finally { } finally {
loading.value = false loading.value = false
} }
} }
@ -174,11 +182,6 @@ const delAnswer = () =>{
} }
// ### **
let getResult = (str) => {
let newStr = str.replace(/#+|(\*\*)/g, '');
return newStr
}
// //
const conversation_id = ref('') const conversation_id = ref('')
@ -231,6 +234,18 @@ onMounted(() => {
border-radius: 5px; border-radius: 5px;
text-align: left; text-align: left;
overflow-y: auto; overflow-y: auto;
padding: 15px;
.con-item{
display: flex;
flex-direction: column;
margin-top: 15px;
.item-text{
background: #F2F2F2;
padding: 15px;
border-radius: 5px;
margin-top: 10px;
}
}
} }
} }

View File

@ -5,8 +5,8 @@
<div> <div>
<el-button type="primary" link @click="resetSelect">重置</el-button> <el-button type="primary" link @click="resetSelect">重置</el-button>
<el-button type="primary" link @click=" <el-button type="primary" link @click="
addVisible = true addVisible = true,
addChild = false addChild = false,
isEdit = false isEdit = false
"><i class="iconfont icon-jiahao"></i>新增</el-button> "><i class="iconfont icon-jiahao"></i>新增</el-button>
</div> </div>