Работа над BookInfoDialog
This commit is contained in:
@@ -235,6 +235,10 @@ class Api {
|
|||||||
return await this.request(Object.assign({action: 'get-book-link'}, params), 120);
|
return await this.request(Object.assign({action: 'get-book-link'}, params), 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getBookInfo(params) {
|
||||||
|
return await this.request(Object.assign({action: 'get-book-info'}, params), 120);
|
||||||
|
}
|
||||||
|
|
||||||
async getConfig() {
|
async getConfig() {
|
||||||
return await this.request({action: 'get-config'});
|
return await this.request({action: 'get-config'});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,6 +185,10 @@ export default class BaseList {
|
|||||||
const url = this.config.bookReadLink.replace('${DOWNLOAD_LINK}', href);
|
const url = this.config.bookReadLink.replace('${DOWNLOAD_LINK}', href);
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
}
|
}
|
||||||
|
} else if (action == 'bookInfo') {
|
||||||
|
//информация о книге
|
||||||
|
const response = await this.api.getBookInfo({bookPath, downFileName});
|
||||||
|
this.$emit('listEvent', {action: 'bookInfo', data: response.bookInfo});
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
this.$root.stdDialog.alert(e.message, 'Ошибка');
|
this.$root.stdDialog.alert(e.message, 'Ошибка');
|
||||||
@@ -208,6 +212,7 @@ export default class BaseList {
|
|||||||
case 'download':
|
case 'download':
|
||||||
case 'copyLink':
|
case 'copyLink':
|
||||||
case 'readBook':
|
case 'readBook':
|
||||||
|
case 'bookInfo':
|
||||||
this.download(event.book, event.action);//no await
|
this.download(event.book, event.action);//no await
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
66
client/components/Search/BookInfoDialog/BookInfoDialog.vue
Normal file
66
client/components/Search/BookInfoDialog/BookInfoDialog.vue
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<template>
|
||||||
|
<Dialog ref="dialog" v-model="dialogVisible">
|
||||||
|
<template #header>
|
||||||
|
<div class="row items-center">
|
||||||
|
<div style="font-size: 110%">
|
||||||
|
Информация о книге
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div ref="box" class="column q-mt-xs overflow-auto no-wrap" style="width: 200px; padding: 0px 10px 10px 10px;">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<q-btn class="q-px-md q-ml-sm" color="primary" dense no-caps @click="okClick">
|
||||||
|
OK
|
||||||
|
</q-btn>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
import vueComponent from '../../vueComponent.js';
|
||||||
|
|
||||||
|
import Dialog from '../../share/Dialog.vue';
|
||||||
|
|
||||||
|
const componentOptions = {
|
||||||
|
components: {
|
||||||
|
Dialog
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
modelValue(newValue) {
|
||||||
|
this.dialogVisible = newValue;
|
||||||
|
},
|
||||||
|
dialogVisible(newValue) {
|
||||||
|
this.$emit('update:modelValue', newValue);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
class BookInfoDialog {
|
||||||
|
_options = componentOptions;
|
||||||
|
_props = {
|
||||||
|
modelValue: Boolean,
|
||||||
|
};
|
||||||
|
|
||||||
|
dialogVisible = false;
|
||||||
|
|
||||||
|
created() {
|
||||||
|
this.commit = this.$store.commit;
|
||||||
|
}
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
}
|
||||||
|
|
||||||
|
okClick() {
|
||||||
|
this.dialogVisible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default vueComponent(BookInfoDialog);
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
{{ bookSize }}, {{ book.ext }}
|
{{ bookSize }}, {{ book.ext }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="showInfo" class="row items-center q-ml-sm clickable" @click="emit('info')">
|
<div v-if="showInfo" class="row items-center q-ml-sm clickable" @click="emit('bookInfo')">
|
||||||
[ . . . ]
|
[ . . . ]
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -250,6 +250,7 @@
|
|||||||
<SelectLangDialog v-model="selectLangDialogVisible" v-model:lang="search.lang" :lang-list="langList" :lang-default="langDefault" />
|
<SelectLangDialog v-model="selectLangDialogVisible" v-model:lang="search.lang" :lang-list="langList" :lang-default="langDefault" />
|
||||||
<SelectLibRateDialog v-model="selectLibRateDialogVisible" v-model:librate="search.librate" />
|
<SelectLibRateDialog v-model="selectLibRateDialogVisible" v-model:librate="search.librate" />
|
||||||
<SelectDateDialog v-model="selectDateDialogVisible" v-model:date="search.date" />
|
<SelectDateDialog v-model="selectDateDialogVisible" v-model:date="search.date" />
|
||||||
|
<BookInfoDialog v-model="bookInfoDialogVisible" book-info="bookInfo" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -266,6 +267,7 @@ import SelectGenreDialog from './SelectGenreDialog/SelectGenreDialog.vue';
|
|||||||
import SelectLangDialog from './SelectLangDialog/SelectLangDialog.vue';
|
import SelectLangDialog from './SelectLangDialog/SelectLangDialog.vue';
|
||||||
import SelectLibRateDialog from './SelectLibRateDialog/SelectLibRateDialog.vue';
|
import SelectLibRateDialog from './SelectLibRateDialog/SelectLibRateDialog.vue';
|
||||||
import SelectDateDialog from './SelectDateDialog/SelectDateDialog.vue';
|
import SelectDateDialog from './SelectDateDialog/SelectDateDialog.vue';
|
||||||
|
import BookInfoDialog from './BookInfoDialog/BookInfoDialog.vue';
|
||||||
|
|
||||||
import authorBooksStorage from './authorBooksStorage';
|
import authorBooksStorage from './authorBooksStorage';
|
||||||
import DivBtn from '../share/DivBtn.vue';
|
import DivBtn from '../share/DivBtn.vue';
|
||||||
@@ -292,6 +294,7 @@ const componentOptions = {
|
|||||||
SelectLangDialog,
|
SelectLangDialog,
|
||||||
SelectLibRateDialog,
|
SelectLibRateDialog,
|
||||||
SelectDateDialog,
|
SelectDateDialog,
|
||||||
|
BookInfoDialog,
|
||||||
Dialog,
|
Dialog,
|
||||||
DivBtn
|
DivBtn
|
||||||
},
|
},
|
||||||
@@ -404,6 +407,7 @@ class Search {
|
|||||||
selectLangDialogVisible = false;
|
selectLangDialogVisible = false;
|
||||||
selectLibRateDialogVisible = false;
|
selectLibRateDialogVisible = false;
|
||||||
selectDateDialogVisible = false;
|
selectDateDialogVisible = false;
|
||||||
|
bookInfoDialogVisible = false;
|
||||||
|
|
||||||
pageCount = 1;
|
pageCount = 1;
|
||||||
|
|
||||||
@@ -458,6 +462,8 @@ class Search {
|
|||||||
genreTreeInpxHash = '';
|
genreTreeInpxHash = '';
|
||||||
showTooltips = true;
|
showTooltips = true;
|
||||||
|
|
||||||
|
bookInfo = {};
|
||||||
|
|
||||||
limitOptions = [
|
limitOptions = [
|
||||||
{label: '10', value: 10},
|
{label: '10', value: 10},
|
||||||
{label: '20', value: 20},
|
{label: '20', value: 20},
|
||||||
@@ -879,6 +885,10 @@ class Search {
|
|||||||
case 'submitUrl':
|
case 'submitUrl':
|
||||||
this.sendMessage({type: 'submitUrl', data: event.data});
|
this.sendMessage({type: 'submitUrl', data: event.data});
|
||||||
break;
|
break;
|
||||||
|
case 'bookInfo':
|
||||||
|
this.bookInfo = event.data;
|
||||||
|
this.bookInfoDialogVisible = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ class WebSocketController {
|
|||||||
await this.getGenreTree(req, ws); break;
|
await this.getGenreTree(req, ws); break;
|
||||||
case 'get-book-link':
|
case 'get-book-link':
|
||||||
await this.getBookLink(req, ws); break;
|
await this.getBookLink(req, ws); break;
|
||||||
|
case 'get-book-info':
|
||||||
|
await this.getBookInfo(req, ws); break;
|
||||||
|
|
||||||
case 'get-inpx-file':
|
case 'get-inpx-file':
|
||||||
await this.getInpxFile(req, ws); break;
|
await this.getInpxFile(req, ws); break;
|
||||||
@@ -173,6 +175,17 @@ class WebSocketController {
|
|||||||
this.send(result, req, ws);
|
this.send(result, req, ws);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getBookInfo(req, ws) {
|
||||||
|
if (!utils.hasProp(req, 'bookPath'))
|
||||||
|
throw new Error(`bookPath is empty`);
|
||||||
|
if (!utils.hasProp(req, 'downFileName'))
|
||||||
|
throw new Error(`downFileName is empty`);
|
||||||
|
|
||||||
|
const result = await this.webWorker.getBookInfo({bookPath: req.bookPath, downFileName: req.downFileName});
|
||||||
|
|
||||||
|
this.send(result, req, ws);
|
||||||
|
}
|
||||||
|
|
||||||
async getInpxFile(req, ws) {
|
async getInpxFile(req, ws) {
|
||||||
if (!this.config.allowRemoteLib)
|
if (!this.config.allowRemoteLib)
|
||||||
throw new Error('Remote lib access disabled');
|
throw new Error('Remote lib access disabled');
|
||||||
|
|||||||
@@ -437,6 +437,26 @@ class WebWorker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getBookInfo(params) {
|
||||||
|
this.checkMyState();
|
||||||
|
|
||||||
|
try {
|
||||||
|
//const db = this.db;
|
||||||
|
let link = await this.getBookLink(params);
|
||||||
|
const hash = path.basename(link.link);
|
||||||
|
|
||||||
|
/*const bookFile = `${this.config.filesDir}/${hash}`;
|
||||||
|
const bookInfo = await fb2parser*/
|
||||||
|
|
||||||
|
return {hash};
|
||||||
|
} catch(e) {
|
||||||
|
log(LM_ERR, `getBookInfo error: ${e.message}`);
|
||||||
|
if (e.message.indexOf('ENOENT') >= 0)
|
||||||
|
throw new Error('404 Файл не найден');
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
async restoreBookFile(publicPath) {
|
async restoreBookFile(publicPath) {
|
||||||
this.checkMyState();
|
this.checkMyState();
|
||||||
|
|||||||
Reference in New Issue
Block a user