Skip to content

Commit

Permalink
首屏缓存优化
Browse files Browse the repository at this point in the history
  • Loading branch information
jimbeamman7 committed May 20, 2022
1 parent 0f40d61 commit f22596f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const debug = true
// 程序信息,置空则不显示
const info = {
about: 'help/about', // "关于我们"的文档标识
version: 'v1.4.0',
version: 'v1.5.1',
copyright: 'BookStack.CN',
license: 'Apache 2.0',
author: 'TruthHun',
Expand Down
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name" : "BookChat",
"appid" : "__UNI__8FAB29C",
"description" : "",
"versionName" : "1.5.0",
"versionCode" : 150,
"versionName" : "1.5.1",
"versionCode" : 151,
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
Expand All @@ -13,7 +13,7 @@
"usingComponents" : true,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : false,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
Expand Down
17 changes: 10 additions & 7 deletions pages/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
let that = this
let cids = []
let categories = []
let bookLists = []
api.getCategories().then(function(res) {
if (res.length > 0) {
categories = res.filter(function(category) {
Expand All @@ -127,7 +128,6 @@
}).finally(function() {
let banners = []
let recommendBooks = []
let bookLists = []
Promise.all([util.request(config.api.banners), util.request(config.api.bookLists, {
page: 1,
size: 12,
Expand Down Expand Up @@ -155,6 +155,7 @@
}
if (resRecommendBooks.data && resRecommendBooks.data.books) recommendBooks = resRecommendBooks.data.books
if (resBookLists.data && resBookLists.data.books) {
bookLists = resBookLists.data.books
categories = categories.map(function(category) {
let book = resBookLists.data.books[category.id]
if (book != undefined && book.length > 0) {
Expand All @@ -169,12 +170,8 @@
console.log(e)
util.toastError(e.data.message || e.ErrMsg)
}).finally(function() {
that.banners = banners
that.categoryBooks = categories
that.recommendBooks = recommendBooks
that.showSearch = true
uni.hideLoading()
if (that.times > 0 && (!categories || categories.length == 0)) {
if (that.times > 0 && bookLists.length == 0) {
if (config.debug) console.log("reload")
let iload = setTimeout(function() {
clearTimeout(iload)
Expand All @@ -184,7 +181,13 @@
} else {
that.times = 0
}
util.setPageCache("index", {'banners': banners, 'categoryBooks': categories, 'recommendBooks':recommendBooks})
if(bookLists.length>0){
that.banners = banners
that.categoryBooks = categories
that.recommendBooks = recommendBooks
that.showSearch = true
util.setPageCache("index", {'banners': banners, 'categoryBooks': categories, 'recommendBooks':recommendBooks})
}
})
})
},
Expand Down

0 comments on commit f22596f

Please sign in to comment.