ChineseWithLastDateHeader.js
1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
*
* Created by Stone
* https://github.com/bolan9999
* Email: shanshang130@gmail.com
* Date: 2019/1/25
*
*/
import { WithLastDateHeader } from "./WithLastDateHeader";
export class ChineseWithLastDateHeader extends WithLastDateHeader {
getText() {
return "最后更新: ";
}
getTimeDescription() {
if (!this.lastTime) {
return "从未更新";
}
const now = new Date();
let timeInterval = Math.floor(
(now.getTime() - this.lastTime.getTime()) / 1000
);
if (timeInterval < 60) {
return `${timeInterval}秒前`;
} else if (timeInterval < 3600) {
return `${Math.floor(timeInterval / 60)}分钟前`;
} else if (
now.getFullYear() === this.lastTime.getFullYear() &&
now.getMonth() === this.lastTime.getMonth() &&
now.getDate() === this.lastTime.getDate()
) {
return `${this.lastTime.getHours()}:${this.lastTime.getMinutes()}`;
} else if (now.getFullYear() === this.lastTime.getFullYear()) {
return `${this.lastTime.getMonth() + 1}-${this.lastTime.getDate()}`;
} else {
return `${this.lastTime.getFullYear()}-${this.lastTime.getMonth() +
1}-${this.lastTime.getDate()}`;
}
}
getTitle() {
const s = this.state.status;
if (s === "pulling" || s === "waiting") {
return "下拉可以刷新";
} else if (s === "pullingEnough") {
return "松开立即刷新";
} else if (s === "refreshing") {
return "正在刷新数据中...";
} else if (s === "pullingCancel") {
return "放弃刷新";
} else if (s === "rebound") {
return "刷新完成";
}
}
}