lyc-dev #76

Merged
lyc merged 2 commits from lyc-dev into main 2024-12-02 14:25:32 +08:00
8 changed files with 123 additions and 37 deletions

View File

@ -1,5 +1,5 @@
<template> <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> <template #header>
<div class="custom-header flex"> <div class="custom-header flex">
<span>{{ item.name }}</span> <span>{{ item.name }}</span>
@ -105,11 +105,9 @@ const getCompletion = async (val) => {
} }
const saveAdjust = (item) =>{ const saveAdjust = (item) =>{
isDialog.value = false isDialog.value = false
ElMessage.success('操作成功') ElMessage.success('操作成功')
emitter.on('saveAdjust', item.msg) emitter.emit('onSaveAdjust', item.msg)
} }
const modeType = ref('课标') const modeType = ref('课标')

View File

@ -51,7 +51,9 @@
<div class="item-icon"> <div class="item-icon">
<i class="iconfont icon-ai"></i> <i class="iconfont icon-ai"></i>
</div> </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>
<div class="ai-btn" v-if="item.answer"> <div class="ai-btn" v-if="item.answer">
<el-button type="primary" link @click="againResult(index, item)"> <el-button type="primary" link @click="againResult(index, item)">
@ -68,7 +70,6 @@
</el-button> </el-button>
</div> </div>
</div> </div>
</template> </template>
<el-empty v-if="!childTempList.length" description="暂无模板数据" /> <el-empty v-if="!childTempList.length" description="暂无模板数据" />
</div> </div>
@ -89,6 +90,7 @@ import { sessionStore } from '@/utils/store'
import keywordDialog from './keyword-dialog.vue'; import keywordDialog from './keyword-dialog.vue';
import AdjustDialog from './adjust-dialog.vue' import AdjustDialog from './adjust-dialog.vue'
import EditDialog from './edit-dialog.vue' import EditDialog from './edit-dialog.vue'
import TypingEffect from '@/components/typing-effect/index.vue'
import emitter from '@/utils/mitt'; import emitter from '@/utils/mitt';
import { dataSetJson } from '@/utils/comm.js' import { dataSetJson } from '@/utils/comm.js'
@ -109,7 +111,6 @@ const onAdd = () => {
isAdd.value = true isAdd.value = true
Object.assign(editItem, curTemplate) Object.assign(editItem, curTemplate)
isWordDialog.value = true isWordDialog.value = true
} }
const editKeyWord = (item, val) => { const editKeyWord = (item, val) => {
@ -263,12 +264,14 @@ const params = reactive(
const againResult = async (index, item) => { const againResult = async (index, item) => {
try { try {
childTempList.value[index].loading = true childTempList.value[index].loading = true
item.aiShow = true
childTempList.value[index].oldAnswer = ''
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)
let answer = data.answer let answer = data.answer
childTempList.value[index].oldAnswer = answer childTempList.value[index].oldAnswer = answer
childTempList.value[index].answer = getResult(answer); childTempList.value[index].answer = getResult(answer);
onEditSave(item) // onEditSave(item)
} finally { } finally {
childTempList.value[index].loading = false childTempList.value[index].loading = false
} }
@ -278,18 +281,29 @@ const getCompletion = async () => {
for (let item of childTempList.value) { for (let item of childTempList.value) {
try { try {
item.loading = true item.loading = 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)
let answer = data.answer let answer = data.answer
item.oldAnswer = answer item.oldAnswer = answer
item.answer = getResult(answer); item.answer = getResult(answer);
onSaveTemp(item)
} finally { } finally {
item.loading = false 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 onEditSave = async (item) =>{
const { res } = await editTempResult({id: item.resultId, content: item.oldAnswer}) const { res } = await editTempResult({id: item.resultId, content: item.oldAnswer})
@ -297,30 +311,18 @@ const onEditSave = async (item) =>{
getChildTemplate() getChildTemplate()
} }
// //
const onSaveTemp = (item) => { const onSaveTemp = (item) => {
if(item.oldAnswer == '') return
const data = { const data = {
mainModelId: curTemplate.id, mainModelId: curTemplate.id,
modelId: item.id, modelId: item.id,
examDocld: '', examDocld: '',
content: item.oldAnswer content: item.oldAnswer
} }
tempSave(data).then(res => { tempSave(data).then(res => {})
console.log(res)
})
} }
//
emitter.on('saveAdjust', (item) => {
childTempList.value[curIndex.value].oldAnswer = item
let answer = getResult(item);
childTempList.value[curIndex.value].answer = answer
})
// //
let getResult = (text) => { let getResult = (text) => {
text = text.replace(/^\n\n(.*?)\n\n$/s, '<div>$1</div>'); text = text.replace(/^\n\n(.*?)\n\n$/s, '<div>$1</div>');
@ -351,8 +353,9 @@ onMounted(() => {
// //
onUnmounted(() => { onUnmounted(() => {
emitter.off('onGetMain');
emitter.off('onGetChild'); emitter.off('onGetChild');
emitter.off('saveAdjust'); emitter.off('onSaveAdjust');
}) })
</script> </script>
@ -422,6 +425,7 @@ onUnmounted(() => {
.item-answer { .item-answer {
flex-direction: column; flex-direction: column;
padding-top: 5px; padding-top: 5px;
width: 100%;
:deep(.text-tit) { :deep(.text-tit) {
font-weight: bold; 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> </template>
<script setup> <script setup>
import { ref } from 'vue' import { ref, onMounted } from 'vue'
import { ElMessageBox } from 'element-plus' import { ElMessageBox } from 'element-plus'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
const Remote = require('@electron/remote')
const userStore = useUserStore() const userStore = useUserStore()
const { ipcRenderer } = window.electron || {} const { ipcRenderer } = window.electron || {}
@ -47,6 +48,11 @@ const closeWindow = () => {
}) })
}).catch(() => { }); }).catch(() => { });
} }
onMounted(() =>{
isMaxSize.value = Remote.getCurrentWindow().isMaximized()
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -8,6 +8,7 @@
<el-breadcrumb :separator-icon="ArrowRight"> <el-breadcrumb :separator-icon="ArrowRight">
<el-breadcrumb-item v-for="item in breadList"> {{ item.title }} </el-breadcrumb-item> <el-breadcrumb-item v-for="item in breadList"> {{ item.title }} </el-breadcrumb-item>
</el-breadcrumb> </el-breadcrumb>
<span class="ml-5">{{ curNode.itemtitle }}</span>
</div> </div>
<div class="header-center" v-else> <div class="header-center" v-else>
AI文枢{{ version }} AI文枢{{ version }}
@ -20,11 +21,13 @@
</template> </template>
<script setup> <script setup>
import { ref, watch } from 'vue' import { reactive, ref, watch } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { ArrowRight } from '@element-plus/icons-vue' import { ArrowRight } from '@element-plus/icons-vue'
import WindowTools from '@/components/window-tools/index.vue' import WindowTools from '@/components/window-tools/index.vue'
import pkc from "../../../../../package.json" import pkc from "../../../../../package.json"
import { sessionStore } from '@/utils/store'
const version = ref(pkc.version) const version = ref(pkc.version)
// //
@ -33,6 +36,8 @@ const onBack = () => {
router.go(-1) router.go(-1)
} }
const curNode = reactive({itemtitle: ''})
// //
const isShowBack = ref(false) const isShowBack = ref(false)
const breadList = ref([]) const breadList = ref([])
@ -44,7 +49,8 @@ watch(
if (path.includes('/model') && path !== ('/model/index')) { if (path.includes('/model') && path !== ('/model/index')) {
isShowBack.value = true isShowBack.value = true
breadList.value = newValue.matched.map(item => item.meta) breadList.value = newValue.matched.map(item => item.meta)
let data = sessionStore.get('subject.curNode')
Object.assign(curNode, data)
} }
else { else {
isShowBack.value = false isShowBack.value = false

View File

@ -113,7 +113,7 @@ const getConversation = (val) => {
const getCompletion = async (val) => { const getCompletion = async (val) => {
try { 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) const { data } = await completion(params)
let answer = data.answer let answer = data.answer
msgList.value.push({ msgList.value.push({
@ -133,8 +133,6 @@ const saveAdjust = (item) =>{
} }
const curFile = reactive({}) const curFile = reactive({})
const dataset_id = ref('') const dataset_id = ref('')
const fileList = ref([]) const fileList = ref([])
@ -143,15 +141,15 @@ const getList = () =>{
userId: userInfo.userId, userId: userInfo.userId,
dataset_id: dataset_id.value dataset_id: dataset_id.value
}).then( res =>{ }).then( res =>{
fileList.value = [{fileId: '',fileName: '选择文件', id:-1},...res.rows] fileList.value = res.rows
Object.assign(curFile, fileList.value[0]) Object.assign(curFile, fileList.value[0])
params.document_ids = fileList.value[0].docId
}) })
} }
emitter.on('curFile', (item) =>{ emitter.on('curFile', (item) =>{
changeFile(item) changeFile(item)
}) })
const changeFile = (val) =>{ const changeFile = (val) =>{
Object.assign(curFile, val); Object.assign(curFile, val);
params.document_ids = val.docId params.document_ids = val.docId
} }

View File

@ -51,7 +51,7 @@ watch(() => props.item.answer, (newVal) => {
const emit = defineEmits(['saveEdit']) const emit = defineEmits(['saveEdit'])
const onSave = () =>{ 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 isDialog.value = false
ElMessage.success('操作成功') ElMessage.success('操作成功')
emit('saveEdit', textarea.value) emit('saveEdit', textarea.value)

View File

@ -67,7 +67,7 @@ import AdjustDialog from './adjust-dialog.vue'
import keywordDialog from './keyword-dialog.vue'; import keywordDialog from './keyword-dialog.vue';
import { sessionStore } from '@/utils/store' import { sessionStore } from '@/utils/store'
import useUserStore from '@/store/modules/user' 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 { dataSetJson } from '@/utils/comm.js'
import emitter from '@/utils/mitt'; import emitter from '@/utils/mitt';
@ -109,7 +109,7 @@ const getTempResult = () => {
rows.forEach(el => { rows.forEach(el => {
if (item.id == el.modelId) { if (item.id == el.modelId) {
item.answer = el.content 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) { for (let item of childTempList.value) {
try { try {
item.loading = true item.loading = true
// params.prompt = `${curNode.edustage}${curNode.edusubject}${item.prompt}`
params.prompt = `按照${item.prompt}的要求,针对${curNode.edustage}${curNode.edusubject}考试 对${curNode.itemtitle}进行教学分析` params.prompt = `按照${item.prompt}的要求,针对${curNode.edustage}${curNode.edusubject}考试 对${curNode.itemtitle}进行教学分析`
const { data } = await completion(params) const { data } = await completion(params)
let answer = data.answer let answer = data.answer
@ -175,16 +174,24 @@ const onSaveTemp = (item) => {
const againResult = async (index, item) => { const againResult = async (index, item) => {
try { try {
childTempList.value[index].loading = true 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) const { data } = await completion(params)
let answer = data.answer let answer = data.answer
childTempList.value[index].oldAnswer = answer childTempList.value[index].oldAnswer = answer
childTempList.value[index].answer = getResult(answer); childTempList.value[index].answer = getResult(answer);
onEditSave(childTempList.value[index])
} finally { } finally {
childTempList.value[index].loading = false 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) => { let getResult = (text) => {