diff --git a/src/manifest.json b/src/manifest.json
index 2a855a9..5d6558e 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -1,8 +1,8 @@
{
"package": "cn.seedsoft.tmtclock",
"name": "番茄钟",
- "versionName": "1.0.1",
- "versionCode": 2,
+ "versionName": "1.0.2",
+ "versionCode": 3,
"minPlatformVersion": 1000,
"icon": "/common/logo.png",
"deviceTypeList": [
@@ -23,6 +23,12 @@
},
{
"name": "system.audio"
+ },
+ {
+ "name": "system.brightness"
+ },
+ {
+ "name": "system.storage"
}
],
"config": {
diff --git a/src/pages/5/timer/timer.ux b/src/pages/5/timer/timer.ux
index acc8ecb..20fdf65 100644
--- a/src/pages/5/timer/timer.ux
+++ b/src/pages/5/timer/timer.ux
@@ -24,6 +24,16 @@
累计休息
{{ restTotalText }}
+
+
@@ -31,6 +41,8 @@
import router from "@system.router"
import file from "@system.file"
import vibrator from "@system.vibrator"
+import brightness from "@system.brightness"
+import storage from "@system.storage"
export default {
protected: { duration: "m:20" },
@@ -44,6 +56,7 @@ export default {
isResting: false,
focusDurationSeconds: 1200,
restDurationSeconds: 300,
+ screenAlwaysOn: false,
// 息屏后 setInterval 会被系统挂起,所有计时以时间戳为准
phaseEndAt: 0,
lastCountedAt: 0,
@@ -56,6 +69,7 @@ export default {
onInit() {
this.loadStats()
+ this.loadScreenAlwaysOn()
this.startCountdown(this.durationSeconds(this.duration))
this.updateTime()
this.clockTimer = setInterval(() => this.updateTime(), 1000)
@@ -226,6 +240,35 @@ export default {
}
},
+ loadScreenAlwaysOn() {
+ storage.get({
+ key: "screenAlwaysOn",
+ success: (data) => {
+ const on = data === "true"
+ this.screenAlwaysOn = on
+ if (on) this.applyScreenOn(true)
+ }
+ })
+ },
+
+ toggleScreenAlwaysOn() {
+ const on = !this.screenAlwaysOn
+ this.screenAlwaysOn = on
+ this.applyScreenOn(on)
+ storage.set({
+ key: "screenAlwaysOn",
+ value: "" + on
+ })
+ },
+
+ applyScreenOn(on) {
+ brightness.setKeepScreenOn({
+ keepScreenOn: on,
+ success: () => {},
+ fail: () => {}
+ })
+ },
+
stopTimer() {
router.back()
}
@@ -235,14 +278,16 @@ export default {
diff --git a/src/pages/s4-timer/s4-timer.ux b/src/pages/s4-timer/s4-timer.ux
index 20c2981..0c0ee11 100644
--- a/src/pages/s4-timer/s4-timer.ux
+++ b/src/pages/s4-timer/s4-timer.ux
@@ -32,6 +32,16 @@
累计休息
{{ restTotalText }}
+
+
@@ -39,6 +49,8 @@
import router from "@system.router"
import file from "@system.file"
import vibrator from "@system.vibrator"
+import brightness from "@system.brightness"
+import storage from "@system.storage"
export default {
protected: {
@@ -55,6 +67,7 @@ export default {
isResting: false,
focusDurationSeconds: 1200,
restDurationSeconds: 300,
+ screenAlwaysOn: false,
// 息屏后 setInterval 会被系统挂起,所有计时以时间戳为准
phaseEndAt: 0,
lastCountedAt: 0,
@@ -67,6 +80,7 @@ export default {
onInit() {
this.loadStats()
+ this.loadScreenAlwaysOn()
const duration = this.durationSeconds(this.duration)
if (duration > 0) {
this.startCountdown(duration)
@@ -269,6 +283,35 @@ export default {
}
},
+ loadScreenAlwaysOn() {
+ storage.get({
+ key: "screenAlwaysOn",
+ success: (data) => {
+ const on = data === "true"
+ this.screenAlwaysOn = on
+ if (on) this.applyScreenOn(true)
+ }
+ })
+ },
+
+ toggleScreenAlwaysOn() {
+ const on = !this.screenAlwaysOn
+ this.screenAlwaysOn = on
+ this.applyScreenOn(on)
+ storage.set({
+ key: "screenAlwaysOn",
+ value: "" + on
+ })
+ },
+
+ applyScreenOn(on) {
+ brightness.setKeepScreenOn({
+ keepScreenOn: on,
+ success: () => {},
+ fail: () => {}
+ })
+ },
+
stopTimer() {
router.back()
}
@@ -389,6 +432,13 @@ export default {
background-color: #000000;
}
+.settings-page {
+ position: relative;
+ width: 466px;
+ height: 466px;
+ background-color: #000000;
+}
+
.stats-clock-label {
position: absolute;
left: 169px;
@@ -460,4 +510,62 @@ export default {
font-weight: 500;
line-height: 53.04px;
}
+
+.settings-title {
+ position: absolute;
+ left: 83px;
+ top: 34px;
+ width: 300px;
+ height: 45px;
+ color: #ffffff;
+ font-size: 30px;
+ font-weight: 500;
+ line-height: 44.8px;
+ text-align: center;
+}
+
+.setting-row {
+ position: absolute;
+ left: 83px;
+ top: 134px;
+ width: 300px;
+ height: 45px;
+}
+
+.setting-label {
+ position: absolute;
+ left: 0px;
+ top: 0px;
+ width: 220px;
+ height: 45px;
+ color: #ffffff;
+ font-size: 30px;
+ font-weight: 500;
+ line-height: 44.8px;
+ text-align: left;
+}
+
+.toggle-track {
+ position: absolute;
+ left: 232px;
+ top: 5px;
+ width: 60px;
+ height: 34px;
+ border-radius: 17px;
+}
+
+.toggle-on { background-color: #1cb45c; }
+.toggle-off { background-color: #3f3f3f; }
+
+.toggle-knob {
+ position: absolute;
+ top: 4px;
+ width: 26px;
+ height: 26px;
+ border-radius: 13px;
+ background-color: #ffffff;
+}
+
+.knob-on { left: 32px; }
+.knob-off { left: 2px; }
diff --git a/src/pages/s5/timer/timer.ux b/src/pages/s5/timer/timer.ux
index 5ee589b..0f832a3 100644
--- a/src/pages/s5/timer/timer.ux
+++ b/src/pages/s5/timer/timer.ux
@@ -22,6 +22,15 @@
累计休息
{{ restTotalText }}
+
@@ -29,13 +38,15 @@
import router from "@system.router"
import file from "@system.file"
import vibrator from "@system.vibrator"
+import brightness from "@system.brightness"
+import storage from "@system.storage"
export default {
protected: { duration: "m:20" },
private: {
time: "00:00", countdown: "20:00", clockTimer: null, countdownTimer: null,
remaining: 1200, paused: false, isResting: false, focusDurationSeconds: 1200,
- restDurationSeconds: 300,
+ restDurationSeconds: 300, screenAlwaysOn: false,
// 息屏后 setInterval 会被系统挂起,所有计时以时间戳为准
phaseEndAt: 0, lastCountedAt: 0, lastPersistAt: 0,
focusTotalMs: 0, restTotalMs: 0,
@@ -44,6 +55,7 @@ export default {
onInit() {
this.loadStats()
+ this.loadScreenAlwaysOn()
const seconds = this.durationSeconds(this.duration)
this.startCountdown(seconds > 0 ? seconds : 1200)
this.updateTime()
@@ -215,18 +227,47 @@ export default {
}
},
+ loadScreenAlwaysOn() {
+ storage.get({
+ key: "screenAlwaysOn",
+ success: (data) => {
+ const on = data === "true"
+ this.screenAlwaysOn = on
+ if (on) this.applyScreenOn(true)
+ }
+ })
+ },
+
+ toggleScreenAlwaysOn() {
+ const on = !this.screenAlwaysOn
+ this.screenAlwaysOn = on
+ this.applyScreenOn(on)
+ storage.set({
+ key: "screenAlwaysOn",
+ value: "" + on
+ })
+ },
+
+ applyScreenOn(on) {
+ brightness.setKeepScreenOn({
+ keepScreenOn: on,
+ success: () => {},
+ fail: () => {}
+ })
+ },
+
stopTimer() { router.back() }
}