Skip to content

Commit

Permalink
fix(use-go): fix useGo router is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Jul 23, 2020
1 parent b8c428c commit 99a9b2d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Bug Fixes

- **components:** add file upload,modal add closeFunc props ([92f19a9](https://github.com/anncwb/vue-vben-admin/commit/92f19a9cc7f48d4aba547eccbb515087cb94b39b))
- **use-go:** fix useGo router is undefined ([85359d2](https://github.com/anncwb/vue-vben-admin/commit/85359d2037695b35ce61dfc008452e9716c64f74))
- **vac:** fix vca plugins auto import onMounted onunMounted ([5fea1d0](https://github.com/anncwb/vue-vben-admin/commit/5fea1d051173422a37be7a48a578b13e472f4e2b))
- **workbench:** update image's name and performance api ([838681d](https://github.com/anncwb/vue-vben-admin/commit/838681d07b24bb0a19479732487b8465b87de740))
- remove scroll component props ([bc1398a](https://github.com/anncwb/vue-vben-admin/commit/bc1398abae582a11041f83112b2b3a36c6cebe30))
Expand Down
6 changes: 4 additions & 2 deletions src/hooks/core/useRouter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { unref, computed } from 'compatible-vue';
import { pageEnum } from '@/enums/pageEnum';
import { getRuntimeVM } from '@/setup/vue/runtimeVm';

import VurRouter from 'vue-router';
export const useRouter = () => {
const vm = getRuntimeVM();
const route = computed(() => vm.$route);
Expand All @@ -24,10 +24,12 @@ export const useRedo = () => {
export const useGo = ({
path = pageEnum.BASE_HOME,
replace = true,
router: rootRouter,
}: {
router?: VurRouter;
path?: pageEnum;
replace?: boolean;
} = {}) => {
const { router } = useRouter();
replace ? router.replace(path) : router.push(path);
replace ? (rootRouter || router).replace(path) : (rootRouter || router).push(path);
};
4 changes: 2 additions & 2 deletions src/layouts/default/LayoutMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
default: '',
} as PropOptions<string>,
},
setup(props) {
setup(props, { root }) {
const { prefixCls } = useDesign('layout-menu');
function handleMenuClick({ targetRoute }: { menu?: MenuItem; targetRoute: RouteConfigEx }) {
const { path } = targetRoute;
// const { path, meta: { frameSrc } = {} } = targetRoute;
if (path) {
useGo({ path: path as pageEnum, replace: false });
useGo({ path: path as pageEnum, replace: false, router: root.$router });
}
}
return () => {
Expand Down

0 comments on commit 99a9b2d

Please sign in to comment.