页面完善

This commit is contained in:
李寻欢 2024-02-02 17:30:25 +08:00
parent c8e560781d
commit f60b004d34
3 changed files with 162 additions and 2 deletions

29
src/api/assistant.ts Normal file
View File

@ -0,0 +1,29 @@
import { http } from "@/utils/http";
import { BaseResponse } from "@/api/base";
/** AI助手信息 */
export type AiAssistantResult = {
/** Id */
id: string;
createdAt: Date;
updatedAt: Date;
/** 名称 */
name: string;
/** 人设 */
personality: string;
/** 模型 */
model: string;
/** 是否启用 */
enable: boolean;
/** 是否编辑 */
edit: boolean;
};
/** 查询所有AI助手 */
export const getAllAiAssistant = (data: any) => {
return http.request<BaseResponse<Array<AiAssistantResult>>>(
"get",
"/admin/v1/ai-assistant",
{ data }
);
};

View File

@ -256,3 +256,20 @@ div:focus {
content: " ";
}
}
/* 调整滚动条 */
/* 选择滚动条的样式 */
::-webkit-scrollbar {
width: 5px; /* 调整滚动条的宽度 */
}
/* 设置滚动条的轨道 */
::-webkit-scrollbar-track {
background-color: #f1f1f1;
}
/* 设置滚动条的滑块 */
::-webkit-scrollbar-thumb {
background-color: #888;
border-radius: 4px; /* 可以根据需要调整滑块的圆角 */
}

View File

@ -1,12 +1,126 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { AiAssistantResult, getAllAiAssistant } from "@/api/assistant";
defineOptions({
name: "Assistant"
});
//
const assistantList = ref([] as AiAssistantResult[]);
//
const getAllAiAssistantHandle = async () => {
const assistantData = await getAllAiAssistant({});
assistantList.value = assistantData.data;
};
const changeAssistantEditStatusHandle = index => {
console.log("正在修改: ", index);
//
console.log(assistantList.value[index]);
};
onMounted(() => {
//
getAllAiAssistantHandle();
});
</script>
<template>
<div class="flex justify-center items-center h-[640px]">
<h1>AI助手</h1>
<div class="flex h-[640px]">
<div class="card-container">
<el-card
class="assistant-card"
shadow="hover"
v-for="item in assistantList"
:key="item.id"
>
<template #header>
<div class="assistant-header">
<el-input v-model="item.name" :disabled="!item.edit" />
<el-button
link
:type="item.edit ? 'danger' : 'warning'"
@click="item.edit = !item.edit"
>
{{ item.edit ? "取消" : "编辑" }}
</el-button>
</div>
</template>
<div>
<el-descriptions :column="1" size="default">
<el-descriptions-item label="模型">
<el-input v-model="item.model" :readonly="!item.edit" />
</el-descriptions-item>
<el-descriptions-item label="人设" class-name="personality">
<el-input
v-model="item.personality"
:autosize="{ minRows: 2, maxRows: 4 }"
resize="none"
type="textarea"
placeholder="请输入人设"
:readonly="!item.edit"
/>
</el-descriptions-item>
<el-descriptions-item label="启用">
<el-switch
v-model="item.enable"
active-text="是"
inactive-text="否"
:disabled="!item.edit"
/>
</el-descriptions-item>
</el-descriptions>
</div>
</el-card>
</div>
</div>
</template>
<style lang="scss" scoped>
.card-container {
display: flex;
flex-wrap: wrap;
gap: 20px;
justify-content: flex-start; /* 改为 flex-start 以优先横向排列 */
}
.assistant-card {
width: 300px;
height: 330px;
}
.assistant-header {
font-size: 18px;
font-weight: bold;
display: flex;
justify-content: space-between;
align-items: center;
}
.edit-button {
text-align: right;
margin-top: 10px;
}
.personality {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.el-textarea__inner::-webkit-scrollbar {
width: 8px; /*滚动条宽度*/
height: 8px; /*滚动条高度*/
}
.el-textarea__inner::-webkit-scrollbar-thumb {
background-color: red; /*滚动条默认显示的颜色*/
}
.el-textarea__inner::-webkit-scrollbar {
width: 4px;
height: 4px;
background-color: white; /*滚动条背景色显示的颜色*/
}
</style>