From 2037d1e577d273a18ef95bd70a1a99c7ab2bd8f9 Mon Sep 17 00:00:00 2001 From: Putoo <290555932@qq.com> Date: Mon, 18 May 2026 18:12:21 +0800 Subject: [PATCH] 11 --- .../Application.Domain.Entity.csproj | 4 + .../User => game/user}/game_account.cs | 0 .../game/user/unit_user.cs | 93 ++++++++++++ .../Game => resource/game}/game_area.cs | 0 .../Game => resource/game}/game_notice.cs | 0 .../Services/Interface/Pub/INoticeService.cs | 1 + .../Interface/User/IUnitUserService.cs | 22 +++ .../Services/Service/Pub/NoticeService.cs | 6 + .../Services/Service/User/UnitUserService.cs | 135 ++++++++++++++++++ .../Common/DateTimeJsonConverter.cs | 21 +++ .../Controllers/Login/LoginController.cs | 76 ++++++++-- .../Controllers/Pub/PubController.cs | 38 ++++- Service/Application.Web/Program.cs | 7 +- Web/src/composables/StateHelper.ts | 10 +- Web/src/extends/MessageExtend.ts | 16 ++- Web/src/pages/index.vue | 127 +++++++++------- Web/src/pages/news/index.vue | 6 +- Web/src/pages/news/info.vue | 52 ++++++- Web/src/services/Index/PubService.ts | 10 +- Web/src/services/login/LoginService.ts | 8 ++ 20 files changed, 555 insertions(+), 77 deletions(-) rename Service/Application.Domain.Entity/{DB_Resource/User => game/user}/game_account.cs (100%) create mode 100644 Service/Application.Domain.Entity/game/user/unit_user.cs rename Service/Application.Domain.Entity/{DB_Resource/Game => resource/game}/game_area.cs (100%) rename Service/Application.Domain.Entity/{DB_Resource/Game => resource/game}/game_notice.cs (100%) create mode 100644 Service/Application.Domain/Services/Interface/User/IUnitUserService.cs create mode 100644 Service/Application.Domain/Services/Service/User/UnitUserService.cs create mode 100644 Service/Application.Web/Common/DateTimeJsonConverter.cs diff --git a/Service/Application.Domain.Entity/Application.Domain.Entity.csproj b/Service/Application.Domain.Entity/Application.Domain.Entity.csproj index 8f5e89a..f7d78e1 100644 --- a/Service/Application.Domain.Entity/Application.Domain.Entity.csproj +++ b/Service/Application.Domain.Entity/Application.Domain.Entity.csproj @@ -10,4 +10,8 @@ + + + + diff --git a/Service/Application.Domain.Entity/DB_Resource/User/game_account.cs b/Service/Application.Domain.Entity/game/user/game_account.cs similarity index 100% rename from Service/Application.Domain.Entity/DB_Resource/User/game_account.cs rename to Service/Application.Domain.Entity/game/user/game_account.cs diff --git a/Service/Application.Domain.Entity/game/user/unit_user.cs b/Service/Application.Domain.Entity/game/user/unit_user.cs new file mode 100644 index 0000000..4d6f46b --- /dev/null +++ b/Service/Application.Domain.Entity/game/user/unit_user.cs @@ -0,0 +1,93 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Game")] + public class unit_user + { + /// + /// userId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string userId { get; set; } + + /// + /// 账号ID + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? accId { get; set; } + + /// + /// 区服 + /// + [SugarColumn(IsNullable = true)] + public int? areaId { get; set; } + + /// + /// userNo + /// + [SugarColumn(Length = 12, IsNullable = false)] + public string userNo { get; set; } + + /// + /// 名称 + /// + [SugarColumn(IsNullable = true)] + public string? nick { get; set; } + + /// + /// 头像 + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? headImg { get; set; } + + /// + /// 性别 + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? sex { get; set; } + + /// + /// 简介 + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? sign { get; set; } + + /// + /// 状态 + /// + [SugarColumn(IsNullable = true)] + public int? status { get; set; } + + /// + /// 注册状态 + /// + [SugarColumn(IsNullable = true)] + public int? regOk { get; set; } + + /// + /// token + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? token { get; set; } + + /// + /// 是否系统账号 + /// + [SugarColumn(IsNullable = true)] + public int? isSystem { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? addTime { get; set; } + + /// + /// 最后更新时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? upTime { get; set; } + } +} diff --git a/Service/Application.Domain.Entity/DB_Resource/Game/game_area.cs b/Service/Application.Domain.Entity/resource/game/game_area.cs similarity index 100% rename from Service/Application.Domain.Entity/DB_Resource/Game/game_area.cs rename to Service/Application.Domain.Entity/resource/game/game_area.cs diff --git a/Service/Application.Domain.Entity/DB_Resource/Game/game_notice.cs b/Service/Application.Domain.Entity/resource/game/game_notice.cs similarity index 100% rename from Service/Application.Domain.Entity/DB_Resource/Game/game_notice.cs rename to Service/Application.Domain.Entity/resource/game/game_notice.cs diff --git a/Service/Application.Domain/Services/Interface/Pub/INoticeService.cs b/Service/Application.Domain/Services/Interface/Pub/INoticeService.cs index 594e14a..a07b805 100644 --- a/Service/Application.Domain/Services/Interface/Pub/INoticeService.cs +++ b/Service/Application.Domain/Services/Interface/Pub/INoticeService.cs @@ -4,4 +4,5 @@ public interface INoticeService { Task> GetNoticeDataByTake(int take); Task> GetNoticeData(int page, int limit, RefAsync total); + Task GetNoticeInfo(string id); } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/User/IUnitUserService.cs b/Service/Application.Domain/Services/Interface/User/IUnitUserService.cs new file mode 100644 index 0000000..769adda --- /dev/null +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserService.cs @@ -0,0 +1,22 @@ +namespace Application.Domain; + +public interface IUnitUserService +{ + #region 用户信息 + + Task> GetUserDataByAccId(string accId); + + #endregion + + #region 用户注册 + + /// + /// 注册游戏角色 + /// + /// + /// + /// + Task Register(int areaId, string accId); + + #endregion +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Pub/NoticeService.cs b/Service/Application.Domain/Services/Service/Pub/NoticeService.cs index e1d69cd..76ba07a 100644 --- a/Service/Application.Domain/Services/Service/Pub/NoticeService.cs +++ b/Service/Application.Domain/Services/Service/Pub/NoticeService.cs @@ -22,4 +22,10 @@ public class NoticeService:INoticeService,ITransient var db = _dbClient.AsTenant().GetConnectionWithAttr(); return await db.Queryable().OrderByDescending(it=>it.addTime).ToPageListAsync(page, limit, total); } + + public async Task GetNoticeInfo(string id) + { + var db = _dbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(it => it.noticeId == id).SingleAsync(); + } } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/User/UnitUserService.cs b/Service/Application.Domain/Services/Service/User/UnitUserService.cs new file mode 100644 index 0000000..6756ee8 --- /dev/null +++ b/Service/Application.Domain/Services/Service/User/UnitUserService.cs @@ -0,0 +1,135 @@ +using Photon.Core.Assist; + +namespace Application.Domain; + +public class UnitUserService : IUnitUserService, ITransient +{ + private readonly ISqlSugarClient _dbClient; + private readonly IRedisCache _redisClient; + + public UnitUserService(ISqlSugarClient dbClient, IRedisCache redisClient) + { + _dbClient = dbClient; + _redisClient = redisClient; + } + + #region 用户信息 + public async Task> GetUserDataByAccId(string accId) + { + var db = _dbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(it => it.accId == accId).ToListAsync(); + } + public async Task GetUserInfoByUserNo(string userNo) + { + string key = string.Format(UserCache.BaseCacheKeys, "UserInfo", "UserNo"); + var data = await _redisClient.GetHashAsync(key, userNo); + if (data == null) + { + var db = _dbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(it => it.userNo == userNo).SingleAsync(); + if (data != null) + { + await _redisClient.AddHashAsync(key, userNo, data); + } + } + + return data; + } + + public async Task GetUserInfoBySid(string token) + { + string key = string.Format(UserCache.BaseCacheKeys, "UserInfo", "Sid"); + var data = await _redisClient.GetHashAsync(key, token); + if (data == null) + { + var db = _dbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(it => it.token == token).SingleAsync(); + if (data != null) + { + await _redisClient.AddHashAsync(key, token, data); + } + } + + return data; + } + + #endregion + + #region 用户注册 + + + + public async Task Register(int areaId, string accId) + { + unit_user result = new unit_user(); + try + { + var db = _dbClient.AsTenant().GetConnectionWithAttr(); + await _dbClient.AsTenant().BeginTranAsync(); + string userId = StringAssist.NewGuid; + result.userId = userId; + result.areaId = areaId; + result.accId = accId; + result.nick = "四海虾米"; + result.headImg = ""; + int no = await GetUserNo(); + result.userNo = no.ToString(); + string token = await GetToken(); + result.token = token; + result.sign = "这个小家伙儿很懒,什么也没留下."; + result.status = 1; + result.regOk = 0; + result.isSystem = 0; + result.addTime = DateTime.Now; + result.upTime = DateTime.Now; + bool isok = db.Insertable(result).ExecuteCommand() > 0; + if (!isok) + { + result = null; + } + + await _dbClient.AsTenant().CommitTranAsync(); + } + catch + { + result = null; + await _dbClient.AsTenant().RollbackTranAsync(); + } + + return result; + } + + public async Task GetUserNo() + { + int No = 0; + bool ok = true; + while (ok) + { + No = RandomAssist.GetFormatedNumeric(11012585, 97521695); + if (await GetUserInfoByUserNo(No.ToString()) == null) + { + ok = false; + } + } + + return No; + } + + private async Task GetToken() + { + string sid = string.Empty; + bool ok = true; + while (ok) + { + sid = StringAssist.RandomString(32); + if (await GetUserInfoBySid(sid) == null) + { + ok = false; + } + } + + return sid; + } + + #endregion +} \ No newline at end of file diff --git a/Service/Application.Web/Common/DateTimeJsonConverter.cs b/Service/Application.Web/Common/DateTimeJsonConverter.cs new file mode 100644 index 0000000..f092e73 --- /dev/null +++ b/Service/Application.Web/Common/DateTimeJsonConverter.cs @@ -0,0 +1,21 @@ +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Application.Web; + +public class DateTimeJsonConverter: JsonConverter +{ + public override DateTime Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options) + { + return DateTime.ParseExact(reader.GetString(), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); + } + + public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) + { + writer.WriteStringValue(value.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)); + } +} \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Login/LoginController.cs b/Service/Application.Web/Controllers/Login/LoginController.cs index 239dad5..65c21fb 100644 --- a/Service/Application.Web/Controllers/Login/LoginController.cs +++ b/Service/Application.Web/Controllers/Login/LoginController.cs @@ -14,9 +14,15 @@ namespace Application.Web.Controllers.Login public class LoginController : ControllerBase { private readonly IGameAccountService _accountService; - public LoginController(IGameAccountService accountService) + private readonly IAreaService _areaService; + private readonly IUnitUserService _userService; + + public LoginController(IGameAccountService accountService, IAreaService areaService, + IUnitUserService userService) { _accountService = accountService; + _areaService = areaService; + _userService = userService; } /// @@ -27,8 +33,6 @@ namespace Application.Web.Controllers.Login [HttpPost] public async Task Login([FromBody] LoginParms parms) { - - return PoAction.Ok(parms.code); } @@ -38,14 +42,15 @@ namespace Application.Web.Controllers.Login /// /// [HttpGet] - public async Task TwLogin( string code) + public async Task TwLogin(string code) { if (string.IsNullOrEmpty(code)) { return PoAction.Message("code值错误!"); } + AutoLogin login = new AutoLogin(); - var loginInfo = await login.TwLogin(code); + var loginInfo = await login.TwLogin(code); if (loginInfo.code == 0) { dynamic twInfo = JsonConvert.DeserializeObject(loginInfo.data.ToString()); @@ -54,14 +59,14 @@ namespace Application.Web.Controllers.Login var accInfo = await _accountService.GetAccInfoByOpenId(openId); if (accInfo == null) { - var userData = await _accountService.Regist("", nick, "", "", openId); + var userData = await _accountService.Regist("", nick, "", "", openId); if (userData == null) { return PoAction.Message("登录失败,请联系客服!"); } else { - object ret =new { token = userData.token }; + object ret = new { token = userData.token }; return PoAction.Ok(ret); } } @@ -73,7 +78,7 @@ namespace Application.Web.Controllers.Login } else { - object ret =new { token = accInfo.token }; + object ret = new { token = accInfo.token }; return PoAction.Ok(ret); } } @@ -112,5 +117,60 @@ namespace Application.Web.Controllers.Login return PoAction.Message("退出失败,请稍后尝试!"); } } + + /// + /// 注册基础账号信息 + /// + /// + /// + /// + [HttpGet] + public async Task Register(string sid, int area) + { + if (string.IsNullOrEmpty(sid)) + { + return PoAction.Message("未登录账号!"); + } + + var accInfo = await _accountService.GetAccInfoByToken(sid); + if (accInfo == null) + { + return PoAction.Message("未登录账号!"); + } + + var areaInfo = await _areaService.GetAreaInfo(area); + if (areaInfo == null) + { + return PoAction.Message("区服不存在!"); + } + + if (areaInfo.status != 1) + { + return PoAction.Message("当前区繁忙,无法进入!"); + } + + //判断是否已经注册 + var userData = await _userService.GetUserDataByAccId(accInfo.accId); + if (userData.Any(it => it.areaId == area)) + { + return PoAction.Message("该区已存在角色!"); + } + + var userInfo = await _userService.Register(areaInfo.areaId, accInfo.accId); + if (userInfo == null) + { + return PoAction.Message("注册失败,请稍后尝试!"); + } + + Dictionary loadData = new Dictionary(); + loadData.Add("userId", userInfo.userId); + loadData.Add("accId", userInfo.accId); + + string Key = App.Configuration["JwtTokenOptions:SecurityKey"].ToString(); + string Issuer = App.Configuration["JwtTokenOptions:Issuer"].ToString(); + string Audience = App.Configuration["JwtTokenOptions:Audience"].ToString(); + string token = JwtHelper.CreateToken(Key, Issuer, Audience, loadData, 300); + return PoAction.Ok(new { token = token, refToken = userInfo.token, userId = userInfo.userId }); + } } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Pub/PubController.cs b/Service/Application.Web/Controllers/Pub/PubController.cs index 98533c0..218d805 100644 --- a/Service/Application.Web/Controllers/Pub/PubController.cs +++ b/Service/Application.Web/Controllers/Pub/PubController.cs @@ -13,12 +13,14 @@ namespace Application.Web.Controllers.Pub private readonly IAreaService _areaService; private readonly INoticeService _noticeService; private readonly IGameAccountService _accountService; + private readonly IUnitUserService _userService; - public PubController(IAreaService areaService, INoticeService noticeService,IGameAccountService accountService) + public PubController(IAreaService areaService, INoticeService noticeService, IGameAccountService accountService,IUnitUserService userService) { _areaService = areaService; _noticeService = noticeService; _accountService = accountService; + _userService = userService; } /// @@ -31,20 +33,27 @@ namespace Application.Web.Controllers.Pub { bool isOnline = false; game_account account = new game_account(); + List userData = new List(); if (!string.IsNullOrEmpty(sid)) { account = await _accountService.GetAccInfoByToken(sid); if (account != null) { isOnline = true; + userData = await _userService.GetUserDataByAccId(account.accId); } } - + var areaData = await _areaService.GetAreaData(); - var notice = await _noticeService.GetNoticeDataByTake(5); + foreach (var _user in userData) + { + areaData.RemoveAll(it => it.areaId == _user.areaId); + } + var notice = await _noticeService.GetNoticeDataByTake(5); + int OnCount = 100; - return PoAction.Ok(new { area = areaData, notice, isOnline, onCount = OnCount,account }); + return PoAction.Ok(new { area = areaData, notice, isOnline, onCount = OnCount, account,userData }); } /// @@ -54,11 +63,28 @@ namespace Application.Web.Controllers.Pub /// /// [HttpGet] - public async Task GetNoticeData(int page,int limit) + public async Task GetNoticeData(int page, int limit) { RefAsync total = 0; var data = await _noticeService.GetNoticeData(page, limit, total); - return PoAction.Ok(new { data, total=total.Value }); + return PoAction.Ok(new { data, total = total.Value }); + } + + /// + /// 获取公告详情 + /// + /// + /// + [HttpGet] + public async Task GetNoticeInfo(string id) + { + var data = await _noticeService.GetNoticeInfo(id); + if (data == null) + { + return PoAction.Message("公告不存在!"); + } + data.sign = data.sign.Replace("[Br]", ""); + return PoAction.Ok(data); } } } \ No newline at end of file diff --git a/Service/Application.Web/Program.cs b/Service/Application.Web/Program.cs index d74e7e5..d0710cf 100644 --- a/Service/Application.Web/Program.cs +++ b/Service/Application.Web/Program.cs @@ -53,8 +53,13 @@ builder.Services.InjectTimer(services => builder.Logging.InjectLog(); // Add services to the container. +builder.Services.AddControllers().AddJsonOptions(option => +{ + option.JsonSerializerOptions.Converters.Add(new DateTimeJsonConverter()); + option.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.IgnoreCycles; + option.JsonSerializerOptions.MaxDepth =int.MaxValue; +}); -builder.Services.AddControllers(); // Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi #region 配置跨域处理,允许所有来源 diff --git a/Web/src/composables/StateHelper.ts b/Web/src/composables/StateHelper.ts index 96a5265..2aba5b9 100644 --- a/Web/src/composables/StateHelper.ts +++ b/Web/src/composables/StateHelper.ts @@ -16,20 +16,22 @@ export class StateHelper { static get userId() { return this.userStore.userId; } + static SetToken(userId: string, token: string, refToken: string) { + this.userStore.setToken(userId, token, refToken); + } static SetSid(sid: string) { this.userStore.setSid(sid); } - static OffOnline() - { + static OffOnline() { this.userStore.offOnline(); } - static get IsAccLogin(){ + static get IsAccLogin() { return this.userStore.isLoginAccount; } - static get IsLogin(){ + static get IsLogin() { return this.userStore.isLogin; } diff --git a/Web/src/extends/MessageExtend.ts b/Web/src/extends/MessageExtend.ts index c38431d..f203e45 100644 --- a/Web/src/extends/MessageExtend.ts +++ b/Web/src/extends/MessageExtend.ts @@ -4,7 +4,11 @@ export class MessageExtend { // 消息通知 static Notify(message: any, type?: 'primary' | 'success' | 'danger' | 'warning') { - showNotify({ type, message }) + showNotify({ + type: type, + message: message, + duration: 1500, + }); } // 提示弹窗 @@ -12,6 +16,16 @@ export class MessageExtend { showDialog({ title: title, message: message }) } + static ShowDialogEvent(title: string, message: string, onConfirm?: () => void, confirmButtonText?: string) { + showDialog({ + title: title, + message: message, + confirmButtonText: confirmButtonText || '确认' + }).then(() => { + onConfirm?.() + }); + } + // 确认提示弹窗 static ShowConfirmDialog(title: string, message: string, onConfirm?: () => void, onCancel?: () => void, confirmButtonText?: string) { showConfirmDialog({ diff --git a/Web/src/pages/index.vue b/Web/src/pages/index.vue index dbae7d3..e1c3e17 100644 --- a/Web/src/pages/index.vue +++ b/Web/src/pages/index.vue @@ -14,10 +14,10 @@ - ➢返回探玩驿站 + ➢返回探玩驿站 - ➸游戏论坛 + ➸游戏论坛 ➸退出游戏 @@ -30,8 +30,8 @@ =====☆我的区服☆===== - - ✧【1区】新手村✰村长(男) + + 【{{ item.areaId }}区】{{ item.nick }}({{ (item.sex == null||item.sex=='') ? "未知" : item.sex }}) @@ -41,7 +41,7 @@ - ✧({{ item.areaId }}区){{ item.name }} + ✧({{ item.areaId }}区){{ item.name }} {{ item.status == 1 ? "(推荐)" : "(繁忙)" }} 暂无区服. @@ -49,7 +49,7 @@ - =====☆官方公告☆===== + =====☆官方公告☆===== @@ -64,7 +64,7 @@ 客服. 关于. - 合作 + 合作 @@ -85,50 +85,7 @@ const noticeData = ref>([]); const isOnline = ref(false); const OnCount = ref(0); const AccountInfo = ref(); - -const Initialize = async (): Promise => { - var result = await PubService.GetMain(StateHelper.Sid); - if (result.code == 0) { - isOnline.value = result.data.isOnline; - if (isOnline.value == false) { - StateHelper.OffOnline(); - } - areaData.value = result.data?.area; - noticeData.value = result.data.notice; - OnCount.value = result.data.onCount; - AccountInfo.value = result.data.account; - } - else { - MessageExtend.ShowToast(result.msg, "fail"); - } -}; - -//退出登录 -const offOnline = async () => { - MessageExtend.ShowConfirmDialog("退出游戏", "您确定要退出游戏吗?", async () => { - var result = await PubService.GetMain(StateHelper.Sid); - if (result.code == 0) { - StateHelper.OffOnline(); - isOnline.value = false; - MessageExtend.ShowToast("退出成功!", "success"); - } - else { - MessageExtend.ShowToast(result.msg, "fail"); - } - }); -} - -const login = async (code: string): Promise => { - var result = await LoginService.TwLogin(code); - console.log(result); - if (result.code == 0) { - StateHelper.SetSid(result.data.token); - await Initialize(); - } - else { - MessageExtend.ShowToast(result.msg, "default"); - } -} +const userData = ref>([]); onMounted(async () => { try { @@ -146,4 +103,72 @@ onMounted(async () => { PageLoading.Close(); } }) + +/**初始化数据 */ +const Initialize = async (): Promise => { + let result = await PubService.GetMain(StateHelper.Sid); + if (result.code == 0) { + isOnline.value = result.data.isOnline; + if (isOnline.value == false) { + StateHelper.OffOnline(); + } + areaData.value = result.data?.area; + noticeData.value = result.data.notice; + OnCount.value = result.data.onCount; + AccountInfo.value = result.data.account; + userData.value = result.data.userData; + } + else { + MessageExtend.ShowToast(result.msg, "fail"); + } +}; + +/**自动登录 */ +const login = async (code: string): Promise => { + let result = await LoginService.TwLogin(code); + console.log(result); + if (result.code == 0) { + StateHelper.SetSid(result.data.token); + await Initialize(); + } + else { + MessageExtend.ShowToast(result.msg, "default"); + } +} + +/**退出登录 */ +const offOnline = async () => { + MessageExtend.ShowConfirmDialog("退出游戏", "您确定要退出游戏吗?", async () => { + let result = await PubService.GetMain(StateHelper.Sid); + if (result.code == 0) { + StateHelper.OffOnline(); + isOnline.value = false; + MessageExtend.ShowToast("退出成功!", "success"); + } + else { + MessageExtend.ShowToast(result.msg, "fail"); + } + }); +} + +/**登录到游戏 */ +const loginGame = async (gameId: string): Promise => { + alert(gameId) +}; + +/**注册游戏 */ +const registerGame = async (area: number): Promise => { + let result = await LoginService.Register(StateHelper.Sid, area); + if (result.code == 0) { + StateHelper.SetToken(result.data.userId, result.data.token, result.data.refToken); + PageExtend.Redirect("/login/register"); + } + else { + MessageExtend.ShowDialog("注册角色", result.msg); + } +} + +/**辅助方法 */ + + diff --git a/Web/src/pages/news/index.vue b/Web/src/pages/news/index.vue index 993b6c5..f439d71 100644 --- a/Web/src/pages/news/index.vue +++ b/Web/src/pages/news/index.vue @@ -27,12 +27,10 @@ const data = ref>([]); const handlePageChange = async (page: number): Promise => { currentPage.value = page; await BindData(); - console.log('跳转到第', page, '页'); }; -const BindData = async (): Promise => { - var result = await PubService.GetNoticeData(currentPage.value, 10); - console.log(result); +const BindData = async (): Promise => { + var result = await PubService.GetNoticeData(currentPage.value, 10); if (result.code == 0) { data.value = result.data.data; totalPages.value = result.data.total; diff --git a/Web/src/pages/news/info.vue b/Web/src/pages/news/info.vue index 41a40c8..1b2f3db 100644 --- a/Web/src/pages/news/info.vue +++ b/Web/src/pages/news/info.vue @@ -1 +1,51 @@ - \ No newline at end of file + + + 官方公告>详情 + + + + [标题]:{{ noticeData.title }} + + + [时间]: {{noticeData.addTime}} + + + + + 返回公告列表 + + 返回游戏首页 + + \ No newline at end of file diff --git a/Web/src/services/Index/PubService.ts b/Web/src/services/Index/PubService.ts index fb93b79..c143ea0 100644 --- a/Web/src/services/Index/PubService.ts +++ b/Web/src/services/Index/PubService.ts @@ -8,10 +8,18 @@ export class PubService { } /** - * GetNoticeData + * 获取公告列表 * GET /Pub/GetNoticeData */ static async GetNoticeData(page: number, limit: number) { return await ApiService.Request("get", "/Pub/GetNoticeData", { page, limit }); } + + /** + * 获取公告详情 + * GET /Pub/GetNoticeInfo + */ + static async GetNoticeInfo(id: string) { + return await ApiService.Request("get", "/Pub/GetNoticeInfo", { id }); + } } \ No newline at end of file diff --git a/Web/src/services/login/LoginService.ts b/Web/src/services/login/LoginService.ts index 1847b28..4d12c50 100644 --- a/Web/src/services/login/LoginService.ts +++ b/Web/src/services/login/LoginService.ts @@ -26,4 +26,12 @@ export class LoginService { static async LoginOut(sid: string) { return await ApiService.Request("get", "/Login/LoginOut", { sid }); } + + /** + * 注册基础账号信息 + * GET /Login/Regist + */ + static async Register(sid: string, area: number) { + return await ApiService.Request("get", "/Login/Register", { sid, area }); + } } \ No newline at end of file