mirror of
https://github.com/go-shiori/shiori.git
synced 2025-10-06 03:35:35 +08:00
Add switch to list view in web ui
This commit is contained in:
parent
7f31d67043
commit
f2afeab26f
4 changed files with 260 additions and 180 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -43,6 +43,11 @@
|
|||
</a>
|
||||
</yla-tooltip>
|
||||
<div class="spacer"></div>
|
||||
<yla-tooltip placement="right" :content="listView ? 'Switch to grid view' : 'Switch to list view'">
|
||||
<a @click="toggleListView">
|
||||
<i class="fas fa-fw" :class="listView ? 'fa-th-large' : 'fa-th-list'"></i>
|
||||
</a>
|
||||
</yla-tooltip>
|
||||
<yla-tooltip placement="right" content="Toggle night mode">
|
||||
<a>
|
||||
<i class="fas fa-moon fa-fw"></i>
|
||||
|
@ -61,7 +66,8 @@
|
|||
<i class="fas fa-search fa-fw"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div id="grid">
|
||||
<div id="content" ref="content">
|
||||
<div id="grid" :class="{list: listView}">
|
||||
<div class="pagination-box" v-if="maxPage > 0">
|
||||
<p>Page</p>
|
||||
<input type="text" placeholder="1" :value="page+1" @focus="$event.target.select()" @keyup.enter="changePage($event.target.value-1)">
|
||||
|
@ -122,6 +128,7 @@
|
|||
<div id="grid-padding"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<yla-dialog v-bind="dialog"></yla-dialog>
|
||||
</div>
|
||||
<script>
|
||||
|
@ -148,6 +155,8 @@
|
|||
search: '',
|
||||
page: 0,
|
||||
maxPage: 0,
|
||||
listView: false,
|
||||
nightMode: false
|
||||
},
|
||||
computed: {
|
||||
visibleBookmarks() {
|
||||
|
@ -183,7 +192,7 @@
|
|||
this.bookmarks = response.data;
|
||||
this.page = 0;
|
||||
this.maxPage = Math.ceil(this.bookmarks.length / pageSize) - 1;
|
||||
document.getElementById('grid').scrollTop = 0;
|
||||
this.$refs.content.scrollTop = 0;
|
||||
})
|
||||
.catch((error) => {
|
||||
var errorMsg = (error.response ? error.response.data : error.message).trim();
|
||||
|
@ -191,7 +200,11 @@
|
|||
this.showErrorDialog(errorMsg);
|
||||
});
|
||||
},
|
||||
reloadData() {},
|
||||
reloadData() {
|
||||
if (this.loading) return;
|
||||
this.search = '';
|
||||
this.loadData();
|
||||
},
|
||||
changePage(target) {
|
||||
target = parseInt(target, 10) || 0;
|
||||
|
||||
|
@ -199,7 +212,12 @@
|
|||
else if (target <= 0) this.page = 0;
|
||||
else this.page = target;
|
||||
|
||||
document.getElementById('grid').scrollTop = 0;
|
||||
this.$refs.content.scrollTop = 0;
|
||||
},
|
||||
toggleListView() {
|
||||
this.listView = !this.listView;
|
||||
this.$refs.content.scrollTop = 0;
|
||||
localStorage.setItem('shiori-list-view', this.listView ? '1' : '0');
|
||||
},
|
||||
showDialogAdd() {
|
||||
this.showDialog({
|
||||
|
@ -403,6 +421,14 @@
|
|||
}
|
||||
},
|
||||
mounted() {
|
||||
// Read config from local storage
|
||||
var listView = localStorage.getItem('shiori-list-view'),
|
||||
nightMode = localStorage.getItem('shiori-night-mode');
|
||||
|
||||
this.listView = listView === '1';
|
||||
this.nightMode = nightMode === '1';
|
||||
|
||||
// Load data
|
||||
this.loadData();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -198,8 +198,9 @@ a {
|
|||
}
|
||||
}
|
||||
}
|
||||
#grid {
|
||||
#content {
|
||||
overflow-y: auto;
|
||||
#grid {
|
||||
display: grid;
|
||||
grid-template-rows: auto;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
|
@ -220,7 +221,6 @@ a {
|
|||
}
|
||||
.bookmark-content {
|
||||
display: block;
|
||||
position: relative;
|
||||
flex: 1;
|
||||
cursor: default;
|
||||
&[href] {
|
||||
|
@ -334,6 +334,60 @@ a {
|
|||
grid-column-end: -1;
|
||||
min-height: 1px;
|
||||
}
|
||||
&.list {
|
||||
grid-gap: 0;
|
||||
grid-template-columns: 1fr;
|
||||
max-width: 1280px;
|
||||
.pagination-box {
|
||||
margin-top: 16px;
|
||||
&:first-of-type {
|
||||
margin-top: 0;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
.bookmark {
|
||||
border-top-width: 0;
|
||||
border-bottom-width: 1px;
|
||||
position: relative;
|
||||
padding-left: 100px;
|
||||
background-color: #FAFAFA;
|
||||
&:first-of-type {
|
||||
border-top-width: 1px;
|
||||
}
|
||||
.bookmark-content {
|
||||
display: flex;
|
||||
flex-flow: column nowrap;
|
||||
background-color: @contentBg;
|
||||
border-left: 1px solid @border;
|
||||
padding: 16px 24px 8px;
|
||||
img {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100px;
|
||||
height: 100%;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.title {
|
||||
padding: 0;
|
||||
margin-top: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.excerpt {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.bookmark-menu {
|
||||
background-color: @contentBg;
|
||||
border-left: 1px solid @border;
|
||||
padding: 0 24px 16px;
|
||||
}
|
||||
}
|
||||
#grid-padding {
|
||||
min-height: 16px
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue