refactor: 使用更简洁的方式进行认证
This commit is contained in:
@@ -181,7 +181,7 @@
|
||||
import { ref, onMounted, computed } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
import { AuthManager } from "@/utils/AuthManager";
|
||||
import { type ExamInfo } from "@/APIClient";
|
||||
import { ExamClient, type ExamInfo } from "@/APIClient";
|
||||
import { formatDate } from "@/utils/Common";
|
||||
import ExamInfoModal from "./ExamInfoModal.vue";
|
||||
import ExamEditModal from "./ExamEditModal.vue";
|
||||
@@ -206,7 +206,7 @@ async function refreshExams() {
|
||||
error.value = "";
|
||||
|
||||
try {
|
||||
const client = AuthManager.createAuthenticatedExamClient();
|
||||
const client = AuthManager.createClient(ExamClient);
|
||||
exams.value = await client.getExamList();
|
||||
} catch (err: any) {
|
||||
error.value = err.message || "获取实验列表失败";
|
||||
@@ -218,7 +218,7 @@ async function refreshExams() {
|
||||
|
||||
async function viewExam(examId: string) {
|
||||
try {
|
||||
const client = AuthManager.createAuthenticatedExamClient();
|
||||
const client = AuthManager.createClient(ExamClient);
|
||||
selectedExam.value = await client.getExam(examId);
|
||||
showInfoModal.value = true;
|
||||
} catch (err: any) {
|
||||
@@ -248,7 +248,7 @@ onMounted(async () => {
|
||||
router.push("/login");
|
||||
}
|
||||
|
||||
isAdmin.value = await AuthManager.verifyAdminAuth();
|
||||
isAdmin.value = await AuthManager.isAdminAuthenticated();
|
||||
|
||||
await refreshExams();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user