feat: publicize doc implemetation
This commit is contained in:
8
plugins/README.md
Normal file
8
plugins/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# PLUGINS
|
||||
|
||||
This directory contains your Javascript plugins that you want to run before instantiating the root vue.js application.
|
||||
|
||||
More information about the usage of this directory in the documentation:
|
||||
https://nuxtjs.org/guide/plugins
|
||||
|
||||
**This directory is not required, you can delete it if you don't want to use it.**
|
||||
32
plugins/algolia.js
Normal file
32
plugins/algolia.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import { getLocale } from '../common/i18n'
|
||||
|
||||
function check (name, timeout, callback) {
|
||||
if (name in window) {
|
||||
setTimeout(() => callback(window[name]))
|
||||
return
|
||||
}
|
||||
setTimeout(() => {
|
||||
check(name, timeout, callback)
|
||||
}, timeout)
|
||||
}
|
||||
|
||||
export default ({ app, route }) => {
|
||||
// if (process.env.NODE_ENV !== 'production') return
|
||||
|
||||
check('docsearch', 300, docsearch => {
|
||||
window.docsearchInstance = docsearch({
|
||||
apiKey: '21cdc123c620ec4bb81259c32e90c08f',
|
||||
indexName: 'veui',
|
||||
inputSelector: '.search',
|
||||
algoliaOptions: {
|
||||
facetFilters: [`lang:${getLocale(route.path)}`]
|
||||
},
|
||||
handleSelected (input, e, { url }) {
|
||||
input.setVal('')
|
||||
e.preventDefault()
|
||||
let { pathname, search, hash } = new URL(url)
|
||||
app.router.push(`${pathname}${search}${hash}`)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
14
plugins/hm.js
Normal file
14
plugins/hm.js
Normal file
@@ -0,0 +1,14 @@
|
||||
export default ({ app }) => {
|
||||
if (process.env.NODE_ENV !== 'production') return
|
||||
|
||||
var _hmt = window._hmt = window._hmt || []
|
||||
|
||||
var hm = document.createElement('script')
|
||||
hm.src = 'https://hm.baidu.com/hm.js?d204d9e2f2ad504d6fe10939a9b5b588'
|
||||
var s = document.getElementsByTagName('script')[0]
|
||||
s.parentNode.insertBefore(hm, s)
|
||||
|
||||
app.router.afterEach(to => {
|
||||
_hmt.push(['_trackPageview', to.fullPath])
|
||||
})
|
||||
}
|
||||
11
plugins/i18n.js
Normal file
11
plugins/i18n.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import Vue from 'vue'
|
||||
import VueI18n from 'vue-i18n'
|
||||
import { getLocale } from '../common/i18n'
|
||||
import i18nMgr from 'veui/managers/i18n'
|
||||
|
||||
Vue.use(VueI18n)
|
||||
|
||||
export default ({ app, route }) => {
|
||||
app.i18n = new VueI18n()
|
||||
i18nMgr.locale = getLocale(route.path)
|
||||
}
|
||||
43
plugins/l10n.js
Normal file
43
plugins/l10n.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import i18n from 'veui/managers/i18n'
|
||||
|
||||
i18n.register(
|
||||
'zh-Hans',
|
||||
{
|
||||
showCode: '显示代码',
|
||||
hideCode: '隐藏代码'
|
||||
},
|
||||
{
|
||||
ns: 'onedemo'
|
||||
}
|
||||
)
|
||||
|
||||
i18n.register(
|
||||
'en-US',
|
||||
{
|
||||
showCode: 'Show code',
|
||||
hideCode: 'Hide code'
|
||||
},
|
||||
{
|
||||
ns: 'onedemo'
|
||||
}
|
||||
)
|
||||
|
||||
i18n.register(
|
||||
'zh-Hans',
|
||||
{
|
||||
toTop: '回到顶部'
|
||||
},
|
||||
{
|
||||
ns: 'onebacktotop'
|
||||
}
|
||||
)
|
||||
|
||||
i18n.register(
|
||||
'en-US',
|
||||
{
|
||||
toTop: 'Back to top'
|
||||
},
|
||||
{
|
||||
ns: 'onebacktotop'
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user