Skip to content

Commit

Permalink
feat: Add routing and route skeleton (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
clockworkgr authored Feb 5, 2024
1 parent d69c3ad commit aa3afad
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"test:coverage": "vitest run --coverage"
},
"dependencies": {
"vue": "^3.4.15"
"vue": "^3.4.15",
"vue-router": "^4.2.5"
},
"devDependencies": {
"@playwright/test": "^1.41.2",
Expand Down
16 changes: 16 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { ref } from "vue";
import { RouterView } from "vue-router";
let world = ref("World");
</script>
Expand All @@ -8,6 +9,7 @@ let world = ref("World");
<div>
<h1><div class="world" /></h1>
<h2>Hello {{ world }}</h2>
<RouterView />
</div>
</template>

Expand Down
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { createApp } from "vue";
import "./style.css";
import App from "./App.vue";
import router from "./router";

createApp(App).mount("#app");
const app = createApp(App);
app.use(router);
app.mount("#app");
21 changes: 21 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { createRouter, createWebHistory } from "vue-router";

import HomeView from "../views/HomeView.vue";
import CreateProposalView from "../views/CreateProposalView.vue";
import ProposalsView from "../views/ProposalsView.vue";
import ProposalView from "../views/ProposalView.vue";

const routerHistory = createWebHistory();
const routes = [
{ path: "/", component: HomeView },
{ path: "/proposals", component: ProposalsView },
{ path: "/create", component: CreateProposalView },
{ path: "/proposals/:id", component: ProposalView },
];

const router = createRouter({
history: routerHistory,
routes,
});

export default router;
4 changes: 4 additions & 0 deletions src/views/CreateProposalView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template>
<div></div>
</template>
<script setup lang="ts"></script>
4 changes: 4 additions & 0 deletions src/views/HomeView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template>
<div></div>
</template>
<script setup lang="ts"></script>
4 changes: 4 additions & 0 deletions src/views/ProposalView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template>
<div></div>
</template>
<script setup lang="ts"></script>
4 changes: 4 additions & 0 deletions src/views/ProposalsView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template>
<div></div>
</template>
<script setup lang="ts"></script>
7 changes: 7 additions & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
/// <reference types="vite/client" />

declare module "*.vue" {
import type { DefineComponent } from "vue";
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>;
export default component;
}

0 comments on commit aa3afad

Please sign in to comment.