improve question tag and card display

This commit is contained in:
2024-04-01 15:07:09 +08:00
parent 78688bbd77
commit 2a2895802f
5 changed files with 253 additions and 33 deletions

View File

@@ -178,4 +178,25 @@ const themeOverrides = {
position: absolute; position: absolute;
left: 0; left: 0;
} }
.slide-up-enter-active,
.slide-up-leave-active {
transition: all 0.5s ease-out;
}
.slide-up-enter-to {
position: absolute;
top: 0;
}
.slide-up-enter-from {
position: absolute;
top: -100%;
}
.slide-up-leave-to {
position: absolute;
bottom : -100%;
}
.slide-up-leave-from {
position: absolute;
bottom : 0;
}
</style> </style>

View File

@@ -173,6 +173,13 @@ onMounted(() => {
</NAlert> </NAlert>
<NButton type="primary" @click="refresh"> 刷新 </NButton> <NButton type="primary" @click="refresh"> 刷新 </NButton>
<NButton type="primary" @click="shareModalVisiable = true" secondary> 分享 </NButton> <NButton type="primary" @click="shareModalVisiable = true" secondary> 分享 </NButton>
<NButton
type="primary"
@click="$router.push({ name: 'user-questionBox', params: { id: accountInfo.name } })"
secondary
>
前往提问页
</NButton>
</NSpace> </NSpace>
<NDivider style="margin: 10px 0 10px 0" /> <NDivider style="margin: 10px 0 10px 0" />
<NSpin v-if="useQB.isLoading" show /> <NSpin v-if="useQB.isLoading" show />
@@ -188,7 +195,9 @@ onMounted(() => {
clearable clearable
:options="useQB.tags.map((s) => ({ label: s.name, value: s.name }))" :options="useQB.tags.map((s) => ({ label: s.name, value: s.name }))"
style="width: 200px" style="width: 200px"
/> >
<template #header> <NText strong depth="3"> 在设置选项卡中添加或删除话题 </NText> </template>
</NSelect>
<NCheckbox v-model:checked="useQB.onlyFavorite"> 只显示收藏 </NCheckbox> <NCheckbox v-model:checked="useQB.onlyFavorite"> 只显示收藏 </NCheckbox>
<NCheckbox v-model:checked="useQB.onlyPublic"> 只显示公开 </NCheckbox> <NCheckbox v-model:checked="useQB.onlyPublic"> 只显示公开 </NCheckbox>
<NCheckbox v-model:checked="useQB.onlyUnread"> 只显示未读 </NCheckbox> <NCheckbox v-model:checked="useQB.onlyUnread"> 只显示未读 </NCheckbox>
@@ -285,14 +294,16 @@ onMounted(() => {
类似于话题, 可以在投稿时选择 类似于话题, 可以在投稿时选择
</NTooltip> </NTooltip>
</NDivider> </NDivider>
<NInputGroup> <NFlex>
<NInputGroupLabel> 标签名称 </NInputGroupLabel> <NInputGroup style="max-width: 400px">
<NInput v-model:value="addTagName" placeholder="就是名称" maxlength="30" show-count clearable /> <NInputGroupLabel> 标签名称 </NInputGroupLabel>
<NButton type="primary" @click="useQB.addTag(addTagName)"> 添加 </NButton> <NInput v-model:value="addTagName" placeholder="就是名称" maxlength="30" show-count clearable />
</NInputGroup> <NButton type="primary" @click="useQB.addTag(addTagName)"> 添加 </NButton>
<NDivider style="margin: 15px 0 15px 0" /> </NInputGroup>
</NFlex>
<br />
<NEmpty v-if="useQB.tags.length == 0" description="暂无标签" /> <NEmpty v-if="useQB.tags.length == 0" description="暂无标签" />
<NFlex v-else justify="center"> <NFlex v-else>
<NList bordered> <NList bordered>
<NListItem v-for="item in useQB.tags.sort((a, b) => b.createAt - a.createAt)" :key="item.name"> <NListItem v-for="item in useQB.tags.sort((a, b) => b.createAt - a.createAt)" :key="item.name">
<NFlex align="center"> <NFlex align="center">

View File

@@ -56,18 +56,20 @@ onUnmounted(() => {
}" }"
:display="question ? 1 : 0" :display="question ? 1 : 0"
> >
<div <Transition name="scale" mode="out-in">
v-if="setting.showUserName && question" <div
class="question-display-user-name" v-if="setting.showUserName && question"
:style="{ class="question-display-user-name"
color: '#' + setting.nameFontColor, :style="{
fontSize: setting.nameFontSize + 'px', color: '#' + setting.nameFontColor,
fontWeight: setting.nameFontWeight ? setting.nameFontWeight : undefined, fontSize: setting.nameFontSize + 'px',
fontFamily: setting.nameFont, fontWeight: setting.nameFontWeight ? setting.nameFontWeight : undefined,
}" fontFamily: setting.nameFont,
> }"
{{ question?.sender?.name ?? '匿名用户' }} >
</div> {{ question?.sender?.name ?? '匿名用户' }}
</div>
</Transition>
<div <div
class="question-display-content" class="question-display-content"
:style="{ :style="{
@@ -78,15 +80,28 @@ onUnmounted(() => {
textAlign: align, textAlign: align,
fontFamily: setting.font, fontFamily: setting.font,
}" }"
:is-empty="question ? 0 : 1"
> >
<div class="question-display-text" :is-empty="question ? 0 : 1"> <Transition name="fade" mode="out-in">
{{ question?.question.message }} <template v-if="question">
</div> <div>
<img <div class="question-display-text">
class="question-display-image" {{ question?.question.message }}
v-if="setting.showImage && question?.question.image" </div>
:src="question?.question.image" <img
/> class="question-display-image"
v-if="setting.showImage && question?.question.image"
:src="question?.question.image"
/>
</div>
</template>
<div v-else class="question-display-loading loading" :style="{ color: '#' + setting.fontColor }">
<div :style="{ color: '#' + setting.fontColor }"></div>
<div></div>
<div></div>
<div></div>
</div>
</Transition>
</div> </div>
</div> </div>
</template> </template>
@@ -99,9 +114,9 @@ onUnmounted(() => {
border: 2 solid rgb(255, 255, 255); border: 2 solid rgb(255, 255, 255);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
transition: all 0.3s ease;
border-style: solid; border-style: solid;
box-sizing: border-box; box-sizing: border-box;
transition: all 0.3s ease;
} }
.question-display-content { .question-display-content {
border-radius: 10px; border-radius: 10px;
@@ -110,19 +125,156 @@ onUnmounted(() => {
height: 100%; height: 100%;
justify-content: space-evenly; justify-content: space-evenly;
padding: 24px; padding: 24px;
overflow: auto;
} }
.question-display-user-name { .question-display-user-name {
text-align: center; text-align: center;
margin: 5px; margin: 5px;
transition: all 0.3s ease; height: 32px;
text-overflow: ellipsis;
white-space: nowrap;
} }
.question-display-text { .question-display-text {
min-height: 50px; min-height: 50px;
transition: all 0.3s ease;
} }
.question-display-image { .question-display-image {
max-width: 40%; max-width: 40%;
max-height: 40%; max-height: 40%;
margin: 0 auto; margin: 0 auto;
} }
::-webkit-scrollbar {
width: 10px;
height: 10px;
}
::-webkit-scrollbar-thumb {
background: hsla(0, 0%, 51%, 0.377);
-webkit-box-shadow: none;
border-radius: 10px;
-webkit-box-shadow: none;
}
::-webkit-scrollbar-track {
border-radius: 10px;
background: #cccccc4b;
-webkit-box-shadow: none;
-webkit-box-shadow: none;
}
</style>
<style scoped>
.loading,
.loading > div {
position: relative;
box-sizing: border-box;
}
.loading {
display: block;
margin: 0 auto;
font-size: 0;
}
.loading.la-dark {
color: #333;
}
.loading > div {
display: inline-block;
float: none;
background-color: currentColor;
border: 0 solid currentColor;
}
.loading {
width: 40px;
height: 10px;
}
.loading > div {
width: 10px;
height: 10px;
border-radius: 100%;
}
.loading > div:first-child {
transform: translateX(0%);
animation: ball-newton-cradle-left 1.5s 0s ease-out infinite;
}
.loading > div:last-child {
transform: translateX(0%);
animation: ball-newton-cradle-right 1.5s 0s ease-out infinite;
}
.loading.la-sm {
width: 20px;
height: 4px;
}
.loading.la-sm > div {
width: 4px;
height: 4px;
}
.loading.la-2x {
width: 80px;
height: 20px;
}
.loading.la-2x > div {
width: 20px;
height: 20px;
}
.loading.la-3x {
width: 120px;
height: 30px;
}
.loading.la-3x > div {
width: 30px;
height: 30px;
}
@keyframes ball-newton-cradle-left {
25% {
transform: translateX(-200%);
animation-timing-function: ease-in;
}
50% {
transform: translateX(0%);
}
}
@keyframes ball-newton-cradle-right {
50% {
transform: translateX(0%);
}
75% {
transform: translateX(200%);
animation-timing-function: ease-in;
}
100% {
transform: translateX(0%);
}
}
.loading > div:first-child {
animation: ball-newton-cradle-left 1.5s 0s ease-in-out infinite;
}
.loading > div:last-child {
animation: ball-newton-cradle-right 1.5s 0s ease-in-out infinite;
}
</style> </style>

View File

@@ -72,7 +72,7 @@ watch([cardSize.width, cardSize.height], () => {
const setting = computed({ const setting = computed({
get: () => { get: () => {
if (accountInfo.value) { if (accountInfo.value && accountInfo.value.settings) {
return accountInfo.value.settings.questionDisplay return accountInfo.value.settings.questionDisplay
} }
return defaultSettings return defaultSettings
@@ -161,6 +161,16 @@ onMounted(() => {
<template v-if="useQB.displayQuestion"> <template v-if="useQB.displayQuestion">
<NDivider style="margin: 10px 0 10px 0" /> <NDivider style="margin: 10px 0 10px 0" />
<NCard size="small" title="当前展示" embedded> <NCard size="small" title="当前展示" embedded>
<template #header-extra>
<NFlex>
<NButton @click="useQB.setCurrentQuestion(useQB.displayQuestion)" size="small" secondary type="info">
取消展示
</NButton>
<NButton @click="useQB.read(useQB.displayQuestion, true)" size="small" secondary type="success">
已读
</NButton>
</NFlex>
</template>
<QuestionItem :item="useQB.displayQuestion" /> <QuestionItem :item="useQB.displayQuestion" />
</NCard> </NCard>
<NDivider style="margin: 10px 0 10px 0" /> <NDivider style="margin: 10px 0 10px 0" />

View File

@@ -18,6 +18,7 @@ import {
NListItem, NListItem,
NSelect, NSelect,
NSpace, NSpace,
NTag,
NText, NText,
NTime, NTime,
NTooltip, NTooltip,
@@ -136,7 +137,11 @@ function getTags() {
}) })
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
tags.value = data.data if (userInfo?.id == accountInfo.value.id) {
tags.value = data.data.map((tag) => JSON.parse(JSON.stringify(tag)).name)
} else {
tags.value = data.data
}
} else { } else {
message.error('获取标签失败:' + data.message) message.error('获取标签失败:' + data.message)
} }
@@ -148,6 +153,13 @@ function getTags() {
isGetting.value = false isGetting.value = false
}) })
} }
function onSelectTag(tag: string) {
if (selectedTag.value == tag) {
selectedTag.value = null
return
}
selectedTag.value = tag
}
onMounted(() => { onMounted(() => {
getPublicQuestions() getPublicQuestions()
@@ -163,6 +175,20 @@ onUnmounted(() => {
<div style="max-width: 700px; margin: 0 auto" title="提问"> <div style="max-width: 700px; margin: 0 auto" title="提问">
<NCard embedded> <NCard embedded>
<NSpace vertical> <NSpace vertical>
<NCard title="投稿话题 (可选)" size="small">
<NSpace v-if="tags.length > 0">
<NTag
v-for="tag in tags"
:key="tag"
@click="onSelectTag(tag)"
style="cursor: pointer"
:bordered="false"
:type="selectedTag == tag ? 'primary' : 'default'"
>
{{ tag }}
</NTag>
</NSpace>
</NCard>
<NSpace align="center" justify="center"> <NSpace align="center" justify="center">
<NSelect <NSelect
v-model:value="selectedTag" v-model:value="selectedTag"