Skip to content

Commit b2a7b07

Browse files
author
lucifer
committed
feat: 上先导篇
1 parent 50aa652 commit b2a7b07

File tree

4 files changed

+52
-14
lines changed

4 files changed

+52
-14
lines changed

routes/lectures.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,36 @@ router.get("/api/v1/lectures/basic", async (ctx) => {
2222
};
2323
});
2424

25-
router.get("/api/v1/lectures/basic/:id", async (ctx) => {
25+
router.get("/api/v1/lectures/intro", async (ctx) => {
26+
ctx.body = {
27+
success: true,
28+
code: 0,
29+
data: [
30+
{
31+
title: "01. 数据结构与算法概述",
32+
desc: "主要介绍了数据结构与算法是在研究什么",
33+
image: {
34+
url:
35+
"https://cdn.jsdelivr.net/gh/azl397985856/cdn/2020-10-22/1603338453129-image.png",
36+
alt: "数据结构总览",
37+
},
38+
id: -1,
39+
},
40+
{
41+
title: "02. 如何衡量算法的性能",
42+
desc: "介绍复杂度",
43+
image: {
44+
url:
45+
"https://cdn.jsdelivr.net/gh/azl397985856/cdn/2020-10-22/1603339778900-image.png",
46+
alt: "复杂度",
47+
},
48+
id: -2,
49+
},
50+
],
51+
};
52+
});
53+
54+
router.get("/api/v1/lectures/:id", async (ctx) => {
2655
const id = ctx.params.id;
2756
const lecture = lectures[id];
2857
if (!lecture) {

static/lectures/basic.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

static/lectures/generate.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const fs = require("fs");
2+
3+
const { encrypt } = require("../../utils/crypto.js");
4+
const lectures = {};
5+
6+
lectures["-1"] = {
7+
id: "-1",
8+
content: encrypt(Buffer.from(fs.readFileSync("./-1.intro-01.md"), "utf8")),
9+
};
10+
11+
lectures["-2"] = {
12+
id: "-2",
13+
content: encrypt(Buffer.from(fs.readFileSync("./-2.intro-02.md"), "utf8")),
14+
};
15+
16+
lectures["1"] = {
17+
id: "1",
18+
content: encrypt(Buffer.from(fs.readFileSync("./1.basic-01.md"), "utf8")),
19+
};
20+
21+
fs.writeFileSync("./lectures.json", JSON.stringify(lectures));

0 commit comments

Comments
 (0)