diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussGetListOutputDto.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussGetListOutputDto.cs index df37566f..c3be2a81 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussGetListOutputDto.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Discuss/DiscussGetListOutputDto.cs @@ -9,11 +9,11 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss public class DiscussGetListOutputDto : EntityDto { /// - /// 是否禁止评论创建功能 + /// 鏄惁绂佹璇勮鍒涘缓鍔熻兘 /// public bool IsDisableCreateComment { get; set; } /// - /// 是否已点赞,默认未登录不点赞 + /// 鏄惁宸茬偣璧烇紝榛樿鏈櫥褰曚笉鐐硅禐 /// public bool IsAgree { get; set; } = false; public string Title { get; set; } @@ -23,26 +23,26 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss public int AgreeNum { get; set; } public int SeeNum { get; set; } - //批量查询,不给内容,性能考虑 + //鎵归噺鏌ヨ锛屼笉缁欏唴瀹癸紝鎬ц兘鑰冭檻 //public string Content { get; set; } public string? Color { get; set; } public Guid PlateId { get; set; } - //是否置顶,默认false + //鏄惁缃《锛岄粯璁alse public bool IsTop { get; set; } public DiscussPermissionTypeEnum PermissionType { get; set; } - //是否禁止,默认false + //鏄惁绂佹锛岄粯璁alse public bool IsBan { get; set; } /// - /// 封面 + /// 灏侀潰 /// public string? Cover { get; set; } - //私有需要判断code权限 + //绉佹湁闇瑕佸垽鏂璫ode鏉冮檺 public string? PrivateCode { get; set; } public DateTime CreationTime { get; set; } @@ -55,7 +55,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss Title = DiscussConst.Privacy; Introduction = ""; Cover = null; - //被禁止 + //琚姝 IsBan = true; } } @@ -73,14 +73,14 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss case DiscussPermissionTypeEnum.Public: break; case DiscussPermissionTypeEnum.Oneself: - //当前主题是仅自己可见,同时不是当前登录用户 + //褰撳墠涓婚鏄粎鑷繁鍙锛屽悓鏃朵笉鏄綋鍓嶇櫥褰曠敤鎴 if (dto.User.Id != userId) { dto.SetBan(); } break; case DiscussPermissionTypeEnum.User: - //当前主题为部分可见,同时不是当前登录用户 也 不在可见用户列表中 + //褰撳墠涓婚涓洪儴鍒嗗彲瑙侊紝鍚屾椂涓嶆槸褰撳墠鐧诲綍鐢ㄦ埛 涔 涓嶅湪鍙鐢ㄦ埛鍒楄〃涓 if (dto.User.Id != userId && !dto.PermissionUserIds.Contains(userId)) { dto.SetBan(); diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Analyses/BbsForumAnalyseService.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Analyses/BbsForumAnalyseService.cs index 62cbb971..39727e8f 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Analyses/BbsForumAnalyseService.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Analyses/BbsForumAnalyseService.cs @@ -17,9 +17,11 @@ namespace Yi.Framework.Bbs.Application.Services.Analyses public class BbsForumAnalyseService : ApplicationService, IApplicationService { private ForumManager _forumManager; - public BbsForumAnalyseService(ForumManager forumManager) + private ISqlSugarRepository _agreeRepository; + public BbsForumAnalyseService(ForumManager forumManager, ISqlSugarRepository agreeRepository) { _forumManager = forumManager; + _agreeRepository = agreeRepository; } /// @@ -38,7 +40,7 @@ namespace Yi.Framework.Bbs.Application.Services.Analyses .Select((discuss, user, info) => new DiscussGetListOutputDto { Id = discuss.Id, - IsAgree = SqlFunc.Subqueryable().WhereIF(CurrentUser.Id != null, x => x.CreatorId == CurrentUser.Id && x.DiscussId == discuss.Id).Any(), + // IsAgree = SqlFunc.Subqueryable().WhereIF(CurrentUser.Id != null, x => x.CreatorId == CurrentUser.Id && x.DiscussId == discuss.Id).Any(), User = new BbsUserGetListOutputDto() { @@ -52,6 +54,26 @@ namespace Yi.Framework.Bbs.Application.Services.Analyses }, true) .ToPageListAsync(input.SkipCount, input.MaxResultCount); + var discussId = output.Select(x => x.Id); + //鐐硅禐瀛楀吀锛宬ey涓轰富棰榠d锛寉涓虹敤鎴穒ds + var agreeDic = + (await _agreeRepository._DbQueryable.Where(x => discussId.Contains(x.DiscussId)).ToListAsync()) + .GroupBy(x => x.DiscussId) + .ToDictionary(x => x.Key, y => y.Select(y => y.CreatorId).ToList()); + + //绛夌骇銆佹槸鍚︾偣璧炶祴鍊 + output?.ForEach(x => + { + if (CurrentUser.Id is not null) + { + //榛樿fasle + if (agreeDic.TryGetValue(x.Id,out var userIds)) + { + x.IsAgree = userIds.Contains(CurrentUser.Id); + } + } + }); + return output; } diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/DiscussService.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/DiscussService.cs index 2df69d8c..ccd9500e 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/DiscussService.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/DiscussService.cs @@ -29,19 +29,27 @@ namespace Yi.Framework.Bbs.Application.Services.Forum /// /// Discuss搴旂敤鏈嶅姟瀹炵幇,鐢ㄤ簬鍙傛暟鏍¢獙銆侀鍩熸湇鍔′笟鍔$粍鍚堛佹棩蹇楄褰曘佷簨鍔″鐞嗐佽处鎴蜂俊鎭 /// - public class DiscussService : YiCrudAppService, - IDiscussService + public class DiscussService : YiCrudAppService, + IDiscussService { - private ISqlSugarRepository _discussTopEntityRepository; + private ISqlSugarRepository _discussTopRepository; + private ISqlSugarRepository _agreeRepository; private BbsUserManager _bbsUserManager; - public DiscussService(BbsUserManager bbsUserManager, ForumManager forumManager, ISqlSugarRepository discussTopEntityRepository, ISqlSugarRepository plateEntityRepository, ILocalEventBus localEventBus) : base(forumManager._discussRepository) + + public DiscussService(BbsUserManager bbsUserManager, ForumManager forumManager, + ISqlSugarRepository discussTopRepository, + ISqlSugarRepository plateEntityRepository, ILocalEventBus localEventBus, + ISqlSugarRepository agreeRepository) : base(forumManager._discussRepository) { _forumManager = forumManager; _plateEntityRepository = plateEntityRepository; _localEventBus = localEventBus; - _discussTopEntityRepository = discussTopEntityRepository; - _bbsUserManager=bbsUserManager; + _agreeRepository = agreeRepository; + _discussTopRepository = discussTopRepository; + _bbsUserManager = bbsUserManager; } + private readonly ILocalEventBus _localEventBus; private ForumManager _forumManager { get; set; } @@ -49,8 +57,6 @@ namespace Yi.Framework.Bbs.Application.Services.Forum private ISqlSugarRepository _plateEntityRepository { get; set; } - - /// /// 鍗曟煡 /// @@ -58,42 +64,43 @@ namespace Yi.Framework.Bbs.Application.Services.Forum /// public async override Task GetAsync(Guid id) { - //鏌ヨ涓婚鍙戝竷 娴忚涓婚 浜嬩欢锛屾祻瑙堟暟+1 - var item = await _forumManager._discussRepository._DbQueryable.LeftJoin((discuss, user) => discuss.CreatorId == user.Id) + var item = await _forumManager._discussRepository._DbQueryable + .LeftJoin((discuss, user) => discuss.CreatorId == user.Id) .LeftJoin((discuss, user, info) => user.Id == info.UserId) .LeftJoin((discuss, user, info, plate) => plate.Id == discuss.PlateId) - .Select((discuss, user, info, plate) => new DiscussGetOutputDto - { - Id = discuss.Id, - IsAgree = SqlFunc.Subqueryable().WhereIF(CurrentUser.Id != null, x => x.CreatorId == CurrentUser.Id && x.DiscussId == discuss.Id).Any(), - User = new BbsUserGetListOutputDto() - { - UserName = user.UserName, - Nick = user.Nick, - Icon = user.Icon, - Id = user.Id, - Level = info.Level, - UserLimit = info.UserLimit, - Money=info.Money, - Experience=info.Experience - }, - Plate = new Contracts.Dtos.Plate.PlateGetOutputDto() - { - Name = plate.Name, - Id = plate.Id, - Code = plate.Code, - Introduction = plate.Introduction, - Logo = plate.Logo - - } - }, true) - .SingleAsync(discuss => discuss.Id == id); + .Select((discuss, user, info, plate) => new DiscussGetOutputDto + { + Id = discuss.Id, + IsAgree = SqlFunc.Subqueryable().WhereIF(CurrentUser.Id != null, + x => x.CreatorId == CurrentUser.Id && x.DiscussId == discuss.Id).Any(), + User = new BbsUserGetListOutputDto() + { + UserName = user.UserName, + Nick = user.Nick, + Icon = user.Icon, + Id = user.Id, + Level = info.Level, + UserLimit = info.UserLimit, + Money = info.Money, + Experience = info.Experience + }, + Plate = new Contracts.Dtos.Plate.PlateGetOutputDto() + { + Name = plate.Name, + Id = plate.Id, + Code = plate.Code, + Introduction = plate.Introduction, + Logo = plate.Logo + } + }, true) + .SingleAsync(discuss => discuss.Id == id); if (item is not null) { await VerifyDiscussPermissionAsync(item.Id); - await _localEventBus.PublishAsync(new SeeDiscussEventArgs { DiscussId = item.Id, OldSeeNum = item.SeeNum }); + await _localEventBus.PublishAsync(new SeeDiscussEventArgs + { DiscussId = item.Id, OldSeeNum = item.SeeNum }); } return item; @@ -105,49 +112,65 @@ namespace Yi.Framework.Bbs.Application.Services.Forum /// /// /// - public override async Task> GetListAsync([FromQuery] DiscussGetListInputVo input) + public override async Task> GetListAsync( + [FromQuery] DiscussGetListInputVo input) { //闇瑕佸叧鑱斿垱寤鸿呯敤鎴 RefAsync total = 0; var items = await _forumManager._discussRepository._DbQueryable - .WhereIF(!string.IsNullOrEmpty(input.Title), x => x.Title.Contains(input.Title)) - .WhereIF(input.PlateId is not null, x => x.PlateId == input.PlateId) - .WhereIF(input.IsTop is not null, x => x.IsTop == input.IsTop) - .WhereIF(input.UserId is not null,x=>x.CreatorId==input.UserId) - .LeftJoin((discuss, user) => discuss.CreatorId == user.Id) - .WhereIF(input.UserName is not null, (discuss, user)=>user.UserName==input.UserName!) - - .LeftJoin((discuss, user, info) => user.Id == info.UserId) - - .OrderByDescending(discuss => discuss.OrderNum) - .OrderByIF(input.Type == QueryDiscussTypeEnum.New, discuss => discuss.CreationTime, OrderByType.Desc) - .OrderByIF(input.Type == QueryDiscussTypeEnum.Host, discuss => discuss.SeeNum, OrderByType.Desc) - .OrderByIF(input.Type == QueryDiscussTypeEnum.Suggest, discuss => discuss.AgreeNum, OrderByType.Desc) - - .Select((discuss, user, info) => new DiscussGetListOutputDto - { - Id = discuss.Id, - IsAgree = SqlFunc.Subqueryable().WhereIF(CurrentUser.Id != null, x => x.CreatorId == CurrentUser.Id && x.DiscussId == discuss.Id).Any(), - - User = new BbsUserGetListOutputDto() - { - Id = user.Id, - UserName = user.UserName, - Nick = user.Nick, - Icon = user.Icon, - Level = info.Level, - UserLimit = info.UserLimit, - Money = info.Money, - Experience = info.Experience - } - - }, true) + .WhereIF(!string.IsNullOrEmpty(input.Title), x => x.Title.Contains(input.Title)) + .WhereIF(input.PlateId is not null, x => x.PlateId == input.PlateId) + .WhereIF(input.IsTop is not null, x => x.IsTop == input.IsTop) + .WhereIF(input.UserId is not null, x => x.CreatorId == input.UserId) + .LeftJoin((discuss, user) => discuss.CreatorId == user.Id) + .WhereIF(input.UserName is not null, (discuss, user) => user.UserName == input.UserName!) + .LeftJoin((discuss, user, info) => user.Id == info.UserId) + .OrderByDescending(discuss => discuss.OrderNum) + .OrderByIF(input.Type == QueryDiscussTypeEnum.New, discuss => discuss.CreationTime, OrderByType.Desc) + .OrderByIF(input.Type == QueryDiscussTypeEnum.Host, discuss => discuss.SeeNum, OrderByType.Desc) + .OrderByIF(input.Type == QueryDiscussTypeEnum.Suggest, discuss => discuss.AgreeNum, OrderByType.Desc) + .Select((discuss, user, info) => new DiscussGetListOutputDto + { + Id = discuss.Id, + // 浼樺寲鏌ヨ锛屼笉浣跨敤瀛愭煡璇 + // IsAgree = SqlFunc.Subqueryable().WhereIF(CurrentUser.Id != null, x => x.CreatorId == CurrentUser.Id && x.DiscussId == discuss.Id).Any(), + User = new BbsUserGetListOutputDto() + { + Id = user.Id, + UserName = user.UserName, + Nick = user.Nick, + Icon = user.Icon, + Level = info.Level, + UserLimit = info.UserLimit, + Money = info.Money, + Experience = info.Experience + } + }, true) .ToPageListAsync(input.SkipCount, input.MaxResultCount, total); + var discussId = items.Select(x => x.Id); + + //鐐硅禐瀛楀吀锛宬ey涓轰富棰榠d锛寉涓虹敤鎴穒ds + var agreeDic = + (await _agreeRepository._DbQueryable.Where(x => discussId.Contains(x.DiscussId)).ToListAsync()) + .GroupBy(x => x.DiscussId) + .ToDictionary(x => x.Key, y => y.Select(y => y.CreatorId).ToList()); //鏌ヨ瀹屼富棰樹箣鍚庯紝瑕佽繃婊や竴涓嬬鏈夌殑涓婚淇℃伅 items.ApplyPermissionTypeFilter(CurrentUser.Id ?? Guid.Empty); - items?.ForEach(x => x.User.LevelName = _bbsUserManager._levelCacheDic[x.User.Level].Name); + //绛夌骇銆佹槸鍚︾偣璧炶祴鍊 + items?.ForEach(x => + { + x.User.LevelName = _bbsUserManager._levelCacheDic[x.User.Level].Name; + if (CurrentUser.Id is not null) + { + //榛樿fasle + if (agreeDic.TryGetValue(x.Id,out var userIds)) + { + x.IsAgree = userIds.Contains(CurrentUser.Id); + } + } + }); return new PagedResultDto(total, items); } @@ -157,14 +180,16 @@ namespace Yi.Framework.Bbs.Application.Services.Forum /// public async Task> GetListTopAsync() { - var output = await _discussTopEntityRepository._DbQueryable.LeftJoin((top, discuss) => top.DiscussId == discuss.Id) + var output = await _discussTopRepository._DbQueryable + .LeftJoin((top, discuss) => top.DiscussId == discuss.Id) .LeftJoin((top, discuss, user) => discuss.CreatorId == user.Id) .LeftJoin((top, discuss, user, info) => user.Id == info.UserId) .OrderByDescending(top => top.OrderNum) .Select((top, discuss, user, info) => new DiscussGetListOutputDto { Id = discuss.Id, - IsAgree = SqlFunc.Subqueryable().WhereIF(CurrentUser.Id != null, x => x.CreatorId == CurrentUser.Id && x.DiscussId == discuss.Id).Any(), + IsAgree = SqlFunc.Subqueryable().WhereIF(CurrentUser.Id != null, + x => x.CreatorId == CurrentUser.Id && x.DiscussId == discuss.Id).Any(), User = new BbsUserGetListOutputDto { Id = user.Id, @@ -206,6 +231,11 @@ namespace Yi.Framework.Bbs.Application.Services.Forum throw new UserFriendlyException(PlateConst.No_Exist); } + if (await _forumManager._discussRepository.IsAnyAsync(x => x.Title == input.Title)) + { + throw new UserFriendlyException(DiscussConst.Repeat); + } + //濡傛灉寮鍚簡绂佺敤鍒涘缓涓婚 if (plate.IsDisableCreateDiscuss == true) { @@ -233,6 +263,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum { throw new UserFriendlyException(DiscussConst.No_Exist); } + if (discuss.PermissionType == DiscussPermissionTypeEnum.Oneself) { if (discuss.CreatorId != CurrentUser.Id) @@ -240,13 +271,15 @@ namespace Yi.Framework.Bbs.Application.Services.Forum throw new UserFriendlyException(DiscussConst.Privacy); } } + if (discuss.PermissionType == DiscussPermissionTypeEnum.User) { - if (discuss.CreatorId != CurrentUser.Id && !discuss.PermissionUserIds.Contains(CurrentUser.Id ?? Guid.Empty)) + if (discuss.CreatorId != CurrentUser.Id && + !discuss.PermissionUserIds.Contains(CurrentUser.Id ?? Guid.Empty)) { throw new UserFriendlyException(DiscussConst.Privacy); } } } } -} +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Consts/DiscussConst.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Consts/DiscussConst.cs index f0a7d249..05d8aae7 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Consts/DiscussConst.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Consts/DiscussConst.cs @@ -11,6 +11,7 @@ namespace Yi.Framework.Bbs.Domain.Shared.Consts /// public class DiscussConst { + public const string Repeat = "鍒涘缓涓婚閲嶅"; public const string No_Exist = "浼犲叆鐨勪富棰榠d涓嶅瓨鍦"; public const string Privacy = "銆愮瀵嗐戞偍鏃犺涓婚鏉冮檺锛屽彲鑱旂郴浣滆呯敵璇峰紑鏀"; diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs index 8676435c..df56e25e 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs @@ -184,22 +184,24 @@ namespace Yi.Framework.Rbac.Application.Services /// /// /// - [HttpPost("captcha-phone")] + [HttpPost("account/captcha-phone")] [AllowAnonymous] public async Task PostCaptchaPhoneForRegisterAsync(PhoneCaptchaImageDto input) { return await PostCaptchaPhoneAsync(ValidationPhoneTypeEnum.Register, input); } + /// /// 鎵嬫満楠岃瘉鐮-鎵惧洖瀵嗙爜 /// /// /// - [HttpPost("captcha-phone/repassword")] + [HttpPost("account/captcha-phone/repassword")] public async Task PostCaptchaPhoneForRetrievePasswordAsync(PhoneCaptchaImageDto input) { return await PostCaptchaPhoneAsync(ValidationPhoneTypeEnum.RetrievePassword, input); } + /// /// 鎵嬫満楠岃瘉鐮 /// @@ -223,7 +225,7 @@ namespace Yi.Framework.Rbac.Application.Services var uuid = Guid.NewGuid(); await _aliyunManger.SendSmsAsync(input.Phone, code); - await _phoneCache.SetAsync(new CaptchaPhoneCacheKey(ValidationPhoneTypeEnum.Register, input.Phone), + await _phoneCache.SetAsync(new CaptchaPhoneCacheKey(ValidationPhoneTypeEnum.RetrievePassword, input.Phone), new CaptchaPhoneCacheItem(code), new DistributedCacheEntryOptions { SlidingExpiration = TimeSpan.FromMinutes(10) }); return new @@ -255,14 +257,11 @@ namespace Yi.Framework.Rbac.Application.Services /// [AllowAnonymous] [UnitOfWork] - public async Task PostRetrievePasswordAsync(RetrievePasswordDto input) + public async Task PostRetrievePasswordAsync(RetrievePasswordDto input) { - if (_rbacOptions.EnableCaptcha) - { - //鏍¢獙楠岃瘉鐮侊紝鏍规嵁鐢佃瘽鍙风爜鑾峰彇 value锛屾瘮瀵归獙璇佺爜宸茬粡uuid - await ValidationPhoneCaptchaAsync(ValidationPhoneTypeEnum.RetrievePassword, input.Phone, input.Code); - } - + //鏍¢獙楠岃瘉鐮侊紝鏍规嵁鐢佃瘽鍙风爜鑾峰彇 value锛屾瘮瀵归獙璇佺爜宸茬粡uuid + await ValidationPhoneCaptchaAsync(ValidationPhoneTypeEnum.RetrievePassword, input.Phone, input.Code); + var entity = await _userRepository.GetFirstAsync(x => x.Phone == input.Phone); if (entity is null) { @@ -270,6 +269,8 @@ namespace Yi.Framework.Rbac.Application.Services } await _accountManager.RestPasswordAsync(entity.Id, input.Password); + + return entity.UserName; } diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/FileService.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/FileService.cs index f0287ad9..fc999707 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/FileService.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/FileService.cs @@ -39,7 +39,8 @@ namespace Yi.Framework.Rbac.Application.Services if (!File.Exists(path)) { - throw new UserFriendlyException("鏂囦欢涓嶅瓨鍦",code:"404"); + return new NotFoundResult(); + // throw new UserFriendlyException("鏂囦欢涓嶅瓨鍦",code:"404"); } @@ -66,12 +67,6 @@ namespace Yi.Framework.Rbac.Application.Services // path = $"wwwroot/{FileTypeEnum.Thumbnail}/{file.Id}{Path.GetExtension(file.FileName)}"; //} //璺緞涓猴細 鏂囦欢璺緞/鏂囦欢id+鏂囦欢鎵╁睍鍚 - - if (!File.Exists(path)) - { - throw new UserFriendlyException("鏈湴鏂囦欢涓嶅瓨鍦", "404"); - } - return path; } diff --git a/Yi.Bbs.Vue3/.env.development b/Yi.Bbs.Vue3/.env.development index c08da086..3adabc35 100644 --- a/Yi.Bbs.Vue3/.env.development +++ b/Yi.Bbs.Vue3/.env.development @@ -7,4 +7,7 @@ VITE_APP_URL="http://localhost:19001/api/app" # ws/寮鍙戠幆澧 VITE_APP_BASE_WS = '/dev-ws' -VITE_APP_BASE_URL_WS="http://localhost:19001/hub" \ No newline at end of file +VITE_APP_BASE_URL_WS="http://localhost:19001/hub" + +# 鏄惁寮鍚疘CP澶囨妯″紡 +VITE_APP_ICP = true \ No newline at end of file diff --git a/Yi.Bbs.Vue3/.env.production b/Yi.Bbs.Vue3/.env.production index b69d6e43..e7174e00 100644 --- a/Yi.Bbs.Vue3/.env.production +++ b/Yi.Bbs.Vue3/.env.production @@ -6,4 +6,7 @@ VITE_APP_URL="http://ccnetcore.com:19001/api/app" # ws VITE_APP_BASE_WS = '/prod-ws' -VITE_APP_BASE_URL_WS="http://ccnetcore.com:19001/hub" \ No newline at end of file +VITE_APP_BASE_URL_WS="http://ccnetcore.com:19001/hub" + +# 鏄惁寮鍚疘CP澶囨妯″紡 +VITE_APP_ICP = true \ No newline at end of file diff --git a/Yi.Bbs.Vue3/index.html b/Yi.Bbs.Vue3/index.html index cb47cd78..da02cce0 100644 --- a/Yi.Bbs.Vue3/index.html +++ b/Yi.Bbs.Vue3/index.html @@ -4,20 +4,22 @@ - .Net鎰忕ぞ鍖 - - - - -
-
- - - 鎰忕ぞ鍖哄緢澶э紝浣犺绛変竴涓... -
-
-
- - - + + + 涓汉鎴愭灉灞曠ず + + + + +
+
+ + + 鎰忕ぞ鍖哄緢澶э紝浣犺绛変竴涓... +
+
+
+ + + diff --git a/Yi.Bbs.Vue3/src/apis/accountApi.js b/Yi.Bbs.Vue3/src/apis/accountApi.js index da3ed0a6..4dae948f 100644 --- a/Yi.Bbs.Vue3/src/apis/accountApi.js +++ b/Yi.Bbs.Vue3/src/apis/accountApi.js @@ -18,6 +18,24 @@ export function login(username, password, code, uuid) { }); } + +//鎵惧洖瀵嗙爜 +export function retrievePassword(password, phone, code, uuid) { + const data = { + password, + phone, + code, + uuid, + }; + return request({ + url: "/account/retrieve-password", + headers: { + isToken: false, + }, + method: "post", + data: data, + }); +} // 娉ㄥ唽鏂规硶 export function register(userName, password, phone, code, uuid) { const data = { @@ -76,3 +94,15 @@ export function getCodePhone(phone) { data: { phone }, }); } +// 鑾峰彇鐭俊楠岃瘉鐮-涓轰簡閲嶇疆瀵嗙爜 +export function getCodePhoneForRetrievePassword(phone) { + return request({ + url: "/account/captcha-phone/repassword", + headers: { + isToken: false, + }, + method: "post", + timeout: 20000, + data: { phone }, + }); +} diff --git a/Yi.Bbs.Vue3/src/apis/auth.js b/Yi.Bbs.Vue3/src/apis/auth.js index 8d2ce5d2..ad037ca1 100644 --- a/Yi.Bbs.Vue3/src/apis/auth.js +++ b/Yi.Bbs.Vue3/src/apis/auth.js @@ -1,5 +1,4 @@ import request from "@/config/axios/service"; - /** * 鐢ㄦ埛鐧诲綍 * @param {*} data 璐﹀彿瀵嗙爜 @@ -23,6 +22,17 @@ export function userRegister(data) { data, }); } +/** + * 鐢ㄦ埛鎵惧洖瀵嗙爜 + * @param {*} data 璐﹀彿瀵嗙爜 + */ +export function userRetrievePassword(data) { + return request({ + url: `/account/retrieve-password`, + method: "post", + data, + }); +} /** * 鑾峰彇鐢ㄦ埛璇︾粏淇℃伅 @@ -44,15 +54,6 @@ export function userLogout() { }); } -/** - * 鑾峰彇楠岃瘉鐮 - */ -export function getCodeImg() { - return request({ - url: `/account/captcha-image`, - method: "get", - }); -} /** * 鑾峰彇鐭俊楠岃瘉鐮 */ diff --git a/Yi.Bbs.Vue3/src/assets/styles/login.css b/Yi.Bbs.Vue3/src/assets/styles/login.css index 9a16c4dc..2c178405 100644 --- a/Yi.Bbs.Vue3/src/assets/styles/login.css +++ b/Yi.Bbs.Vue3/src/assets/styles/login.css @@ -103,13 +103,18 @@ height: 25px; .left-lable { display: flex; - align-items: center; + justify-content: space-between; font-size: 12px; } .left-lable label{ margin-left: 5px; } - +.right-forgot{ + cursor: pointer; +} +.right-forgot:hover{ + color: #7f438c; +} .bottom-div { font-size: 12px; diff --git a/Yi.Bbs.Vue3/src/assets/wechat/share.png b/Yi.Bbs.Vue3/src/assets/wechat/share.png index 2b23e44e..39350380 100644 Binary files a/Yi.Bbs.Vue3/src/assets/wechat/share.png and b/Yi.Bbs.Vue3/src/assets/wechat/share.png differ diff --git a/Yi.Bbs.Vue3/src/hooks/useAuths.js b/Yi.Bbs.Vue3/src/hooks/useAuths.js index acee7595..fa32eadc 100644 --- a/Yi.Bbs.Vue3/src/hooks/useAuths.js +++ b/Yi.Bbs.Vue3/src/hooks/useAuths.js @@ -7,7 +7,7 @@ import { userLogin, getUserDetailInfo, userLogout, - userRegister, + userRegister, userRetrievePassword, } from "@/apis/auth"; const TokenKey = "AccessToken"; export const AUTH_MENUS = "AUTH_MENUS"; @@ -182,6 +182,20 @@ const currentUserInfo=computed(()=>{ // } }; + // 鎵惧洖瀵嗙爜 + const retrievePasswordFun = async (params) => { + // try { + const {data}=await userRetrievePassword(params); + ElMessage({ + message: `鎭枩锛佽处鍙凤細${data}锛屾壘鍥炴垚鍔燂紒瀵嗙爜宸查噸缃紝璇风櫥褰曪紒`, + type: "success", + duration: 8000 + }); + // } catch (error) { + // console.log(error); + // } + }; + return { getToken, setToken, @@ -189,6 +203,7 @@ const currentUserInfo=computed(()=>{ loginFun, getUserInfo, logoutFun, + retrievePasswordFun, clearStorage, registerFun, loginSuccess, diff --git a/Yi.Bbs.Vue3/src/layout/AppHeader.vue b/Yi.Bbs.Vue3/src/layout/AppHeader.vue index f315273b..b882a38e 100644 --- a/Yi.Bbs.Vue3/src/layout/AppHeader.vue +++ b/Yi.Bbs.Vue3/src/layout/AppHeader.vue @@ -4,7 +4,8 @@
-
{{ configStore.name }}
+ +
{{ isIcp===true?"涓汉鎴愭灉灞曠ず":configStore.name }}
@@ -152,6 +153,8 @@ const searchText = ref(""); const noticeForNoReadCount = computed(() => { return noticeList.value.filter(x => x.isRead == false).length; }) + +const isIcp=import.meta.env.VITE_APP_ICP==="true"; //鍔犺浇鍒濆鍖栫绾挎秷鎭 onMounted(async () => { //鐧诲綍浜嗘墠鍘诲垽鏂秷鎭氱煡 diff --git a/Yi.Bbs.Vue3/src/router/index.js b/Yi.Bbs.Vue3/src/router/index.js index 9fd58b5d..48abff7e 100644 --- a/Yi.Bbs.Vue3/src/router/index.js +++ b/Yi.Bbs.Vue3/src/router/index.js @@ -26,13 +26,18 @@ const router = createRouter({ name: "login", path: "/login", // component: () => import("../views/Login.vue"), - component: () => import("../views/login/index.vue"), + component: () => import("../views/login/login.vue"), }, { name: "register", path: "/register", component: () => import("../views/login/register.vue"), }, + { + name: "forgotPassword", + path: "/forgotPassword", + component: () => import("../views/login/forgotPassword.vue"), + }, { name: "auth", path: "/auth/:type", diff --git a/Yi.Bbs.Vue3/src/stores/user.js b/Yi.Bbs.Vue3/src/stores/user.js index 0d54b6ec..f286f974 100644 --- a/Yi.Bbs.Vue3/src/stores/user.js +++ b/Yi.Bbs.Vue3/src/stores/user.js @@ -1,4 +1,4 @@ -import { login, logout, register } from "@/apis/accountApi"; +import { login, logout, register,retrievePassword } from "@/apis/accountApi"; import { getUserDetailInfo, getLoginCode } from "@/apis/auth"; import useAuths from "@/hooks/useAuths"; import { defineStore } from "pinia"; @@ -122,6 +122,23 @@ const useUserStore = defineStore("user", { }); }); }, + //鎵惧洖瀵嗙爜 + retrievePassword(userInfo) + { + const password = userInfo.password.trim(); + const phone = userInfo.phone; + const uuid = userInfo.uuid; + const code = userInfo.code; + return new Promise((resolve, reject) => { + retrievePassword(password, phone, code, uuid) + .then((response) => { + resolve(response); + }) + .catch((error) => { + reject(error); + }); + }); + }, // 閲嶇疆鐢ㄦ埛淇℃伅 resetInfo() { this.roles = []; diff --git a/Yi.Bbs.Vue3/src/views/home/Index.vue b/Yi.Bbs.Vue3/src/views/home/Index.vue index 04fec20b..cb6be620 100644 --- a/Yi.Bbs.Vue3/src/views/home/Index.vue +++ b/Yi.Bbs.Vue3/src/views/home/Index.vue @@ -4,7 +4,26 @@
-

鐐瑰嚮鍏虫敞-鏈鏂颁笂绾銆婃剰.Net瀹樻柟寰俊鍏紬鍙枫 锛屽垎浜湁娣卞害鐨.Net鐭ヨ瘑锛屽笇鏈涜兘甯姪澶у

+ +

+ 鏈珯鐐逛负涓汉鍐呭鍒嗕韩锛屽叏閮ㄨ祫鏂欏厤璐瑰紑婧愬涔狅紝鎵鏈夋暟鎹负鍋囨暟鎹 +
+ 涓嶆秹鍙婁紒涓氥佸洟浣撱佽鍧涘拰缁忚惀閿鍞瓑鍐呭锛屽彧鍋氱畝鍗曠殑鎴愭灉灞曠ず +
+ 瀵屽己銆佲屾皯涓汇佹枃鏄庛佲屽拰璋愩佲岃嚜鐢便佲屽钩绛 +
+ 鍏銆佲屾硶娌汇佲岀埍鍥姐佲屾暚涓氥佲岃瘹淇°佸弸鍠 +

+

鐐瑰嚮鍏虫敞-鏈鏂颁笂绾銆婃剰.Net瀹樻柟寰俊鍏紬鍙枫 锛屽垎浜湁娣卞害鐨.Net鐭ヨ瘑锛屽笇鏈涜兘甯姪澶у

+ +
@@ -272,7 +291,7 @@ const activeList = [ {name: "寮濮", path: "/start", icon: "Position"}, {name: "鑱婂ぉ瀹", path: "/chat", icon: "ChatRound"}, ]; - +const isIcp=import.meta.env.VITE_APP_ICP==="true"; //涓婚鏌ヨ鍙傛暟 const query = reactive({ skipCount: 1, @@ -622,7 +641,7 @@ const onClickToWeChat=()=>{ display: flex; align-content: center; flex-wrap: wrap; - height: 30px; + min-height: 30px; p { margin: 0 auto; diff --git a/Yi.Bbs.Vue3/src/views/login/ForgotPassword.vue b/Yi.Bbs.Vue3/src/views/login/ForgotPassword.vue deleted file mode 100644 index a4f76b28..00000000 --- a/Yi.Bbs.Vue3/src/views/login/ForgotPassword.vue +++ /dev/null @@ -1,11 +0,0 @@ -锘 - - - - \ No newline at end of file diff --git a/Yi.Bbs.Vue3/src/views/login/forgotPassword.vue b/Yi.Bbs.Vue3/src/views/login/forgotPassword.vue new file mode 100644 index 00000000..29c91948 --- /dev/null +++ b/Yi.Bbs.Vue3/src/views/login/forgotPassword.vue @@ -0,0 +1,153 @@ +锘 + + + + \ No newline at end of file diff --git a/Yi.Bbs.Vue3/src/views/login/index.vue b/Yi.Bbs.Vue3/src/views/login/login.vue similarity index 93% rename from Yi.Bbs.Vue3/src/views/login/index.vue rename to Yi.Bbs.Vue3/src/views/login/login.vue index 49da43d7..dc79a2d5 100644 --- a/Yi.Bbs.Vue3/src/views/login/index.vue +++ b/Yi.Bbs.Vue3/src/views/login/login.vue @@ -1,145 +1,153 @@ - - - \ No newline at end of file