Add server and mini-program pagination for shared lists

This commit is contained in:
2026-10-11 10:10:49 +08:00
parent c0a3db5c8e
commit 7854d94e7b
37 changed files with 395 additions and 175 deletions
+2 -2
View File
@@ -38,7 +38,7 @@ test('failed homepage load ends the recent-record spinner',async()=>{
let definition;
const api={coupleInfo:async()=>{throw { _statusCode:404 };}};
vm.runInNewContext(fs.readFileSync(path.join(__dirname,'../pages/index/index.js'),'utf8'),{
Page(p){definition=p;},require(name){return name.endsWith('/page-cache')?{withDataCache:p=>p}:name.endsWith('/request')?{api,getImageUrl:v=>v}:name.endsWith('/layout')?{getLayout:()=>({})}:{saveScrollPosition(){},getScrollPosition(){return 0;}};},
Page(p){definition=p;},require(name){return name.endsWith('/list-pagination')?require('../utils/list-pagination'):name.endsWith('/page-cache')?{withDataCache:p=>p}:name.endsWith('/request')?{api,getImageUrl:v=>v}:name.endsWith('/layout')?{getLayout:()=>({})}:{saveScrollPosition(){},getScrollPosition(){return 0;}};},
wx:{getStorageSync:()=> 'test-token'}, console:{error(){}}, Date, setTimeout
});
const page={...definition,data:{...definition.data},setData(data){Object.assign(this.data,data);}};
@@ -50,7 +50,7 @@ test('unbound newcomer loads homepage records without requesting couple-only pet
let definition;let petCalls=0;
const api={coupleInfo:async()=>({not_bound:true,partner1:{nickname:'新用户'}}),timelineList:async()=>[],albumList:async()=>[],diaryList:async()=>({items:[],total:0}),songsList:async()=>[],checkinList:async()=>({items:[]}),petInfo:async()=>{petCalls++;throw Error('请先绑定情侣');}};
vm.runInNewContext(fs.readFileSync(path.join(__dirname,'../pages/index/index.js'),'utf8'),{
Page(p){definition=p;},require(name){return name.endsWith('/page-cache')?{withDataCache:p=>p}:name.endsWith('/request')?{api,getImageUrl:v=>v}:name.endsWith('/layout')?{getLayout:()=>({})}:name.endsWith('/journal')?{diaryEntry:v=>v}:{};},
Page(p){definition=p;},require(name){return name.endsWith('/list-pagination')?require('../utils/list-pagination'):name.endsWith('/page-cache')?{withDataCache:p=>p}:name.endsWith('/request')?{api,getImageUrl:v=>v}:name.endsWith('/layout')?{getLayout:()=>({})}:name.endsWith('/journal')?{diaryEntry:v=>v}:{};},
wx:{getStorageSync:()=>1,removeStorageSync(){}},console,Date,setTimeout
});
const page={...definition,data:{...definition.data,coupleId:99},setData(data){Object.assign(this.data,data);}};