-
@@ -88,9 +88,9 @@ export default {
this.selectTopic && this.changeTopic({
k: this.selectTopic.toLocaleLowerCase(),
v: this.selectTopic,
- })
+ }, true)
},
- changeTopic(topicItem) {
+ changeTopic(topicItem, noSearch) {
const index_ori = this.topicOri.findIndex((item) => {
return item.k == this.selectTopic.toLocaleLowerCase();
});
@@ -112,7 +112,7 @@ export default {
});
}
}
- this.search();
+ !noSearch && this.search();
},
handlerTopicsData(data) {
try {
diff --git a/web_src/vuepages/pages/repos/search/index.vue b/web_src/vuepages/pages/repos/search/index.vue
index d5a520011..c23b55ba1 100644
--- a/web_src/vuepages/pages/repos/search/index.vue
+++ b/web_src/vuepages/pages/repos/search/index.vue
@@ -11,7 +11,9 @@
-
+
@@ -44,6 +46,10 @@ export default {
reposListQurey: '',
reposListTopic: '',
+ page: 1,
+ pageSize: 15,
+ pageSizes: [15, 30, 50],
+
staticSquareTopics: staticSquareTopics,
};
},
@@ -56,32 +62,45 @@ export default {
},
methods: {
filtersChange(condition) {
+ this.page = 1;
this.reposListSortType = condition.key;
this.search();
},
searchBarChange(params) {
+ this.page = 1;
this.reposListQurey = params.q || '';
this.reposListTopic = params.topic || '';
this.search();
},
+ currentChange({ page, pageSize }) {
+ this.page = page;
+ this.search();
+ },
+ sizeChange({ page, pageSize }) {
+ this.page = 1;
+ this.pageSize = pageSize;
+ this.search();
+ },
search() {
- this.$nextTick(() => {
- this.$refs.reposListRef.search();
- });
+ window.location.href = `/explore/repos?q=${this.reposListQurey.trim()}&sort=${this.reposListSortType}&topic=${this.reposListTopic.trim()}&page=${this.page}&pageSize=${this.pageSize}`;
}
},
- mounted() {
+ beforeMount() {
const urlParams = getUrlSearchParams();
this.reposListQurey = urlParams.q || '';
this.reposListTopic = urlParams.topic || '';
this.reposListSortType = urlParams.sort || 'mostpopular';
- this.search();
+ this.page = Number(urlParams.page) || 1;
+ this.pageSize = this.pageSizes.indexOf(Number(urlParams.pageSize)) >= 0 ? Number(urlParams.pageSize) : 15;
+ },
+ mounted() {
this.$nextTick(() => {
this.$refs.reposFiltersRef.setDefaultFilter(this.reposListSortType);
this.$refs.searchBarRef.setDefaultSearch({
q: this.reposListQurey,
topic: this.reposListTopic,
});
+ this.$refs.reposListRef.search();
});
},
beforeDestroy() { },
diff --git a/web_src/vuepages/pages/repos/square/index.vue b/web_src/vuepages/pages/repos/square/index.vue
index 56a8bb539..c6dc49bf6 100644
--- a/web_src/vuepages/pages/repos/square/index.vue
+++ b/web_src/vuepages/pages/repos/square/index.vue
@@ -17,7 +17,9 @@
-
+
@@ -41,6 +43,7 @@ import ReposFilters from '../components/ReposFilters.vue';
import ReposList from '../components/ReposList.vue';
import ActiveUsers from '../components/ActiveUsers.vue';
import ActiveOrgs from '../components/ActiveOrgs.vue';
+import { getUrlSearchParams } from '~/utils';
const staticSquareBanners = JSON.stringify(window.staticSquareBanners || []);
const staticSquarePreferredRepos = window.staticSquarePreferredRepos || [];
@@ -54,6 +57,10 @@ export default {
reposListQurey: '',
reposListTopic: '',
+ page: 1,
+ pageSize: 15,
+ pageSizes: [15, 30, 50],
+
staticSquareBanners: staticSquareBanners,
staticSquarePreferredRepos: staticSquarePreferredRepos,
staticSquareTopics: staticSquareTopics,
@@ -71,27 +78,45 @@ export default {
},
methods: {
filtersChange(condition) {
+ this.page = 1;
this.reposListSortType = condition.key;
this.search();
},
searchBarChange(params) {
+ this.page = 1;
this.reposListQurey = params.q || '';
this.reposListTopic = params.topic || '';
this.search();
},
+ currentChange({ page, pageSize }) {
+ this.page = page;
+ this.search();
+ },
+ sizeChange({ page, pageSize }) {
+ this.page = 1;
+ this.pageSize = pageSize;
+ this.search();
+ },
search() {
- this.$nextTick(() => {
- this.$refs.reposListRef.search();
- });
+ window.location.href = `/explore/repos/square?q=${this.reposListQurey.trim()}&sort=${this.reposListSortType}&topic=${this.reposListTopic.trim()}&page=${this.page}&pageSize=${this.pageSize}`;
}
},
+ beforeMount() {
+ const urlParams = getUrlSearchParams();
+ this.reposListQurey = urlParams.q || '';
+ this.reposListTopic = urlParams.topic || '';
+ this.reposListSortType = urlParams.sort || 'mostpopular';
+ this.page = Number(urlParams.page) || 1;
+ this.pageSize = this.pageSizes.indexOf(Number(urlParams.pageSize)) >= 0 ? Number(urlParams.pageSize) : 15;
+ },
mounted() {
this.$nextTick(() => {
+ this.$refs.reposFiltersRef.setDefaultFilter(this.reposListSortType);
this.$refs.searchBarRef.setDefaultSearch({
- q: '',
- topic: '',
+ q: this.reposListQurey,
+ topic: this.reposListTopic,
});
- this.search();
+ this.$refs.reposListRef.search();
});
},
beforeDestroy() { },