Skip to content

Commit e8ab18f

Browse files
committed
🐛 修复参量质变仪状态判断异常
close #244
1 parent aa4a20b commit e8ab18f

2 files changed

Lines changed: 33 additions & 19 deletions

File tree

src/components/pageHome/ph-daily-note-transformer.vue

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- 参量质变仪显示组件 -->
22
<template>
33
<div :class="{ 'ph-dnt-ready': ready }" class="ph-dnt-box">
4-
<div class="pdb-trans-icon">
4+
<div :class="{ 'ph-dnt-none': !props.trans.obtained }" class="pdb-trans-icon">
55
<img alt="参量质变仪" src="/UI/daily/trans.webp" />
66
</div>
77
<div class="pdb-trans-info">
@@ -29,15 +29,13 @@ const formattedTime = ref<string>("");
2929
let timer: ReturnType<typeof setInterval> | null = null;
3030
3131
const valueText = computed<string>(() => {
32-
if (!props.trans.obtained && !props.trans.recovery_time.reached) {
33-
return "恢复中";
34-
}
35-
if (props.trans.obtained || props.trans.recovery_time.reached) {
32+
if (!props.trans.obtained) return "未拥有";
33+
if (props.trans.recovery_time.reached) {
3634
return "可使用";
3735
}
3836
return formattedTime.value;
3937
});
40-
const ready = computed<boolean>(() => props.trans.obtained || props.trans.recovery_time.reached);
38+
const ready = computed<boolean>(() => props.trans.obtained && props.trans.recovery_time.reached);
4139
4240
onMounted(() => {
4341
initTime();
@@ -61,19 +59,19 @@ watch(
6159
function initTime(): void {
6260
const time = props.trans.recovery_time;
6361
if (time) {
64-
const hours = time.hour || 0;
65-
const minutes = time.minute || 0;
66-
const seconds = time.second || 0;
67-
remainedTime.value = hours * 3600 + minutes * 60 + seconds;
62+
const days = time.Day || 0;
63+
const hours = time.Hour || 0;
64+
const minutes = time.Minute || 0;
65+
const seconds = time.Second || 0;
66+
remainedTime.value = days * 86400 + hours * 3600 + minutes * 60 + seconds;
6867
} else {
6968
remainedTime.value = 0;
7069
}
7170
updateFormattedTime();
7271
}
7372
7473
function startTimer(): void {
75-
if (remainedTime.value <= 0 || props.trans.obtained || props.trans.recovery_time.reached) return;
76-
74+
if (remainedTime.value <= 0 || !props.trans.obtained || props.trans.recovery_time.reached) return;
7775
timer = setInterval(() => {
7876
if (remainedTime.value > 0) {
7977
remainedTime.value -= 1;
@@ -91,11 +89,12 @@ function stopTimer(): void {
9189
9290
function updateFormattedTime(): void {
9391
if (remainedTime.value <= 0) {
94-
formattedTime.value = "0 小时 0 分钟 0 秒";
92+
formattedTime.value = "00:00:00";
9593
return;
9694
}
97-
98-
formattedTime.value = stamp2LastTime(remainedTime.value * 1000);
95+
const days = Math.floor(remainedTime.value / 86400);
96+
if (days > 0) formattedTime.value = `${days}天后可再次使用`;
97+
else formattedTime.value = stamp2LastTime(remainedTime.value * 1000);
9998
}
10099
</script>
101100
<style lang="scss" scoped>
@@ -128,6 +127,13 @@ function updateFormattedTime(): void {
128127
height: 100%;
129128
object-fit: cover;
130129
}
130+
131+
&.ph-dnt-none {
132+
img {
133+
filter: grayscale(1);
134+
opacity: 0.5;
135+
}
136+
}
131137
}
132138
133139
.pdb-trans-info {

src/types/Game/DailyNote.d.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ declare namespace TGApp.Game.DailyNote {
7171
* @since Beta v0.10.0
7272
*/
7373
type TransformerData = {
74-
/** 是否可以使用 */
74+
/** 是否拥有 */
7575
obtained: boolean;
7676
/** 恢复时间 */
7777
recovery_time: TransformerTime;
@@ -85,10 +85,18 @@ declare namespace TGApp.Game.DailyNote {
8585

8686
/**
8787
* 时间
88-
* @since Beta v0.10.0
88+
* @since Beta v0.10.2
8989
*/
90-
type TransformerTime = TGApp.Game.Base.DateTime & {
91-
/** 是否到达 */
90+
type TransformerTime = {
91+
/** 天 */
92+
Day: number;
93+
/** 时 */
94+
Hour: number;
95+
/** 分 */
96+
Minute: number;
97+
/** 秒 */
98+
Second: number;
99+
/** 是否冷却 */
92100
reached: boolean;
93101
};
94102

0 commit comments

Comments
 (0)