Добавлена расшифровка имен жанров в информации о книге(#24)
This commit is contained in:
@@ -118,6 +118,7 @@ class BookInfoDialog {
|
||||
_props = {
|
||||
modelValue: Boolean,
|
||||
bookInfo: Object,
|
||||
genreMap: Object,
|
||||
};
|
||||
|
||||
dialogVisible = false;
|
||||
@@ -169,6 +170,19 @@ class BookInfoDialog {
|
||||
return `${size.toFixed(1)} ${unit}`;
|
||||
}
|
||||
|
||||
convertGenres(genreArr) {
|
||||
let result = [];
|
||||
if (genreArr) {
|
||||
for (const genre of genreArr) {
|
||||
const g = genre.trim();
|
||||
const name = this.genreMap.get(g);
|
||||
result.push(name ? name : g);
|
||||
}
|
||||
}
|
||||
|
||||
return result.join(', ');
|
||||
}
|
||||
|
||||
get inpx() {
|
||||
const mapping = [
|
||||
{name: 'fileInfo', label: 'Информация о файле', value: [
|
||||
@@ -211,6 +225,9 @@ class BookInfoDialog {
|
||||
if (nodePath == 'titleInfo/author')
|
||||
return value.split(',').join(', ');
|
||||
|
||||
if (nodePath == 'titleInfo/genre')
|
||||
return this.convertGenres(value.split(','));
|
||||
|
||||
if (nodePath == 'titleInfo/librate' && !value)
|
||||
return null;
|
||||
|
||||
@@ -279,11 +296,16 @@ class BookInfoDialog {
|
||||
}
|
||||
}
|
||||
|
||||
const self = this;
|
||||
this.fb2 = parser.bookInfoList(infoObj, {
|
||||
valueToString(value, nodePath, origVTS) {//eslint-disable-line no-unused-vars
|
||||
if (nodePath == 'documentInfo/historyHtml' && value)
|
||||
return value.replace(/<p>/g, `<p class="p-history">`);
|
||||
|
||||
if ((nodePath == 'titleInfo/genre' || nodePath == 'srcTitleInfo/genre') && value) {
|
||||
return self.convertGenres(value);
|
||||
}
|
||||
|
||||
return origVTS(value, nodePath);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -347,7 +347,7 @@
|
||||
<SelectLibRateDialog v-model="selectLibRateDialogVisible" v-model:librate="search.librate" />
|
||||
<SelectDateDialog v-model="selectDateDialogVisible" v-model:date="search.date" />
|
||||
<SelectExtDialog v-model="selectExtDialogVisible" v-model:ext="search.ext" :ext-list="extList" />
|
||||
<BookInfoDialog v-model="bookInfoDialogVisible" :book-info="bookInfo" />
|
||||
<BookInfoDialog v-model="bookInfoDialogVisible" :book-info="bookInfo" :genre-map="genreMap" />
|
||||
<SelectExtSearchDialog v-model="selectExtSearchDialogVisible" v-model:ext-search="extSearch" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user