1.0.2 Update
加入了屏幕常亮功能。
This commit is contained in:
+8
-2
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"package": "cn.seedsoft.tmtclock",
|
"package": "cn.seedsoft.tmtclock",
|
||||||
"name": "番茄钟",
|
"name": "番茄钟",
|
||||||
"versionName": "1.0.1",
|
"versionName": "1.0.2",
|
||||||
"versionCode": 2,
|
"versionCode": 3,
|
||||||
"minPlatformVersion": 1000,
|
"minPlatformVersion": 1000,
|
||||||
"icon": "/common/logo.png",
|
"icon": "/common/logo.png",
|
||||||
"deviceTypeList": [
|
"deviceTypeList": [
|
||||||
@@ -23,6 +23,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "system.audio"
|
"name": "system.audio"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "system.brightness"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "system.storage"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"config": {
|
"config": {
|
||||||
|
|||||||
+105
-2
@@ -24,6 +24,16 @@
|
|||||||
<text class="stats-title rest-title">累计休息</text>
|
<text class="stats-title rest-title">累计休息</text>
|
||||||
<text class="stats-value rest-value">{{ restTotalText }}</text>
|
<text class="stats-value rest-value">{{ restTotalText }}</text>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="settings-page">
|
||||||
|
<text class="settings-title">设置</text>
|
||||||
|
<div class="setting-row">
|
||||||
|
<text class="setting-label">屏幕常亮</text>
|
||||||
|
<div class="toggle-track {{screenAlwaysOn ? 'toggle-on' : 'toggle-off'}}" onclick="toggleScreenAlwaysOn">
|
||||||
|
<div class="toggle-knob {{screenAlwaysOn ? 'knob-on' : 'knob-off'}}"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</swiper>
|
</swiper>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -31,6 +41,8 @@
|
|||||||
import router from "@system.router"
|
import router from "@system.router"
|
||||||
import file from "@system.file"
|
import file from "@system.file"
|
||||||
import vibrator from "@system.vibrator"
|
import vibrator from "@system.vibrator"
|
||||||
|
import brightness from "@system.brightness"
|
||||||
|
import storage from "@system.storage"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
protected: { duration: "m:20" },
|
protected: { duration: "m:20" },
|
||||||
@@ -44,6 +56,7 @@ export default {
|
|||||||
isResting: false,
|
isResting: false,
|
||||||
focusDurationSeconds: 1200,
|
focusDurationSeconds: 1200,
|
||||||
restDurationSeconds: 300,
|
restDurationSeconds: 300,
|
||||||
|
screenAlwaysOn: false,
|
||||||
// 息屏后 setInterval 会被系统挂起,所有计时以时间戳为准
|
// 息屏后 setInterval 会被系统挂起,所有计时以时间戳为准
|
||||||
phaseEndAt: 0,
|
phaseEndAt: 0,
|
||||||
lastCountedAt: 0,
|
lastCountedAt: 0,
|
||||||
@@ -56,6 +69,7 @@ export default {
|
|||||||
|
|
||||||
onInit() {
|
onInit() {
|
||||||
this.loadStats()
|
this.loadStats()
|
||||||
|
this.loadScreenAlwaysOn()
|
||||||
this.startCountdown(this.durationSeconds(this.duration))
|
this.startCountdown(this.durationSeconds(this.duration))
|
||||||
this.updateTime()
|
this.updateTime()
|
||||||
this.clockTimer = setInterval(() => this.updateTime(), 1000)
|
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() {
|
stopTimer() {
|
||||||
router.back()
|
router.back()
|
||||||
}
|
}
|
||||||
@@ -235,14 +278,16 @@ export default {
|
|||||||
<style>
|
<style>
|
||||||
.timer-swiper,
|
.timer-swiper,
|
||||||
.timer-page,
|
.timer-page,
|
||||||
.stats-page {
|
.stats-page,
|
||||||
|
.settings-page {
|
||||||
width: 432px;
|
width: 432px;
|
||||||
height: 514px;
|
height: 514px;
|
||||||
background-color: #000000;
|
background-color: #000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.timer-page,
|
.timer-page,
|
||||||
.stats-page {
|
.stats-page,
|
||||||
|
.settings-page {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,4 +405,62 @@ export default {
|
|||||||
.focus-value { top: 204px; }
|
.focus-value { top: 204px; }
|
||||||
.rest-title { top: 260px; color: rgba(149, 168, 0, 1); }
|
.rest-title { top: 260px; color: rgba(149, 168, 0, 1); }
|
||||||
.rest-value { top: 303px; }
|
.rest-value { top: 303px; }
|
||||||
|
|
||||||
|
.settings-title {
|
||||||
|
position: absolute;
|
||||||
|
left: 66px;
|
||||||
|
top: 19px;
|
||||||
|
width: 300px;
|
||||||
|
height: 45px;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 30px;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 44.8px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setting-row {
|
||||||
|
position: absolute;
|
||||||
|
left: 66px;
|
||||||
|
top: 161px;
|
||||||
|
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; }
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -32,6 +32,16 @@
|
|||||||
<text class="rest-total-title">累计休息</text>
|
<text class="rest-total-title">累计休息</text>
|
||||||
<text class="rest-total-value">{{ restTotalText }}</text>
|
<text class="rest-total-value">{{ restTotalText }}</text>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="settings-page">
|
||||||
|
<text class="settings-title">设置</text>
|
||||||
|
<div class="setting-row">
|
||||||
|
<text class="setting-label">屏幕常亮</text>
|
||||||
|
<div class="toggle-track {{screenAlwaysOn ? 'toggle-on' : 'toggle-off'}}" onclick="toggleScreenAlwaysOn">
|
||||||
|
<div class="toggle-knob {{screenAlwaysOn ? 'knob-on' : 'knob-off'}}"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</swiper>
|
</swiper>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -39,6 +49,8 @@
|
|||||||
import router from "@system.router"
|
import router from "@system.router"
|
||||||
import file from "@system.file"
|
import file from "@system.file"
|
||||||
import vibrator from "@system.vibrator"
|
import vibrator from "@system.vibrator"
|
||||||
|
import brightness from "@system.brightness"
|
||||||
|
import storage from "@system.storage"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
protected: {
|
protected: {
|
||||||
@@ -55,6 +67,7 @@ export default {
|
|||||||
isResting: false,
|
isResting: false,
|
||||||
focusDurationSeconds: 1200,
|
focusDurationSeconds: 1200,
|
||||||
restDurationSeconds: 300,
|
restDurationSeconds: 300,
|
||||||
|
screenAlwaysOn: false,
|
||||||
// 息屏后 setInterval 会被系统挂起,所有计时以时间戳为准
|
// 息屏后 setInterval 会被系统挂起,所有计时以时间戳为准
|
||||||
phaseEndAt: 0,
|
phaseEndAt: 0,
|
||||||
lastCountedAt: 0,
|
lastCountedAt: 0,
|
||||||
@@ -67,6 +80,7 @@ export default {
|
|||||||
|
|
||||||
onInit() {
|
onInit() {
|
||||||
this.loadStats()
|
this.loadStats()
|
||||||
|
this.loadScreenAlwaysOn()
|
||||||
const duration = this.durationSeconds(this.duration)
|
const duration = this.durationSeconds(this.duration)
|
||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
this.startCountdown(duration)
|
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() {
|
stopTimer() {
|
||||||
router.back()
|
router.back()
|
||||||
}
|
}
|
||||||
@@ -389,6 +432,13 @@ export default {
|
|||||||
background-color: #000000;
|
background-color: #000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.settings-page {
|
||||||
|
position: relative;
|
||||||
|
width: 466px;
|
||||||
|
height: 466px;
|
||||||
|
background-color: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
.stats-clock-label {
|
.stats-clock-label {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 169px;
|
left: 169px;
|
||||||
@@ -460,4 +510,62 @@ export default {
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 53.04px;
|
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; }
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
+102
-3
@@ -22,6 +22,15 @@
|
|||||||
<text class="stats-title rest-title">累计休息</text>
|
<text class="stats-title rest-title">累计休息</text>
|
||||||
<text class="stats-value rest-value">{{ restTotalText }}</text>
|
<text class="stats-value rest-value">{{ restTotalText }}</text>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="settings-page">
|
||||||
|
<text class="settings-title">设置</text>
|
||||||
|
<div class="setting-row">
|
||||||
|
<text class="setting-label">屏幕常亮</text>
|
||||||
|
<div class="toggle-track {{screenAlwaysOn ? 'toggle-on' : 'toggle-off'}}" onclick="toggleScreenAlwaysOn">
|
||||||
|
<div class="toggle-knob {{screenAlwaysOn ? 'knob-on' : 'knob-off'}}"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</swiper>
|
</swiper>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -29,13 +38,15 @@
|
|||||||
import router from "@system.router"
|
import router from "@system.router"
|
||||||
import file from "@system.file"
|
import file from "@system.file"
|
||||||
import vibrator from "@system.vibrator"
|
import vibrator from "@system.vibrator"
|
||||||
|
import brightness from "@system.brightness"
|
||||||
|
import storage from "@system.storage"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
protected: { duration: "m:20" },
|
protected: { duration: "m:20" },
|
||||||
private: {
|
private: {
|
||||||
time: "00:00", countdown: "20:00", clockTimer: null, countdownTimer: null,
|
time: "00:00", countdown: "20:00", clockTimer: null, countdownTimer: null,
|
||||||
remaining: 1200, paused: false, isResting: false, focusDurationSeconds: 1200,
|
remaining: 1200, paused: false, isResting: false, focusDurationSeconds: 1200,
|
||||||
restDurationSeconds: 300,
|
restDurationSeconds: 300, screenAlwaysOn: false,
|
||||||
// 息屏后 setInterval 会被系统挂起,所有计时以时间戳为准
|
// 息屏后 setInterval 会被系统挂起,所有计时以时间戳为准
|
||||||
phaseEndAt: 0, lastCountedAt: 0, lastPersistAt: 0,
|
phaseEndAt: 0, lastCountedAt: 0, lastPersistAt: 0,
|
||||||
focusTotalMs: 0, restTotalMs: 0,
|
focusTotalMs: 0, restTotalMs: 0,
|
||||||
@@ -44,6 +55,7 @@ export default {
|
|||||||
|
|
||||||
onInit() {
|
onInit() {
|
||||||
this.loadStats()
|
this.loadStats()
|
||||||
|
this.loadScreenAlwaysOn()
|
||||||
const seconds = this.durationSeconds(this.duration)
|
const seconds = this.durationSeconds(this.duration)
|
||||||
this.startCountdown(seconds > 0 ? seconds : 1200)
|
this.startCountdown(seconds > 0 ? seconds : 1200)
|
||||||
this.updateTime()
|
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() }
|
stopTimer() { router.back() }
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.timer-swiper, .timer-page, .stats-page {
|
.timer-swiper, .timer-page, .stats-page, .settings-page {
|
||||||
width: 480px;
|
width: 480px;
|
||||||
height: 480px;
|
height: 480px;
|
||||||
background-color: #000000;
|
background-color: #000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.timer-page, .stats-page { position: relative; }
|
.timer-page, .stats-page, .settings-page { position: relative; }
|
||||||
|
|
||||||
.clock-label {
|
.clock-label {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -340,4 +381,62 @@ export default {
|
|||||||
.focus-value { top: 184px; }
|
.focus-value { top: 184px; }
|
||||||
.rest-title { top: 240px; color: rgba(149, 168, 0, 1); }
|
.rest-title { top: 240px; color: rgba(149, 168, 0, 1); }
|
||||||
.rest-value { top: 283px; }
|
.rest-value { top: 283px; }
|
||||||
|
|
||||||
|
.settings-title {
|
||||||
|
position: absolute;
|
||||||
|
left: 90px;
|
||||||
|
top: 41px;
|
||||||
|
width: 300px;
|
||||||
|
height: 45px;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 30px;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 44.8px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setting-row {
|
||||||
|
position: absolute;
|
||||||
|
left: 90px;
|
||||||
|
top: 141px;
|
||||||
|
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; }
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user