- 服务端新增 database 模块(/api/database/*,仅 ADMIN):全库 JSON 快照(备份 / 恢复 / 导入导出 / 定时备份
共用同一格式,14 张表按拓扑序导出、恢复时关外键检查)、连接测试与目标库校验、一键 SQLite ⇄ MySQL 切换
(备份 → 导出 → 测试连接 → 校验空库 → 改 schema → 子进程 generate / tsc / db push → 写数据,全部成功才改写
.env,中途失败回滚 schema);XML 快照与 SQLite 数据文件均可下载;打包形态随包带上 prisma CLI 与 typescript
(prisma-client 生成物是 .ts,需再编进 dist/generated,安装包因之变大)
- Web 管理端新增「数据库管理」页(仅管理员),并加首次登录新手引导(el-tour,可跳过、可随时重看,版本号写
localStorage,改版后老用户会再收到一次)
- 客户端设置改版:侧边栏改为分组折叠菜单,设置拆成 6 个子路由
(/settings/{general,appearance,island,reminder,account,about}),新增深色模式(主题持久化到主进程配置,
主窗口底色跟主题走,避免"先白后黑"闪一下),新增「关于」页(应用信息 / 诊断信息)
- 客户端新增首启六步引导(OnboardingWelcome,状态存主进程配置 onboardingDone)
- 客户端主窗口初始尺寸与 ClassIsland 对齐(1242x582 / minHeight 540 / 居中)
- 版本号统一提升到 1.0.0:5 个 package.json、部署配置与镜像标签(.env.example / docker-compose / Dockerfile)、
服务端 /health 与首页、插件 manifest.yml 与 BridgeService.PluginVersion、文档里的安装包名
- 文档与验收同步:AGENTS.md 补第 37~51 条约定(深色主题实现边界、设置子路由、数据库管理三件事、侧栏与窗口
尺寸、引导在自动化里的判据等),README 补「数据库管理 / 新手引导 / 设置改版」三节;verify:e2e 增补 13 条
数据库管理用例,客户端冒烟与 Web UI 冒烟跟进子路由、深色主题、侧栏与引导
验证:pnpm lint 0 error;pnpm typecheck 全过;verify:e2e 186/186;verify:classisland-plugin 68/68;
build:desktop 通过(含产物凭据门禁);verify:desktop 99/102(3 项为上课时段下的"真实通知链路"用例,
客户端按产品规则暂存普通通知所致,见下);插件 dotnet 编译 0 错误。
注:verify:desktop 的「真实通知链路 / 标记已读」三项要求当前不在上课时段——本次运行时种子课表恰有
「周五 10:55-11:40 生物」正在进行,客户端正确地暂存了普通通知(AGENTS.md 第 18 条),属时间相关用例,
与本次改动无关。
120 lines
3.8 KiB
Vue
120 lines
3.8 KiB
Vue
<script setup lang="ts">
|
||
import { onMounted, onUnmounted, ref } from 'vue';
|
||
import { useRouter } from 'vue-router';
|
||
import {
|
||
startIslandBridge,
|
||
stopIslandBridge,
|
||
subscribeIslandMarkAllRead,
|
||
subscribeIslandMarkRead,
|
||
} from './island/bridge.js';
|
||
import OnboardingWelcome from './components/OnboardingWelcome.vue';
|
||
import { useAppStore } from './stores/app.js';
|
||
import { useAuthStore } from './stores/auth.js';
|
||
import { useOnboardingStore } from './stores/onboarding.js';
|
||
import { useRealtimeStore } from './stores/realtime.js';
|
||
import { useUiStore } from './stores/ui.js';
|
||
|
||
const router = useRouter();
|
||
const appStore = useAppStore();
|
||
const auth = useAuthStore();
|
||
const onboarding = useOnboardingStore();
|
||
const ui = useUiStore();
|
||
const realtime = useRealtimeStore();
|
||
|
||
const booting = ref(true);
|
||
const bootText = ref('正在读取本地配置...');
|
||
|
||
/**
|
||
* 启动流程:
|
||
* 1) 从主进程配置恢复服务器地址与登录令牌
|
||
* 2) 先用缓存资料渲染,再尝试向服务器刷新(不可达则进入离线会话)
|
||
* 3) 已登录则建立 Socket.IO 连接并进入主界面
|
||
*/
|
||
onMounted(async () => {
|
||
try {
|
||
bootText.value = '正在读取本地配置...';
|
||
// 主题与侧栏折叠最先恢复:在首屏渲染前挂好 html.dark,避免"先白后黑"闪一下
|
||
await ui.init();
|
||
|
||
bootText.value = '正在恢复登录状态...';
|
||
const session = await auth.restore();
|
||
|
||
// 通知显示位置:先用本地配置兜底(断网也要按上次的选择决定本机弹不弹),
|
||
// 登录态就绪后再向服务器对齐一次(服务端才是单一事实来源)
|
||
const storedConfig = await window.desktop?.getConfig?.();
|
||
if (storedConfig?.notificationChannel) {
|
||
appStore.applyLocalNotificationChannel(storedConfig.notificationChannel);
|
||
}
|
||
void appStore.loadNotificationChannel(auth.classId);
|
||
|
||
// 连通性探测与健康轮询放到后台,不阻塞进入界面(离线时也能立刻看到缓存数据)
|
||
void appStore.init(session.serverUrl);
|
||
|
||
if (auth.token) realtime.connect(appStore.serverUrl, auth.token);
|
||
|
||
// 灵动岛:开始按课表计算上课状态(上课隐藏、下课自动弹出)
|
||
if (auth.token) startIslandBridge();
|
||
|
||
// 灵动岛"标为已读" → 同步通知中心(未读红点);多条通知时是整批已读
|
||
subscribeIslandMarkRead();
|
||
subscribeIslandMarkAllRead();
|
||
|
||
if (auth.isAuthenticated) await router.replace('/schedule');
|
||
else await router.replace('/login');
|
||
|
||
// 初次启动引导:配置里没记「已看过」就自动弹一次(完成/跳过后由引导组件写入配置)。
|
||
// 稍等一拍再弹:让登录页/主界面先渲染完,避免和启动过渡的收尾抢帧。
|
||
window.setTimeout(() => {
|
||
void window.desktop
|
||
?.getConfig()
|
||
.then((config) => {
|
||
if (config.onboardingDone !== true) onboarding.open();
|
||
})
|
||
.catch(() => undefined);
|
||
}, 400);
|
||
} finally {
|
||
booting.value = false;
|
||
}
|
||
});
|
||
|
||
onUnmounted(() => {
|
||
stopIslandBridge();
|
||
});
|
||
</script>
|
||
|
||
<template>
|
||
<div v-if="booting" class="boot-screen">
|
||
<el-icon :size="30" class="is-loading" color="#409eff"><Loading /></el-icon>
|
||
<p class="boot-title">班级小助手</p>
|
||
<p class="boot-text">{{ bootText }}</p>
|
||
</div>
|
||
<router-view v-else />
|
||
<!-- 初次启动引导:常驻挂载,由 onboarding store 控制显隐(登录页/主界面/设置页都能唤起) -->
|
||
<OnboardingWelcome v-if="!booting" />
|
||
</template>
|
||
|
||
<style scoped>
|
||
.boot-screen {
|
||
height: 100vh;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 10px;
|
||
background: linear-gradient(135deg, #1f2d3d 0%, #3a5169 60%, #409eff 100%);
|
||
color: #fff;
|
||
}
|
||
|
||
.boot-title {
|
||
margin: 6px 0 0;
|
||
font-size: 20px;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.boot-text {
|
||
margin: 0;
|
||
font-size: 13px;
|
||
color: rgba(255, 255, 255, 0.75);
|
||
}
|
||
</style>
|