Skip to content

Commit

Permalink
fix: create poll and pagination issue
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat616 committed Aug 27, 2023
1 parent 97ee8bd commit b3f1c2a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composables/api/reviewer/poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export type PollListRes = {
}

export function usePollList(
req: PollListReq,
req: PollListReq | Ref<PollListReq>,
options: HTTPOption<PollListRes> = {}
) {
return useHTTP.get<PollListRes>('/poll', req, options)
Expand Down
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
ssr: process.env.NODE_ENV !== 'development',
// ssr: process.env.NODE_ENV !== 'development',
app: {
head: {
meta: [
Expand Down
31 changes: 18 additions & 13 deletions pages/dashboard/do_review.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,23 @@ const segmentOptions = reactive<string[]>(['全部', '待审核', '已审核'])
const segmentedValue = ref(segmentOptions[0])
// 获取投票列表
const {
pending,
data: pollListData,
error,
refresh
} = usePollList(
{
const pollListParams = computed(() => {
return {
status_start: PollStatus.Open,
status_end: PollStatus.Open,
with_records: true,
page: page.value,
page_size: pageSize.value
},
{ lazy: true }
)
}
})
const {
pending,
data: pollListData,
error,
refresh
} = usePollList(pollListParams, { lazy: true })
watch(
() => route.query,
() => [page.value, pageSize.value],
() => refresh()
)
Expand Down Expand Up @@ -114,7 +114,7 @@ const getNewPoll = async () => {
// 如果当前页面是最后一页且不足 pageSize 条,刷新页面
if (
!pollListData.value?.data?.total ||
(page.value * pageSize.value < pollListData.value?.data?.total &&
(page.value * pageSize.value > pollListData.value?.data?.total &&
cardData.value.length < pageSize.value)
) {
refresh()
Expand Down Expand Up @@ -201,7 +201,12 @@ onMounted(() => {
</a-button>
</div>
<div class="mobile">
<a-button type="primary">
<a-button
type="primary"
:loading="getNewPollLoading"
:disabled="getNewPollLoading"
@click="getNewPoll"
>
<template #icon>
<PlusCircleOutlined />
</template>
Expand Down

0 comments on commit b3f1c2a

Please sign in to comment.