From 33e79e4bb88ea047001b656d75fe63aa2bdcf4cb Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 12 Nov 2018 05:35:09 +0900 Subject: [PATCH] [Client] Split some components to reduce bundle size --- src/client/app/common/views/components/index.ts | 4 ---- .../views/components/choose-file-from-drive-window.vue | 5 ++++- .../views/components/choose-folder-from-drive-window.vue | 5 ++++- src/client/app/desktop/views/components/drive-window.vue | 5 ++++- src/client/app/desktop/views/components/index.ts | 2 -- .../desktop/views/components/messaging-room-window.vue | 5 ++++- .../app/desktop/views/components/messaging-window.vue | 5 ++++- src/client/app/desktop/views/pages/deck/deck.vue | 9 +++------ src/client/app/desktop/views/pages/drive.vue | 5 ++++- src/client/app/desktop/views/pages/messaging-room.vue | 5 ++++- src/client/app/desktop/views/pages/selectdrive.vue | 5 ++++- src/client/app/desktop/views/widgets/messaging.vue | 5 ++++- .../app/mobile/views/components/drive-file-chooser.vue | 5 ++++- .../app/mobile/views/components/drive-folder-chooser.vue | 5 ++++- src/client/app/mobile/views/components/index.ts | 2 -- src/client/app/mobile/views/pages/drive.vue | 5 ++++- src/client/app/mobile/views/pages/messaging-room.vue | 5 ++++- src/client/app/mobile/views/pages/messaging.vue | 5 ++++- src/client/app/mobile/views/pages/selectdrive.vue | 5 ++++- 19 files changed, 63 insertions(+), 29 deletions(-) diff --git a/src/client/app/common/views/components/index.ts b/src/client/app/common/views/components/index.ts index 62184c3d13..f6ab63e63a 100644 --- a/src/client/app/common/views/components/index.ts +++ b/src/client/app/common/views/components/index.ts @@ -32,8 +32,6 @@ import mediaList from './media-list.vue'; import uploader from './uploader.vue'; import streamIndicator from './stream-indicator.vue'; import ellipsis from './ellipsis.vue'; -import messaging from './messaging.vue'; -import messagingRoom from './messaging-room.vue'; import urlPreview from './url-preview.vue'; import twitterSetting from './twitter-setting.vue'; import githubSetting from './github-setting.vue'; @@ -85,8 +83,6 @@ Vue.component('mk-media-list', mediaList); Vue.component('mk-uploader', uploader); Vue.component('mk-stream-indicator', streamIndicator); Vue.component('mk-ellipsis', ellipsis); -Vue.component('mk-messaging', messaging); -Vue.component('mk-messaging-room', messagingRoom); Vue.component('mk-url-preview', urlPreview); Vue.component('mk-twitter-setting', twitterSetting); Vue.component('mk-github-setting', githubSetting); diff --git a/src/client/app/desktop/views/components/choose-file-from-drive-window.vue b/src/client/app/desktop/views/components/choose-file-from-drive-window.vue index 401a903c8a..8aa7fe1674 100644 --- a/src/client/app/desktop/views/components/choose-file-from-drive-window.vue +++ b/src/client/app/desktop/views/components/choose-file-from-drive-window.vue @@ -5,7 +5,7 @@ ({{ $t('chosen-files', { count: files.length }) }}) - import('./drive.vue').then(m => m.default), + }, props: { multiple: { default: false diff --git a/src/client/app/desktop/views/components/choose-folder-from-drive-window.vue b/src/client/app/desktop/views/components/choose-folder-from-drive-window.vue index 6c19480d90..e5ea7bea1e 100644 --- a/src/client/app/desktop/views/components/choose-folder-from-drive-window.vue +++ b/src/client/app/desktop/views/components/choose-folder-from-drive-window.vue @@ -4,7 +4,7 @@ {{ $t('choose-prompt') }} - import('./drive.vue').then(m => m.default), + }, methods: { ok() { this.$emit('selected', (this.$refs.browser as any).folder); diff --git a/src/client/app/desktop/views/components/drive-window.vue b/src/client/app/desktop/views/components/drive-window.vue index 1318762cbe..be828f53c7 100644 --- a/src/client/app/desktop/views/components/drive-window.vue +++ b/src/client/app/desktop/views/components/drive-window.vue @@ -4,7 +4,7 @@

{{ usage.toFixed(1) }}% {{ $t('used') }}

{{ $t('@.drive') }} - + @@ -15,6 +15,9 @@ import { url } from '../../../config'; export default Vue.extend({ i18n: i18n('desktop/views/components/drive-window.vue'), + components: { + XDrive: () => import('./drive.vue').then(m => m.default), + }, props: ['folder'], data() { return { diff --git a/src/client/app/desktop/views/components/index.ts b/src/client/app/desktop/views/components/index.ts index 2478f75ac4..6d516c118a 100644 --- a/src/client/app/desktop/views/components/index.ts +++ b/src/client/app/desktop/views/components/index.ts @@ -16,7 +16,6 @@ import noteForm from './post-form.vue'; import renoteForm from './renote-form.vue'; import followButton from './follow-button.vue'; import notePreview from './note-preview.vue'; -import drive from './drive.vue'; import noteDetail from './note-detail.vue'; import settings from './settings.vue'; import calendar from './calendar.vue'; @@ -42,7 +41,6 @@ Vue.component('mk-post-form', noteForm); Vue.component('mk-renote-form', renoteForm); Vue.component('mk-follow-button', followButton); Vue.component('mk-note-preview', notePreview); -Vue.component('mk-drive', drive); Vue.component('mk-note-detail', noteDetail); Vue.component('mk-settings', settings); Vue.component('mk-calendar', calendar); diff --git a/src/client/app/desktop/views/components/messaging-room-window.vue b/src/client/app/desktop/views/components/messaging-room-window.vue index 90d67414ba..c1d310b8dd 100644 --- a/src/client/app/desktop/views/components/messaging-room-window.vue +++ b/src/client/app/desktop/views/components/messaging-room-window.vue @@ -1,7 +1,7 @@ @@ -13,6 +13,9 @@ import getAcct from '../../../../../misc/acct/render'; export default Vue.extend({ i18n: i18n('desktop/views/components/messaging-room-window.vue'), + components: { + XMessagingRoom: () => import('../../../common/views/components/messaging-room.vue').then(m => m.default) + }, props: ['user'], computed: { popout(): string { diff --git a/src/client/app/desktop/views/components/messaging-window.vue b/src/client/app/desktop/views/components/messaging-window.vue index 68a04c772a..9b79fcb327 100644 --- a/src/client/app/desktop/views/components/messaging-window.vue +++ b/src/client/app/desktop/views/components/messaging-window.vue @@ -1,7 +1,7 @@ @@ -12,6 +12,9 @@ import MkMessagingRoomWindow from './messaging-room-window.vue'; export default Vue.extend({ i18n: i18n('desktop/views/components/messaging-window.vue'), + components: { + XMessaging: () => import('../../../common/views/components/messaging.vue').then(m => m.default) + }, methods: { navigate(user) { this.$root.new(MkMessagingRoomWindow, { diff --git a/src/client/app/desktop/views/pages/deck/deck.vue b/src/client/app/desktop/views/pages/deck/deck.vue index ea204d0fc0..533cec8130 100644 --- a/src/client/app/desktop/views/pages/deck/deck.vue +++ b/src/client/app/desktop/views/pages/deck/deck.vue @@ -25,9 +25,6 @@ import i18n from '../../../../i18n'; import XColumnCore from './deck.column-core.vue'; import Menu from '../../../../common/views/components/menu.vue'; import MkUserListsWindow from '../../components/user-lists-window.vue'; -import XUserColumn from './deck.user-column.vue'; -import XNoteColumn from './deck.note-column.vue'; -import XHashtagColumn from './deck.hashtag-column.vue'; import * as uuid from 'uuid'; @@ -35,9 +32,9 @@ export default Vue.extend({ i18n: i18n('deck'), components: { XColumnCore, - XUserColumn, - XNoteColumn, - XHashtagColumn + XUserColumn: () => import('./deck.user-column.vue').then(m => m.default), + XNoteColumn: () => import('./deck.note-column.vue').then(m => m.default), + XHashtagColumn: () => import('./deck.hashtag-column.vue').then(m => m.default) }, computed: { diff --git a/src/client/app/desktop/views/pages/drive.vue b/src/client/app/desktop/views/pages/drive.vue index 46a3333c79..2916569a5f 100644 --- a/src/client/app/desktop/views/pages/drive.vue +++ b/src/client/app/desktop/views/pages/drive.vue @@ -1,6 +1,6 @@ @@ -10,6 +10,9 @@ import i18n from '../../../i18n'; export default Vue.extend({ i18n: i18n('desktop/views/pages/drive.vue'), + components: { + XDrive: () => import('../components/drive.vue').then(m => m.default), + }, data() { return { folder: null diff --git a/src/client/app/desktop/views/pages/messaging-room.vue b/src/client/app/desktop/views/pages/messaging-room.vue index 8bb3976e5f..5bc28947cb 100644 --- a/src/client/app/desktop/views/pages/messaging-room.vue +++ b/src/client/app/desktop/views/pages/messaging-room.vue @@ -1,6 +1,6 @@ @@ -13,6 +13,9 @@ import getUserName from '../../../../../misc/get-user-name'; export default Vue.extend({ i18n: i18n('.vue'), + components: { + XMessagingRoom: () => import('../../../common/views/components/messaging-room.vue').then(m => m.default) + }, data() { return { fetching: true, diff --git a/src/client/app/desktop/views/pages/selectdrive.vue b/src/client/app/desktop/views/pages/selectdrive.vue index 422acb9890..7e6a8e1937 100644 --- a/src/client/app/desktop/views/pages/selectdrive.vue +++ b/src/client/app/desktop/views/pages/selectdrive.vue @@ -1,6 +1,6 @@ @@ -22,6 +22,9 @@ export default define({ }) }).extend({ i18n: i18n('desktop/views/widgets/messaging.vue'), + components: { + XMessaging: () => import('../../../common/views/components/messaging.vue').then(m => m.default) + }, methods: { navigate(user) { this.$root.new(MkMessagingRoomWindow, { diff --git a/src/client/app/mobile/views/components/drive-file-chooser.vue b/src/client/app/mobile/views/components/drive-file-chooser.vue index 92919c73c0..b72c796c1d 100644 --- a/src/client/app/mobile/views/components/drive-file-chooser.vue +++ b/src/client/app/mobile/views/components/drive-file-chooser.vue @@ -6,7 +6,7 @@ - import('./drive.vue').then(m => m.default), + }, props: ['multiple'], data() { return { diff --git a/src/client/app/mobile/views/components/drive-folder-chooser.vue b/src/client/app/mobile/views/components/drive-folder-chooser.vue index 4d08679624..250a7aca2c 100644 --- a/src/client/app/mobile/views/components/drive-folder-chooser.vue +++ b/src/client/app/mobile/views/components/drive-folder-chooser.vue @@ -6,7 +6,7 @@ - @@ -18,6 +18,9 @@ import Vue from 'vue'; import i18n from '../../../i18n'; export default Vue.extend({ i18n: i18n('mobile/views/components/drive-folder-chooser.vue'), + components: { + XDrive: () => import('./drive.vue').then(m => m.default), + }, methods: { cancel() { this.$emit('canceled'); diff --git a/src/client/app/mobile/views/components/index.ts b/src/client/app/mobile/views/components/index.ts index 38c130ecbf..5e9640bf01 100644 --- a/src/client/app/mobile/views/components/index.ts +++ b/src/client/app/mobile/views/components/index.ts @@ -5,7 +5,6 @@ import note from './note.vue'; import notes from './notes.vue'; import mediaImage from './media-image.vue'; import mediaVideo from './media-video.vue'; -import drive from './drive.vue'; import notePreview from './note-preview.vue'; import subNoteContent from './sub-note-content.vue'; import noteCard from './note-card.vue'; @@ -29,7 +28,6 @@ Vue.component('mk-note', note); Vue.component('mk-notes', notes); Vue.component('mk-media-image', mediaImage); Vue.component('mk-media-video', mediaVideo); -Vue.component('mk-drive', drive); Vue.component('mk-note-preview', notePreview); Vue.component('mk-sub-note-content', subNoteContent); Vue.component('mk-note-card', noteCard); diff --git a/src/client/app/mobile/views/pages/drive.vue b/src/client/app/mobile/views/pages/drive.vue index e5085d2aa1..2aca540506 100644 --- a/src/client/app/mobile/views/pages/drive.vue +++ b/src/client/app/mobile/views/pages/drive.vue @@ -6,7 +6,7 @@ - import('../components/drive.vue').then(m => m.default), + }, data() { return { Progress, diff --git a/src/client/app/mobile/views/pages/messaging-room.vue b/src/client/app/mobile/views/pages/messaging-room.vue index 2bd506b6a6..648a5d72e9 100644 --- a/src/client/app/mobile/views/pages/messaging-room.vue +++ b/src/client/app/mobile/views/pages/messaging-room.vue @@ -4,7 +4,7 @@ - + @@ -15,6 +15,9 @@ import parseAcct from '../../../../../misc/acct/parse'; export default Vue.extend({ i18n: i18n(), + components: { + XMessagingRoom: () => import('../../../common/views/components/messaging-room.vue').then(m => m.default) + }, data() { return { fetching: true, diff --git a/src/client/app/mobile/views/pages/messaging.vue b/src/client/app/mobile/views/pages/messaging.vue index 9af5d1cd1e..918f925f3a 100644 --- a/src/client/app/mobile/views/pages/messaging.vue +++ b/src/client/app/mobile/views/pages/messaging.vue @@ -1,7 +1,7 @@ @@ -12,6 +12,9 @@ import getAcct from '../../../../../misc/acct/render'; export default Vue.extend({ i18n: i18n(), + components: { + XMessaging: () => import('../../../common/views/components/messaging.vue').then(m => m.default) + }, mounted() { document.title = `${this.$root.instanceName} ${this.$t('@.messaging')}`; }, diff --git a/src/client/app/mobile/views/pages/selectdrive.vue b/src/client/app/mobile/views/pages/selectdrive.vue index 633c83e40d..095c19cf2c 100644 --- a/src/client/app/mobile/views/pages/selectdrive.vue +++ b/src/client/app/mobile/views/pages/selectdrive.vue @@ -5,7 +5,7 @@ - + @@ -15,6 +15,9 @@ import i18n from '../../../i18n'; export default Vue.extend({ i18n: i18n('mobile/views/pages/selectdrive.vue'), + components: { + XDrive: () => import('../components/drive.vue').then(m => m.default), + }, data() { return { files: []