diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 6326094dd..5754ed2bf 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -559,6 +559,8 @@ author: "作者" leaveConfirm: "未保存の変更があります。破棄しますか?" manage: "管理" plugins: "プラグイン" +preferencesRegistry: "クライアント設定のレジストリ" +preferencesRegistryShort: "レジストリ" deck: "デッキ" undeck: "デッキ解除" useBlurEffectForModal: "モーダルにぼかし効果を使用" @@ -894,6 +896,25 @@ _plugin: installWarn: "信頼できないプラグインはインストールしないでください。" manage: "プラグインの管理" +_preferencesRegistry: + list: "一覧" + saveNew: "新規保存" + apply: "適用" + delete: "削除" + save: "上書き保存" + rename: "名称変更" + saveNewDescription: "現在のデバイスの状態をサーバーに保存します。" + inputName: "レジストリ名を入力" + cannotSave: "保存できません" + nameAlreadyExists: "レジストリ名「{name}」は既に存在します。違うレジストリ名を指定してください。" + applyConfirm: "プロファイル「{name}」を現在のデバイスに適用しますか?現在のデバイス設定は失われます。" + saveConfirm: "{name}に上書き保存しますか?" + deleteConfirm: "{name}を削除しますか?" + renameConfirm: "「{old}」を「{new}」に変更しますか?" + noRegistries: "レジストリは登録されていません。「新規保存」で現在のクライアント設定をサーバーに保存できます。" + createdAt: "作成日時: {date} {time}" + updatedAt: "更新日時: {date} {time}" + _registry: scope: "スコープ" key: "キー" diff --git a/packages/client/src/pages/settings/index.vue b/packages/client/src/pages/settings/index.vue index 1838cb73e..752054e9b 100644 --- a/packages/client/src/pages/settings/index.vue +++ b/packages/client/src/pages/settings/index.vue @@ -132,6 +132,11 @@ const menuDef = computed(() => [{ text: i18n.ts.plugins, to: '/settings/plugin', active: props.initialPage === 'plugin', + }, { + icon: 'fas fa-floppy-disk', + text: i18n.ts.preferencesRegistryShort, + to: '/settings/preferences-registry', + active: props.initialPage === 'preferences-registry', }], }, { title: i18n.ts.otherSettings, @@ -225,6 +230,7 @@ const component = computed(() => { case 'deck': return defineAsyncComponent(() => import('./deck.vue')); case 'plugin': return defineAsyncComponent(() => import('./plugin.vue')); case 'plugin/install': return defineAsyncComponent(() => import('./plugin.install.vue')); + case 'preferences-registry': return defineAsyncComponent(() => import('./preferences-registry.vue')); case 'import-export': return defineAsyncComponent(() => import('./import-export.vue')); case 'account-info': return defineAsyncComponent(() => import('./account-info.vue')); case 'delete-account': return defineAsyncComponent(() => import('./delete-account.vue')); diff --git a/packages/client/src/pages/settings/preferences-registry.vue b/packages/client/src/pages/settings/preferences-registry.vue new file mode 100644 index 000000000..d66815004 --- /dev/null +++ b/packages/client/src/pages/settings/preferences-registry.vue @@ -0,0 +1,278 @@ + + + {{ ts._preferencesRegistry.saveNew }} + + + {{ ts._preferencesRegistry.list }} + menu($event, id)" + @contextmenu.prevent.stop="$event => menu($event, id)" + > + {{ registry.name }} + {{ t('_preferencesRegistry.createdAt', { date: (new Date(registry.createdAt)).toLocaleDateString(), time: (new Date(registry.createdAt)).toLocaleTimeString() }) }} + {{ t('_preferencesRegistry.updatedAt', { date: (new Date(registry.createdAt)).toLocaleDateString(), time: (new Date(registry.createdAt)).toLocaleTimeString() }) }} + + + {{ ts._preferencesRegistry.noRegistries }} + + + + + + + + + diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index b9800ec60..296eaa206 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -286,6 +286,16 @@ export class ColdDeviceStorage { } } + public static getAll(): Partial { + return (Object.keys(this.default) as (keyof typeof this.default)[]).reduce((acc, key) => { + const value = localStorage.getItem(PREFIX + key); + if (value != null) { + acc[key] = JSON.parse(value); + } + return acc; + }, {} as any); + } + public static set(key: T, value: typeof ColdDeviceStorage.default[T]): void { localStorage.setItem(PREFIX + key, JSON.stringify(value));