Skip to content

Commit

Permalink
feat: add dislike button; fix: padding overflow of IconButton; v-divi…
Browse files Browse the repository at this point in the history
…der style
  • Loading branch information
dest1n1s committed Jul 21, 2023
1 parent 9ebebf5 commit 7ef89cd
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/components/TheLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
>
<v-list-item-title>{{ division.name }}</v-list-item-title>
</v-list-item>
<v-divider />
<v-divider class="border-gray-800" />
<template v-if="userStore.isAdmin">
<v-list-item
class="text-left pl-10 cursor-pointer select-none"
Expand All @@ -54,7 +54,7 @@
>
<v-list-item-title>管理</v-list-item-title>
</v-list-item>
<v-divider />
<v-divider class="border-gray-800" />
</template>
<v-list-item
v-for="(r, i) in otherRoutes"
Expand Down
21 changes: 19 additions & 2 deletions src/components/floor/FloorBlockAction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@
>
mdi-thumb-up-outline
</IconBtn>
<IconBtn
:icon-class="
floor instanceof DetailedFloor && floor.disliked ? 'text-red-500' : 'text-neutral-400'
"
:text="floor.dislike"
@click="sendDislike"
>
mdi-thumb-down-outline
</IconBtn>
<IconBtn @click="reply"> mdi-chat-outline </IconBtn>
<v-divider
class="mx-1"
class="mx-1 border-gray-800"
:vertical="true"
/>
<IconBtn
Expand Down Expand Up @@ -47,7 +56,7 @@
</IconBtn>
<v-divider
v-if="userStore.isAdmin || (floor instanceof DetailedFloor && floor.isMe)"
class="mx-1"
class="mx-1 border-gray-800"
:vertical="true"
/>
<IconBtn @click="toggleAction(ActionType.Report)"> mdi-alert-octagon-outline </IconBtn>
Expand Down Expand Up @@ -335,6 +344,14 @@ const sendLike = async () => {
}
}
const sendDislike = async () => {
if (floor.value instanceof DetailedFloor && floor.value.disliked) {
floor.value = await likeFloor(floor.value.id, 0)
} else {
floor.value = await likeFloor(floor.value.id, -1)
}
}
const sendReport = async () => {
if (reportReason.value === '') {
not.error('举报理由不能为空')
Expand Down
2 changes: 1 addition & 1 deletion src/components/floor/ReportBlock.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<p class="flex">
<p class="flex pt-2">
<span class="font-bold min-w-max">举报理由:</span>
<span> {{ report.reason }} </span>
<span class="grow"></span>
Expand Down
4 changes: 2 additions & 2 deletions src/components/floor/ReportBlockAction.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template>
<div>
<div class="flex justify-end mt-2 overflow-visible">
<div class="flex justify-end py-2 overflow-visible">
<IconBtn @click="toggleAction(ActionType.Delete)">mdi-delete-outline</IconBtn>
<IconBtn @click="toggleAction(ActionType.Penalty)">mdi-account-off-outline</IconBtn>
<v-divider
class="mx-1"
class="mx-1 border-gray-800"
:vertical="true"
/>
<IconBtn
Expand Down
6 changes: 6 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export class Floor {
@Field()
like: number

@Field()
dislike: number

@Field({ type: Date })
timeCreated: Date

Expand All @@ -54,6 +57,9 @@ export class DetailedFloor extends Floor {
@Field()
liked?: boolean

@Field()
disliked?: boolean

@Field({ type: Floor, array: true })
mention: Floor[]

Expand Down
2 changes: 1 addition & 1 deletion src/views/admin/ReportView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</div>
<div class="hidden lg:block lg:max-w-[35%] xl:max-w-[30%] 3xl:max-w-[25%] pl-5 grow">
<v-list>
<v-list-item class="py-5">
<v-list-item class="py-3">
<p class="text-left">举报类别:</p>
<v-radio-group v-model="range">
<v-radio
Expand Down

0 comments on commit 7ef89cd

Please sign in to comment.