Skip to content

Commit

Permalink
Merge pull request #146 from traPtitech/fix/chapter2_sec2
Browse files Browse the repository at this point in the history
Fix/chapter2_sec2
  • Loading branch information
mathsuky authored Jul 13, 2024
2 parents 4941ab1 + a145de0 commit 10dbc0e
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/chapter2/section2/0_router-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Vue Router を読み込むように`src/main.ts`を以下のように変更し

<<<@/chapter2/section2/src/1/routes.ts{typescript:line-numbers}

この後、皆さんにはいくつかのページとその`path`の対応を追加してもらうわけですが、どの`path`にもマッチしなかった場合、任意の`path`にマッチする`/:path(.*)`がマッチし、NotFound ページが表示されます。
この後、皆さんにはいくつかのページとその`path`の対応を追加してもらうわけですが、どの`path`にもマッチしなかった場合、任意の`path`にマッチする`/:path(.*)*`がマッチし、NotFound ページが表示されます。

`src/pages/NotFound.vue`を以下の内容で作成してください。

Expand Down
4 changes: 4 additions & 0 deletions docs/chapter2/section2/2_fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

<<<@/chapter2/section2/src/2/router.ts{typescript:line-numbers}

また併せて、`src/App.vue`にリンクを追加します。

<<<@/chapter2/section2/src/2/App.vue{vue:line-numbers}

`http://localhost:5173/ping`にアクセスすると以下のような画面が表示されれば OK です。

![](images/2/ping.png)
Expand Down
2 changes: 1 addition & 1 deletion docs/chapter2/section2/src/1/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import NotFound from './pages/NotFound.vue'

const routes = [
{ path: '/', name: 'home', component: HomePage },
{ path: '/:path(.*)', component: NotFound }
{ path: '/:path(.*)*', component: NotFound }
]

const router = createRouter({
Expand Down
2 changes: 1 addition & 1 deletion docs/chapter2/section2/src/1/routes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const routes = [
{ path: '/', name: 'home', component: HomePage },
{ path: '/:path(.*)', component: NotFound }
{ path: '/:path(.*)*', component: NotFound }
]
2 changes: 1 addition & 1 deletion docs/chapter2/section2/src/1/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default defineConfig({
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '/')
rewrite: (path: string) => path.replace(/^\/api/, '/')
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/chapter2/section2/src/2/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PingPage from './pages/PingPage.vue' //[!code ++]
const routes = [
{ path: '/', name: 'home', component: HomePage },
{ path: '/ping', name: 'ping', component: PingPage }, //[!code ++]
{ path: '/:path(.*)', component: NotFound }
{ path: '/:path(.*)*', component: NotFound }
]

const router = createRouter({
Expand Down
2 changes: 1 addition & 1 deletion docs/chapter2/section2/src/2/router_2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const routes = [
{ path: '/', name: 'home', component: HomePage },
{ path: '/ping', name: 'ping', component: PingPage },
{ path: '/login', name: 'login', component: LoginPage }, //[!code ++]
{ path: '/:path(.*)', component: NotFound }
{ path: '/:path(.*)*', component: NotFound }
]

const router = createRouter({
Expand Down
2 changes: 1 addition & 1 deletion docs/chapter2/section2/src/2/router_3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const routes = [
{ path: '/ping', name: 'ping', component: PingPage },
{ path: '/login', name: 'login', component: LoginPage },
{ path: '/city/:cityName', name: 'city', component: CityPage, props: true }, //[!code ++]
{ path: '/:path(.*)', component: NotFound }
{ path: '/:path(.*)*', component: NotFound }
]

const router = createRouter({
Expand Down
2 changes: 1 addition & 1 deletion docs/chapter2/section2/src/2/router_4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const routes = [
{ path: '/ping', name: 'ping', component: PingPage },
{ path: '/login', name: 'login', component: LoginPage },
{ path: '/city/:cityName', name: 'city', component: CityPage, props: true },
{ path: '/:path(.*)', component: NotFound }
{ path: '/:path(.*)*', component: NotFound }
]

const router = createRouter({
Expand Down
4 changes: 2 additions & 2 deletions docs/chapter2/section2/src/2/router_5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import CityPage from './pages/CityPage.vue'

const routes = [
{ path: '/', name: 'home', component: HomePage, meta: { isPublic: true } },
{ path: '/ping', name: 'ping', component: PingPage },
{ path: '/ping', name: 'ping', component: PingPage, meta: { isPublic: true } },
{
path: '/login',
name: 'login',
component: LoginPage,
meta: { isPublic: true }
},
{ path: '/city/:cityName', name: 'city', component: CityPage, props: true },
{ path: '/:path(.*)', component: NotFound, meta: { isPublic: true } }
{ path: '/:path(.*)*', component: NotFound, meta: { isPublic: true } }
]

const router = createRouter({
Expand Down

0 comments on commit 10dbc0e

Please sign in to comment.