@@ -143,17 +143,13 @@ import { reverse, uniq } from "lodash/array";
143
143
import { trim } from "lodash/string";
144
144
145
145
import AppLayout from "@theme/layouts/AppLayout.vue";
146
+ import common from "@theme/common";
146
147
import LazyPackageCard from "@theme/components/LazyPackageCard.vue";
147
148
import NavLink from "@theme/components/NavLink.vue";
148
149
import PackageLayoutControl from "@theme/components/PackageLayoutControl.vue";
149
150
import util from "@root/docs/.vuepress/util";
150
151
151
- const SortType = {
152
- name: "name",
153
- pop: "pop",
154
- createdAt: "createdAt",
155
- updatedAt: "updatedAt"
156
- };
152
+ const SortType = common.SortType;
157
153
158
154
export default {
159
155
components: {
@@ -167,7 +163,6 @@ export default {
167
163
return {
168
164
active: true,
169
165
topicValue: "",
170
- sort: SortType.updatedAt,
171
166
sortList: [
172
167
{ text: "Name", value: SortType.name },
173
168
{ text: "Popularity", value: SortType.pop },
@@ -247,8 +242,13 @@ export default {
247
242
return query;
248
243
},
249
244
250
- stateText() {
251
- return this.active ? "Ready to Use" : "Pending";
245
+ sort: {
246
+ get() {
247
+ return this.$store.getters.packageListSort;
248
+ },
249
+ set(value) {
250
+ this.$store.dispatch("setPackageListSort", { value });
251
+ }
252
252
},
253
253
254
254
sortOptions() {
@@ -261,6 +261,10 @@ export default {
261
261
});
262
262
},
263
263
264
+ stateText() {
265
+ return this.active ? "Ready to Use" : "Pending";
266
+ },
267
+
264
268
timeField() {
265
269
if (this.sort == SortType.createdAt) {
266
270
return SortType.createdAt;
@@ -331,8 +335,8 @@ export default {
331
335
this.active = this.$route.query.active != "0";
332
336
// sort
333
337
const sort = this.$route.query.sort;
334
- if (this.sortList.map(x => x.value).includes(sort)) this. sort = sort;
335
- else this.sort = SortType.updatedAt ;
338
+ if (this.sortList.map(x => x.value).includes(sort) && sort != this. sort)
339
+ this.$store.dispatch("setPackageListSort", { value: sort }) ;
336
340
// unity
337
341
const unity = this.$route.query.unity;
338
342
if (this.unityOptions.map(x => x.value).includes(unity))
0 commit comments