From efd4fbad7018e5648e650278660cc8e18319380d Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 25 Feb 2020 21:07:12 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=BD=D0=B0=20quasar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reader/SettingsPage/SettingsPage.vue | 13 ++--- client/components/share/StdDialog.vue | 55 ++++++++++++++++++- 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/client/components/Reader/SettingsPage/SettingsPage.vue b/client/components/Reader/SettingsPage/SettingsPage.vue index 5615c3ec..5a228f45 100644 --- a/client/components/Reader/SettingsPage/SettingsPage.vue +++ b/client/components/Reader/SettingsPage/SettingsPage.vue @@ -472,20 +472,15 @@ class SettingsPage extends Vue { async enterServerStorageKey(key) { try { - const result = await this.$prompt(`Предупреждение! Изменение ключа доступа приведет к замене всех профилей и читаемых книг в читалке.` + - `

Введите новый ключ доступа:`, '', { - dangerouslyUseHTMLString: true, - confirmButtonText: 'OK', - cancelButtonText: 'Отмена', + const result = await this.stdDialog.prompt(`Предупреждение! Изменение ключа доступа приведет к замене всех профилей и читаемых книг в читалке.` + + `

Введите новый ключ доступа:`, ' ', { inputValidator: (str) => { if (str && utils.fromBase58(str).length == 32) return true; else return 'Неверный формат ключа'; }, inputValue: (key && _.isString(key) ? key : null), - customClass: 'prompt-dialog', - type: 'warning', }); - +/* if (result.value && utils.fromBase58(result.value).length == 32) { this.commit('reader/setServerStorageKey', result.value); - } + }*/ } catch (e) { // } diff --git a/client/components/share/StdDialog.vue b/client/components/share/StdDialog.vue index 9abdff6c..9fbdd830 100644 --- a/client/components/share/StdDialog.vue +++ b/client/components/share/StdDialog.vue @@ -1,7 +1,8 @@ @@ -63,6 +90,7 @@ class StdDialog extends Vue { message = ''; active = false; type = ''; + inputValue = ''; created() { if (this.$root.addKeyHook) { @@ -85,6 +113,12 @@ class StdDialog extends Vue { } } + onShow() { + if (this.type == 'prompt') { + this.$refs.input.focus(); + } + } + okClick() { this.ok = true; } @@ -123,6 +157,25 @@ class StdDialog extends Vue { }); } + prompt(message, caption, opts) { + return new Promise((resolve) => { + this.init(message, caption); + + this.hideTrigger = () => { + if (this.ok) { + resolve(true); + } else { + resolve(false); + } + }; + + this.type = 'prompt'; + this.inputValue = opts.inputValue || ''; + this.inputValidator = opts.inputValidator || null; + this.active = true; + }); + } + keyHook(event) { if (this.active && event.code == 'Enter') { this.okClick();