Skip to content

Commit ee932e0

Browse files
feat: Workspace list adds scrolling load (#6226)
Co-authored-by: wangdan-fit2cloud <dan.wang@fit2cloud.com>
1 parent 38929f7 commit ee932e0

2 files changed

Lines changed: 38 additions & 13 deletions

File tree

ui/src/components/common-list/index.vue

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
<template>
22
<div class="common-list">
33
<ul v-if="data.length > 0">
4-
<template v-for="(item, index) in data" :key="index">
5-
<li
6-
@click.stop="clickHandle(item, index)"
7-
:class="current === item[props.valueKey] ? 'active color-primary-1' : ''"
8-
class="cursor"
9-
@mouseenter.stop="mouseenter(item)"
10-
@mouseleave.stop="mouseleave()"
11-
>
12-
<slot :row="item" :index="index"> </slot>
13-
</li>
14-
</template>
4+
<InfiniteScroll
5+
:size="renderList.length"
6+
:total="data.length"
7+
:page_size="paginationConfig.page_size"
8+
v-model:current_page="paginationConfig.current_page"
9+
>
10+
<template v-for="(item, index) in renderList" :key="item[props.valueKey] ?? index">
11+
<li
12+
@click.stop="clickHandle(item, index)"
13+
:class="current === item[props.valueKey] ? 'active color-primary-1' : ''"
14+
class="cursor"
15+
@mouseenter.stop="mouseenter(item)"
16+
@mouseleave.stop="mouseleave()"
17+
>
18+
<slot :row="item" :index="index"> </slot>
19+
</li>
20+
</template>
21+
</InfiniteScroll>
1522
</ul>
1623
<slot name="empty" v-else>
1724
<el-empty :description="$t('common.noData')" />
1825
</slot>
1926
</div>
2027
</template>
2128
<script setup lang="ts">
22-
import { ref, watch } from 'vue'
29+
import { ref, watch, reactive, computed } from 'vue'
2330
2431
defineOptions({ name: 'CommonList' })
2532
@@ -48,6 +55,25 @@ watch(
4855
4956
const emit = defineEmits(['click', 'mouseenter', 'mouseleave'])
5057
58+
const paginationConfig = reactive({
59+
current_page: 1,
60+
page_size: 50,
61+
total: 0,
62+
})
63+
64+
// 前端分页滚动加载:data 为全量数据,仅渲染前 current_page * page_size 条,滚动到底再追加
65+
const renderList = computed(() =>
66+
props.data.slice(0, paginationConfig.current_page * paginationConfig.page_size),
67+
)
68+
69+
// 数据源变化时重置到第一页,避免切换数据后仍停留在很大的页码
70+
watch(
71+
() => props.data,
72+
() => {
73+
paginationConfig.current_page = 1
74+
},
75+
)
76+
5177
function mouseenter(row: any) {
5278
emit('mouseenter', row)
5379
}

ui/src/views/system-chat-user/group/index.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@
267267

268268
<script lang="ts" setup>
269269
import { onMounted, ref, watch, reactive } from 'vue'
270-
import SystemGroupApi from '@/api/system/user-group'
271270
import { t } from '@/locales'
272271
import { i18n_name } from '@/utils/common'
273272
import type { ChatUserGroupUserItem } from '@/api/type/systemChatUser'

0 commit comments

Comments
 (0)