111
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIRedisCache_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F55e5569a0f314a0db6a665eafad446dd6800_003F9e_003F88bbb06d_003FIRedisCache_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIRedisCache_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F55e5569a0f314a0db6a665eafad446dd6800_003F9e_003F88bbb06d_003FIRedisCache_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></wpf:ResourceDictionary>
|
<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_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></wpf:ResourceDictionary>
|
||||||
@@ -5,6 +5,9 @@ public interface IUnitUserService
|
|||||||
#region 用户信息
|
#region 用户信息
|
||||||
|
|
||||||
Task<List<unit_user>> GetUserDataByAccId(string accId);
|
Task<List<unit_user>> GetUserDataByAccId(string accId);
|
||||||
|
Task<unit_user> GetUserInfoByUserId(string userId);
|
||||||
|
Task<unit_user> GetUserInfoByUserNo(string userNo);
|
||||||
|
Task<unit_user> GetUserInfoByToken(string token);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -18,5 +21,7 @@ public interface IUnitUserService
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<unit_user> Register(int areaId, string accId);
|
Task<unit_user> Register(int areaId, string accId);
|
||||||
|
|
||||||
|
Task<bool> RegisterUserInfo(string userId, string nick, string sex);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,22 @@ public class UnitUserService : IUnitUserService, ITransient
|
|||||||
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();
|
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);
|
||||||
|
if (data == null)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
public async Task<unit_user> GetUserInfoByUserNo(string userNo)
|
public async Task<unit_user> GetUserInfoByUserNo(string userNo)
|
||||||
{
|
{
|
||||||
string key = string.Format(UserCache.BaseCacheKeys, "UserInfo", "UserNo");
|
string key = string.Format(UserCache.BaseCacheKeys, "UserInfo", "UserNo");
|
||||||
@@ -36,9 +52,9 @@ public class UnitUserService : IUnitUserService, ITransient
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<unit_user> GetUserInfoBySid(string token)
|
public async Task<unit_user> GetUserInfoByToken(string token)
|
||||||
{
|
{
|
||||||
string key = string.Format(UserCache.BaseCacheKeys, "UserInfo", "Sid");
|
string key = string.Format(UserCache.BaseCacheKeys, "UserInfo", "token");
|
||||||
var data = await _redisClient.GetHashAsync<unit_user>(key, token);
|
var data = await _redisClient.GetHashAsync<unit_user>(key, token);
|
||||||
if (data == null)
|
if (data == null)
|
||||||
{
|
{
|
||||||
@@ -52,6 +68,23 @@ public class UnitUserService : IUnitUserService, ITransient
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
private async Task ClearUserInfo(int type, string id)
|
||||||
|
{
|
||||||
|
unit_user result = new unit_user();
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
result = await GetUserInfoByUserId(id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
result = await GetUserInfoByToken(id);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -98,8 +131,27 @@ public class UnitUserService : IUnitUserService, ITransient
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public async Task<bool> RegisterUserInfo(string userId, string nick, string sex)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//注册配置信息
|
||||||
|
|
||||||
public async Task<int> GetUserNo()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
await ClearUserInfo(0, userId);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
private async Task<int> GetUserNo()
|
||||||
{
|
{
|
||||||
int No = 0;
|
int No = 0;
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
@@ -117,18 +169,18 @@ public class UnitUserService : IUnitUserService, ITransient
|
|||||||
|
|
||||||
private async Task<string> GetToken()
|
private async Task<string> GetToken()
|
||||||
{
|
{
|
||||||
string sid = string.Empty;
|
string token = string.Empty;
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
while (ok)
|
while (ok)
|
||||||
{
|
{
|
||||||
sid = StringAssist.RandomString(32);
|
token = StringAssist.RandomString(32);
|
||||||
if (await GetUserInfoBySid(sid) == null)
|
if (await GetUserInfoByToken(token) == null)
|
||||||
{
|
{
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sid;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -138,6 +138,11 @@ namespace Application.Web.Controllers.Login
|
|||||||
return PoAction.Message("未登录账号!");
|
return PoAction.Message("未登录账号!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (accInfo.status != 1)
|
||||||
|
{
|
||||||
|
return PoAction.Message("账号已冻结!");
|
||||||
|
}
|
||||||
|
|
||||||
var areaInfo = await _areaService.GetAreaInfo(area);
|
var areaInfo = await _areaService.GetAreaInfo(area);
|
||||||
if (areaInfo == null)
|
if (areaInfo == null)
|
||||||
{
|
{
|
||||||
@@ -172,5 +177,94 @@ namespace Application.Web.Controllers.Login
|
|||||||
string token = JwtHelper.CreateToken(Key, Issuer, Audience, loadData, 300);
|
string token = JwtHelper.CreateToken(Key, Issuer, Audience, loadData, 300);
|
||||||
return PoAction.Ok(new { token = token, refToken = userInfo.token, userId = userInfo.userId });
|
return PoAction.Ok(new { token = token, refToken = userInfo.token, userId = userInfo.userId });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登录到游戏
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sid"></param>
|
||||||
|
/// <param name="user"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IPoAction> LoginGame(string sid, string user)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(sid))
|
||||||
|
{
|
||||||
|
return PoAction.Message("未登录账号!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var accInfo = await _accountService.GetAccInfoByToken(sid);
|
||||||
|
if (accInfo == null)
|
||||||
|
{
|
||||||
|
return PoAction.Message("未登录账号!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accInfo.status != 1)
|
||||||
|
{
|
||||||
|
return PoAction.Message("账号已冻结!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var userInfo = await _userService.GetUserInfoByUserId(user);
|
||||||
|
if (userInfo == null)
|
||||||
|
{
|
||||||
|
return PoAction.Message("角色不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userInfo.accId != accInfo.accId)
|
||||||
|
{
|
||||||
|
return PoAction.Message("角色不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userInfo.status == 0)
|
||||||
|
{
|
||||||
|
return PoAction.Message("角色已封禁!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, object> loadData = new Dictionary<string, object>();
|
||||||
|
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, 1);
|
||||||
|
return PoAction.Ok(new
|
||||||
|
{ regOk = userInfo.regOk, token = token, refToken = userInfo.token, userId = userInfo.userId });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 注册角色信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parms"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Authorize]
|
||||||
|
public async Task<IPoAction> RegisterInfo([FromBody] RegisterInfoParms parms)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(parms.nick))
|
||||||
|
{
|
||||||
|
return PoAction.Message("昵称不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RegExpAssist.RegStringLeght(parms.nick, 1, 12))
|
||||||
|
{
|
||||||
|
return PoAction.Message("昵称需要1-12字符之间哦!");
|
||||||
|
}
|
||||||
|
string sex = parms.sex == 0 ? "女" : "男";
|
||||||
|
string userId = StateHelper.userId;
|
||||||
|
var userInfo = await _userService.GetUserInfoByUserId(userId);
|
||||||
|
if (userInfo.regOk == 1)
|
||||||
|
{
|
||||||
|
return PoAction.Ok(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await _userService.RegisterUserInfo(userId, parms.nick, sex))
|
||||||
|
{
|
||||||
|
return PoAction.Ok(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message("注册失败,请稍后尝试!");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,5 +86,26 @@ namespace Application.Web.Controllers.Pub
|
|||||||
data.sign = data.sign.Replace("[Br]", "<br />");
|
data.sign = data.sign.Replace("[Br]", "<br />");
|
||||||
return PoAction.Ok(data);
|
return PoAction.Ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取用户游戏角色
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sid"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IPoAction> GetMyGame(string? sid)
|
||||||
|
{
|
||||||
|
List<unit_user> userData = new List<unit_user>();
|
||||||
|
if (!string.IsNullOrEmpty(sid))
|
||||||
|
{
|
||||||
|
var account = await _accountService.GetAccInfoByToken(sid);
|
||||||
|
if (account != null)
|
||||||
|
{
|
||||||
|
userData = await _userService.GetUserDataByAccId(account.accId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PoAction.Ok(userData);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Application.Web;
|
||||||
|
|
||||||
|
public class RegisterInfoParms
|
||||||
|
{
|
||||||
|
public string nick { get; set; } = string.Empty;
|
||||||
|
public int sex { get; set; }
|
||||||
|
}
|
||||||
@@ -97,3 +97,59 @@ a:focus {
|
|||||||
margin-right: 2px;
|
margin-right: 2px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
}
|
||||||
@@ -12,6 +12,9 @@ export type HandledRedirectError = {
|
|||||||
export class ApiService {
|
export class ApiService {
|
||||||
private static initialized = false;
|
private static initialized = false;
|
||||||
|
|
||||||
|
private static get userStore() {
|
||||||
|
return useUserStore()
|
||||||
|
}
|
||||||
private static request = new RequestExtend({
|
private static request = new RequestExtend({
|
||||||
baseURL: BaseConfig.BaseUrl,
|
baseURL: BaseConfig.BaseUrl,
|
||||||
timeout: 60000
|
timeout: 60000
|
||||||
@@ -43,7 +46,7 @@ export class ApiService {
|
|||||||
|
|
||||||
RequestExtend.addRequestInterceptor({
|
RequestExtend.addRequestInterceptor({
|
||||||
onFulfilled: (config) => {
|
onFulfilled: (config) => {
|
||||||
const token = typeof localStorage !== "undefined" ? localStorage.getItem("token") : "";
|
const token = this.userStore.token;
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
config.headers = {
|
config.headers = {
|
||||||
|
|||||||
@@ -11,6 +11,19 @@ export class MessageExtend {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LoadingToast(message?: string) {
|
||||||
|
showLoadingToast({
|
||||||
|
message: message || '加载中',
|
||||||
|
forbidClick: true,
|
||||||
|
loadingType: 'spinner',
|
||||||
|
duration: 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static LoadingClose() {
|
||||||
|
closeToast();
|
||||||
|
}
|
||||||
|
|
||||||
// 提示弹窗
|
// 提示弹窗
|
||||||
static ShowDialog(title: string, message: string) {
|
static ShowDialog(title: string, message: string) {
|
||||||
showDialog({ title: title, message: message })
|
showDialog({ title: title, message: message })
|
||||||
|
|||||||
@@ -1 +1,64 @@
|
|||||||
<template></template>
|
<template>
|
||||||
|
|
||||||
|
<div class="common">
|
||||||
|
<div class="title">
|
||||||
|
=====☆我的区服☆=====
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<div class="item" v-for="(item, index) in userData" :key="index">
|
||||||
|
✧<a @click="loginGame(item.userId)">【{{ item.areaId }}区】{{ item.nick }}({{ (item.sex == null || item.sex == '') ?
|
||||||
|
"未知" : item.sex }})</a>
|
||||||
|
</div>
|
||||||
|
<span v-if="userData.length == 0">暂无角色.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Abar href="/">返回游戏首页</Abar>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
definePageMeta({
|
||||||
|
layout: layout.empty,
|
||||||
|
middleware: 'page-loading'
|
||||||
|
})
|
||||||
|
let userData = ref<Array<any>>([]);
|
||||||
|
|
||||||
|
const BindData = async (): Promise<void> => {
|
||||||
|
var result = await PubService.GetMyGame(StateHelper.Sid);
|
||||||
|
if (result.code == 0) {
|
||||||
|
userData.value = result.data;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageExtend.ShowDialogEvent("提示", result.msg, () => {
|
||||||
|
PageExtend.Redirect("/");
|
||||||
|
}, "我知道了");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const loginGame = async (gameId: string): Promise<void> => {
|
||||||
|
let result = await LoginService.LoginGame(StateHelper.Sid, gameId);
|
||||||
|
if (result.code == 0) {
|
||||||
|
StateHelper.SetToken(result.data.userId, result.data.token, result.data.refToken);
|
||||||
|
if (result.data.regOk == 0) {
|
||||||
|
PageExtend.Redirect("/login/register");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PageExtend.Redirect("/map");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageExtend.ShowDialog("登录游戏", result.msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
|
await BindData();
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
PageLoading.Close();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -31,7 +31,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="item" v-for="(item, index) in userData" :key="index">
|
<div class="item" v-for="(item, index) in userData" :key="index">
|
||||||
<a @click="loginGame(item.userId)">【{{ item.areaId }}区】{{ item.nick }}({{ (item.sex == null||item.sex=='') ? "未知" : item.sex }})</a>
|
<a @click="loginGame(item.userId)">【{{ item.areaId }}区】{{ item.nick }}({{ (item.sex == null || item.sex == '') ?
|
||||||
|
"未知" : item.sex }})</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -126,7 +127,6 @@ const Initialize = async (): Promise<void> => {
|
|||||||
/**自动登录 */
|
/**自动登录 */
|
||||||
const login = async (code: string): Promise<void> => {
|
const login = async (code: string): Promise<void> => {
|
||||||
let result = await LoginService.TwLogin(code);
|
let result = await LoginService.TwLogin(code);
|
||||||
console.log(result);
|
|
||||||
if (result.code == 0) {
|
if (result.code == 0) {
|
||||||
StateHelper.SetSid(result.data.token);
|
StateHelper.SetSid(result.data.token);
|
||||||
await Initialize();
|
await Initialize();
|
||||||
@@ -142,7 +142,7 @@ const offOnline = async () => {
|
|||||||
let result = await PubService.GetMain(StateHelper.Sid);
|
let result = await PubService.GetMain(StateHelper.Sid);
|
||||||
if (result.code == 0) {
|
if (result.code == 0) {
|
||||||
StateHelper.OffOnline();
|
StateHelper.OffOnline();
|
||||||
isOnline.value = false;
|
await Initialize();
|
||||||
MessageExtend.ShowToast("退出成功!", "success");
|
MessageExtend.ShowToast("退出成功!", "success");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -153,7 +153,19 @@ const offOnline = async () => {
|
|||||||
|
|
||||||
/**登录到游戏 */
|
/**登录到游戏 */
|
||||||
const loginGame = async (gameId: string): Promise<void> => {
|
const loginGame = async (gameId: string): Promise<void> => {
|
||||||
alert(gameId)
|
let result = await LoginService.LoginGame(StateHelper.Sid, gameId);
|
||||||
|
if (result.code == 0) {
|
||||||
|
StateHelper.SetToken(result.data.userId, result.data.token, result.data.refToken);
|
||||||
|
if (result.data.regOk == 0) {
|
||||||
|
PageExtend.Redirect("/login/register");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PageExtend.Redirect("/map");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageExtend.ShowDialog("注册角色", result.msg);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**注册游戏 */
|
/**注册游戏 */
|
||||||
|
|||||||
@@ -1 +1,58 @@
|
|||||||
<template></template>
|
<template>
|
||||||
|
<div class="content">
|
||||||
|
<img src="/images/logo.png" class="logo" />
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<div class="common">
|
||||||
|
<div class="input">
|
||||||
|
昵称:<input name="nick" placeholder="输入昵称(1-12个长度字符)" maxlength="12" class="ipt" type="text"
|
||||||
|
v-model="nick" />
|
||||||
|
</div>
|
||||||
|
<div class="input">
|
||||||
|
性别:<select name="sex" class="ipt" v-model="sex">
|
||||||
|
<option value="0">女</option>
|
||||||
|
<option value="1">男</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="input">
|
||||||
|
<input type="button"" class=" btn btn-danger" value="注册角色" @click="SubRegInfo" />.
|
||||||
|
<Abar href="/">返回首页</Abar>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
definePageMeta({
|
||||||
|
layout: layout.empty,
|
||||||
|
middleware: middleware.loading
|
||||||
|
})
|
||||||
|
|
||||||
|
const nick = ref('');
|
||||||
|
const sex = ref(0);
|
||||||
|
|
||||||
|
const SubRegInfo = async (): Promise<void> => {
|
||||||
|
if (nick.value == null || nick.value == '') {
|
||||||
|
MessageExtend.ShowToast("昵称不能为空!", "default");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MessageExtend.LoadingToast("注册中...");
|
||||||
|
let result = await LoginService.RegisterInfo(nick.value, sex.value);
|
||||||
|
MessageExtend.LoadingClose();
|
||||||
|
if (result.code == 0) {
|
||||||
|
PageExtend.Redirect("/map");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageExtend.ShowDialog("注册角色", result.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
|
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
PageLoading.Close();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -22,4 +22,12 @@ export class PubService {
|
|||||||
static async GetNoticeInfo(id: string) {
|
static async GetNoticeInfo(id: string) {
|
||||||
return await ApiService.Request("get", "/Pub/GetNoticeInfo", { id });
|
return await ApiService.Request("get", "/Pub/GetNoticeInfo", { id });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户游戏角色
|
||||||
|
* GET /Pub/GetMyGame
|
||||||
|
*/
|
||||||
|
static async GetMyGame(sid: string) {
|
||||||
|
return await ApiService.Request("get", "/Pub/GetMyGame", { sid });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -29,9 +29,27 @@ export class LoginService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册基础账号信息
|
* 注册基础账号信息
|
||||||
* GET /Login/Regist
|
* GET /Login/Register
|
||||||
*/
|
*/
|
||||||
static async Register(sid: string, area: number) {
|
static async Register(sid: string, area: number) {
|
||||||
return await ApiService.Request("get", "/Login/Register", { sid, area });
|
return await ApiService.Request("get", "/Login/Register", { sid, area });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录到游戏
|
||||||
|
* GET /Login/LoginGame
|
||||||
|
*/
|
||||||
|
static async LoginGame(sid: string, user: string) {
|
||||||
|
return await ApiService.Request("get", "/Login/LoginGame", { sid, user });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册角色信息
|
||||||
|
* POST /Login/RegisterInfo
|
||||||
|
* @param nick body
|
||||||
|
* @param sex body
|
||||||
|
*/
|
||||||
|
static async RegisterInfo(nick: string, sex: number) {
|
||||||
|
return await ApiService.Request("post", "/Login/RegisterInfo", { nick, sex });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user