Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
R
rrpgLink_FrontEnd
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kesaubeeire
rrpgLink_FrontEnd
Commits
93961d3d
Commit
93961d3d
authored
Oct 22, 2023
by
JoyJ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 瀑布流
parent
7d6208e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
20 deletions
+29
-20
src/Content.svelte
src/Content.svelte
+29
-20
No files found.
src/Content.svelte
View file @
93961d3d
...
...
@@ -83,10 +83,12 @@
if (params.method == 'POST') msg.body = payload;
if (params.headers) msg.headers = params.headers;
/*
if (lastSearchURL == url) {
toast.push('搜索参数重复捏~');
return;
}
*/
lastSearchURL = url;
fetch(url, msg)
...
...
@@ -132,13 +134,7 @@
* @param data JSON数据
*/
function appendList(data) {
// List = [...List, ...data];
List = [];
// <!-- FIXME: 暂时以这种略微丑陋的方式做切换动画, 可能这就是唯一方案了 -->
setTimeout(() => {
List = [...List, ...data];
isSearching = false;
}, 400);
showList([...List, ...data]);
}
let lastSearchFunc = null;
...
...
@@ -146,8 +142,10 @@
let isSearching = false;
function continueLastSearch() {
console.log("continueLastSearch");
console.log("lastSearchFunc=" + lastSearchFunc.toString());
if (lastSearchFunc) {
lastSearchFunc(lastSearchParam);
lastSearchFunc(lastSearchParam
, limit, nextPage
);
}
}
...
...
@@ -170,10 +168,7 @@
if (process.env.APP_ENV === 'dev') console.log(tag, encodeURIComponent(tag));
createFetch(searchTagRequest(tag), data => {
if (process.env.APP_ENV === 'dev') console.log(data);
if (page == 1) {
showList(data);
}
isSearching = false;
page == 1 ? showList(data) : appendList(data);
});
nextPage++;
}
...
...
@@ -194,7 +189,11 @@
nextPage = page;
}
lastSearchFunc = searchCategory;
if (process.env.APP_ENV === 'dev') console.log(category);
if (process.env.APP_ENV === 'dev') console.log('执行搜索:\t', category);
createFetch(searchCategoryRequest(title), data => {
if (process.env.APP_ENV === 'dev') console.log(data);
page == 1 ? showList(data) : appendList(data);
});
nextPage++;
}
...
...
@@ -219,7 +218,7 @@
if (process.env.APP_ENV === 'dev') console.log('执行搜索:\t', title);
createFetch(searchTextRequest(title), data => {
if (process.env.APP_ENV === 'dev') console.log(data);
page == 1 ? showList(data) : appendList();
page == 1 ? showList(data) : appendList(
data
);
});
nextPage++;
}
...
...
@@ -229,15 +228,19 @@
* 默认搜索 -> 暂时是全部搜索
* TODO: 全局内容 30分钟 一次缓存在 localstorage 里
*/
export function searchDefault(_,pageLimit = 20, page = 1) {
export function searchDefault(_, pageLimit = 20, page = 1) {
if (isSearching) {
return;
}
isSearching = true;
isEnd = false;
limit = pageLimit;
nextPage = page;
lastSearchFunc = searchDefault;
lastSearchParam = "";
createFetch(getContentsRequest, data => {
if (process.env.APP_ENV === 'dev') console.log(data);
page == 1 ? showList(data) : appendList();
page == 1 ? showList(data) : appendList(
data
);
});
nextPage++;
}
...
...
@@ -289,11 +292,17 @@
}
//拉动到页面底部则更新数据
window.scroll(function () {
//滚动到底部时
if (window.scrollTop() + window.height() > document.height() - 1.0 && !isSearching) {
window.addEventListener("scroll",() => {
let scrollTop =document.documentElement.scrollTop ||document.body.scrollTop
let clientHeight =document.documentElement.clientHeight ||document.body.clientHeight
let scrollHeight =document.documentElement.scrollHeight ||document.body.scrollHeight
console.log('scrolled, top=' + scrollTop.toString());
console.log('scrolled, ch=' + clientHeight.toString());
console.log('scrolled, top+ch=' + (scrollTop +clientHeight).toString());
console.log('scrolled, sh=' + scrollHeight.toString());
if ((clientHeight >0 &&scrollTop >0) && (scrollTop +clientHeight > scrollHeight - 10.0)) {
//page+1重复上次搜索
continueLastSearch();
//具体数据操作
}
});
// 初始化请求 -> 拉取全部条目
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment