mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-09 04:31:35 +08:00
6453b90043
* feat(vite-doc): add vite md plugin * fixed(site-vite): merge conflicts * fix(vite-doc): some bug in vue rerender,use key to advoid * feat(vite-doc): finished doc * fix(vite-doc): import path should be same as normal * chore(vite-doc): remove useless code Co-authored-by: Lecong Zhang <50313260+tskirby@users.noreply.github.com>
75 lines
1.5 KiB
Vue
75 lines
1.5 KiB
Vue
<template>
|
|
<n-config-provider
|
|
class="demo"
|
|
namespace="naive-ui-doc"
|
|
:theme="theme"
|
|
:language="lang"
|
|
>
|
|
<n-loading-bar-provider ref="loadingBar">
|
|
<n-message-provider>
|
|
<n-notification-provider>
|
|
<n-dialog-provider>
|
|
<site />
|
|
</n-dialog-provider>
|
|
</n-notification-provider>
|
|
</n-message-provider>
|
|
</n-loading-bar-provider>
|
|
</n-config-provider>
|
|
</template>
|
|
|
|
<script>
|
|
import Site from './Site.vue'
|
|
|
|
export default {
|
|
name: 'SiteProvider',
|
|
provide () {
|
|
return {
|
|
SiteProvider: this
|
|
}
|
|
},
|
|
components: {
|
|
Site
|
|
},
|
|
computed: {
|
|
lang: {
|
|
get () {
|
|
return this.$route.params.lang || 'en-US'
|
|
},
|
|
set (lang) {
|
|
this.$router.push(changeLangInPath(this.$route.fullPath, lang))
|
|
}
|
|
},
|
|
theme: {
|
|
get () {
|
|
switch (this.$route.params.theme) {
|
|
case 'os-theme': return 'light'
|
|
case 'dark': return 'dark'
|
|
default: return 'light'
|
|
}
|
|
},
|
|
set (theme) {
|
|
this.$router.push(
|
|
changeThemeInPath(this.$route.fullPath, theme)
|
|
)
|
|
}
|
|
}
|
|
},
|
|
beforeRouteEnter (to, from, next) {
|
|
next()
|
|
},
|
|
beforeRouteUpdate (to, from, next) {
|
|
next()
|
|
}
|
|
}
|
|
|
|
function changeLangInPath (path, lang) {
|
|
const langReg = /^\/(zh-CN|en-US)\//
|
|
return path.replace(langReg, `/${lang}/`)
|
|
}
|
|
|
|
function changeThemeInPath (path, theme) {
|
|
const themeReg = /(^\/[^/]+\/)([^/]+)/
|
|
return path.replace(themeReg, '$1' + theme)
|
|
}
|
|
</script>
|