Repository navigation
feat: model display order #5090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9ebf9ee
feat: add model display ordering
VirtualHotBar 2d99f3f
feat: expose model ordering in classic UI
VirtualHotBar 900e718
fix: add classic model ordering translations
VirtualHotBar 56cb668
fix: address CodeRabbit review — RowsAffected check, stable sort, inp…
VirtualHotBar ddcae44
fix: avoid false not-found on no-op update — verify row exists before…
VirtualHotBar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,12 +24,17 @@ import { | |
| Tag, | ||
| Typography, | ||
| Modal, | ||
| InputNumber, | ||
| Switch, | ||
| Tooltip, | ||
| } from '@douyinfe/semi-ui'; | ||
| import { | ||
| timestamp2string, | ||
| getLobeHubIcon, | ||
| stringToColor, | ||
| API, | ||
| showError, | ||
| showSuccess, | ||
| } from '../../../helpers'; | ||
| import { | ||
| renderLimitedItems, | ||
|
|
@@ -38,6 +43,24 @@ import { | |
|
|
||
| const { Text } = Typography; | ||
|
|
||
| const updateModelOrdering = async (record, changes, refresh, t) => { | ||
| try { | ||
| const res = await API.put('/api/models/?order_only=true', { | ||
| id: record.id, | ||
| ...changes, | ||
| }); | ||
| const { success, message } = res.data; | ||
| if (success) { | ||
| showSuccess(t('操作成功完成!')); | ||
| await refresh(); | ||
| } else { | ||
| showError(t(message)); | ||
| } | ||
| } catch (error) { | ||
| showError(error.response?.data?.message || t('操作失败')); | ||
| } | ||
| }; | ||
|
|
||
| // Render timestamp | ||
| function renderTimestamp(timestamp) { | ||
| return <>{timestamp2string(timestamp)}</>; | ||
|
|
@@ -298,6 +321,55 @@ export const getModelsColumns = ({ | |
| </Text> | ||
| ), | ||
| }, | ||
| { | ||
| title: t('置顶'), | ||
| dataIndex: 'pinned', | ||
| align: 'center', | ||
| width: 90, | ||
| render: (value, record) => ( | ||
| <div onClick={(e) => e.stopPropagation()}> | ||
| <Switch | ||
| size='small' | ||
| checked={Boolean(value)} | ||
| onChange={(checked) => | ||
| updateModelOrdering( | ||
| record, | ||
| { pinned: checked ? 1 : 0 }, | ||
| refresh, | ||
| t, | ||
| ) | ||
| } | ||
| /> | ||
| </div> | ||
| ), | ||
| }, | ||
| { | ||
| title: t('展示顺序'), | ||
| dataIndex: 'display_order', | ||
| width: 130, | ||
| render: (value, record) => ( | ||
| <div onClick={(e) => e.stopPropagation()}> | ||
| <InputNumber | ||
| key={`${record.id}-${value ?? 0}`} | ||
| size='small' | ||
| defaultValue={value ?? 0} | ||
| step={1} | ||
|
Comment on lines
+352
to
+356
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested patch- <InputNumber
+ <InputNumber
size='small'
- defaultValue={value ?? 0}
+ value={value ?? 0}
step={1}🤖 Prompt for AI Agents |
||
| min={0} | ||
| onBlur={(event) => { | ||
| const nextValue = Number(event.target.value || 0); | ||
| if (nextValue === (record.display_order ?? 0)) return; | ||
| updateModelOrdering( | ||
| record, | ||
| { display_order: nextValue }, | ||
| refresh, | ||
| t, | ||
| ); | ||
| }} | ||
| style={{ width: 96 }} | ||
| /> | ||
| </div> | ||
| ), | ||
| }, | ||
| { | ||
| title: t('匹配类型'), | ||
| dataIndex: 'name_rule', | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not map DB count errors to “模型不存在”.
Line 155 currently treats query errors and true not-found as the same result. That can hide real DB failures and return a false 404-style message.
Suggested fix
🤖 Prompt for AI Agents