mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Fix keyword sync (fix #4721)
This commit is contained in:
parent
1a0f6ab5dd
commit
c580d67617
@ -68,6 +68,7 @@ import { registerAndGetData } from '@/plugins/data'
|
|||||||
import { select } from '@/core/spin-query'
|
import { select } from '@/core/spin-query'
|
||||||
import { ascendingSort } from '@/core/utils/sort'
|
import { ascendingSort } from '@/core/utils/sort'
|
||||||
import { matchUrlPattern } from '@/core/utils'
|
import { matchUrlPattern } from '@/core/utils'
|
||||||
|
import { urlChange } from '@/core/observer'
|
||||||
import ActionItem from './ActionItem.vue'
|
import ActionItem from './ActionItem.vue'
|
||||||
import {
|
import {
|
||||||
LaunchBarActionProviders,
|
LaunchBarActionProviders,
|
||||||
@ -169,30 +170,29 @@ export default Vue.extend({
|
|||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
await this.getActions()
|
await this.getActions()
|
||||||
|
if (matchUrlPattern(/^https?:\/\/search\.bilibili\.com/)) {
|
||||||
|
await this.setupSearchPageSync()
|
||||||
|
}
|
||||||
this.focusTarget.addEventListener('index-change', () => {
|
this.focusTarget.addEventListener('index-change', () => {
|
||||||
this.handleIndexUpdate()
|
this.handleIndexUpdate()
|
||||||
})
|
})
|
||||||
if (!matchUrlPattern(/^https?:\/\/search\.bilibili\.com/)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
select('#search-keyword, .search-input-el').then((input: HTMLInputElement) => {
|
|
||||||
if (!input) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.keyword = input.value
|
|
||||||
document.addEventListener('change', e => {
|
|
||||||
if (!(e.target instanceof HTMLInputElement)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (e.target.id === 'search-keyword') {
|
|
||||||
this.keyword = e.target.value
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getOnlineActions: lodash.debounce(getOnlineActions, 200),
|
getOnlineActions: lodash.debounce(getOnlineActions, 200),
|
||||||
getActions,
|
getActions,
|
||||||
|
async setupSearchPageSync() {
|
||||||
|
const selector = '#search-keyword, .search-input-el'
|
||||||
|
const input = (await select(selector)) as HTMLInputElement
|
||||||
|
if (!input) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.keyword = input.value
|
||||||
|
urlChange(url => {
|
||||||
|
const params = new URLSearchParams(url)
|
||||||
|
this.keyword = params.get('keyword')
|
||||||
|
})
|
||||||
|
await this.$nextTick()
|
||||||
|
},
|
||||||
handleSelect() {
|
handleSelect() {
|
||||||
this.$emit('close')
|
this.$emit('close')
|
||||||
this.getActions()
|
this.getActions()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user