fix: fix select demo and search (#14)
This commit is contained in:
parent
a3ba44e690
commit
b22b1cf9e0
@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div class="one-search">
|
||||
<veui-search-box
|
||||
ref="search"
|
||||
v-model="query"
|
||||
class="input"
|
||||
:placeholder="searchPlaceholder"
|
||||
@ -36,6 +37,12 @@ function normalizeURL (url) {
|
||||
return url.replace(/\/([#?])/, '$1')
|
||||
}
|
||||
|
||||
function wait (time) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(resolve, time)
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'one-search',
|
||||
components: {
|
||||
@ -44,6 +51,7 @@ export default {
|
||||
mixins: [i18n],
|
||||
data () {
|
||||
return {
|
||||
preparing: true,
|
||||
query: ''
|
||||
}
|
||||
},
|
||||
@ -65,11 +73,20 @@ export default {
|
||||
const { pathname, hash } = new URL(absoluteUrl)
|
||||
return `${pathname}/${hash}`
|
||||
},
|
||||
triggerFocus (e) {
|
||||
if (e.key === 'k' && (e.metaKey || e.ctrlKey)) {
|
||||
this.$refs.search.focus()
|
||||
}
|
||||
},
|
||||
initialize (locale) {
|
||||
document.addEventListener('keydown', this.triggerFocus)
|
||||
|
||||
Promise.all([
|
||||
import(/* webpackChunkName: "docsearch" */ '@docsearch/js'),
|
||||
import(/* webpackChunkName: "docsearch" */ '@docsearch/css')
|
||||
]).then(([docsearch]) => {
|
||||
document.removeEventListener('keydown', this.triggerFocus)
|
||||
|
||||
docsearch = docsearch.default
|
||||
docsearch({
|
||||
appId: 'WW5G10K3KO',
|
||||
@ -130,6 +147,12 @@ export default {
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
this.preparing = false
|
||||
|
||||
if (this.query) {
|
||||
this.teleportQuery(this.query)
|
||||
}
|
||||
})
|
||||
},
|
||||
update (locale) {
|
||||
@ -137,7 +160,7 @@ export default {
|
||||
this.initialize(locale)
|
||||
},
|
||||
handleInput (value) {
|
||||
if (!value) {
|
||||
if (!value || this.preparing) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,6 @@ module.exports = {
|
||||
})
|
||||
|
||||
config.resolve.alias.vue$ = 'vue/dist/vue.esm.js'
|
||||
config.resolve.alias['vue-inbrowser-compiler-utils'] = '@justfork/vue-inbrowser-compiler-utils'
|
||||
config.resolve.alias['vue-monaco'] = '@justfork/vue-monaco'
|
||||
},
|
||||
|
||||
|
23882
package-lock.json
generated
23882
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,6 @@
|
||||
"devDependencies": {
|
||||
"@docsearch/css": "^3.0.0-alpha.39",
|
||||
"@docsearch/js": "^3.0.0-alpha.39",
|
||||
"@justfork/vue-inbrowser-compiler-utils": "^4.42.0",
|
||||
"@justfork/vue-monaco": "^0.3.1",
|
||||
"@stackblitz/sdk": "^1.5.2",
|
||||
"babel-eslint": "^10.1.0",
|
||||
@ -88,7 +87,7 @@
|
||||
"veui-loader": "^2.3.4",
|
||||
"veui-theme-dls": "^2.3.4",
|
||||
"veui-theme-dls-icons": "^2.3.4",
|
||||
"vue-awesome": "^4.1.0",
|
||||
"vue-awesome": "^4.5.0",
|
||||
"vue-i18n": "^8.16.0",
|
||||
"vue-live": "^1.17.2",
|
||||
"vue-windows": "^0.2.4"
|
||||
|
Loading…
Reference in New Issue
Block a user