This commit is contained in:
Ls
2026-04-28 18:01:15 +08:00
5 changed files with 36 additions and 30 deletions

View File

@@ -12,7 +12,8 @@ namespace Application.Web.Controllers.Pub
{ {
private readonly IAreaService _areaService; private readonly IAreaService _areaService;
private readonly INoticeService _noticeService; private readonly INoticeService _noticeService;
public PubController(IAreaService areaService,INoticeService noticeService)
public PubController(IAreaService areaService, INoticeService noticeService)
{ {
_areaService = areaService; _areaService = areaService;
_noticeService = noticeService; _noticeService = noticeService;
@@ -24,7 +25,7 @@ namespace Application.Web.Controllers.Pub
/// <param name="sid"></param> /// <param name="sid"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
public async Task<IPoAction> GetMain(string sid) public async Task<IPoAction> GetMain(string? sid)
{ {
bool isOnline = false; bool isOnline = false;
if (!string.IsNullOrEmpty(sid)) if (!string.IsNullOrEmpty(sid))
@@ -34,8 +35,9 @@ namespace Application.Web.Controllers.Pub
var areaData = await _areaService.GetAreaData(); var areaData = await _areaService.GetAreaData();
var notice = await _noticeService.GetNoticeDataByTake(5); var notice = await _noticeService.GetNoticeDataByTake(5);
int OnCount = 100; int OnCount = 100;
return PoAction.Ok(new { area = areaData ,notice,isOnline,onCount=OnCount}); return PoAction.Ok(new { area = areaData, notice, isOnline, onCount = OnCount });
} }
} }
} }

View File

@@ -21,4 +21,9 @@ export class StateHelper {
this.userStore.setSid(sid); this.userStore.setSid(sid);
} }
static OffOnline()
{
this.userStore.offOnline();
}
} }

View File

@@ -8,12 +8,12 @@ export class MessageExtend {
} }
// 提示弹窗 // 提示弹窗
static ShowDialog(message: string, title?: string) { static ShowDialog(title: string, message: string) {
showDialog({ title: title, message: message }) showDialog({ title: title, message: message })
} }
// 确认提示弹窗 // 确认提示弹窗
static Dialog(title: string, message: string, onConfirm?: () => void, onCancel?: () => void, confirmButtonText?: string) { static ShowConfirmDialog(title: string, message: string, onConfirm?: () => void, onCancel?: () => void, confirmButtonText?: string) {
showConfirmDialog({ showConfirmDialog({
title: title, title: title,
message: message, message: message,
@@ -58,7 +58,6 @@ export class MessageExtend {
} else if (type == 'fail') { } else if (type == 'fail') {
showFailToast(text) showFailToast(text)
} else { } else {
console.log(text)
showToast(text) showToast(text)
} }
} }

View File

@@ -1,34 +1,30 @@
<template> <template>
<div> <div>
<div class="head"> <div class="head">
<div> <img src="/images/logo.png" class="logo" />
<img src="/images/logo.png" class="logo" /> <br />
<br /> 驰骋四海
驰骋四海&#xB7;社区版
</div>
</div> </div>
<div> <div>
当前在线<strong> {{ OnCount }} </strong>位玩家在驰骋四海 当前在线<strong> {{ OnCount }} </strong>位玩家在驰骋四海
</div> </div>
<div class="content" style="font-size:17px"> <div class="content" style="font-size:17px" v-if="isOnline">
<div> <div>
亲爱的&nbsp;<strong style="color:red">探玩玩家</strong>欢迎来到驰骋四海&#xB7;社区版! 亲爱的&nbsp;<strong style="color:red">探玩玩家</strong>欢迎来到驰骋四海&#xB7;社区版!
</div> </div>
<div style="margin-top:5px;"> <div style="margin-top:5px;">
<div> <div>
<a href="http://m.twbar.cn/Home/Index?sid=KrWxKypJuDO0zFKrTig0bG">返回探玩驿站</a> <a href="http://m.twbar.cn/Home/Index?sid=KrWxKypJuDO0zFKrTig0bG">返回探玩驿站</a>
</div> </div>
<div> <div>
<a href="http://m.twbar.cn/b/1145?sid=KrWxKypJuDO0zFKrTig0bG">游戏论坛</a>&nbsp;&nbsp;<a class="" <a href="http://m.twbar.cn/b/1145?sid=KrWxKypJuDO0zFKrTig0bG">游戏论坛</a>&nbsp;&nbsp;
href="/Login/LoginOut?sid=klxy7ADn96CBYGWQ9AG4xPqFC2Ib6Ty1Kx">退出游戏</a> <a @click.stop="offOnline">退出游戏</a>
</div> </div>
</div> </div>
</div> </div>
<div class="content" v-else>
<a href="https://3g.fan/Login">立即进入游戏?</a>
</div>
<div class="common"> <div class="common">
<div class="title"> <div class="title">
=====<a class="" href="/Pallet/GameOpen/GameUser?sid=klxy7ADn96CBYGWQ9AG4xPqFC2Ib6Ty1Kx">我的区服</a>===== =====<a class="" href="/Pallet/GameOpen/GameUser?sid=klxy7ADn96CBYGWQ9AG4xPqFC2Ib6Ty1Kx">我的区服</a>=====
@@ -111,6 +107,7 @@ definePageMeta({
const areaData = ref<any>([]); const areaData = ref<any>([]);
const isOnline = ref(false); const isOnline = ref(false);
const OnCount = ref(0); const OnCount = ref(0);
const Initialize = async (): Promise<void> => { const Initialize = async (): Promise<void> => {
var result = await PubService.GetMain(StateHelper.Sid); var result = await PubService.GetMain(StateHelper.Sid);
if (result.code == 0) { if (result.code == 0) {
@@ -124,18 +121,20 @@ const Initialize = async (): Promise<void> => {
} }
}; };
//退出登录
const offOnline = () => {
MessageExtend.ShowConfirmDialog("退出游戏", "您确定要退出游戏吗?", () => {
StateHelper.OffOnline();
MessageExtend.ShowToast("退出成功!", "success");
});
}
onMounted(async () => { onMounted(async () => {
//默认设置身份,正式环境删除 //默认设置身份,正式环境删除
StateHelper.SetSid("kUVjj2cBUemcdokUEIBEKh0qhKkkSkui0x"); StateHelper.SetSid("kUVjj2cBUemcdokUEIBEKh0qhKkkSkui0x");
//StateHelper.SetSid('');
try { try {
const id = PageExtend.QueryString("id");
MessageExtend.ShowToast(id);
await Initialize(); await Initialize();
} }
finally { finally {

View File

@@ -49,10 +49,11 @@ export const useUserStore = defineStore('user', {
}, },
// 退出登录:清空用户状态 // 退出登录:清空用户状态
clearUserInfo() { offOnline() {
this.token = '', this.token = '',
this.refToken='', this.refToken='',
this.sid='' this.sid='',
this.userId = ''
} }
}, },