From 274cf1af1c4aaa41a01784920115f5cec5923fe3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 3 Oct 2018 02:57:31 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=86=E3=83=BC=E3=83=9E=E9=96=A2=E9=80=A3?= =?UTF-8?q?=E3=81=AE=E6=A9=9F=E8=83=BD=E3=82=92=E5=BC=B7=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/ja-JP.yml | 3 ++ .../app/common/views/components/theme.vue | 41 ++++++++++++++++--- .../app/common/views/components/ui/button.vue | 18 ++++++-- 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 1453f1b0bb..65f72eced1 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -311,6 +311,9 @@ common/views/components/theme.vue: uninstalled: "「{}」をアンインストールしました" author: "作者" desc: "説明" + export: "エクスポート" + import: "インポート" + import-by-code: "またはコードをペースト" common/views/components/cw-button.vue: hide: "隠す" 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({