mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Improve pubTime display
This commit is contained in:
parent
6af4d26140
commit
12138416a3
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -45,7 +45,7 @@
|
|||||||
"custom-navbar.min.css": "5C7BC1ECCF80E87509DC27D13DC3AFAAACC4B655ED7ADE915874724147FDDC07",
|
"custom-navbar.min.css": "5C7BC1ECCF80E87509DC27D13DC3AFAAACC4B655ED7ADE915874724147FDDC07",
|
||||||
"custom-navbar.min.html": "DB04478D34A6ABE6792201E22FC11163366C4EBBDBB4726F624FC368077016F8",
|
"custom-navbar.min.html": "DB04478D34A6ABE6792201E22FC11163366C4EBBDBB4726F624FC368077016F8",
|
||||||
"custom-navbar.min.js": "AC2723AC55D602099D5B7659B9B17DE2662CD28A6419C74200C46EB358CFC84B",
|
"custom-navbar.min.js": "AC2723AC55D602099D5B7659B9B17DE2662CD28A6419C74200C46EB358CFC84B",
|
||||||
"custom-navbar-activities.min.js": "BFB1D66A2AFB87D1B5A6552A3045A45B1C7816AAABC828B3F40A706A1DF9005D",
|
"custom-navbar-activities.min.js": "02850C5F91246238A48CDB4B8CD5F63CC2BB7DC8E73ECD754209AF2A96681366",
|
||||||
"custom-navbar-blank.min.js": "E8F08DA7CD2C67F9D064B959A64CFC6658103DBCBE2B9B58D978A1742E02D829",
|
"custom-navbar-blank.min.js": "E8F08DA7CD2C67F9D064B959A64CFC6658103DBCBE2B9B58D978A1742E02D829",
|
||||||
"custom-navbar-category.min.js": "B973D1BAC5B634214C5688CC4A1B1EA5AAC6A5F19B007EDB1A0A43D66EEB3438",
|
"custom-navbar-category.min.js": "B973D1BAC5B634214C5688CC4A1B1EA5AAC6A5F19B007EDB1A0A43D66EEB3438",
|
||||||
"custom-navbar-component.min.js": "369BB1D0E5714B6940C607B909DD3709BB35B4831CA9DC7DD774619596E6CD87",
|
"custom-navbar-component.min.js": "369BB1D0E5714B6940C607B909DD3709BB35B4831CA9DC7DD774619596E6CD87",
|
||||||
|
|||||||
BIN
min/bundle.zip
BIN
min/bundle.zip
Binary file not shown.
2
min/custom-navbar-activities.min.js
vendored
2
min/custom-navbar-activities.min.js
vendored
File diff suppressed because one or more lines are too long
@ -263,15 +263,31 @@ export class Activities extends NavbarComponent {
|
|||||||
const now = Number(new Date())
|
const now = Number(new Date())
|
||||||
const oneDayBefore = now - 1000 * 3600 * 24
|
const oneDayBefore = now - 1000 * 3600 * 24
|
||||||
const formatPubTime = (pubTime: number) => {
|
const formatPubTime = (pubTime: number) => {
|
||||||
|
const pubDate = new Date(pubTime)
|
||||||
|
const time = [pubDate.getHours(), pubDate.getMinutes(), pubDate.getSeconds()]
|
||||||
|
.map(it => it.toString().padStart(2, '0'))
|
||||||
|
.join(':')
|
||||||
|
let date: number[]
|
||||||
|
if (new Date(now).getFullYear() !== pubDate.getFullYear()) {
|
||||||
|
date = [pubDate.getFullYear(), pubDate.getMonth() + 1, pubDate.getDate()]
|
||||||
|
} else {
|
||||||
|
date = [pubDate.getMonth() + 1, pubDate.getDate()]
|
||||||
|
}
|
||||||
|
return `${date.map(it => it.toString().padStart(2, '0')).join('-')} ${time}`
|
||||||
|
}
|
||||||
|
const formatPubTimeText = (pubTime: number) => {
|
||||||
if (oneDayBefore < pubTime) {
|
if (oneDayBefore < pubTime) {
|
||||||
const diffHours = Math.round((now - pubTime) / 1000 / 3600)
|
const diffHours = Math.round((now - pubTime) / 1000 / 3600)
|
||||||
return `${diffHours}小时前`
|
return `${diffHours}小时前`
|
||||||
}
|
}
|
||||||
const pubDate = new Date(pubTime)
|
const pubDate = new Date(pubTime)
|
||||||
|
let date: number[]
|
||||||
if (new Date(now).getFullYear() !== pubDate.getFullYear()) {
|
if (new Date(now).getFullYear() !== pubDate.getFullYear()) {
|
||||||
return `${pubDate.getFullYear()}-${pubDate.getMonth() + 1}-${pubDate.getDate()}`
|
date = [pubDate.getFullYear(), pubDate.getMonth() + 1, pubDate.getDate()]
|
||||||
|
} else {
|
||||||
|
date = [pubDate.getMonth() + 1, pubDate.getDate()]
|
||||||
}
|
}
|
||||||
return `${pubDate.getMonth() + 1}-${pubDate.getDate()}`
|
return `${date.map(it => it.toString().padStart(2, '0')).join('-')}`
|
||||||
}
|
}
|
||||||
const jsonCards = _.get(json, 'data.cards', []).map((card: any) => {
|
const jsonCards = _.get(json, 'data.cards', []).map((card: any) => {
|
||||||
const cardJson = JSON.parse(card.card)
|
const cardJson = JSON.parse(card.card)
|
||||||
@ -288,8 +304,8 @@ export class Activities extends NavbarComponent {
|
|||||||
upName: card.desc.user_profile.info.uname,
|
upName: card.desc.user_profile.info.uname,
|
||||||
upUrl: `https://space.bilibili.com/${card.desc.user_profile.info.uid}`,
|
upUrl: `https://space.bilibili.com/${card.desc.user_profile.info.uid}`,
|
||||||
id: card.desc.dynamic_id_str,
|
id: card.desc.dynamic_id_str,
|
||||||
pubTime: new Date(cardJson.pubdate * 1000).toLocaleString(),
|
pubTime: formatPubTime(cardJson.pubdate * 1000),
|
||||||
pubTimeText: formatPubTime(cardJson.pubdate * 1000),
|
pubTimeText: formatPubTimeText(cardJson.pubdate * 1000),
|
||||||
watchlater: true,
|
watchlater: true,
|
||||||
get new() { return Activities.isNewID(this.id) },
|
get new() { return Activities.isNewID(this.id) },
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user