mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 21:28:06 +00:00
fix: search issues
This commit is contained in:
parent
0ef108df4c
commit
86452f0420
6 changed files with 44 additions and 56 deletions
|
|
@ -38,7 +38,8 @@
|
|||
ref="searchInput"
|
||||
:placeholder="inputFocus ? '' : $t('nav.search')"
|
||||
v-model="keywords"
|
||||
@focus="focusSearchBox"
|
||||
@keydown.enter="doSearch"
|
||||
@focus="inputFocus = true"
|
||||
@blur="inputFocus = false"
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -61,32 +62,29 @@ export default {
|
|||
return {
|
||||
inputFocus: false,
|
||||
langs: ["zh-CN", "en"],
|
||||
keywords: "",
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(["settings", "search"]),
|
||||
keywords: {
|
||||
get() {
|
||||
return this.search.keywords;
|
||||
},
|
||||
set(value) {
|
||||
this.$store.commit("updateSearch", { key: "keywords", value });
|
||||
},
|
||||
},
|
||||
...mapState(["settings"]),
|
||||
},
|
||||
methods: {
|
||||
go(where) {
|
||||
if (where === "back") this.$router.go(-1);
|
||||
else this.$router.go(1);
|
||||
},
|
||||
focusSearchBox() {
|
||||
this.inputFocus = true;
|
||||
if (this.$route.name !== "search") {
|
||||
this.$router.push({
|
||||
name: "search",
|
||||
params: { keywords: this.keywords },
|
||||
});
|
||||
doSearch() {
|
||||
if (!this.keywords) return;
|
||||
if (
|
||||
this.$route.name === "search" &&
|
||||
this.$route.params.keywords === this.keywords
|
||||
) {
|
||||
return;
|
||||
}
|
||||
this.$router.push({
|
||||
name: "search",
|
||||
params: { keywords: this.keywords },
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue