Skip to content

Commit 2caec07

Browse files
committed
统一管理配置
1 parent adaeace commit 2caec07

File tree

5 files changed

+20
-44
lines changed

5 files changed

+20
-44
lines changed

src/router.js

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,19 @@ import { routes } from "@/setting";
44

55
Vue.use(Router);
66

7-
let children = [
8-
{
9-
path: "/plan",
10-
name: "plan",
11-
component: () => import("@/views/plan.vue")
12-
}
13-
];
14-
let firstRoute = null;
7+
let children = [];
158
routes.forEach(({ path }) => {
169
if (!path) return;
17-
let pathArray = path.split(".");
18-
pathArray.pop();
19-
let url = pathArray.join("");
20-
if (!firstRoute) {
21-
firstRoute = {
22-
path: "/",
23-
name: "notes",
24-
component: () => import(`.${path}`)
25-
};
26-
}
27-
children.push({
28-
path: url,
29-
name: url,
30-
component: () => import(`.${path}`)
31-
});
10+
let url = path.replace(/@/, "").replace(/.md$/, "");
11+
children.push({ path: url, name: url, component: () => import(`.${url}.md`) });
3212
});
13+
let firstRoute = { path: "/", name: "notes", component: children[0].component };
14+
children.push({
15+
path: "/plan",
16+
name: "plan",
17+
component: () => import("@/views/plan.vue")
18+
});
19+
3320
export default new Router({
3421
mode: "history",
3522
base: process.env.BASE_URL,

src/setting.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module.exports = {
55
// 2.name:生成菜单标题或者分组标题,必填
66
routes: [
77
{ path: "", name: "JavaScript基础" },
8-
{ path: "/notes/javascript/JAVASCRIPT-01.md", name: "简介和使用" },
9-
{ path: "/notes/javascript/JAVASCRIPT-02.md", name: "语法和数据类型" }
8+
{ path: "@/notes/javascript/JAVASCRIPT-01.md", name: "简介和使用",date:"2018-12-09" }
109
]
1110
};

src/views/home.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ export default {
7676
this.handleClickOutSide();
7777
},
7878
convertUrl(path) {
79-
let pathArray = path.split(".");
80-
pathArray.pop();
81-
return pathArray.join("");
79+
return path.replace(/@/,'').replace(/.md$/,'');
8280
}
8381
},
8482
mounted() {

src/views/plan.vue

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,37 @@
11
<template>
22
<div class="k-v-plan">
33
<k-snippet v-for="({date,rows}, index) in planGroupList" :key="index" :title="date">
4-
<div v-for="(content,index) in rows" :key="index" :class="`k-v-plan--item k-v-plan--item-color-${index}`">
5-
{{ content }}
4+
<div v-for="(name,index) in rows" :key="index" :class="`k-v-plan--item k-v-plan--item-color-${index}`">
5+
{{ name }}
66
</div>
77
</k-snippet>
88
</div>
99
</template>
1010

1111
<script>
1212
import moment from "dayjs";
13+
import { routes } from "@/setting";
1314
1415
export default {
1516
data() {
1617
return {
17-
planList: [
18-
{ date: "2018-11-30", content: "test0" },
19-
{ date: "2018-12-01", content: "test1" },
20-
{ date: "2018-12-02", content: "test2" },
21-
{ date: "2018-12-03", content: "test3" },
22-
{ date: "2018-12-04", content: "test4" },
23-
{ date: "2018-12-05", content: "test5" }
24-
]
18+
planList:routes
2519
};
2620
},
2721
computed: {
2822
planGroupList() {
2923
let planMap = {};
3024
let intervalList = [1, 2, 4, 7, 15, 30, 60];
31-
this.planList.forEach(({ date, content }) => {
25+
this.planList.forEach(({ date, name ,path}) => {
26+
if(!path) return;
3227
intervalList.forEach(interval => {
3328
let reviewDate = moment(date).add(interval, "days");
3429
if (reviewDate.isBefore(moment().add(-1, "days"), "day")) return;
3530
let reviewDateFormat = reviewDate.format("YYYY-MM-DD");
3631
if (!planMap[reviewDateFormat]) {
3732
planMap[reviewDateFormat] = [];
3833
}
39-
planMap[reviewDateFormat].push(content);
34+
planMap[reviewDateFormat].push(name);
4035
});
4136
});
4237
let rows = [];

vue.config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ module.exports = {
3535
return `---snippet ${value.replace(/```/g, "")} \n---\n ${value}`;
3636
});
3737
},
38-
use: [
39-
kMarkdownSnippet,
40-
kMarkdownSnippetCode
41-
]
38+
use: [kMarkdownSnippet, kMarkdownSnippetCode]
4239
});
4340
},
4441
configureWebpack: () => {

0 commit comments

Comments
 (0)