feat: 重做灵动岛编辑器与课表档案时间表编辑
灵动岛 - 重构自定义方案编辑器:组件库常驻、拖拽添加与排序、方案切换/新建/复制/删除、编辑模式预览与缩放,容器在编辑时展开全部子组件。 - 新增天气简报组件:主进程固定请求 Open-Meteo,只接受数值经纬度,失败退避并保留本次运行缓存;冒烟模式不访问外网。 - 倒计时支持目标名称与日期;课程表组件新增「今日时间点」,按时间点类型折叠/展开,课中不再常驻倒计时。 - preload 暴露 getIslandWeather 与时间点订阅,契约同步 desktop.d.ts。 课表档案 - 时间点默认课程:布局返回 defaultCourse,日课表没有条目时回退;新增 apply-default 覆盖所有引用课表;全校时间表不携带默认课程。 - 新增 ClassIsland 式时间表编辑器(列表/时间轴视图、拖动把柄、按类型添加、默认时长与缩放)与「课表信息」表单。 - 课表页默认进入单表编辑,底部保留列表/周/月视图;时间表支持新路由删除。 - 「课间」统一改称「课间休息」。 验证 - pnpm typecheck、pnpm lint 通过。 - verify:e2e 隔离验收 248/248 项通过(含默认课程回退、覆盖写入与时间表删除)。 - ui-smoke 覆盖单表编辑、课表信息与时间轴视图,并更新回归截图。
This commit is contained in:
1 parent
938285bb9c
commit
682818dd4a
41 files changed
+4349
-1095
No files matched your search
@@ -0,0 +1,91 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onUnmounted, ref, watch } from 'vue';
|
||||
import type { IslandComponentNode, IslandWeather } from '@classhelper/shared';
|
||||
const props = defineProps<{ settings: IslandComponentNode['settings'] }>();
|
||||
const weather = ref<IslandWeather | null>(null),
|
||||
loading = ref(false),
|
||||
unavailable = ref(false);
|
||||
const configured = computed(
|
||||
() => typeof props.settings.latitude === 'number' && typeof props.settings.longitude === 'number',
|
||||
);
|
||||
let revision = 0;
|
||||
async function refresh() {
|
||||
const current = ++revision;
|
||||
if (!configured.value) {
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
const bridge = window.island ?? window.desktop;
|
||||
if (!bridge) throw new Error('仅桌面客户端可读取天气');
|
||||
const result = await bridge.getIslandWeather({
|
||||
latitude: props.settings.latitude!,
|
||||
longitude: props.settings.longitude!,
|
||||
});
|
||||
if (current === revision) {
|
||||
weather.value = result;
|
||||
unavailable.value = false;
|
||||
}
|
||||
} catch {
|
||||
if (current === revision) unavailable.value = true;
|
||||
} finally {
|
||||
if (current === revision) loading.value = false;
|
||||
}
|
||||
}
|
||||
watch(
|
||||
() => [props.settings.latitude, props.settings.longitude],
|
||||
() => {
|
||||
weather.value = null;
|
||||
unavailable.value = false;
|
||||
void refresh();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
const timer = setInterval(() => void refresh(), 60_000);
|
||||
onUnmounted(() => {
|
||||
clearInterval(timer);
|
||||
revision++;
|
||||
});
|
||||
const description = computed(() => {
|
||||
const code = weather.value?.code ?? -1;
|
||||
if (code === 0) return '晴';
|
||||
if (code <= 3 && code > 0) return ['少云', '多云', '阴'][code - 1];
|
||||
if ([45, 48].includes(code)) return '雾';
|
||||
if ([51, 53, 55, 56, 57].includes(code)) return '毛毛雨';
|
||||
if ([61, 63, 65, 66, 67, 80, 81, 82].includes(code)) return '雨';
|
||||
if ([71, 73, 75, 77, 85, 86].includes(code)) return '雪';
|
||||
if ([95, 96, 99].includes(code)) return '雷雨';
|
||||
return '天气';
|
||||
});
|
||||
const advice = computed(() => {
|
||||
if (!weather.value) return '';
|
||||
if (weather.value.code >= 95) return '雷雨天气,注意避雷';
|
||||
if (weather.value.windSpeed >= 40) return '风力较大,注意出行';
|
||||
return '';
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<span
|
||||
class="weather-brief"
|
||||
:title="weather ? `Open-Meteo · ${new Date(weather.fetchedAt).toLocaleString('zh-CN')}\n${advice}` : ''"
|
||||
>
|
||||
<template v-if="weather">
|
||||
{{ settings.locationName }} {{ description }} {{ Math.round(weather.temperature) }}°C
|
||||
<span v-if="weather.stale || unavailable">· 缓存</span>
|
||||
<small v-if="advice">{{ advice }}</small>
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ !configured ? '请设置天气地点' : loading ? '天气加载中…' : '天气暂不可用' }}
|
||||
</template>
|
||||
</span>
|
||||
</template>
|
||||
<style scoped>
|
||||
.weather-brief {
|
||||
white-space: nowrap;
|
||||
}
|
||||
small {
|
||||
display: block;
|
||||
font-size: var(--secondary, 12px);
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user