frequi_origin/src/router/index.ts
2023-09-06 20:44:12 +02:00

103 lines
2.3 KiB
TypeScript

import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import { initBots, useBotStore } from '@/stores/ftbotwrapper';
const routes: Array<RouteRecordRaw> = [
{
path: '/',
name: 'Home',
component: () => import('@/views/HomeView.vue'),
meta: {
allowAnonymous: true,
},
},
{
path: '/trade',
name: 'Freqtrade Trading',
component: () => import('@/views/TradingView.vue'),
},
{
path: '/graph',
name: 'Freqtrade Graph',
component: () => import('@/views/ChartsView.vue'),
},
{
path: '/logs',
name: 'Freqtrade Logs',
component: () => import('@/views/LogView.vue'),
},
{
path: '/backtest',
name: 'Freqtrade Backtest',
component: () => import('@/views/BacktestingView.vue'),
},
{
path: '/dashboard',
name: 'Freqtrade Dashboard',
component: () => import('@/views/DashboardView.vue'),
},
{
path: '/balance',
name: 'Freqtrade Balance',
component: () => import('@/components/ftbot/BotBalance.vue'),
},
{
path: '/open_trades',
component: () => import('@/views/TradesListView.vue'),
},
{
path: '/trade_history',
component: () => import('@/views/TradesListView.vue'),
props: { history: true },
},
{
path: '/pairlist',
component: () => import('@/components/ftbot/PairListLive.vue'),
},
{
path: '/settings',
name: 'Freqtrade Settings',
component: () => import('@/views/SettingsView.vue'),
},
{
path: '/login',
name: 'Login',
component: () => import('@/views/LoginView.vue'),
meta: {
allowAnonymous: true,
},
},
{
path: '/pairlist_config',
name: 'Pairlist Configuration',
component: () => import('@/views/PairlistConfigView.vue'),
},
{
path: '/(.*)*',
name: '404',
component: () => import('@/views/Error404View.vue'),
},
];
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes,
});
router.beforeEach((to, from, next) => {
// Init bots here...
initBots();
const botStore = useBotStore();
if (!to.meta?.allowAnonymous && !botStore.hasBots) {
// Forward to login if login is required
next({
path: '/login',
query: { redirect: to.fullPath },
});
} else {
next();
}
});
export default router;