Fix a bug.

This commit is contained in:
李寻欢 2024-02-03 16:02:46 +08:00
parent d3c074090f
commit 64d85c22c2

View File

@ -106,141 +106,143 @@ onMounted(() => {
</script>
<template>
<div style="margin: 20px">
<el-button type="primary" @click="showCreateDialog = true"
>新增 AI 助手</el-button
>
</div>
<div class="flex h-[640px]" v-loading="dataLoading">
<div class="card-container">
<el-card
class="assistant-card"
shadow="hover"
v-for="item in assistantList"
:key="item.id"
v-loading="item.saveLoading"
<div>
<div style="margin: 20px">
<el-button type="primary" @click="showCreateDialog = true"
>新增 AI 助手</el-button
>
<template #header>
<div class="assistant-header">
<span v-if="!item.edit">
{{ item.name }}
</span>
<el-input v-else v-model="item.name" style="width: 80%" />
<el-button-group>
<el-button
link
:type="item.edit ? 'primary' : 'warning'"
@click="item.edit = !item.edit"
>
{{ item.edit ? "取消" : "编辑" }}
</el-button>
<el-button
v-if="!item.edit"
link
type="danger"
@click="deleteAssistantHandle(item.id)"
>删除</el-button
>
<el-button
v-else
link
type="success"
@click="saveAssistantHandle(item)"
>保存</el-button
>
</el-button-group>
</div>
</template>
<div>
<el-descriptions :column="1" size="default" border>
<el-descriptions-item label="模型">
<el-text v-if="!item.edit">{{ item.model }}</el-text>
<el-select
v-else
v-model="item.model"
placeholder="请选择模型"
style="width: 100%"
>
<el-option
v-for="model in modelList"
:key="model.value"
:label="model.name"
:value="model.value"
/>
</el-select>
</el-descriptions-item>
<el-descriptions-item label="人设">
<el-input
v-model="item.personality"
:autosize="{ minRows: 2, maxRows: 4 }"
resize="none"
type="textarea"
placeholder="请输入人设"
:disabled="!item.edit"
clahh="data-input"
/>
</el-descriptions-item>
<el-descriptions-item label="启用">
<el-tag v-if="!item.edit">{{
item.enable ? "已启用" : "已禁用"
}}</el-tag>
<el-switch
v-else
v-model="item.enable"
active-text="是"
inactive-text="否"
/>
</el-descriptions-item>
</el-descriptions>
</div>
</el-card>
</div>
</div>
<el-dialog
v-model="showCreateDialog"
title="新增 AI 助手"
width="40%"
:close-on-click-modal="false"
:before-close="clearCreateParam"
>
<el-form :model="createAssistantParam" label-width="120px">
<el-form-item label="名称">
<el-input v-model="createAssistantParam.name" />
</el-form-item>
<el-form-item label="模型">
<el-select
v-model="createAssistantParam.model"
placeholder="请选择模型"
style="width: 100%"
<div class="flex h-[640px]" v-loading="dataLoading">
<div class="card-container">
<el-card
class="assistant-card"
shadow="hover"
v-for="item in assistantList"
:key="item.id"
v-loading="item.saveLoading"
>
<el-option
v-for="model in modelList"
:key="model.value"
:label="model.name"
:value="model.value"
<template #header>
<div class="assistant-header">
<span v-if="!item.edit">
{{ item.name }}
</span>
<el-input v-else v-model="item.name" style="width: 80%" />
<el-button-group>
<el-button
link
:type="item.edit ? 'primary' : 'warning'"
@click="item.edit = !item.edit"
>
{{ item.edit ? "取消" : "编辑" }}
</el-button>
<el-button
v-if="!item.edit"
link
type="danger"
@click="deleteAssistantHandle(item.id)"
>删除</el-button
>
<el-button
v-else
link
type="success"
@click="saveAssistantHandle(item)"
>保存</el-button
>
</el-button-group>
</div>
</template>
<div>
<el-descriptions :column="1" size="default" border>
<el-descriptions-item label="模型">
<el-text v-if="!item.edit">{{ item.model }}</el-text>
<el-select
v-else
v-model="item.model"
placeholder="请选择模型"
style="width: 100%"
>
<el-option
v-for="model in modelList"
:key="model.value"
:label="model.name"
:value="model.value"
/>
</el-select>
</el-descriptions-item>
<el-descriptions-item label="人设">
<el-input
v-model="item.personality"
:autosize="{ minRows: 2, maxRows: 4 }"
resize="none"
type="textarea"
placeholder="请输入人设"
:disabled="!item.edit"
clahh="data-input"
/>
</el-descriptions-item>
<el-descriptions-item label="启用">
<el-tag v-if="!item.edit">{{
item.enable ? "已启用" : "已禁用"
}}</el-tag>
<el-switch
v-else
v-model="item.enable"
active-text="是"
inactive-text="否"
/>
</el-descriptions-item>
</el-descriptions>
</div>
</el-card>
</div>
</div>
<el-dialog
v-model="showCreateDialog"
title="新增 AI 助手"
width="40%"
:close-on-click-modal="false"
:before-close="clearCreateParam"
>
<el-form :model="createAssistantParam" label-width="120px">
<el-form-item label="名称">
<el-input v-model="createAssistantParam.name" />
</el-form-item>
<el-form-item label="模型">
<el-select
v-model="createAssistantParam.model"
placeholder="请选择模型"
style="width: 100%"
>
<el-option
v-for="model in modelList"
:key="model.value"
:label="model.name"
:value="model.value"
/>
</el-select>
</el-form-item>
<el-form-item label="人设">
<el-input
v-model="createAssistantParam.personality"
:autosize="{ minRows: 2, maxRows: 4 }"
resize="none"
type="textarea"
placeholder="请输入人设"
/>
</el-select>
</el-form-item>
<el-form-item label="人设">
<el-input
v-model="createAssistantParam.personality"
:autosize="{ minRows: 2, maxRows: 4 }"
resize="none"
type="textarea"
placeholder="请输入人设"
/>
</el-form-item>
<el-form-item label="启用">
<el-switch
v-model="createAssistantParam.enable"
active-text="是"
inactive-text="否"
/>
</el-form-item>
</el-form>
</el-dialog>
</el-form-item>
<el-form-item label="启用">
<el-switch
v-model="createAssistantParam.enable"
active-text="是"
inactive-text="否"
/>
</el-form-item>
</el-form>
</el-dialog>
</div>
</template>
<style lang="scss" scoped>