Skip to content

Commit

Permalink
时间展示
Browse files Browse the repository at this point in the history
  • Loading branch information
niltor committed Apr 2, 2024
1 parent 32af235 commit aa1dbe8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

### Fork并配置GitHub Page

1. 点击`Fork`按钮,并创建自己的仓库。
2. 进入自己的仓库,点击`Actions`,启用workflows。
1. 点击`Fork`按钮,并创建自己的仓库。 并取消选择 Copy the main branch only。
2. 进入自己的GitHub仓库,点击`Actions`,启用workflows。
3. 点击`Settings`,找到Pages配置,在Build and deployment 选项中选择`GitHub Actions`.

### 配置
Expand Down
9 changes: 6 additions & 3 deletions WebApp/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,18 @@ function timeAgo(date) {
if (unit === '年') {
// show year and month
const month = Math.floor((seconds - counter * intervals[unit]) / intervals['月']);
return `${counter}${unit}${month}月前`;
month = month > 0 ? month + '月' : '';
return `${counter}${unit}${month}前`;
}
if (unit === '月') {
const day = Math.floor((seconds - counter * intervals[unit]) / intervals['天']);
return `${counter}${unit}${day}天前`;
day = day > 0 ? day + '天' : '';
return `${counter}${unit}${day}前`;
}
if (unit === '天') {
const hour = Math.floor((seconds - counter * intervals[unit]) / intervals['小时']);
return `${counter}${unit}${hour}小时前`;
hour = hour > 0 ? hour + '小时' : '';
return `${counter}${unit}${hour}前`;
}
return `${counter}${unit}前`;
}
Expand Down

0 comments on commit aa1dbe8

Please sign in to comment.