前端:

优化electron效果
This commit is contained in:
2026-03-07 13:40:06 +08:00
parent 333391d16f
commit e43f7d6365
52 changed files with 2929 additions and 543 deletions
+12
View File
@@ -11,6 +11,7 @@ using IM_API.Models.Upload;
using IM_API.Tools;
using IM_API.VOs;
using IM_API.VOs.Conversation;
using IM_API.VOs.Group;
using IM_API.VOs.Message;
namespace IM_API.Configs
@@ -203,6 +204,17 @@ namespace IM_API.Configs
.ForMember(dest => dest.Size, opt => opt.MapFrom(src => src.FileSize));
CreateMap<ImageDto, VideoDto>();
//群成员模型
CreateMap<UserInfoDto, GroupMemberVo>()
.ForMember(dest => dest.Nickname, opt => opt.MapFrom(src => src.NickName))
.ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.Username))
.ForMember(dest => dest.UserId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.Avatar, opt => opt.MapFrom(src => src.Avatar));
CreateMap<GroupMember, GroupMemberVo>()
.ForMember(dest => dest.Created, opt => opt.MapFrom(src => src.Created))
.ForMember(dest => dest.Role, opt => opt.MapFrom(src => src.RoleEnum));
}
}
}
@@ -1,6 +1,7 @@
using IM_API.Dtos;
using IM_API.Dtos.Group;
using IM_API.Interface.Services;
using IM_API.VOs.Group;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@@ -67,5 +68,14 @@ namespace IM_API.Controllers
var res = new BaseResponse<object?>();
return Ok(res);
}
[HttpGet]
[ProducesResponseType(typeof(BaseResponse<List<GroupMemberVo>>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetGroupMembers([FromQuery]int groupId)
{
var useridStr = User.FindFirstValue(ClaimTypes.NameIdentifier);
var members = await _groupService.GetGroupMembers(int.Parse(useridStr), groupId);
return Ok(new BaseResponse<List<GroupMemberVo>>(members));
}
}
}
@@ -1,5 +1,6 @@
using IM_API.Dtos.Group;
using IM_API.Models;
using IM_API.VOs.Group;
namespace IM_API.Interface.Services
{
@@ -51,5 +52,6 @@ namespace IM_API.Interface.Services
Task HandleGroupRequestAsync(int userid, HandleGroupRequestDto dto);
Task MakeGroupRequestAsync(int userId,int? adminUserId,int groupId);
Task MakeGroupMemberAsync(int userId, int groupId, GroupMemberRole? role);
Task<List<GroupMemberVo>> GetGroupMembers(int userId, int groupId);
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IM_API.Migrations
{
/// <inheritdoc />
public partial class uploadtaskurl : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Url",
table: "upload_tasks",
type: "longtext",
nullable: true,
collation: "utf8mb4_general_ci")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Url",
table: "upload_tasks");
}
}
}
@@ -812,6 +812,9 @@ namespace IM_API.Migrations
b.Property<int>("TotalChunks")
.HasColumnType("int");
b.Property<string>("Url")
.HasColumnType("longtext");
b.HasKey("Id")
.HasName("PRIMARY");
@@ -20,5 +20,6 @@
public string? ProviderUploadId { get; set; } // OSS/S3 UploadId
public DateTimeOffset CreatedAt { get; set; }
public string? Url { get; set; }
}
}
@@ -34,8 +34,9 @@ namespace IM_API.Services
var privateList = await (from c in _context.Conversations
join f in _context.Friends on new { c.UserId, c.TargetId }
equals new { UserId = f.UserId, TargetId = f.FriendId }
join u in _context.Users on c.TargetId equals u.Id
where c.UserId == userId && c.ChatType == ChatType.PRIVATE
select new { c, f.Avatar, f.RemarkName })
select new { c, u.Avatar, f.RemarkName })
.ToListAsync();
// 2. 获取群聊会话
+19
View File
@@ -2,13 +2,16 @@
using AutoMapper.QueryableExtensions;
using IM_API.Domain.Events;
using IM_API.Dtos.Group;
using IM_API.Dtos.User;
using IM_API.Exceptions;
using IM_API.Interface.Services;
using IM_API.Models;
using IM_API.Tools;
using IM_API.VOs.Group;
using MassTransit;
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
namespace IM_API.Services
{
@@ -247,5 +250,21 @@ namespace IM_API.Services
});
return;
}
public async Task<List<GroupMemberVo>> GetGroupMembers(int userId, int groupId)
{
var members = await _context.GroupMembers
.Where(x => x.GroupId == groupId).ToListAsync();
if (members is null || members.Count() == 0)
return [];
var users = await _userService.GetUserInfoListAsync(members.Select(x => x.UserId).ToList());
return users.Zip(members, (u, m) =>
{
var user = _mapper.Map<GroupMemberVo>(u);
_mapper.Map(m, user);
return user;
}).ToList();
}
}
}
@@ -157,9 +157,14 @@ namespace IM_API.Services
public async Task<UploadTask> UploadSmallFileAsync(Stream stream, string fileName, string fileType, long size, string hash)
{
var request = _httpContext.HttpContext?.Request;
var baseUrl = $"{request.Scheme}://{request.Host}";
var taskOld = await _uploadTaskService.GetTaskAsync(hash);
if (taskOld is not null) return taskOld;
if (taskOld is not null) {
taskOld.Url = UrlTools.GetFullUrl(taskOld.ObjectName, ProviderName, baseUrl);
return taskOld;
}
var userId = _httpContext.HttpContext?.User.FindFirstValue(ClaimTypes.NameIdentifier);
var objectname = ObjectNameGenerator.Generate(new ObjectNameContext
@@ -184,6 +189,7 @@ namespace IM_API.Services
FileSize = size,
Id = Guid.NewGuid(),
ObjectName = objectname,
Url = UrlTools.GetFullUrl(objectname, ProviderName, baseUrl),
ProviderUploadId = Guid.NewGuid().ToString(),
Status = UploadStatus.Completed,
StorageProvider = ProviderName,
+14
View File
@@ -0,0 +1,14 @@
using IM_API.Models;
namespace IM_API.VOs.Group
{
public class GroupMemberVo
{
public int UserId { get; set; }
public string Username { get; set; }
public string Nickname { get; set; }
public string Avatar { get; set; }
public GroupMemberRole Role { get; set; }
public DateTimeOffset Created { get; set; }
}
}