Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ declare module 'vue' {
NDatePicker: typeof import('naive-ui')['NDatePicker']
NDivider: typeof import('naive-ui')['NDivider']
NDropdown: typeof import('naive-ui')['NDropdown']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NIcon: typeof import('naive-ui')['NIcon']
NInput: typeof import('naive-ui')['NInput']
NInputNumber: typeof import('naive-ui')['NInputNumber']
Expand Down
41 changes: 28 additions & 13 deletions src/components/common/PromptStore/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import PromptRecommend from '../../../assets/recommend.json'

interface DataProps {
_id?: string
renderKey: string
renderValue: string
renderType: string
title: string
value: string
type: 'built-in' | 'user-defined'
Expand Down Expand Up @@ -277,12 +274,8 @@ async function downloadPromptTemplate() {

// 移动端自适应相关
function renderTemplate() {
const [keyLimit, valueLimit] = isMobile.value ? [10, 30] : [15, 50]
return promptList.value.map((item: UserPrompt) => {
return {
renderKey: item.title.length <= keyLimit ? item.title : `${item.title.substring(0, keyLimit)}...`,
renderValue: item.value.length <= valueLimit ? item.value : `${item.value.substring(0, valueLimit)}...`,
renderType: item.type === 'built-in' ? t('store.builtIn') : t('store.userDefined'),
title: item.title,
value: item.value,
_id: item._id,
Expand All @@ -304,15 +297,27 @@ function createColumns(): DataTableColumns<DataProps> {
return [
{
title: 'type',
key: 'renderType',
key: 'type',
width: 100,
align: 'center',
render: (row: DataProps) => row.type === 'built-in' ? t('store.builtIn') : t('store.userDefined'),
},
{
title: t('store.title'),
key: 'renderKey',
key: 'title',
width: 200,
},
{
title: t('store.description'),
key: 'renderValue',
key: 'value',
ellipsis: {
lineClamp: 6,
tooltip: {
contentClass: 'whitespace-pre-line text-xs max-h-100 max-w-200',
scrollable: true,
},
},
className: 'whitespace-pre-line',
},
{
title: t('common.action'),
Expand Down Expand Up @@ -371,7 +376,7 @@ const dataSource = computed(() => {
const value = searchValue.value
if (value && value !== '') {
return data.filter((item: DataProps) => {
return item.renderKey.includes(value) || item.renderValue.includes(value)
return item.title.includes(value) || item.value.includes(value)
})
}
return data
Expand Down Expand Up @@ -445,9 +450,19 @@ async function handleGetUserPromptList() {
/>
<NList v-if="isMobile" style="max-height: 400px; overflow-y: auto;">
<NListItem v-for="(item, index) of dataSource" :key="index">
<NThing :title="item.renderKey" :description="item.renderValue" />
<NThing :title="item.title" :description="item.value" description-class="text-xs">
<template #description>
<NEllipsis
class="max-w-240 whitespace-pre-line"
:tooltip="{ contentClass: 'whitespace-pre-line text-xs max-h-100 max-w-90', scrollable: true }"
:line-clamp="3"
>
{{ item.value }}
</NEllipsis>
</template>
</NThing>>
<template #suffix>
<div class="flex flex-col items-center gap-2">
<div v-if="item.type !== 'built-in'" class="flex flex-col items-center gap-2">
<NButton tertiary size="small" type="info" @click="changeShowModal('modify', item)">
{{ t('common.edit') }}
</NButton>
Expand Down