upgrade from webpack to vite + typescript
Some checks failed
CSGOWTF/csgowtf/pipeline/head There was a failure building this commit
Some checks failed
CSGOWTF/csgowtf/pipeline/head There was a failure building this commit
This commit is contained in:
130
src/router/index.ts
Normal file
130
src/router/index.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
|
||||
function lazyLoadView(view: string) {
|
||||
return () => import(`/src/views/${view}.vue`);
|
||||
}
|
||||
|
||||
function lazyLoadErrorPages(view: string) {
|
||||
return () => import(`/src/views/errorPages/${view}.vue`);
|
||||
}
|
||||
|
||||
function lazyLoadComponent(view: string) {
|
||||
return () => import(`/src/components/${view}.vue`);
|
||||
}
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
routes: [
|
||||
{
|
||||
path: "/",
|
||||
name: "Home",
|
||||
components: {
|
||||
main: lazyLoadView("HomeView"),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/privacy-policy",
|
||||
name: "PrivacyPolicy",
|
||||
components: {
|
||||
main: lazyLoadView("PrivacyPolicy"),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/matches",
|
||||
name: "Explore",
|
||||
components: {
|
||||
main: lazyLoadView("ExploreView"),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/player/:id",
|
||||
name: "Player",
|
||||
components: {
|
||||
main: lazyLoadView("PlayerView"),
|
||||
},
|
||||
props: true,
|
||||
},
|
||||
{
|
||||
path: "/match/:match_id",
|
||||
name: "Match",
|
||||
components: {
|
||||
main: lazyLoadView("MatchView"),
|
||||
},
|
||||
props: true,
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
components: {
|
||||
score: lazyLoadComponent("ScoreTeam"),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "economy",
|
||||
components: {
|
||||
score: lazyLoadComponent("EqValueGraph"),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "details",
|
||||
components: {
|
||||
score: lazyLoadComponent("DetailsComponent"),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "flashes",
|
||||
components: {
|
||||
score: lazyLoadComponent("FlashChart"),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "damage",
|
||||
components: {
|
||||
score: lazyLoadComponent("DamageSite"),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "chat",
|
||||
components: {
|
||||
score: lazyLoadComponent("MatchChatHistory"),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/404",
|
||||
name: "404",
|
||||
components: {
|
||||
main: lazyLoadErrorPages("404Page"),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/500",
|
||||
name: "500",
|
||||
components: {
|
||||
main: lazyLoadErrorPages("500Page"),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/502",
|
||||
name: "502",
|
||||
components: {
|
||||
main: lazyLoadErrorPages("502Page"),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/:pathMatch(.*)*",
|
||||
redirect: "/",
|
||||
},
|
||||
],
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
scrollBehavior(to, from, savedPosition) {
|
||||
if (savedPosition) {
|
||||
return savedPosition;
|
||||
} else {
|
||||
return { x: 0, y: 0 };
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default router;
|
Reference in New Issue
Block a user