Skip to content

Commit

Permalink
🔖 chore: optimize channel list
Browse files Browse the repository at this point in the history
  • Loading branch information
MartialBE committed Aug 10, 2024
1 parent 42cb6f2 commit 1bd449e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion model/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func GetChannelsList(params *SearchChannelsParams) (*DataResult[Channel], error)
}

if params.Name != "" {
db = db.Where("name LIKE ?", params.Name+"%")
db = db.Where("name LIKE ?", "%"+params.Name+"%")
}

if params.Group != "" {
Expand Down
20 changes: 11 additions & 9 deletions web/src/views/Channel/ChannelList.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export default function ChannelList() {
if (success) {
showSuccess(t('userPage.operationSuccess'));
if (action === 'delete' || action === 'copy' || action == 'delete_tag') {
await handleRefresh();
await handleRefresh(false);
}
} else {
showError(message);
Expand All @@ -188,11 +188,13 @@ export default function ChannelList() {
};

// 处理刷新
const handleRefresh = async () => {
setOrderBy('id');
setOrder('desc');
setToolBarValue(originalKeyword);
setSearchKeyword(originalKeyword);
const handleRefresh = async (reset) => {
if (reset) {
setOrderBy('id');
setOrder('desc');
setToolBarValue(originalKeyword);
setSearchKeyword(originalKeyword);
}
setRefreshFlag(!refreshFlag);
};

Expand Down Expand Up @@ -258,7 +260,7 @@ export default function ChannelList() {
const handleOkModal = (status) => {
if (status === true) {
handleCloseModal();
handleRefresh();
handleRefresh(false);
}
};

Expand Down Expand Up @@ -348,7 +350,7 @@ export default function ChannelList() {
<Container>
{matchUpMd ? (
<ButtonGroup variant="outlined" aria-label="outlined small primary button group">
<Button onClick={handleRefresh} startIcon={<IconRefresh width={'18px'} />}>
<Button onClick={() => handleRefresh(true)} startIcon={<IconRefresh width={'18px'} />}>
{t('channel_index.refreshClearSearchConditions')}
</Button>
<Button onClick={searchChannels} startIcon={<IconSearch width={'18px'} />}>
Expand All @@ -372,7 +374,7 @@ export default function ChannelList() {
justifyContent="space-around"
alignItems="center"
>
<IconButton onClick={handleRefresh} size="large">
<IconButton onClick={() => handleRefresh(true)} size="large">
<IconRefresh />
</IconButton>
<IconButton onClick={searchChannels} size="large">
Expand Down

0 comments on commit 1bd449e

Please sign in to comment.