From cd4c7689b76ec5768a31ffba0c01741133b18050 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 21 May 2019 04:21:43 +0900 Subject: [PATCH] Reduce initial bundle size --- src/client/app/common/views/pages/share.vue | 15 ++++++----- .../app/common/views/widgets/post-form.vue | 3 +-- src/client/app/desktop/script.ts | 9 +++---- .../app/desktop/views/components/index.ts | 4 --- .../views/components/post-form-window.vue | 8 +++++- .../desktop/views/components/post-form.vue | 4 +-- .../desktop/views/components/renote-form.vue | 6 ++++- .../app/desktop/views/home/timeline.vue | 6 +++-- src/client/app/init.ts | 25 ++++++++++++++----- src/client/app/mobile/script.ts | 20 ++++++--------- .../app/mobile/views/components/index.ts | 2 -- .../views/components/post-form-dialog.vue | 7 +++++- .../app/mobile/views/components/post-form.vue | 4 +-- 13 files changed, 67 insertions(+), 46 deletions(-) diff --git a/src/client/app/common/views/pages/share.vue b/src/client/app/common/views/pages/share.vue index 0452b25dfc..293a9bcfb5 100644 --- a/src/client/app/common/views/pages/share.vue +++ b/src/client/app/common/views/pages/share.vue @@ -3,7 +3,7 @@

{{ $t('share-with', { name }) }}

- +

{{ $t('@.close') }} @@ -16,6 +16,9 @@ import i18n from '../../../i18n'; export default Vue.extend({ i18n: i18n('mobile/views/pages/share.vue'), + components: { + XPostForm: () => import('../../../desktop/views/components/post-form.vue').then(m => m.default) + }, data() { return { name: null, @@ -35,15 +38,15 @@ export default Vue.extend({ return t.trim(); } }, - methods: { - close() { - window.close(); - } - }, mounted() { this.$root.getMeta().then(meta => { this.name = meta.name || 'Misskey'; }); + }, + methods: { + close() { + window.close(); + } } }); diff --git a/src/client/app/common/views/widgets/post-form.vue b/src/client/app/common/views/widgets/post-form.vue index d8617bea58..e180290f95 100644 --- a/src/client/app/common/views/widgets/post-form.vue +++ b/src/client/app/common/views/widgets/post-form.vue @@ -38,7 +38,6 @@ import define from '../../../common/define-widget'; import i18n from '../../../i18n'; import insertTextAtCursor from 'insert-text-at-cursor'; -import XPostFormAttaches from '../components/post-form-attaches.vue'; export default define({ name: 'post-form', @@ -49,7 +48,7 @@ export default define({ i18n: i18n('desktop/views/widgets/post-form.vue'), components: { - XPostFormAttaches + XPostFormAttaches: () => import('../components/post-form-attaches.vue').then(m => m.default) }, data() { diff --git a/src/client/app/desktop/script.ts b/src/client/app/desktop/script.ts index eab400d4c6..10b929ff3f 100644 --- a/src/client/app/desktop/script.ts +++ b/src/client/app/desktop/script.ts @@ -13,7 +13,6 @@ import fuckAdBlock from '../common/scripts/fuck-ad-block'; import composeNotification from '../common/scripts/compose-notification'; import MkHome from './views/home/home.vue'; -import MkDeck from '../common/views/deck/deck.vue'; import MkSelectDrive from './views/pages/selectdrive.vue'; import MkDrive from './views/pages/drive.vue'; import MkMessagingRoom from './views/pages/messaging-room.vue'; @@ -25,7 +24,6 @@ import MkSettings from './views/pages/settings.vue'; import DeckColumn from '../common/views/deck/deck.column-template.vue'; import Ctx from './views/components/context-menu.vue'; -import PostFormWindow from './views/components/post-form-window.vue'; import RenoteFormWindow from './views/components/renote-form-window.vue'; import MkChooseFileFromDriveWindow from './views/components/choose-file-from-drive-window.vue'; import MkChooseFolderFromDriveWindow from './views/components/choose-folder-from-drive-window.vue'; @@ -62,12 +60,13 @@ init(async (launch, os) => { }); if (o.cb) vm.$once('closed', o.cb); } else { - const vm = this.$root.new(PostFormWindow, { + this.$root.new(() => import('./views/components/post-form-window.vue').then(m => m.default), { reply: o.reply, mention: o.mention, animation: o.animation == null ? true : o.animation + }).then(vm => { + if (o.cb) vm.$once('closed', o.cb); }); - if (o.cb) vm.$once('closed', o.cb); } }, @@ -129,7 +128,7 @@ init(async (launch, os) => { mode: 'history', routes: [ os.store.state.device.inDeckMode - ? { path: '/', name: 'index', component: MkDeck, children: [ + ? { path: '/', name: 'index', component: () => import('../common/views/deck/deck.vue').then(m => m.default), children: [ { path: '/@:user', component: () => import('../common/views/deck/deck.user-column.vue').then(m => m.default), children: [ { path: '', name: 'user', component: () => import('../common/views/deck/deck.user-column.home.vue').then(m => m.default) }, { path: 'following', component: () => import('../common/views/pages/following.vue').then(m => m.default) }, diff --git a/src/client/app/desktop/views/components/index.ts b/src/client/app/desktop/views/components/index.ts index 76ab7b5fec..0cc44e1bbd 100644 --- a/src/client/app/desktop/views/components/index.ts +++ b/src/client/app/desktop/views/components/index.ts @@ -6,11 +6,9 @@ import note from './note.vue'; import notes from './notes.vue'; import subNoteContent from './sub-note-content.vue'; import window from './window.vue'; -import noteFormWindow from './post-form-window.vue'; import renoteFormWindow from './renote-form-window.vue'; import mediaVideo from './media-video.vue'; import notifications from './notifications.vue'; -import noteForm from './post-form.vue'; import renoteForm from './renote-form.vue'; import notePreview from './note-preview.vue'; import noteDetail from './note-detail.vue'; @@ -25,11 +23,9 @@ Vue.component('mk-note', note); Vue.component('mk-notes', notes); Vue.component('mk-sub-note-content', subNoteContent); Vue.component('mk-window', window); -Vue.component('mk-post-form-window', noteFormWindow); Vue.component('mk-renote-form-window', renoteFormWindow); Vue.component('mk-media-video', mediaVideo); Vue.component('mk-notifications', notifications); -Vue.component('mk-post-form', noteForm); Vue.component('mk-renote-form', renoteForm); Vue.component('mk-note-preview', notePreview); Vue.component('mk-note-detail', noteDetail); diff --git a/src/client/app/desktop/views/components/post-form-window.vue b/src/client/app/desktop/views/components/post-form-window.vue index 1d718bef15..ae5f0af71d 100644 --- a/src/client/app/desktop/views/components/post-form-window.vue +++ b/src/client/app/desktop/views/components/post-form-window.vue @@ -12,7 +12,7 @@
- import Vue from 'vue'; import i18n from '../../../i18n'; +import XPostForm from './post-form.vue'; export default Vue.extend({ i18n: i18n('desktop/views/components/post-form-window.vue'), + + components: { + XPostForm + }, + props: { reply: { type: Object, diff --git a/src/client/app/desktop/views/components/post-form.vue b/src/client/app/desktop/views/components/post-form.vue index e0e2db1708..64652e0eb9 100644 --- a/src/client/app/desktop/views/components/post-form.vue +++ b/src/client/app/desktop/views/components/post-form.vue @@ -1,5 +1,5 @@