add question delete

This commit is contained in:
2024-04-18 21:49:33 +08:00
parent b63d3f36ce
commit 000963fd38
3 changed files with 35 additions and 6 deletions

View File

@@ -99,6 +99,22 @@ export const useQuestionBox = defineStore('QuestionBox', () => {
isLoading.value = false isLoading.value = false
}) })
} }
async function DelQA(id: number) {
await QueryGetAPI(QUESTION_API_URL + 'del', {
id: id,
})
.then((data) => {
if (data.code == 200) {
message.success('删除成功')
recieveQuestions.value = recieveQuestions.value.filter((q) => q.id != id)
} else {
message.error(data.message)
}
})
.catch((err) => {
message.error('发生错误: ' + err)
})
}
async function GetTags() { async function GetTags() {
isLoading.value = true isLoading.value = true
await QueryGetAPI<QATagInfo[]>(QUESTION_API_URL + 'get-tags', { await QueryGetAPI<QATagInfo[]>(QUESTION_API_URL + 'get-tags', {
@@ -296,8 +312,8 @@ export const useQuestionBox = defineStore('QuestionBox', () => {
message.error('拉黑失败: ' + err) message.error('拉黑失败: ' + err)
}) })
} }
async function setCurrentQuestion(item: QAInfo) { async function setCurrentQuestion(item: QAInfo | undefined) {
const isCurrent = displayQuestion.value?.id == item.id const isCurrent = displayQuestion.value?.id == item?.id
if (!isCurrent) { if (!isCurrent) {
displayQuestion.value = item displayQuestion.value = item
} else { } else {
@@ -306,7 +322,7 @@ export const useQuestionBox = defineStore('QuestionBox', () => {
try { try {
const data = await QueryGetAPI( const data = await QueryGetAPI(
QUESTION_API_URL + 'set-current', QUESTION_API_URL + 'set-current',
isCurrent isCurrent || !item
? null ? null
: { : {
id: item.id, id: item.id,
@@ -339,6 +355,7 @@ export const useQuestionBox = defineStore('QuestionBox', () => {
displayTag, displayTag,
GetRecieveQAInfo, GetRecieveQAInfo,
GetSendQAInfo, GetSendQAInfo,
DelQA,
GetTags, GetTags,
addTag, addTag,
delTag, delTag,

View File

@@ -44,7 +44,7 @@ import QrcodeVue from 'qrcode.vue'
import { computed, onMounted, ref } from 'vue' import { computed, onMounted, ref } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import QuestionItem from '@/components/QuestionItems.vue' import QuestionItem from '@/components/QuestionItems.vue'
import { ArrowCircleRight12Filled, Delete24Regular, Eye24Filled, EyeOff24Filled, Info24Filled } from '@vicons/fluent' import { Delete24Filled, Delete24Regular, Eye24Filled, EyeOff24Filled, Info24Filled, } from '@vicons/fluent'
import { useQuestionBox } from '@/store/useQuestionBox' import { useQuestionBox } from '@/store/useQuestionBox'
const accountInfo = useAccount() const accountInfo = useAccount()
@@ -218,13 +218,24 @@ onMounted(() => {
</template> </template>
收藏 收藏
</NButton> </NButton>
<NPopconfirm @positive-click="useQB.DelQA(item.id)">
<template #trigger>
<NButton size="small" type="error">
<template #icon>
<NIcon :component="Delete24Filled"/>
</template>
删除
</NButton>
</template>
确认删除这条提问
</NPopconfirm>
<!-- <NTooltip> <!-- <NTooltip>
<template #trigger> <template #trigger>
<NButton size="small"> 举报 </NButton> <NButton size="small"> 举报 </NButton>
</template> </template>
暂时还没写 暂时还没写
</NTooltip> --> </NTooltip> -->
<NButton size="small" @click="useQB.blacklist(item)"> 拉黑 </NButton> <NButton size="small" @click="useQB.blacklist(item)" type="warning"> 拉黑 </NButton>
</NSpace> </NSpace>
</template> </template>
<template #header-extra="{ item }"> <template #header-extra="{ item }">

View File

@@ -16,7 +16,7 @@ import {
TextAlignLeft16Filled, TextAlignLeft16Filled,
TextAlignRight16Filled, TextAlignRight16Filled,
} from '@vicons/fluent' } from '@vicons/fluent'
import { Heart, HeartOutline } from '@vicons/ionicons5' import { Heart, HeartOutline, Delete24Filled } from '@vicons/ionicons5'
import { useDebounceFn, useElementSize, useStorage } from '@vueuse/core' import { useDebounceFn, useElementSize, useStorage } from '@vueuse/core'
import { import {
NButton, NButton,
@@ -33,6 +33,7 @@ import {
NInputGroupLabel, NInputGroupLabel,
NInputNumber, NInputNumber,
NModal, NModal,
NPopconfirm,
NRadioButton, NRadioButton,
NRadioGroup, NRadioGroup,
NScrollbar, NScrollbar,