Compare commits

..

9 Commits

9 changed files with 125 additions and 40 deletions

View File

@ -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('课标')

View File

@ -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;

View File

@ -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>

View File

@ -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>

View File

@ -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

View File

@ -152,7 +152,7 @@
</el-form-item>
</div>
<div class="item-cropper-btn">
<el-button v-show="isCropper" circle @click="cropperFormItem('workdesc')"></el-button>
<el-button v-show="isCropper" circle @click="cropperFormItem('workdesc')"><el-icon><Search /></el-icon></el-button>
</div>
</div>
@ -252,8 +252,7 @@
<el-tag v-else type="danger" style=" margin-left: 10px ">温馨提示这里 - 号删除的是最后一道题目哟</el-tag>
</el-form-item>
<div class="item-cropper-btn-multi">
<!-- <el-button v-show="isCropper" circle icon="Search" @click="cropperFormItem('workdesc')"></el-button> -->
<el-button v-show="isCropper" circle @click="cropperFormItem('workdesc')">识别</el-button>
<el-button v-show="isCropper" circle @click="cropperFormItem('workdesc')"><el-icon><Search /></el-icon></el-button>
</div>

View File

@ -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
}

View File

@ -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)

View File

@ -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) => {