mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-15 09:48:14 +08:00
👌 fix(ppol): 卡池结束样式变更
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
<img :src="character.icon" class="pool-icon" alt="character">
|
<img :src="character.icon" class="pool-icon" alt="character">
|
||||||
</div>
|
</div>
|
||||||
<div class="pool-clock">
|
<div class="pool-clock">
|
||||||
<v-progress-circular :model-value="poolTimePass[pool.post_id]" size="100" width="10" color="#90caf9">
|
<v-progress-circular :model-value="poolTimePass[pool.post_id]" size="100" width="10" :color="poolColor">
|
||||||
{{ poolTimeGet[pool.post_id] }}
|
{{ poolTimeGet[pool.post_id] }}
|
||||||
</v-progress-circular>
|
</v-progress-circular>
|
||||||
</div>
|
</div>
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
// vue
|
// vue
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted, onUpdated } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
// store
|
// store
|
||||||
import { useHomeStore } from "../store/modules/home";
|
import { useHomeStore } from "../store/modules/home";
|
||||||
@@ -71,17 +71,41 @@ const loading = ref(true as boolean);
|
|||||||
const poolCards = ref([] as GachaCard[]);
|
const poolCards = ref([] as GachaCard[]);
|
||||||
const poolTimeGet = ref({} as Record<number, string>);
|
const poolTimeGet = ref({} as Record<number, string>);
|
||||||
const poolTimePass = ref({} as Record<number, number>);
|
const poolTimePass = ref({} as Record<number, number>);
|
||||||
|
const poolColor = ref("#fec90b" as string);
|
||||||
|
const timer = ref(null as any);
|
||||||
// expose
|
// expose
|
||||||
defineExpose({
|
defineExpose({
|
||||||
name: "限时祈愿",
|
name: "限时祈愿",
|
||||||
loading,
|
loading,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function poolLastInterval () {
|
||||||
|
poolCards.value.map((pool) => {
|
||||||
|
poolTimeGet.value[pool.post_id] = getLastPoolTime(pool.time.end_stamp - Date.now());
|
||||||
|
poolTimePass.value[pool.post_id] =
|
||||||
|
((pool.time.end_stamp - Date.now()) / (pool.time.end_stamp - pool.time.start_stamp)) * 100;
|
||||||
|
return pool;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听 poolTimePass
|
||||||
|
onUpdated(() => {
|
||||||
|
poolCards.value.map((pool) => {
|
||||||
|
if (poolTimePass.value[pool.post_id] <= 0) {
|
||||||
|
clearInterval(timer.value);
|
||||||
|
timer.value = null;
|
||||||
|
poolTimeGet.value[pool.post_id] = "已结束";
|
||||||
|
poolTimePass.value[pool.post_id] = 100;
|
||||||
|
poolColor.value = "#f44336";
|
||||||
|
}
|
||||||
|
return pool;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const gachaData = await MysOper.Gacha.get();
|
const gachaData = await MysOper.Gacha.get();
|
||||||
if (!gachaData) {
|
if (!gachaData) {
|
||||||
await console.error("获取限时祈愿数据失败");
|
console.error("获取限时祈愿数据失败");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!checkCover(gachaData)) {
|
if (!checkCover(gachaData)) {
|
||||||
@@ -100,13 +124,8 @@ onMounted(async () => {
|
|||||||
poolTimePass.value[pool.post_id] = pool.time.end_stamp - Date.now();
|
poolTimePass.value[pool.post_id] = pool.time.end_stamp - Date.now();
|
||||||
return pool;
|
return pool;
|
||||||
});
|
});
|
||||||
await setInterval(() => {
|
timer.value = setInterval(() => {
|
||||||
poolCards.value.map((pool) => {
|
poolLastInterval();
|
||||||
poolTimeGet.value[pool.post_id] = getLastPoolTime(pool.time.end_stamp - Date.now());
|
|
||||||
poolTimePass.value[pool.post_id] =
|
|
||||||
((pool.time.end_stamp - Date.now()) / (pool.time.end_stamp - pool.time.start_stamp)) * 100;
|
|
||||||
return pool;
|
|
||||||
});
|
|
||||||
}, 1000);
|
}, 1000);
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user