Skip to content

Commit be40799

Browse files
committed
style: 更新多个组件以使用分段控件替代按钮组
1 parent edc4caa commit be40799

File tree

5 files changed

+83
-110
lines changed

5 files changed

+83
-110
lines changed

server/utils/migrate.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,7 @@ def check_and_migrate(db_path: str):
350350
logger.warning(f" - {issue}")
351351

352352
if os.path.exists(db_path):
353-
logger.info(
354-
"建议运行迁移脚本: docker exec api-dev python /app/scripts/migrate_user_soft_delete.py"
355-
)
353+
logger.info("建议运行迁移脚本: docker exec api-dev python /app/scripts/migrate_user_soft_delete.py")
356354

357355
migrator = DatabaseMigrator(db_path)
358356

web/src/components/AgentConfigSidebar.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@
234234
<a-modal
235235
v-model:open="toolsModalOpen"
236236
title="选择工具"
237-
:width="600"
237+
:width="800"
238238
:footer="null"
239239
:maskClosable="false"
240240
class="tools-modal"
@@ -569,7 +569,7 @@ watch(() => props.isOpen, (newVal) => {
569569
570570
<style lang="less" scoped>
571571
572-
@padding-bottom: 40px;
572+
@padding-bottom: 0px;
573573
.agent-config-sidebar {
574574
position: relative;
575575
width: 0;
@@ -642,7 +642,7 @@ watch(() => props.isOpen, (newVal) => {
642642
643643
.sidebar-footer {
644644
position: sticky;
645-
bottom: 16px;
645+
bottom: 0px;
646646
padding: 12px 0;
647647
border-top: 1px solid var(--gray-100);
648648
background: #fff;
@@ -1159,4 +1159,4 @@ watch(() => props.isOpen, (newVal) => {
11591159
width: 100vw;
11601160
}
11611161
}
1162-
</style>
1162+
</style>

web/src/components/TaskCenterDrawer.vue

Lines changed: 47 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,10 @@
99
<div class="task-center">
1010
<div class="task-toolbar">
1111
<div class="task-filter-group">
12-
<a-button-group>
13-
<a-button
14-
:type="isActiveFilter('all') ? 'primary' : 'default'"
15-
@click="setFilter('all')"
16-
>
17-
全部
18-
<span class="filter-count">{{ totalCount }}</span>
19-
</a-button>
20-
<a-button
21-
:type="isActiveFilter('active') ? 'primary' : 'default'"
22-
@click="setFilter('active')"
23-
>
24-
进行中
25-
<span class="filter-count">{{ inProgressCount }}</span>
26-
</a-button>
27-
<a-button
28-
:type="isActiveFilter('success') ? 'primary' : 'default'"
29-
@click="setFilter('success')"
30-
>
31-
已完成
32-
<span class="filter-count">{{ completedCount }}</span>
33-
</a-button>
34-
<a-button
35-
:type="isActiveFilter('failed') ? 'primary' : 'default'"
36-
@click="setFilter('failed')"
37-
>
38-
失败
39-
<span class="filter-count">{{ failedCount }}</span>
40-
</a-button>
41-
</a-button-group>
12+
<a-segmented
13+
v-model:value="statusFilter"
14+
:options="taskFilterOptions"
15+
/>
4216
</div>
4317
<div class="task-toolbar-actions">
4418
<a-button
@@ -135,7 +109,6 @@ import { computed, h, onBeforeUnmount, watch, ref } from 'vue'
135109
import { Modal } from 'ant-design-vue'
136110
import { useTaskerStore } from '@/stores/tasker'
137111
import { storeToRefs } from 'pinia'
138-
import { ReloadOutlined } from '@ant-design/icons-vue'
139112
import { formatFullDateTime, formatRelative, parseToShanghai } from '@/utils/time'
140113
141114
const taskerStore = useTaskerStore()
@@ -146,6 +119,48 @@ const tasks = computed(() => sortedTasks.value)
146119
const loadingState = computed(() => Boolean(loading.value))
147120
const lastErrorState = computed(() => lastError.value)
148121
const statusFilter = ref('all')
122+
const inProgressCount = computed(
123+
() => tasks.value.filter((task) => ACTIVE_CLASS_STATUSES.has(task.status)).length
124+
)
125+
const completedCount = computed(() => tasks.value.filter((task) => task.status === 'success').length)
126+
const failedCount = computed(
127+
() => tasks.value.filter((task) => FAILED_STATUSES.has(task.status)).length
128+
)
129+
const totalCount = computed(() => tasks.value.length)
130+
const taskFilterOptions = computed(() => [
131+
{
132+
label: () =>
133+
h('span', { class: 'task-filter-option' }, [
134+
'全部',
135+
h('span', { class: 'filter-count' }, totalCount.value)
136+
]),
137+
value: 'all'
138+
},
139+
{
140+
label: () =>
141+
h('span', { class: 'task-filter-option' }, [
142+
'进行中',
143+
h('span', { class: 'filter-count' }, inProgressCount.value)
144+
]),
145+
value: 'active'
146+
},
147+
{
148+
label: () =>
149+
h('span', { class: 'task-filter-option' }, [
150+
'已完成',
151+
h('span', { class: 'filter-count' }, completedCount.value)
152+
]),
153+
value: 'success'
154+
},
155+
{
156+
label: () =>
157+
h('span', { class: 'task-filter-option' }, [
158+
'失败',
159+
h('span', { class: 'filter-count' }, failedCount.value)
160+
]),
161+
value: 'failed'
162+
}
163+
])
149164
150165
const filteredTasks = computed(() => {
151166
const list = tasks.value
@@ -321,22 +336,6 @@ function canCancel(task) {
321336
return ['pending', 'running', 'queued'].includes(task.status) && !task.cancel_requested
322337
}
323338
324-
const inProgressCount = computed(
325-
() => tasks.value.filter((task) => ACTIVE_CLASS_STATUSES.has(task.status)).length
326-
)
327-
const completedCount = computed(() => tasks.value.filter((task) => task.status === 'success').length)
328-
const failedCount = computed(
329-
() => tasks.value.filter((task) => FAILED_STATUSES.has(task.status)).length
330-
)
331-
const totalCount = computed(() => tasks.value.length)
332-
333-
function setFilter(value) {
334-
statusFilter.value = value
335-
}
336-
337-
function isActiveFilter(value) {
338-
return statusFilter.value === value
339-
}
340339
</script>
341340
<style scoped lang="less">
342341
.task-center {
@@ -365,13 +364,7 @@ function isActiveFilter(value) {
365364
gap: 4px;
366365
}
367366
368-
.task-filter-group :deep(.ant-btn) {
369-
display: inline-flex;
370-
align-items: center;
371-
gap: 4px;
372-
}
373-
374-
.filter-count {
367+
:deep(.filter-count) {
375368
margin-left: 2px;
376369
font-size: 12px;
377370
color: #94a3b8;

web/src/components/dashboard/FeedbackModalComponent.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
:footer="null"
88
>
99
<a-space style="margin-bottom: 16px">
10-
<a-radio-group v-model:value="feedbackFilter" @change="loadFeedbacks">
11-
<a-radio-button value="all">全部</a-radio-button>
12-
<a-radio-button value="like">点赞</a-radio-button>
13-
<a-radio-button value="dislike">点踩</a-radio-button>
14-
</a-radio-group>
10+
<a-segmented
11+
v-model:value="feedbackFilter"
12+
:options="feedbackOptions"
13+
@change="loadFeedbacks"
14+
/>
1515
</a-space>
1616

1717
<!-- 卡片列表 -->
@@ -92,7 +92,7 @@
9292
</template>
9393

9494
<script setup>
95-
import { ref, reactive, watch } from 'vue'
95+
import { ref, watch } from 'vue'
9696
import { message } from 'ant-design-vue'
9797
import { LikeOutlined, DislikeOutlined, ClockCircleOutlined } from '@ant-design/icons-vue'
9898
import { dashboardApi } from '@/apis/dashboard_api'
@@ -113,6 +113,11 @@ const modalVisible = ref(false)
113113
const feedbacks = ref([])
114114
const loadingFeedbacks = ref(false)
115115
const feedbackFilter = ref('all')
116+
const feedbackOptions = [
117+
{ label: '全部', value: 'all' },
118+
{ label: '点赞', value: 'like' },
119+
{ label: '点踩', value: 'dislike' }
120+
]
116121
117122
// 显示模态框
118123
const show = () => {

web/src/views/SettingView.vue

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@
1818
<h3>检索配置</h3>
1919
<div class="section">
2020
<div class="card card-select">
21-
<span class="label">对话模型</span>
21+
<span class="label">{{ items?.default_model?.des || '默认对话模型' }}</span>
2222
<ModelSelectorComponent
2323
@select-model="handleChatModelSelect"
24-
:model_name="configStore.config?.model_name"
25-
:model_provider="configStore.config?.model_provider"
24+
:model_spec="configStore.config?.default_model"
25+
placeholder="请选择默认模型"
2626
/>
2727
</div>
2828
<div class="card card-select">
2929
<span class="label">{{ items?.fast_model.des }}</span>
3030
<ModelSelectorComponent
3131
@select-model="handleFastModelSelect"
32-
:model_name="fastModelName"
33-
:model_provider="fastModelProvider"
32+
:model_spec="configStore.config?.fast_model"
33+
placeholder="请选择模型"
3434
/>
3535
</div>
3636
<div class="card card-select">
@@ -109,8 +109,8 @@
109109
<span class="label">{{ items?.content_guard_llm_model.des }}</span>
110110
<ModelSelectorComponent
111111
@select-model="handleContentGuardModelSelect"
112-
:model_name="contentGuardModelName"
113-
:model_provider="contentGuardModelProvider"
112+
:model_spec="configStore.config?.content_guard_llm_model"
113+
placeholder="请选择模型"
114114
/>
115115
</div>
116116
</div>
@@ -251,45 +251,22 @@ const updateWindowWidth = () => {
251251
state.windowWidth = window?.innerWidth || 0
252252
}
253253
254-
const handleChatModelSelect = ({ provider, name }) => {
255-
configStore.setConfigValues({
256-
model_provider: provider,
257-
model_name: name,
258-
})
254+
const handleChatModelSelect = (spec) => {
255+
if (typeof spec === 'string' && spec) {
256+
configStore.setConfigValue('default_model', spec)
257+
}
259258
}
260259
261-
const fastModelProvider = computed(() => {
262-
const fastModel = configStore.config?.fast_model
263-
if (!fastModel) return ''
264-
return fastModel.split('/')[0]
265-
})
266-
267-
const fastModelName = computed(() => {
268-
const fastModel = configStore.config?.fast_model
269-
if (!fastModel) return ''
270-
const parts = fastModel.split('/')
271-
return parts.slice(1).join('/')
272-
})
273-
274-
const handleFastModelSelect = ({ provider, name }) => {
275-
configStore.setConfigValue('fast_model', `${provider}/${name}`)
260+
const handleFastModelSelect = (spec) => {
261+
if (typeof spec === 'string' && spec) {
262+
configStore.setConfigValue('fast_model', spec)
263+
}
276264
}
277265
278-
const contentGuardModelProvider = computed(() => {
279-
const contentGuardModel = configStore.config?.content_guard_llm_model
280-
if (!contentGuardModel) return ''
281-
return contentGuardModel.split('/')[0]
282-
})
283-
284-
const contentGuardModelName = computed(() => {
285-
const contentGuardModel = configStore.config?.content_guard_llm_model
286-
if (!contentGuardModel) return ''
287-
const parts = contentGuardModel.split('/')
288-
return parts.slice(1).join('/')
289-
})
290-
291-
const handleContentGuardModelSelect = ({ provider, name }) => {
292-
configStore.setConfigValue('content_guard_llm_model', `${provider}/${name}`)
266+
const handleContentGuardModelSelect = (spec) => {
267+
if (typeof spec === 'string' && spec) {
268+
configStore.setConfigValue('content_guard_llm_model', spec)
269+
}
293270
}
294271
295272
onMounted(() => {
@@ -381,7 +358,7 @@ const openLink = (url) => {
381358
382359
.setting-container {
383360
--setting-header-height: 55px;
384-
max-width: 870px;
361+
max-width: 1054px;
385362
}
386363
387364
.setting-header {

0 commit comments

Comments
 (0)