naive-ui/demo/utils/EditOnGithubButton.vue

56 lines
879 B
Vue
Raw Normal View History

2020-03-19 13:26:06 +08:00
<template>
<n-button
class="edit-button"
2020-05-31 11:56:00 +08:00
text
2020-03-19 18:26:48 +08:00
:size="size"
2020-03-19 13:26:06 +08:00
@click="handleEditOnGithubClick"
>
2020-11-03 15:10:29 +08:00
<template #icon>
<n-icon>
<edit-icon />
</n-icon>
2020-03-19 13:26:06 +08:00
</template>
</n-button>
</template>
2020-03-19 18:26:48 +08:00
2020-03-19 13:26:06 +08:00
<script>
import EditIcon from '@vicons/fluent/Compose16Regular.js'
2020-09-04 01:06:39 +08:00
import githubUrl from './github-url'
2020-03-19 18:26:48 +08:00
2020-03-19 13:26:06 +08:00
export default {
name: 'EditOnGithubButton',
components: {
2020-11-03 18:56:13 +08:00
EditIcon
2020-03-19 13:26:06 +08:00
},
props: {
2020-09-04 01:06:39 +08:00
relativeUrl: {
2020-03-19 13:26:06 +08:00
type: String,
required: true
2020-03-19 18:26:48 +08:00
},
text: {
type: Boolean,
default: false
},
size: {
type: String,
default: undefined
2020-03-19 13:26:06 +08:00
}
},
data () {
return {
2020-09-04 01:06:39 +08:00
githubUrl
2020-03-19 13:26:06 +08:00
}
},
computed: {
gheDocUrl () {
2020-09-04 01:06:39 +08:00
return this.githubUrl + this.relativeUrl
2020-03-19 13:26:06 +08:00
}
},
methods: {
handleEditOnGithubClick () {
2020-03-19 13:34:13 +08:00
window.open(this.gheDocUrl, '_blank')
2020-03-19 13:26:06 +08:00
}
}
}
</script>