Skip to content

Commit

Permalink
refactor: use masonry instead of grid card
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat616 committed Aug 31, 2023
1 parent 6da0e2c commit 141209f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"vite": "^4.4.9",
"vue-echarts": "^6.6.1",
"vue-masonry": "^0.16.0",
"vue-next-masonry": "^1.1.3",
"xss": "^1.0.14"
},
"dependencies": {
Expand Down
43 changes: 27 additions & 16 deletions pages/dashboard/records/review.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { UserPollLogsReq, useUserPollLogs } from '~/composables/api'
useHead({
title: '审核记录'
})
Expand Down Expand Up @@ -70,19 +69,31 @@ watch([page, pageSize], () => {
v-if="!userPollLogsPending && !userPollLogsError"
class="records-container"
>
<div class="records">
<template v-if="userPollLogsData && userPollLogsData.data.total > 0">
<ReviewRecordsCard
v-for="userPollLog in userPollLogsData.data.collection"
:key="userPollLog.poll_id"
:user-poll-log="userPollLog"
@show-poll-detail="showPollDetail"
/>
</template>
<div v-else class="status">
<a-empty />
</div>
</div>
<ClientOnly>
<masonry
class="records"
:cols="{ default: 2, 640: 1 }"
:gutter="'1rem'"
>
<template
v-if="userPollLogsData && userPollLogsData.data.total > 0"
>
<div
v-for="userPollLog in userPollLogsData.data.collection"
:key="userPollLog.poll_id"
class="py-2"
>
<ReviewRecordsCard
:user-poll-log="userPollLog"
@show-poll-detail="showPollDetail"
/>
</div>
</template>
<div v-else class="status">
<a-empty />
</div>
</masonry>
</ClientOnly>
<!-- 分页器 -->
<div
v-show="userPollLogsData && userPollLogsData.data.total > 0"
Expand Down Expand Up @@ -117,8 +128,8 @@ watch([page, pageSize], () => {
@apply w-full flex-1 flex flex-col;
.records {
@apply w-full flex-1 flex flex-col;
@apply grid grid-cols-1 md:grid-cols-2 gap-x-4 gap-y-4;
@apply w-full flex-1;
// @apply grid grid-cols-1 md:grid-cols-2 gap-x-4 gap-y-4;
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions plugins/masonry.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Masonry from 'vue-next-masonry'

export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(Masonry, null)
})
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 141209f

Please sign in to comment.