Skip to content

Commit 026c208

Browse files
committed
修复文档的一些错误
1 parent d1cd6e9 commit 026c208

14 files changed

+4469
-101
lines changed

dist/my-vue-dialog.css

Lines changed: 104 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/my-vue-dialog.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/my-vue-dialog.js

Lines changed: 4258 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/my-vue-dialog.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs-src/build/webpack.base.conf.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ function resolve (dir) {
99
return path.join(__dirname, '..', dir)
1010
}
1111

12-
13-
1412
module.exports = {
1513
context: path.resolve(__dirname, '../'),
1614
entry: {
@@ -50,7 +48,8 @@ module.exports = {
5048
{
5149
test: /\.js$/,
5250
loader: 'babel-loader',
53-
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
51+
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client'),
52+
resolve('node_modules/iview'), resolve('node_modules/vue-particles')]
5453
},
5554
{
5655
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,

docs-src/src/components/A/goLink.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
2+
let userAgent = window.navigator.userAgent
3+
let isIE = (function () {
4+
let matches;
5+
const tridentMap = {
6+
'4': 8,
7+
'5': 9,
8+
'6': 10,
9+
'7': 11
10+
};
11+
12+
matches = userAgent.match(/MSIE (\d+)/i);
13+
if(matches && matches[1]) {
14+
return !!+matches[1];
15+
}
16+
matches = userAgent.match(/Trident\/(\d+)/i);
17+
if(matches && matches[1]) {
18+
return !!tridentMap[matches[1]] || false;
19+
}
20+
//we did what we could
21+
return false;
22+
})();
23+
24+
export function goLink(path, router){
25+
if(path.startsWith('http') || path.startsWith('//')){
26+
window.open(path, '_blank')
27+
} else {
28+
if(path.startsWith('#')){
29+
path = path.substr(1)
30+
}
31+
32+
let route = router.currentRoute
33+
let position = path.indexOf('#')
34+
let hash = ~position ? path.substr(position + 1) : ''
35+
let routePath = path.split('#')[0]
36+
if(route.path == routePath){
37+
goHash(hash, router)
38+
39+
} else{
40+
if(isIE){
41+
router.app.$destroy()
42+
location.assign('#' + path)
43+
setTimeout(()=>{
44+
location.reload()
45+
})
46+
} else {
47+
location.assign('#' + path)
48+
}
49+
}
50+
}
51+
}
52+
53+
export function goHash(hash, router){
54+
if(hash.startsWith('#')){
55+
hash = hash.substr(1)
56+
}
57+
if(hash){
58+
try{
59+
let title = document.querySelector(`[name='${hash}']`)
60+
if(title){
61+
title.scrollIntoView()
62+
}
63+
} catch(e){console.log(e)}
64+
} else {
65+
let title = document.querySelector(`#menu`)
66+
if(title){
67+
title.scrollIntoView()
68+
}
69+
}
70+
}

docs-src/src/components/A/index.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
<template>
2-
<a class="a" :href="href" :target="href && (href.startsWith('http') || href.startsWith('//')) ? '_blank' : '_self'"><slot></slot></a>
2+
<a class="a" :href="href" @click.stop.prevent="goLink"><slot></slot></a>
33
</template>
44
<script>
5+
import {goLink} from './goLink'
56
export default {
67
props: {
78
href: {
89
type: String,
910
required: true
1011
},
12+
},
13+
methods: {
14+
goLink($event){
15+
goLink(this.href, this.$router)
16+
}
1117
}
1218
}
1319
</script>

docs-src/src/components/Demo/index.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,19 @@
9898
},
9999
mounted () {
100100
this.$nextTick(() => {
101-
const demo_height = this.$refs.demo.$el.clientHeight;
102-
const code_height = this.$refs.code.$el.clientHeight + 20;
103-
this.code_height = code_height;
104-
if (code_height <= demo_height) {
101+
if(this.$refs.demo && this.$refs.code){
102+
const demo_height = this.$refs.demo.$el.clientHeight;
103+
const code_height = this.$refs.code.$el.clientHeight + 20;
104+
this.code_height = code_height;
105+
if (code_height <= demo_height) {
106+
this.showMore = false;
107+
}
108+
this.demo_height = demo_height;
109+
this.ready = true;
110+
} else {
105111
this.showMore = false;
112+
this.ready = true;
106113
}
107-
this.demo_height = demo_height;
108-
this.ready = true;
109114
});
110115
}
111116
}

docs-src/src/components/Doc/index.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@
44
</div>
55
</template>
66
<script>
7+
import {goHash} from '../A/goLink'
78
export default {
89
inject: ['clear'],
910
name: 'Doc',
1011
created(){
1112
if( this.$parent.$parent.$vnode.componentOptions.tag === 'Menu' ){
1213
this.clear()
14+
this.needGoHash = true
15+
}
16+
},
17+
mounted(){
18+
if(this.needGoHash){
19+
goHash(this.$route.hash, this.$router)
20+
this.needGoHash = false
1321
}
1422
}
1523
}

0 commit comments

Comments
 (0)