Skip to content

Commit f7b3cc9

Browse files
feat: Custom sorting function style
1 parent d8d15c8 commit f7b3cc9

File tree

14 files changed

+183
-158
lines changed

14 files changed

+183
-158
lines changed
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
11
import { t } from '@/locales'
22

3-
43
export const SORT_TYPES = {
54
CREATE_TIME_ASC: 'createTime-asc',
65
CREATE_TIME_DESC: 'createTime-desc',
76
NAME_ASC: 'name-asc',
87
NAME_DESC: 'name-desc',
9-
CUSTOM: 'custom'
8+
CUSTOM: 'custom',
109
} as const
1110

12-
export type SortType = typeof SORT_TYPES[keyof typeof SORT_TYPES]
11+
export type SortType = (typeof SORT_TYPES)[keyof typeof SORT_TYPES]
1312

1413
export const SORT_MENU_CONFIG = [
1514
{
16-
title: 'time',
15+
title: 'time',
1716
items: [
18-
{ label: t('components.folder.ascTime', '按创建时间升序'), value: SORT_TYPES.CREATE_TIME_ASC},
19-
{ label: t('components.folder.descTime', '按创建时间降序'), value: SORT_TYPES.CREATE_TIME_DESC },
20-
]
17+
{ label: t('components.folder.ascTime'), value: SORT_TYPES.CREATE_TIME_ASC },
18+
{ label: t('components.folder.descTime'), value: SORT_TYPES.CREATE_TIME_DESC },
19+
],
2120
},
2221
{
2322
title: 'name',
2423
items: [
25-
{ label: t('components.folder.ascName', '按名称升序'), value: SORT_TYPES.NAME_ASC },
26-
{ label: t('components.folder.descName', '按名称降序'), value: SORT_TYPES.NAME_DESC },
27-
]
24+
{ label: t('components.folder.ascName'), value: SORT_TYPES.NAME_ASC },
25+
{ label: t('components.folder.descName'), value: SORT_TYPES.NAME_DESC },
26+
],
2827
},
2928
{
30-
items: [
31-
{ label: t('components.folder.custom', '按用户拖拽排序'), value: SORT_TYPES.CUSTOM },
32-
]
33-
}
34-
]
29+
items: [{ label: t('components.folder.sortDrop'), value: SORT_TYPES.CUSTOM }],
30+
},
31+
]

ui/src/components/folder-tree/index.vue

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
<template>
22
<div class="folder-tree">
3-
<div class="flex ml-4 p-8 pb-0 items-start">
3+
<div class="flex ml-4 p-8 pb-0">
44
<el-input
55
v-model="filterText"
66
:placeholder="$t('common.search')"
77
prefix-icon="Search"
88
clearable
9-
class="flex-[5]"
109
/>
1110
<el-dropdown trigger="click" :teleported="false" @command="switchSortMethod">
12-
<el-button class="flex-1 ml-4">
11+
<el-button class="ml-4">
1312
<el-icon><Operation /></el-icon>
1413
</el-button>
1514
<template #dropdown>
16-
<el-dropdown-menu>
15+
<el-dropdown-menu class="w-180">
1716
<template v-for="(group, index) in SORT_MENU_CONFIG" :key="index">
1817
<el-dropdown-item
1918
v-for="obj in group.items"
2019
:key="obj.value"
2120
:command="obj.value"
22-
class="mr-2"
21+
:class="`${currentSort === obj.value ? 'active' : ''} flex-between`"
2322
>
24-
{{ obj.label }}
23+
<span>
24+
{{ obj.label }}
25+
</span>
26+
2527
<el-icon v-if="currentSort === obj.value" class="ml-4">
2628
<Check />
2729
</el-icon>
@@ -272,7 +274,7 @@ function addOrderToTree(nodes: any, parentId: string): Node[] {
272274
return nodes
273275
}
274276
275-
let positions = getPositions(parentId)
277+
const positions = getPositions(parentId)
276278
let needSave = false
277279
278280
nodes.forEach((node: any) => {

ui/src/components/infinite-scroll/index.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ const noMore = computed(
6161
props.size > 0 && props.size === props.total && props.total > props.page_size && !props.loading,
6262
)
6363
const disabledScroll = computed(() => props.size > 0 && (props.loading || noMore.value))
64-
console.log(props.size)
65-
console.log(props.total)
66-
console.log(props.page_size)
6764
function loadData() {
6865
if (props.total > props.page_size) {
6966
current.value += 1

ui/src/layout/layout-header/avatar/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
</div>
110110

111111
<template #dropdown>
112-
<el-dropdown-menu style="width: 180px">
112+
<el-dropdown-menu class="w-180">
113113
<el-dropdown-item
114114
v-for="(lang, index) in langList"
115115
:key="index"

ui/src/layout/login-layout/LoginLayout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<el-col :xs="24" :sm="24" :md="14" :lg="14" :xl="14" class="right-container flex-center">
99
<el-dropdown trigger="click" type="primary" class="lang" v-if="lang">
1010
<template #dropdown>
11-
<el-dropdown-menu style="width: 180px">
11+
<el-dropdown-menu class="w-180">
1212
<el-dropdown-item
1313
v-for="(lang, index) in langList"
1414
:key="index"

ui/src/locales/lang/en-US/components.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,10 @@ export default {
1717
folderNamePlaceholder: 'Please enter a name',
1818
requiredMessage: 'Please select a folder',
1919
deleteConfirmMessage: 'Folders with resources will be deleted, please be cautious.',
20+
ascTime: 'Sort by creation time ascending',
21+
descTime: 'Sort by creation time descending',
22+
ascName: 'Sort by name ascending',
23+
descName: 'Sort by name descending',
24+
custom: 'Sort by user drag-and-drop',
2025
},
2126
}

ui/src/locales/lang/zh-CN/components.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,10 @@ export default {
1717
folderNamePlaceholder: '请输入名称',
1818
requiredMessage: '请选择文件夹',
1919
deleteConfirmMessage: '文件夹下的资源会被删除,请谨慎操作。',
20+
ascTime: '按创建时间升序',
21+
descTime: '按创建时间降序',
22+
ascName: '按名称升序',
23+
descName: '按名称降序',
24+
sortDrop: '按用户拖拽排序',
2025
},
2126
}

ui/src/locales/lang/zh-Hant/components.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,10 @@ export default {
1717
folderNamePlaceholder: '請輸入名稱',
1818
requiredMessage: '請選擇文件夾',
1919
deleteConfirmMessage: '文件夹下的資源會被刪除,請謹慎操作。',
20+
ascTime: '按創建時間升序',
21+
descTime: '按創建時間降序',
22+
ascName: '按名稱升序',
23+
descName: '按名稱降序',
24+
sortDrop: '按用戶拖拽排序',
2025
},
2126
}

ui/src/styles/app.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ h5 {
125125
.w-120 {
126126
width: 120px;
127127
}
128+
.w-180 {
129+
width: 180px;
130+
}
128131
.w-240 {
129132
width: 240px;
130133
}

ui/src/views/application-overview/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@
150150
<div class="mb-16">
151151
<el-select
152152
v-model="history_day"
153-
class="mr-12"
153+
class="mr-12 w-180"
154154
@change="changeDayHandle"
155-
style="width: 180px"
155+
156156
>
157157
<el-option
158158
v-for="item in dayOptions"

0 commit comments

Comments
 (0)