Merge pull request 'lyc-dev' (#76) from lyc-dev into main
This commit is contained in:
commit
1a267e5696
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<el-dialog v-model="isDialog" :show-close="false" width="800" destroy-on-close>
|
||||
<el-dialog v-model="isDialog" :show-close="false" width="800" append-to-body destroy-on-close>
|
||||
<template #header>
|
||||
<div class="custom-header flex">
|
||||
<span>{{ item.name }}</span>
|
||||
|
@ -105,11 +105,9 @@ const getCompletion = async (val) => {
|
|||
}
|
||||
|
||||
const saveAdjust = (item) =>{
|
||||
|
||||
isDialog.value = false
|
||||
ElMessage.success('操作成功')
|
||||
emitter.on('saveAdjust', item.msg)
|
||||
|
||||
emitter.emit('onSaveAdjust', item.msg)
|
||||
}
|
||||
|
||||
const modeType = ref('课标')
|
||||
|
|
|
@ -51,7 +51,9 @@
|
|||
<div class="item-icon">
|
||||
<i class="iconfont icon-ai"></i>
|
||||
</div>
|
||||
<div class="item-answer" v-html="item.answer"></div>
|
||||
<div class="item-answer">
|
||||
<TypingEffect :text="item.oldAnswer" :delay="10" :aiShow="item.aiShow" @complete="onSaveTemp(item)" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="ai-btn" v-if="item.answer">
|
||||
<el-button type="primary" link @click="againResult(index, item)">
|
||||
|
@ -68,7 +70,6 @@
|
|||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
<el-empty v-if="!childTempList.length" description="暂无模板数据" />
|
||||
</div>
|
||||
|
@ -89,6 +90,7 @@ import { sessionStore } from '@/utils/store'
|
|||
import keywordDialog from './keyword-dialog.vue';
|
||||
import AdjustDialog from './adjust-dialog.vue'
|
||||
import EditDialog from './edit-dialog.vue'
|
||||
import TypingEffect from '@/components/typing-effect/index.vue'
|
||||
import emitter from '@/utils/mitt';
|
||||
import { dataSetJson } from '@/utils/comm.js'
|
||||
|
||||
|
@ -109,7 +111,6 @@ const onAdd = () => {
|
|||
isAdd.value = true
|
||||
Object.assign(editItem, curTemplate)
|
||||
isWordDialog.value = true
|
||||
|
||||
}
|
||||
|
||||
const editKeyWord = (item, val) => {
|
||||
|
@ -263,12 +264,14 @@ const params = reactive(
|
|||
const againResult = async (index, item) => {
|
||||
try {
|
||||
childTempList.value[index].loading = true
|
||||
item.aiShow = true
|
||||
childTempList.value[index].oldAnswer = ''
|
||||
params.prompt = `按照${item.name}的要求,针对${curNode.edustage}${curNode.edusubject}${modeType.value} 对${curNode.itemtitle}进行教学分析`
|
||||
const { data } = await completion(params)
|
||||
let answer = data.answer
|
||||
childTempList.value[index].oldAnswer = answer
|
||||
childTempList.value[index].answer = getResult(answer);
|
||||
onEditSave(item)
|
||||
// onEditSave(item)
|
||||
} finally {
|
||||
childTempList.value[index].loading = false
|
||||
}
|
||||
|
@ -278,18 +281,29 @@ const getCompletion = async () => {
|
|||
for (let item of childTempList.value) {
|
||||
try {
|
||||
item.loading = true
|
||||
item.aiShow = true
|
||||
params.prompt = `按照${item.name}的要求,针对${curNode.edustage}${curNode.edusubject}${modeType.value} 对${curNode.itemtitle}进行教学分析`
|
||||
const { data } = await completion(params)
|
||||
let answer = data.answer
|
||||
item.oldAnswer = answer
|
||||
item.answer = getResult(answer);
|
||||
onSaveTemp(item)
|
||||
|
||||
} finally {
|
||||
item.loading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 替换分析结果
|
||||
emitter.on('onSaveAdjust', (item) => {
|
||||
childTempList.value[curIndex.value].oldAnswer = item
|
||||
let answer = getResult(item);
|
||||
childTempList.value[curIndex.value].oldAnswer = item
|
||||
childTempList.value[curIndex.value].answer = answer
|
||||
onEditSave(childTempList.value[curIndex.value])
|
||||
})
|
||||
|
||||
|
||||
// 保存 重新研读后的结果
|
||||
const onEditSave = async (item) =>{
|
||||
const { res } = await editTempResult({id: item.resultId, content: item.oldAnswer})
|
||||
|
@ -297,30 +311,18 @@ const onEditSave = async (item) =>{
|
|||
getChildTemplate()
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 保存模板
|
||||
const onSaveTemp = (item) => {
|
||||
if(item.oldAnswer == '') return
|
||||
const data = {
|
||||
mainModelId: curTemplate.id,
|
||||
modelId: item.id,
|
||||
examDocld: '',
|
||||
content: item.oldAnswer
|
||||
}
|
||||
tempSave(data).then(res => {
|
||||
console.log(res)
|
||||
})
|
||||
tempSave(data).then(res => {})
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 替换分析结果
|
||||
emitter.on('saveAdjust', (item) => {
|
||||
childTempList.value[curIndex.value].oldAnswer = item
|
||||
let answer = getResult(item);
|
||||
childTempList.value[curIndex.value].answer = answer
|
||||
})
|
||||
|
||||
// 分析获取课标对话结果
|
||||
let getResult = (text) => {
|
||||
text = text.replace(/^\n\n(.*?)\n\n$/s, '<div>$1</div>');
|
||||
|
@ -351,8 +353,9 @@ onMounted(() => {
|
|||
|
||||
// 解绑
|
||||
onUnmounted(() => {
|
||||
emitter.off('onGetMain');
|
||||
emitter.off('onGetChild');
|
||||
emitter.off('saveAdjust');
|
||||
emitter.off('onSaveAdjust');
|
||||
})
|
||||
</script>
|
||||
|
||||
|
@ -422,6 +425,7 @@ onUnmounted(() => {
|
|||
.item-answer {
|
||||
flex-direction: column;
|
||||
padding-top: 5px;
|
||||
width: 100%;
|
||||
|
||||
:deep(.text-tit) {
|
||||
font-weight: bold;
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
<template>
|
||||
<div class="typing-effect">
|
||||
<!-- <span v-html="displayedText"></span> -->
|
||||
<el-input
|
||||
v-model="displayedText"
|
||||
:autosize="{ minRows: 2 }"
|
||||
type="textarea"
|
||||
readonly
|
||||
resize="none"
|
||||
style="width: 100%;"
|
||||
input-style="border:none;outline: none;box-shadow:none;color:000;fontSize:15px"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, watch } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
text: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
delay: {
|
||||
type: Number,
|
||||
default: 100 // 默认每个字符出现的延迟时间,单位是毫秒
|
||||
},
|
||||
aiShow: {
|
||||
type: [Boolean]
|
||||
}
|
||||
});
|
||||
const emit = defineEmits(['complete']);
|
||||
const displayedText = ref('');
|
||||
const index = ref(0);
|
||||
|
||||
const type = () => {
|
||||
if(!props.aiShow) return
|
||||
if (index.value <= props.text.length) {
|
||||
displayedText.value += props.text.charAt(index.value);
|
||||
index.value++;
|
||||
setTimeout(() => type(), props.delay);
|
||||
} else {
|
||||
// 当所有字符都显示完毕时,触发 complete 事件
|
||||
emit('complete');
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
type();
|
||||
});
|
||||
|
||||
// 监听 props 的变化,以便当传入的 text 或 delay 发生改变时重新开始打字机效果
|
||||
watch([() => props.text, () => props.delay], () => {
|
||||
displayedText.value = '';
|
||||
index.value = 0;
|
||||
type();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.typing-effect {
|
||||
font-family: monospace;
|
||||
}
|
||||
:deep(.el-textarea__inner:hover){
|
||||
box-shadow: none;
|
||||
}
|
||||
</style>
|
|
@ -8,9 +8,10 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
const Remote = require('@electron/remote')
|
||||
|
||||
const userStore = useUserStore()
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
|
@ -47,6 +48,11 @@ const closeWindow = () => {
|
|||
})
|
||||
}).catch(() => { });
|
||||
}
|
||||
|
||||
onMounted(() =>{
|
||||
isMaxSize.value = Remote.getCurrentWindow().isMaximized()
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<el-breadcrumb :separator-icon="ArrowRight">
|
||||
<el-breadcrumb-item v-for="item in breadList"> {{ item.title }} </el-breadcrumb-item>
|
||||
</el-breadcrumb>
|
||||
<span class="ml-5">《{{ curNode.itemtitle }}》</span>
|
||||
</div>
|
||||
<div class="header-center" v-else>
|
||||
AI文枢{{ version }}
|
||||
|
@ -20,11 +21,13 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue'
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ArrowRight } from '@element-plus/icons-vue'
|
||||
import WindowTools from '@/components/window-tools/index.vue'
|
||||
import pkc from "../../../../../package.json"
|
||||
import { sessionStore } from '@/utils/store'
|
||||
|
||||
const version = ref(pkc.version)
|
||||
|
||||
// 返回
|
||||
|
@ -33,6 +36,8 @@ const onBack = () => {
|
|||
router.go(-1)
|
||||
}
|
||||
|
||||
const curNode = reactive({itemtitle: ''})
|
||||
|
||||
// 监听当前路由
|
||||
const isShowBack = ref(false)
|
||||
const breadList = ref([])
|
||||
|
@ -44,7 +49,8 @@ watch(
|
|||
if (path.includes('/model') && path !== ('/model/index')) {
|
||||
isShowBack.value = true
|
||||
breadList.value = newValue.matched.map(item => item.meta)
|
||||
|
||||
let data = sessionStore.get('subject.curNode')
|
||||
Object.assign(curNode, data)
|
||||
}
|
||||
else {
|
||||
isShowBack.value = false
|
||||
|
|
|
@ -113,7 +113,7 @@ const getConversation = (val) => {
|
|||
const getCompletion = async (val) => {
|
||||
try {
|
||||
|
||||
params.prompt = `根据${curNode.edustage}${curNode.edusubject},分析${props.item.name},${val}`
|
||||
params.prompt = `按照${val}的要求,针对${curNode.edustage}${curNode.edusubject}考试 对${curNode.itemtitle}进行教学分析`
|
||||
const { data } = await completion(params)
|
||||
let answer = data.answer
|
||||
msgList.value.push({
|
||||
|
@ -133,8 +133,6 @@ const saveAdjust = (item) =>{
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const curFile = reactive({})
|
||||
const dataset_id = ref('')
|
||||
const fileList = ref([])
|
||||
|
@ -143,15 +141,15 @@ const getList = () =>{
|
|||
userId: userInfo.userId,
|
||||
dataset_id: dataset_id.value
|
||||
}).then( res =>{
|
||||
fileList.value = [{fileId: '',fileName: '选择文件', id:-1},...res.rows]
|
||||
fileList.value = res.rows
|
||||
Object.assign(curFile, fileList.value[0])
|
||||
params.document_ids = fileList.value[0].docId
|
||||
})
|
||||
}
|
||||
emitter.on('curFile', (item) =>{
|
||||
changeFile(item)
|
||||
})
|
||||
const changeFile = (val) =>{
|
||||
|
||||
Object.assign(curFile, val);
|
||||
params.document_ids = val.docId
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ watch(() => props.item.answer, (newVal) => {
|
|||
|
||||
const emit = defineEmits(['saveEdit'])
|
||||
const onSave = () =>{
|
||||
editTempResult({id: props.item.reultId, content: textarea.value}).then( res =>{
|
||||
editTempResult({id: props.item.resultId, content: textarea.value}).then( res =>{
|
||||
isDialog.value = false
|
||||
ElMessage.success('操作成功')
|
||||
emit('saveEdit', textarea.value)
|
||||
|
|
|
@ -67,7 +67,7 @@ import AdjustDialog from './adjust-dialog.vue'
|
|||
import keywordDialog from './keyword-dialog.vue';
|
||||
import { sessionStore } from '@/utils/store'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { tempSave, completion, modelList, removeChildTemp, tempResult } from '@/api/mode/index'
|
||||
import { tempSave, completion, modelList, removeChildTemp, tempResult, editTempResult } from '@/api/mode/index'
|
||||
import { dataSetJson } from '@/utils/comm.js'
|
||||
import emitter from '@/utils/mitt';
|
||||
|
||||
|
@ -109,7 +109,7 @@ const getTempResult = () => {
|
|||
rows.forEach(el => {
|
||||
if (item.id == el.modelId) {
|
||||
item.answer = el.content
|
||||
item.reultId = el.id
|
||||
item.resultId = el.id
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -143,7 +143,6 @@ const getCompletion = async () => {
|
|||
for (let item of childTempList.value) {
|
||||
try {
|
||||
item.loading = true
|
||||
// params.prompt = `根据${curNode.edustage}${curNode.edusubject},提炼出${item.prompt}`
|
||||
params.prompt = `按照${item.prompt}的要求,针对${curNode.edustage}${curNode.edusubject}考试 对${curNode.itemtitle}进行教学分析`
|
||||
const { data } = await completion(params)
|
||||
let answer = data.answer
|
||||
|
@ -175,16 +174,24 @@ const onSaveTemp = (item) => {
|
|||
const againResult = async (index, item) => {
|
||||
try {
|
||||
childTempList.value[index].loading = true
|
||||
params.prompt = `根据${curNode.edustage}${curNode.edusubject}课标,提炼出${item.name}`
|
||||
params.prompt = `按照${item.name}的要求,针对${curNode.edustage}${curNode.edusubject}考试 对${curNode.itemtitle}进行教学分析`
|
||||
const { data } = await completion(params)
|
||||
let answer = data.answer
|
||||
childTempList.value[index].oldAnswer = answer
|
||||
childTempList.value[index].answer = getResult(answer);
|
||||
onEditSave(childTempList.value[index])
|
||||
} finally {
|
||||
childTempList.value[index].loading = false
|
||||
}
|
||||
}
|
||||
|
||||
// 保存 重新研读后的结果
|
||||
const onEditSave = async (item) =>{
|
||||
const { res } = await editTempResult({id: item.resultId, content: item.oldAnswer})
|
||||
ElMessage.success(res)
|
||||
getChildTemplate()
|
||||
}
|
||||
|
||||
|
||||
// 分析获取课标对话结果
|
||||
let getResult = (text) => {
|
||||
|
|
Loading…
Reference in New Issue