We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 17fa37d commit df2bcecCopy full SHA for df2bcec
2 files changed
server/api/courses/doc.get.ts
@@ -45,5 +45,16 @@ export default defineEventHandler(async (event): Promise<CourseWithDbId> => {
45
deleted: { $ne: true },
46
});
47
if (!data) throw createError({ statusCode: 404, message: "没有这篇文档" });
48
+ if (data.user_only) {
49
+ try {
50
+ await requireUserSession(event);
51
+ } catch {
52
+ data.doc_str = `
53
+:::error
54
+仅限注册用户查看
55
+:::
56
+ `;
57
+ }
58
59
return data;
60
utils/types.ts
@@ -21,6 +21,7 @@ export interface CourseInfo {
21
class: string;
22
course_id: number;
23
teachers: string[];
24
+ user_only?: boolean;
25
}
26
27
export type CourseWithDbId = Course & {
0 commit comments