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

View File

@ -52,26 +52,55 @@
</template> </template>
<script setup> <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 emitter from '@/utils/mitt'
import EditDialog from './edit-dialog.vue' import EditDialog from './edit-dialog.vue'
import AdjustDialog from './adjust-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([]) const resultList = ref([])
emitter.on('changeMode', (item) => { emitter.on('changeMode', (item) => {
console.log(item, 'item')
resultList.value = item.child 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 () => { const conversation = async () => {
for (let item of resultList.value) { for (let item of resultList.value) {
item.loading = true item.loading = true
try { try {
const { data } = await completion({ params.prompt = `按照${item.prompt}的要求,针对${curNode.edustage}${curNode.edusubject}课标对${curNode.itemtitle}进行教学分析`
dataset_id: 'cee3062a9fcf11efa6910242ac140006', const { data } = await completion(params)
prompt: item.prompt
})
item.answer = data.answer item.answer = data.answer
} finally { } finally {
item.loading = false item.loading = false
@ -89,10 +118,8 @@ const curItem = reactive({})
const againResult = async (index, item) => { const againResult = async (index, item) => {
try { try {
resultList.value[index].loading = true resultList.value[index].loading = true
const { data } = await completion({ params.prompt = `按照${item.prompt}的要求,针对${curNode.edustage}${curNode.edusubject}课标对${curNode.itemtitle}进行教学分析`
dataset_id: 'cee3062a9fcf11efa6910242ac140006', const { data } = await completion(params)
prompt: item.prompt
})
resultList.value[index].answer = data.answer resultList.value[index].answer = data.answer
} finally { } finally {
resultList.value[index].loading = false resultList.value[index].loading = false
@ -106,7 +133,7 @@ const onAdjust = (index, item) => {
Object.assign(curItem, item) Object.assign(curItem, item)
isAdjust.value = true isAdjust.value = true
} }
emitter.on('changeAdjust', (item) =>{ emitter.on('changeAdjust', (item) => {
resultList.value[curIndex.value].answer = item resultList.value[curIndex.value].answer = item
}) })
@ -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(() => { onUnmounted(() => {
emitter.off('changeMode') emitter.off('changeMode')