智能开屏:显示“姓名+早上/中午/下午/晚上问候”,支持春节、端午、中秋、国庆等节日文案,可点击跳过:[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
+31 -5
View File
@@ -1,4 +1,11 @@
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
import {
copyFileSync,
existsSync,
mkdirSync,
readFileSync,
readdirSync,
writeFileSync,
} from 'node:fs'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
@@ -12,17 +19,36 @@ function updateFile(path, update) {
return true
}
function copyTemplateTree(source, destination) {
if (!existsSync(source)) {
throw new Error(`缺少原生模板目录:${source}`)
}
mkdirSync(destination, { recursive: true })
for (const entry of readdirSync(source, { withFileTypes: true })) {
const sourcePath = resolve(source, entry.name)
const destinationPath = resolve(destination, entry.name)
if (entry.isDirectory()) copyTemplateTree(sourcePath, destinationPath)
else copyFileSync(sourcePath, destinationPath)
}
}
function configureAndroid() {
const androidRoot = resolve(webRoot, 'android')
const variablesPath = resolve(webRoot, 'android', 'variables.gradle')
const templateRoot = resolve(webRoot, 'native', 'android')
const manifestPath = resolve(
webRoot,
'android',
androidRoot,
'app',
'src',
'main',
'AndroidManifest.xml',
)
if (!existsSync(variablesPath) || !existsSync(manifestPath)) return false
if (!existsSync(variablesPath)) return false
copyTemplateTree(templateRoot, androidRoot)
if (!existsSync(manifestPath)) {
throw new Error('Android 原生模板未生成 AndroidManifest.xml。')
}
updateFile(variablesPath, content => {
if (!/minSdkVersion\s*=\s*\d+/.test(content)) {
@@ -78,4 +104,4 @@ if (!configuredPlatforms.length) {
throw new Error('尚未生成 Capacitor 原生工程,请先运行 npx cap add android 或 ios。')
}
console.log(`已配置 ${configuredPlatforms.join('、')} 的扫码定位权限`)
console.log(`已配置 ${configuredPlatforms.join('、')} 的扫码定位和原生桌面体验`)