feat(工具箱): 完善“原神时钟”,添加背景图片
This commit is contained in:
@@ -87,24 +87,16 @@ import {
|
||||
} from 'vue';
|
||||
|
||||
import {
|
||||
IMAGE_CLOCK_BG_INNER,
|
||||
IMAGE_CLOCK_BG_OUTER,
|
||||
IMAGE_CLOCK_DIAL,
|
||||
IMAGE_CLOCK_GEAR_1,
|
||||
IMAGE_CLOCK_GEAR_4,
|
||||
IMAGE_CLOCK_GEAR_5,
|
||||
IMAGE_CLOCK_GEAR_6,
|
||||
IMAGE_CLOCK_PARTICLES,
|
||||
IMAGE_POINTER_LOWER,
|
||||
IMAGE_POINTER_UPPER,
|
||||
IMAGE_TIME_ICON_DUSK,
|
||||
IMAGE_TIME_ICON_MORNING,
|
||||
IMAGE_TIME_ICON_NIGHT,
|
||||
IMAGE_TIME_ICON_NOON,
|
||||
IMAGE_CLOCK_BG_INNER, IMAGE_CLOCK_BG_OUTER, IMAGE_CLOCK_DIAL,
|
||||
IMAGE_CLOCK_GEAR_1, IMAGE_CLOCK_GEAR_4,
|
||||
IMAGE_CLOCK_GEAR_5, IMAGE_CLOCK_GEAR_6,
|
||||
IMAGE_CLOCK_PARTICLES, IMAGE_POINTER_LOWER, IMAGE_POINTER_UPPER,
|
||||
IMAGE_TIME_ICON_DUSK, IMAGE_TIME_ICON_MORNING,
|
||||
IMAGE_TIME_ICON_NIGHT, IMAGE_TIME_ICON_NOON,
|
||||
isAutoRotating, isTimeExceeded, isTimeTooEarly,
|
||||
timeCurrHour, timeCurrMinute,
|
||||
timeCurrHour, timeCurrMinute, timeCurrValue,
|
||||
timeDiffLabel, timeDiffLabelStill,
|
||||
timeNewHour, timeNewMinute,
|
||||
timeNewHour, timeNewMinute, timeNewValue,
|
||||
} from './common-data';
|
||||
|
||||
import ClockColor from './ClockColor.vue';
|
||||
@@ -358,6 +350,7 @@ watch(() => {
|
||||
// 计算时间值
|
||||
timeCurrHour.value = String(currHour).padStart(2, '0');
|
||||
timeCurrMinute.value = String(currMinute).padStart(2, '0');
|
||||
timeCurrValue.value = timeValue;
|
||||
|
||||
}, { immediate: true });
|
||||
|
||||
@@ -410,6 +403,7 @@ watch(() => {
|
||||
// 计算时间值
|
||||
timeNewHour.value = String(newHour).padStart(2, '0');
|
||||
timeNewMinute.value = String(newMinute).padStart(2, '0');
|
||||
timeNewValue.value = timeValue;
|
||||
|
||||
}, { immediate: true });
|
||||
|
||||
@@ -442,7 +436,7 @@ onBeforeUnmount(() => {
|
||||
width: 32em;
|
||||
height: 32em;
|
||||
border-radius: 50%;
|
||||
font-size: 11px;
|
||||
font-size: 12px;
|
||||
overflow: hidden;
|
||||
filter: brightness(1.1) saturate(0.9);
|
||||
}
|
||||
@@ -661,7 +655,7 @@ onBeforeUnmount(() => {
|
||||
|
||||
> div {
|
||||
// [角度 1 相关计算]
|
||||
// 计算指针角度与图标所在角度的差值(可能为负数)
|
||||
// 计算指针角度与图标对应角度的差值(可能为负数)
|
||||
--angle-1-diff: calc(var(--self-angle-1) - var(--pointer-lower-angle-value));
|
||||
// 计算角度差值的绝对值
|
||||
--angle-1-abs: ~"max(var(--angle-1-diff), var(--angle-1-diff) * -1)";
|
||||
|
@@ -1,6 +1,42 @@
|
||||
<template>
|
||||
<div class="tool-detail-page has-radius">
|
||||
|
||||
<!-- 背景图片 -->
|
||||
<div
|
||||
class="page-bg-wrapper"
|
||||
:style="{ '--curr-time': Number(timeCurrValue) }"
|
||||
>
|
||||
<div
|
||||
:style="{
|
||||
'--bg-url': IMAGE_BG_DUSK,
|
||||
'--self-hour-1': 18,
|
||||
'--self-hour-2': 18,
|
||||
}"
|
||||
></div>
|
||||
<div
|
||||
:style="{
|
||||
'--bg-url': IMAGE_BG_MORNING,
|
||||
'--self-hour-1': 6,
|
||||
'--self-hour-2': 6,
|
||||
}"
|
||||
></div>
|
||||
<div
|
||||
:style="{
|
||||
'--bg-url': IMAGE_BG_NIGHT,
|
||||
'--self-hour-1': 0,
|
||||
'--self-hour-2': 24,
|
||||
}"
|
||||
></div>
|
||||
<div
|
||||
:style="{
|
||||
'--bg-url': IMAGE_BG_NOON,
|
||||
'--self-hour-1': 12,
|
||||
'--self-hour-2': 12,
|
||||
}"
|
||||
></div>
|
||||
<div class="page-bg-mask"></div>
|
||||
</div>
|
||||
|
||||
<!-- 左 -->
|
||||
<div class="page-column">
|
||||
<time-info />
|
||||
@@ -55,7 +91,14 @@ import {
|
||||
} from 'vue';
|
||||
|
||||
import {
|
||||
isAutoRotating, isTimeTooEarly, isTimeExceeded,
|
||||
IMAGE_BG_DUSK,
|
||||
IMAGE_BG_MORNING,
|
||||
IMAGE_BG_NIGHT,
|
||||
IMAGE_BG_NOON,
|
||||
isAutoRotating,
|
||||
isTimeTooEarly,
|
||||
isTimeExceeded,
|
||||
timeCurrValue,
|
||||
} from './common-data';
|
||||
|
||||
import ClockElement from './ClockElement.vue';
|
||||
@@ -82,17 +125,63 @@ function handleConfirm() {
|
||||
|
||||
<style lang="less" scoped>
|
||||
.tool-detail-page {
|
||||
position: relative;
|
||||
background-color: #000;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.page-bg-wrapper {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
z-index: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
> div {
|
||||
// [小时 1 相关计算]
|
||||
// 计算当前小时与背景对应小时的差值(可能为负数)
|
||||
--hour-1-diff: calc(var(--self-hour-1) - var(--curr-time));
|
||||
// 计算小时差值的绝对值
|
||||
--hour-1-abs: ~"max(var(--hour-1-diff), var(--hour-1-diff) * -1)";
|
||||
// 限制小时最大差值为 6
|
||||
--hour-1-use: ~"min(6, var(--hour-1-abs))";
|
||||
// [小时 2 相关计算,主要用于 0 点]
|
||||
// 计算当前小时与背景所在小时的差值(可能为负数)
|
||||
--hour-2-diff: calc(var(--self-hour-2) - var(--curr-time));
|
||||
// 计算小时差值的绝对值
|
||||
--hour-2-abs: ~"max(var(--hour-2-diff), var(--hour-2-diff) * -1)";
|
||||
// 限制小时最大差值为 6
|
||||
--hour-2-use: ~"min(6, var(--hour-2-abs))";
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: var(--bg-url);
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
// 根据小时计算透明度
|
||||
// 注:计算两个小时的透明度,取最大值
|
||||
opacity: ~"calc((6 - min(var(--hour-1-use), var(--hour-2-use))) / 6)";
|
||||
}
|
||||
|
||||
.page-bg-mask {
|
||||
background-color: #000;
|
||||
opacity: 0.75;
|
||||
}
|
||||
}
|
||||
|
||||
.page-column {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
justify-content: center;;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
vertical-align: middle;
|
||||
height: 100%;
|
||||
white-space: initial;
|
||||
|
@@ -1,6 +1,10 @@
|
||||
import { ref } from "vue";
|
||||
|
||||
export const IMAGE_BASE = `https://c.frost-zx.top/data/static/image/genshin-impact-clock`;
|
||||
export const IMAGE_BG_DUSK = `url("${IMAGE_BASE}/bg_dusk.png")`;
|
||||
export const IMAGE_BG_MORNING = `url("${IMAGE_BASE}/bg_morning.png")`;
|
||||
export const IMAGE_BG_NIGHT = `url("${IMAGE_BASE}/bg_night.png")`;
|
||||
export const IMAGE_BG_NOON = `url("${IMAGE_BASE}/bg_noon.png")`;
|
||||
export const IMAGE_CLOCK_BG_INNER = `url("${IMAGE_BASE}/clock_bg_inner.png")`;
|
||||
export const IMAGE_CLOCK_BG_OUTER = `url("${IMAGE_BASE}/clock_bg_outer.png")`;
|
||||
export const IMAGE_CLOCK_DIAL = `url("${IMAGE_BASE}/clock_dial.png")`;
|
||||
@@ -33,6 +37,9 @@ export const timeCurrHour = ref('00');
|
||||
/** 当前分 */
|
||||
export const timeCurrMinute = ref('00');
|
||||
|
||||
/** 当前时分 */
|
||||
export const timeCurrValue = ref(0);
|
||||
|
||||
/** 时间差(动态)*/
|
||||
export const timeDiffLabel = ref('');
|
||||
|
||||
@@ -44,3 +51,6 @@ export const timeNewHour = ref('00');
|
||||
|
||||
/** 新的分 */
|
||||
export const timeNewMinute = ref('00');
|
||||
|
||||
/** 新的时分 */
|
||||
export const timeNewValue = ref(0);
|
||||
|
Reference in New Issue
Block a user