From a2300900be389d71d4efffcdc49cbf6eff76c809 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 13 Jan 2019 18:06:29 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20Pr?= =?UTF-8?q?ogressPage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/api/reader.js | 2 +- .../Reader/LoaderPage/LoaderPage.vue | 28 +++--- .../Reader/ProgressPage/ProgressPage.vue | 93 +++++++++++++++++++ .../components/Reader/TextPage/TextPage.vue | 2 - client/element.js | 5 +- 5 files changed, 113 insertions(+), 17 deletions(-) create mode 100644 client/components/Reader/ProgressPage/ProgressPage.vue diff --git a/client/api/reader.js b/client/api/reader.js index c8ce80a3..0254893e 100644 --- a/client/api/reader.js +++ b/client/api/reader.js @@ -29,7 +29,7 @@ class Reader { if (callback) callback(Object.assign({}, response.data, - {state: 'loading', stage: 4, progress: Math.round((progress.loaded*100)/progress.total)} + {state: 'loading', step: 4, progress: Math.round((progress.loaded*100)/progress.total)} )); } } diff --git a/client/components/Reader/LoaderPage/LoaderPage.vue b/client/components/Reader/LoaderPage/LoaderPage.vue index 2352c9a1..c3fff633 100644 --- a/client/components/Reader/LoaderPage/LoaderPage.vue +++ b/client/components/Reader/LoaderPage/LoaderPage.vue @@ -19,6 +19,7 @@ Справка {{ version }} + @@ -27,12 +28,17 @@ import Vue from 'vue'; import Component from 'vue-class-component'; +import ProgressPage from '../ProgressPage/ProgressPage.vue'; import readerApi from '../../../api/reader'; export default @Component({ + components: { + ProgressPage + } }) class LoaderPage extends Vue { bookUrl = null; + loadPercent = 0; created() { this.commit = this.$store.commit; @@ -40,6 +46,10 @@ class LoaderPage extends Vue { this.config = this.$store.state.config; } + mounted() { + this.progress = this.$refs.progress; + } + activated() { this.$refs.input.focus(); } @@ -57,15 +67,15 @@ class LoaderPage extends Vue { async submitUrl() { if (this.bookUrl) { - const loading = this.$loading({target: this.$refs.main, customClass: 'loading'}); + this.progress.show(); + this.progress.setState({totalSteps: 4}); try { const book = await readerApi.loadBook(this.bookUrl, (state) => { - const progress = state.progress || 0; - loading.text = `${state.state} ${progress}%`; + this.progress.setState(state); }); - loading.close(); + this.progress.hide(); } catch (e) { - loading.close(); + this.progress.hide(); this.$alert(e.message, 'Ошибка', {type: 'error'}); } } @@ -89,14 +99,6 @@ class LoaderPage extends Vue { } //----------------------------------------------------------------------------- - + diff --git a/client/components/Reader/TextPage/TextPage.vue b/client/components/Reader/TextPage/TextPage.vue index f4bc4fb0..0eda2e94 100644 --- a/client/components/Reader/TextPage/TextPage.vue +++ b/client/components/Reader/TextPage/TextPage.vue @@ -12,8 +12,6 @@ import Component from 'vue-class-component'; export default @Component({ }) class TextPage extends Vue { - bookUrl = null; - created() { this.commit = this.$store.commit; this.dispatch = this.$store.dispatch; diff --git a/client/element.js b/client/element.js index 69c2e085..5e52af32 100644 --- a/client/element.js +++ b/client/element.js @@ -50,6 +50,9 @@ import './theme/main.css'; import ElInput from 'element-ui/lib/input'; import './theme/input.css'; +import ElProgress from 'element-ui/lib/progress'; +import './theme/progress.css'; + import Notification from 'element-ui/lib/notification'; import './theme/notification.css'; @@ -62,7 +65,7 @@ import './theme/message-box.css'; const components = { ElMenu, ElMenuItem, ElButton, ElCheckbox, ElTabs, ElTabPane, ElTooltip, ElContainer, ElAside, ElMain, ElHeader, - ElInput + ElInput, ElProgress }; for (let [name, comp] of Object.entries(components)) {