Skip to content

Commit c18cd0d

Browse files
committed
详情页面
1 parent 89ff7df commit c18cd0d

File tree

4 files changed

+75
-5
lines changed

4 files changed

+75
-5
lines changed

Diff for: layouts/default.vue

+24-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<img class="logo" src="~assets/images/logo.jpg" alt="logo" />
1212
</template>
1313
<template v-else>
14-
<van-icon name="arrow-left" style="font-size: 1.4em;" />
14+
<van-icon name="arrow-left" style="font-size: 16px;" />
1515
<span>返回</span>
1616
</template>
1717
</div>
@@ -74,7 +74,7 @@ export default {
7474
let active = 0
7575
for (let index = 0, len = this.tabbar.length; index < len; index++) {
7676
const element = this.tabbar[index]
77-
if (element.to === this.$route.path) {
77+
if (element.name === this.$route.name) {
7878
active = index
7979
break
8080
}
@@ -88,6 +88,28 @@ export default {
8888
return `${this.tabbar[this.active].label}--${process.env.VUE_APP_title}`
8989
}
9090
},
91+
watch: {
92+
$route: {
93+
handler(val, oldVal) {
94+
if (val.name === 'detail-id') {
95+
this.tabbar.push({
96+
name: 'detail-id',
97+
icon: 'label-o',
98+
selectedIcon: 'label',
99+
to: val.path,
100+
label: '详情'
101+
})
102+
} else {
103+
// eslint-disable-next-line no-lonely-if
104+
if (this.tabbar.length === 5) {
105+
this.tabbar.splice(4, 1)
106+
}
107+
}
108+
},
109+
deep: true,
110+
immediate: true
111+
}
112+
},
91113
methods: {
92114
clickNavLeft() {
93115
if (!this.isHome) {

Diff for: package-lock.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"cross-env": "^5.2.0",
3131
"dayjs": "^1.8.21",
3232
"express": "^4.16.4",
33+
"github-markdown-css": "^4.0.0",
3334
"nuxt": "^2.0.0",
3435
"vant": "^2.5.3"
3536
},

Diff for: pages/detail/_id.vue

+45-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,53 @@
11
<template>
2-
<div class="content">Detail {{ $route.params.id }}</div>
2+
<div class="content">
3+
<div class="detail-box">
4+
<div
5+
class="detail-article markdown-body"
6+
v-html="detailInfo.info.articleContentHtml"
7+
></div>
8+
</div>
9+
</div>
310
</template>
411

512
<script>
13+
import 'github-markdown-css/github-markdown.css'
14+
615
export default {
7-
name: 'Detail'
16+
name: 'Detail',
17+
async asyncData({ app, route, store, params, query }) {
18+
let detailInfo = {}
19+
const result = await app.$axios.$get('/api/vue-blog/article/detail', {
20+
params: {
21+
articleId: params.id,
22+
changeView: 1
23+
}
24+
})
25+
if (result.isok) {
26+
detailInfo = result.data
27+
}
28+
return {
29+
detailInfo
30+
}
31+
},
32+
data() {
33+
return {}
34+
}
835
}
936
</script>
1037

11-
<style lang="scss" scoped></style>
38+
<style lang="scss" scoped>
39+
.detail-box {
40+
margin: 15px 0;
41+
background-color: #fff;
42+
.detail-article {
43+
padding: 15px;
44+
&.markdown-body {
45+
/deep/ {
46+
ol {
47+
list-style: decimal;
48+
}
49+
}
50+
}
51+
}
52+
}
53+
</style>

0 commit comments

Comments
 (0)