2023-05-15 15:19:09 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { usePromptStore, type IPrompt } from '@/stores/modules/prompt';
|
|
|
|
import { NThing, NTag, NButton, NEllipsis, useMessage } from 'naive-ui';
|
|
|
|
import { storeToRefs } from 'pinia';
|
|
|
|
|
2023-05-16 07:41:30 +08:00
|
|
|
defineProps<{
|
2023-05-15 15:19:09 +08:00
|
|
|
index: number;
|
|
|
|
source: IPrompt;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const messgae = useMessage();
|
|
|
|
const promptStore = usePromptStore();
|
|
|
|
const { promptList, optPromptConfig } = storeToRefs(promptStore);
|
|
|
|
|
|
|
|
const delPrompt = (item: IPrompt) => {
|
|
|
|
promptList.value = promptList.value.filter((x) => x.act !== item.act && x.prompt !== item.prompt);
|
|
|
|
messgae.success('删除提示词成功');
|
|
|
|
};
|
|
|
|
|
|
|
|
const showEditPromptPop = (item: IPrompt) => {
|
|
|
|
optPromptConfig.value.isShow = true;
|
|
|
|
optPromptConfig.value.type = 'edit';
|
|
|
|
optPromptConfig.value.title = '编辑提示词';
|
|
|
|
optPromptConfig.value.tmpPrompt = item;
|
|
|
|
optPromptConfig.value.newPrompt = { ...item };
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<NThing class="hover:bg-gray-100 cursor-pointer p-5">
|
|
|
|
<template #description>
|
2023-05-16 07:41:30 +08:00
|
|
|
<NTag class="max-w-[150px] xl:max-w-[680px] overflow-ellipsis overflow-hidden" type="info"> {{ source.act }} </NTag>
|
2023-05-15 15:19:09 +08:00
|
|
|
<div class="float-right">
|
2023-05-16 07:41:30 +08:00
|
|
|
<NButton secondary type="info" size="small" @click="showEditPromptPop(source)">编辑</NButton>
|
|
|
|
<NButton secondary class="ml-2" type="error" size="small" @click="delPrompt(source)">删除</NButton>
|
2023-05-15 15:19:09 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
2023-05-16 07:41:30 +08:00
|
|
|
<NEllipsis :tooltip="false" :line-clamp="2">{{ source.prompt }}</NEllipsis>
|
2023-05-15 15:19:09 +08:00
|
|
|
</NThing>
|
|
|
|
</template>
|