diff --git a/client/components/Reader/HistoryPage/HistoryPage.vue b/client/components/Reader/HistoryPage/HistoryPage.vue
index f3732767..29b53a1c 100644
--- a/client/components/Reader/HistoryPage/HistoryPage.vue
+++ b/client/components/Reader/HistoryPage/HistoryPage.vue
@@ -1,13 +1,56 @@
-
+
- Прочитаные книги:
+ Последние 100 открытых книг
-
- Test
-
+
+
+
+
+ Время
просмотра
+
+
+
+
+
+
+
+
+ {{ scope.row.desc.author }}
+ {{ `"${scope.row.desc.title}"` }}
+
+
+
+
+
+ Убрать
+
+
+
+
+
@@ -16,7 +59,8 @@
//-----------------------------------------------------------------------------
import Vue from 'vue';
import Component from 'vue-class-component';
-
+import _ from 'lodash';
+import {formatDate} from '../../../share/utils';
import Window from '../../share/Window.vue';
export default @Component({
@@ -25,11 +69,44 @@ export default @Component({
},
})
class HistoryPage extends Vue {
+ search = null;
+
created() {
this.commit = this.$store.commit;
this.reader = this.$store.state.reader;
}
+ get tableData() {
+ const state = this.reader;
+ let result = [];
+
+ for (let bookKey in state.openedBook) {
+ const book = state.openedBook[bookKey];
+ let touchTime = new Date();
+ touchTime.setTime(book.touchTime);
+
+ result.push({
+ touchTime: formatDate(touchTime),
+ desc: {
+ title: book.fb2.bookTitle,
+ author: _.compact([
+ book.fb2.lastName,
+ book.fb2.firstName,
+ book.fb2.middleName
+ ]).join(' '),
+ }
+ });
+ }
+
+ return result;
+ }
+
+ keyHook(event) {
+ if (event.type == 'keydown' && event.code == 'Escape') {
+ this.$emit('history-toggle');
+ return true;
+ }
+ }
}
//-----------------------------------------------------------------------------
@@ -42,11 +119,9 @@ class HistoryPage extends Vue {
align-items: center;
}
-.list {
- flex: 1;
- background-color: #ffffff;
+.window {
+ min-width: 200px;
+ max-width: 600px;
}
-.list-item {
-}
\ No newline at end of file
diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue
index 4fae89d2..31c88066 100644
--- a/client/components/Reader/Reader.vue
+++ b/client/components/Reader/Reader.vue
@@ -46,7 +46,12 @@
-
+
diff --git a/client/components/Reader/share/bookManager.js b/client/components/Reader/share/bookManager.js
index 33bff3e0..986742cd 100644
--- a/client/components/Reader/share/bookManager.js
+++ b/client/components/Reader/share/bookManager.js
@@ -121,7 +121,12 @@ class BookManager {
const parsed = new BookParser();
const parsedMeta = await parsed.parse(data, callback);
- const result = Object.assign({}, meta, parsedMeta, {length: data.length, data, parsed});
+ const result = Object.assign({}, meta, parsedMeta, {
+ length: data.length,
+ textLength: parsed.textLength,
+ data,
+ parsed
+ });
return result;
}
diff --git a/client/components/share/Window.vue b/client/components/share/Window.vue
index 439736ef..d435c061 100644
--- a/client/components/share/Window.vue
+++ b/client/components/share/Window.vue
@@ -27,9 +27,7 @@ class Window extends Vue {
flex: 1;
display: flex;
flex-direction: column;
- min-width: 200px;
- max-width: 600px;
- background-color: #f5f7fa;
+ background-color: #e5e7ea;
margin: 10px;
border: 1px solid black;
box-shadow: 3px 3px 5px black;
@@ -43,5 +41,6 @@ class Window extends Vue {
.header-text {
margin-left: 10px;
+ margin-right: 10px;
}
\ No newline at end of file
diff --git a/client/element.js b/client/element.js
index b3ac3cc8..415c5a16 100644
--- a/client/element.js
+++ b/client/element.js
@@ -50,6 +50,12 @@ import './theme/main.css';
import ElInput from 'element-ui/lib/input';
import './theme/input.css';
+import ElTable from 'element-ui/lib/table';
+import './theme/table.css';
+
+import ElTableColumn from 'element-ui/lib/table-column';
+import './theme/table-column.css';
+
import ElProgress from 'element-ui/lib/progress';
import './theme/progress.css';
@@ -65,7 +71,8 @@ import './theme/message-box.css';
const components = {
ElMenu, ElMenuItem, ElButton, ElCheckbox, ElTabs, ElTabPane, ElTooltip,
ElContainer, ElAside, ElMain, ElHeader,
- ElInput, ElProgress
+ ElInput, ElTable, ElTableColumn,
+ ElProgress
};
for (let name in components) {
diff --git a/client/share/utils.js b/client/share/utils.js
index 912c2fac..9debde67 100644
--- a/client/share/utils.js
+++ b/client/share/utils.js
@@ -16,4 +16,16 @@ export function hexToString(str) {
result += String.fromCharCode(parseInt(str.substr(i, 2), 16));
}
return result;
+}
+
+export function formatDate(d, format) {
+ if (!format)
+ format = 'normal';
+
+ switch (format) {
+ case 'normal':
+ return `${d.getDate().toString().padStart(2, '0')}.${(d.getMonth() + 1).toString().padStart(2, '0')}.${d.getFullYear()} ` +
+ `${d.getHours().toString().padStart(2, '0')}:${d.getMinutes().toString().padStart(2, '0')}`;
+ }
+
}
\ No newline at end of file
diff --git a/client/store/modules/reader.js b/client/store/modules/reader.js
index 33087e66..e2ec7c0b 100644
--- a/client/store/modules/reader.js
+++ b/client/store/modules/reader.js
@@ -25,6 +25,29 @@ const getters = {
// actions
const actions = {};
+function delBook(state, value) {
+ Vue.delete(state.openedBook, value.key);
+}
+
+function cleanBooks(state) {
+ if (Object.keys(state.openedBook).length > 100) {
+ let min = Date.now();
+ let found = null;
+ for (let bookKey in state.openedBook) {
+ const book = state.openedBook[bookKey];
+ if (book.touchTime < min) {
+ min = book.touchTime;
+ found = book;
+ }
+ }
+
+ if (found) {
+ delBook(found);
+ cleanBooks(state);
+ }
+ }
+}
+
// mutations
const mutations = {
setToolBarActive(state, value) {
@@ -32,9 +55,10 @@ const mutations = {
},
setOpenedBook(state, value) {
Vue.set(state.openedBook, value.key, Object.assign({}, value, {touchTime: Date.now()}));
+ cleanBooks(state);
},
delOpenedBook(state, value) {
- Vue.delete(state.openedBook, value.key);
+ delBook(state, value);
}
};