From 04f9147db6c0b3aff3347a62659f3dfb21fc3f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8A=E3=81=95=E3=82=80=E3=81=AE=E3=81=B2=E3=81=A8?= <46447427+samunohito@users.noreply.github.com> Date: Mon, 8 Jan 2024 14:44:43 +0900 Subject: [PATCH] =?UTF-8?q?refactor(frontend):=20router.ts=E8=A7=A3?= =?UTF-8?q?=E3=81=8D=E3=81=BB=E3=81=90=E3=81=97=20=20(#12907)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor(frontend): router.ts解きほぐし * add debug hmr option * fix comment * fix not working * add comment * fix name * Update definition.ts --------- Co-authored-by: syuilo --- packages/frontend/package.json | 2 +- packages/frontend/src/boot/common.ts | 3 + packages/frontend/src/boot/main-boot.ts | 10 +- .../frontend/src/components/MkDrive.file.vue | 2 +- .../frontend/src/components/MkPageWindow.vue | 33 +- .../frontend/src/components/global/MkA.vue | 2 +- .../src/components/global/RouterView.vue | 6 +- .../frontend/src/global/router/definition.ts | 571 ++++++++++++++++++ packages/frontend/src/global/router/main.ts | 163 +++++ .../frontend/src/global/router/supplier.ts | 30 + packages/frontend/src/nirax.ts | 126 +++- packages/frontend/src/pages/admin/index.vue | 2 +- .../frontend/src/pages/admin/roles.edit.vue | 2 +- .../frontend/src/pages/admin/roles.role.vue | 2 +- packages/frontend/src/pages/admin/roles.vue | 2 +- .../frontend/src/pages/antenna-timeline.vue | 2 +- .../frontend/src/pages/channel-editor.vue | 2 +- packages/frontend/src/pages/channel.vue | 2 +- packages/frontend/src/pages/channels.vue | 2 +- .../frontend/src/pages/drive.file.info.vue | 2 +- .../frontend/src/pages/flash/flash-edit.vue | 2 +- .../frontend/src/pages/flash/flash-index.vue | 2 +- packages/frontend/src/pages/follow.vue | 2 +- packages/frontend/src/pages/gallery/edit.vue | 2 +- packages/frontend/src/pages/gallery/index.vue | 2 +- packages/frontend/src/pages/gallery/post.vue | 2 +- .../frontend/src/pages/my-antennas/create.vue | 2 +- .../frontend/src/pages/my-antennas/edit.vue | 2 +- packages/frontend/src/pages/my-lists/list.vue | 2 +- .../src/pages/page-editor/page-editor.vue | 2 +- packages/frontend/src/pages/pages.vue | 2 +- .../frontend/src/pages/reset-password.vue | 2 +- packages/frontend/src/pages/search.note.vue | 2 +- packages/frontend/src/pages/search.user.vue | 2 +- .../frontend/src/pages/settings/index.vue | 2 +- .../src/pages/settings/webhook.edit.vue | 2 +- .../frontend/src/pages/user-list-timeline.vue | 2 +- packages/frontend/src/pages/user/home.vue | 2 +- packages/frontend/src/router.ts | 561 ----------------- .../frontend/src/scripts/get-user-menu.ts | 6 +- packages/frontend/src/scripts/lookup.ts | 2 +- .../frontend/src/ui/_common_/sw-inject.ts | 2 +- packages/frontend/src/ui/classic.vue | 2 +- packages/frontend/src/ui/deck.vue | 2 +- packages/frontend/src/ui/deck/main-column.vue | 2 +- packages/frontend/src/ui/minimum.vue | 2 +- packages/frontend/src/ui/universal.vue | 2 +- packages/frontend/src/ui/visitor.vue | 2 +- packages/frontend/src/ui/zen.vue | 2 +- 49 files changed, 937 insertions(+), 650 deletions(-) create mode 100644 packages/frontend/src/global/router/definition.ts create mode 100644 packages/frontend/src/global/router/main.ts create mode 100644 packages/frontend/src/global/router/supplier.ts delete mode 100644 packages/frontend/src/router.ts diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 7e7559d82..9ef18a56a 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -4,7 +4,7 @@ "type": "module", "scripts": { "watch": "vite", - "dev": "vite --config vite.config.local-dev.ts", + "dev": "vite --config vite.config.local-dev.ts --debug hmr", "build": "vite build", "storybook-dev": "nodemon --verbose --watch src --ext \"mdx,ts,vue\" --ignore \"*.stories.ts\" --exec \"pnpm build-storybook-pre && pnpm exec storybook dev -p 6006 --ci\"", "build-storybook-pre": "(tsc -p .storybook || echo done.) && node .storybook/generate.js && node .storybook/preload-locale.js && node .storybook/preload-theme.js", diff --git a/packages/frontend/src/boot/common.ts b/packages/frontend/src/boot/common.ts index ef69eff76..c67911c9c 100644 --- a/packages/frontend/src/boot/common.ts +++ b/packages/frontend/src/boot/common.ts @@ -22,6 +22,7 @@ import { getAccountFromId } from '@/scripts/get-account-from-id.js'; import { deckStore } from '@/ui/deck/deck-store.js'; import { miLocalStorage } from '@/local-storage.js'; import { fetchCustomEmojis } from '@/custom-emojis.js'; +import { setupRouter } from '@/global/router/definition.js'; export async function common(createVue: () => App) { console.info(`Misskey v${version}`); @@ -241,6 +242,8 @@ export async function common(createVue: () => App) { const app = createVue(); + setupRouter(app); + if (_DEV_) { app.config.performance = true; } diff --git a/packages/frontend/src/boot/main-boot.ts b/packages/frontend/src/boot/main-boot.ts index 0159d0c03..5011ce9e7 100644 --- a/packages/frontend/src/boot/main-boot.ts +++ b/packages/frontend/src/boot/main-boot.ts @@ -3,23 +3,23 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { createApp, markRaw, defineAsyncComponent } from 'vue'; +import { createApp, defineAsyncComponent, markRaw } from 'vue'; import { common } from './common.js'; import { ui } from '@/config.js'; import { i18n } from '@/i18n.js'; -import { confirm, alert, post, popup, toast } from '@/os.js'; +import { alert, confirm, popup, post, toast } from '@/os.js'; import { useStream } from '@/stream.js'; import * as sound from '@/scripts/sound.js'; -import { $i, updateAccount, signout } from '@/account.js'; -import { defaultStore, ColdDeviceStorage } from '@/store.js'; +import { $i, signout, updateAccount } from '@/account.js'; +import { ColdDeviceStorage, defaultStore } from '@/store.js'; import { makeHotkey } from '@/scripts/hotkey.js'; import { reactionPicker } from '@/scripts/reaction-picker.js'; import { miLocalStorage } from '@/local-storage.js'; import { claimAchievement, claimedAchievements } from '@/scripts/achievements.js'; -import { mainRouter } from '@/router.js'; import { initializeSw } from '@/scripts/initialize-sw.js'; import { deckStore } from '@/ui/deck/deck-store.js'; import { emojiPicker } from '@/scripts/emoji-picker.js'; +import { mainRouter } from '@/global/router/main.js'; export async function mainBoot() { const { isClientUpdated } = await common(() => createApp( diff --git a/packages/frontend/src/components/MkDrive.file.vue b/packages/frontend/src/components/MkDrive.file.vue index b46b25eba..8a74319f2 100644 --- a/packages/frontend/src/components/MkDrive.file.vue +++ b/packages/frontend/src/components/MkDrive.file.vue @@ -45,9 +45,9 @@ import bytes from '@/filters/bytes.js'; import * as os from '@/os.js'; import { i18n } from '@/i18n.js'; import { $i } from '@/account.js'; -import { useRouter } from '@/router.js'; import { getDriveFileMenu } from '@/scripts/get-drive-file-menu.js'; import { deviceKind } from '@/scripts/device-kind.js'; +import { useRouter } from '@/global/router/supplier.js'; const router = useRouter(); diff --git a/packages/frontend/src/components/MkPageWindow.vue b/packages/frontend/src/components/MkPageWindow.vue index 2647ace7d..28058c338 100644 --- a/packages/frontend/src/components/MkPageWindow.vue +++ b/packages/frontend/src/components/MkPageWindow.vue @@ -23,26 +23,26 @@ SPDX-License-Identifier: AGPL-3.0-only
- +