Skip to content

Commit

Permalink
refactor and fix ui performance
Browse files Browse the repository at this point in the history
  • Loading branch information
mythsman committed Mar 31, 2023
1 parent f2f0dcc commit 25b47ef
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 234 deletions.
104 changes: 52 additions & 52 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,36 @@ module.exports.fetchBook = async function (id, action, referer, timeout) {

for (let i in bookResult.comment) {
let comment = bookResult.comment[i]
let pubs = []
let metas = []
if (comment.item.author) {
pubs.push(comment.item.author)
metas.push(comment.item.author)
}
if (comment.item.translator) {
pubs.push(comment.item.translator)
metas.push(comment.item.translator)
}
if (comment.item.press) {
pubs.push(comment.item.press)
metas.push(comment.item.press)
}
if (comment.item.producer) {
pubs.push(comment.item.producer)
metas.push(comment.item.producer)
}

let meta = []
let rating = []
if (comment.mark_date) {
meta.push(comment.mark_date)
rating.push(comment.mark_date)
}
if (comment.label) {
meta.push(comment.label)
rating.push(comment.label)
}
if (comment.rate) {
meta.push(renderStar(comment.rate + ''))
rating.push(renderStar(comment.rate + ''))
}
book.push({
title: comment.item.title,
alt: "https://book.douban.com/subject/" + comment.item.douban_id + "/",
image: comment.item.thumbnail,
pub: pubs.join(" / "),
meta: meta.join(" / "),
meta: metas.join(" / "),
rating: rating.join(" / "),
comment: comment.comment
})
}
Expand All @@ -76,35 +76,35 @@ module.exports.fetchGame = async function (id, action, referer, timeout) {
let gameResult = response.result
for (let i in gameResult.comment) {
let comment = gameResult.comment[i]
let pubs = []
let metas = []
if (comment.item.platform) {
pubs.push(comment.item.platform)
metas.push(comment.item.platform)
}
if (comment.item.genre) {
pubs.push(comment.item.genre)
metas.push(comment.item.genre)
}
if (comment.item.developer) {
pubs.push(comment.item.developer)
metas.push(comment.item.developer)
}
if (comment.item.publisher) {
pubs.push(comment.item.publisher)
if (comment.item.metalisher) {
metas.push(comment.item.metalisher)
}
let meta = []
let rating = []
if (comment.mark_date) {
meta.push(comment.mark_date)
rating.push(comment.mark_date)
}
if (comment.label) {
meta.push(comment.label)
rating.push(comment.label)
}
if (comment.rate) {
meta.push(renderStar(comment.rate + ''))
rating.push(renderStar(comment.rate + ''))
}
game.push({
title: comment.item.title,
alt: "https://www.douban.com/game/" + comment.item.douban_id + "/",
image: comment.item.thumbnail,
pub: pubs.join(" / "),
meta: meta.join(" / "),
meta: metas.join(" / "),
rating: rating.join(" / "),
comment: comment.comment
})
}
Expand All @@ -123,44 +123,44 @@ module.exports.fetchSong = async function (id, action, referer, timeout) {
let songResult = response.result
for (let i in songResult.comment) {
let comment = songResult.comment[i]
let pubs = []
let metas = []
if (comment.item.alias) {
pubs.push(comment.item.alias)
metas.push(comment.item.alias)
}
if (comment.item.musician) {
pubs.push(comment.item.musician)
metas.push(comment.item.musician)
}
if (comment.item.album_type) {
pubs.push(comment.item.album_type)
metas.push(comment.item.album_type)
}
if (comment.item.genre) {
pubs.push(comment.item.genre)
metas.push(comment.item.genre)
}
if (comment.item.media) {
pubs.push(comment.item.media)
metas.push(comment.item.media)
}
if (comment.item.publisher) {
pubs.push(comment.item.publisher)
if (comment.item.metalisher) {
metas.push(comment.item.metalisher)
}
if (comment.item.publish_date) {
pubs.push(comment.item.publish_date)
if (comment.item.metalish_date) {
metas.push(comment.item.metalish_date)
}
let meta = []
let rating = []
if (comment.mark_date) {
meta.push(comment.mark_date)
rating.push(comment.mark_date)
}
if (comment.label) {
meta.push(comment.label)
rating.push(comment.label)
}
if (comment.rate) {
meta.push(renderStar(comment.rate + ''))
rating.push(renderStar(comment.rate + ''))
}
song.push({
title: comment.item.title,
alt: "https://music.douban.com/subject/" + comment.item.douban_id + "/",
image: comment.item.thumbnail,
pub: pubs.join(" / "),
meta: meta.join(" / "),
meta: metas.join(" / "),
rating: rating.join(" / "),
comment: comment.comment
})
}
Expand All @@ -179,38 +179,38 @@ module.exports.fetchMovie = async function (id, action, referer, timeout) {
let movieResult = response.result
for (let i in movieResult.comment) {
let comment = movieResult.comment[i]
let pubs = []
let metas = []
if (comment.item.style) {
pubs.push(comment.item.style)
metas.push(comment.item.style)
}
if (comment.item.director) {
pubs.push(comment.item.director)
metas.push(comment.item.director)
}
if (comment.item.writer) {
pubs.push(comment.item.writer)
metas.push(comment.item.writer)
}
if (comment.item.actor) {
pubs.push(comment.item.actor)
metas.push(comment.item.actor)
}
if (comment.item.publish_date) {
pubs.push(comment.item.publish_date)
if (comment.item.metalish_date) {
metas.push(comment.item.metalish_date)
}
let meta = []
let rating = []
if (comment.mark_date) {
meta.push(comment.mark_date)
rating.push(comment.mark_date)
}
if (comment.label) {
meta.push(comment.label)
rating.push(comment.label)
}
if (comment.rate) {
meta.push(renderStar(comment.rate + ''))
rating.push(renderStar(comment.rate + ''))
}
movie.push({
title: comment.item.title,
alt: "https://movie.douban.com/subject/" + comment.item.douban_id + "/",
image: comment.item.thumbnail,
pub: pubs.join(" / "),
meta: meta.join(" / "),
meta: metas.join(" / "),
rating: rating.join(" / "),
comment: comment.comment
})
}
Expand Down
23 changes: 12 additions & 11 deletions lib/templates/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
text-decoration: none !important;
}

.hexo-douban-active {
.hexo-douban-tab-active {
background: #657b83;
color: #fff !important;
}
Expand Down Expand Up @@ -43,9 +43,19 @@
overflow: hidden;
display: -webkit-box;
font-size: 12px;
line-height: 16px;
padding-right: 10px;
margin-top: 5px;
-webkit-box-orient: vertical;
-webkit-line-clamp: 4;
-webkit-line-clamp: 4
}

.hexo-douban-rating {
overflow: hidden;
display: -webkit-box;
font-size: 12px;
padding-right: 10px;
margin-top: 8px;
}

.hexo-douban-comments {
Expand All @@ -68,12 +78,3 @@
color: #fff !important;
opacity: 1;
}

.hexo-douban-hide {
display: none;
}

.hexo-douban-show {
display: block;
}

Loading

0 comments on commit 25b47ef

Please sign in to comment.