- {{ timeString }}{{ secondsString }}
+ {{ timeString }}{{ secondsString }} {{ amPmString }}
{{ dateString }} {{ weekdayString }} {{ periodOfDay }}
@@ -677,6 +684,24 @@
/>
+
+
+
+
+ 12 小时制
+ 以 12 小时制(AM/PM)显示时间。
+
+
+
+
@@ -720,6 +745,7 @@ export default {
showFullscreen: false,
showSettings: false,
timeCardEnabled: true,
+ use12hClock: false,
// 全屏模式切换
fullscreenMode: 'clock',
// 工具栏自动隐藏
@@ -785,9 +811,16 @@ export default {
},
computed: {
timeString() {
- const h = String(this.now.getHours()).padStart(2, '0')
+ const hours = this.now.getHours()
const m = String(this.now.getMinutes()).padStart(2, '0')
- return `${h}:${m}`
+ if (this.use12hClock) {
+ const h12 = hours % 12 || 12
+ return `${h12}:${m}`
+ }
+ return `${String(hours).padStart(2, '0')}:${m}`
+ },
+ amPmString() {
+ return this.now.getHours() < 12 ? 'AM' : 'PM'
},
secondsString() {
return `:${String(this.now.getSeconds()).padStart(2, '0')}`
@@ -994,12 +1027,17 @@ export default {
loadSettings() {
this.fontSize = SettingsManager.getSetting('font.size')
this.timeCardEnabled = getSetting('timeCard.enabled')
+ this.use12hClock = getSetting('timeCard.use12h')
this.noiseEnabled = getSetting('noiseMonitor.enabled')
},
setTimeCardEnabled(val) {
this.timeCardEnabled = val
setSetting('timeCard.enabled', val)
},
+ setUse12hClock(val) {
+ this.use12hClock = val
+ setSetting('timeCard.use12h', val)
+ },
startTimer() {
this.timer = setInterval(() => {
this.now = new Date()
diff --git a/src/utils/settings.js b/src/utils/settings.js
index c475762..a7c15f0 100644
--- a/src/utils/settings.js
+++ b/src/utils/settings.js
@@ -127,6 +127,12 @@ const settingsDefinitions = {
description: "启用时间卡片",
icon: "mdi-clock-outline",
},
+ "timeCard.use12h": {
+ type: "boolean",
+ default: false,
+ description: "使用 12 小时制显示时间",
+ icon: "mdi-clock-time-six-outline",
+ },
// 一言设置
"hitokoto.enabled": {