Skip to content

Commit 2248829

Browse files
authored
style: Adjust the recommended question style. (#566)
1 parent 0293465 commit 2248829

File tree

8 files changed

+148
-93
lines changed

8 files changed

+148
-93
lines changed

backend/apps/chat/curd/chat.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,15 @@ def list_chats(session: SessionDep, current_user: CurrentUser) -> List[Chat]:
4343
def list_recent_questions(session: SessionDep, current_user: CurrentUser, datasource_id: int) -> List[str]:
4444
chat_records = (
4545
session.query(
46-
ChatRecord.question,
47-
func.count(ChatRecord.question).label('question_count')
46+
ChatRecord.question
4847
)
4948
.join(Chat, ChatRecord.chat_id == Chat.id) # 关联Chat表
5049
.filter(
5150
Chat.datasource == datasource_id, # 使用Chat表的datasource字段
5251
ChatRecord.question.isnot(None)
5352
)
5453
.group_by(ChatRecord.question)
55-
.order_by(desc('question_count'), desc(func.max(ChatRecord.create_time)))
54+
.order_by(desc(func.max(ChatRecord.create_time)))
5655
.limit(10)
5756
.all()
5857
)

frontend/src/i18n/en.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@
193193
"chart_selected": "Selected {0}"
194194
},
195195
"qa": {
196-
"recommended_repetitive_tips": "Duplicate questions exist",
197-
"retrieve_error": "Model recommendation failed...",
196+
"retrieve_error": "No content available",
198197
"retrieve_again": "Retrieve Again",
199198
"recently": "recently",
200199
"recommend": "recommend",
@@ -324,6 +323,7 @@
324323
}
325324
},
326325
"datasource": {
326+
"recommended_repetitive_tips": "Duplicate questions exist",
327327
"recommended_problem_tips": "Custom configuration requires at least one problem, each problem should be 2-200 characters",
328328
"recommended_problem_configuration": "Recommended Problem Configuration",
329329
"problem_generation_method": "Problem Generation Method",
@@ -800,4 +800,4 @@
800800
"modelType": {
801801
"llm": "Large Language Model"
802802
}
803-
}
803+
}

frontend/src/i18n/ko-KR.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@
193193
"chart_selected": "{0}개 선택됨"
194194
},
195195
"qa": {
196-
"recommended_repetitive_tips": "중복된 문제가 존재합니다",
197-
"retrieve_error": "모델 추천 문제 실패...",
196+
"retrieve_error": "콘텐츠 없음",
198197
"retrieve_again": "다시 가져오기",
199198
"recently": "최근",
200199
"recommend": "추천",
@@ -324,6 +323,7 @@
324323
}
325324
},
326325
"datasource": {
326+
"recommended_repetitive_tips": "중복된 문제가 존재합니다",
327327
"recommended_problem_tips": "사용자 정의 구성으로 최소 한 개의 문제를 생성하세요, 각 문제는 2~200자로 작성",
328328
"recommended_problem_configuration": "추천 문제 구성",
329329
"problem_generation_method": "문제 생성 방식",
@@ -800,4 +800,4 @@
800800
"modelType": {
801801
"llm": "대형 언어 모델"
802802
}
803-
}
803+
}

frontend/src/i18n/zh-CN.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@
193193
"chart_selected": "已选{0}"
194194
},
195195
"qa": {
196-
"retrieve_error": "模型推荐问题失败...",
196+
"recommended_repetitive_tips": "Duplicate questions exist",
197+
"retrieve_error": "暂无内容",
197198
"retrieve_again": "重新获取",
198199
"recently": "最近",
199200
"recommend": "推荐",
@@ -800,4 +801,4 @@
800801
"modelType": {
801802
"llm": "大语言模型"
802803
}
803-
}
804+
}

frontend/src/views/chat/QuickQuestion.vue

Lines changed: 73 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script lang="ts" setup>
22
import { onMounted, ref } from 'vue'
33
import icon_quick_question from '@/assets/svg/icon_quick_question.svg'
4-
import icon_close from '@/assets/svg/operate/ope-close.svg'
54
import icon_replace_outlined from '@/assets/svg/icon_replace_outlined.svg'
65
import { ChatInfo } from '@/api/chat.ts'
76
import RecentQuestion from '@/views/chat/RecentQuestion.vue'
@@ -38,6 +37,9 @@ const loadingOver = () => {
3837
emits('loadingOver')
3938
}
4039
40+
const onTitleChange = (title: string) => {
41+
activeName.value = title
42+
}
4143
onMounted(() => {
4244
getRecommendQuestions()
4345
})
@@ -70,45 +72,54 @@ const props = withDefaults(
7072
popper-class="quick_question_popover"
7173
placement="top-start"
7274
trigger="click"
73-
:width="320"
75+
:width="240"
7476
>
75-
<el-button class="tool-btn close_icon" text @click="hiddenProps">
76-
<el-icon size="18">
77-
<icon_close />
78-
</el-icon>
79-
</el-button>
8077
<el-tooltip effect="dark" :offset="8" :content="$t('qa.retrieve_again')" placement="top">
8178
<el-button class="tool-btn refresh_icon" text :disabled="disabled" @click="retrieveQuestions">
8279
<el-icon size="18">
8380
<icon_replace_outlined />
8481
</el-icon>
8582
</el-button>
8683
</el-tooltip>
87-
<el-tabs v-model="activeName" class="quick_question_tab">
88-
<el-tab-pane :label="$t('qa.recommend')" name="recommend">
89-
<RecommendQuestionQuick
90-
ref="recommendQuestionRef"
91-
:current-chat="currentChat"
92-
:record-id="recordId"
93-
:questions="questions"
94-
:disabled="disabled"
95-
:first-chat="firstChat"
96-
position="input"
97-
@click-question="quickAsk"
98-
@stop="onChatStop"
99-
@loading-over="loadingOver"
100-
/>
101-
</el-tab-pane>
102-
<el-tab-pane v-if="datasourceId" :label="$t('qa.recently')" name="recently">
103-
<RecentQuestion
104-
ref="recentQuestionRef"
105-
:disabled="disabled"
106-
:datasource-id="datasourceId"
107-
@click-question="quickAsk"
108-
>
109-
</RecentQuestion>
110-
</el-tab-pane>
111-
</el-tabs>
84+
<div style="display: flex">
85+
<div
86+
class="quick_question_title"
87+
:class="{ 'title-active': activeName == 'recommend' }"
88+
@click="onTitleChange('recommend')"
89+
>
90+
{{ $t('qa.recommend') }}
91+
</div>
92+
<div
93+
class="quick_question_title"
94+
:class="{ 'title-active': activeName == 'recently' }"
95+
@click="onTitleChange('recently')"
96+
>
97+
{{ $t('qa.recently') }}
98+
</div>
99+
</div>
100+
<div class="quick_question_content">
101+
<RecommendQuestionQuick
102+
v-show="activeName === 'recommend'"
103+
ref="recommendQuestionRef"
104+
:current-chat="currentChat"
105+
:record-id="recordId"
106+
:questions="questions"
107+
:disabled="disabled"
108+
:first-chat="firstChat"
109+
position="input"
110+
@click-question="quickAsk"
111+
@stop="onChatStop"
112+
@loading-over="loadingOver"
113+
/>
114+
<RecentQuestion
115+
v-show="activeName == 'recently'"
116+
ref="recentQuestionRef"
117+
:disabled="disabled"
118+
:datasource-id="datasourceId"
119+
@click-question="quickAsk"
120+
>
121+
</RecentQuestion>
122+
</div>
112123
<template #reference>
113124
<el-button plain size="small">
114125
<el-icon size="16" class="el-icon--left">
@@ -122,21 +133,43 @@ const props = withDefaults(
122133

123134
<style lang="less">
124135
.quick_question_popover {
125-
.quick_question_tab {
126-
height: 230px;
127-
}
128-
.ed-tab-pane {
136+
padding: 4px !important;
137+
.quick_question_title {
138+
width: 40px;
139+
height: 24px;
140+
border-radius: 6px;
141+
opacity: 1;
142+
padding: 2px 8px;
143+
font-size: 12px;
129144
display: flex;
130-
align-items: normal;
131-
width: 100%;
145+
align-items: center;
146+
justify-content: center;
147+
background: rgba(31, 35, 41, 0.1);
148+
cursor: pointer;
149+
margin-left: 8px;
150+
&:hover {
151+
color: rgba(24, 158, 122, 0.5);
152+
background: rgba(28, 186, 144, 0.1);
153+
}
132154
}
133-
.ed-tabs__content {
134-
overflow: auto;
155+
.title-active {
156+
color: rgba(24, 158, 122, 1);
157+
background: rgba(28, 186, 144, 0.2);
158+
}
159+
.quick_question_content {
160+
height: 168px;
161+
margin-top: 4px;
162+
padding: 4px 4px 4px 4px;
163+
overflow-y: auto;
135164
}
136165
.ed-popover__title {
137166
font-size: 14px;
138167
font-weight: 500;
139168
margin-bottom: 0;
169+
height: 32px;
170+
display: flex;
171+
align-items: center;
172+
padding: 0 8px;
140173
}
141174
.close_icon {
142175
position: absolute;

frontend/src/views/chat/RecentQuestion.vue

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,31 @@ defineExpose({
3737
</script>
3838

3939
<template>
40-
<div v-if="computedQuestions.length > 0 || loading" class="recent-questions">
41-
<div class="question-grid-input">
42-
<div
43-
v-for="(question, index) in computedQuestions"
44-
:key="index"
45-
class="question"
46-
:class="{ disabled: disabled }"
47-
@click="clickQuestion(question)"
48-
>
49-
{{ question }}
40+
<div style="width: 100%; height: 100%">
41+
<div v-if="computedQuestions.length > 0 || loading" class="recent-questions">
42+
<div class="question-grid-input">
43+
<div
44+
v-for="(question, index) in computedQuestions"
45+
:key="index"
46+
class="question"
47+
:class="{ disabled: disabled }"
48+
:title="question"
49+
@click="clickQuestion(question)"
50+
>
51+
{{ question }}
52+
</div>
5053
</div>
5154
</div>
55+
<div v-else class="recommend-questions-error">
56+
{{ $t('qa.retrieve_error') }}
57+
</div>
5258
</div>
5359
</template>
5460

5561
<style scoped lang="less">
5662
.recent-questions {
5763
height: 100%;
5864
width: 100%;
59-
overflow-x: hidden;
60-
overflow-y: auto;
6165
font-size: 14px;
6266
font-weight: 500;
6367
line-height: 22px;
@@ -72,7 +76,7 @@ defineExpose({
7276
7377
.question-grid-input {
7478
display: grid;
75-
grid-gap: 12px;
79+
grid-gap: 1px;
7680
grid-template-columns: repeat(1, calc(100% - 6px));
7781
}
7882
@@ -85,11 +89,13 @@ defineExpose({
8589
.question {
8690
font-weight: 400;
8791
cursor: pointer;
88-
background: rgba(245, 246, 247, 1);
89-
min-height: 32px;
90-
border-radius: 6px;
91-
padding: 5px 12px;
92+
height: 32px;
93+
border-radius: 4px;
94+
padding: 5px 8px;
9295
line-height: 22px;
96+
white-space: nowrap; /* 禁止换行 */
97+
overflow: hidden; /* 隐藏溢出内容 */
98+
text-overflow: ellipsis; /* 显示省略号 */
9399
&:hover {
94100
background: rgba(31, 35, 41, 0.1);
95101
}
@@ -99,4 +105,15 @@ defineExpose({
99105
}
100106
}
101107
}
108+
109+
.recommend-questions-error {
110+
font-size: 14px;
111+
font-weight: 400;
112+
color: rgba(100, 106, 115, 1);
113+
margin-top: 60px;
114+
display: flex;
115+
align-items: center;
116+
justify-content: center;
117+
width: 100%;
118+
}
102119
</style>

0 commit comments

Comments
 (0)