diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml
index 1453f1b0b..65f72eced 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 5cc779ee8..39d8e8aa9 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%
+ install(this.installThemeCode)">%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({