123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <template>
- <div ref="main" class="main">
- <div class="part">
- <span class="greeting bold-font">{{ title }}</span>
- <span class="greeting">Добро пожаловать!</span>
- <span class="greeting">Поддерживаются форматы: fb2, fb2.zip, html, txt</span>
- </div>
- <div class="part center">
- <el-input ref="input" placeholder="URL книги" v-model="bookUrl">
- <el-button slot="append" icon="el-icon-check" @click="submitUrl"></el-button>
- </el-input>
- <div class="space"></div>
- <el-button size="mini" @click="loadFle">
- Загрузить файл с диска
- </el-button>
- </div>
- <div class="part bottom">
- <span v-if="config.mode == 'omnireader'" class="bottom-span clickable" @click="openComments">Комментарии</span>
- <span class="bottom-span clickable" @click="openHelp">Справка</span>
- <span class="bottom-span">{{ version }}</span>
- </div>
- <ProgressPage ref="progress"></ProgressPage>
- </div>
- </template>
- <script>
- //-----------------------------------------------------------------------------
- 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;
- this.dispatch = this.$store.dispatch;
- this.config = this.$store.state.config;
- }
- mounted() {
- this.progress = this.$refs.progress;
- }
- activated() {
- this.$refs.input.focus();
- }
- get title() {
- if (this.config.mode == 'omnireader')
- return 'Omni Reader - браузерная онлайн-читалка.';
- return 'Универсальная читалка книг и ресурсов интернета.';
- }
- get version() {
- return `v${this.config.version}`;
- }
- async submitUrl() {
- if (this.bookUrl) {
- this.progress.show();
- this.progress.setState({totalSteps: 4});
- try {
- const book = await readerApi.loadBook(this.bookUrl, (state) => {
- this.progress.setState(state);
- });
- this.progress.hide();
- } catch (e) {
- this.progress.hide();
- this.$alert(e.message, 'Ошибка', {type: 'error'});
- }
- }
- }
- loadFle() {
- }
- openHelp() {
- }
- openComments() {
- window.open('http://samlib.ru/comment/b/bookpauk/bookpauk_reader', '_blank');
- }
- keyHook(event) {
- //недостатки сторонних ui
- if (document.activeElement == this.$refs.input.$refs.input && event.type == 'keyup' && event.key == 'Enter')
- this.submitUrl();
- }
- }
- //-----------------------------------------------------------------------------
- </script>
- <style scoped>
- .main {
- flex: 1;
- display: flex;
- flex-direction: column;
- }
- .part {
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- }
- .greeting {
- font-size: 130%;
- line-height: 170%;
- }
- .bold-font {
- font-weight: bold;
- }
- .clickable {
- color: blue;
- text-decoration: underline;
- cursor: pointer;
- }
- .center {
- justify-content: flex-start;
- padding: 0 10px 0 10px;
- }
- .bottom {
- justify-content: flex-end;
- }
- .bottom-span {
- font-size: 70%;
- margin-bottom: 10px;
- }
- .el-input {
- max-width: 700px;
- }
- .space {
- height: 20px;
- }
- </style>
|