Skip to content

Commit

Permalink
perf: rm gs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaviilee committed Feb 29, 2024
1 parent 473bbfc commit 3e5c94b
Showing 1 changed file with 4 additions and 42 deletions.
46 changes: 4 additions & 42 deletions src/views/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ export default {
cn: "简体中文",
tr: "繁體中文",
},
globalSearch: []
};
},
computed: {
Expand All @@ -118,7 +116,7 @@ export default {
order: this.order,
mark: this.mark,
client: this.client,
// search: this.search,
search: this.search,
lang: this.lang,
zlp: this.zlp,
};
Expand Down Expand Up @@ -160,31 +158,16 @@ export default {
_query.sticky = 1;
}
if (this.globalSearch.length) {
_query.list = this.globalSearch.join(',')
}
return _query;
},
onSearch: function (search) {
this.search = search;
if (search) {
this.loadGlobalSearch()
} else {
this.globalSearch = []
this.loadData()
}
},
// 加载数据
loadData: function (appendMode = false) {
let query = this.buildQuery(appendMode);
// console.log("[cms-list]", "<loading data>", query);
// if (this.search) {
// query.page = 1
// }
this.loading = true;
return getPosts(query)
.then((res) => {
Expand All @@ -201,10 +184,8 @@ export default {
},
});
// if (!this.search) {
// this.total = res.data?.data?.total;
// this.pages = res.data?.data?.pages;
// }
this.total = res.data?.data?.total;
this.pages = res.data?.data?.pages;
})
.finally(() => {
this.loading = false;
Expand Down Expand Up @@ -234,11 +215,7 @@ export default {
},
// 追加加载
appendPage: function () {
if (this.search) {
this.loadGlobalSearch(true)
} else {
this.loadData(true);
}
this.loadData(true);
},
// 打开抽屉
loadMacro([author, m, id]) {
Expand All @@ -252,21 +229,6 @@ export default {
const prefix = this.client == "std" ? "www" : "origin";
return `${prefix}:/${appKey}/` + val;
},
loadGlobalSearch(appendMode = false) {
const params = {
filter_category: "宏库",
pageIndex: this.page,
pageSize: this.per,
q: this.search,
}
globalSearch(params).then(res => {
this.globalSearch = res.data.data?.hits?.map(item => item.id) || []
// this.total = res.data.data?.page?.total;
this.loadData(appendMode)
})
}
},
watch: {
// 加载路由参数
Expand Down

0 comments on commit 3e5c94b

Please sign in to comment.