site: fill github url

This commit is contained in:
07akioni 2021-06-05 04:20:31 +08:00
parent 6e2f4a7194
commit 63d0e255d3
4 changed files with 33 additions and 10 deletions

View File

@ -86,7 +86,9 @@
<n-button text class="nav-picker" @click="handleThemeUpdate">
{{ themeLabelMap[theme] }}
</n-button>
<n-button text class="nav-picker">Github</n-button>
<n-button tag="a" text class="nav-picker" :href="repoUrl" target="_blank">
Github
</n-button>
<n-text class="nav-picker">
{{ version }}
</n-text>
@ -115,6 +117,7 @@ import { computed, ref } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { useMessage, version } from 'naive-ui'
import { MenuOutline } from '@vicons/ionicons5'
import { repoUrl } from './utils/github-url'
import { i18n, useIsXs, useIsM, useIsS } from './utils/composables'
import { findMenuValue } from './utils/route'
import {
@ -196,17 +199,18 @@ export default {
})
const themeAndLocaleReg = /^(\/[^/]+){2}/
function handleMenuUpdateValue (value) {
if (value === 'github') {
window.open(repoUrl, '_blank')
}
if (value === 'home') {
router.push(themeAndLocaleReg.exec(route.path)[0])
}
if (value === 'doc') {
} else if (value === 'doc') {
if (!/^(\/[^/]+){2}\/docs/.test(route.path)) {
router.push(
themeAndLocaleReg.exec(route.path)[0] + '/docs/introduction'
)
}
}
if (value === 'component') {
} else if (value === 'component') {
if (!/^(\/[^/]+){2}\/components/.test(route.path)) {
router.push(
themeAndLocaleReg.exec(route.path)[0] + '/components/button'
@ -266,6 +270,10 @@ export default {
{
key: 'component',
title: t('component')
},
{
key: 'github',
title: 'Github'
}
]
})
@ -308,6 +316,10 @@ export default {
key: 'component',
title: t('component'),
children: componentOptionsRef.value
},
{
key: 'github',
title: 'Github'
}
]
})
@ -437,6 +449,7 @@ export default {
isXs: isXsRef,
isM: useIsM(),
isS: useIsS(),
repoUrl,
// theme
theme: themeNameRef,
handleThemeUpdate,

View File

@ -25,10 +25,17 @@
</div>
<div class="footer-links-col">
<n-text depth="1" class="col-header">{{ t('community') }}</n-text>
<n-button text tag="a" target="_blank" href="https://www.github.com">
<n-button text tag="a" target="_blank" :href="repoUrl">
Github
</n-button>
<n-button text>Discord</n-button>
<n-button
text
tag="a"
href="https://discord.gg/Pqv7Mev5Dd"
target="_blank"
>
Discord
</n-button>
<n-button text>钉钉</n-button>
</div>
<div class="footer-links-col footer-links-col--last">
@ -53,6 +60,7 @@
<script>
import { i18n } from '../../utils/composables'
import { push } from '../../store'
import { repoUrl } from '../../utils/github-url'
import { version } from 'naive-ui'
export default {
@ -62,6 +70,7 @@ export default {
setup () {
return {
version,
repoUrl,
push,
...i18n({
'zh-CN': {

View File

@ -16,7 +16,7 @@
<script>
import EditIcon from '@vicons/fluent/Compose16Regular.js'
import githubUrl from './github-url'
import { treeUrl } from './github-url'
export default {
name: 'EditOnGithubButton',
@ -35,7 +35,7 @@ export default {
setup (props) {
return {
handleClick () {
window.open(githubUrl + props.relativeUrl, '_blank')
window.open(treeUrl + props.relativeUrl, '_blank')
}
}
}

View File

@ -1 +1,2 @@
export default 'https://github.com/TuSimple/naive-ui/tree/master/'
export const repoUrl = 'https://github.com/TuSimple/naive-ui'
export const treeUrl = 'https://github.com/TuSimple/naive-ui/tree/main/'