Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Home button clear search query #916

Merged
merged 6 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
4 changes: 4 additions & 0 deletions internal/view/assets/js/component/eventBus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Create a new Vue instance as the EventBus
const EventBus = new Vue();

export default EventBus;
10 changes: 10 additions & 0 deletions internal/view/assets/js/page/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -153,6 +156,10 @@ export default {
},
},
methods: {
clearHomePage() {
fmartingr marked this conversation as resolved.
Show resolved Hide resolved
this.search = "";
this.searchBookmarks();
},
reloadData() {
if (this.loading) return;
this.page = 1;
Expand Down Expand Up @@ -999,6 +1006,9 @@ export default {
},
},
mounted() {
this.$bus.$on("clearHomePage", () => {
this.clearHomePage();
});
// Prepare history state watcher
var stateWatcher = (e) => {
var state = e.state || {},
Expand Down
5 changes: 5 additions & 0 deletions internal/view/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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);
Expand Down
Loading