diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2020-04-04 08:25:28 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2020-04-04 08:25:28 +0900 |
| commit | f2e347fec1053cc47e9d5c2daa8eb34cea645bdd (patch) | |
| tree | 2510a40a3b356bac71944290c7006ee54fae2f6b /src/client/init.ts | |
| parent | Update CHANGELOG.md (diff) | |
| download | sharkey-f2e347fec1053cc47e9d5c2daa8eb34cea645bdd.tar.gz sharkey-f2e347fec1053cc47e9d5c2daa8eb34cea645bdd.tar.bz2 sharkey-f2e347fec1053cc47e9d5c2daa8eb34cea645bdd.zip | |
perf(client): Lazy load themes
Diffstat (limited to 'src/client/init.ts')
| -rw-r--r-- | src/client/init.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/client/init.ts b/src/client/init.ts index c226f29b30..29fc219740 100644 --- a/src/client/init.ts +++ b/src/client/init.ts @@ -18,7 +18,7 @@ import PostFormDialog from './components/post-form-dialog.vue'; import Dialog from './components/dialog.vue'; import Menu from './components/menu.vue'; import { router } from './router'; -import { applyTheme, lightTheme, builtinThemes } from './theme'; +import { applyTheme, lightTheme } from './theme'; import { isDeviceDarkmode } from './scripts/is-device-darkmode'; import createStore from './store'; @@ -149,9 +149,10 @@ os.init(async () => { }, false) store.watch(state => state.device.darkMode, darkMode => { - // TODO: このファイルでbuiltinThemesを参照するとcode splittingが効かず、初回読み込み時に全てのテーマコードを読み込むことになってしまい無駄なので何とかする - const themes = builtinThemes.concat(store.state.device.themes); - applyTheme(themes.find(x => x.id === (darkMode ? store.state.device.darkTheme : store.state.device.lightTheme))); + import('./theme').then(({ builtinThemes }) => { + const themes = builtinThemes.concat(store.state.device.themes); + applyTheme(themes.find(x => x.id === (darkMode ? store.state.device.darkTheme : store.state.device.lightTheme))); + }); }); //#region Sync dark mode |