Files
XH-XunKe/frontend/src/views/admin/Admin.vue
T
xhgitandClaude Code ed55053b10 直播观看与录像链路真实验证通过,前端 UI 全面重做,分角色控制台
- 修复: 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>
2026-11-22 15:08:36 +08:00

260 lines
8.6 KiB
Vue

<template>
<div class="admin-layout">
<aside class="admin-side">
<router-link to="/" class="side-brand">
<LogoMark :size="28" />
<span>{{ site.nameZh }}</span>
</router-link>
<nav class="side-nav">
<div v-for="group in menuGroups" :key="group.label" class="menu-group">
<p class="group-label">{{ group.label }}</p>
<button
v-for="item in group.items"
:key="item.key"
type="button"
class="menu-item"
:class="{ active: current === item.key }"
:title="item.label"
@click="current = item.key"
>
<span class="menu-text">{{ item.label }}</span>
</button>
</div>
</nav>
</aside>
<div class="admin-body">
<header class="admin-top">
<div class="top-title">{{ currentLabel }}</div>
<div class="top-actions">
<button class="icon-btn" type="button" @click="toggleTheme">
<svg v-if="dark" viewBox="0 0 24 24" width="17" height="17" 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="17" height="17" 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>
<router-link to="/" class="home-link">返回首页</router-link>
<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>{{ roleLabel }}</el-dropdown-item>
<el-dropdown-item command="logout" divided>退出登录</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</header>
<main class="admin-main">
<component :is="currentComponent" />
</main>
</div>
</div>
</template>
<script setup lang="ts">
import { computed, defineAsyncComponent, ref } from "vue";
import { useRouter } from "vue-router";
import LogoMark from "../../components/LogoMark.vue";
import { useAuthStore } from "../../stores/auth";
import { useSiteStore } from "../../stores/site";
import { currentTheme, setThemeOverride } from "../../theme";
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(() => {
const roles = auth.roles;
if (roles.includes("SUPER_ADMIN")) return "超级管理员";
if (roles.includes("SCHOOL_ADMIN")) return "学校管理员";
if (roles.includes("INSPECTOR")) return "巡课人员";
return "管理员";
});
const menuGroups = [
{ label: "总览", items: [{ key: "overview", label: "数据概览" }] },
{
label: "组织与课程",
items: [
{ key: "schools", label: "学校管理" },
{ key: "grades", label: "年级管理" },
{ key: "classes", label: "班级管理" },
{ key: "courses", label: "课程管理" },
{ key: "timetable", label: "课表管理" }
]
},
{
label: "用户与审核",
items: [
{ key: "users", label: "用户管理" },
{ key: "bindings", label: "家长绑定审核" }
]
},
{
label: "直播与录像",
items: [
{ key: "live", label: "直播管理" },
{ key: "recordings", label: "课程录像" },
{ key: "inspections", label: "巡课记录" }
]
},
{
label: "消息通知",
items: [
{ key: "notify", label: "邮件与短信" },
{ key: "templates", label: "通知模板" }
]
},
{
label: "系统",
items: [
{ key: "storage", label: "存储管理" },
{ key: "logs", label: "操作日志" },
{ key: "settings", label: "系统设置" }
]
}
];
const sections: Record<string, ReturnType<typeof defineAsyncComponent>> = {
overview: defineAsyncComponent(() => import("./AdminOverview.vue")),
schools: defineAsyncComponent(() => import("./AdminSchools.vue")),
grades: defineAsyncComponent(() => import("./AdminGrades.vue")),
classes: defineAsyncComponent(() => import("./AdminClasses.vue")),
courses: defineAsyncComponent(() => import("./AdminCourses.vue")),
timetable: defineAsyncComponent(() => import("./AdminTimetable.vue")),
users: defineAsyncComponent(() => import("./AdminUsers.vue")),
bindings: defineAsyncComponent(() => import("./AdminBindings.vue")),
live: defineAsyncComponent(() => import("./AdminLive.vue")),
recordings: defineAsyncComponent(() => import("./AdminRecordings.vue")),
inspections: defineAsyncComponent(() => import("./AdminInspections.vue")),
notify: defineAsyncComponent(() => import("./AdminNotify.vue")),
templates: defineAsyncComponent(() => import("./AdminTemplates.vue")),
storage: defineAsyncComponent(() => import("./AdminStorage.vue")),
logs: defineAsyncComponent(() => import("./AdminLogs.vue")),
settings: defineAsyncComponent(() => import("./AdminSettings.vue"))
};
const current = ref("overview");
const currentComponent = computed(() => sections[current.value] ?? sections.overview);
const currentLabel = computed(() => {
for (const group of menuGroups) {
const found = group.items.find((item) => item.key === current.value);
if (found) return found.label;
}
return "管理后台";
});
function toggleTheme() {
setThemeOverride(dark.value ? "light" : "dark");
}
async function onCommand(command: string) {
if (command === "logout") {
await auth.logout().catch(() => undefined);
router.push("/login");
}
}
</script>
<style scoped>
.admin-layout { display: flex; min-height: 100vh; }
.admin-side {
width: 220px;
flex: none;
background: #101623;
color: #cfd6e4;
display: flex;
flex-direction: column;
position: sticky;
top: 0;
height: 100vh;
overflow-y: auto;
}
.side-brand {
display: flex;
align-items: center;
gap: 8px;
padding: 16px;
font-weight: 700;
font-size: 16px;
color: #fff;
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.side-nav { padding: 10px 8px 24px; }
.menu-group { margin-bottom: 14px; }
.group-label { margin: 6px 10px 4px; font-size: 11px; color: #5f6b82; letter-spacing: 1px; }
.menu-item {
display: block;
width: 100%;
text-align: left;
border: none;
background: transparent;
color: #aab3c5;
font-size: 14px;
padding: 9px 12px;
border-radius: 8px;
cursor: pointer;
margin-bottom: 2px;
}
.menu-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.menu-item.active { background: var(--xh-primary); color: #fff; font-weight: 600; }
.admin-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-top {
height: 54px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
background: var(--xh-header);
backdrop-filter: blur(12px);
border-bottom: 1px solid var(--xh-border);
position: sticky;
top: 0;
z-index: 50;
}
.top-title { font-size: 16px; font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.home-link { color: var(--xh-text-2); font-size: 13px; }
.home-link:hover { color: var(--xh-primary); }
.icon-btn {
width: 34px; height: 34px; 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;
}
.admin-main { flex: 1; padding: 20px; max-width: 1400px; width: 100%; margin: 0 auto; }
@media (max-width: 800px) {
.admin-side { width: 56px; }
.side-brand span, .group-label, .menu-text { display: none; }
.menu-item { text-align: center; padding: 10px 6px; }
.admin-main { padding: 12px; }
}
</style>