feat:完成底部

This commit is contained in:
橙子
2023-03-24 22:39:35 +08:00
parent ab0d126c49
commit c83fcb7f26
17 changed files with 118 additions and 76 deletions

View File

@@ -12,4 +12,11 @@ export function add(data){
method: 'post',
data:data
})
};
export function del(ids){
return myaxios({
url: `/comment/${ids}`,
method: 'delete'
})
};

View File

@@ -1,25 +1,36 @@
<template>
<div class="body-div">
<a>站长橙子</a>
<a>YiFramework意框架</a>
<a>关于本站&nbsp&nbsp&nbsp&nbsp建议反馈</a>
<a>2023 <span style="color: #40a9ff ;">意社区</span> | 赣ICP备xxxxxx号-4</a>
<div class="botton-div">
<a><el-icon><UserFilled /></el-icon>站长橙子</a>
<a><el-icon><Search /></el-icon>YiFramework意框架</a>
<a><el-icon><View /></el-icon>关于本站</a>
<a><el-icon><Message /></el-icon>建议反馈</a>
<p></p>
<a><el-icon><Position /></el-icon>2023 <span style="color: #40a9ff ;">意社区</span> | 赣ICP备xxxxxx号-4</a>
</div>
</template>
<script setup>
</script>
<style scoped>
.el-icon
{margin: 0 0.2rem;}
a{
display: block;
margin-right: 2rem;
line-height: 1.8rem;
}
a:hover {
color: #40a9ff;
cursor:pointer;
}
.body-div
.botton-div
{
background: transparent;
color: rgba(0,0,0,.45);
font-size: 14px;
display: flex;
flex-wrap: wrap;
height: auto;
width: auto;
justify-content: center;
margin: 1rem auto;
}
</style>

View File

@@ -32,21 +32,23 @@
<span class="pointer"><el-icon>
<Pointer />
</el-icon> 4</span>
<el-button @click="replay(item.createUser.nick, item.id, item.id)" size="large" text>回复</el-button>
<el-button type="primary" @click="replay(item.createUser.nick, item.id, item.id)" size="large" text>回复</el-button>
<el-button type="danger" @click="delComment(item.id)" size="large" text>删除</el-button>
<div v-show="replayId == item.id" class="input-reply">
<el-input v-model="form.content" :placeholder="placeholder" :rows="3" type="textarea"></el-input>
<div class="btn-reply">
<el-button @click="addComment" type="primary">回复</el-button>
</div>
</div>
<!-- 开始子评论主体 -->
<div v-for="children in item.children" :key="children.id" class="comment2">
<div style="display: flex ;">
<AvatarInfo :userInfo="children.createUser" />
<span style="align-self: center;"> 回复@{{ children.commentedUser.nick }}</span>
<span style="align-self: center;color:#606266;"> 回复@{{ children.commentedUser.nick }}</span>
</div>
<div class="content">
{{ children.content }}
@@ -55,8 +57,8 @@
<span class="pointer"> <el-icon>
<Pointer />
</el-icon>0</span>
<el-button @click="replay(children.createUser.nick, children.id, item.id)" size="large" text>回复</el-button>
<el-button type="primary" @click="replay(children.createUser.nick, children.id, item.id)" size="large" text>回复</el-button>
<el-button type="danger" @click="delComment(children.id)" size="large" text>删除</el-button>
<div v-show="replayId == children.id" class="input-reply">
<el-input v-model="form.content" :placeholder="placeholder" :rows="3" type="textarea"></el-input>
<div class="btn-reply">
@@ -74,7 +76,7 @@
<script setup>
import { onMounted, reactive, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
import { getListByDiscussId, add } from "@/apis/commentApi.js";
import { getListByDiscussId, add ,del} from "@/apis/commentApi.js";
import AvatarInfo from './AvatarInfo.vue';
//数据定义
const route = useRoute();
@@ -129,6 +131,23 @@ const addComment = async () => {
type: 'success',
})
};
const delComment=async(ids)=>{
ElMessageBox.confirm(`确定是否删除编号[${ids}]的评论吗?`, "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "warning",
}).then(async () => {
await del(ids);
await loadComment();
ElMessage({
message: '评论已删除!',
type: 'success',
})
});
}
const replay = async (parentUserName, parentId, rootId) => {
replayId.value = parentId;
form.parentId = parentId;

View File

@@ -19,8 +19,9 @@
</div>
<el-button icon="Pointer" text @click="agree">
点赞:{{ agreeNum??0 }}</el-button>
<el-button text @click="agree" >
<el-icon v-if="isAgree" color="#409EFF"><CircleCheckFilled /></el-icon>
<el-icon v-else color="#1E1E1E" ><Pointer /></el-icon> 点赞:{{ agreeNum??0 }}</el-button>
<el-button icon="Star" text>
收藏</el-button>
@@ -39,7 +40,7 @@ import { useRouter } from 'vue-router'
import AvatarInfo from './AvatarInfo.vue';
import {operate} from '@/apis/agreeApi'
const props = defineProps(['title','introduction','creationTime','id','user','badge',"color","seeNum","agreeNum"])
const props = defineProps(['title','introduction','creationTime','id','user','badge',"color","seeNum","agreeNum","isAgree"])
const router = useRouter()
const spacer = h(ElDivider, { direction: 'vertical' })
@@ -47,13 +48,15 @@ const enterDiscuss = (id) => {
router.push(`/article/${id}`)
}
const agreeNum=ref(0)
const isAgree=ref(false)
//点赞操作
const agree=async ()=>{
const response= await operate(props.id)
const res=response.data;
//提示框,颜色区分
if(res.isArgee)
if(res.isAgree)
{
isAgree.value=true;
agreeNum.value+=1;
ElMessage({
message: res.message,
@@ -62,6 +65,7 @@ const agree=async ()=>{
}
else
{
isAgree.value=false;
agreeNum.value-=1;
ElMessage({
message: res.message,
@@ -70,6 +74,7 @@ const agree=async ()=>{
}
}
onMounted(()=>{
isAgree.value=props.isAgree;
agreeNum.value=props.agreeNum;
})
</script>

View File

@@ -58,7 +58,9 @@
<CommentInfo/>
</el-col>
</el-row>
<BottomInfo/>
</el-col>
<el-col :span="5">
@@ -126,7 +128,7 @@ import AvatarInfo from "@/components/AvatarInfo.vue";
import InfoCard from "@/components/InfoCard.vue";
import ArticleContentInfo from "@/components/ArticleContentInfo.vue";
import CommentInfo from "@/components/CommentInfo.vue";
import BottomInfo from '@/components/BottomInfo.vue'
import TreeArticleInfo from "@/components/TreeArticleInfo.vue";
import { useRoute, useRouter } from "vue-router";

View File

@@ -58,14 +58,14 @@
</div>
</template>
<div class="div-item" v-for="i in topDiscussList" >
<DisscussCard :title="i.title" :introduction="i.introduction" :creationTime="i.creationTime" :agreeNum="i.agreeNum" :id="i.id" :user="i.user" :color="i.color" :seeNum="i.seeNum" badge="置顶"/>
<DisscussCard :title="i.title" :isAgree="i.isAgree" :introduction="i.introduction" :creationTime="i.creationTime" :agreeNum="i.agreeNum" :id="i.id" :user="i.user" :color="i.color" :seeNum="i.seeNum" badge="置顶"/>
</div>
</el-collapse-item>
</el-collapse>
<el-divider v-show="topDiscussList.length>0" />
<div class="div-item" v-for="i in discussList" >
<DisscussCard :title="i.title" :introduction="i.introduction" :creationTime="i.creationTime" :agreeNum="i.agreeNum" :id="i.id" :color="i.color" :seeNum="i.seeNum" :user="i.user"/>
<DisscussCard :title="i.title" :isAgree="i.isAgree" :introduction="i.introduction" :creationTime="i.creationTime" :agreeNum="i.agreeNum" :id="i.id" :color="i.color" :seeNum="i.seeNum" :user="i.user"/>
</div>
<div>
<el-pagination
@@ -81,7 +81,12 @@
</div>
<el-empty v-if="discussList.length==0" description="空空如也" />
<BottomInfo/>
</div>
</template>
@@ -90,7 +95,7 @@ import DisscussCard from '@/components/DisscussCard.vue'
import {getList,getTopList} from '@/apis/discussApi.js'
import { onMounted, ref,reactive } from 'vue'
import { useRoute,useRouter } from 'vue-router'
import BottomInfo from '@/components/BottomInfo.vue'
//数据定义
const route=useRoute()
const router=useRouter()

View File

@@ -10,11 +10,11 @@
<el-row class="left-div">
<el-col :span="8" v-for="i in plateList" class="plate" :style="{ 'padding-left': i%3==1?0:0.2+'rem','padding-right': i%3==0?0:0.2+'rem'}" >
<PlateCard :name="i.name" :introduction="i.introduction" :id="i.id"/>
<PlateCard :name="i.name" :introduction="i.introduction" :id="i.id" />
</el-col>
<el-col :span="24" v-for="i in discussList">
<DisscussCard :title="i.title" :introduction="i.introduction" :creationTime="i.creationTime" :agreeNum="i.agreeNum" :id="i.id" :user="i.user" :seeNum="i.seeNum"/>
<DisscussCard :title="i.title" :introduction="i.introduction" :creationTime="i.creationTime" :agreeNum="i.agreeNum" :id="i.id" :user="i.user" :seeNum="i.seeNum" :isAgree="i.isAgree"/>
</el-col>
<el-col :span="24">

View File

@@ -94,6 +94,11 @@
Discuss输入创建对象
</summary>
</member>
<member name="P:Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussGetListOutputDto.IsAgree">
<summary>
是否已点赞
</summary>
</member>
<member name="T:Yi.BBS.Application.Contracts.Forum.Dtos.MyTypeCreateInputVo">
<summary>
Label输入创建对象

View File

@@ -6,12 +6,12 @@ using System.Threading.Tasks;
namespace Yi.BBS.Application.Contracts.Exhibition.Dtos.Argee
{
public class ArgeeDto
public class AgreeDto
{
public ArgeeDto(bool isArgee)
public AgreeDto(bool isAgree)
{
IsArgee = isArgee;
if (isArgee)
IsAgree = isAgree;
if (isAgree)
{
Message = "点赞成功,点赞+1";
@@ -24,7 +24,7 @@ namespace Yi.BBS.Application.Contracts.Exhibition.Dtos.Argee
}
public bool IsArgee { get; set; }
public bool IsAgree { get; set; }
public string Message { get; set; }
}
}

View File

@@ -37,7 +37,7 @@ namespace Yi.BBS.Application.Exhibition
/// 点赞,返回true为点赞+1返回false为点赞-1
/// </summary>
/// <returns></returns>
public async Task<ArgeeDto> PostOperateAsync(long discussId)
public async Task<AgreeDto> PostOperateAsync(long discussId)
{
var entity = await _repository.GetFirstAsync(x => x.DiscussId == discussId && x.CreatorId == _currentUser.Id);
//判断是否已经点赞过
@@ -56,7 +56,7 @@ namespace Yi.BBS.Application.Exhibition
await _discssRepository.UpdateAsync(discussEntity);
uow.Commit();
}
return new ArgeeDto(true);
return new AgreeDto(true);
}
else
@@ -75,7 +75,7 @@ namespace Yi.BBS.Application.Exhibition
uow.Commit();
}
return new ArgeeDto(false);
return new AgreeDto(false);
}
}
}

View File

@@ -94,6 +94,11 @@
Discuss输入创建对象
</summary>
</member>
<member name="P:Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussGetListOutputDto.IsAgree">
<summary>
是否已点赞
</summary>
</member>
<member name="T:Yi.BBS.Application.Contracts.Forum.Dtos.MyTypeCreateInputVo">
<summary>
Label输入创建对象

View File

@@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.BBS.Application.Contracts.Exhibition.Dtos.Argee
{
public class ArgeeDto
{
public ArgeeDto(bool isArgee)
{
IsArgee = isArgee;
if (isArgee)
{
Message = "点赞成功,点赞+1";
}
else
{
Message = "取消点赞,点赞-1";
}
}
public bool IsArgee { get; set; }
public string Message { get; set; }
}
}

View File

@@ -11,7 +11,10 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
{
public class DiscussGetListOutputDto : IEntityDto<long>
{
/// <summary>
/// <20>Ƿ<EFBFBD><C7B7>ѵ<EFBFBD><D1B5><EFBFBD>
/// </summary>
public bool IsAgree { get; set; }
public long Id { get; set; }
public string Title { get; set; }
public string Types { get; set; }

View File

@@ -37,7 +37,7 @@ namespace Yi.BBS.Application.Exhibition
/// 点赞,返回true为点赞+1返回false为点赞-1
/// </summary>
/// <returns></returns>
public async Task<ArgeeDto> PostOperateAsync(long discussId)
public async Task<AgreeDto> PostOperateAsync(long discussId)
{
var entity = await _repository.GetFirstAsync(x => x.DiscussId == discussId && x.CreatorId == _currentUser.Id);
//判断是否已经点赞过
@@ -56,7 +56,7 @@ namespace Yi.BBS.Application.Exhibition
await _discssRepository.UpdateAsync(discussEntity);
uow.Commit();
}
return new ArgeeDto(true);
return new AgreeDto(true);
}
else
@@ -75,7 +75,7 @@ namespace Yi.BBS.Application.Exhibition
uow.Commit();
}
return new ArgeeDto(false);
return new AgreeDto(false);
}
}
}

View File

@@ -17,6 +17,8 @@ using Yi.RBAC.Application.Contracts.Identity.Dtos;
using Cike.EventBus.DistributedEvent;
using Yi.BBS.Domain.Shared.Forum.Etos;
using Yi.BBS.Domain.Shared.Forum.EnumClasses;
using Yi.Framework.Core.CurrentUsers;
using Yi.BBS.Domain.Exhibition.Entities;
namespace Yi.BBS.Application.Forum
{
@@ -36,6 +38,8 @@ namespace Yi.BBS.Application.Forum
[Autowired]
private IDistributedEventBus _distributedEventBus { get; set; }
[Autowired]
private ICurrentUser _currentUser { get; set; }
/// <summary>
/// 单查
/// </summary>
@@ -47,10 +51,13 @@ namespace Yi.BBS.Application.Forum
var item = await _DbQueryable.LeftJoin<UserEntity>((discuss, user) => discuss.CreatorId == user.Id)
.Select((discuss, user) => new DiscussGetOutputDto
{
User = new UserGetListOutputDto() { UserName = user.UserName, Nick = user.Nick,Icon=user.Icon }
}, true).SingleAsync(discuss => discuss.Id==id);
_distributedEventBus.PublishAsync(new SeeDiscussEventArgs { DiscussId= item.Id, OldSeeNum= item .SeeNum});
User = new UserGetListOutputDto() { UserName = user.UserName, Nick = user.Nick, Icon = user.Icon }
}, true).SingleAsync(discuss => discuss.Id == id);
if (item is not null)
{
_distributedEventBus.PublishAsync(new SeeDiscussEventArgs { DiscussId = item.Id, OldSeeNum = item.SeeNum });
}
return item;
}
@@ -61,21 +68,24 @@ namespace Yi.BBS.Application.Forum
/// <param name="input"></param>
/// <returns></returns>
public override async Task<PagedResultDto<DiscussGetListOutputDto>> GetListAsync( [FromQuery] DiscussGetListInputVo input)
public override async Task<PagedResultDto<DiscussGetListOutputDto>> GetListAsync([FromQuery] DiscussGetListInputVo input)
{
//需要关联创建者用户
RefAsync<int> total = 0;
var items = await _DbQueryable
.WhereIF(!string.IsNullOrEmpty(input.Title), x => x.Title.Contains(input.Title))
.WhereIF(input.PlateId is not null, x => x.PlateId == input.PlateId)
.Where(x=>x.IsTop==input.IsTop)
.OrderByIF(input.Type==QueryDiscussTypeEnum.New, x =>x.CreationTime,OrderByType.Desc )
.Where(x => x.IsTop == input.IsTop)
.OrderByIF(input.Type == QueryDiscussTypeEnum.New, x => x.CreationTime, OrderByType.Desc)
.OrderByIF(input.Type == QueryDiscussTypeEnum.Host, x => x.SeeNum, OrderByType.Desc)
.OrderByIF(input.Type == QueryDiscussTypeEnum.Suggest, x => x.AgreeNum, OrderByType.Desc)
.LeftJoin<UserEntity>((discuss, user) => discuss.CreatorId==user.Id)
.Select((discuss,user) =>new DiscussGetListOutputDto {
User=new UserGetListOutputDto() { UserName=user.UserName,Nick=user.Nick, Icon = user.Icon }
},true)
.LeftJoin<UserEntity>((discuss, user) => discuss.CreatorId == user.Id)
.Select((discuss, user) => new DiscussGetListOutputDto
{
Id=discuss.Id,
IsAgree = SqlFunc.Subqueryable<AgreeEntity>().Where(x => x.CreatorId == _currentUser.Id && x.DiscussId == discuss.Id).Any(),
User = new UserGetListOutputDto() { UserName = user.UserName, Nick = user.Nick, Icon = user.Icon }
}, true)
.ToPageListAsync(input.PageNum, input.PageSize, total);
return new PagedResultDto<DiscussGetListOutputDto>(total, items);
}