|
|
@@ -4,7 +4,7 @@
|
|
|
<view class="status-space"></view>
|
|
|
<view class="hero-top">
|
|
|
<view>
|
|
|
- <text class="greeting">下午好,{{ currentUser.name }}</text>
|
|
|
+ <text class="greeting">{{ greetingText }}{{ currentUser.name }}</text>
|
|
|
<text class="date">{{ todayText }}</text>
|
|
|
</view>
|
|
|
<view class="message press" @click="go('/pages/notice/index')">
|
|
|
@@ -149,6 +149,18 @@ const todayText = computed(() => {
|
|
|
return `${d.getFullYear()}年${d.getMonth() + 1}月${d.getDate()}日 · 星期${weeks[d.getDay()]}`;
|
|
|
});
|
|
|
|
|
|
+// 当前时间,作为问候语与日期的依赖源;onShow 时刷新,避免长开页面后时段过期
|
|
|
+const now = ref(new Date());
|
|
|
+
|
|
|
+const greetingText = computed(() => {
|
|
|
+ const h = now.value.getHours();
|
|
|
+ if (h < 5) return "凌晨好,";
|
|
|
+ if (h < 11) return "上午好,";
|
|
|
+ if (h < 13) return "中午好,";
|
|
|
+ if (h < 18) return "下午好,";
|
|
|
+ return "晚上好,";
|
|
|
+});
|
|
|
+
|
|
|
const shiftText = computed(() => {
|
|
|
// 未配置 / 不可打卡:给明确提示而不是显示 08:30
|
|
|
if (ruleStatus.value === 'empty') return "未配置考勤规则";
|
|
|
@@ -219,6 +231,8 @@ async function loadDaily() {
|
|
|
}
|
|
|
|
|
|
onShow(() => {
|
|
|
+ // 进入页面时刷新"当前时间",确保问候语与日期反映最新时段
|
|
|
+ now.value = new Date();
|
|
|
loadPending();
|
|
|
loadDaily();
|
|
|
});
|