mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-27 05:25:17 +00:00
useRoute from vue-router
This commit is contained in:
parent
d08250925a
commit
9d000f50ce
|
@ -77,8 +77,8 @@ import { useUserService } from '@/shared/userService';
|
||||||
import { AuthPayload } from '@/types';
|
import { AuthPayload } from '@/types';
|
||||||
|
|
||||||
import { defineComponent, ref } from 'vue';
|
import { defineComponent, ref } from 'vue';
|
||||||
import { useRouter, useRoute } from '@/composables/router-helper';
|
|
||||||
import { useBotStore } from '@/stores/ftbotwrapper';
|
import { useBotStore } from '@/stores/ftbotwrapper';
|
||||||
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
const defaultURL = window.location.origin || 'http://localhost:3000';
|
const defaultURL = window.location.origin || 'http://localhost:3000';
|
||||||
|
|
||||||
|
|
|
@ -128,10 +128,10 @@ import ReloadControl from '@/components/ftbot/ReloadControl.vue';
|
||||||
import BotEntry from '@/components/BotEntry.vue';
|
import BotEntry from '@/components/BotEntry.vue';
|
||||||
import BotList from '@/components/BotList.vue';
|
import BotList from '@/components/BotList.vue';
|
||||||
import { defineComponent, ref, onBeforeUnmount, onMounted, watch } from 'vue';
|
import { defineComponent, ref, onBeforeUnmount, onMounted, watch } from 'vue';
|
||||||
import { useRoute } from '@/composables/router-helper';
|
|
||||||
import { OpenTradeVizOptions, useSettingsStore } from '@/stores/settings';
|
import { OpenTradeVizOptions, useSettingsStore } from '@/stores/settings';
|
||||||
import { useLayoutStore } from '@/stores/layout';
|
import { useLayoutStore } from '@/stores/layout';
|
||||||
import { useBotStore } from '@/stores/ftbotwrapper';
|
import { useBotStore } from '@/stores/ftbotwrapper';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'NavBar',
|
name: 'NavBar',
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
// TODO: This helper can be removed once
|
|
||||||
// vue-router either releases a new version, or we update to vue3.
|
|
||||||
import {
|
|
||||||
// effectScope,
|
|
||||||
getCurrentInstance,
|
|
||||||
reactive,
|
|
||||||
} from 'vue';
|
|
||||||
|
|
||||||
import { Route } from 'vue-router';
|
|
||||||
|
|
||||||
let currentRoute: Route;
|
|
||||||
|
|
||||||
function assign(target: Record<string, any>, source: Record<string, any>) {
|
|
||||||
for (const key of Object.keys(source)) {
|
|
||||||
target[key] = source[key];
|
|
||||||
}
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useRoute(): Route {
|
|
||||||
const inst = getCurrentInstance();
|
|
||||||
if (!inst) {
|
|
||||||
return undefined as any;
|
|
||||||
}
|
|
||||||
if (!currentRoute) {
|
|
||||||
// const scope = effectScope(true);
|
|
||||||
// scope.run(() => {
|
|
||||||
// const { $router } = inst.proxy;
|
|
||||||
// currentRoute = reactive(assign({}, $router.currentRoute)) as any;
|
|
||||||
// $router.afterEach((to) => {
|
|
||||||
// assign(currentRoute, to);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
return currentRoute;
|
|
||||||
}
|
|
||||||
export function useRouter() {
|
|
||||||
const inst = getCurrentInstance();
|
|
||||||
if (!inst) {
|
|
||||||
throw new Error('No current instance found');
|
|
||||||
}
|
|
||||||
const { proxy } = inst;
|
|
||||||
return proxy.$router;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user