Skip to content

Commit cfd8d3b

Browse files
committed
[Fix] 🐛 Prompt Selector Style Error on Dark Mode #404
1 parent 7fc3523 commit cfd8d3b

File tree

6 files changed

+36
-147
lines changed

6 files changed

+36
-147
lines changed

frontend/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
"format": "prettier --write src/"
1313
},
1414
"dependencies": {
15-
"naive-ui": "^2.34.4",
15+
"naive-ui": "^2.38.1",
1616
"pinia": "^2.0.36",
1717
"pinia-plugin-persistedstate": "^3.1.0",
1818
"vue": "^3.3.2",
19-
"vue-router": "^4.2.0",
20-
"vue3-virtual-scroll-list": "^0.2.1"
19+
"vue-router": "^4.2.0"
2120
},
2221
"devDependencies": {
2322
"@rushstack/eslint-patch": "^1.2.0",

frontend/src/components/ChatPromptStore/ChatPromptItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const showEditPromptPop = (item: IPrompt) => {
2727
</script>
2828

2929
<template>
30-
<NThing class="hover:bg-gray-100 cursor-pointer p-5">
30+
<NThing class="hover:bg-gray-400 dark:md:hover:bg-slate-800 cursor-pointer p-5">
3131
<template #description>
3232
<NTag type="info">
3333
<span class="inline-block max-w-[120px] xl:max-w-[650px] overflow-hidden text-ellipsis">{{ source.act }}</span>

frontend/src/components/ChatPromptStore/ChatPromptStore.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<script setup lang="ts">
22
import { ref } from 'vue';
3-
import { NModal, NList, NListItem, NButton, useMessage, NSpace, NInput, NUpload, type UploadFileInfo, NEmpty } from 'naive-ui';
3+
import { NModal, NList, NListItem, NButton, useMessage, NSpace, NInput, NUpload, NVirtualList, type UploadFileInfo, NEmpty } from 'naive-ui';
44
import { usePromptStore, type IPrompt, type IPromptDownloadConfig } from '@/stores/modules/prompt';
55
import { storeToRefs } from 'pinia';
6-
import VirtualList from 'vue3-virtual-scroll-list';
76
import ChatPromptItem from './ChatPromptItem.vue';
87
98
const messgae = useMessage();
@@ -155,14 +154,17 @@ const downloadPrompt = async (config: IPromptDownloadConfig) => {
155154
<NButton secondary type="success" @click="exportPrompt" :loading="isExporting">导出</NButton>
156155
<NButton secondary type="error" @click="clearPrompt">清空</NButton>
157156
</div>
158-
<VirtualList
157+
<NVirtualList
159158
v-if="searchPromptList.length > 0"
160159
class="h-[40vh] xl:h-[60vh] overflow-y-auto"
161-
:data-key="'prompt'"
162-
:data-sources="searchPromptList"
163-
:data-component="ChatPromptItem"
164-
:keeps="10"
165-
/>
160+
:item-size="131"
161+
item-resizable
162+
:items="searchPromptList"
163+
>
164+
<template #default="{ item, index }">
165+
<ChatPromptItem :index="index" :source="item" />
166+
</template>
167+
</NVirtualList>
166168
<NEmpty v-else class="h-[40vh] xl:h-[60vh] flex justify-center items-center" description="暂无数据">
167169
<template #extra>
168170
<NButton secondary type="info" @click="isShowDownloadPop = true">下载提示词</NButton>

frontend/src/views/chat/components/Chat/Chat.vue

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<script setup lang="ts">
22
import { onMounted, ref, computed, h } from 'vue';
3-
import { NEmpty, NButton, useDialog, useMessage, NResult, NInput, NAlert, NModal} from 'naive-ui';
3+
import { NEmpty, NButton, useDialog, useMessage, NResult, NInput, NAlert, NModal, NPopover, NVirtualList} from 'naive-ui';
44
import conversationCssText from '@/assets/css/conversation.css?raw';
55
import { usePromptStore, type IPrompt } from '@/stores/modules/prompt';
66
import { storeToRefs } from 'pinia';
7-
import VirtualList from 'vue3-virtual-scroll-list';
87
import ChatPromptItem from './ChatPromptItem.vue';
98
import { isMobile } from '@/utils/utils';
109
import LoadingSpinner from '@/components/LoadingSpinner/LoadingSpinner.vue';
@@ -456,31 +455,35 @@ const auth = async () => {
456455
<template>
457456
<LoadingSpinner :is-show="isShowLoading" />
458457
<main>
459-
<div
460-
v-if="isShowChatPrompt"
461-
class="box-border fixed bottom-[110px] w-full flex justify-center px-[14px] md:px-[34px] z-999"
462-
:class="{
463-
'md:px-[170px]': isShowHistory,
464-
'xl:px-[220px]': isShowHistory,
465-
}"
458+
<NPopover
459+
trigger="manual"
460+
:show="isShowChatPrompt"
461+
:show-arrow="false"
462+
class="max-w-[1060px] max-h-[390px]"
463+
:to="false"
466464
>
465+
<template #trigger>
466+
<NButton style="position: fixed; left: 20px; bottom: 80px; z-index: -1;" />
467+
</template>
467468
<div class="w-0 md:w-[60px]"></div>
468-
<VirtualList
469-
ref="scrollbarRef"
469+
<NVirtualList
470470
v-if="promptList.length > 0"
471-
class="bg-white w-full max-w-[1060px] max-h-[390px] rounded-xl overflow-y-auto"
472-
:data-key="'prompt'"
473-
:data-sources="searchPromptList"
474-
:data-component="ChatPromptItem"
475-
:keeps="10"
471+
class="w-full max-w-[1060px] max-h-[390px] overflow-y-auto"
472+
:item-size="131"
473+
item-resizable
474+
:items="promptList"
476475
@scroll="handlePromptListScroll"
477-
/>
478-
<NEmpty v-else class="bg-white w-full max-w-[1060px] max-h-[390px] rounded-xl py-6" description="暂未设置提示词数据">
476+
>
477+
<template #default="{ item, index }">
478+
<ChatPromptItem :index="index" :source="item" />
479+
</template>
480+
</NVirtualList>
481+
<NEmpty v-else class="w-full max-w-[1060px] max-h-[390px] rounded-xl py-6" description="暂未设置提示词数据">
479482
<template #extra>
480483
<NButton secondary type="info" @click="isShowPromptSotre = true">去提示词库添加</NButton>
481484
</template>
482485
</NEmpty>
483-
</div>
486+
</NPopover>
484487
</main>
485488
<footer>
486489
<!-- 服务器选择 -->

frontend/src/views/chat/components/Chat/ChatPromptItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const selectPrompt = (item: IPrompt) => {
2525

2626
<template>
2727
<NThing
28-
class="hover:bg-gray-100 cursor-pointer px-5 h-[130px] flex justify-start items-center"
28+
class="hover:bg-gray-400 cursor-pointer px-5 h-[130px] flex justify-start items-center"
2929
:class="{
3030
'bg-gray-100': index === selectedPromptIndex,
3131
}"

frontend/types/vue3-virtual-scroll-list.d.ts

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)