mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-02-02 18:28:40 +08:00
fix: search menu did not correctly carry routing parameters
This commit is contained in:
parent
5611f6c7f5
commit
c8ea7832de
@ -2,17 +2,17 @@
|
|||||||
import type { MenuRecordRaw } from '@vben/types';
|
import type { MenuRecordRaw } from '@vben/types';
|
||||||
|
|
||||||
import { nextTick, onMounted, ref, shallowRef, watch } from 'vue';
|
import { nextTick, onMounted, ref, shallowRef, watch } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
|
|
||||||
import { SearchX, X } from '@vben/icons';
|
import { SearchX, X } from '@vben/icons';
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
import { mapTree, traverseTreeValues, uniqueByField } from '@vben/utils';
|
import { mapTree, traverseTreeValues, uniqueByField } from '@vben/utils';
|
||||||
|
|
||||||
import { VbenIcon, VbenScrollbar } from '@vben-core/shadcn-ui';
|
import { VbenIcon, VbenScrollbar } from '@vben-core/shadcn-ui';
|
||||||
import { isHttpUrl } from '@vben-core/shared/utils';
|
|
||||||
|
|
||||||
import { onKeyStroke, useLocalStorage, useThrottleFn } from '@vueuse/core';
|
import { onKeyStroke, useLocalStorage, useThrottleFn } from '@vueuse/core';
|
||||||
|
|
||||||
|
import { useNavigation } from '../../basic/menu/use-navigation';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'SearchPanel',
|
name: 'SearchPanel',
|
||||||
});
|
});
|
||||||
@ -26,7 +26,6 @@ const props = withDefaults(
|
|||||||
);
|
);
|
||||||
const emit = defineEmits<{ close: [] }>();
|
const emit = defineEmits<{ close: [] }>();
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
const searchHistory = useLocalStorage<MenuRecordRaw[]>(
|
const searchHistory = useLocalStorage<MenuRecordRaw[]>(
|
||||||
`__search-history-${location.hostname}__`,
|
`__search-history-${location.hostname}__`,
|
||||||
[],
|
[],
|
||||||
@ -86,6 +85,7 @@ function scrollIntoView() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { navigation } = useNavigation();
|
||||||
// enter keyboard event
|
// enter keyboard event
|
||||||
async function handleEnter() {
|
async function handleEnter() {
|
||||||
if (searchResults.value.length === 0) {
|
if (searchResults.value.length === 0) {
|
||||||
@ -101,11 +101,7 @@ async function handleEnter() {
|
|||||||
searchHistory.value.push(to);
|
searchHistory.value.push(to);
|
||||||
handleClose();
|
handleClose();
|
||||||
await nextTick();
|
await nextTick();
|
||||||
if (isHttpUrl(to.path)) {
|
await navigation(to.path);
|
||||||
window.open(to.path, '_blank');
|
|
||||||
} else {
|
|
||||||
router.push({ path: to.path, replace: true });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user