Skip to content

Commit 92046b4

Browse files
committed
feat: blog mock
1 parent 0e74ecc commit 92046b4

3 files changed

Lines changed: 55 additions & 1 deletion

File tree

vue2/sandboxs/package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vue2/sandboxs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"test:Icon": "vue serve ./src/components/Icon/test.vue",
1515
"test:toast": "vue serve ./test/toast/index.vue",
1616
"test:Lifecycle": "vue serve ./test/lifecycle/Lifecycle.vue",
17-
"test:FetchData":"vue serve ./test/lifecycle/FetchData.vue",
17+
"test:FetchData": "vue serve ./test/lifecycle/FetchData.vue",
1818
"test:Loading": "vue serve ./src/components/Loading/test.vue",
1919
"test:vLoading": "vue serve ./src/directives/loading/test.vue",
2020
"test:TreeListMenu": "vue serve ./src/components/TreeListMenu/test.vue"
@@ -23,6 +23,7 @@
2323
"axios": "^1.13.4",
2424
"core-js": "^3.6.5",
2525
"mockjs": "^1.1.0",
26+
"querystring": "^0.2.1",
2627
"vue": "^2.6.11",
2728
"vue-router": "^3.6.5"
2829
},

vue2/sandboxs/src/mock/blog.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import Mock from "mockjs";
2+
import qs from "querystring";
3+
Mock.mock("/api/blogtype", "get", {
4+
code: 0,
5+
msg: "",
6+
"data|10-20": [
7+
{
8+
"id|+1": 1,
9+
name: "分类@id",
10+
"articleCount|0-300": 0,
11+
"order|+1": 1,
12+
},
13+
],
14+
});
15+
16+
Mock.mock(/^\/api\/blog(\?.+)?$/, "get", function (options) {
17+
const query = qs.parse(options.url);
18+
19+
return Mock.mock({
20+
code: 0,
21+
msg: "",
22+
data: {
23+
"total|2000-3000": 0,
24+
[`rows|${query.limit || 10}`]: [
25+
{
26+
id: "@guid",
27+
title: "@ctitle",
28+
description: "@cparagraph(1, 10)",
29+
category: {
30+
"id|1-10": 0,
31+
name: "分类@id",
32+
},
33+
"scanNumber|0-3000": 0,
34+
"commentNumber|0-300": 30,
35+
thumb: Mock.Random.image("300x250", "#000", "#fff", "Random Image"),
36+
createDate: `@date('T')`,
37+
},
38+
],
39+
},
40+
});
41+
});
42+

0 commit comments

Comments
 (0)