-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79c5d1a
commit b38487d
Showing
18 changed files
with
316 additions
and
75 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<script setup> | ||
import { ref, onMounted } from "vue"; | ||
import { getvcp } from "@/util/vcp.js"; | ||
import { useInterval } from "@/hook/定时器.js"; | ||
const 屏幕亮度 = ref(-1); | ||
async function 加载数据() { | ||
const { v } = await getvcp("10"); | ||
屏幕亮度.value = v; | ||
} | ||
// 每 10s 刷新一次 | ||
useInterval(加载数据, 10e3); | ||
onMounted(加载数据); | ||
</script> | ||
|
||
<template> | ||
<span class="c-屏幕亮度">屏幕亮度: {{ 屏幕亮度 }}%</span> | ||
</template> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<script setup> | ||
import { computed } from "vue"; | ||
const p = defineProps({ | ||
天气数据: Object, | ||
}); | ||
const 当前气温 = computed(() => p.天气数据.now.temp); | ||
const 天气状况 = computed(() => p.天气数据.now.text); | ||
const 相对湿度 = computed(() => p.天气数据.now.humidity); | ||
const 大气压强 = computed(() => (Number.parseFloat(p.天气数据.now.pressure) / 10).toFixed(1)); | ||
const 风向 = computed(() => p.天气数据.now.windDir); | ||
const 风级 = computed(() => p.天气数据.now.windScale); | ||
const 风速 = computed(() => p.天气数据.now.windSpeed); | ||
</script> | ||
|
||
<template> | ||
<v-col class="c-qw实时天气" cols="4"> | ||
<div class="d-flex align-start"> | ||
<div class="text-h2">{{ 当前气温 }}</div> | ||
<div class="text-h2 温度单位"><span>°C</span></div> | ||
|
||
<div class="text-h4 天气状况">{{ 天气状况 }}</div> | ||
</div> | ||
|
||
<p class="信息2 d-flex py-2 justify-space-between text-medium-emphasis"> | ||
<span>湿度 {{ 相对湿度 }}%</span> | ||
<span>气压 {{ 大气压强 }}kPa</span> | ||
</p> | ||
<p class="信息2 py-2 text-medium-emphasis"> | ||
<span>{{ 风向 }}, {{ 风级 }} 级 ({{ 风速 }}km/h)</span> | ||
</p> | ||
</v-col> | ||
</template> | ||
|
||
<style scoped> | ||
.温度单位 { | ||
flex-grow: 1; | ||
line-height: 0.5em; | ||
} | ||
.温度单位 span { | ||
font-size: 0.6em; | ||
} | ||
.信息2 { | ||
font-size: 1.4em; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<script setup> | ||
import { computed } from "vue"; | ||
import { 格式化时分 } from "@/util/时间.js"; | ||
const p = defineProps({ | ||
天气数据: Object, | ||
}); | ||
const 显示数据 = computed(() => { | ||
const 结果 = p.天气数据.hourly.map((x) => ({ | ||
时间: 格式化时分(new Date(x.fxTime)), | ||
温度: x.temp, | ||
t: Number.parseFloat(x.temp), | ||
})); | ||
// 温度范围 | ||
let 最小 = 0; | ||
let 最大 = 0; | ||
for (const i of 结果) { | ||
if (i.t < 最小) { | ||
最小 = i.t; | ||
} | ||
if (i.t > 最大) { | ||
最大 = i.t; | ||
} | ||
} | ||
// 最大最小要有足够的差值 | ||
if ((最大 - 最小) < 1) { | ||
最小 = 最大 - 1; | ||
} | ||
// 最大最小按 10 跳变 | ||
最小 = Math.floor(最小 / 10) * 10; | ||
最大 = Math.ceil(最大 / 10) * 10; | ||
// 温度条 | ||
for (const i of 结果) { | ||
i.p = ((i.t - 最小) / (最大 - 最小)) * 100; | ||
} | ||
// 只显示 12 个, 太多显示不下 | ||
return 结果.slice(0, 12); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<v-col class="c-qw小时预报 ml-2" col="8"> | ||
<v-row class="内容" no-gutters> | ||
<template v-for="(i, j) in 显示数据"> | ||
<v-col class="列" col="1"> | ||
<span>{{ i.温度 }}°C</span> | ||
|
||
<div class="温度条0"> | ||
<div class="温度条1"> | ||
<div class="温度条2"> | ||
<v-progress-linear | ||
:model-value="i.p" | ||
:height="16" | ||
color="primary" | ||
rounded | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<span | ||
v-if="j % 3 == 0" | ||
class="text-medium-emphasis" | ||
>{{ i.时间 }}</span> | ||
<span | ||
v-if="j % 3 != 0" | ||
class="占位 text-medium-emphasis" | ||
>-</span> | ||
</v-col> | ||
</template> | ||
</v-row> | ||
</v-col> | ||
</template> | ||
|
||
<style scoped> | ||
.内容 { | ||
height: 100%; | ||
} | ||
.列 { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
.温度条0 { | ||
position: relative; | ||
top: 0; | ||
left: 0; | ||
flex-grow: 1; | ||
} | ||
.温度条1 { | ||
position: absolute; | ||
top: 40%; | ||
left: -45px; | ||
} | ||
.温度条2 { | ||
width: 90px; | ||
rotate: -90deg; | ||
} | ||
.占位 { | ||
opacity: 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,37 @@ | ||
<script setup> | ||
import { computed } from "vue"; | ||
import { 格式化时分 } from "@/util/时间.js"; | ||
import { useWeather } from "@/hook/天气.js"; | ||
import c天气qw from "./天气qw.vue"; | ||
const { 天气配置, 天气正在加载, 天气数据, 天气错误 } = useWeather(); | ||
const api = computed(() => 天气配置.value.api); | ||
const 更新时间 = computed(() => { | ||
if ("qweather" == api.value) { | ||
const d = new Date(天气数据.value.now.obsTime); | ||
return 格式化时分(d); | ||
} | ||
return ""; | ||
}); | ||
const 正在加载 = computed(() => 天气正在加载.value && (null == 天气错误.value)); | ||
const 显示错误 = computed(() => null != 天气错误.value); | ||
const 显示内容 = computed(() => !天气正在加载.value); | ||
</script> | ||
|
||
<template> | ||
<v-card | ||
class="c-天气" | ||
title="天气" | ||
> | ||
<v-card-text v-if="天气正在加载 && (null == 天气错误)"> | ||
<v-card-text v-if="正在加载" class="d-flex justify-center"> | ||
<v-progress-circular color="primary" indeterminate /> | ||
</v-card-text> | ||
<v-card-text v-if="天气错误 != null"> | ||
<v-card-text v-if="显示错误"> | ||
<v-alert title="错误" :text="天气错误" type="error" /> | ||
</v-card-text> | ||
|
||
<template v-if="!天气正在加载"> | ||
<template v-if="api == 'qweather'"> | ||
<v-card-text class="py-0 d-flex"> | ||
<v-row no-gutters> | ||
<v-col cols="4"> | ||
<div class="d-flex align-start"> | ||
<div class="text-h2">{{ 天气数据.now.temp }}</div> | ||
<div class="text-h2 温度单位"><span>°C</span></div> | ||
|
||
<div class="text-h3 天气状况">{{ 天气数据.now.text }}</div> | ||
</div> | ||
|
||
<p class="信息2 d-flex py-2 justify-space-between text-medium-emphasis"> | ||
<span>湿度 {{ 天气数据.now.humidity }}%</span> | ||
<span>气压 {{ (Number.parseFloat(天气数据.now.pressure) / 10).toFixed(1) }}kPa</span> | ||
</p> | ||
</v-col> | ||
|
||
<v-col col="8"> | ||
<div class="d-flex justify-center">(TODO)</div> | ||
</v-col> | ||
</v-row> | ||
</v-card-text> | ||
|
||
<v-divider class="mt-3" /> | ||
<v-card-actions class="数据来源0"> | ||
<span class="数据来源 text-medium-emphasis">数据来源: <a href="https://www.qweather.com" target="_blank">和风天气</a></span> | ||
<span class="更新时间 text-medium-emphasis">(更新时间 {{ 更新时间 }})</span> | ||
</v-card-actions> | ||
</template> | ||
|
||
<template v-if="显示内容"> | ||
<c天气qw | ||
v-if="api == 'qweather'" | ||
:天气配置="天气配置" | ||
:天气数据="天气数据" | ||
/> | ||
</template> | ||
</v-card> | ||
</template> | ||
|
||
<style scoped> | ||
.温度单位 { | ||
flex-grow: 1; | ||
line-height: 0.5em; | ||
} | ||
.温度单位 span { | ||
font-size: 0.6em; | ||
} | ||
.信息2 { | ||
font-size: 1.2em; | ||
} | ||
.数据来源 { | ||
flex-grow: 1; | ||
} | ||
.数据来源0 { | ||
font-size: 0.8em; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<script setup> | ||
import { computed } from "vue"; | ||
import { 格式化时分 } from "@/util/时间.js"; | ||
import cqw实时天气 from "./qw实时天气.vue"; | ||
import cqw小时预报 from "./qw小时预报.vue"; | ||
const p = defineProps({ | ||
天气配置: Object, | ||
天气数据: Object, | ||
}); | ||
const 更新时间 = computed(() => { | ||
const d = new Date(p.天气数据.实时.now.obsTime); | ||
return 格式化时分(d); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<v-card-text class="py-0 d-flex"> | ||
<v-row no-gutters> | ||
<cqw实时天气 :天气数据="p.天气数据.实时" /> | ||
<cqw小时预报 :天气数据="p.天气数据.小时预报" /> | ||
</v-row> | ||
</v-card-text> | ||
|
||
<v-divider class="mt-3" /> | ||
<v-card-actions class="数据来源0"> | ||
<span class="数据来源 text-medium-emphasis">数据来源: 和风天气 https://www.qweather.com</span> | ||
<span class="更新时间 text-medium-emphasis">(更新时间 {{ 更新时间 }})</span> | ||
</v-card-actions> | ||
</template> | ||
|
||
<style scoped> | ||
.数据来源 { | ||
flex-grow: 1; | ||
} | ||
.数据来源0 { | ||
font-size: 0.8em; | ||
} | ||
</style> |
Oops, something went wrong.