feat: 添加注册人数分析,优化bbs聊天回车优化

This commit is contained in:
橙子
2024-08-10 13:03:29 +08:00
parent 1c7486a7bc
commit 24b011ef93
6 changed files with 141 additions and 11 deletions

View File

@@ -0,0 +1,20 @@
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Analyse;
public class RegisterAnalyseDto
{
public RegisterAnalyseDto(DateTime time, int number)
{
Time = time;
Number = number;
}
/// <summary>
/// 时间
/// </summary>
public DateTime Time { get; set; }
/// <summary>
/// 人数
/// </summary>
public int Number { get; set; }
}

View File

@@ -48,12 +48,14 @@ namespace Yi.Framework.Bbs.Application.Services
/// <summary>
/// 获取全部访问流量
/// 获取全部访问流量(3个月)
/// </summary>
/// <returns></returns>
public async Task<List<AccessLogDto>> Get()
{
var entities = await _repository._DbQueryable.OrderBy(x => x.CreationTime).ToListAsync();
var entities = await _repository._DbQueryable
.Where(x=>x.CreationTime>=DateTime.Now.AddMonths(-3))
.OrderBy(x => x.CreationTime).ToListAsync();
var output = entities.Adapt<List<AccessLogDto>>();
output?.ForEach(x => x.CreationTime = x.CreationTime.Date);
return output;

View File

@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Analyse;
using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Integral;
@@ -26,6 +27,59 @@ namespace Yi.Framework.Bbs.Application.Services.Analyses
_onlineService = onlineService;
}
/// <summary>
/// 人数注册统计(近3个月)
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("analyse/bbs-user/register")]
public async Task<List<RegisterAnalyseDto>> GetRegisterAsync([FromQuery] PagedResultRequestDto input)
{
using (DataFilter.DisablePermissionHandler())
{
var users = await _bbsUserManager._userRepository._DbQueryable
.Where(u=>u.CreationTime>=DateTime.Now.AddMonths(-3))
.LeftJoin<BbsUserExtraInfoEntity>((u, info) => u.Id == info.UserId)
.Select((u, info) => new BbsUserGetListOutputDto()
{
Id = u.Id,
Icon = u.Icon,
Level = info.Level,
UserLimit = info.UserLimit,
Money = info.Money,
Experience = info.Experience,
CreationTime = u.CreationTime
})
.ToListAsync();
var minCreateUser = users.MinBy(x => x.CreationTime);
var userCreateTimeDic = users.OrderBy(x => x.CreationTime)
.GroupBy(x => x.CreationTime.Date)
.ToDictionary(x => x.Key.Date, y => y.Count());
DateTime startDate = minCreateUser.CreationTime.Date;
DateTime endDate = DateTime.Today;
List<RegisterAnalyseDto> output = new List<RegisterAnalyseDto>();
// 计算从起始日期到今天的所有天数
for (DateTime date = startDate; date <= endDate; date = date.AddDays(1))
{
var count = 0;
userCreateTimeDic.TryGetValue(date, out count);
RegisterAnalyseDto dayInfo = new RegisterAnalyseDto(date, count);
output.Add(dayInfo);
}
return output;
}
}
/// <summary>
/// 财富排行榜
/// </summary>
@@ -38,7 +92,7 @@ namespace Yi.Framework.Bbs.Application.Services.Analyses
RefAsync<int> total = 0;
var output = await _bbsUserManager._userRepository._DbQueryable
.LeftJoin<BbsUserExtraInfoEntity>((u, info) => u.Id == info.UserId)
.OrderByDescending((u,info) => info.Money)
.OrderByDescending((u, info) => info.Money)
.Select((u, info) =>
new MoneyTopUserDto
{
@@ -51,7 +105,6 @@ namespace Yi.Framework.Bbs.Application.Services.Analyses
Order = SqlFunc.RowNumber(u.Id)
}
)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
output.ForEach(x => { x.LevelName = _bbsUserManager._levelCacheDic[x.Level].Name; });

View File

@@ -51,3 +51,17 @@ export function getUserAnalyse(data) {
data,
});
}
/**
* 获取注册数量用户分析
* @param {*} data
* @returns
*/
export function getRegisterAnalyse(data) {
return request({
url: "/analyse/bbs-user/register",
method: "get",
data,
});
}

View File

@@ -288,6 +288,20 @@ const onclickUserItem = (userInfo, itemType) => {
changeInputValue(value);
}
//输入框按键事件
const handleKeydownInput=()=>{
// 检查是否按下 Shift + Enter
if (event.key === 'Enter' && event.shiftKey) {
// 允许输入换行
return; // 让默认行为继续
}
// 如果只按下 Enter则阻止默认的提交行为比如在表单中
if (event.key === 'Enter') {
onclickSendMsg();
}
}
//点击发送按钮
const onclickSendMsg = () => {
if (currentInputValue.value == "") {
@@ -389,7 +403,7 @@ const getLastMessage = ((receiveId, itemType) => {
<template>
<div style="position: absolute; top: 0;left: 0;" v-show="isShowTipNumber>0">
<p>当前版本1.5.0</p>
<p>当前版本1.5.1</p>
<p>tip:官方学习交流群每次发送消息消耗 1 钱钱</p>
<p>tip:点击聊天窗口右上角X可退出</p>
<p>tip:多人同时在聊天室时左侧可显示其他成员</p>
@@ -553,7 +567,9 @@ const getLastMessage = ((receiveId, itemType) => {
</div> -->
<textarea class="bottom-input" v-model="currentInputValue" @input="updateInputValue"
@keyup.enter="onclickSendMsg()">
@keydown="handleKeydownInput"
>
</textarea>
<div class="bottom-send">

View File

@@ -107,7 +107,7 @@
<AccessLogChart :option="accessLogOptins" style="height: 600px;width: 1200px;" />
</el-tab-pane>
<el-tab-pane label="注册统计" name="RegisterChart" style="display: flex;justify-content: center;">
即将上线敬请期待
<AccessLogChart :option="registerLogOptins" style="height: 600px;width: 1200px;" />
</el-tab-pane>
</el-tabs>
@@ -206,6 +206,7 @@ import {
getRecommendedFriend,
getRankingPoints,
getUserAnalyse,
getRegisterAnalyse
} from "@/apis/analyseApi.js";
import { getList as getAllDiscussList } from "@/apis/discussApi.js";
import PointsRanking from "./components/PointsRanking/index.vue";
@@ -218,6 +219,7 @@ const accessLogDialogVisible = ref(false)
const router = useRouter();
const accessAllList = ref([]);
const registerAllList = ref([]);
const plateList = ref([]);
const discussList = ref([]);
@@ -323,6 +325,26 @@ const accessLogOptins = computed(() => {
]
}
});
//历史注册人员全部访问统计
const registerLogOptins = computed(() => {
return {
xAxis: {
data: registerAllList.value?.map((item, index) => {
return item.time.slice(0, 10);
})
},
series: [
{
data: registerAllList.value?.map((item, index) => {
return item.number;
})
}
]
}
});
const onClickMoneyTop = () => {
router.push("/money");
@@ -347,14 +369,17 @@ watch(
);
watch(
() => accessLogTab.value,
async(value) => {
async (value) => {
switch (value) {
case "AccessLogChart":
const {data} = await getAccessList();
accessAllList.value = data;
const { data } = await getAccessList();
accessAllList.value = data;
break;
break;
case "RegisterChart":
const { data: registerUserListData } = await getRegisterAnalyse();
registerAllList.value = registerUserListData;
break;
}
}