Compare commits
3 Commits
f3beb80ce4
...
eb196a25be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb196a25be | ||
|
|
a219fbec32 | ||
|
|
c55a104573 |
3
Kx.SeaTime.sln.DotSettings.user
Normal file
3
Kx.SeaTime.sln.DotSettings.user
Normal file
@@ -0,0 +1,3 @@
|
||||
<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_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>
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace Application.Domain.Entity
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace Application.Domain.Entity
|
||||
{
|
||||
[Tenant("Kg.SeaTime.Resource")]
|
||||
public class game_area
|
||||
{
|
||||
/// <summary>
|
||||
/// areaId
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public int areaId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// name
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 255, IsNullable = true)]
|
||||
public string? name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int? status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 开放时间
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public DateTime? opTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 添加时间
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public DateTime? addTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace Application.Domain.Entity
|
||||
{
|
||||
[Tenant("Kg.SeaTime.Resource")]
|
||||
public class game_notice
|
||||
{
|
||||
/// <summary>
|
||||
/// noticeId
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, Length = 50)]
|
||||
public string noticeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// title
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50, IsNullable = true)]
|
||||
public string? title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// sign
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public string? sign { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// addTime
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public DateTime? addTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// endTime
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public DateTime? endTime { get; set; }
|
||||
}
|
||||
}
|
||||
7
Service/Application.Domain/Cache/BaseCache.cs
Normal file
7
Service/Application.Domain/Cache/BaseCache.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public class BaseCache
|
||||
{
|
||||
public static string BaseCacheKey = "BaseGameCache:{0}";
|
||||
public static string BaseCacheKeys = "BaseGameCache:{0}:{1}";
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace Application.Domain
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
4
Service/Application.Domain/GlobalUsings.cs
Normal file
4
Service/Application.Domain/GlobalUsings.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
global using Photon.Core;
|
||||
global using SqlSugar;
|
||||
global using Application.Domain.Entity;
|
||||
global using Photon.Core.Redis;
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public interface IAreaService
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取所有区服
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<game_area>> GetAreaData();
|
||||
/// <summary>
|
||||
/// 获取区服信息
|
||||
/// </summary>
|
||||
/// <param name="areaId"></param>
|
||||
/// <returns></returns>
|
||||
Task<game_area> GetAreaInfo(int areaId);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public interface INoticeService
|
||||
{
|
||||
Task<List<game_notice>> GetNoticeDataByTake(int take);
|
||||
Task<List<game_notice>> GetNoticeData(int page, int limit, RefAsync<int> total);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public class AreaService : IAreaService, ITransient
|
||||
{
|
||||
private readonly ISqlSugarClient _dbClient;
|
||||
private readonly IRedisCache _redisClient;
|
||||
|
||||
public AreaService(ISqlSugarClient dbClient, IRedisCache redisClient)
|
||||
{
|
||||
_dbClient = dbClient;
|
||||
_redisClient = redisClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有区服
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<game_area>> GetAreaData()
|
||||
{
|
||||
string key = string.Format(BaseCache.BaseCacheKey, "AreaData");
|
||||
if (await _redisClient.ExistsAsync(key))
|
||||
{
|
||||
return await _redisClient.GetAsync<List<game_area>>(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_area>();
|
||||
var data = await db.Queryable<game_area>().ToListAsync();
|
||||
await _redisClient.SetAsync(key, data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<game_area> GetAreaInfo(int areaId)
|
||||
{
|
||||
string key = string.Format(BaseCache.BaseCacheKeys, "AreaData", areaId);
|
||||
if (await _redisClient.ExistsAsync(key))
|
||||
{
|
||||
return await _redisClient.GetAsync<game_area>(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_area>();
|
||||
var data = await db.Queryable<game_area>().Where(it => it.areaId == areaId).SingleAsync();
|
||||
await _redisClient.SetAsync(key, data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ClearAreaCache(int areaId = 0)
|
||||
{
|
||||
string key = string.Format(BaseCache.BaseCacheKey, "AreaData");
|
||||
await _redisClient.DelAsync(key);
|
||||
if (areaId != 0)
|
||||
{
|
||||
key = string.Format(BaseCache.BaseCacheKeys, "AreaData", areaId);
|
||||
await _redisClient.DelAsync(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public class NoticeService:INoticeService,ITransient
|
||||
{
|
||||
private readonly ISqlSugarClient _dbClient;
|
||||
private readonly IRedisCache _redisClient;
|
||||
|
||||
public NoticeService(ISqlSugarClient dbClient, IRedisCache redisClient)
|
||||
{
|
||||
_dbClient = dbClient;
|
||||
_redisClient = redisClient;
|
||||
}
|
||||
|
||||
public async Task<List<game_notice>> GetNoticeDataByTake(int take)
|
||||
{
|
||||
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_notice>();
|
||||
return await db.Queryable<game_notice>().Take(take).OrderByDescending(it=>it.addTime).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<game_notice>> GetNoticeData(int page, int limit, RefAsync<int> total)
|
||||
{
|
||||
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_notice>();
|
||||
return await db.Queryable<game_notice>().ToPageListAsync(page, limit, total);
|
||||
}
|
||||
}
|
||||
@@ -15,4 +15,10 @@
|
||||
<Folder Include="wwwroot\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="applicationsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -2,6 +2,15 @@
|
||||
{
|
||||
public class StateHelper
|
||||
{
|
||||
public static bool isOnline
|
||||
{
|
||||
get
|
||||
{
|
||||
var token = App.HttpContext.GetTokenInfo();
|
||||
return token != null;
|
||||
}
|
||||
}
|
||||
|
||||
public static string userId
|
||||
{
|
||||
get {
|
||||
@@ -14,7 +23,7 @@
|
||||
get
|
||||
{
|
||||
var token = App.HttpContext.GetTokenInfo();
|
||||
return token.Claims["sid"];
|
||||
return token.Claims["token"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Application.Web.Controllers.Login
|
||||
[HttpPost]
|
||||
public async Task<IPoAction> Login([FromBody] LoginParms parms)
|
||||
{
|
||||
HttpContext.Request.QueryString
|
||||
return PoAction.Ok(parms.code);
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
31
Service/Application.Web/Controllers/Pub/PubController.cs
Normal file
31
Service/Application.Web/Controllers/Pub/PubController.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Application.Web.Controllers.Pub
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 公共接口
|
||||
/// </summary>
|
||||
[Route("[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class PubController : ControllerBase
|
||||
{
|
||||
private readonly IAreaService _areaService;
|
||||
public PubController(IAreaService areaService)
|
||||
{
|
||||
_areaService = areaService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取首页信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetMain()
|
||||
{
|
||||
var areaData = await _areaService.GetAreaData();
|
||||
return PoAction.Ok(new{area=areaData});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Photon.Core.Redis;
|
||||
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -9,7 +10,7 @@ builder.Services.Inject(new List<string> {
|
||||
});//框架初始化
|
||||
|
||||
builder.Configuration.RegisterConfig();//注入配置
|
||||
builder.Services.InjectMemory();
|
||||
builder.Services.InjectRedis(builder.Configuration);
|
||||
builder.Services.InjectSql(builder.Configuration);
|
||||
|
||||
#region JWT与接口配置
|
||||
|
||||
@@ -1,19 +1,29 @@
|
||||
{
|
||||
"AutoProgram": 0,
|
||||
"Redis": {
|
||||
"connection": "127.0.0.1,password=,defaultdatabase=1"
|
||||
"connection": "127.0.0.1:6379,password=,defaultdatabase=5"
|
||||
},
|
||||
"SqlData": [
|
||||
{
|
||||
"type": 0,
|
||||
"name": "KgDb",
|
||||
"connect": "data source=kx.iyba.cn;database=kx.petera;user id=root;password=1f5ozxRGE3Y;pooling=true;port=23306;sslmode=Required;charset=utf8mb4;"
|
||||
"name": "Kg.SeaTime.Game",
|
||||
"connect": "data source=192.168.0.88;database=kg.seatime.game;user id=root;password=1f5ozxRGE3Y;pooling=true;port=3306;sslmode=Required;charset=utf8mb4;"
|
||||
},
|
||||
{
|
||||
"type": 0,
|
||||
"name": "Kg.SeaTime.Resource",
|
||||
"connect": "data source=192.168.0.88;database=kg.seatime.resource;user id=root;password=1f5ozxRGE3Y;pooling=true;port=3306;sslmode=Required;charset=utf8mb4;"
|
||||
},
|
||||
{
|
||||
"type": 0,
|
||||
"name": "Kg.SeaTime.Log",
|
||||
"connect": "data source=192.168.0.88;database=kg.seatime.log;user id=root;password=1f5ozxRGE3Y;pooling=true;port=3306;sslmode=Required;charset=utf8mb4;"
|
||||
}
|
||||
],
|
||||
"JwtTokenOptions": {
|
||||
"Issuer": "kx.petera",
|
||||
"Audience": "kx.petera",
|
||||
"SecurityKey": "DAbdA9fF9MYXDCFBEb75WKWWDAbDBWQi"
|
||||
"Issuer": "kx.seatime",
|
||||
"Audience": "kx.seatime",
|
||||
"SecurityKey": "46055HR0n7FeNHhDKAYD2i9ZsdsYn4jn"
|
||||
},
|
||||
"ResUrl": {
|
||||
"local": "http://192.168.0.142:5298",
|
||||
|
||||
@@ -75,7 +75,7 @@ div {
|
||||
.foot {
|
||||
}
|
||||
|
||||
a {
|
||||
body a {
|
||||
color: #1e5494;
|
||||
margin: 0 5px;
|
||||
text-decoration: underline;
|
||||
|
||||
@@ -92,7 +92,7 @@ export class ApiService {
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
public static async Request<T = unknown>(
|
||||
public static async Request<T = any>(
|
||||
method: HttpMethod,
|
||||
url: string,
|
||||
params: RequestParams = {}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
export class PageExtend {
|
||||
public static Redirect(route: string) {
|
||||
navigateTo(route, { replace: true })
|
||||
public static Redirect(route: string) {
|
||||
navigateTo(route, { replace: true })
|
||||
}
|
||||
|
||||
public static QueryString(params: string): string {
|
||||
const route = useRoute()
|
||||
const value = route.query[params]
|
||||
return value ? String(value) : ''
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
export interface IResultData<T = unknown> {
|
||||
export interface IResultData<T = any> {
|
||||
code: number
|
||||
msg: string
|
||||
data?: T
|
||||
|
||||
@@ -87,22 +87,44 @@
|
||||
小G报时(18:33)
|
||||
</div>
|
||||
</div>
|
||||
<div v-for="(item, index) in areaData" :key="index">
|
||||
{{ index }} - {{ item.name }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
|
||||
|
||||
//MessageExtend.ShowToast('success', '更新成功!')
|
||||
//MessageExtend.ShowToast('success', '更新成功!')
|
||||
//MessageExtend.NotifyList("success", ['获取装备',"获取物品"])
|
||||
definePageMeta({
|
||||
layout: layout.empty
|
||||
})
|
||||
|
||||
const areaData = ref<any>([]);
|
||||
|
||||
|
||||
|
||||
const Initialize = async (): Promise<void> => {
|
||||
var result = await PubService.GetMain();
|
||||
if (result.code == 0) {
|
||||
areaData.value = result.data?.area;
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowToast("fail", result.msg);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// await navigateTo('/auth/login', { replace: true })
|
||||
onMounted(async () => {
|
||||
|
||||
const test = await LoginService.Test("dddd","dddd2");
|
||||
console.log(test);
|
||||
const id = PageExtend.QueryString("id");
|
||||
|
||||
MessageExtend.Notify("success", id);
|
||||
|
||||
await Initialize();
|
||||
|
||||
//alert(1);
|
||||
})
|
||||
|
||||
9
Web/src/services/Index/PubService.ts
Normal file
9
Web/src/services/Index/PubService.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export class PubService {
|
||||
/**
|
||||
* 获取首页信息
|
||||
* GET /Pub/GetMain
|
||||
*/
|
||||
static async GetMain() {
|
||||
return await ApiService.Request("get", "/Pub/GetMain");
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
export class LoginService {
|
||||
/**
|
||||
* 登录接口
|
||||
* POST /Login/Login
|
||||
* 请求体: 登录请求参数
|
||||
* @param name 登录名/手机号
|
||||
* @param pwd 密码
|
||||
* @param code 验证码
|
||||
*/
|
||||
static async Login(name: string, pwd: string, code: string) {
|
||||
return ApiService.Request("post", "/Login/Login", { name, pwd, code });
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试接口
|
||||
* GET /Login/Test
|
||||
* @param name 测试名
|
||||
* @param ttt 测试2
|
||||
*/
|
||||
static async Test(name: string, ttt: string) {
|
||||
return ApiService.Request("get", "/Login/Test", { name, ttt });
|
||||
}
|
||||
}
|
||||
@@ -3,72 +3,58 @@
|
||||
* 管理用户登录信息、Token等核心状态
|
||||
*/
|
||||
import { defineStore } from 'pinia'
|
||||
import type { IUserInfo } from '~/types/user'
|
||||
|
||||
// 仓库命名规范:use+业务域+Store
|
||||
export const useUserStore = defineStore('user', {
|
||||
// 1. 原始状态:仅存基础数据,不做任何计算、判断
|
||||
state: () => ({
|
||||
userInfo: null as IUserInfo | null,
|
||||
state: () => ({
|
||||
token: '',
|
||||
isLoading: false as boolean
|
||||
refToken:"",
|
||||
sid:""
|
||||
}),
|
||||
|
||||
// 2. 只读计算属性:封装派生逻辑,全局只读
|
||||
getters: {
|
||||
|
||||
//判断是否登录主页
|
||||
isLoginAccount: (state) => !!state.sid,
|
||||
// 判断是否登录
|
||||
isLogin: (state) => !!state.token,
|
||||
|
||||
// 获取用户ID
|
||||
userId: (state) => state.userInfo?.id ?? 0,
|
||||
//token
|
||||
getToken:(state)=>state.token??"",
|
||||
|
||||
// 格式化用户昵称
|
||||
userNickname: (state) => state.userInfo?.nickname || state.userInfo?.username || '未知用户',
|
||||
// 刷新token
|
||||
getRefToken: (state) => state.refToken??"",
|
||||
|
||||
// 获取用户头像
|
||||
userAvatar: (state) => state.userInfo?.avatar || '',
|
||||
|
||||
// 获取用户角色
|
||||
userRole: (state) => state.userInfo?.role || 'user'
|
||||
// 账号
|
||||
getSid: (state) => state.sid?? '',
|
||||
},
|
||||
|
||||
// 3. 唯一状态修改入口:所有状态变更必须走actions
|
||||
actions: {
|
||||
// 设置用户信息与Token
|
||||
setUserInfo(data: IUserInfo, token: string) {
|
||||
this.userInfo = data
|
||||
this.token = token
|
||||
this.isLoading = false
|
||||
setToken( token: string,refToken :string) {
|
||||
this.token = token,
|
||||
this.refToken = refToken
|
||||
},
|
||||
|
||||
// 仅更新Token
|
||||
setToken(token: string) {
|
||||
this.token = token
|
||||
setSid(sid: string) {
|
||||
this.sid = sid
|
||||
},
|
||||
|
||||
// 退出登录:清空用户状态
|
||||
clearUserInfo() {
|
||||
this.userInfo = null
|
||||
this.token = ''
|
||||
this.isLoading = false
|
||||
},
|
||||
|
||||
// 设置登录加载态
|
||||
setLoginLoading(loading: boolean) {
|
||||
this.isLoading = loading
|
||||
},
|
||||
|
||||
// 更新用户信息(部分更新)
|
||||
updateUserInfo(partialData: Partial<IUserInfo>) {
|
||||
if (this.userInfo) {
|
||||
this.userInfo = { ...this.userInfo, ...partialData }
|
||||
}
|
||||
this.token = '',
|
||||
this.refToken='',
|
||||
this.sid=''
|
||||
}
|
||||
},
|
||||
|
||||
// 4. 持久化配置:仅缓存核心状态(token + userInfo)
|
||||
persist: {
|
||||
storage: piniaPluginPersistedstate.localStorage(),
|
||||
pick: ['token', 'userInfo']
|
||||
pick: ['token','refToken', 'sid']
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user