mirror of
https://github.com/go-shiori/shiori.git
synced 2024-09-20 06:56:10 +08:00
feat: Home button clear search query (#916)
* click on home will clear searchbox * clearHome when mounted * clearHomePage just when you are in homepage * check clearHomePage signal out of clearHomePage method * fix style
This commit is contained in:
parent
2d88f908e2
commit
6c94d56bf0
4
internal/view/assets/js/component/eventBus.js
Normal file
4
internal/view/assets/js/component/eventBus.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Create a new Vue instance as the EventBus
|
||||
const EventBus = new Vue();
|
||||
|
||||
export default EventBus;
|
|
@ -90,6 +90,9 @@ import paginationBox from "../component/pagination.js";
|
|||
import bookmarkItem from "../component/bookmark.js";
|
||||
import customDialog from "../component/dialog.js";
|
||||
import basePage from "./base.js";
|
||||
import EventBus from "../component/eventBus.js";
|
||||
|
||||
Vue.prototype.$bus = EventBus;
|
||||
|
||||
export default {
|
||||
template: template,
|
||||
|
@ -153,6 +156,10 @@ export default {
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
clearHomePage() {
|
||||
this.search = "";
|
||||
this.searchBookmarks();
|
||||
},
|
||||
reloadData() {
|
||||
if (this.loading) return;
|
||||
this.page = 1;
|
||||
|
@ -999,6 +1006,9 @@ export default {
|
|||
},
|
||||
},
|
||||
mounted() {
|
||||
this.$bus.$on("clearHomePage", () => {
|
||||
this.clearHomePage();
|
||||
});
|
||||
// Prepare history state watcher
|
||||
var stateWatcher = (e) => {
|
||||
var state = e.state || {},
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
import pageHome from "./assets/js/page/home.js";
|
||||
import pageSetting from "./assets/js/page/setting.js";
|
||||
import customDialog from "./assets/js/component/dialog.js";
|
||||
import EventBus from "../assets/js/component/eventBus.js";
|
||||
Vue.prototype.$bus = EventBus;
|
||||
|
||||
var app = new Vue({
|
||||
el: '#main-scene',
|
||||
|
@ -69,6 +71,9 @@
|
|||
state = { activePage: page },
|
||||
url = new Url;
|
||||
|
||||
if (page === 'page-home' && this.activePage === 'page-home') {
|
||||
Vue.prototype.$bus.$emit('clearHomePage', {});
|
||||
}
|
||||
url.hash = pageName;
|
||||
this.activePage = page;
|
||||
history.pushState(state, page, url);
|
||||
|
|
Loading…
Reference in a new issue