智能开屏:显示“姓名+早上/中午/下午/晚上问候”,支持春节、端午、中秋、国庆等节日文案,可点击跳过:[SmartLaunchScreen.vue](E:/jiaowu/web/src/components/SmartLaunchScreen.vue)

长按 App 图标:提供“我的课表、考试安排、课堂签到、消息中心”四个入口。签到会按学生/教师角色自动分流:[shortcuts.xml](E:/jiaowu/web/native/android/app/src/main/res/xml/shortcuts.xml)
桌面小组件:新增“今日课表”和“近期考试”,展示最近同步的数据,点击可进入对应页面:[WidgetRenderer.java](E:/jiaowu/web/native/android/app/src/main/java/edu/mingxu/jiaowu/WidgetRenderer.java)
安全处理:组件只缓存课程和考试摘要,不保存登录令牌;退出账号会清空组件,隔天未刷新时不会继续展示旧的“今日课表”。
原生模板已纳入版本管理,每次 npm run cap:sync 会自动恢复到被忽略的 Android 工程:[configure-capacitor.mjs](E:/jiaowu/web/scripts/configure-capacitor.mjs)
This commit is contained in:
2026-07-29 11:11:37 +08:00 Unverified
parent 93997ea8b1
commit 66622ca207
27 changed files with 1304 additions and 5 deletions
+74
View File
@@ -0,0 +1,74 @@
export interface SmartGreeting {
title: string
subtitle: string
label: string
}
const dailySubtitles = [
'愿今天的课程与计划都清晰顺利。',
'新的一天,从有序安排开始。',
'把每一次学习,都变成看得见的进步。',
]
function lunarFestival(date: Date) {
try {
const parts = new Intl.DateTimeFormat('zh-CN-u-ca-chinese', {
month: 'long',
day: 'numeric',
}).formatToParts(date)
const month = parts.find((part) => part.type === 'month')?.value ?? ''
const day = parts.find((part) => part.type === 'day')?.value ?? ''
if (month === '正月' && ['1', '2', '3'].includes(day)) return '春节快乐'
if (month === '正月' && day === '15') return '元宵节快乐'
if (month === '五月' && day === '5') return '端午安康'
if (month === '八月' && day === '15') return '中秋快乐'
} catch {
// 少数精简 WebView 不支持中国农历日历,继续使用公历与时段问候。
}
return ''
}
function festivalGreeting(date: Date) {
const month = date.getMonth() + 1
const day = date.getDate()
const lunar = lunarFestival(date)
if (lunar) return lunar
if (month === 1 && day === 1) return '新年快乐'
if (month === 5 && day >= 1 && day <= 5) return '劳动节愉快'
if (month === 9 && day === 10) return '教师节快乐'
if (month === 10 && day >= 1 && day <= 7) return '国庆节快乐'
return ''
}
function timeGreeting(date: Date) {
const hour = date.getHours()
if (hour < 5) return '夜深了'
if (hour < 11) return '早上好'
if (hour < 14) return '中午好'
if (hour < 18) return '下午好'
return '晚上好'
}
export function getSmartGreeting(
date = new Date(),
displayName?: string | null,
): SmartGreeting {
const greeting = festivalGreeting(date) || timeGreeting(date)
const name = displayName?.trim()
const weekday = new Intl.DateTimeFormat('zh-CN', { weekday: 'long' }).format(date)
const label = new Intl.DateTimeFormat('zh-CN', {
month: 'long',
day: 'numeric',
}).format(date)
const index = Math.abs(date.getFullYear() * 372 + date.getMonth() * 31 + date.getDate())
% dailySubtitles.length
return {
title: name ? `${name}${greeting}` : `${greeting},欢迎使用明序教务`,
subtitle: date.getDay() === 0 || date.getDay() === 6
? '周末也要记得放松一下,查看安排后从容出发。'
: dailySubtitles[index],
label: `${label} · ${weekday}`,
}
}