Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7649bc4

Browse files
committed
#30, 文档相关
1 parent c54faaa commit 7649bc4

File tree

6 files changed

+103
-4
lines changed

6 files changed

+103
-4
lines changed

build/miniprogram.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ module.exports = {
2222
doc: [
2323
'/doc/index',
2424
],
25+
docDetail: [
26+
'/doc/detail/:id',
27+
],
2528
article: [
2629
'/article/:id',
2730
],

build/webpack.mp.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module.exports = {
2121
other: path.resolve(__dirname, '../src/mp/other/main.mp.js'),
2222
me: path.resolve(__dirname, '../src/mp/me/main.mp.js'),
2323
doc: path.resolve(__dirname, '../src/mp/doc/main.mp.js'),
24+
docDetail: path.resolve(__dirname, '../src/mp/docDetail/main.mp.js'),
2425
article: path.resolve(__dirname, '../src/mp/article/main.mp.js'),
2526
},
2627
output: {

src/doc/Index.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ export default Vue.extend({
2323
narrowImg: 'https://wechat-1251018873.file.myqcloud.com/images/narrow.png',
2424
docTitleList: [{
2525
name: '英文文档',
26-
url: '/home',
26+
url: '/doc/detail/docs',
2727
}, {
2828
name: '中文文档',
29-
url: '/me',
29+
url: '/doc/detail/docscn',
3030
}, {
3131
name: '标准库中文文档',
32-
url: '/',
32+
url: '/doc/detail/pkgdoc',
3333
}, {
3434
name: 'Go指南',
35-
url: '/',
35+
url: '/doc/detail/tour',
3636
}],
3737
}
3838
},

src/docDetail/Index.vue

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<template>
2+
<div class="doc_detail">
3+
<wx-web-view :src="url"></wx-web-view>
4+
</div>
5+
</template>
6+
7+
<script>
8+
import Vue from 'vue'
9+
10+
const docUrl = {
11+
docs: 'https://docs.studygolang.com',
12+
docscn: 'http://docscn.studygolang.com',
13+
pkgdoc: 'https://studygolang.com/pkgdoc',
14+
tour: 'http://tour.studygolang.com',
15+
}
16+
17+
export default Vue.extend({
18+
name: 'DocDetail',
19+
data() {
20+
return {
21+
id: 'docs',
22+
url: 'https://docs.studygolang.com',
23+
}
24+
},
25+
created() {
26+
this.id = this.$route.params.id
27+
this.url = docUrl[this.id]
28+
this.openShare(this.id)
29+
},
30+
methods: {
31+
openShare(id) {
32+
wx.showShareMenu({
33+
withShareTicket: true,
34+
menus: ['shareAppMessage', 'shareTimeline'],
35+
})
36+
window.onShareAppMessage = (res) => {
37+
console.log(res)
38+
return {
39+
path: `/doc/detail/${id}`,
40+
}
41+
}
42+
window.onShareTimeline = (res) => {
43+
console.log(res)
44+
return {
45+
path: `/doc/detail/${id}`,
46+
}
47+
}
48+
}
49+
}
50+
})
51+
</script>
52+
<style lang="less">
53+
.doc_detail {
54+
background: #fff;
55+
}
56+
</style>

src/mp/docDetail/main.mp.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import Vue from 'vue'
2+
import Router from 'vue-router'
3+
import { sync } from 'vuex-router-sync'
4+
import App from '../../App.vue'
5+
import store from '../../store'
6+
import DocDetail from '../../docDetail/Index.vue'
7+
8+
Vue.use(Router)
9+
10+
const router = new Router({
11+
mode: 'history',
12+
routes: [{
13+
path: '/doc/detail/:id',
14+
name: 'DocDetail',
15+
component: DocDetail,
16+
}],
17+
})
18+
19+
export default function createApp() {
20+
const container = document.createElement('div')
21+
container.id = 'app'
22+
document.body.appendChild(container)
23+
24+
Vue.config.productionTip = false
25+
26+
sync(store, router)
27+
28+
return new Vue({
29+
el: '#app',
30+
router,
31+
store,
32+
render: h => h(App)
33+
})
34+
}

src/router/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const Home = () => import(/* webpackChunkName: "Home" */'@/home/Index.vue')
55
const List = () => import(/* webpackChunkName: "List" */'@/list/Index.vue')
66
const Detail = () => import(/* webpackChunkName: "Detail" */'@/detail/Index.vue')
77
const Doc = () => import(/* webpackChunkName: "Doc" */'@/doc/Index.vue')
8+
const DocDetail = () => import(/* webpackChunkName: "DocDetail" */'@/docDetail/Index.vue')
89
const Article = () => import(/* webpackChunkName: "Article" */'@/article/Index.vue')
910
Vue.use(Router)
1011

@@ -35,6 +36,10 @@ export default new Router({
3536
name: 'Doc',
3637
component: Doc,
3738
}, {
39+
path: '/doc/detail/:id',
40+
name: 'DocDetail',
41+
component: DocDetail,
42+
},{
3843
path: '/article/:id',
3944
name: 'Article',
4045
component: Article,

0 commit comments

Comments
 (0)