Skip to content

Commit 7835171

Browse files
committed
refactor(frontend): add base router support
1 parent 47cfee2 commit 7835171

File tree

5 files changed

+40
-3
lines changed

5 files changed

+40
-3
lines changed

packages/app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"build": "vite build"
88
},
99
"dependencies": {
10-
"vue": "^3.2.25"
10+
"vue": "^3.2.25",
11+
"vue-router": "^4.0.16"
1112
},
1213
"devDependencies": {
1314
"@vitejs/plugin-vue": "^2.3.3",

packages/app/src/App.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
<template>
2-
<h1 class="text-3xl font-bold underline">Authentication!</h1>
2+
<div id="nav">
3+
<router-link to="/">Home</router-link>
4+
|
5+
<router-link to="/about">About</router-link>
6+
</div>
7+
8+
<router-view />
39
</template>

packages/app/src/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { createApp } from 'vue';
22
import App from './App.vue';
3+
import router from './router';
4+
35
import './assets/css/index.css';
46

5-
createApp(App).mount('#app');
7+
createApp(App).use(router).mount('#app');

packages/app/src/router.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { createWebHistory, createRouter } from 'vue-router';
2+
3+
const Home = { template: '<div>Home</div>' };
4+
const About = { template: '<div>About</div>' };
5+
6+
const routes = [
7+
{ path: '/', component: Home },
8+
{ path: '/about', component: About },
9+
];
10+
11+
const router = createRouter({
12+
history: createWebHistory(),
13+
routes,
14+
});
15+
16+
export default router;

yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,11 @@
11581158
"@vue/compiler-dom" "3.2.37"
11591159
"@vue/shared" "3.2.37"
11601160

1161+
"@vue/devtools-api@^6.0.0":
1162+
version "6.1.4"
1163+
resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.1.4.tgz#b4aec2f4b4599e11ba774a50c67fa378c9824e53"
1164+
integrity sha512-IiA0SvDrJEgXvVxjNkHPFfDx6SXw0b/TUkqMcDZWNg9fnCAHbTpoo59YfJ9QLFkwa3raau5vSlRVzMSLDnfdtQ==
1165+
11611166
11621167
version "3.2.37"
11631168
resolved "https://registry.yarnpkg.com/@vue/reactivity-transform/-/reactivity-transform-3.2.37.tgz#0caa47c4344df4ae59f5a05dde2a8758829f8eca"
@@ -6352,6 +6357,13 @@ vue-eslint-parser@^9.0.1:
63526357
lodash "^4.17.21"
63536358
semver "^7.3.6"
63546359

6360+
vue-router@^4.0.16:
6361+
version "4.0.16"
6362+
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.0.16.tgz#9477beeeef36e80e04d041a1738801a55e6e862e"
6363+
integrity sha512-JcO7cb8QJLBWE+DfxGUL3xUDOae/8nhM1KVdnudadTAORbuxIC/xAydC5Zr/VLHUDQi1ppuTF5/rjBGzgzrJNA==
6364+
dependencies:
6365+
"@vue/devtools-api" "^6.0.0"
6366+
63556367
vue@^3.2.25:
63566368
version "3.2.37"
63576369
resolved "https://registry.yarnpkg.com/vue/-/vue-3.2.37.tgz#da220ccb618d78579d25b06c7c21498ca4e5452e"

0 commit comments

Comments
 (0)