|
|
|
@ -5,7 +5,9 @@
|
|
|
|
<script setup>
|
|
|
|
<script setup>
|
|
|
|
import { exchangeStudentDemoSession } from "@/api/studentDemo";
|
|
|
|
import { exchangeStudentDemoSession } from "@/api/studentDemo";
|
|
|
|
import { saveStudentDemoSession } from "@/utils/studentDemo";
|
|
|
|
import { saveStudentDemoSession } from "@/utils/studentDemo";
|
|
|
|
|
|
|
|
import useUserStore from "@/store/modules/user";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
const message = ref("正在连接教师演示会话…");
|
|
|
|
const message = ref("正在连接教师演示会话…");
|
|
|
|
let readyTimer;
|
|
|
|
let readyTimer;
|
|
|
|
|
|
|
|
|
|
|
|
@ -17,9 +19,12 @@ function receiveTicket(event) {
|
|
|
|
if (event.origin !== window.location.origin || event.source !== window.opener || event.data?.type !== "STUDENT_DEMO_TICKET") return;
|
|
|
|
if (event.origin !== window.location.origin || event.source !== window.opener || event.data?.type !== "STUDENT_DEMO_TICKET") return;
|
|
|
|
exchangeStudentDemoSession(event.data.ticket).then((res) => {
|
|
|
|
exchangeStudentDemoSession(event.data.ticket).then((res) => {
|
|
|
|
saveStudentDemoSession(res.data);
|
|
|
|
saveStudentDemoSession(res.data);
|
|
|
|
|
|
|
|
userStore.token = res.data.token;
|
|
|
|
|
|
|
|
userStore.userInfo = res.data;
|
|
|
|
window.clearInterval(readyTimer);
|
|
|
|
window.clearInterval(readyTimer);
|
|
|
|
window.removeEventListener("message", receiveTicket);
|
|
|
|
window.removeEventListener("message", receiveTicket);
|
|
|
|
window.location.replace("/#/index");
|
|
|
|
window.location.hash = "#/index";
|
|
|
|
|
|
|
|
window.location.reload();
|
|
|
|
}).catch(() => { message.value = "演示链接已失效,请返回教师端重新打开。"; });
|
|
|
|
}).catch(() => { message.value = "演示链接已失效,请返回教师端重新打开。"; });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|