Skip to content

Commit

Permalink
feat: record the comment query conditions in the route query parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Wang <i@ryanc.cc>
  • Loading branch information
ruibaby committed Jul 13, 2023
1 parent efcf526 commit be1fe72
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions console/src/modules/contents/comments/CommentList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ import { apiClient } from "@/utils/api-client";
import { useQuery } from "@tanstack/vue-query";
import { useI18n } from "vue-i18n";
import UserFilterDropdown from "@/components/filter/UserFilterDropdown.vue";
import { useRouteQuery } from "@vueuse/router";
const { t } = useI18n();
const checkAll = ref(false);
const selectedComment = ref<ListedComment>();
const selectedCommentNames = ref<string[]>([]);
const keyword = ref("");
const selectedApprovedStatus = ref();
const selectedSort = ref();
const selectedUser = ref();
const keyword = useRouteQuery<string>("keyword", "");
const selectedApprovedStatus = useRouteQuery<string | undefined>(
"approved",
undefined
);
const selectedSort = useRouteQuery<string | undefined>("sort");
const selectedUser = useRouteQuery<string | undefined>("user");
watch(
() => [
Expand Down Expand Up @@ -57,8 +61,12 @@ function handleClearFilters() {
selectedUser.value = undefined;
}
const page = ref(1);
const size = ref(20);
const page = useRouteQuery<number>("page", 1, {
transform: Number,
});
const size = useRouteQuery<number>("size", 20, {
transform: Number,
});
const total = ref(0);
const {
Expand All @@ -80,7 +88,10 @@ const {
const { data } = await apiClient.comment.listComments({
page: page.value,
size: size.value,
approved: selectedApprovedStatus.value,
approved:
selectedApprovedStatus.value !== undefined
? Boolean(selectedApprovedStatus.value)
: undefined,
sort: [selectedSort.value].filter(Boolean) as string[],
keyword: keyword.value,
ownerName: selectedUser.value,
Expand Down

0 comments on commit be1fe72

Please sign in to comment.