把 XH巡课 的当前可运行版本放进仓库,方便后续继续改并同步。
This commit is contained in:
commit
6e5107f1b6
134 files changed
+11284
No files matched your search
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<header class="card">
|
||||
<h1>{{ site.nameZh }}</h1>
|
||||
<p>{{ site.intro }}</p>
|
||||
<p v-if="site.announcement">{{ site.announcement }}</p>
|
||||
<nav>
|
||||
<router-link v-if="!auth.user" to="/login">登录</router-link>
|
||||
<template v-else>
|
||||
<span>{{ auth.user.displayName }}</span>
|
||||
<router-link to="/studio">教室</router-link>
|
||||
<router-link to="/inspect">巡课</router-link>
|
||||
<router-link to="/replays">回放</router-link>
|
||||
<router-link to="/admin">管理</router-link>
|
||||
<el-button link @click="auth.logout()">退出</el-button>
|
||||
</template>
|
||||
</nav>
|
||||
</header>
|
||||
<section class="card" style="margin-top: 16px" v-if="auth.user">
|
||||
<h2>我的绑定与直播</h2>
|
||||
<p v-if="loading">加载中</p>
|
||||
<p v-else-if="error">{{ error }}</p>
|
||||
<p v-else-if="bindings.length === 0 && lives.length === 0">暂无绑定或直播</p>
|
||||
<ul>
|
||||
<li v-for="item in bindings" :key="item.id">
|
||||
班级 {{ item.classId }} · {{ item.status }} · 直播 {{ item.liveGranted ? "已授权" : "未授权" }} · 回放 {{ item.replayGranted ? "已授权" : "未授权" }}
|
||||
</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li v-for="item in lives" :key="item.id">
|
||||
<router-link :to="`/watch/${item.id}`">{{ item.roomName }} · {{ item.status }}</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
<el-form v-if="auth.isParent" @submit.prevent="bind">
|
||||
<el-input v-model.number="form.classId" placeholder="班级 ID" />
|
||||
<el-input v-model="form.studentNo" placeholder="学号" />
|
||||
<el-input v-model="form.studentName" placeholder="学生姓名" />
|
||||
<el-input v-model="form.relationship" placeholder="关系,例如父亲" />
|
||||
<el-checkbox v-model="form.requestLive">申请直播</el-checkbox>
|
||||
<el-checkbox v-model="form.requestReplay">申请回放</el-checkbox>
|
||||
<el-button native-type="submit" type="primary">提交绑定</el-button>
|
||||
</el-form>
|
||||
</section>
|
||||
<p>{{ site.footer }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
import { http } from "../api/http";
|
||||
import { useAuthStore } from "../stores/auth";
|
||||
import { useSiteStore } from "../stores/site";
|
||||
|
||||
const site = useSiteStore();
|
||||
const auth = useAuthStore();
|
||||
const bindings = ref<Array<{ id: number; classId: number; status: string; liveGranted: boolean; replayGranted: boolean }>>([]);
|
||||
const lives = ref<Array<{ id: number; roomName: string; status: string }>>([]);
|
||||
const loading = ref(false);
|
||||
const error = ref("");
|
||||
const form = reactive({ classId: undefined as number | undefined, studentNo: "", studentName: "", relationship: "家长", requestLive: true, requestReplay: true });
|
||||
|
||||
async function load() {
|
||||
if (!auth.user) return;
|
||||
loading.value = true;
|
||||
try {
|
||||
const { data } = await http.get("/parent/home");
|
||||
bindings.value = data.data.bindings ?? [];
|
||||
lives.value = data.data.lives ?? [];
|
||||
} catch (err: unknown) {
|
||||
error.value = (err as { response?: { data?: { message?: string } } }).response?.data?.message ?? "暂时无法加载";
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function bind() {
|
||||
await http.post("/bindings", form);
|
||||
await load();
|
||||
}
|
||||
|
||||
onMounted(load);
|
||||
</script>
|
||||
Reference in new issue
Block a user