This commit is contained in:
Putoo
2026-05-30 17:32:27 +08:00
parent bd1535aee9
commit f8d4a28d53
79 changed files with 1369 additions and 134 deletions

1
.gitignore vendored
View File

@@ -2,6 +2,7 @@ node_modules
.nuxt
.output
.vs
.output
[Bb]in
[Oo]bj
[Ll]og/

View File

@@ -8,6 +8,7 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APoAction_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F8fb1d14dca1046e78e0684daa8bc3a1b7800_003Fb7_003F35e46383_003FPoAction_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASqlSetup_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F72993acb059c49dcbba437a858c0b0942000_003F46_003F2e14505d_003FSqlSetup_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASqlSugarScopeProvider_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6c0f22f0a47643a3b2a40899acd2044c2e3a00_003Fc5_003F4738d33f_003FSqlSugarScopeProvider_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AStringAssist_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa380d649d5b2495d9bfa0fa24f13662b6400_003Fee_003F90da4dea_003FStringAssist_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AString_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F51505665371d472f8bdbc333fa4d888cf49938_003Fdf_003F23ca03dd_003FString_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATimeAssist_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa380d649d5b2495d9bfa0fa24f13662b6400_003Fe6_003F9539602d_003FTimeAssist_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATokenValidationParameters_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Ffbb48859ccd84b0d884ab212a4cf9fdb5f820_003F55_003F417754e1_003FTokenValidationParameters_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>

View File

@@ -65,5 +65,10 @@ namespace Application.Domain.Entity
/// </summary>
[SugarColumn(IsNullable = true)]
public int? state { get; set; }
/// <summary>
/// opUser
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? opUser { get; set; }
}
}

View File

@@ -0,0 +1,39 @@
using SqlSugar;
using System;
namespace Application.Domain.Entity
{
[Tenant("Kg.SeaTime.Game")]
public class unit_user_config
{
/// <summary>
/// userId
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 50)]
public string userId { get; set; }
/// <summary>
/// 加好友权限1默认 0禁止加好友 2不限制
/// </summary>
[SugarColumn(IsNullable = true)]
public int? friendRole { get; set; }
/// <summary>
/// 频道管理权限0无 1区域 2全部
/// </summary>
[SugarColumn(IsNullable = true)]
public int? chatRole { get; set; }
/// <summary>
/// 自动拾取物品:-1未开通1开通0禁止
/// </summary>
[SugarColumn(IsNullable = true)]
public int? autoBag { get; set; }
/// <summary>
/// 自动使用药品:-1未开通,1开通0禁止
/// </summary>
[SugarColumn(IsNullable = true)]
public int? autoDrug { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
using SqlSugar;
using System;
namespace Application.Domain.Entity
{
[Tenant("Kg.SeaTime.Game")]
public class unit_user_enemy
{
/// <summary>
/// euId
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 100)]
public string euId { get; set; }
/// <summary>
/// userId
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? userId { get; set; }
/// <summary>
/// eId
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? eId { get; set; }
/// <summary>
/// addTime
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? addTime { get; set; }
}
}

View File

@@ -5,7 +5,9 @@ public class UserModel
public string userNo { get; set; }
public string nick { get; set; }
public string sex { get; set; }
public string sign { get; set; }
public string headImg { get; set; }
public int area { get; set; }
public string icon { get; set; }
public int lev { get; set; }

View File

@@ -0,0 +1,45 @@
using SqlSugar;
using System;
namespace Application.Domain.Entity
{
[Tenant("Kg.SeaTime.Resource")]
public class game_ack
{
/// <summary>
/// ackCode
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 50)]
public string ackCode { get; set; }
/// <summary>
/// areaId
/// </summary>
[SugarColumn(IsNullable = true)]
public int? areaId { get; set; }
/// <summary>
/// status
/// </summary>
[SugarColumn(IsNullable = true)]
public int? status { get; set; }
/// <summary>
/// addTime
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? addTime { get; set; }
/// <summary>
/// useTime
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? useTime { get; set; }
/// <summary>
/// useUser
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? useUser { get; set; }
}
}

View File

@@ -30,6 +30,12 @@ namespace Application.Domain.Entity
[SugarColumn(IsNullable = true)]
public DateTime? opTime { get; set; }
/// <summary>
/// 是否需要激活码
/// </summary>
[SugarColumn(IsNullable = true)]
public int? isNeedCode { get; set; }
/// <summary>
/// 添加时间
/// </summary>

View File

@@ -9,4 +9,8 @@ public static class GameConfig
public const int SendChatGoodsService = 10002;//金海螺
public const int UpLevAddWeight = 10;//升级增加负重
public const int GameBaseVigour = 50;//初始活力
public const int GameRelationEnemyNeedGold = 50;//添加仇人所需金元
public const int GameUpdateNickNeedGoods = 10001;//更新昵称所需道具
public const int GameUpdateSexNeedGoods = 10001;//更新性别所需道具
public const int GameUserFriendMaxCount = 50;//好友最大上限人数
}

View File

@@ -6,4 +6,12 @@ public static class UserEnum
{
Person
}
public enum ConfigCode
{
FriendRole,
ChatRole,
AutoBag,
AutoDrug,
}
}

View File

@@ -15,7 +15,13 @@ public class MessageHandle
if (state == 1)
{
if (await relationService.AddFriend(events.userId, events.pars))
var friendCount = await relationService.GetUserFriendCount(events.pars);
if (friendCount >= GameConfig.GameUserFriendMaxCount)
{
return new MessageHandleResult() { success = false, msg = "Ta的好友人数已达上限!" };
}
if (await relationService.AddFriend(events.pars,events.userId ))
{
var chatService = App.GetService<IGameChatService>();
var userService = App.GetService<IUnitUserService>();
@@ -39,7 +45,7 @@ public class MessageHandle
return new MessageHandleResult() { success = true, msg = "已拒绝该好友申请!" };
}
}
else if (events.code == nameof(MessageEnum.EventCode.Friend))
else if (events.code == nameof(MessageEnum.EventCode.Trade))
{
return new MessageHandleResult() { success = true, msg = "消息通知已处理!" };
}

View File

@@ -10,5 +10,6 @@ public interface IGameChatService
Task<bool> SendChat(string userId, int areaId, string code, string sign, string par = "");
Task<bool> SendChat(string userId, string code, string sign, string par = "");
Task<bool> DeleteChat(string chatId);
Task<game_chat> GetChatInfo(string chatId);
Task<bool> DeleteChat(string chatId, string opUser);
}

View File

@@ -13,4 +13,12 @@ public interface IAreaService
/// <param name="areaId"></param>
/// <returns></returns>
Task<game_area> GetAreaInfo(int areaId);
#region
Task<game_ack> GetAckInfo(string code);
Task<bool> UseAck(string code, string userId);
#endregion
}

View File

@@ -0,0 +1,6 @@
namespace Application.Domain;
public interface IGameMaxNameService
{
}

View File

@@ -11,4 +11,13 @@ public interface IUnitUserRelationService
Task<bool> DeleteFriend(string userId, string toId);
#endregion
#region
Task<List<RelationView>> GetUserEnemyData(string userId);
Task<bool> CheckUserEnemy(string userId, string eId);
Task<bool> AddUserEnemy(string userId, string eId);
Task<bool> DeleteUserEnemy(string userId, string eId);
#endregion
}

View File

@@ -8,8 +8,10 @@ public interface IUnitUserService
Task<unit_user> GetUserInfoByUserId(string userId);
Task<unit_user> GetUserInfoByUserNo(string userNo);
Task<unit_user> GetUserInfoByToken(string token);
Task<bool> CheckUserNickIsAt(string nick);
Task<bool> UpdateUserNick(string userId, string nick);
Task<bool> UpdateUserSex(string userId, string sex);
Task<bool> UpdateUserSign(string userId, string sign);
#endregion
#region
@@ -31,5 +33,16 @@ public interface IUnitUserService
Task<int> GetOnlineCount();
#endregion
#region
Task<unit_user_config> GetUserConfigInfo(string userId);
Task<int> GetUserConfigInfo(string userId, string code);
Task<bool> UpdateUserConfigInfo(string userId, string code, int state);
#endregion
}

View File

@@ -123,6 +123,7 @@ public class GameChatService : IGameChatService, ITransient
chat.addTime = DateTime.Now;
chat.sort = TimeExtend.GetTimeStampSeconds;
chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(3));
chat.opUser = "";
switch (code)
{
case "Region":
@@ -156,15 +157,24 @@ public class GameChatService : IGameChatService, ITransient
return await SendChat(userId, (int)userInfo.areaId, code, sign, par);
}
public async Task<game_chat> GetChatInfo(string chatId)
{
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_chat>();
return await db.Queryable<game_chat>().Where(it => it.chatId == chatId).SingleAsync();
}
/// <summary>
/// 删除聊天
/// </summary>
/// <param name="chatId"></param>
/// <param name="opUser"></param>
/// <returns></returns>
public async Task<bool> DeleteChat(string chatId)
public async Task<bool> DeleteChat(string chatId, string opUser)
{
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_chat>();
return await db.Updateable<game_chat>().SetColumns(it => it.state == 0).Where(it => it.chatId == chatId)
return await db.Updateable<game_chat>().SetColumns(it => it.state == 0)
.SetColumns(it => it.opUser == opUser)
.Where(it => it.chatId == chatId)
.ExecuteCommandAsync() > 0;
}
}

View File

@@ -57,4 +57,25 @@ public class AreaService : IAreaService, ITransient
await _redisClient.DelAsync(key);
}
}
#region
public async Task<game_ack> GetAckInfo(string code)
{
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_ack>();
return await db.Queryable<game_ack>().Where(it => it.ackCode == code).SingleAsync();
}
public async Task<bool> UseAck(string code, string userId)
{
DateTime time = DateTime.Now;
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_ack>();
return await db.Updateable<game_ack>().SetColumns(it => it.status == 1)
.SetColumns(it => it.useTime == time)
.SetColumns(it => it.useUser == userId)
.Where(it => it.ackCode == code)
.ExecuteCommandAsync() > 0;
}
#endregion
}

View File

@@ -0,0 +1,6 @@
namespace Application.Domain;
public class GameMaxNameService(ISqlSugarClient DbClient, IRedisCache redis) : IGameMaxNameService, ITransient
{
}

View File

@@ -5,27 +5,27 @@ public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : I
public async Task<long> GetUserAccInfo(string userId, string accType)
{
long result = 0;
if (accType == AccEnum.AccType.copper.ToString())
if (accType == nameof(AccEnum.AccType.copper))
{
var info = await GetUserCopperInfo(userId);
result = (long)info.copper;
}
else if (accType == AccEnum.AccType.cowry.ToString())
else if (accType == nameof(AccEnum.AccType.cowry))
{
var info = await GetUserAccInfo(userId);
result = (long)info.cowry;
}
else if (accType == AccEnum.AccType.gold.ToString())
else if (accType == nameof(AccEnum.AccType.gold))
{
var info = await GetUserAccInfo(userId);
result = (long)info.gold;
}
else if (accType == AccEnum.AccType.teach.ToString())
else if (accType == nameof(AccEnum.AccType.teach))
{
var info = await GetUserAccInfo(userId);
result = (long)info.teach;
}
else if (accType == AccEnum.AccType.renown.ToString())
else if (accType == nameof(AccEnum.AccType.renown))
{
var info = await GetUserAccInfo(userId);
result = (long)info.renown;
@@ -53,10 +53,10 @@ public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : I
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_acc>();
await DbClient.AsTenant().BeginTranAsync();
isOk = await db.Updateable<unit_user_acc>()
.SetColumnsIF(accType.Equals(AccEnum.AccType.cowry.ToString()), it => it.cowry == it.cowry + opCount)
.SetColumnsIF(accType.Equals(AccEnum.AccType.gold.ToString()), it => it.gold == it.gold + opCount)
.SetColumnsIF(accType.Equals(AccEnum.AccType.teach.ToString()), it => it.teach == it.teach + opCount)
.SetColumnsIF(accType.Equals(AccEnum.AccType.renown.ToString()), it => it.renown == it.renown + opCount)
.SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.cowry)), it => it.cowry == it.cowry + opCount)
.SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.gold)), it => it.gold == it.gold + opCount)
.SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.teach)), it => it.teach == it.teach + opCount)
.SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.renown)), it => it.renown == it.renown + opCount)
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
//生成日志
if (isOk)

View File

@@ -63,4 +63,61 @@ public class UnitUserRelationService(ISqlSugarClient DbClient, IRedisCache redis
}
#endregion
#region
public async Task<List<RelationView>> GetUserEnemyData(string userId)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_enemy>();
var data = await db.Queryable<unit_user_enemy>().Where(it => it.userId == userId)
.OrderByDescending(it => it.addTime)
.ToListAsync();
List<RelationView> result = new List<RelationView>();
foreach (var item in data)
{
RelationView temp = new RelationView();
temp.user = await UserModelTool.GetUserView(item.eId);
temp.near = 0;
var mapService = App.GetService<IGameMapService>();
var onMap = await mapService.GetUserOnMapInfo(item.eId);
temp.mapName = onMap.mapName;
temp.cityName = onMap.cityName;
temp.sort = TimeExtend.GetTimeStampBySeconds((DateTime)item.addTime);
temp.isOnline = onMap.isOnline;
result.Add(temp);
}
return result;
}
public async Task<bool> CheckUserEnemy(string userId, string eId)
{
string euId = $"{userId}_{eId}";
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_enemy>();
return await db.Queryable<unit_user_enemy>().Where(it => it.euId == euId).AnyAsync();
}
public async Task<bool> AddUserEnemy(string userId, string eId)
{
string euId = $"{userId}_{eId}";
unit_user_enemy enemy = new unit_user_enemy()
{
euId = euId,
userId = userId,
eId = eId,
addTime = DateTime.Now
};
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_enemy>();
return await db.Insertable(enemy).ExecuteCommandAsync() > 0;
}
public async Task<bool> DeleteUserEnemy(string userId, string eId)
{
string euId = $"{userId}_{eId}";
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_enemy>();
return await db.Deleteable<unit_user_enemy>().Where(it => it.euId == euId).ExecuteCommandAsync() > 0;
}
#endregion
}

View File

@@ -2,36 +2,28 @@
namespace Application.Domain;
public class UnitUserService : IUnitUserService, ITransient
public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUnitUserService, ITransient
{
private readonly ISqlSugarClient _dbClient;
private readonly IRedisCache _redisClient;
public UnitUserService(ISqlSugarClient dbClient, IRedisCache redisClient)
{
_dbClient = dbClient;
_redisClient = redisClient;
}
#region
public async Task<List<unit_user>> GetUserDataByAccId(string accId)
{
var db = _dbClient.AsTenant().GetConnectionWithAttr<unit_user>();
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
return await db.Queryable<unit_user>().Where(it => it.accId == accId).ToListAsync();
}
public async Task<unit_user> GetUserInfoByUserId(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "UserInfo", "UserId");
var data = await _redisClient.GetHashAsync<unit_user>(key, userId);
var data = await redis.GetHashAsync<unit_user>(key, userId);
if (data == null)
{
var db = _dbClient.AsTenant().GetConnectionWithAttr<unit_user>();
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
data = await db.Queryable<unit_user>().Where(it => it.userId == userId).SingleAsync();
if (data != null)
{
await _redisClient.AddHashAsync(key, userId, data);
await redis.AddHashAsync(key, userId, data);
}
}
@@ -41,14 +33,14 @@ public class UnitUserService : IUnitUserService, ITransient
public async Task<unit_user> GetUserInfoByUserNo(string userNo)
{
string key = string.Format(UserCache.BaseCacheKeys, "UserInfo", "UserNo");
var data = await _redisClient.GetHashAsync<unit_user>(key, userNo);
var data = await redis.GetHashAsync<unit_user>(key, userNo);
if (data == null)
{
var db = _dbClient.AsTenant().GetConnectionWithAttr<unit_user>();
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
data = await db.Queryable<unit_user>().Where(it => it.userNo == userNo).SingleAsync();
if (data != null)
{
await _redisClient.AddHashAsync(key, userNo, data);
await redis.AddHashAsync(key, userNo, data);
}
}
@@ -58,14 +50,14 @@ public class UnitUserService : IUnitUserService, ITransient
public async Task<unit_user> GetUserInfoByToken(string token)
{
string key = string.Format(UserCache.BaseCacheKeys, "UserInfo", "token");
var data = await _redisClient.GetHashAsync<unit_user>(key, token);
var data = await redis.GetHashAsync<unit_user>(key, token);
if (data == null)
{
var db = _dbClient.AsTenant().GetConnectionWithAttr<unit_user>();
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
data = await db.Queryable<unit_user>().Where(it => it.token == token).SingleAsync();
if (data != null)
{
await _redisClient.AddHashAsync(key, token, data);
await redis.AddHashAsync(key, token, data);
}
}
@@ -86,9 +78,52 @@ public class UnitUserService : IUnitUserService, ITransient
break;
}
await _redisClient.DelHashAsync(string.Format(UserCache.BaseCacheKeys, "UserInfo", "UserId"), result.userId);
await _redisClient.DelHashAsync(string.Format(UserCache.BaseCacheKeys, "UserInfo", "UserNo"), result.userNo);
await _redisClient.DelHashAsync(string.Format(UserCache.BaseCacheKeys, "UserInfo", "Sid"), result.token);
await redis.DelHashAsync(string.Format(UserCache.BaseCacheKeys, "UserInfo", "UserId"), result.userId);
await redis.DelHashAsync(string.Format(UserCache.BaseCacheKeys, "UserInfo", "UserNo"), result.userNo);
await redis.DelHashAsync(string.Format(UserCache.BaseCacheKeys, "UserInfo", "Sid"), result.token);
}
public async Task<bool> CheckUserNickIsAt(string nick)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
return await db.Queryable<unit_user>().Where(it => it.nick.Contains(nick)).AnyAsync();
}
public async Task<bool> UpdateUserNick(string userId, string nick)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
bool result = await db.Updateable<unit_user>().SetColumns(it => it.nick == nick)
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
if (result)
{
await ClearUserInfo(0, userId);
}
return result;
}
public async Task<bool> UpdateUserSex(string userId, string sex)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
bool result = await db.Updateable<unit_user>().SetColumns(it => it.sex == sex)
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
if (result)
{
await ClearUserInfo(0, userId);
}
return result;
}
public async Task<bool> UpdateUserSign(string userId, string sign)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
bool result = await db.Updateable<unit_user>().SetColumns(it => it.sign == sign)
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
if (result)
{
await ClearUserInfo(0, userId);
}
return result;
}
#endregion
@@ -100,8 +135,8 @@ public class UnitUserService : IUnitUserService, ITransient
unit_user result = new unit_user();
try
{
var db = _dbClient.AsTenant().GetConnectionWithAttr<unit_user>();
await _dbClient.AsTenant().BeginTranAsync();
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
await DbClient.AsTenant().BeginTranAsync();
string userId = StringAssist.NewGuid;
result.userId = userId;
result.areaId = areaId;
@@ -123,12 +158,12 @@ public class UnitUserService : IUnitUserService, ITransient
result = null;
}
await _dbClient.AsTenant().CommitTranAsync();
await DbClient.AsTenant().CommitTranAsync();
}
catch
{
result = null;
await _dbClient.AsTenant().RollbackTranAsync();
await DbClient.AsTenant().RollbackTranAsync();
}
return result;
@@ -136,7 +171,7 @@ public class UnitUserService : IUnitUserService, ITransient
public async Task<bool> RegisterUserInfo(string userId, string nick, string sex)
{
var db = _dbClient.AsTenant().GetConnectionWithAttr<unit_user>();
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user>();
bool result = await db.Updateable<unit_user>().SetColumns(it => it.nick == nick)
.SetColumns(it => it.sex == sex)
.SetColumns(it => it.regOk == 1)
@@ -164,6 +199,15 @@ public class UnitUserService : IUnitUserService, ITransient
userAttr.userId = userId;
db.Insertable(userAttr).AddQueue();
//注册配置
unit_user_config config = new unit_user_config();
config.userId = userId;
config.friendRole = 1;
config.chatRole = 0;
config.autoBag = -1;
config.autoDrug = -1;
db.Insertable(config).AddQueue();
//注册个人血量
unit_user_blood blood = new unit_user_blood();
blood.userId = userId;
@@ -249,9 +293,77 @@ public class UnitUserService : IUnitUserService, ITransient
public async Task<int> GetOnlineCount()
{
long time = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddMinutes(0 - GameConfig.OnLineTime));
var db = _dbClient.AsTenant().GetConnectionWithAttr<unit_user_online>();
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_online>();
return await db.Queryable<unit_user_online>().Where(it => it.upTime > time).CountAsync();
}
#endregion
#region
public async Task<unit_user_config> GetUserConfigInfo(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "UserInfo", "Config");
var data = await redis.GetHashAsync<unit_user_config>(key, userId);
if (data == null)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_config>();
data = await db.Queryable<unit_user_config>().Where(it => it.userId == userId).SingleAsync();
if (data != null)
{
await redis.AddHashAsync(key, userId, data);
}
}
return data;
}
public async Task<int> GetUserConfigInfo(string userId, string code)
{
int result = 0;
var config = await GetUserConfigInfo(userId);
switch (code)
{
case "FriendRole":
result = (int)config.friendRole;
break;
case "ChatRole":
result = (int)config.chatRole;
break;
case "AutoBag":
result = (int)config.autoBag;
break;
case "AutoDrug":
result = (int)config.autoDrug;
break;
}
return result;
}
private async Task ClearUserConfig(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "UserInfo", "Config");
await redis.DelHashAsync(key, userId);
}
public async Task<bool> UpdateUserConfigInfo(string userId, string code, int state)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_config>();
bool result = await db.Updateable<unit_user_config>()
.SetColumnsIF(code == "FriendRole", it => it.friendRole == state)
.SetColumnsIF(code == "ChatRole", it => it.chatRole == state)
.SetColumnsIF(code == "AutoBag", it => it.autoBag == state)
.SetColumnsIF(code == "AutoDrug", it => it.autoDrug == state)
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
if (result)
{
await ClearUserConfig(userId);
}
return result;
}
#endregion
}

View File

@@ -19,6 +19,7 @@ public class UserModelTool
result.headImg = "";
result.area = 0;
result.icon = "";
result.sign = "会陪你在航海的世界里浪迹天涯~";
result.lev = 999;
}
else
@@ -31,6 +32,7 @@ public class UserModelTool
result.userNo = userInfo.userNo;
result.nick = userInfo.nick;
result.sex = userInfo.sex;
result.sign = userInfo.sign;
result.headImg = userInfo.headImg;
result.area = (int)userInfo.areaId;
result.icon = "";
@@ -38,6 +40,7 @@ public class UserModelTool
{
result.icon = "";
}
result.lev = await attrService.GetUserLev(userId);
}
}

View File

@@ -12,11 +12,13 @@ public class ChatController : ControllerBase
{
private readonly IGameChatService _chatService;
private readonly IGameGoodsService _goodsService;
private readonly IUnitUserService _userService;
public ChatController(IGameChatService chatService, IGameGoodsService goodsService)
public ChatController(IGameChatService chatService, IGameGoodsService goodsService, IUnitUserService userService)
{
_chatService = chatService;
_goodsService = goodsService;
_userService = userService;
}
/// <summary>
@@ -53,8 +55,10 @@ public class ChatController : ControllerBase
break;
}
int chatRole = await _userService.GetUserConfigInfo(userId, nameof(UserEnum.ConfigCode.ChatRole)); //获取聊天权限
return PoAction.Ok(new { data, total = Total.Value, sendGoodsCount, sendGoodsName });
return PoAction.Ok(new { data, total = Total.Value, sendGoodsCount, sendGoodsName, chatRole });
}
/// <summary>
@@ -73,7 +77,7 @@ public class ChatController : ControllerBase
string userId = StateHelper.userId;
int areaId = StateHelper.areaId;
string par = string.Empty;
string code = GameChatEnum.Code.Public.ToString();
string code = nameof(GameChatEnum.Code.Public);
int goodsId = 0;
bool isSend = false;
switch (pars.type)
@@ -110,7 +114,29 @@ public class ChatController : ControllerBase
return PoAction.Message("无法发言!");
}
int chatRole = await _userService.GetUserConfigInfo(userId, nameof(UserEnum.ConfigCode.ChatRole));
if (chatRole < 0)
{
return PoAction.Message("发言权限已被系统限制!");
}
bool upGoods = true;
if (goodsId != 0)
{
bool checkGoods = true;
if ((nameof(GameChatEnum.Code.Region) == code || nameof(GameChatEnum.Code.Public) == code) && chatRole > 0)
{
checkGoods = false;
upGoods = false;
}
else if (nameof(GameChatEnum.Code.Dress) == code && chatRole > 1)
{
checkGoods = false;
upGoods = false;
}
if (checkGoods)
{
var myCount = await _goodsService.GetUserGoodsCount(userId, goodsId);
if (myCount < 1)
@@ -118,12 +144,13 @@ public class ChatController : ControllerBase
return PoAction.Message("暂无发言道具,去商城购买海螺才可以发言哦!");
}
}
}
string sign = StringAssist.NoHTML(pars.sign);
bool result = await _chatService.SendChat(userId, areaId, code, sign, par);
if (result)
{
if (goodsId != 0) //扣除道具
if (goodsId != 0 && upGoods) //扣除道具
{
await _goodsService.UpdateUserGoods(userId, 0, goodsId, 1, "发言");
}
@@ -135,4 +162,56 @@ public class ChatController : ControllerBase
return PoAction.Message("发送失败,请稍后尝试!");
}
}
/// <summary>
/// 删除聊天记录
/// </summary>
/// <param name="chatId"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> DeleteChat(string chatId)
{
var chatInfo = await _chatService.GetChatInfo(chatId);
if (chatInfo == null)
{
return PoAction.Message("发言不存在!");
}
if (chatInfo.state != 1)
{
return PoAction.Message("发言不存在!");
}
if (chatInfo.areaId != StateHelper.areaId)
{
return PoAction.Message("发言不存在!");
}
bool IsOp = false;
string userId = StateHelper.userId;
int chatRole = await _userService.GetUserConfigInfo(userId, nameof(UserEnum.ConfigCode.ChatRole));
if ((chatInfo.code == nameof(GameChatEnum.Code.Public) || chatInfo.code == nameof(GameChatEnum.Code.Region)) &&
chatRole > 0)
{
IsOp = true;
}
else if (chatRole > 1 && chatInfo.code == nameof(GameChatEnum.Code.Dress))
{
IsOp = true;
}
if (IsOp == false)
{
return PoAction.Message("无权限!");
}
if (await _chatService.DeleteChat(chatId, userId))
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("操作失败,请稍后尝试!");
}
}
}

View File

@@ -297,13 +297,53 @@ namespace Application.Web.Controllers.Login
string sex = parms.sex == 0 ? "女" : "男";
string userId = StateHelper.userId;
var userInfo = await _userService.GetUserInfoByUserId(userId);
if (userInfo == null)
{
return PoAction.Message("角色不存在!");
}
if (userInfo.regOk == 1)
{
return PoAction.Ok(true);
}
var areaInfo = await _areaService.GetAreaInfo((int)userInfo.areaId);
if (areaInfo.isNeedCode == 1) //需要激活码
{
if (string.IsNullOrEmpty(parms.code))
{
return PoAction.Message("请输入激活码!");
}
var ackInfo = await _areaService.GetAckInfo(parms.code);
if (ackInfo == null)
{
return PoAction.Message("激活码过期!");
}
if (ackInfo.status != 0)
{
return PoAction.Message("激活码过期!");
}
if (ackInfo.areaId != 0 && ackInfo.areaId != areaInfo.areaId)
{
return PoAction.Message($"当前激活码可用于{ackInfo.areaId}区激活!");
}
}
if (await _userService.CheckUserNickIsAt(parms.nick))
{
return PoAction.Message("昵称已存在!");
}
if (await _userService.RegisterUserInfo(userId, parms.nick, sex))
{
if (areaInfo.isNeedCode == 1)
{
await _areaService.UseAck(parms.code, userId);
}
return PoAction.Ok(true);
}
else

View File

@@ -119,7 +119,7 @@ public class MapController : ControllerBase
page,
10, Total);
return PoAction.Ok(new { data, total = Total.Value });
return PoAction.Ok(new { data, total = Total.Value, map = mapInfo });
}
/// <summary>

View File

@@ -107,5 +107,27 @@ namespace Application.Web.Controllers.Pub
return PoAction.Ok(userData);
}
/// <summary>
/// 获取区服信息
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetOnAreaInfo()
{
int areaId = StateHelper.areaId;
var areaInfo = await _areaService.GetAreaInfo(areaId);
if (areaInfo == null)
{
return PoAction.Message("区服不存在!");
}
if (areaInfo.status != 1)
{
return PoAction.Message("当前区服繁忙!");
}
return PoAction.Ok(areaInfo);
}
}
}

View File

@@ -14,13 +14,15 @@ public class RelationController : ControllerBase
private readonly IUnitUserRelationService _relationService;
private readonly IUnitUserService _userService;
private readonly IMessageService _messageService;
private readonly IUnitUserAccService _accService;
public RelationController(IUnitUserRelationService relationService, IUnitUserService userService,
IMessageService messageService)
IMessageService messageService, IUnitUserAccService accService)
{
_relationService = relationService;
_userService = userService;
_messageService = messageService;
_accService = accService;
}
/// <summary>
@@ -51,10 +53,23 @@ public class RelationController : ControllerBase
.ThenByDescending(it => it.sort).ToList();
result = PageExtend.GetPageList(data, page, 10);
}
else if (type == 3)
{
var data = await _relationService.GetUserEnemyData(userId);
total = data.Count;
data = data.OrderByDescending(it => it.isOnline)
.ThenByDescending(it => it.sort).ToList();
result = PageExtend.GetPageList(data, page, 10);
}
return PoAction.Ok(new { data = result, total = total.Value, online = result.Count(it => it.isOnline == 1) });
}
/// <summary>
/// 好友处理
/// </summary>
/// <param name="no"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> FriendHandle(string no)
{
@@ -76,8 +91,33 @@ public class RelationController : ControllerBase
}
bool IsFriend = await _relationService.CheckIsFriend(userId, userInfo.userId);
if (IsFriend == false)
if (IsFriend == false) //添加好友
{
var friendRole =
await _userService.GetUserConfigInfo(userInfo.userId, nameof(UserEnum.ConfigCode.FriendRole));
if (friendRole == 0)
{
return PoAction.Message("该玩家拒绝任何人添加好友!");
}
var friendCount = await _relationService.GetUserFriendCount(userId);
if (friendCount >= GameConfig.GameUserFriendMaxCount)
{
return PoAction.Message("好友人数已达上限!");
}
if (friendRole == 2)//不限制加好友
{
if (await _relationService.AddFriend(userId, userInfo.userId))
{
return PoAction.Ok(true, "添加好友成功!");
}
else
{
return PoAction.Ok(true, "添加好友失败,请稍后尝试!");
}
}
string token = $"{nameof(MessageEnum.EventCode.Friend)}_{userId}_{userInfo.userId}";
if (await _messageService.CheckAtEventMsg(token))
{
@@ -114,4 +154,91 @@ public class RelationController : ControllerBase
}
}
}
/// <summary>
/// 删除仇人
/// </summary>
/// <param name="no"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> DeleteEnemy(string no)
{
string userId = StateHelper.userId;
var userInfo = await _userService.GetUserInfoByUserNo(no); //基础资料
if (userInfo == null)
{
return PoAction.Message("玩家不存在!");
}
bool IsEnemy = await _relationService.CheckUserEnemy(userId, userInfo.userId);
if (IsEnemy == false)
{
return PoAction.Message("不是仇人,无需删除哦");
}
bool result = await _relationService.DeleteUserEnemy(userId, userInfo.userId);
if (result)
{
return PoAction.Ok(true, "删除成功!");
}
else
{
return PoAction.Message("删除失败,请稍后尝试.");
}
}
/// <summary>
/// 添加仇人
/// </summary>
/// <param name="no"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> AddEnemy(string no)
{
string userId = StateHelper.userId;
var userInfo = await _userService.GetUserInfoByUserNo(no); //基础资料
if (userInfo == null)
{
return PoAction.Message("玩家不存在!");
}
if (userInfo.userId == userId)
{
return PoAction.Message("不能加自己为仇人!");
}
if (userInfo.areaId != StateHelper.areaId)
{
return PoAction.Message("玩家不存在!");
}
bool IsEnemy = await _relationService.CheckUserEnemy(userId, userInfo.userId);
if (IsEnemy == true)
{
return PoAction.Message("已经是仇人啦,无需重复添加!");
}
var myAcc = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.gold));
if (myAcc < GameConfig.GameRelationEnemyNeedGold)
{
return PoAction.Message("您的金元不足!");
}
if (await _accService.UpdateUserAcc(userId, 0, nameof(AccEnum.AccType.gold),
GameConfig.GameRelationEnemyNeedGold, nameof(AccEnum.Name.), "添加仇人"))
{
if (await _relationService.AddUserEnemy(userId, userInfo.userId))
{
return PoAction.Ok(true, "仇人添加成功!");
}
else
{
return PoAction.Message("添加失败,请稍后尝试.");
}
}
else
{
return PoAction.Message("添加失败,请稍后尝试.");
}
}
}

View File

@@ -13,19 +13,23 @@ public class UserController : ControllerBase
private readonly IUnitUserAccService _accService;
private readonly IGameMapService _mapService;
private readonly IUnitUserRelationService _relationService;
private readonly IGameGoodsService _goodsService;
private readonly IGameChatService _chatService;
public UserController(IUnitUserService userService, IUnitUserAttrService attrService,
IUnitUserAccService accService, IGameMapService mapService,IUnitUserRelationService relationService)
IUnitUserAccService accService, IGameMapService mapService, IUnitUserRelationService relationService,
IGameGoodsService goodsService, IGameChatService chatService)
{
_userService = userService;
_attrService = attrService;
_accService = accService;
_mapService = mapService;
_relationService = relationService;
_goodsService = goodsService;
_chatService = chatService;
}
/// <summary>
/// 获取个人资料信息
/// </summary>
@@ -53,9 +57,11 @@ public class UserController : ControllerBase
/// <param name="no"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetUserBaseInfo(string no)
public async Task<IPoAction> GetUserBaseInfo(string? no)
{
string userId = StateHelper.userId;
if (!string.IsNullOrEmpty(no))
{
var userInfo = await _userService.GetUserInfoByUserNo(no); //基础资料
if (userInfo == null)
{
@@ -66,14 +72,19 @@ public class UserController : ControllerBase
{
return PoAction.Message("用户本身!", 101);
}
if (userInfo.areaId != StateHelper.areaId)
{
return PoAction.Message("玩家不存在!", 102);
}
var model = await UserModelTool.GetUserView(userInfo.userId);
userId = userInfo.userId;
}
var model = await UserModelTool.GetUserView(userId);
return PoAction.Ok(model);
}
/// <summary>
/// 获取用户资料
/// </summary>
@@ -93,6 +104,7 @@ public class UserController : ControllerBase
{
return PoAction.Message("用户本身!", 101);
}
if (userInfo.areaId != StateHelper.areaId)
{
return PoAction.Message("玩家不存在!", 102);
@@ -112,7 +124,126 @@ public class UserController : ControllerBase
var onCity = await _mapService.GetCityInfo((int)onMapInfo.cityId);
string onMapName = $"{onCity.cityName}-{onMapInfo.mapName}";
bool isFriend = await _relationService.CheckIsFriend(userId, userInfo.userId);
object result = new { user, attr = new { attrInfo.lev }, acc, isOnline, onMapName ,isFriend};
bool isEnemy = await _relationService.CheckUserEnemy(userId, userInfo.userId);
object result = new { user, attr = new { attrInfo.lev }, acc, isOnline, onMapName, isFriend, isEnemy };
return PoAction.Ok(result);
}
/// <summary>
/// 更新昵称
/// </summary>
/// <param name="parms"></param>
/// <returns></returns>
[HttpPost]
public async Task<IPoAction> UpdateUserNick([FromBody] UpdateNickParms parms)
{
parms.nick = StringAssist.NoHTML(parms.nick);
if (string.IsNullOrEmpty(parms.nick))
{
return PoAction.Message("昵称不能为空!");
}
string userId = StateHelper.userId;
var userInfo = await _userService.GetUserInfoByUserId(userId);
if (userInfo.nick == parms.nick)
{
return PoAction.Message("昵称无变化,无需修改!");
}
if (await _userService.CheckUserNickIsAt(parms.nick))
{
return PoAction.Message("昵称已存在!");
}
var myGoods = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameUpdateNickNeedGoods);
if (myGoods < 1)
{
return PoAction.Message("暂无改名道具!");
}
if (await _goodsService.UpdateUserGoods(userId, 0, GameConfig.GameUpdateNickNeedGoods, 1, "改名使用"))
{
if (await _userService.UpdateUserNick(userId, parms.nick))
{
string sign = $"玩家注意:【{UbbTool.HomeUbb(userInfo.userNo, userInfo.nick)}】已将昵称修改为【{parms.nick}】";
await _chatService.SendChat("0", StateHelper.areaId, nameof(GameChatEnum.Code.Region), sign);
return PoAction.Ok(true);
}
else
{
return PoAction.Message("操作失败,请稍后尝试!");
}
}
else
{
return PoAction.Message("操作失败,请稍后尝试!");
}
}
/// <summary>
/// 变更性别
/// </summary>
/// <param name="parms"></param>
/// <returns></returns>
[HttpPost]
public async Task<IPoAction> UpdateUserSex([FromBody] UpdateSexParms parms)
{
parms.sex = parms.sex == "男" ? "男" : "女";
string userId = StateHelper.userId;
var userInfo = await _userService.GetUserInfoByUserId(userId);
if (userInfo.sex == parms.sex)
{
return PoAction.Message("已是当前性别,无需修改!");
}
var myGoods = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameUpdateSexNeedGoods);
if (myGoods < 1)
{
return PoAction.Message("暂无性别变更道具!");
}
if (await _goodsService.UpdateUserGoods(userId, 0, GameConfig.GameUpdateSexNeedGoods, 1, "变更性别使用"))
{
if (await _userService.UpdateUserSex(userId, parms.sex))
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("操作失败,请稍后尝试!");
}
}
else
{
return PoAction.Message("操作失败,请稍后尝试!");
}
}
/// <summary>
/// 更新签名
/// </summary>
/// <param name="parms"></param>
/// <returns></returns>
[HttpPost]
public async Task<IPoAction> UpdateUserSign([FromBody] UpdateSignParms parms)
{
if (parms.sign.Length > 80)
{
return PoAction.Message("签名不能超过80个字符!");
}
parms.sign = StringAssist.NoHTML(parms.sign);
string userId = StateHelper.userId;
if (await _userService.UpdateUserSign(userId, parms.sign))
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("操作失败,请稍后尝试!");
}
}
}

View File

@@ -4,4 +4,5 @@ public class RegisterInfoParms
{
public string nick { get; set; } = string.Empty;
public int sex { get; set; }
public string code { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace Application.Web;
public class UpdateNickParms
{
public string nick { get; set; }
}

View File

@@ -0,0 +1,6 @@
namespace Application.Web;
public class UpdateSexParms
{
public string sex { get; set; }
}

View File

@@ -0,0 +1,6 @@
namespace Application.Web;
public class UpdateSignParms
{
public string sign { get; set; }
}

View File

@@ -5,7 +5,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5031",
"applicationUrl": "http://localhost:5031;http://192.168.0.110:5032",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}

View File

@@ -1,5 +1,6 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
ssr: false,
srcDir: 'src/',
components: {
dirs: [

View File

@@ -0,0 +1,13 @@
<template>
<img :src="BaseConfig.BaseMediaUrl + url" :class="_class" :alt="_alt">
</template>
<script setup>
import { BaseConfig } from "@/config/BaseConfig";
// 1. 定义接收父组件传来的参数 props
const props = defineProps({
// 字段名、类型、默认值
url: String,
_class: String,
_alt:String
})
</script>

View File

@@ -15,6 +15,9 @@
({{ TimeExtend.StrToFormat(item.chat.addTime, "dd日HH:mm") }})
</span>
</span>
<span v-if="CheckRole(item.chat.code)">
[<Abutton @click="DelChat(item.chat.chatId)">删除</Abutton>]
</span>
</div>
</div>
</template>
@@ -24,7 +27,8 @@ const props = defineProps({
data: Array<any>,
showTime: Number,
page: Number,
limit: Number
limit: Number,
role: Number
})
const GetChatType = (type: string) => {
@@ -52,4 +56,22 @@ const GetChatType = (type: string) => {
}
return result;
}
const CheckRole = (type: string): boolean => {
if ((type == 'Public' || type == 'Region') && (props.role ?? 0) > 0) {
return true;
}
else if (type == 'Dress' && (props.role ?? 0) > 1) {
return true;
}
return false
}
// 1. 声明要触发的事件
const emit = defineEmits(['delChat'])
const DelChat = async (chatId: string) => {
emit('delChat', { chatId: chatId });
}
</script>

View File

@@ -1,13 +1,17 @@
<template>
<span v-if="data.userNo == '0'">海精灵</span>
<span v-else>
<Abar :href='"/user/user?no=" + data.userNo'>{{ data.nick }}</Abar>
<Abar :href='"/user/user?no=" + data.userNo'>
{{ showArea==1?"["+data.area+"区]":"" }}
{{ data.nick }}
</Abar>
</span>
</template>
<script lang="ts" setup>
const props = defineProps({
// 字段名、类型、默认值
data: null,
showIcon: Number
showIcon: Number,
showArea:Number
})
</script>

View File

@@ -5,9 +5,9 @@
<Abar href="/chat">聊天</Abar>
</div>
<div class="common">
<Abar href="/friend">好友</Abar>.
<Abar href="/user/friend">好友</Abar>.
<Abar href="/trade">交易</Abar>.
<Abar href="/team">队伍</Abar>
<Abar href="/user/team">队伍</Abar>
</div>
<div class="common">
<Abar href="/mall">商城</Abar>.

View File

@@ -2,5 +2,7 @@
统一配置中心
*/
export class BaseConfig {
public static BaseUrl:string="https://localhost:7198";
//public static BaseUrl:string="https://localhost:7198";
public static BaseUrl:string="http://192.168.0.110:5032";
public static BaseMediaUrl:string="https://localhost:7198";
}

View File

@@ -12,13 +12,17 @@
<Acheak @click="ChangeChat('5')" :on-value="type" on-cheak="5">系统</Acheak>
</div>
<div class="content">
<GameChat :data="data" :show-time="1"></GameChat>
<GameChat :data="data" :show-time="1" :role="chatRole" @delChat="DelChat"></GameChat>
<span v-if="data.length == 0">暂无发言.</span>
</div>
<div class="content">
<Pagination :currentPage="currentPage" :limit="10" :total="total" @pageChange="handlePageChange" />
</div>
<div class="content" v-if="type != '5'">
<div class="common" v-if="chatRole < 0">
*发言权限已封禁!
</div>
<div class="common" v-else>
<span>请输入聊天信息:</span><br>
<div v-if="goodsName != ''">
{{ goodsName }}{{ goodsCount }} <span style="font-size: 18px;">(每次发言需要1个哦)</span>
@@ -32,6 +36,8 @@
<Abutton @click="Refresh">刷新</Abutton>
</div>
</div>
</div>
<div class="content">
<Abar href="/customer/chat">*公聊频道发言规范</Abar><br />
<Abar href="/customer/rule">*游戏用户守则规范</Abar>
@@ -51,6 +57,7 @@ const data = ref<Array<any>>([]);
const goodsCount = ref(0);
const goodsName = ref('');
const sign = ref('');
const chatRole = ref(0);
onMounted(async () => {
try {
@@ -68,6 +75,7 @@ const BindData = async (): Promise<void> => {
goodsCount.value = result.data.sendGoodsCount
goodsName.value = result.data.sendGoodsName
total.value = result.data.total;
chatRole.value = result.data.chatRole;
}
else {
MessageExtend.ShowDialog("提示", result.msg);
@@ -121,4 +129,22 @@ const ChangeChat = async (typeid: string): Promise<void> => {
await BindData();
};
//删除记录
const DelChat = async (data: any) => {
MessageExtend.ShowConfirmDialogAsyc("频道管理", `您确定要删除该发言吗?`, async () => {
MessageExtend.LoadingToast("删除中...");
let result = await ChatService.DeleteChat(data.chatId);
MessageExtend.LoadingClose();
if (result.code == 0) {
await BindData();
MessageExtend.Notify("删除成功!", "success");
}
else {
MessageExtend.ShowDialog("删除操作", result.msg);
}
return true;
});
}
</script>

View File

@@ -0,0 +1,3 @@
<template>
暂未开放
</template>

View File

@@ -14,6 +14,9 @@
<option value="1"></option>
</select>
</div>
<div class="input" v-if="isNeedCode">
激活码:<input name="nick" placeholder="联系客服获取激活码" maxlength="50" class="ipt" type="text" v-model="code" />
</div>
<div class="input">
<input type="button"" class=" btn btn-danger" value="注册角色" @click="SubRegInfo" />.
<Abar href="/">返回首页</Abar>
@@ -29,6 +32,9 @@ definePageMeta({
const nick = ref('');
const sex = ref(0);
const code = ref('');
const isNeedCode = ref(false);
const data = ref<any>({});
const SubRegInfo = async (): Promise<void> => {
if (nick.value == null || nick.value == '') {
@@ -36,7 +42,7 @@ const SubRegInfo = async (): Promise<void> => {
return;
}
MessageExtend.LoadingToast("注册中...");
let result = await LoginService.RegisterInfo(nick.value, sex.value);
let result = await LoginService.RegisterInfo(nick.value, sex.value, code.value);
MessageExtend.LoadingClose();
if (result.code == 0) {
PageExtend.Redirect("/map");
@@ -49,10 +55,24 @@ const SubRegInfo = async (): Promise<void> => {
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async () => {
let result = await PubService.GetOnAreaInfo();
if (result.code == 0) {
data.value = result.data;
isNeedCode.value = result.data.isNeedCode == 1;
}
else {
MessageExtend.ShowDialogEvent("提示", result.msg, () => {
PageExtend.RedirectTo('/');
});
}
}
</script>

View File

@@ -20,7 +20,7 @@
</div>
<div class="content">
<div class="item" v-for="item in npcData">
<Abar :href='"/npc?npc=" + item.npcId'>{{ item.npcName }}{{ item.tips }}</Abar>
<Abar :href='"/map/npc?npc=" + item.npcId'>{{ item.npcName }}{{ item.tips }}</Abar>
</div>
</div>

View File

@@ -4,7 +4,7 @@
</div>
<div class="content">
<div class="item" v-for="(item, index) in data" :key="index">
{{ index + 1 }}.<GameUser :data="item" :show-icon="0"></GameUser>
{{ index + 1 }}.<GameUser :data="item" :show-icon="0" :show-area="mapInfo.lookArea == 0 ? 1 : 0"></GameUser>
</div>
<span v-if="data.length == 0">暂无玩家.</span>
</div>
@@ -22,6 +22,7 @@ definePageMeta({
const currentPage = ref<number>(1);
const total = ref<number>(0);
const data = ref<Array<any>>([]);
const mapInfo = ref<any>({});
onMounted(async () => {
try {
@@ -37,6 +38,7 @@ const BindData = async (): Promise<void> => {
if (result.code == 0) {
data.value = result.data.data;
total.value = result.data.total;
mapInfo.value = result.data.map;
}
else {
MessageExtend.ShowDialog("提示", result.msg);

View File

@@ -0,0 +1 @@
<template>暂未开放</template>

View File

@@ -0,0 +1 @@
<template>未开放.</template>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1,3 @@
<template>
暂未开放.
</template>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -30,6 +30,15 @@
<span v-if="data.length == 0">暂无师徒.</span>
</div>
<div class="content" v-if="type == '3'">
<div class="item" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
{{ item.isOnline == 1 ? "[在线]" : "[离线]" }}
<GameUser :data="item.user" :show-icon="1"></GameUser>
<span>
({{ item.user.lev }},{{ item.cityName }}{{ item.mapName }})
<Abutton @click="DeleteEnemy(item.user.userNo)">[×]</Abutton>
</span>
</div>
<span v-if="data.length == 0">暂无仇人.</span>
</div>
<div class="content">
@@ -37,7 +46,7 @@
</div>
<div class="clear"></div>
<div class="content">
<Abar href="/friend/search">添加好友</Abar>
<Abar href="/user/friend/search">添加好友</Abar>
</div>
</template>
<script setup lang="ts">
@@ -126,4 +135,19 @@ const FriendHandle = async (no:string): Promise<void> => {
});
}
const DeleteEnemy = async (no: string): Promise<void> => {
MessageExtend.ShowConfirmDialogAsyc("关系操作", `您确定要删除仇人吗?`, async () => {
let result = await RelationService.DeleteEnemy(no);
if (result.code == 0) {
await BindData();
MessageExtend.Notify(result.msg, "success");
}
else {
MessageExtend.Notify(result.msg, "danger");
}
return true;
});
}
</script>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1,3 @@
<template>
暂未开放.
</template>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1 @@
<template>成就暂未开放.</template>

View File

@@ -1,17 +1,17 @@
<template>
<div class="content">
<Abar href="">更换称号</Abar><br>
ID:{{ userData.userNo }}&nbsp;[<Abar href="">升靓号</Abar>]<br>
昵称:<Abar href="">{{ userData.nick }}</Abar><br>
性别:<Abar href="">{{ userData.sex }}</Abar><br>
<Abar>特权</Abar>:<br>
徽章:<Abar>显示</Abar><br>
社交:<Abar>未收到礼物</Abar><br>
<Abar href="/user/maxname">更换称号</Abar><br>
ID:{{ userData.userNo }}&nbsp;[<Abar href="/privilege/liang">升靓号</Abar>]<br>
昵称:<Abar href="/user/nick">{{ userData.nick }}</Abar><br>
性别:<Abar href="/user/sex">{{ userData.sex }}</Abar><br>
<Abar href="/privilege/">特权</Abar>:<br>
徽章:<Abar href="/user/badge/">显示</Abar><br>
社交:<Abar href="/user/gift">未收到礼物</Abar><br>
婚姻:单身<br>
个性签名:{{ userData.sign }}.<Abar>修改</Abar><br>
个性签名:{{ userData.sign }}<Abar href="/user/sign">修改</Abar><br>
宠物:暂无<br>
坐骑:<br>
成就:<Abar>展示成就</Abar><br>
成就:<Abar href="/user/honnor">展示成就</Abar><br>
等级:{{ attrData.lev }}<br>
综合战力:{{attrData.score}}<br>
经验:{{ expData.exp }}/{{ expData.upExp }}<br>
@@ -31,19 +31,19 @@
</div>
<div class="content">
<div class="item">
<Abar>装备</Abar>.
<Abar>技能</Abar>.
<Abar>特性</Abar>
<Abar href="/user/equ">装备</Abar>.
<Abar href="/user/skill">技能</Abar>.
<Abar href="/user/attr">特性</Abar>
</div>
<div class="item">
<Abar>帮派</Abar>.
<Abar href="/group">帮派</Abar>.
<Abar href="/pet">宠物</Abar>.
<Abar>船队</Abar>
<Abar href="/user/ship">船队</Abar>
</div>
<div class="item">
<Abar>山寨</Abar>.
<Abar>房产</Abar>.
<Abar>设置</Abar>
<Abar href="/user/home/study">山寨</Abar>.
<Abar href="/user/home">房产</Abar>.
<Abar href="/user/setting">设置</Abar>
</div>
</div>
</template>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1 @@
<template>暂未开放</template>

View File

@@ -0,0 +1,63 @@
<template>
<div class="module-title">
更改昵称
</div>
<div class="module-content">
<div class="inArea">
<input name="nick" type="text" class="ipt" maxlength="12" v-model="nick" />
</div>
<div class="inArea">
<input type="button" class="btn btn-danger" value="更改昵称" @click="ChangeNick" />
</div>
</div>
<div class="module-content" style="font-size:15px;font-weight:bold">
*更改昵称需要改名卡 1 <br>
*昵称修改需要符合<Abar href="/customer/rule">游戏用户守则规范</Abar>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: middleware.loading
})
const nick = ref('');
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async () => {
let result = await UserService.GetUserBaseInfo("");
if (result.code == 0) {
nick.value = result.data.nick;
}
else {
MessageExtend.ShowDialog("更改昵称", result.msg);
}
}
const ChangeNick = async (): Promise<void> => {
if (nick.value == null || nick.value == '') {
MessageExtend.ShowToast("昵称不能为空!", "default");
return;
}
MessageExtend.LoadingToast("更改中...");
let result = await UserService.UpdateUserNick(nick.value);
MessageExtend.LoadingClose();
if (result.code == 0) {
MessageExtend.Notify("修改成功!","success");
}
else {
MessageExtend.ShowDialog("更改昵称", result.msg);
}
}
</script>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1,66 @@
<template>
<div class="module-title">
更改性别
</div>
<div class="module-content">
<div class="inArea">
请选择性别:
<select class="ipt" id="sex" name="sex" v-model="sex">
<option value="男"></option>
<option value="女"></option>
</select>
</div>
<div class="inArea">
<input type="button" class="btn btn-danger" value="更改性别" @click="ChangeSex" />
</div>
</div>
<div class="module-content" style="font-size:15px;font-weight:bold">
*更改昵称需要变性卡 1
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: middleware.loading
})
const sex = ref('');
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async () => {
let result = await UserService.GetUserBaseInfo("");
if (result.code == 0) {
sex.value = result.data.sex;
}
else {
MessageExtend.ShowDialog("更改性别", result.msg);
}
}
const ChangeSex = async (): Promise<void> => {
if (sex.value == null || sex.value == '') {
MessageExtend.ShowToast("性别不能为空!", "default");
return;
}
MessageExtend.LoadingToast("更改中...");
let result = await UserService.UpdateUserSex(sex.value);
MessageExtend.LoadingClose();
if (result.code == 0) {
MessageExtend.Notify("修改成功!", "success");
}
else {
MessageExtend.ShowDialog("更改性别", result.msg);
}
}
</script>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1,62 @@
<template>
<div class="module-title">
修改签名
</div>
<div class="module-content">
<div class="inArea">
<textarea name="sign" rows="2" cols="20" maxlength="80" class="ipt" v-model="sign"></textarea>
</div>
<div class="inArea">
<input type="button" class="btn btn-danger" value="保存签名" @click="ChangeSign" />
</div>
</div>
<div class="module-content" style="font-size:15px;font-weight:bold">
*签名要求在80个字符以内
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: middleware.loading
})
const sign = ref('');
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async () => {
let result = await UserService.GetUserBaseInfo("");
if (result.code == 0) {
sign.value = result.data.sign;
}
else {
MessageExtend.ShowDialog("修改签名", result.msg);
}
}
const ChangeSign = async (): Promise<void> => {
if (sign.value == null || sign.value == '') {
MessageExtend.ShowToast("签名不能为空!", "default");
return;
}
MessageExtend.LoadingToast("保存中...");
let result = await UserService.UpdateUserSign(sign.value);
MessageExtend.LoadingClose();
if (result.code == 0) {
MessageExtend.Notify("保存成功!","success");
}
else {
MessageExtend.ShowDialog("修改签名", result.msg);
}
}
</script>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -1,8 +1,11 @@
<template>
<div class="content">
<Abar :href='"/message/read?id=" + userData.userNo'>私聊</Abar>. <Abar>送礼物</Abar>. <Abar>逗一下</Abar><br />
<Abar>拜师</Abar>. <Abar>山寨</Abar>. <Abar>送道具</Abar><br>
<Abutton @click="FriendHandle">{{ isFriend ? "删除好友" : "加好友" }}</Abutton>. <Abar>加仇人</Abar>
<Abar :href='"/message/read?id=" + userData.userNo'>私聊</Abar>. <Abar :href='"/user/gift/give?no="+userData.userNo'>送礼物</Abar>. <Abar href="/user/interact/dou">逗一下</Abar><br />
<Abar href="/user/master/add">拜师</Abar>. <Abar :href='"/trade/user?no="+userData.userNo'>交易</Abar>. <Abar href="/bag/give">送道具</Abar><br>
<Abutton @click="FriendHandle">{{ isFriend ? "删除好友" : "加好友" }}</Abutton>
<span v-if="isEnemy == false">
.<Abutton @click="AddEnemy">加仇人</Abutton>
</span>
</div>
<div class="content"></div>
<div class="content">
@@ -52,6 +55,7 @@ const accData = ref<any>({});
const online = ref(0);
const onMap = ref('');
const isFriend = ref(false);
const isEnemy = ref(false);
onMounted(async () => {
try {
@@ -74,6 +78,7 @@ const BindData = async (): Promise<void> => {
online.value = result.data.isOnline;
onMap.value = result.data.onMapName;
isFriend.value = result.data.isFriend;
isEnemy.value = result.data.isEnemy;
console.log(result);
}
else if (result.code == 101) {
@@ -105,4 +110,20 @@ const FriendHandle = async (): Promise<void> => {
});
}
const AddEnemy = async (): Promise<void> => {
MessageExtend.ShowConfirmDialogAsyc("关系操作", `您确定要添加Ta为仇人吗?(添加消耗50金元)`, async () => {
let no = PageExtend.QueryString("no");
let result = await RelationService.AddEnemy(no);
if (result.code == 0) {
await BindData();
MessageExtend.Notify(result.msg, "success");
}
else {
MessageExtend.Notify(result.msg, "danger");
}
return true;
});
}
</script>

View File

@@ -16,4 +16,11 @@ export class ChatService {
static async SendChat(type: number, sign: string) {
return await ApiService.Request("post", "/Chat/Chat/SendChat", { type, sign });
}
/**
* 删除聊天记录
* GET /Chat/Chat/DeleteChat
*/
static async DeleteChat(chatId: string) {
return await ApiService.Request("get", "/Chat/Chat/DeleteChat", { chatId });
}
}

View File

@@ -30,4 +30,12 @@ export class PubService {
static async GetMyGame(sid: string) {
return await ApiService.Request("get", "/Pub/GetMyGame", { sid });
}
/**
* 获取区服信息
* GET /Pub/GetOnAreaInfo
*/
static async GetOnAreaInfo() {
return await ApiService.Request("get", "/Pub/GetOnAreaInfo");
}
}

View File

@@ -43,13 +43,24 @@ export class LoginService {
return await ApiService.Request("get", "/Login/LoginGame", { sid, user });
}
/**
* RefreshToken
* POST /Login/RefreshToken
* @param refToken body
* @param token body
*/
static async RefreshToken(refToken: string, token: string) {
return await ApiService.Request("post", "/Login/RefreshToken", { refToken, token });
}
/**
* 注册角色信息
* POST /Login/RegisterInfo
* @param nick body
* @param sex body
* @param code body
*/
static async RegisterInfo(nick: string, sex: number) {
return await ApiService.Request("post", "/Login/RegisterInfo", { nick, sex });
static async RegisterInfo(nick: string, sex: number, code: string) {
return await ApiService.Request("post", "/Login/RegisterInfo", { nick, sex, code });
}
}

View File

@@ -8,10 +8,26 @@ export class RelationService {
}
/**
* FriendHandle
* 好友处理
* GET /User/Relation/FriendHandle
*/
static async FriendHandle(no: string) {
return await ApiService.Request("get", "/User/Relation/FriendHandle", { no });
}
/**
* 删除仇人
* GET /User/Relation/DeleteEnemy
*/
static async DeleteEnemy(no: string) {
return await ApiService.Request("get", "/User/Relation/DeleteEnemy", { no });
}
/**
* 添加仇人
* GET /User/Relation/AddEnemy
*/
static async AddEnemy(no: string) {
return await ApiService.Request("get", "/User/Relation/AddEnemy", { no });
}
}

View File

@@ -22,4 +22,31 @@ export class UserService {
static async GetHomeInfo(no: string) {
return await ApiService.Request("get", "/User/User/GetHomeInfo", { no });
}
/**
* 更新昵称
* POST /User/User/UpdateUserNick
* @param nick body
*/
static async UpdateUserNick(nick: string) {
return await ApiService.Request("post", "/User/User/UpdateUserNick", { nick });
}
/**
* 变更性别
* POST /User/User/UpdateUserSex
* @param sex body
*/
static async UpdateUserSex(sex: string) {
return await ApiService.Request("post", "/User/User/UpdateUserSex", { sex });
}
/**
* 更新签名
* POST /User/User/UpdateUserSign
* @param sign body
*/
static async UpdateUserSign(sign: string) {
return await ApiService.Request("post", "/User/User/UpdateUserSign", { sign });
}
}