This commit is contained in:
Putoo
2026-05-18 13:28:20 +08:00
parent 78759387f7
commit 974421ce9b
13 changed files with 200 additions and 39 deletions

View File

@@ -20,6 +20,6 @@ public class NoticeService:INoticeService,ITransient
public async Task<List<game_notice>> GetNoticeData(int page, int limit, RefAsync<int> total) public async Task<List<game_notice>> GetNoticeData(int page, int limit, RefAsync<int> total)
{ {
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_notice>(); var db = _dbClient.AsTenant().GetConnectionWithAttr<game_notice>();
return await db.Queryable<game_notice>().ToPageListAsync(page, limit, total); return await db.Queryable<game_notice>().OrderByDescending(it=>it.addTime).ToPageListAsync(page, limit, total);
} }
} }

View File

@@ -25,7 +25,11 @@ public class GameAccountService : IGameAccountService, ITransient
{ {
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_account>(); var db = _dbClient.AsTenant().GetConnectionWithAttr<game_account>();
var data = await db.Queryable<game_account>().Where(it => it.openId == openId).FirstAsync(); var data = await db.Queryable<game_account>().Where(it => it.openId == openId).FirstAsync();
if (data != null)
{
await _redisClient.AddHashAsync(key, openId, data); await _redisClient.AddHashAsync(key, openId, data);
}
return data; return data;
} }
} }
@@ -41,7 +45,11 @@ public class GameAccountService : IGameAccountService, ITransient
{ {
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_account>(); var db = _dbClient.AsTenant().GetConnectionWithAttr<game_account>();
var data = await db.Queryable<game_account>().Where(it => it.accId == accId).FirstAsync(); var data = await db.Queryable<game_account>().Where(it => it.accId == accId).FirstAsync();
if (data != null)
{
await _redisClient.AddHashAsync(key, accId, data); await _redisClient.AddHashAsync(key, accId, data);
}
return data; return data;
} }
} }
@@ -116,6 +124,7 @@ public class GameAccountService : IGameAccountService, ITransient
{ {
result = null; result = null;
} }
await _dbClient.AsTenant().CommitTranAsync(); await _dbClient.AsTenant().CommitTranAsync();
} }
catch catch

View File

@@ -12,11 +12,13 @@ namespace Application.Web.Controllers.Pub
{ {
private readonly IAreaService _areaService; private readonly IAreaService _areaService;
private readonly INoticeService _noticeService; private readonly INoticeService _noticeService;
private readonly IGameAccountService _accountService;
public PubController(IAreaService areaService, INoticeService noticeService) public PubController(IAreaService areaService, INoticeService noticeService,IGameAccountService accountService)
{ {
_areaService = areaService; _areaService = areaService;
_noticeService = noticeService; _noticeService = noticeService;
_accountService = accountService;
} }
/// <summary> /// <summary>
@@ -28,16 +30,35 @@ namespace Application.Web.Controllers.Pub
public async Task<IPoAction> GetMain(string? sid) public async Task<IPoAction> GetMain(string? sid)
{ {
bool isOnline = false; bool isOnline = false;
game_account account = new game_account();
if (!string.IsNullOrEmpty(sid)) if (!string.IsNullOrEmpty(sid))
{
account = await _accountService.GetAccInfoByToken(sid);
if (account != null)
{ {
isOnline = true; isOnline = true;
} }
}
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,account });
}
/// <summary>
/// 获取公告列表
/// </summary>
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetNoticeData(int page,int limit)
{
RefAsync<int> total = 0;
var data = await _noticeService.GetNoticeData(page, limit, total);
return PoAction.Ok(new { data, total=total.Value });
} }
} }
} }

View File

@@ -4,6 +4,7 @@ global using Photon.Core.Services;
global using Photon.Core.SqlSugar; global using Photon.Core.SqlSugar;
global using Photon.Core.Assist; global using Photon.Core.Assist;
global using Photon.Core.Timer; global using Photon.Core.Timer;
global using SqlSugar;
global using Application.Service.Pub; global using Application.Service.Pub;
global using Application.Domain; global using Application.Domain;

View File

@@ -2,10 +2,10 @@
<div class="pagination"> <div class="pagination">
<!-- 第一行导航按钮 --> <!-- 第一行导航按钮 -->
<div class="pagination-nav"> <div class="pagination-nav">
<span v-if="currentPage !== 1" @click="changePage('first')">首页 . </span> <span v-if="currentPage > 1" @click="changePage('first')">首页 . </span>
<span v-if="currentPage !== 1" @click="changePage('prev')">上一页 .</span> <span v-if="currentPage > 1" @click="changePage('prev')">上一页 .</span>
<span v-if="currentPage !== totalPages" @click="changePage('next')">下一页 .</span> <span v-if="currentPage < totalPages" @click="changePage('next')">下一页 .</span>
<span v-if="currentPage !== totalPages" @click="changePage('last')">尾页</span> <span v-if="currentPage < totalPages" @click="changePage('last')">尾页</span>
</div> </div>
<!-- 第二行页码信息与跳转 --> <!-- 第二行页码信息与跳转 -->
<div class="pagination-info"> <div class="pagination-info">
@@ -20,16 +20,20 @@
<script setup lang="ts"> <script setup lang="ts">
interface Props { interface Props {
currentPage: number; currentPage: number;
totalPages: number; limit: number;
total: number;
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
currentPage: 1, currentPage: 1,
totalPages: 1, limit:10,
total: 1,
}); });
let currentPage = ref(props.currentPage) let currentPage = ref(props.currentPage);
let totalPages = ref(props.totalPages) let limit = ref(props.limit);
let total = ref(props.total);
let totalPages = total.value / limit.value;
const emit = defineEmits(['pageChange']) const emit = defineEmits(['pageChange'])
@@ -38,14 +42,14 @@ const changePage = (type: any) => {
if (type == 'input' && currentPage.value < 1) { if (type == 'input' && currentPage.value < 1) {
currentPage.value = 1 currentPage.value = 1
} }
if (type == 'input' && currentPage.value > totalPages.value) { if (type == 'input' && currentPage.value > totalPages) {
currentPage.value = totalPages.value currentPage.value = totalPages
} }
if (type == 'prev' && currentPage.value == 1) { if (type == 'prev' && currentPage.value == 1) {
return return
} }
if (type == 'next' && currentPage.value == totalPages.value) { if (type == 'next' && currentPage.value == totalPages) {
return return
} }
@@ -57,7 +61,7 @@ const changePage = (type: any) => {
} else if (type == 'next') { } else if (type == 'next') {
currentPage.value++ currentPage.value++
} else if (type == 'last') { } else if (type == 'last') {
currentPage.value = totalPages.value currentPage.value = totalPages
} }
emit('pageChange', currentPage.value) emit('pageChange', currentPage.value)
} }
@@ -68,11 +72,11 @@ const changePage = (type: any) => {
<style scoped> <style scoped>
.pagination { .pagination {
text-align: left; text-align: left;
font-size: 14px; font-size: 18px;
} }
.pagination-nav { .pagination-nav {
margin-bottom: 8px; margin-bottom: 0px;
} }
.pagination-nav span { .pagination-nav span {
@@ -96,7 +100,7 @@ const changePage = (type: any) => {
} }
.page-input { .page-input {
width: 50px; width: 30px;
padding: 2px 4px; padding: 2px 4px;
text-align: center; text-align: center;
border: 1px solid #ccc; border: 1px solid #ccc;

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1,26 @@
<template>
<div>
<div class="content">
<Abar href="/">首页</Abar>&gt;关于
</div>
<div class="content">
驰骋四海是2022年初自主设计的一款以大航海时代为背景的wap文字游戏希望给大家呈现一种不一样的怀旧场景
</div>
<Abar href="/">返回游戏首页</Abar>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.empty,
middleware: middleware.loading
})
onMounted(() => {
PageLoading.Close();
})
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,27 @@
<template>
<div>
<div class="content">
<Abar href="/">首页</Abar>&gt;合作
</div>
<div class="content">
商务合作请联系<br />
客服QQ290555931
</div>
<Abar href="/">返回游戏首页</Abar>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.empty,
middleware: middleware.loading
})
onMounted(() => {
PageLoading.Close();
})
</script>
<style lang="scss" scoped></style>

View File

@@ -10,14 +10,14 @@
</div> </div>
<div class="content" style="font-size:17px" v-if="isOnline"> <div class="content" style="font-size:17px" v-if="isOnline">
<div> <div>
亲爱的&nbsp;<strong style="color:red">探玩玩家</strong>欢迎来到驰骋四海&#xB7;社区版! 亲爱的&nbsp;<strong style="color:red">{{ AccountInfo.nick }}</strong>欢迎来到驰骋四海!
</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/Regain/ToMain?openid=" + AccountInfo.openId'>返回探玩驿站</a>
</div> </div>
<div> <div>
<a href="http://m.twbar.cn/b/1145?sid=KrWxKypJuDO0zFKrTig0bG">游戏论坛</a>&nbsp;&nbsp; <a :href='"http://m.twbar.cn/Regain/ToBbs?openid=" + AccountInfo.openId + "&bbs=1146"'>游戏论坛</a>&nbsp;&nbsp;
<a @click.stop="offOnline">退出游戏</a> <a @click.stop="offOnline">退出游戏</a>
</div> </div>
</div> </div>
@@ -27,12 +27,11 @@
</div> </div>
<div class="common" v-if="isOnline"> <div class="common" v-if="isOnline">
<div class="title"> <div class="title">
=====<a class="" href="/Pallet/GameOpen/GameUser?sid=klxy7ADn96CBYGWQ9AG4xPqFC2Ib6Ty1Kx">我的区服</a>===== =====<Abar href="/area/my">我的区服</Abar>=====
</div> </div>
<div class="content"> <div class="content">
<div class="item"> <div class="item">
<a <Abar href="/">&#x2727;&#x3010;1&#x3011;新手村&#x2730;村长()</Abar>
href="/LoginGame/LoginOk?sid=W6Wg8iH9gY7wIBNSEdtFcQ3KbI5YiKDo">&#x2727;&#x3010;1&#x3011;新手村&#x2730;村长()</a>
</div> </div>
</div> </div>
</div> </div>
@@ -50,11 +49,11 @@
</div> </div>
<div class="title"> <div class="title">
=====<a class="" href="/Pallet/Notice/Index?sid=klxy7ADn96CBYGWQ9AG4xPqFC2Ib6Ty1Kx">官方公告</a>===== =====<Abar href="/news/">官方公告</Abar>=====
</div> </div>
<div> <div>
<div class="item" v-for="(item, index) in noticeData" :key="index"> <div class="item" v-for="(item, index) in noticeData" :key="index">
{{ index + 1 }}.<Abar :href='"/login/register?id=" + item.noticeId'>{{ item.title }}</Abar> {{ index + 1 }}.<Abar :href='"/news/info?id=" + item.noticeId'>{{ item.title }}</Abar>
</div> </div>
<span v-if="noticeData.length == 0">暂无公告.</span> <span v-if="noticeData.length == 0">暂无公告.</span>
</div> </div>
@@ -63,9 +62,9 @@
=====服务导航===== =====服务导航=====
</div> </div>
<div class="content"> <div class="content">
<Abar href="/customer">客服</Abar> <Abar href="/customer">客服</Abar>.
.<a class="" href="/Index/About?sid=klxy7ADn96CBYGWQ9AG4xPqFC2Ib6Ty1Kx">关于</a>.<a class="" <Abar href="/customer/about">关于</Abar>.
href="/Index/Cooperation?sid=klxy7ADn96CBYGWQ9AG4xPqFC2Ib6Ty1Kx">合作</a> <Abar href="/customer/cooperation">合作</Abar>
</div> </div>
<div class="foot"> <div class="foot">
<div class="timeService"> <div class="timeService">
@@ -85,15 +84,19 @@ const areaData = ref<Array<any>>([]);
const noticeData = ref<Array<any>>([]); const noticeData = ref<Array<any>>([]);
const isOnline = ref(false); const isOnline = ref(false);
const OnCount = ref(0); const OnCount = ref(0);
const AccountInfo = ref<any>();
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) {
isOnline.value = result.data.isOnline;
if (isOnline.value == false) {
StateHelper.OffOnline();
}
areaData.value = result.data?.area; areaData.value = result.data?.area;
noticeData.value = result.data.notice; noticeData.value = result.data.notice;
isOnline.value = result.data.isOnline;
OnCount.value = result.data.onCount; OnCount.value = result.data.onCount;
AccountInfo.value = result.data.account;
} }
else { else {
MessageExtend.ShowToast(result.msg, "fail"); MessageExtend.ShowToast(result.msg, "fail");

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1,59 @@
<template>
<div class="content">
<Abar href="/">首页</Abar>&gt;官方公告
</div>
<div class="common">
<div class="item border" v-for="(item, index) in data" :key="index">
{{ index + 1 }}.<Abar :href='"/news/info?id=" + item.noticeId'>{{ item.title }}</Abar>
</div>
<span v-if="data.length == 0">暂无公告.</span>
</div>
<div class="content">
<Pagination :currentPage="currentPage" :limit="10" :total="totalPages" @pageChange="handlePageChange" />
</div>
<Abar href="/">返回游戏首页</Abar>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.empty,
middleware: 'page-loading'
})
const currentPage = ref<number>(1);
const totalPages = ref<number>(0);
const data = ref<Array<any>>([]);
const handlePageChange = async (page: number): Promise<void> => {
currentPage.value = page;
await BindData();
console.log('跳转到第', page, '页');
};
const BindData = async (): Promise<void> => {
var result = await PubService.GetNoticeData(currentPage.value, 10);
console.log(result);
if (result.code == 0) {
data.value = result.data.data;
totalPages.value = result.data.total;
}
else {
MessageExtend.ShowToast(result.msg, "fail");
}
};
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -6,4 +6,12 @@ export class PubService {
static async GetMain(sid: string) { static async GetMain(sid: string) {
return await ApiService.Request("get", "/Pub/GetMain", { sid }); return await ApiService.Request("get", "/Pub/GetMain", { sid });
} }
/**
* GetNoticeData
* GET /Pub/GetNoticeData
*/
static async GetNoticeData(page: number, limit: number) {
return await ApiService.Request("get", "/Pub/GetNoticeData", { page, limit });
}
} }