fix: normalize path for search result
This commit is contained in:
parent
b8432a870e
commit
2a59d493a5
@ -27,6 +27,15 @@ function isSpecialClick (event) {
|
||||
event.shiftKey
|
||||
)
|
||||
}
|
||||
|
||||
function normalizeURL (url) {
|
||||
if (url.endsWith('/')) {
|
||||
return url.slice(0, -1)
|
||||
}
|
||||
|
||||
return url.replace(/\/([#?])/, '$1')
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'one-search',
|
||||
components: {
|
||||
@ -90,10 +99,11 @@ export default {
|
||||
})
|
||||
},
|
||||
hitComponent: ({ hit, children }) => {
|
||||
const url = normalizeURL(hit.url)
|
||||
return createElement(
|
||||
'a',
|
||||
{
|
||||
href: hit.url,
|
||||
href: url,
|
||||
onClick: event => {
|
||||
if (isSpecialClick(event)) {
|
||||
return
|
||||
@ -112,7 +122,7 @@ export default {
|
||||
if (this.$router.history.current.path !== hitPathname) {
|
||||
event.preventDefault()
|
||||
}
|
||||
this.$router.push(hit.url)
|
||||
this.$router.push(url)
|
||||
},
|
||||
children
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
# InputGroup <small>输入组件组</small>
|
||||
|
||||
:::tip
|
||||
`Input` 组件需要内联 [`Input`](./input)、[`NumberInput`](./number-input)、[`Autocomplete`](autocomplete)、[`SearchBox`](./search-box)、[`Select`](./select)、[DatePicker](./date-picker)、[TimePicker](./time-picker)、[`Dropdown`](./dropdown)、[`Button`](./button)、[`ButtonGroup`](./button-group)、[`Label`](./label)、[`Span`](./span) 等组件配合使用。
|
||||
`Input` 组件需要内联 [`Input`](./input)、[`NumberInput`](./number-input)、[`Autocomplete`](autocomplete)、[`SearchBox`](./search-box)、[`Select`](./select)、[`DatePicker`](./date-picker)、[`TimePicker`](./time-picker)、[`Dropdown`](./dropdown)、[`Button`](./button)、[`ButtonGroup`](./button-group)、[`Label`](./label)、[`Span`](./span) 等组件配合使用。
|
||||
:::
|
||||
|
||||
## 示例
|
||||
|
Loading…
Reference in New Issue
Block a user