diff --git a/Service/Application.Domain.Entity/DB_Resource/User/game_account.cs b/Service/Application.Domain.Entity/DB_Resource/User/game_account.cs new file mode 100644 index 0000000..7ec66e3 --- /dev/null +++ b/Service/Application.Domain.Entity/DB_Resource/User/game_account.cs @@ -0,0 +1,75 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Game")] + public class game_account + { + /// + /// accId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string accId { get; set; } + + /// + /// userName + /// + [SugarColumn(Length = 20, IsNullable = true)] + public string? userName { get; set; } + + /// + /// nick + /// + [SugarColumn(Length = 30, IsNullable = true)] + public string? nick { get; set; } + + /// + /// pwd + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? pwd { get; set; } + + /// + /// npwd + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? npwd { get; set; } + + /// + /// status + /// + [SugarColumn(IsNullable = true)] + public int? status { get; set; } + + /// + /// remCode + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? remCode { get; set; } + + /// + /// remAccId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? remAccId { get; set; } + + /// + /// token + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? token { get; set; } + + /// + /// addTime + /// + [SugarColumn(IsNullable = true)] + public DateTime? addTime { get; set; } + + /// + /// openId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? openId { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain/Cache/UserCache.cs b/Service/Application.Domain/Cache/UserCache.cs new file mode 100644 index 0000000..58d54fd --- /dev/null +++ b/Service/Application.Domain/Cache/UserCache.cs @@ -0,0 +1,7 @@ +namespace Application.Domain; + +public class UserCache +{ + public static string BaseCacheKey = "BaseUserCache:{0}"; + public static string BaseCacheKeys = "BaseUserCache:{0}:{1}"; +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/User/IGameAccountService.cs b/Service/Application.Domain/Services/Interface/User/IGameAccountService.cs new file mode 100644 index 0000000..ebb90d4 --- /dev/null +++ b/Service/Application.Domain/Services/Interface/User/IGameAccountService.cs @@ -0,0 +1,33 @@ +namespace Application.Domain; + +public interface IGameAccountService +{ + /// + /// 根据OpenId获取账号信息 + /// + /// + /// + Task GetAccInfoByOpenId(string openId); + /// + /// 根据AccId获取账号信息 + /// + /// + /// + Task GetAccInfoByAccId(string accId); + + Task GetAccInfoByToken(string token); + /// + /// 注册账号 + /// + /// + /// + /// + /// + /// + /// + Task Regist(string userName, string nick, string pwd, string remAccId = "", + string openId = ""); + + Task UpdateAccountToken(string accId); + +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/User/GameAccountService.cs b/Service/Application.Domain/Services/Service/User/GameAccountService.cs new file mode 100644 index 0000000..7048487 --- /dev/null +++ b/Service/Application.Domain/Services/Service/User/GameAccountService.cs @@ -0,0 +1,160 @@ +using Photon.Core.Assist; + +namespace Application.Domain; + +public class GameAccountService : IGameAccountService, ITransient +{ + private readonly ISqlSugarClient _dbClient; + private readonly IRedisCache _redisClient; + + public GameAccountService(ISqlSugarClient dbClient, IRedisCache redisClient) + { + _dbClient = dbClient; + _redisClient = redisClient; + } + + + public async Task GetAccInfoByOpenId(string openId) + { + string key = string.Format(UserCache.BaseCacheKeys, "UserAccountData", "OpenId"); + if (await _redisClient.HExistsHashAsync(key, openId)) + { + return await _redisClient.GetHashAsync(key, openId); + } + else + { + var db = _dbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.openId == openId).FirstAsync(); + await _redisClient.AddHashAsync(key, openId, data); + return data; + } + } + + public async Task GetAccInfoByAccId(string accId) + { + string key = string.Format(UserCache.BaseCacheKeys, "UserAccountData", "AccId"); + if (await _redisClient.HExistsHashAsync(key, accId)) + { + return await _redisClient.GetHashAsync(key, accId); + } + else + { + var db = _dbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.accId == accId).FirstAsync(); + await _redisClient.AddHashAsync(key, accId, data); + return data; + } + } + + public async Task GetAccInfoByToken(string token) + { + var db = _dbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.token == token).FirstAsync(); + return data; + } + + private async Task ClearCache(string clearId) + { + string openId = string.Empty; + string accId = string.Empty; + var accInfo = await GetAccInfoByAccId(clearId); + if (accInfo != null) + { + accId = accInfo.accId; + openId = accInfo.openId; + } + else + { + accInfo = await GetAccInfoByOpenId(clearId); + if (accInfo != null) + { + accId = accInfo.accId; + openId = accInfo.openId; + } + } + + if (!string.IsNullOrEmpty(openId)) + { + string key = string.Format(UserCache.BaseCacheKeys, "UserAccountData", "OpenId"); + await _redisClient.DelHashAsync(key, openId); + } + + if (!string.IsNullOrEmpty(accId)) + { + string key = string.Format(UserCache.BaseCacheKeys, "UserAccountData", "AccId"); + await _redisClient.DelHashAsync(key, accId); + } + } + + public async Task Regist(string userName, string nick, string pwd, string remAccId = "", + string openId = "") + { + game_account result = new game_account(); + try + { + var db = _dbClient.AsTenant().GetConnectionWithAttr(); + await _dbClient.AsTenant().BeginTranAsync(); + string accId = StringAssist.NewGuid; + result.accId = accId; + result.userName = userName; + result.nick = nick; + string sid = await CreateToken(); + result.token = sid; + result.npwd = pwd; + result.remAccId = remAccId; + result.remCode = StringAssist.RandomString(6); + result.pwd = EncryptAssist.Md5Encryption(pwd); + result.status = 1; + result.addTime = DateTime.Now; + result.openId = openId; + bool isok = await db.Insertable(result).ExecuteCommandAsync() > 0; + if (isok) + { + await ClearCache(openId); + } + else + { + result = null; + } + await _dbClient.AsTenant().CommitTranAsync(); + } + catch + { + result = null; + await _dbClient.AsTenant().RollbackTranAsync(); + } + + return result; + } + + private async Task CreateToken() + { + var db = _dbClient.AsTenant().GetConnectionWithAttr(); + string token = string.Empty; + bool ok = true; + while (ok) + { + token = string.Format("{0}", StringAssist.RandomString(32)); + if (await db.Queryable().Where(it => it.token == token).AnyAsync() == false) + { + ok = false; + } + } + + return token; + } + + public async Task UpdateAccountToken(string accId) + { + var db = _dbClient.AsTenant().GetConnectionWithAttr(); + string token = await CreateToken(); + bool result = await db.Updateable().SetColumns(it => it.token == token) + .Where(it => it.accId == accId).ExecuteCommandAsync() > 0; + if (result) + { + await ClearCache(accId); + } + + return result; + } +} \ No newline at end of file diff --git a/Service/Application.Web/Common/AutoLogin.cs b/Service/Application.Web/Common/AutoLogin.cs new file mode 100644 index 0000000..1d7cf98 --- /dev/null +++ b/Service/Application.Web/Common/AutoLogin.cs @@ -0,0 +1,22 @@ +using Newtonsoft.Json; + +namespace Application.Web; + +public class AutoLogin +{ + public async Task TwLogin(string code) + { + using HttpClient client = new HttpClient(); +// 发送 GET 请求 + string url = $"https://m.twbar.cn/api/AppAuto/GetOpenInfo?code={code}"; + string responseText = await client.GetStringAsync(url); + return JsonConvert.DeserializeObject(responseText); + } +} + +public class TwResult +{ + public string msg { get; set; } = ""; + public int code { get; set; } + public object data { get; set; } +} \ 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 037ae58..239dad5 100644 --- a/Service/Application.Web/Controllers/Login/LoginController.cs +++ b/Service/Application.Web/Controllers/Login/LoginController.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; +using Newtonsoft.Json; namespace Application.Web.Controllers.Login { @@ -9,39 +10,107 @@ namespace Application.Web.Controllers.Login /// [ApiExplorerSettings(GroupName = "Login")] [Route("[controller]/[action]")] - [ApiController] + [ApiController] public class LoginController : ControllerBase { - private readonly IHubContext _hubContext; - public LoginController(IHubContext hubContext) + private readonly IGameAccountService _accountService; + public LoginController(IGameAccountService accountService) { - _hubContext = hubContext; + _accountService = accountService; } - /// - /// 登录接口 - /// - /// - /// + + /// + /// 登录接口 + /// + /// + /// [HttpPost] public async Task Login([FromBody] LoginParms parms) { + return PoAction.Ok(parms.code); } + /// - /// 测试接口 + /// 探玩自动登录 /// - /// 测试名 - /// 测试2 + /// /// [HttpGet] - public async Task Test(string name,string ttt) + public async Task TwLogin( string code) { - await _hubContext.Clients.All.SendAsync("ReceiveMessage", "系统"); - - return PoAction.Ok(name); - + if (string.IsNullOrEmpty(code)) + { + return PoAction.Message("code值错误!"); + } + AutoLogin login = new AutoLogin(); + var loginInfo = await login.TwLogin(code); + if (loginInfo.code == 0) + { + dynamic twInfo = JsonConvert.DeserializeObject(loginInfo.data.ToString()); + string openId = twInfo.openid; + string nick = "探玩玩家"; + var accInfo = await _accountService.GetAccInfoByOpenId(openId); + if (accInfo == null) + { + var userData = await _accountService.Regist("", nick, "", "", openId); + if (userData == null) + { + return PoAction.Message("登录失败,请联系客服!"); + } + else + { + object ret =new { token = userData.token }; + return PoAction.Ok(ret); + } + } + else + { + if (accInfo.status != 1) + { + return PoAction.Message("账号被冻结!"); + } + else + { + object ret =new { token = accInfo.token }; + return PoAction.Ok(ret); + } + } + } + else + { + return PoAction.Message(loginInfo.msg); + } } + /// + /// 退出登录 + /// + /// + /// + [HttpGet] + public async Task LoginOut(string? sid) + { + if (string.IsNullOrEmpty(sid)) + { + return PoAction.Message("身份信息不存在!"); + } + + var accInfo = await _accountService.GetAccInfoByToken(sid); + if (accInfo == null) + { + return PoAction.Message("身份信息不存在!"); + } + + if (await _accountService.UpdateAccountToken(accInfo.accId)) + { + return PoAction.Ok(true); + } + else + { + return PoAction.Message("退出失败,请稍后尝试!"); + } + } } -} +} \ No newline at end of file diff --git a/Web/src/app.vue b/Web/src/app.vue index 635105c..68f9d76 100644 --- a/Web/src/app.vue +++ b/Web/src/app.vue @@ -15,13 +15,12 @@ const { on, emit } = useEventBus() //连接signlar const ConnectSignlar = (clientId: string) => { - console.log(`客户端:${clientId}`); + console.log(`客户端:${clientId}`); } // 初始化应用配置 onMounted(() => { - userStore.setToken("5555","111","222"); // 初始化屏幕尺寸 if (typeof window !== 'undefined') { appStore.updateScreenSize(window.innerWidth, window.innerHeight) diff --git a/Web/src/assets/css/style.css b/Web/src/assets/css/style.css index 5de4dc9..ae7a5ca 100644 --- a/Web/src/assets/css/style.css +++ b/Web/src/assets/css/style.css @@ -1,4 +1,13 @@ -body, div, p, a, table, textarea, form, img, ul, li { +body, +div, +p, +a, +table, +textarea, +form, +img, +ul, +li { margin: 0; padding: 0; border: 0; @@ -10,87 +19,61 @@ body { font-size: 18px; } -.game_nav { - background: #302828; - color: white; - font-size: 15px; - padding: 2px 0px 2px 3px; - color: white; - font-style: italic; - padding-left: 10px; -} - -.main { -} +.main {} div { margin: 5px 2px; } - div img { - margin-right: 2px; - vertical-align: middle; - } +div img { + margin-right: 2px; + vertical-align: middle; +} - div img { - max-width: 100%; - width: exPRession(document.body.clientWidth>250?"250px":"auto"); - overflow: hidden; - } +div img { + max-width: 100%; +} .logo { max-height: 120px; } -.step-logo { - max-height: 120px; -} +.head {} -.head { -} +.title {} -.title { -} +.content {} -.content { -} - -.item { -} +.item {} .border { border-bottom: 1px dashed #9f8d8d; } -.tips { -} - -.menu { -} - .clear { height: 5px; } -.foot { -} +.foot {} -body a { +a { color: #1e5494; margin: 0 5px; text-decoration: underline; } - a:link { - color: #1e5494; - /*display: inline-block;*/ - margin: 3px 4px 3px 4px; - } +a:link { + color: #1e5494; + /*display: inline-block;*/ + margin: 3px 4px 3px 4px; +} - a:hover, a:active, a:focus { - color: #FFFFFF; - background: #1e5494; - } +a:hover, +a:active, +a:focus { + color: #FFFFFF; + background: #1e5494; +} .a-nomargin { margin: 0; @@ -104,530 +87,13 @@ body a { color: red; } - .text-red a { - color: red; - } - -.page-msg { +.text-red a { color: red; } -.common { -} +.common {} - .common img { - margin-right: 2px; - vertical-align: middle; - } - -.PageTips { - font-size: 15px; - font-weight: bold; -} - -.algin-center { - text-align: center -} - -.input { - line-height: 30px; -} - -.ipt { - width: 60%; - display: block; - padding: 6px 12px; - font-size: 14px; - color: #555; - background-color: #fff; - background-image: none; - border: 1px solid #ccc; - border-radius: 4px; - box-shadow: inset 0 1px 1px rgb(0 0 0 / 8%); - transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s; -} - -.btn { - display: inline-block; - margin-bottom: 0; - font-size: 14px; - font-weight: 400; - text-align: center; - white-space: nowrap; - vertical-align: middle; - -ms-touch-action: manipulation; - touch-action: manipulation; - cursor: pointer; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - background-image: none; - border: 1px solid transparent; - border-radius: 4px; -} - -.btn-danger { - color: #fff; - background-color: #d9534f; - border-color: #d43f3a; -} - -.btn-waring { - color: #fff; - background-color: #FE5E08; - border-color: #FE5E08; -} - -.btn-ret { - border-color: #d2d2d2; - background: 0 0; - color: #666; -} - -.chat { - word-wrap: break-word; -} - - .chat img { - margin-right: 2px; - vertical-align: middle; - } - -.em { - height: 22px; - width: 22px; -} - -.ftbtn { - margin-top: 15px; -} - -.equImg-min { - width: 18px; - height: 18px; -} -.user-head { - max-height: 25px; - max-width: 25px; -} -/******装备样式******/ -.equImg { - max-width: 130px; - max-height: 230px; -} - -.tq { - background-image: url('/images/site/equ/tq.png'); - background-repeat: no-repeat; - display: inline-block; - width: 15px; - height: 15px; - background-size: 15px; /*设置图片大小*/ -} - -.ty { - background-image: url('/images/site/equ/ty.png'); - background-repeat: no-repeat; - display: inline-block; - width: 15px; - height: 15px; - background-size: 15px; /*设置图片大小*/ -} - -.ms { - background-image: url('/images/site/equ/ms.png'); - background-repeat: no-repeat; - display: inline-block; - width: 15px; - height: 15px; - background-size: 15px; /*设置图片大小*/ -} - -.zx { - background-image: url('/images/site/equ/zx.png'); - background-repeat: no-repeat; - display: inline-block; - width: 15px; - height: 15px; - background-size: 15px; /*设置图片大小*/ -} - -.sy { - background-image: url('/images/site/equ/sy.png'); - background-repeat: no-repeat; - display: inline-block; - width: 15px; - height: 15px; - background-size: 15px; /*设置图片大小*/ -} - -.gw { - background-image: url('/images/site/equ/gw.png'); - background-repeat: no-repeat; - display: inline-block; - width: 15px; - height: 15px; - background-size: 15px; /*设置图片大小*/ -} - -.ly { - background-image: url('/images/site/equ/ly.gif'); - background-repeat: no-repeat; - display: inline-block; - width: 15px; - height: 15px; - background-size: 15px; /*设置图片大小*/ -} - -.hm { - background-image: url('/images/site/equ/hm.gif'); - background-repeat: no-repeat; - display: inline-block; - width: 15px; - height: 15px; - background-size: 15px; /*设置图片大小*/ -} - -.j_r { - background-image: url('/images/site/equ/r.gif'); - background-repeat: no-repeat; - display: inline-block; - width: 15px; - height: 15px; - background-size: 15px; /*设置图片大小*/ -} - -.j_l { - background-image: url('/images/site/equ/l.gif'); - background-repeat: no-repeat; - display: inline-block; - width: 15px; - height: 15px; - background-size: 15px; /*设置图片大小*/ -} - -/**********End*******/ -/***副本***/ -.dup { - background-image: url('/images/site/dup/dup.gif'); - background-repeat: no-repeat; - display: inline-block; - width: 18px; - height: 18px; - background-size: 18px; /*设置图片大小*/ -} -/***任务***/ -.task-ret { - background-image: url('/images/site/tr.gif'); - background-repeat: no-repeat; - display: inline-block; - width: 18px; - height: 18px; - background-size: 18px; /*设置图片大小*/ -} - -.task-get { - background-image: url('/images/site/tg.gif'); - background-repeat: no-repeat; - display: inline-block; - width: 18px; - height: 18px; - background-size: 18px; /*设置图片大小*/ -} -/*九宫图片*/ -.gray { - -webkit-filter: grayscale(100%); - -moz-filter: grayscale(100%); - -ms-filter: grayscale(100%); - -o-filter: grayscale(100%); - filter: grayscale(100%); - filter: gray; -} - -/*九宫样式*/ -.wrapper { - display: grid; - grid-template-columns: 51px 51px 51px; - grid-template-rows: 51px 51px 51px; - margin-left: 10px; -} - -.list { - background: #eee; - margin-right: 1px; - margin-bottom: 1px; -} - - .list img { - width: 50px; - height: 50px; - } - -/********其他*******/ -.mounthImg { - width: 120px; - height: 120px; -} - -/***广播***/ -.broad { - font-size: 15px; -} - -.broad-gift { - background-image: url('/images/site/broad/gift.gif'); - background-repeat: no-repeat; - display: inline-block; - width: 18px; - height: 18px; - background-size: 18px; /*设置图片大小*/ +.common img { margin-right: 2px; vertical-align: middle; - border: 0; -} - -.broad-system { - background-image: url('/images/site/broad/system.gif'); - background-repeat: no-repeat; - display: inline-block; - width: 18px; - height: 18px; - background-size: 18px; /*设置图片大小*/ - margin-right: 2px; - vertical-align: middle; -} - -.broad-award { - background-image: url('/images/site/broad/award.gif'); - background-repeat: no-repeat; - display: inline-block; - width: 18px; - height: 18px; - background-size: 18px; /*设置图片大小*/ - margin-right: 2px; - vertical-align: middle; -} - -.broad-remind { - background-image: url('/images/site/broad/remind.gif'); - background-repeat: no-repeat; - display: inline-block; - width: 18px; - height: 18px; - background-size: 18px; /*设置图片大小*/ - margin-right: 2px; - vertical-align: middle; -} - -.broad-promote { - background-image: url('/images/site/broad/promote.gif'); - background-repeat: no-repeat; - display: inline-block; - width: 18px; - height: 18px; - background-size: 18px; /*设置图片大小*/ - margin-right: 2px; - vertical-align: middle; -} -.broad-hot1 { - background-image: url('/images/site/broad/hot1.gif'); - background-repeat: no-repeat; - display: inline-block; - width: 18px; - height: 18px; - background-size: 18px; /*设置图片大小*/ - margin-right: 2px; - vertical-align: middle; -} -/****礼物***/ -.gift { - width: 20px; - height: 20px; -} - -.attire { - height: 200px; - width: 125px; -} - -/****限时活动****/ -.act_item { - margin-bottom: 10px; - border: 1px solid #9f8d8d; - border-radius: 16px; - padding: 5px; -} - -.act_menu a { - font-size: 14px; - font-weight: bold; -} - -.act_content { - font-size: 14px; -} - -.act_header { - text-align: center; -} - -.m_act_head { - text-align: center; -} - -.m_act_head { - text-align: center; -} - -.m_act_item { - border-bottom: 1px dashed #9f8d8d; -} - -.m_act_title { - font-weight: bold; - font-size: 16px; -} - -.m_act_con { - font-size: 15px; - padding: 3px; - text-indent: 2em; -} - - .m_act_con a { - font-size: 15px; - } - - .badge { - max-height: 25px; - max-width: 25px; -} - -.maxname { - max-height: 150px; - max-width: 250px; -} - -/* ========== 自定义通知队列 ========== */ -#custom-notify-container { - position: fixed; - top: 10px; - left: 50%; - transform: translateX(-50%); - z-index: 9999; - display: flex; - flex-direction: column; - align-items: center; - width: 100%; - pointer-events: none; -} - -.custom-notify-item { - box-sizing: border-box; - max-width: 90%; - padding: 8px 16px; - margin-bottom: 8px; - border-radius: 8px; - color: #fff; - font-size: 12px; - line-height: 1.5; - text-align: center; - word-wrap: break-word; - box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); - pointer-events: auto; - cursor: pointer; - opacity: 0; - transform: translateY(-20px); - animation: notify-slide-in 300ms ease-out forwards; -} - -.custom-notify-item.leaving { - animation: notify-fade-out 200ms ease-in forwards; -} - -@keyframes notify-slide-in { - to { - opacity: 1; - transform: translateY(0); - } -} - -@keyframes notify-fade-out { - to { - opacity: 0; - transform: translateY(-10px); - } -} - -/* ========== 顶部通告栏 ========== */ -.custom-notice-bar { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 40px; - display: flex; - align-items: center; - padding: 0 16px; - box-sizing: border-box; - z-index: 9998; - font-size: 14px; - line-height: 24px; -} - -.custom-notice-bar .notice-icon { - flex-shrink: 0; - margin-right: 8px; - font-size: 16px; - position: relative; - z-index: 1; -} - -.custom-notice-bar .notice-wrap { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - overflow: hidden; - display: flex; - align-items: center; - padding: 0 40px; - box-sizing: border-box; -} - -.custom-notice-bar .notice-text { - display: inline-block; - white-space: nowrap; - padding-right: 50px; - flex-shrink: 0; -} - -.custom-notice-bar .notice-wrap.scrolling { - animation: notice-scroll var(--scroll-duration, 10s) linear infinite; -} - -@keyframes notice-scroll { - 0% { - transform: translateX(0); - } - 100% { - transform: translateX(-50%); - } -} - -.custom-notice-bar .notice-close { - flex-shrink: 0; - margin-left: 8px; - font-size: 18px; - cursor: pointer; - width: 24px; - height: 24px; - display: flex; - align-items: center; - justify-content: center; - line-height: 1; - position: relative; - z-index: 1; } \ No newline at end of file diff --git a/Web/src/composables/ApiService.ts b/Web/src/composables/ApiService.ts index 2ec7cb5..caa7fab 100644 --- a/Web/src/composables/ApiService.ts +++ b/Web/src/composables/ApiService.ts @@ -64,25 +64,37 @@ export class ApiService { } const result = response.data; if (result.code === 401) { + //401刷新token + console.log(result.data); } else if (result.code === 40101) { this.redirectToLogin(); throw { handled: true, - redirectTo: "/login/login", + redirectTo: "/",//跳转回首页 message: result.msg || "登录已失效" } satisfies HandledRedirectError; } else if (result.code === 500) { // 跳转错误页面 + throw { + handled: true, + redirectTo: "/",//跳转回首页 + message: result.msg || "登录已失效" + } satisfies HandledRedirectError; } else if (result.code === 404) { // 跳转不存在页面 + throw { + handled: true, + redirectTo: "/",//跳转回首页 + message: result.msg || "登录已失效" + } satisfies HandledRedirectError; } return response; }, onRejected: (error) => { if (error && typeof error === "object" && "status" in error) { - // console.log("接口错误:", error); + // console.log("接口错误:", error); } return error; diff --git a/Web/src/composables/StateHelper.ts b/Web/src/composables/StateHelper.ts index 442a8e6..96a5265 100644 --- a/Web/src/composables/StateHelper.ts +++ b/Web/src/composables/StateHelper.ts @@ -25,5 +25,12 @@ export class StateHelper { { this.userStore.offOnline(); } + static get IsAccLogin(){ + return this.userStore.isLoginAccount; + } + + static get IsLogin(){ + return this.userStore.isLogin; + } } \ No newline at end of file diff --git a/Web/src/pages/customer/index.vue b/Web/src/pages/customer/index.vue index 4c7995c..86e1add 100644 --- a/Web/src/pages/customer/index.vue +++ b/Web/src/pages/customer/index.vue @@ -4,42 +4,21 @@ 首页>客服
- 微信客服:点击咨询
客服QQ:531493955
官方QQ群:238938639
客服邮箱:531493955@qq.com
+ 微信客服:点击咨询
+ 客服QQ:290555931
+ 官方QQ群:931835791
+ 客服邮箱:tanwan@kexunkeji.cn
返回游戏首页 - - -
- -