|
|
@ -1,7 +1,7 @@
|
|
|
|
<script setup lang='ts'>
|
|
|
|
<script setup lang='ts'>
|
|
|
|
import type { DataTableColumns } from 'naive-ui'
|
|
|
|
import type { DataTableColumns } from 'naive-ui'
|
|
|
|
import { computed, h, ref, watch } from 'vue'
|
|
|
|
import { computed, h, ref, watch } from 'vue'
|
|
|
|
import { NButton, NCard, NDataTable, NDivider, NInput, NLayoutContent, NMessageProvider, NModal, NPopconfirm, NSpace, NTabPane, NTabs, useMessage } from 'naive-ui'
|
|
|
|
import { NButton, NCard, NDataTable, NDivider, NInput, NLayoutContent, NList, NListItem, NModal, NPopconfirm, NSpace, NTabPane, NTabs, NThing, useMessage } from 'naive-ui'
|
|
|
|
import PromptRecommend from '../../../assets/recommend.json'
|
|
|
|
import PromptRecommend from '../../../assets/recommend.json'
|
|
|
|
import { SvgIcon } from '..'
|
|
|
|
import { SvgIcon } from '..'
|
|
|
|
import { usePromptStore } from '@/store'
|
|
|
|
import { usePromptStore } from '@/store'
|
|
|
@ -238,7 +238,7 @@ const downloadPromptTemplate = async () => {
|
|
|
|
|
|
|
|
|
|
|
|
// 移动端自适应相关
|
|
|
|
// 移动端自适应相关
|
|
|
|
const renderTemplate = () => {
|
|
|
|
const renderTemplate = () => {
|
|
|
|
const [keyLimit, valueLimit] = isMobile.value ? [6, 9] : [15, 50]
|
|
|
|
const [keyLimit, valueLimit] = isMobile.value ? [10, 30] : [15, 50]
|
|
|
|
|
|
|
|
|
|
|
|
return promptList.value.map((item: { key: string; value: string }) => {
|
|
|
|
return promptList.value.map((item: { key: string; value: string }) => {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
@ -325,145 +325,159 @@ const dataSource = computed(() => {
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<NMessageProvider>
|
|
|
|
<NModal v-model:show="show" style="width: 90%; max-width: 900px;" preset="card">
|
|
|
|
<NModal v-model:show="show" style="width: 90%; max-width: 900px;" preset="card">
|
|
|
|
<div class="space-y-4">
|
|
|
|
<div class="space-y-4">
|
|
|
|
<NTabs type="segment">
|
|
|
|
<NTabs type="segment">
|
|
|
|
<NTabPane name="local" :tab="$t('store.local')">
|
|
|
|
<NTabPane name="local" :tab="$t('store.local')">
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
class="flex gap-3 mb-4"
|
|
|
|
class="flex gap-3"
|
|
|
|
:class="[isMobile ? 'flex-col' : 'flex-row justify-between']"
|
|
|
|
:class="[isMobile ? 'flex-col' : 'flex-row justify-between']"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<div class="flex items-center space-x-4">
|
|
|
|
<div class="flex items-center space-x-4">
|
|
|
|
<NButton
|
|
|
|
<NButton
|
|
|
|
type="primary"
|
|
|
|
type="primary"
|
|
|
|
size="small"
|
|
|
|
size="small"
|
|
|
|
@click="changeShowModal('add')"
|
|
|
|
@click="changeShowModal('add')"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{{ $t('common.add') }}
|
|
|
|
{{ $t('common.add') }}
|
|
|
|
</NButton>
|
|
|
|
</NButton>
|
|
|
|
<NButton
|
|
|
|
<NButton
|
|
|
|
size="small"
|
|
|
|
size="small"
|
|
|
|
@click="changeShowModal('local_import')"
|
|
|
|
@click="changeShowModal('local_import')"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{{ $t('common.import') }}
|
|
|
|
{{ $t('common.import') }}
|
|
|
|
</NButton>
|
|
|
|
</NButton>
|
|
|
|
|
|
|
|
<NButton
|
|
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
|
|
:loading="exportLoading"
|
|
|
|
|
|
|
|
@click="exportPromptTemplate()"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{{ $t('common.export') }}
|
|
|
|
|
|
|
|
</NButton>
|
|
|
|
|
|
|
|
<NPopconfirm @positive-click="clearPromptTemplate">
|
|
|
|
|
|
|
|
<template #trigger>
|
|
|
|
|
|
|
|
<NButton size="small">
|
|
|
|
|
|
|
|
{{ $t('common.clear') }}
|
|
|
|
|
|
|
|
</NButton>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
{{ $t('store.clearStoreConfirm') }}
|
|
|
|
|
|
|
|
</NPopconfirm>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex items-center">
|
|
|
|
|
|
|
|
<NInput v-model:value="searchValue" style="width: 100%" />
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<br>
|
|
|
|
|
|
|
|
<NDataTable
|
|
|
|
|
|
|
|
:max-height="400"
|
|
|
|
|
|
|
|
:columns="columns"
|
|
|
|
|
|
|
|
:data="dataSource"
|
|
|
|
|
|
|
|
:pagination="pagination"
|
|
|
|
|
|
|
|
:bordered="false"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</NTabPane>
|
|
|
|
|
|
|
|
<NTabPane name="download" :tab="$t('store.online')">
|
|
|
|
|
|
|
|
<p class="mb-4">
|
|
|
|
|
|
|
|
{{ $t('store.onlineImportWarning') }}
|
|
|
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<div class="flex items-center gap-4">
|
|
|
|
|
|
|
|
<NInput v-model:value="downloadURL" placeholder="" />
|
|
|
|
|
|
|
|
<NButton
|
|
|
|
<NButton
|
|
|
|
strong
|
|
|
|
size="small"
|
|
|
|
secondary
|
|
|
|
:loading="exportLoading"
|
|
|
|
:disabled="downloadDisabled"
|
|
|
|
@click="exportPromptTemplate()"
|
|
|
|
:loading="importLoading"
|
|
|
|
|
|
|
|
@click="downloadPromptTemplate()"
|
|
|
|
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{{ $t('common.download') }}
|
|
|
|
{{ $t('common.export') }}
|
|
|
|
</NButton>
|
|
|
|
</NButton>
|
|
|
|
|
|
|
|
<NPopconfirm @positive-click="clearPromptTemplate">
|
|
|
|
|
|
|
|
<template #trigger>
|
|
|
|
|
|
|
|
<NButton size="small">
|
|
|
|
|
|
|
|
{{ $t('common.clear') }}
|
|
|
|
|
|
|
|
</NButton>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
{{ $t('store.clearStoreConfirm') }}
|
|
|
|
|
|
|
|
</NPopconfirm>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<NDivider />
|
|
|
|
<div class="flex items-center">
|
|
|
|
<NLayoutContent
|
|
|
|
<NInput v-model:value="searchValue" style="width: 100%" />
|
|
|
|
style="height: 360px"
|
|
|
|
</div>
|
|
|
|
content-style="background: none;"
|
|
|
|
</div>
|
|
|
|
:native-scrollbar="false"
|
|
|
|
<NDataTable
|
|
|
|
|
|
|
|
v-if="!isMobile"
|
|
|
|
|
|
|
|
:max-height="400"
|
|
|
|
|
|
|
|
:columns="columns"
|
|
|
|
|
|
|
|
:data="dataSource"
|
|
|
|
|
|
|
|
:pagination="pagination"
|
|
|
|
|
|
|
|
:bordered="false"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
<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" />
|
|
|
|
|
|
|
|
<template #suffix>
|
|
|
|
|
|
|
|
<div class="flex flex-col items-center gap-2">
|
|
|
|
|
|
|
|
<NButton tertiary size="small" type="info" @click="changeShowModal('modify', item)">
|
|
|
|
|
|
|
|
{{ t('common.edit') }}
|
|
|
|
|
|
|
|
</NButton>
|
|
|
|
|
|
|
|
<NButton tertiary size="small" type="error" @click="deletePromptTemplate(item)">
|
|
|
|
|
|
|
|
{{ t('common.delete') }}
|
|
|
|
|
|
|
|
</NButton>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
</NListItem>
|
|
|
|
|
|
|
|
</NList>
|
|
|
|
|
|
|
|
</NTabPane>
|
|
|
|
|
|
|
|
<NTabPane name="download" :tab="$t('store.online')">
|
|
|
|
|
|
|
|
<p class="mb-4">
|
|
|
|
|
|
|
|
{{ $t('store.onlineImportWarning') }}
|
|
|
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<div class="flex items-center gap-4">
|
|
|
|
|
|
|
|
<NInput v-model:value="downloadURL" placeholder="" />
|
|
|
|
|
|
|
|
<NButton
|
|
|
|
|
|
|
|
strong
|
|
|
|
|
|
|
|
secondary
|
|
|
|
|
|
|
|
:disabled="downloadDisabled"
|
|
|
|
|
|
|
|
:loading="importLoading"
|
|
|
|
|
|
|
|
@click="downloadPromptTemplate()"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{{ $t('common.download') }}
|
|
|
|
|
|
|
|
</NButton>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<NDivider />
|
|
|
|
|
|
|
|
<NLayoutContent
|
|
|
|
|
|
|
|
style="height: 360px"
|
|
|
|
|
|
|
|
content-style="background: none;"
|
|
|
|
|
|
|
|
:native-scrollbar="false"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<NCard
|
|
|
|
|
|
|
|
v-for="info in promptRecommendList"
|
|
|
|
|
|
|
|
:key="info.key" :title="info.key"
|
|
|
|
|
|
|
|
style="margin: 5px;"
|
|
|
|
|
|
|
|
embedded
|
|
|
|
|
|
|
|
:bordered="true"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<NCard
|
|
|
|
<p
|
|
|
|
v-for="info in promptRecommendList"
|
|
|
|
class="overflow-hidden text-ellipsis whitespace-nowrap"
|
|
|
|
:key="info.key" :title="info.key"
|
|
|
|
:title="info.desc"
|
|
|
|
style="margin: 5px;"
|
|
|
|
|
|
|
|
embedded
|
|
|
|
|
|
|
|
:bordered="true"
|
|
|
|
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<p
|
|
|
|
{{ info.desc }}
|
|
|
|
class="overflow-hidden text-ellipsis whitespace-nowrap"
|
|
|
|
</p>
|
|
|
|
:title="info.desc"
|
|
|
|
<template #footer>
|
|
|
|
>
|
|
|
|
<div class="flex items-center justify-end space-x-4">
|
|
|
|
{{ info.desc }}
|
|
|
|
<NButton text>
|
|
|
|
</p>
|
|
|
|
<a
|
|
|
|
<template #footer>
|
|
|
|
:href="info.url"
|
|
|
|
<div class="flex items-center justify-end space-x-4">
|
|
|
|
target="_blank"
|
|
|
|
<NButton text>
|
|
|
|
>
|
|
|
|
<a
|
|
|
|
<SvgIcon class="text-xl" icon="ri:link" />
|
|
|
|
:href="info.url"
|
|
|
|
</a>
|
|
|
|
target="_blank"
|
|
|
|
</NButton>
|
|
|
|
>
|
|
|
|
<NButton text @click="setDownloadURL(info.downloadUrl) ">
|
|
|
|
<SvgIcon class="text-xl" icon="ri:link" />
|
|
|
|
<SvgIcon class="text-xl" icon="ri:add-fill" />
|
|
|
|
</a>
|
|
|
|
</NButton>
|
|
|
|
</NButton>
|
|
|
|
</div>
|
|
|
|
<NButton text @click="setDownloadURL(info.downloadUrl) ">
|
|
|
|
</template>
|
|
|
|
<SvgIcon class="text-xl" icon="ri:add-fill" />
|
|
|
|
</NCard>
|
|
|
|
</NButton>
|
|
|
|
</NLayoutContent>
|
|
|
|
</div>
|
|
|
|
</NTabPane>
|
|
|
|
</template>
|
|
|
|
</NTabs>
|
|
|
|
</NCard>
|
|
|
|
</div>
|
|
|
|
</NLayoutContent>
|
|
|
|
</NModal>
|
|
|
|
</NTabPane>
|
|
|
|
|
|
|
|
</NTabs>
|
|
|
|
<NModal v-model:show="showModal" style="width: 90%; max-width: 600px;" preset="card">
|
|
|
|
</div>
|
|
|
|
<NSpace v-if="modalMode === 'add' || modalMode === 'modify'" vertical>
|
|
|
|
</NModal>
|
|
|
|
{{ t('store.title') }}
|
|
|
|
<NModal v-model:show="showModal" style="width: 90%; max-width: 600px;" preset="card">
|
|
|
|
<NInput v-model:value="tempPromptKey" />
|
|
|
|
<NSpace v-if="modalMode === 'add' || modalMode === 'modify'" vertical>
|
|
|
|
{{ t('store.description') }}
|
|
|
|
{{ t('store.title') }}
|
|
|
|
<NInput v-model:value="tempPromptValue" type="textarea" />
|
|
|
|
<NInput v-model:value="tempPromptKey" />
|
|
|
|
<NButton
|
|
|
|
{{ t('store.description') }}
|
|
|
|
block
|
|
|
|
<NInput v-model:value="tempPromptValue" type="textarea" />
|
|
|
|
type="primary"
|
|
|
|
<NButton
|
|
|
|
:disabled="inputStatus"
|
|
|
|
block
|
|
|
|
@click="() => { modalMode === 'add' ? addPromptTemplate() : modifyPromptTemplate() }"
|
|
|
|
type="primary"
|
|
|
|
>
|
|
|
|
:disabled="inputStatus"
|
|
|
|
{{ t('common.confirm') }}
|
|
|
|
@click="() => { modalMode === 'add' ? addPromptTemplate() : modifyPromptTemplate() }"
|
|
|
|
</NButton>
|
|
|
|
>
|
|
|
|
</NSpace>
|
|
|
|
{{ t('common.confirm') }}
|
|
|
|
<NSpace v-if="modalMode === 'local_import'" vertical>
|
|
|
|
</NButton>
|
|
|
|
<NInput
|
|
|
|
</NSpace>
|
|
|
|
v-model:value="tempPromptValue"
|
|
|
|
<NSpace v-if="modalMode === 'local_import'" vertical>
|
|
|
|
:placeholder="t('store.importPlaceholder')"
|
|
|
|
<NInput
|
|
|
|
:autosize="{ minRows: 3, maxRows: 15 }"
|
|
|
|
v-model:value="tempPromptValue"
|
|
|
|
type="textarea"
|
|
|
|
:placeholder="t('store.importPlaceholder')"
|
|
|
|
/>
|
|
|
|
:autosize="{ minRows: 3, maxRows: 15 }"
|
|
|
|
<NButton
|
|
|
|
type="textarea"
|
|
|
|
block
|
|
|
|
/>
|
|
|
|
type="primary"
|
|
|
|
<NButton
|
|
|
|
:disabled="inputStatus"
|
|
|
|
block
|
|
|
|
@click="() => { importPromptTemplate() }"
|
|
|
|
type="primary"
|
|
|
|
>
|
|
|
|
:disabled="inputStatus"
|
|
|
|
{{ t('common.import') }}
|
|
|
|
@click="() => { importPromptTemplate() }"
|
|
|
|
</NButton>
|
|
|
|
>
|
|
|
|
</NSpace>
|
|
|
|
{{ t('common.import') }}
|
|
|
|
</NModal>
|
|
|
|
</NButton>
|
|
|
|
|
|
|
|
</NSpace>
|
|
|
|
|
|
|
|
</NModal>
|
|
|
|
|
|
|
|
</NMessageProvider>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|