Skip to content

Commit 9c46146

Browse files
committed
优化:优化提示词库组件,替换分类选择为标签式布局,简化二级分类选择逻辑,提升用户体验
1 parent 86e8582 commit 9c46146

File tree

1 file changed

+57
-34
lines changed

1 file changed

+57
-34
lines changed

frontend/src/components/PromptLibrary.vue

Lines changed: 57 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="flex justify-between items-center mb-2">
66
<label class="block text-sm font-medium">提示词库</label>
77
</div>
8-
<div class="flex flex-wrap gap-2 bg-base-200 p-3 rounded-md">
8+
<div class="bg-base-200 p-3 rounded-md">
99
<!-- 加载状态 -->
1010
<div v-if="isLoading" class="text-center text-base-content/50 py-6 w-full flex justify-center items-center">
1111
<i class="icon-[tabler--loader-2] animate-spin mr-2"></i> 正在加载提示词库...
@@ -22,46 +22,69 @@
2222
</div>
2323

2424
<!-- 提示词列表 -->
25-
<div v-else class="flex flex-wrap gap-2 w-full">
25+
<div v-else class="w-full">
2626
<!-- 分类选择 -->
27-
<div class="w-full mb-2 flex gap-2 flex-wrap">
28-
<div class="dropdown">
29-
<label tabindex="0" class="btn btn-sm">
30-
{{ selectedCategory || '选择一级分类' }}
31-
<i class="icon-[tabler--chevron-down]"></i>
32-
</label>
33-
<ul tabindex="0" class="dropdown-content z-[1] menu shadow bg-base-100 rounded-box w-52">
34-
<li><a @click="selectedCategory = ''">全部</a></li>
35-
<li v-for="category in categories" :key="category">
36-
<a @click="selectedCategory = category">{{ category }}</a>
37-
</li>
38-
</ul>
27+
<div class="mb-4">
28+
<div class="tabs tabs-bordered">
29+
<!-- 全部分类选项 -->
30+
<button
31+
class="tab"
32+
:class="{'tab-active': selectedCategory === ''}"
33+
@click="selectedCategory = ''"
34+
>
35+
全部
36+
</button>
37+
38+
<!-- 一级分类选项 -->
39+
<button
40+
v-for="category in categories"
41+
:key="category"
42+
class="tab"
43+
:class="{'tab-active': selectedCategory === category}"
44+
@click="selectedCategory = category"
45+
>
46+
{{ category }}
47+
</button>
3948
</div>
4049

41-
<div class="dropdown" v-if="selectedCategory">
42-
<label tabindex="0" class="btn btn-sm">
43-
{{ selectedSubCategory || '选择二级分类' }}
44-
<i class="icon-[tabler--chevron-down]"></i>
45-
</label>
46-
<ul tabindex="0" class="dropdown-content z-[1] menu shadow bg-base-100 rounded-box w-52">
47-
<li><a @click="selectedSubCategory = ''">全部</a></li>
48-
<li v-for="subCategory in subCategories" :key="subCategory">
49-
<a @click="selectedSubCategory = subCategory">{{ subCategory }}</a>
50-
</li>
51-
</ul>
50+
<!-- 二级分类选择 -->
51+
<div v-if="selectedCategory && subCategories.length > 0" class="mt-2">
52+
<div class="badge-group flex flex-wrap gap-2 mt-2">
53+
<!-- 全部二级分类选项 -->
54+
<button
55+
class="badge badge-outline"
56+
:class="{'badge-primary': selectedSubCategory === ''}"
57+
@click="selectedSubCategory = ''"
58+
>
59+
全部
60+
</button>
61+
62+
<!-- 二级分类选项 -->
63+
<button
64+
v-for="subCategory in subCategories"
65+
:key="subCategory"
66+
class="badge badge-outline"
67+
:class="{'badge-primary': selectedSubCategory === subCategory}"
68+
@click="selectedSubCategory = subCategory"
69+
>
70+
{{ subCategory }}
71+
</button>
72+
</div>
5273
</div>
5374
</div>
5475

5576
<!-- 提示词列表 -->
56-
<button
57-
v-for="(prompt, index) in promptLibraryFiltered"
58-
:key="'lib-prompt-' + index"
59-
class="badge badge-lg badge-secondary h-auto cursor-pointer"
60-
@click="selectPrompt(prompt)"
61-
>
62-
<div class="text-sm">{{ prompt.chinese }}</div>
63-
<div class="text-xs opacity-80">{{ prompt.english }}</div>
64-
</button>
77+
<div class="flex flex-wrap gap-2">
78+
<button
79+
v-for="(prompt, index) in promptLibraryFiltered"
80+
:key="'lib-prompt-' + index"
81+
class="badge badge-lg badge-secondary h-auto cursor-pointer"
82+
@click="selectPrompt(prompt)"
83+
>
84+
<div class="text-sm">{{ prompt.chinese }}</div>
85+
<div class="text-xs opacity-80">{{ prompt.english }}</div>
86+
</button>
87+
</div>
6588
</div>
6689
</div>
6790
</div>

0 commit comments

Comments
 (0)