This commit is contained in:
lyc 2024-12-04 15:13:53 +08:00
parent 3ad4391e10
commit 8b429a4174
4 changed files with 38 additions and 41 deletions

View File

@ -143,8 +143,9 @@ const handleNodeClick = (data) => {
//label label //label label
nodeData.label = nodeData.itemtitle nodeData.label = nodeData.itemtitle
let parentNode let parentNode
// id == rootid // children
if(nodeData.parentid == nodeData.rootid){ if(nodeData.children){
//
parentNode = null parentNode = null
} }
else{ else{

View File

@ -52,7 +52,7 @@
<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" @complete="handleCompleteText(index)" @updateScroll="scrollToBottom($event,index)" /> <TypingEffect v-if="isStarted[index]" :text="item.answer" :delay="10" :aiShow="item.aiShow" @complete="handleCompleteText($event,index)" @updateScroll="scrollToBottom($event,index)" />
</div> </div>
</div> </div>
<div class="ai-btn" v-if="item.answer"> <div class="ai-btn" v-if="item.answer">
@ -178,27 +178,22 @@ const getTempResult = () => {
const scrollToBottom = (height,index) =>{ const scrollToBottom = (height,index) =>{
if (listRef.value) { if (listRef.value) {
let sum = 0
let listDom = listRef.value.children let listDom = listRef.value.children
for(let i = 0; i < index; i++){ if(index == 0){
sum += listDom[i].clientHeight // 220
let screenHeight = window.innerHeight - 220
if(height > screenHeight){
listRef.value.scrollTop = (height - screenHeight + 50)
}
}
else{
for(let i = 0; i < index; i++){
sum += listDom[i].clientHeight
}
listRef.value.scrollTop = sum + height
} }
listRef.value.scrollTop = sum + height
// isStarted.value[index] = height
// const sum = isStarted.value.reduce((accumulator, currentValue) => {
// //
// if (typeof currentValue === 'number') {
// return accumulator + currentValue;
// }
// //
// return accumulator;
// }, 0);
// listRef.value.scrollTop = sum - 150;
} }
} }
@ -294,34 +289,28 @@ const params = reactive(
) )
// //
const isAgain = ref(false)
const againResult = async (index, item) => { const againResult = async (index, item) => {
let sTop = isStarted.value[index] isAgain.value = true
isStarted.value[index] = false isStarted.value[index] = false
childTempList.value[index].answer = '' childTempList.value[index].answer = ''
console.log(listRef.value.scrollTop,listRef.value.children[index].clientHeight);
if(index == 0){ if(index == 0){
listRef.value.scrollTop = 0 listRef.value.scrollTop = 0
}else{ }else{
console.log( listRef.value.scrollTop - (listRef.value.children[index].clientHeight),'index') scrollToBottom(50, index)
listRef.value.scrollTop =listRef.value.scrollTop - listRef.value.children[index].clientHeight - 50
} }
try { try {
await nextTick() await nextTick()
childTempList.value[index].loading = true childTempList.value[index].loading = true
item.aiShow = true item.aiShow = true
//params.prompt = `${item.name}${curNode.edustage}${curNode.edusubject}${modeType.value} ${curNode.itemtitle}` params.prompt = `按照${item.name}的要求,针对${curNode.edustage}${curNode.edusubject}${modeType.value}${curNode.itemtitle}进行教学分析`
//const { data } = await completion(params) const { data } = await completion(params)
//childTempList.value[index].answer = getResult(data.answer); childTempList.value[index].answer = getResult(data.answer);
childTempList.value[index].answer = '根据知识库的内容,核心素\n\n综上所述在大足石刻研学课程中应充分考虑语文学科核心素养的要求通过实践活动提高学生语言运用能力、思维品质及文化认同'
isStarted.value[index] = true isStarted.value[index] = true
// onEditSave(item)
} finally { } finally {
childTempList.value[index].loading = false childTempList.value[index].loading = false
} }
@ -351,10 +340,17 @@ const getCompletion = async () => {
} }
} }
const handleCompleteText = (index) =>{ const handleCompleteText = async (answer, index) =>{
if (index < childTempList.value.length - 1) { if (index < childTempList.value.length - 1) {
isStarted.value[index + 1] = true; // isStarted.value[index + 1] = true; //
} }
if(isAgain.value){
try{
await editTempResult({ id: childTempList.value[index].resultId, content: answer })
}finally{
isAgain.value = false
}
}
} }
// //
@ -363,8 +359,6 @@ emitter.on('onSaveAdjust', (item) => {
onEditSave(childTempList.value[curIndex.value]) onEditSave(childTempList.value[curIndex.value])
}) })
// //
const onEditSave = async (item) => { const onEditSave = async (item) => {
const { res } = await editTempResult({ id: item.resultId, content: item.answer }) const { res } = await editTempResult({ id: item.resultId, content: item.answer })

View File

@ -45,11 +45,11 @@ const type = async () => {
index.value++; index.value++;
setTimeout(() => { setTimeout(() => {
type(); type();
emit('updateScroll', typingEffectRef.value.offsetHeight); // emit('updateScroll', typingEffectRef.value.clientHeight); //
}, props.delay); }, props.delay);
} else { } else {
// complete // complete
emit('complete'); emit('complete',displayedText.value);
} }
}; };

View File

@ -5,7 +5,7 @@
<div class="info"> <div class="info">
<div class="info-name">{{ state.user.nickName }}</div> <div class="info-name">{{ state.user.nickName }}</div>
<div class="infomation"> <div class="infomation">
<selectClass/> <selectClass v-if="!isSubject"/>
</div> </div>
</div> </div>
</div> </div>
@ -46,8 +46,10 @@ const state = reactive({
postGroup: {} postGroup: {}
}) })
const isSubject = ref(false)
async function getUser() { async function getUser() {
getUserProfile().then((response) => { getUserProfile().then((response) => {
isSubject.value = response.roleGroup.indexOf('场馆管理员') != -1
// response.data.avatar = import.meta.env.VITE_APP_BASE_API + response.data.avatar // response.data.avatar = import.meta.env.VITE_APP_BASE_API + response.data.avatar
Object.assign(state.user,response.data) Object.assign(state.user,response.data)
state.roleGroup = response.roleGroup state.roleGroup = response.roleGroup