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
nodeData.label = nodeData.itemtitle
let parentNode
// id == rootid
if(nodeData.parentid == nodeData.rootid){
// children
if(nodeData.children){
//
parentNode = null
}
else{

View File

@ -52,7 +52,7 @@
<i class="iconfont icon-ai"></i>
</div>
<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 class="ai-btn" v-if="item.answer">
@ -178,27 +178,22 @@ const getTempResult = () => {
const scrollToBottom = (height,index) =>{
if (listRef.value) {
let sum = 0
let listDom = listRef.value.children
for(let i = 0; i < index; i++){
sum += listDom[i].clientHeight
if(index == 0){
// 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) => {
let sTop = isStarted.value[index]
isAgain.value = true
isStarted.value[index] = false
childTempList.value[index].answer = ''
console.log(listRef.value.scrollTop,listRef.value.children[index].clientHeight);
if(index == 0){
listRef.value.scrollTop = 0
}else{
console.log( listRef.value.scrollTop - (listRef.value.children[index].clientHeight),'index')
listRef.value.scrollTop =listRef.value.scrollTop - listRef.value.children[index].clientHeight - 50
scrollToBottom(50, index)
}
try {
await nextTick()
childTempList.value[index].loading = true
item.aiShow = true
//params.prompt = `${item.name}${curNode.edustage}${curNode.edusubject}${modeType.value} ${curNode.itemtitle}`
//const { data } = await completion(params)
//childTempList.value[index].answer = getResult(data.answer);
childTempList.value[index].answer = '根据知识库的内容,核心素\n\n综上所述在大足石刻研学课程中应充分考虑语文学科核心素养的要求通过实践活动提高学生语言运用能力、思维品质及文化认同'
params.prompt = `按照${item.name}的要求,针对${curNode.edustage}${curNode.edusubject}${modeType.value}${curNode.itemtitle}进行教学分析`
const { data } = await completion(params)
childTempList.value[index].answer = getResult(data.answer);
isStarted.value[index] = true
// onEditSave(item)
} finally {
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) {
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])
})
//
const onEditSave = async (item) => {
const { res } = await editTempResult({ id: item.resultId, content: item.answer })

View File

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

View File

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