fix
This commit is contained in:
@@ -86,8 +86,7 @@ export function usePagination(
|
|||||||
const res = await requestFn(params)
|
const res = await requestFn(params)
|
||||||
|
|
||||||
const rawData = res[dataKey]
|
const rawData = res[dataKey]
|
||||||
const total = res[totalKey] || 99999999
|
|
||||||
console.log(total, rawData)
|
|
||||||
const data = typeof transformFn === 'function' ? transformFn(rawData) : rawData
|
const data = typeof transformFn === 'function' ? transformFn(rawData) : rawData
|
||||||
|
|
||||||
if (type === 'refresh') {
|
if (type === 'refresh') {
|
||||||
@@ -96,9 +95,9 @@ export function usePagination(
|
|||||||
list.value.push(...data)
|
list.value.push(...data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const total = res[totalKey] || list.value?.length
|
||||||
pageState.total = total
|
pageState.total = total
|
||||||
pageState.maxPage = Math.ceil(total / pageState.pageSize)
|
pageState.maxPage = Math.ceil(total / pageState.pageSize)
|
||||||
|
|
||||||
finished.value = list.value.length >= total
|
finished.value = list.value.length >= total
|
||||||
empty.value = list.value.length === 0
|
empty.value = list.value.length === 0
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ const state = reactive({
|
|||||||
// 响应式搜索条件(可以被修改)
|
// 响应式搜索条件(可以被修改)
|
||||||
const searchParams = ref({});
|
const searchParams = ref({});
|
||||||
const pageSize = ref(10);
|
const pageSize = ref(10);
|
||||||
const { list, loading, refresh, loadMore } = usePagination(
|
const { list, loading, refresh, loadMore,finished } = usePagination(
|
||||||
(params) => $api.createRequest('/app/job/littleVideo', params),
|
(params) => $api.createRequest('/app/job/littleVideo', params),
|
||||||
dataToImg, // 转换函数
|
dataToImg, // 转换函数
|
||||||
{
|
{
|
||||||
@@ -107,7 +107,10 @@ const { list, loading, refresh, loadMore } = usePagination(
|
|||||||
);
|
);
|
||||||
|
|
||||||
function imageloaded() {
|
function imageloaded() {
|
||||||
loadmoreRef.value?.change('more');
|
if(finished.value) loadmoreRef.value?.change('noMore');
|
||||||
|
else loadmoreRef.value?.change('more');
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { columnCount, columnSpace } = useColumnCount(() => {
|
const { columnCount, columnSpace } = useColumnCount(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user