From 274cf1af1c4aaa41a01784920115f5cec5923fe3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 3 Oct 2018 02:57:31 +0900 Subject: テーマ関連の機能を強化 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/app/common/views/components/theme.vue | 41 +++++++++++++++++++--- .../app/common/views/components/ui/button.vue | 18 +++++++--- 2 files changed, 50 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/client/app/common/views/components/theme.vue b/src/client/app/common/views/components/theme.vue index 5cc779ee8e..39d8e8aa97 100644 --- a/src/client/app/common/views/components/theme.vue +++ b/src/client/app/common/views/components/theme.vue @@ -44,10 +44,13 @@
%fa:download% %i18n:@install-a-theme% + %fa:file-import% %i18n:@import% + +

%i18n:@import-by-code%:

%i18n:@theme-code% - %fa:check% %i18n:@install% + %fa:check% %i18n:@install%
@@ -65,6 +68,7 @@ %i18n:@theme-code% + %fa:box% %i18n:@export% %fa:trash-alt R% %i18n:@uninstall%
@@ -177,11 +181,11 @@ export default Vue.extend({ }, methods: { - install() { + install(code) { let theme; try { - theme = JSON5.parse(this.installThemeCode); + theme = JSON5.parse(code); } catch (e) { alert('%i18n:@invalid-theme%'); return; @@ -219,6 +223,29 @@ export default Vue.extend({ alert('%i18n:@uninstalled%'.replace('{}', theme.name)); }, + import_() { + (this.$refs.file as any).click(); + } + + export_() { + const blob = new Blob([this.selectedInstalledThemeCode], { + type: 'application/json5' + }); + this.$refs.export.$el.href = window.URL.createObjectURL(blob); + }, + + onUpdateImportFile() { + const f = (this.$refs.file as any).files[0]; + + const reader = new FileReader(); + + reader.onload = e => { + this.install(e.target.result); + }; + + reader.readAsText(f); + }, + preview() { applyTheme(this.myTheme, false); }, @@ -239,10 +266,14 @@ export default Vue.extend({