master
parent
cea025ecdd
commit
14c947c1f9
174
mock-config.json
174
mock-config.json
|
|
@ -760,10 +760,11 @@
|
||||||
{
|
{
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"path": "/api/lesson/list",
|
"path": "/api/lesson/list",
|
||||||
|
"query": {"type": "1"},
|
||||||
"response": {
|
"response": {
|
||||||
"category": "推荐",
|
"category": "推荐",
|
||||||
"total": 4,
|
"total": 4,
|
||||||
"items": [
|
"data": [
|
||||||
{
|
{
|
||||||
"id": "lesson001",
|
"id": "lesson001",
|
||||||
"title": "隶属的古法用笔技巧",
|
"title": "隶属的古法用笔技巧",
|
||||||
|
|
@ -798,41 +799,154 @@
|
||||||
"learnCount": 6525
|
"learnCount": 6525
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"method": "GET",
|
||||||
|
"path": "/api/lesson/list",
|
||||||
|
"query": {"type": "2"},
|
||||||
|
"response": {
|
||||||
|
"category": "手机电脑",
|
||||||
|
"total": 5,
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": "lesson001",
|
||||||
|
"title": "4个设置让手机更顺手",
|
||||||
|
"image": "https://res.klyj.jinzejk.com/lesson/phone1.png",
|
||||||
|
"price": 0.0,
|
||||||
|
"chapterCount": 7,
|
||||||
|
"learnCount": 6525,
|
||||||
|
"label": "免费"
|
||||||
},
|
},
|
||||||
"swagger": {
|
{
|
||||||
"summary": "获取课程学习列表",
|
"id": "lesson002",
|
||||||
"description": "返回推荐课程列表数据(包含课程封面、价格、节数、学习人数等)",
|
"title": "手机桌面之老年机篇",
|
||||||
"responses": {
|
"image": "https://res.klyj.jinzejk.com/lesson/phone2.png",
|
||||||
"200": {
|
"price": 9.9,
|
||||||
"description": "课程数据",
|
"chapterCount": 3,
|
||||||
"content": {
|
"learnCount": 6525
|
||||||
"application/json": {
|
},
|
||||||
"schema": {
|
{
|
||||||
"type": "object",
|
"id": "lesson003",
|
||||||
"properties": {
|
"title": "如何学习使用微信",
|
||||||
"category": { "type": "string" },
|
"image": "https://res.klyj.jinzejk.com/lesson/phone3.png",
|
||||||
"total": { "type": "integer" },
|
"price": 9.9,
|
||||||
"items": {
|
"chapterCount": 3,
|
||||||
"type": "array",
|
"learnCount": 6525
|
||||||
"items": {
|
},
|
||||||
"type": "object",
|
{
|
||||||
"properties": {
|
"id": "lesson004",
|
||||||
"id": { "type": "string" },
|
"title": "用上iPad老年机更大",
|
||||||
"title": { "type": "string" },
|
"image": "https://res.klyj.jinzejk.com/lesson/phone4.png",
|
||||||
"image": { "type": "string" },
|
"price": 9.9,
|
||||||
"price": { "type": "number" },
|
"chapterCount": 3,
|
||||||
"chapterCount": { "type": "integer" },
|
"learnCount": 6525
|
||||||
"learnCount": { "type": "integer" },
|
},
|
||||||
"label": { "type": "string" }
|
{
|
||||||
}
|
"id": "lesson005",
|
||||||
}
|
"title": "手机桌面之老年机篇",
|
||||||
}
|
"image": "https://res.klyj.jinzejk.com/lesson/phone5.png",
|
||||||
}
|
"price": 9.9,
|
||||||
|
"chapterCount": 3,
|
||||||
|
"learnCount": 6525
|
||||||
}
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"method": "GET",
|
||||||
|
"path": "/api/lesson/list",
|
||||||
|
"query": {"type": "3"},
|
||||||
|
"response": {
|
||||||
|
"category": "书法学习",
|
||||||
|
"total": 4,
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": "lesson101",
|
||||||
|
"title": "隶属的古法用笔技巧",
|
||||||
|
"image": "https://res.klyj.jinzejk.com/lesson/calligraphy-1.png",
|
||||||
|
"price": 0.0,
|
||||||
|
"chapterCount": 7,
|
||||||
|
"learnCount": 6525,
|
||||||
|
"label": "免费"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "lesson102",
|
||||||
|
"title": "六十三个常用行书字",
|
||||||
|
"image": "https://res.klyj.jinzejk.com/lesson/calligraphy-2.png",
|
||||||
|
"price": 9.9,
|
||||||
|
"chapterCount": 3,
|
||||||
|
"learnCount": 6525
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "lesson103",
|
||||||
|
"title": "隶书入门教学",
|
||||||
|
"image": "https://res.klyj.jinzejk.com/lesson/calligraphy-3.png",
|
||||||
|
"price": 9.9,
|
||||||
|
"chapterCount": 3,
|
||||||
|
"learnCount": 6525
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "lesson104",
|
||||||
|
"title": "易道字体教学",
|
||||||
|
"image": "https://res.klyj.jinzejk.com/lesson/calligraphy-4.png",
|
||||||
|
"price": 9.9,
|
||||||
|
"chapterCount": 3,
|
||||||
|
"learnCount": 6525
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "lesson105",
|
||||||
|
"title": "隶书古法教学",
|
||||||
|
"image": "https://res.klyj.jinzejk.com/lesson/calligraphy-5.png",
|
||||||
|
"price": 9.9,
|
||||||
|
"chapterCount": 3,
|
||||||
|
"learnCount": 6525
|
||||||
}
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"method": "GET",
|
||||||
|
"path": "/api/lesson/list",
|
||||||
|
"query": {"type": "4"},
|
||||||
|
"response": {
|
||||||
|
"category": "乐器弹奏",
|
||||||
|
"total": 3,
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": "lesson201",
|
||||||
|
"title": "二胡学习技法",
|
||||||
|
"image": "https://res.klyj.jinzejk.com/lesson/music-1.png",
|
||||||
|
"price": 0.0,
|
||||||
|
"chapterCount": 7,
|
||||||
|
"learnCount": 6525,
|
||||||
|
"label": "免费"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "lesson202",
|
||||||
|
"title": "吹管开启夕阳红🎷",
|
||||||
|
"image": "https://res.klyj.jinzejk.com/lesson/music-2.png",
|
||||||
|
"price": 9.9,
|
||||||
|
"chapterCount": 3,
|
||||||
|
"learnCount": 6525
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "lesson203",
|
||||||
|
"title": "建议中老年人学下乐器",
|
||||||
|
"image": "https://res.klyj.jinzejk.com/lesson/music-3.png",
|
||||||
|
"price": 9.9,
|
||||||
|
"chapterCount": 3,
|
||||||
|
"learnCount": 6525
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "lesson204",
|
||||||
|
"title": "二胡三玄映月",
|
||||||
|
"image": "https://res.klyj.jinzejk.com/lesson/music-4.png",
|
||||||
|
"price": 9.9,
|
||||||
|
"chapterCount": 3,
|
||||||
|
"learnCount": 6525
|
||||||
}
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
10
server.js
10
server.js
|
|
@ -52,6 +52,16 @@ function registerMockApi(config) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (path === '/api/lesson/list' && Object.keys(req.query).length === 0) {
|
||||||
|
const defaultConfig = global.mockConfigs.find(c =>
|
||||||
|
c.path === path
|
||||||
|
);
|
||||||
|
if (defaultConfig) {
|
||||||
|
console.log(`[MOCK] Fallback to default (home)`);
|
||||||
|
return res.json(formatResponse(defaultConfig.response));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 精确 query 匹配
|
// 精确 query 匹配
|
||||||
if (query) {
|
if (query) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue