Skip to content

Commit 895c101

Browse files
committed
refactor: update dashboard view selected style
1 parent 0bbdd4f commit 895c101

File tree

3 files changed

+185
-35
lines changed

3 files changed

+185
-35
lines changed

frontend/src/i18n/zh-CN.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
"password_reset_successful": "重置密码成功"
3535
},
3636
"dashboard": {
37+
"no_chat": "暂无对话",
38+
"today": "今日",
39+
"this_week": "本周",
40+
"earlier": "更早",
3741
"add_component_tips": "从顶部工具栏中选择组件,添加到这里创建仪表板",
3842
"add_view": "添加图表",
3943
"delete_dashboard_warn": "是否删除仪表板:{0}",

frontend/src/views/dashboard/editor/ChatChartSelection.vue

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -214,33 +214,14 @@ defineExpose({
214214
color: #1f2329;
215215
line-height: 22px;
216216
}
217-
</style>
218-
219-
<style lang="less" scoped>
220-
.custom-drawer {
221-
.ed-drawer__footer {
222-
height: 64px !important;
223-
padding: 0 !important;
224-
box-shadow: 0 -1px 0px #d7d7d7 !important;
225-
}
226-
227-
.ed-drawer__body {
228-
padding: 0 0 64px 0 !important;
229-
}
230-
}
231217
232218
.chat-container {
233219
height: 100%;
234-
235220
.chat-container-left {
236221
padding-top: 20px;
237222
--ed-aside-width: 260px;
238223
border-radius: 12px 0 0 12px;
239-
//box-shadow: 0 0 3px #d7d7d7;
240-
//z-index: 1;
241-
242-
background: var(--ed-fill-color-blank);
243-
224+
border-right: 1px solid rgba(31, 35, 41, 0.15);
244225
.chat-container-right-container {
245226
height: 100%;
246227
@@ -258,7 +239,6 @@ defineExpose({
258239
259240
.chat-record-list {
260241
padding: 0 0 20px 0;
261-
background: rgba(255, 255, 255, 1);
262242
}
263243
264244
.chat-footer {
@@ -295,3 +275,18 @@ defineExpose({
295275
}
296276
}
297277
</style>
278+
279+
<style lang="less">
280+
.custom-drawer {
281+
.ed-drawer__footer {
282+
height: 64px !important;
283+
padding: 0 !important;
284+
box-shadow: 0 -1px 0px #d7d7d7 !important;
285+
}
286+
287+
.ed-drawer__body {
288+
background: rgba(245, 246, 247, 1) !important;
289+
padding: 0 0 64px 0 !important;
290+
}
291+
}
292+
</style>

frontend/src/views/dashboard/editor/DashboardChatList.vue

Lines changed: 165 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<script setup lang="ts">
22
import { type Chat } from '@/api/chat.ts'
3+
import { ElIcon } from 'element-plus-secondary'
4+
import { Icon } from '@/components/icon-custom'
5+
import { ref, computed } from 'vue'
6+
import { useI18n } from 'vue-i18n'
7+
import icon_searchOutline_outlined from '@/assets/svg/icon_search-outline_outlined.svg'
38
4-
withDefaults(
9+
const props = withDefaults(
510
defineProps<{
611
currentChatId?: number
712
chatList: Array<Chat>
@@ -11,28 +16,139 @@ withDefaults(
1116
chatList: () => [],
1217
}
1318
)
14-
19+
const { t } = useI18n()
1520
const emits = defineEmits(['chatSelected'])
21+
const filterText = ref('')
1622
1723
function onClickHistory(chat: Chat) {
1824
emits('chatSelected', chat)
1925
}
26+
27+
// 获取当前日期和本周的开始日期
28+
const now = new Date()
29+
const startOfWeek = new Date(now)
30+
startOfWeek.setDate(now.getDate() - now.getDay() + (now.getDay() === 0 ? -6 : 1)) // 设置为本周一
31+
startOfWeek.setHours(0, 0, 0, 0)
32+
33+
// 格式化日期函数
34+
const formatDate = (dateString: string) => {
35+
const date = new Date(dateString)
36+
return date.toLocaleString()
37+
}
38+
39+
// 过滤和分类数据
40+
const filteredAndGroupedData = computed(() => {
41+
const today: Chat[] = []
42+
const thisWeek: Chat[] = []
43+
const earlier: Chat[] = []
44+
45+
// 先过滤数据
46+
const filteredList = props.chatList.filter(
47+
(chat) =>
48+
!filterText.value ||
49+
(chat.brief && chat.brief.toLowerCase().includes(filterText.value.toLowerCase()))
50+
)
51+
52+
// 然后分类
53+
filteredList.forEach((item) => {
54+
const itemDate = new Date(item.create_time)
55+
56+
// 检查是否是今天
57+
if (
58+
itemDate.getDate() === now.getDate() &&
59+
itemDate.getMonth() === now.getMonth() &&
60+
itemDate.getFullYear() === now.getFullYear()
61+
) {
62+
today.push(item)
63+
}
64+
// 检查是否是本周但不是今天
65+
else if (itemDate >= startOfWeek && itemDate < now) {
66+
thisWeek.push(item)
67+
}
68+
// 更早的数据
69+
else {
70+
earlier.push(item)
71+
}
72+
})
73+
74+
return { today, thisWeek, earlier }
75+
})
2076
</script>
2177

2278
<template>
23-
<el-scrollbar ref="chatListRef">
24-
<div class="chat-list-inner">
25-
<template v-for="chat in chatList" :key="chat.id">
79+
<div style="width: 100%; height: 100%">
80+
<el-input
81+
v-model="filterText"
82+
:placeholder="t('dashboard.search')"
83+
clearable
84+
class="search-bar"
85+
>
86+
<template #prefix>
87+
<el-icon>
88+
<Icon name="icon_search-outline_outlined">
89+
<icon_searchOutline_outlined class="svg-icon" />
90+
</Icon>
91+
</el-icon>
92+
</template>
93+
</el-input>
94+
<el-scrollbar ref="chatListRef" class="custom-chart-list">
95+
<div class="chat-list-inner">
96+
<!-- today -->
97+
<div v-if="filteredAndGroupedData.today.length > 0" class="time-group">
98+
<div class="time-group-title">{{ t('dashboard.today') }}</div>
99+
<div
100+
v-for="chat in filteredAndGroupedData.today"
101+
:key="chat.id"
102+
class="chat-list-item"
103+
:class="{ active: currentChatId === chat.id }"
104+
@click="onClickHistory(chat)"
105+
>
106+
<span class="title">{{ chat.brief ?? 'Untitled' }}</span>
107+
</div>
108+
</div>
109+
110+
<!-- this week -->
111+
<div v-if="filteredAndGroupedData.thisWeek.length > 0" class="time-group">
112+
<div class="time-group-title">{{ t('dashboard.this_week') }}</div>
113+
<div
114+
v-for="chat in filteredAndGroupedData.thisWeek"
115+
:key="chat.id"
116+
class="chat-list-item"
117+
:class="{ active: currentChatId === chat.id }"
118+
@click="onClickHistory(chat)"
119+
>
120+
<span class="title">{{ chat.brief ?? 'Untitled' }}</span>
121+
</div>
122+
</div>
123+
124+
<!-- earlier -->
125+
<div v-if="filteredAndGroupedData.earlier.length > 0" class="time-group">
126+
<div class="time-group-title">{{ t('dashboard.earlier') }}</div>
127+
<div
128+
v-for="chat in filteredAndGroupedData.earlier"
129+
:key="chat.id"
130+
class="chat-list-item"
131+
:class="{ active: currentChatId === chat.id }"
132+
@click="onClickHistory(chat)"
133+
>
134+
<span class="title">{{ chat.brief ?? 'Untitled' }}</span>
135+
</div>
136+
</div>
137+
138+
<!-- no data -->
26139
<div
27-
class="chat-list-item"
28-
:class="{ active: currentChatId === chat.id }"
29-
@click="onClickHistory(chat)"
140+
v-if="
141+
filteredAndGroupedData.today.length === 0 &&
142+
filteredAndGroupedData.thisWeek.length === 0 &&
143+
filteredAndGroupedData.earlier.length === 0
144+
"
145+
class="no-data"
30146
>
31-
<span class="title">{{ chat.brief ?? 'Untitled' }}</span>
147+
{{ t('dashboard.no_chat') }}
32148
</div>
33-
</template>
34-
</div>
35-
</el-scrollbar>
149+
</div>
150+
</el-scrollbar>
151+
</div>
36152
</template>
37153

38154
<style scoped lang="less">
@@ -49,6 +165,24 @@ function onClickHistory(chat: Chat) {
49165
50166
gap: 8px;
51167
168+
.time-group {
169+
display: flex;
170+
flex-direction: column;
171+
gap: 8px;
172+
margin-top: 12px;
173+
174+
&:first-child {
175+
margin-top: 0;
176+
}
177+
178+
.time-group-title {
179+
font-size: 12px;
180+
color: rgba(100, 106, 115, 1);
181+
padding: 4px 8px;
182+
font-weight: 500;
183+
}
184+
}
185+
52186
.chat-list-item {
53187
width: 100%;
54188
height: 42px;
@@ -67,6 +201,8 @@ function onClickHistory(chat: Chat) {
67201
.title {
68202
flex: 1;
69203
width: 0;
204+
color: rgba(31, 35, 41, 1);
205+
font-size: 14px;
70206
overflow: hidden;
71207
text-overflow: ellipsis;
72208
white-space: nowrap;
@@ -80,16 +216,31 @@ function onClickHistory(chat: Chat) {
80216
}
81217
82218
&:hover {
83-
background-color: var(--hover-color);
219+
background-color: rgba(255, 255, 255, 0.75);
84220
85221
.icon-more {
86222
display: inline-flex;
87223
}
88224
}
89225
90226
&.active {
91-
background-color: var(--active-color);
227+
background-color: rgba(255, 255, 255, 1);
92228
}
93229
}
230+
231+
.no-data {
232+
text-align: center;
233+
padding: 16px;
234+
color: var(--ed-text-color-placeholder);
235+
font-size: 14px;
236+
}
237+
}
238+
.custom-chart-list {
239+
height: calc(100% - 32px);
240+
}
241+
.search-bar {
242+
padding: 0 12px 10px 12px;
243+
width: 100%;
244+
--ed-input-bg-color: rgba(245, 246, 247, 1);
94245
}
95246
</style>

0 commit comments

Comments
 (0)