框架设计-edit

This commit is contained in:
lyc 2024-11-26 16:07:13 +08:00
parent 5808798b95
commit eb197db4fd
2 changed files with 85 additions and 29 deletions

View File

@ -7,18 +7,22 @@
<span>{{ item.name }}</span>
<el-button type="primary" link @click="onSelect(item)">选择模式</el-button>
</div>
<el-scrollbar>
<div class="content-list">
<div class="item-list flex">
<el-card class="item-card" shadow="never" v-for="el in item.child" :key="el.id">
<p class="card-name">{{ el.name }}</p>
<p class="card-name">
<el-text line-clamp="1" :title="el.name">
{{ el.name }}
</el-text>
</p>
<div class="card-text">
<el-text line-clamp="2">
<el-text line-clamp="4" :title="el.prompt">
{{ el.prompt }}
</el-text>
</div>
</el-card>
</div>
</el-scrollbar>
</div>
</div>
</div>
</div>
@ -97,30 +101,44 @@ onMounted(() => {
justify-content: space-between;
margin-bottom: 5px;
}
.con-item {
margin-bottom: 20px;
display: flex;
flex-direction: column
}
.item-list{
margin-bottom: 10px;
}
.item-card {
width: 130px;
font-size: 13px;
padding: 10px;
margin-right: 20px;
flex-shrink: 0;
border-radius: 10px;
:deep(.el-card__body) {
padding: 0 !important;
}
.card-name {
text-align: center;
font-size: 14px;
}
.card-text {
text-align: left;
font-size: 12px;
.el-text{
font-size: 12px !important;
}
}
}
}
}
.content-list{
overflow-x: auto
}
.content-list::-webkit-scrollbar {
height: 8px;
}
</style>

View File

@ -52,26 +52,55 @@
</template>
<script setup>
import { ref, onUnmounted, reactive } from 'vue'
import { ref, onMounted, onUnmounted, reactive } from 'vue'
import { sessionStore } from '@/utils/store'
import emitter from '@/utils/mitt'
import EditDialog from './edit-dialog.vue'
import AdjustDialog from './adjust-dialog.vue'
import { completion } from '@/api/mode/index.js'
import { completion, tempResult } from '@/api/mode/index.js'
import { dataSetJson } from '@/utils/comm.js'
const resultList = ref([])
emitter.on('changeMode', (item) => {
console.log(item, 'item')
resultList.value = item.child
conversation()
// conversation()
getTempResult(item.id)
})
//
const getTempResult = (id) => {
tempResult({ mainModelId: id }).then(res => {
console.log(res, 2000)
let rows = res.rows
if (rows.length > 0) {
resultList.value.forEach(item => {
rows.forEach(el => {
if (item.id == el.modelId) {
item.answer = el.content
item.reultId = el.id
}
})
})
}
})
}
const params = reactive(
{
prompt: '',
dataset_id: ''
}
)
const conversation = async () => {
for (let item of resultList.value) {
item.loading = true
try {
const { data } = await completion({
dataset_id: 'cee3062a9fcf11efa6910242ac140006',
prompt: item.prompt
})
params.prompt = `按照${item.prompt}的要求,针对${curNode.edustage}${curNode.edusubject}课标对${curNode.itemtitle}进行教学分析`
const { data } = await completion(params)
item.answer = data.answer
} finally {
item.loading = false
@ -89,10 +118,8 @@ const curItem = reactive({})
const againResult = async (index, item) => {
try {
resultList.value[index].loading = true
const { data } = await completion({
dataset_id: 'cee3062a9fcf11efa6910242ac140006',
prompt: item.prompt
})
params.prompt = `按照${item.prompt}的要求,针对${curNode.edustage}${curNode.edusubject}课标对${curNode.itemtitle}进行教学分析`
const { data } = await completion(params)
resultList.value[index].answer = data.answer
} finally {
resultList.value[index].loading = false
@ -122,6 +149,17 @@ emitter.on('changeResult', (item) => {
})
const curNode = reactive({})
onMounted(() => {
let data = sessionStore.get('subject.curNode')
Object.assign(curNode, data);
let jsonKey = `课标-${data.edustage}-${data.edusubject}`
params.dataset_id = dataSetJson[jsonKey]
})
//
onUnmounted(() => {
emitter.off('changeMode')