Skip to content

Commit

Permalink
fix: 修复跨年份时期显示问题
Browse files Browse the repository at this point in the history
  • Loading branch information
dlzmoe committed Jan 2, 2025
1 parent 684193b commit 6899620
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .output/chrome-mv3/content-scripts/content.css

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions .output/chrome-mv3/content-scripts/content.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .output/chrome-mv3/manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"manifest_version":3,"name":"LinuxDo Scripts","description":"为 linux.do 用户提供了一些增强功能。","version":"1.0.8","icons":{"16":"icon/16.png","32":"icon/32.png","48":"icon/48.png","96":"icon/96.png","128":"icon/128.png"},"permissions":["storage"],"background":{"service_worker":"background.js"},"action":{"default_title":"Default Popup Title","default_popup":"popup.html"},"content_scripts":[{"matches":["https://linux.do/*"],"js":["content-scripts/content.js"]}],"web_accessible_resources":[{"resources":["content-scripts/content.css"],"matches":["https://linux.do/*"]}]}
{"manifest_version":3,"name":"LinuxDo Scripts","description":"为 linux.do 用户提供了一些增强功能。","version":"1.0.9","icons":{"16":"icon/16.png","32":"icon/32.png","48":"icon/48.png","96":"icon/96.png","128":"icon/128.png"},"permissions":["storage"],"background":{"service_worker":"background.js"},"action":{"default_title":"Default Popup Title","default_popup":"popup.html"},"content_scripts":[{"matches":["https://linux.do/*"],"js":["content-scripts/content.js"]}],"web_accessible_resources":[{"resources":["content-scripts/content.css"],"matches":["https://linux.do/*"]}]}
2 changes: 1 addition & 1 deletion .output/firefox-mv2/content-scripts/content.css

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions .output/firefox-mv2/content-scripts/content.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .output/firefox-mv2/manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"manifest_version":2,"name":"LinuxDo Scripts","description":"为 linux.do 用户提供了一些增强功能。","version":"1.0.8","icons":{"16":"icon/16.png","32":"icon/32.png","48":"icon/48.png","96":"icon/96.png","128":"icon/128.png"},"permissions":["storage"],"background":{"scripts":["background.js"]},"browser_action":{"default_title":"Default Popup Title","default_popup":"popup.html"},"content_scripts":[{"matches":["https://linux.do/*"],"js":["content-scripts/content.js"]}],"web_accessible_resources":["content-scripts/content.css"]}
{"manifest_version":2,"name":"LinuxDo Scripts","description":"为 linux.do 用户提供了一些增强功能。","version":"1.0.9","icons":{"16":"icon/16.png","32":"icon/32.png","48":"icon/48.png","96":"icon/96.png","128":"icon/128.png"},"permissions":["storage"],"background":{"scripts":["background.js"]},"browser_action":{"default_title":"Default Popup Title","default_popup":"popup.html"},"content_scripts":[{"matches":["https://linux.do/*"],"js":["content-scripts/content.js"]}],"web_accessible_resources":["content-scripts/content.css"]}
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- feat: 新增收藏夹文件夹功能(测试中,注意备份!)
- fix: 修复跨年份时期显示问题
2 changes: 1 addition & 1 deletion entrypoints/App.vue

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions entrypoints/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -920,4 +920,10 @@ body.body-preview #main-outlet-wrapper {
outline: none;
border-radius: 4px;
}
}

.linuxtime {
img {
margin-right: 5px;
}
}
12 changes: 10 additions & 2 deletions entrypoints/components/BasicSettings/MenuShowcreatetime.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,26 @@ export default {
const timestamp = Number(time);
const date = new Date(timestamp);
const now = new Date();
const isToday =
const isToday =
now.getFullYear() === date.getFullYear() &&
now.getMonth() === date.getMonth() &&
now.getDate() === date.getDate();
const isThisYear = now.getFullYear() === date.getFullYear();
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
return isToday ? `${hours}:${minutes}` : `${month}/${day} ${hours}:${minutes}`;
if (isToday) {
return `${hours}:${minutes}`;
} else if (isThisYear) {
return `${month}/${day} ${hours}:${minutes}`;
} else {
return `${year}/${month}/${day} ${hours}:${minutes}`;
}
},
convertToTimestamp(dateStr) {
Expand Down
14 changes: 11 additions & 3 deletions entrypoints/components/BasicSettings/MenuShowcreatetime1.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,28 @@ export default {
const timestamp = Number(time);
const date = new Date(timestamp);
const now = new Date();
const isToday =
const isToday =
now.getFullYear() === date.getFullYear() &&
now.getMonth() === date.getMonth() &&
now.getDate() === date.getDate();
const isThisYear = now.getFullYear() === date.getFullYear();
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
return isToday ? `${hours}:${minutes}` : `${month}/${day} ${hours}:${minutes}`;
if (isToday) {
return `${hours}:${minutes}`;
} else if (isThisYear) {
return `${month}/${day} ${hours}:${minutes}`;
} else {
return `${year}/${month}/${day} ${hours}:${minutes}`;
}
},
convertToTimestamp(dateStr) {
const cleanedDateStr = dateStr.replace(/\s+/g, ""); // 去掉所有空格
const datePattern = /(\d{4})年(\d{1,2})月(\d{1,2})日(\d{2}):(\d{2})/;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "linuxdo-scripts",
"description": "manifest.json description",
"private": true,
"version": "1.0.8",
"version": "1.0.9",
"type": "module",
"scripts": {
"dev": "wxt",
Expand Down
4 changes: 4 additions & 0 deletions version-log.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.9

- fix: 修复跨年份时期显示问题

## 1.0.8

- feat: 新增收藏夹文件夹功能(测试中,注意备份!)
Expand Down

0 comments on commit 6899620

Please sign in to comment.