- 修复: LiveKit 回环候选生效(宿主机浏览器可直连推流) - 修复: 回放预签名 URL 403(公开端点直接签名,SignedHeaders=host) - 修复: 录像探针补 fileSize/durationSeconds - 修复: 家长录像列表被权限过滤误伤为 0 条;教师/家长列表按角色精确隔离 - 修复: 巡课静音失效(LiveKit attach 强制 unmute,静音时不挂载音轨) - 修复: 教室页自动请求摄像头/麦克风权限,分辨率失败自动降级 - 新增: 浏览器端到端验证脚本 scripts/e2e-browser.mjs(9 项断言全过: 教师推流/家长观看含音频电平实测/巡课默认静音/Egress 录像双轨齐全/ DPlayer 回放/录像权限隔离) - 新增: /parent/today 家长今日课程表、网站 Logo 上传与公开读取 - UI 重做: 虎牙风直播播放器 + DPlayer 回放播放器(视觉统一) - 分角色控制台: 管理端 /admin(16 模块)、教师端 /teacher、家长端 /parent - 直播/录像列表返回班级、课程、教师名称与在线人数 - 18088 本地预览改为 Vite 热更新,README/实现状态文档同步更新 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Code <noreply@anthropic.com>
179 lines
7.1 KiB
Vue
179 lines
7.1 KiB
Vue
<template>
|
|
<div class="shell">
|
|
<header class="topbar">
|
|
<div class="topbar-inner">
|
|
<router-link :to="home" class="brand">
|
|
<LogoMark :size="30" />
|
|
<span>{{ site.nameZh }}</span>
|
|
</router-link>
|
|
<nav class="nav">
|
|
<router-link v-if="auth.isStaff" to="/admin" class="nav-link">管理</router-link>
|
|
<router-link v-if="auth.isStaff" to="/inspect" class="nav-link">巡课</router-link>
|
|
<router-link v-if="canTeacher" to="/teacher" class="nav-link">教室</router-link>
|
|
<router-link v-if="!auth.isStaff" to="/parent" class="nav-link">首页</router-link>
|
|
<router-link v-if="!auth.isStaff" to="/parent/replays" class="nav-link">回放</router-link>
|
|
</nav>
|
|
<div class="actions">
|
|
<button class="icon-btn" type="button" @click="toggleTheme" :title="dark ? '切换到浅色' : '切换到深色'">
|
|
<svg v-if="dark" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
<circle cx="12" cy="12" r="4.2" />
|
|
<path d="M12 2.5v2.4M12 19.1v2.4M2.5 12h2.4M19.1 12h2.4M5 5l1.7 1.7M17.3 17.3L19 19M19 5l-1.7 1.7M6.7 17.3L5 19" />
|
|
</svg>
|
|
<svg v-else viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
<path d="M20.4 14.2A8.4 8.4 0 0 1 9.8 3.6a8.4 8.4 0 1 0 10.6 10.6Z" />
|
|
</svg>
|
|
</button>
|
|
<template v-if="auth.user">
|
|
<el-dropdown trigger="click" @command="onCommand">
|
|
<button class="user-chip" type="button">
|
|
<span class="avatar">{{ initial }}</span>
|
|
<span class="name">{{ auth.user.displayName }}</span>
|
|
</button>
|
|
<template #dropdown>
|
|
<el-dropdown-menu>
|
|
<el-dropdown-item disabled>{{ auth.user.displayName }} · {{ roleLabel }}</el-dropdown-item>
|
|
<el-dropdown-item command="password" divided>修改密码</el-dropdown-item>
|
|
<el-dropdown-item command="logout">退出登录</el-dropdown-item>
|
|
</el-dropdown-menu>
|
|
</template>
|
|
</el-dropdown>
|
|
</template>
|
|
<el-button v-else type="primary" @click="$router.push('/login')">登录</el-button>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
<main class="shell-main">
|
|
<router-view />
|
|
</main>
|
|
<footer v-if="site.footer" class="shell-footer">{{ site.footer }}</footer>
|
|
|
|
<el-dialog v-model="passwordVisible" title="修改密码" width="420px">
|
|
<el-form label-width="80px" @submit.prevent="changePassword">
|
|
<el-form-item label="当前密码">
|
|
<el-input v-model="password.oldPassword" type="password" show-password autocomplete="current-password" />
|
|
</el-form-item>
|
|
<el-form-item label="新密码">
|
|
<el-input v-model="password.newPassword" type="password" show-password :placeholder="`至少 ${site.passwordMin ?? 8} 位`" />
|
|
</el-form-item>
|
|
<el-form-item label="确认新密码">
|
|
<el-input v-model="password.confirm" type="password" show-password />
|
|
</el-form-item>
|
|
<p v-if="passwordError" class="form-error">{{ passwordError }}</p>
|
|
<el-button class="touch" type="primary" native-type="submit" :loading="passwordLoading" style="width: 100%">保存密码</el-button>
|
|
</el-form>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed, reactive, ref } from "vue";
|
|
import { useRouter } from "vue-router";
|
|
import { ElMessage } from "element-plus";
|
|
import { http } from "../api/http";
|
|
import { useAuthStore } from "../stores/auth";
|
|
import { useSiteStore } from "../stores/site";
|
|
import { currentTheme, setThemeOverride } from "../theme";
|
|
import { canUseTeacher, homeFor } from "../utils/roles";
|
|
import LogoMark from "./LogoMark.vue";
|
|
|
|
const auth = useAuthStore();
|
|
const site = useSiteStore();
|
|
const router = useRouter();
|
|
const dark = computed(() => currentTheme() === "dark");
|
|
const initial = computed(() => (auth.user?.displayName ?? "?").slice(0, 1));
|
|
const roleLabel = computed(() => ROLE_LABELS[auth.user?.roles?.[0] ?? ""] ?? "用户");
|
|
const canTeacher = computed(() => canUseTeacher(auth.roles));
|
|
const home = computed(() => homeFor(auth.roles));
|
|
|
|
const passwordVisible = ref(false);
|
|
const passwordLoading = ref(false);
|
|
const passwordError = ref("");
|
|
const password = reactive({ oldPassword: "", newPassword: "", confirm: "" });
|
|
|
|
const ROLE_LABELS: Record<string, string> = {
|
|
SUPER_ADMIN: "超级管理员",
|
|
SCHOOL_ADMIN: "学校管理员",
|
|
TEACHER: "教师",
|
|
INSPECTOR: "巡课人员",
|
|
PARENT: "家长"
|
|
};
|
|
|
|
function toggleTheme() {
|
|
setThemeOverride(dark.value ? "light" : "dark");
|
|
}
|
|
|
|
function onCommand(command: string) {
|
|
if (command === "logout") logout();
|
|
if (command === "password") {
|
|
password.oldPassword = "";
|
|
password.newPassword = "";
|
|
password.confirm = "";
|
|
passwordError.value = "";
|
|
passwordVisible.value = true;
|
|
}
|
|
}
|
|
|
|
async function logout() {
|
|
await auth.logout().catch(() => undefined);
|
|
router.push("/login");
|
|
}
|
|
|
|
async function changePassword() {
|
|
passwordError.value = "";
|
|
if (!password.oldPassword || !password.newPassword) {
|
|
passwordError.value = "请填写完整";
|
|
return;
|
|
}
|
|
if (password.newPassword !== password.confirm) {
|
|
passwordError.value = "两次输入的新密码不一致";
|
|
return;
|
|
}
|
|
passwordLoading.value = true;
|
|
try {
|
|
await http.put("/auth/password", { oldPassword: password.oldPassword, newPassword: password.newPassword });
|
|
passwordVisible.value = false;
|
|
ElMessage.success("密码已更新,请重新登录");
|
|
setTimeout(() => logout(), 1200);
|
|
} catch (err: unknown) {
|
|
passwordError.value = (err as { response?: { data?: { message?: string } } }).response?.data?.message ?? "修改失败";
|
|
} finally {
|
|
passwordLoading.value = false;
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.shell { min-height: 100vh; display: flex; flex-direction: column; }
|
|
.shell-main { flex: 1; }
|
|
.shell-footer { padding: 18px; text-align: center; color: var(--xh-text-3); font-size: 12px; }
|
|
.actions { display: flex; align-items: center; gap: 8px; }
|
|
.icon-btn {
|
|
width: 36px; height: 36px; border-radius: 50%;
|
|
border: 1px solid var(--xh-border);
|
|
background: var(--xh-card);
|
|
color: var(--xh-text-2);
|
|
cursor: pointer;
|
|
display: flex; align-items: center; justify-content: center;
|
|
}
|
|
.icon-btn:hover { color: var(--xh-primary); }
|
|
.user-chip {
|
|
display: flex; align-items: center; gap: 8px;
|
|
border: 1px solid var(--xh-border);
|
|
background: var(--xh-card);
|
|
color: var(--xh-text);
|
|
border-radius: 999px;
|
|
padding: 4px 12px 4px 4px;
|
|
cursor: pointer;
|
|
}
|
|
.user-chip .avatar {
|
|
width: 26px; height: 26px; border-radius: 50%;
|
|
background: var(--xh-primary);
|
|
color: #fff;
|
|
display: flex; align-items: center; justify-content: center;
|
|
font-size: 13px;
|
|
}
|
|
.user-chip .name { font-size: 14px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
.nav { overflow-x: auto; }
|
|
.form-error { color: var(--xh-live); font-size: 13px; margin: 0 0 12px; }
|
|
</style>
|