mirror of
https://github.com/go-shiori/shiori.git
synced 2025-10-10 05:35:59 +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>
|
</a>
|
||||||
</yla-tooltip>
|
</yla-tooltip>
|
||||||
<div class="spacer"></div>
|
<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">
|
<yla-tooltip placement="right" content="Toggle night mode">
|
||||||
<a>
|
<a>
|
||||||
<i class="fas fa-moon fa-fw"></i>
|
<i class="fas fa-moon fa-fw"></i>
|
||||||
|
@ -61,7 +66,8 @@
|
||||||
<i class="fas fa-search fa-fw"></i>
|
<i class="fas fa-search fa-fw"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="grid">
|
<div id="content" ref="content">
|
||||||
|
<div id="grid" :class="{list: listView}">
|
||||||
<div class="pagination-box" v-if="maxPage > 0">
|
<div class="pagination-box" v-if="maxPage > 0">
|
||||||
<p>Page</p>
|
<p>Page</p>
|
||||||
<input type="text" placeholder="1" :value="page+1" @focus="$event.target.select()" @keyup.enter="changePage($event.target.value-1)">
|
<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 id="grid-padding"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<yla-dialog v-bind="dialog"></yla-dialog>
|
<yla-dialog v-bind="dialog"></yla-dialog>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
@ -148,6 +155,8 @@
|
||||||
search: '',
|
search: '',
|
||||||
page: 0,
|
page: 0,
|
||||||
maxPage: 0,
|
maxPage: 0,
|
||||||
|
listView: false,
|
||||||
|
nightMode: false
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
visibleBookmarks() {
|
visibleBookmarks() {
|
||||||
|
@ -183,7 +192,7 @@
|
||||||
this.bookmarks = response.data;
|
this.bookmarks = response.data;
|
||||||
this.page = 0;
|
this.page = 0;
|
||||||
this.maxPage = Math.ceil(this.bookmarks.length / pageSize) - 1;
|
this.maxPage = Math.ceil(this.bookmarks.length / pageSize) - 1;
|
||||||
document.getElementById('grid').scrollTop = 0;
|
this.$refs.content.scrollTop = 0;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
var errorMsg = (error.response ? error.response.data : error.message).trim();
|
var errorMsg = (error.response ? error.response.data : error.message).trim();
|
||||||
|
@ -191,7 +200,11 @@
|
||||||
this.showErrorDialog(errorMsg);
|
this.showErrorDialog(errorMsg);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
reloadData() {},
|
reloadData() {
|
||||||
|
if (this.loading) return;
|
||||||
|
this.search = '';
|
||||||
|
this.loadData();
|
||||||
|
},
|
||||||
changePage(target) {
|
changePage(target) {
|
||||||
target = parseInt(target, 10) || 0;
|
target = parseInt(target, 10) || 0;
|
||||||
|
|
||||||
|
@ -199,7 +212,12 @@
|
||||||
else if (target <= 0) this.page = 0;
|
else if (target <= 0) this.page = 0;
|
||||||
else this.page = target;
|
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() {
|
showDialogAdd() {
|
||||||
this.showDialog({
|
this.showDialog({
|
||||||
|
@ -403,6 +421,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
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();
|
this.loadData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -198,8 +198,9 @@ a {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#grid {
|
#content {
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
#grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-rows: auto;
|
grid-template-rows: auto;
|
||||||
grid-template-columns: repeat(4, 1fr);
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
@ -220,7 +221,6 @@ a {
|
||||||
}
|
}
|
||||||
.bookmark-content {
|
.bookmark-content {
|
||||||
display: block;
|
display: block;
|
||||||
position: relative;
|
|
||||||
flex: 1;
|
flex: 1;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
&[href] {
|
&[href] {
|
||||||
|
@ -334,6 +334,60 @@ a {
|
||||||
grid-column-end: -1;
|
grid-column-end: -1;
|
||||||
min-height: 1px;
|
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