[add] 加了一堆東西
This commit is contained in:
parent
1927034da9
commit
6e2920f616
55
public/assets/index.4d99bed5.js
Normal file
55
public/assets/index.4d99bed5.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -8,8 +8,8 @@
|
||||
<!-- <link href="https://fonts.googleapis.com/css2?family=Zen+Maru+Gothic&display=swap" rel="stylesheet"> -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>BJ_Casino_Rank</title>
|
||||
<script type="module" crossorigin src="./assets/index.eabf07ba.js"></script>
|
||||
<link rel="stylesheet" href="./assets/index.b312efde.css">
|
||||
<script type="module" crossorigin src="./assets/index.4d99bed5.js"></script>
|
||||
<link rel="stylesheet" href="./assets/index.89f466a5.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
58
src/App.vue
58
src/App.vue
@ -4,11 +4,29 @@ import { ref } from "vue";
|
||||
import Loading from 'vue-loading-overlay';
|
||||
import 'vue-loading-overlay/dist/vue-loading.css';
|
||||
import BJ_Casino_Magnification from './components/BJ_Casino_Magnification.vue';
|
||||
import Popup from './components/Popup.vue';
|
||||
import { BJ_Casino_Data } from './script/BJ_Casino_Data';
|
||||
|
||||
let isLoading = ref(true)
|
||||
const PopupVisible = ref(false)
|
||||
const isBtn_No = ref(false)
|
||||
const content = ref('666')
|
||||
const enterStr = ref('確定')
|
||||
const cancelStr = ref('取消')
|
||||
const yesCallback: () => void = null
|
||||
const noCallback: () => void = null
|
||||
const PopupData = {
|
||||
content: content,
|
||||
enterStr: enterStr,
|
||||
cancelStr: cancelStr,
|
||||
yesCallback: yesCallback,
|
||||
noCallback: noCallback,
|
||||
isBtn_No: isBtn_No,
|
||||
}
|
||||
const self = {
|
||||
isLoading: isLoading,
|
||||
PopupVisible: PopupVisible,
|
||||
Popup: PopupData,
|
||||
}
|
||||
const BJ_Casino = new BJ_Casino_Data(self)
|
||||
|
||||
@ -16,6 +34,40 @@ const activeName = ref('first')
|
||||
const handleClick = (tab: TabsPaneContext, event: Event) => {
|
||||
console.log(tab, event)
|
||||
}
|
||||
|
||||
getScreen();
|
||||
function getScreen() {
|
||||
// 判断是否为移动端运行环境
|
||||
if (/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))) {
|
||||
if (window.location.href.indexOf("?mobile") < 0) {
|
||||
try {
|
||||
if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
|
||||
// 判断访问环境是 Android|webOS|iPhone|iPod|BlackBerry 则加载以下样式
|
||||
console.log("style_mobile_a");
|
||||
setActiveStyleSheet("style_mobile_a.css");
|
||||
} else if (/iPad/i.test(navigator.userAgent)) {
|
||||
// 判断访问环境是 iPad 则加载以下样式
|
||||
console.log("style_mobile_iPad");
|
||||
setActiveStyleSheet("style_mobile_iPad.css");
|
||||
} else {
|
||||
// 判断访问环境是 其他移动设备 则加载以下样式
|
||||
console.log("style_mobile_other");
|
||||
setActiveStyleSheet("style_mobile_other.css");
|
||||
}
|
||||
} catch (e) { }
|
||||
}
|
||||
} else {
|
||||
BJ_Casino.IsMobile = false;
|
||||
// 如果以上都不是,则加载以下样式
|
||||
console.log("style_mobile_no");
|
||||
setActiveStyleSheet("style_mobile_no.css");
|
||||
}
|
||||
}
|
||||
|
||||
// 判断完毕后加载样式
|
||||
function setActiveStyleSheet(filename: string) {
|
||||
// document.write("<link href=../src/assets/" + filename + " rel=stylesheet>");
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -23,7 +75,7 @@ const handleClick = (tab: TabsPaneContext, event: Event) => {
|
||||
<loading v-model:active="isLoading" :active.sync="isLoading" :can-cancel="false" :is-full-page="true"></loading>
|
||||
<div>
|
||||
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
|
||||
<el-tab-pane label="BJ_Casino_Rank 1303 倍率" name="first">
|
||||
<el-tab-pane label="BJ_Casino_Rank 64 倍率" name="first">
|
||||
這是個參考用的排行榜 啾咪
|
||||
<BJ_Casino_Magnification :BJ_Casino="BJ_Casino" />
|
||||
</el-tab-pane>
|
||||
@ -33,6 +85,10 @@ const handleClick = (tab: TabsPaneContext, event: Event) => {
|
||||
</el-tabs>
|
||||
</div>
|
||||
<!-- <BJ_Casino_Magnification /> -->
|
||||
|
||||
<el-dialog v-model="PopupVisible" :show-close="false">
|
||||
<Popup :APP="self" />
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
|
@ -7,67 +7,7 @@
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
/* .main {
|
||||
width: 80%;
|
||||
margin: 20px auto;
|
||||
.xyhot {
|
||||
width: auto;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
.table {
|
||||
table-layout: fixed;
|
||||
width: 100%;
|
||||
margin-bottom: 1rem;
|
||||
color: #888;
|
||||
vertical-align: top;
|
||||
border-color: rgba(0, 0, 0, .05);
|
||||
}
|
||||
|
||||
td {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
table {
|
||||
caption-side: bottom;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.table>tbody {
|
||||
vertical-align: inherit;
|
||||
}
|
||||
|
||||
.table-info {
|
||||
--bs-table-bg: #6cc3d5;
|
||||
--bs-table-striped-bg: #73c6d7;
|
||||
--bs-table-striped-color: #fff;
|
||||
--bs-table-active-bg: #7bc9d9;
|
||||
--bs-table-active-color: #fff;
|
||||
--bs-table-hover-bg: #77c8d8;
|
||||
--bs-table-hover-color: #fff;
|
||||
color: #fff;
|
||||
border-color: #7bc9d9;
|
||||
}
|
||||
|
||||
.table>:not(caption)>*>* {
|
||||
padding: .5rem .5rem;
|
||||
background-color: var(--bs-table-bg);
|
||||
border-bottom-width: 1px;
|
||||
box-shadow: inset 0 0 0 9999px var(--bs-table-accent-bg);
|
||||
}
|
||||
|
||||
tbody,
|
||||
td,
|
||||
tfoot,
|
||||
th,
|
||||
thead,
|
||||
tr {
|
||||
border-color: inherit;
|
||||
border-style: solid;
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.table>thead {
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
.table>:not(:first-child) {
|
||||
border-top: 2px solid currentColor;
|
||||
} */
|
4
src/assets/style_mobile_a.css
Normal file
4
src/assets/style_mobile_a.css
Normal file
@ -0,0 +1,4 @@
|
||||
.xyhot {
|
||||
width: auto;
|
||||
overflow-y: hidden;
|
||||
}
|
4
src/assets/style_mobile_iPad.css
Normal file
4
src/assets/style_mobile_iPad.css
Normal file
@ -0,0 +1,4 @@
|
||||
.xyhot {
|
||||
width: auto;
|
||||
overflow-y: hidden;
|
||||
}
|
4
src/assets/style_mobile_no.css
Normal file
4
src/assets/style_mobile_no.css
Normal file
@ -0,0 +1,4 @@
|
||||
.xyhot {
|
||||
width: 100%;
|
||||
overflow-y: hidden;
|
||||
}
|
4
src/assets/style_mobile_other.css
Normal file
4
src/assets/style_mobile_other.css
Normal file
@ -0,0 +1,4 @@
|
||||
/* .xyhot {
|
||||
width: auto;
|
||||
overflow-y: hidden;
|
||||
} */
|
@ -13,6 +13,7 @@ const self = {
|
||||
BJ_Casino: props.BJ_Casino,
|
||||
}
|
||||
const Script = new BJ_Casino_Magnification(self);
|
||||
const IsMobile = self.BJ_Casino.IsMobile;
|
||||
|
||||
</script>
|
||||
|
||||
@ -25,9 +26,13 @@ const Script = new BJ_Casino_Magnification(self);
|
||||
</el-button> -->
|
||||
</h1>
|
||||
<div class="d-flex justify-content-center">
|
||||
<!-- <div class="d-flex justify-content-center xyhot"> -->
|
||||
<!-- <div class="d-flex justify-content-center xyhot" :class="IsMobile ? 'xyhot' : 'xyhot'"> -->
|
||||
<!-- <div class="d-flex"> -->
|
||||
<table class="table table-striped table-info table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th align="left" nowrap="nowrap">排名</th> -->
|
||||
<th align="left">排名</th>
|
||||
<th align="left">名稱</th>
|
||||
<th align="left">廳別</th>
|
||||
|
41
src/components/Popup.vue
Normal file
41
src/components/Popup.vue
Normal file
@ -0,0 +1,41 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
const props = defineProps<{ APP: any }>()
|
||||
const content = props.APP.Popup.content
|
||||
const enterStr = props.APP.Popup.enterStr
|
||||
const cancelStr = props.APP.Popup.cancelStr
|
||||
const yesCallback: () => void = props.APP.Popup.yesCallback
|
||||
const noCallback: () => void = props.APP.Popup.noCallback
|
||||
// const self = {
|
||||
// content: content,
|
||||
// enterStr: enterStr,
|
||||
// cancelStr: cancelStr,
|
||||
// yesCallback: yesCallback,
|
||||
// noCallback: noCallback,
|
||||
// }
|
||||
// props.APP.Popup = self;
|
||||
function onClickYes() {
|
||||
if (yesCallback) {
|
||||
yesCallback();
|
||||
}
|
||||
props.APP.PopupVisible.value = false;
|
||||
}
|
||||
function onClickNo() {
|
||||
if (noCallback) {
|
||||
noCallback();
|
||||
}
|
||||
props.APP.PopupVisible.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-row type="flex" justify="center" align="middle">
|
||||
<h1>{{ content }}</h1>
|
||||
</el-row>
|
||||
<el-row class="mb-4" type="flex" justify="center" align="middle">
|
||||
<el-button type="primary" @click.native="() => { onClickNo() }" size="large" round>{{ cancelStr }}
|
||||
</el-button>
|
||||
<el-button type="primary" @click.native="() => { onClickYes() }" size="large" round>{{ enterStr }}
|
||||
</el-button>
|
||||
</el-row>
|
||||
</template>
|
@ -1,172 +0,0 @@
|
||||
<template>
|
||||
<div ref="elRef" v-show="opened" class="vui__popup" :class="{ 'vui__popup-closed': closeCls }" :id="id">
|
||||
|
||||
<!-- //蒙层 -->
|
||||
<div v-if="JSON.parse(shade)" class="vui__overlay" @click="shadeClicked" :style="{ opacity }"></div>
|
||||
<div class="vui__wrap">
|
||||
<div class="vui__wrap-section">
|
||||
<div class="vui__wrap-child"
|
||||
:class="['anim-' + anim, type && 'popupui__' + type, round && 'round', position]"
|
||||
:style="[popupStyle]">
|
||||
<div v-if="title" class="vui__wrap-tit" v-html="title"></div>
|
||||
<div v-if="type == 'toast' && icon" class="vui__toast-icon" :class="['vui__toast-' + icon]"
|
||||
v-html="toastIcon[icon]"></div>
|
||||
|
||||
<!-- 判断插槽是否存在 -->
|
||||
<template v-if="$slots.content">
|
||||
<div class="vui__wrap-cnt">
|
||||
<slot name="content" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div v-if="content" class="vui__wrap-cnt" v-html="content"></div>
|
||||
</template>
|
||||
|
||||
<slot />
|
||||
<div v-if="btns" class="vui__wrap-btns">
|
||||
<span v-for="(btn, index) in btns" :key="index" class="btn" :style="btn.style"
|
||||
@click="btnClicked($event, index)" v-html="btn.text"></span>
|
||||
</div>
|
||||
<span v-if="xclose" class="vui__xclose" :class="xposition" :style="{ 'color': xcolor }"
|
||||
@click="close"></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
/**
|
||||
* @Desc Vue3自定义弹出层组件V3Popup
|
||||
* @Time andy by 2020-12
|
||||
* @About Q:282310962 wx:xy190310
|
||||
*/
|
||||
<script>
|
||||
import { onMounted, ref, reactive, watch, toRefs, nextTick } from 'vue'
|
||||
let $index = 0, $locknum = 0, $timer = {}
|
||||
export default {
|
||||
props: {
|
||||
// 接收父组件v-model值,如果v-model:open,则这里需写open: {...}
|
||||
modelValue: { type: Boolean, default: false },
|
||||
// 标识符,相同ID共享一个实例
|
||||
id: {
|
||||
type: String, default: ''
|
||||
},
|
||||
title: String,
|
||||
content: String,
|
||||
type: String,
|
||||
popupStyle: String,
|
||||
icon: String,
|
||||
shade: { type: [Boolean, String], default: true },
|
||||
shadeClose: { type: [Boolean, String], default: true },
|
||||
opacity: { type: [Number, String], default: '' },
|
||||
round: Boolean,
|
||||
xclose: Boolean,
|
||||
xposition: { type: String, default: 'right' },
|
||||
xcolor: { type: String, default: '#333' },
|
||||
anim: { type: String, default: 'scaleIn' },
|
||||
position: String,
|
||||
follow: { type: Array, default: null },
|
||||
time: { type: [Number, String], default: 0 },
|
||||
zIndex: { type: [Number, String], default: '8080' },
|
||||
teleport: [String, Object],
|
||||
btns: {
|
||||
type: Array, default: null
|
||||
},
|
||||
onSuccess: { type: Function, default: null },
|
||||
onEnd: { type: Function, default: null },
|
||||
},
|
||||
emits: [
|
||||
'update:modelValue'
|
||||
],
|
||||
setup(props, context) {
|
||||
const elRef = ref(null)
|
||||
|
||||
const data = reactive({
|
||||
opened: false,
|
||||
closeCls: '',
|
||||
toastIcon: {
|
||||
...
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
...
|
||||
})
|
||||
|
||||
// 监听弹层v-model
|
||||
watch(() => props.modelValue, (val) => {
|
||||
if (val) {
|
||||
open()
|
||||
} else {
|
||||
close()
|
||||
}
|
||||
})
|
||||
|
||||
// 打开弹层
|
||||
const open = () => {
|
||||
if (data.opened) return
|
||||
data.opened = true
|
||||
typeof props.onSuccess === 'function' && props.onSuccess()
|
||||
|
||||
const dom = elRef.value
|
||||
dom.style.zIndex = getZIndex() + 1
|
||||
|
||||
...
|
||||
|
||||
// 倒计时
|
||||
if (props.time) {
|
||||
$index++
|
||||
// 避免重复操作
|
||||
if ($timer[$index] !== null) clearTimeout($timer[$index])
|
||||
$timer[$index] = setTimeout(() => {
|
||||
close()
|
||||
}, parseInt(props.time) * 1000)
|
||||
}
|
||||
|
||||
// 长按|右键菜单
|
||||
if (props.follow) {
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭弹层
|
||||
const close = () => {
|
||||
if (!data.opened) return
|
||||
|
||||
data.closeCls = true
|
||||
setTimeout(() => {
|
||||
...
|
||||
|
||||
context.emit('update:modelValue', false)
|
||||
typeof props.onEnd === 'function' && props.onEnd()
|
||||
}, 200)
|
||||
}
|
||||
|
||||
// 点击遮罩层
|
||||
const shadeClicked = () => {
|
||||
if (JSON.parse(props.shadeClose)) {
|
||||
close()
|
||||
}
|
||||
}
|
||||
// 按钮事件
|
||||
const btnClicked = (e, index) => {
|
||||
let btn = props.btns[index];
|
||||
if (!btn.disabled) {
|
||||
typeof btn.click === 'function' && btn.click(e)
|
||||
}
|
||||
}
|
||||
|
||||
...
|
||||
|
||||
return {
|
||||
...toRefs(data),
|
||||
elRef,
|
||||
close,
|
||||
shadeClicked,
|
||||
btnClicked,
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -6,13 +6,18 @@ import "./Engine/CatanEngine/CSharp/String";
|
||||
import { INetResponse } from "./Engine/CatanEngine/NetManagerV2/Core/INetResponse";
|
||||
import { NetConnector } from "./Engine/CatanEngine/NetManagerV2/NetConnector";
|
||||
import { NetManager } from "./Engine/CatanEngine/NetManagerV2/NetManager";
|
||||
import { MainControl } from "./MainControl/MainControl";
|
||||
import { Tools } from "./Tools";
|
||||
|
||||
export class BJ_Casino_Data {
|
||||
|
||||
//#region public
|
||||
|
||||
public ContestData: string[] = ["7/22~7/28"];
|
||||
public IsMobile: boolean = true;
|
||||
|
||||
public ContestData: string[] = ["8/8~8/12"];
|
||||
|
||||
public ThisUseSlot: number = 64;
|
||||
|
||||
public ThisUseType: number[] = [1, 2, 3];
|
||||
|
||||
@ -82,6 +87,9 @@ export class BJ_Casino_Data {
|
||||
}
|
||||
|
||||
public async onLoad(): Promise<void> {
|
||||
let mainControl: MainControl = new MainControl();
|
||||
mainControl.onLoad();
|
||||
CSMessage.Initialize(this.Client);
|
||||
await this.ConnectServer();
|
||||
await this.SendRankData();
|
||||
}
|
||||
@ -142,12 +150,12 @@ export class BJ_Casino_Data {
|
||||
private _onNetDisconnected(): void {
|
||||
console.log("[事件] 收到連線中斷事件");
|
||||
this._conn.OnDataReceived.RemoveAllCallbacks();
|
||||
// MainControl.DataReceivedEvent.DispatchCallback([MainControl.DataType.NetDisconnected]);
|
||||
MainControl.DataReceivedEvent.DispatchCallback([MainControl.DataType.NetDisconnected]);
|
||||
}
|
||||
|
||||
private _onNetDataReceived(resp: INetResponse<any>): void {
|
||||
console.log(`[事件] 收到server呼叫: ${resp.Method}(${JSON.stringify(resp.Data)}), 狀態: ${resp.Status}`);
|
||||
// MainControl.DataReceivedEvent.DispatchCallback([MainControl.DataType.ServerData, resp]);
|
||||
MainControl.DataReceivedEvent.DispatchCallback([MainControl.DataType.ServerData, resp]);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
@ -278,9 +286,12 @@ export class BJ_Casino_Data {
|
||||
rankdata = rankdata.filter((rankdata: any, index: any, arr: any) => {
|
||||
return arr.findIndex((s: any) => rankdata[2][1] === s[2][1]) === index;
|
||||
});
|
||||
if (this.ThisUseSlot) {
|
||||
let useSlot = this.ThisUseSlot;
|
||||
rankdata = rankdata.filter((rankdata: any, index: any, arr: any) => {
|
||||
return +rankdata[3][0] === 1303;
|
||||
return +rankdata[3][0] === useSlot;
|
||||
});
|
||||
}
|
||||
for (let i: number = 0; i < rankdata.length; i++) {
|
||||
rankdata[i][0] = i + 1;
|
||||
}
|
||||
|
@ -1,5 +1,54 @@
|
||||
/** 訊息框相關 */
|
||||
export default class CSMessage {
|
||||
private static _client: any;
|
||||
public static Initialize(client: any): void {
|
||||
this._client = client;
|
||||
}
|
||||
|
||||
/** 一個按鈕的訊息框 */
|
||||
public static CreateYesMsg(content: string, yesCallback: () => void = null, enterStr: string = null) {
|
||||
// enterStr = enterStr ? enterStr : CSSettingsV3.prototype.CommonString(3);
|
||||
// let data: MessageNormalData = {
|
||||
// content: content,
|
||||
// isShowCancel: false,
|
||||
// yesCallback: yesCallback,
|
||||
// noCallback: null,
|
||||
// enterName: enterStr,
|
||||
// cancelName: null
|
||||
// };
|
||||
// MessageNormal.Create(this._sourceUI, this._parent, data);
|
||||
}
|
||||
|
||||
/** 兩個按鈕的訊息框 */
|
||||
public static CreateYesNoMsg(content: string, yesCallback: () => void = null, noCallback: () => void = null, enterStr: string = null, cancelStr: string = null) {
|
||||
this._client.isLoading.value = false;
|
||||
this._client.Popup.content.value = content;
|
||||
if (yesCallback) {
|
||||
this._client.Popup.yesCallback = yesCallback;
|
||||
}
|
||||
if (noCallback) {
|
||||
this._client.Popup.noCallback = noCallback;
|
||||
}
|
||||
if (enterStr) {
|
||||
this._client.Popup.enterStr.value = enterStr;
|
||||
}
|
||||
if (cancelStr) {
|
||||
this._client.Popup.cancelStr.value = cancelStr;
|
||||
}
|
||||
this._client.PopupVisible.value = true;
|
||||
// enterStr = enterStr ? enterStr : CSSettingsV3.prototype.CommonString(3);
|
||||
// cancelStr = cancelStr ? cancelStr : CSSettingsV3.prototype.CommonString(4);
|
||||
// let data: MessageNormalData = {
|
||||
// content: content,
|
||||
// isShowCancel: true,
|
||||
// yesCallback: yesCallback,
|
||||
// noCallback: noCallback,
|
||||
// enterName: enterStr,
|
||||
// cancelName: cancelStr
|
||||
// };
|
||||
// MessageNormal.Create(this._sourceUI, this._parent, data);
|
||||
}
|
||||
|
||||
/** 網路錯誤訊息 */
|
||||
public static NetError(method: string, state: number, str: string = ""): void {
|
||||
let error: string = String.Format("[{0}] state:{1} {2}", method, state, str);
|
||||
|
@ -29,6 +29,7 @@ export class AccountCreateRequest extends NetRequest<CreateResquest, CommonAccou
|
||||
interface LoginResquest {
|
||||
p: number;
|
||||
device_info: string[];
|
||||
d: string;
|
||||
fcm_token: string;
|
||||
a: string;
|
||||
pw: string;
|
||||
@ -48,6 +49,7 @@ export class AccountLoginRequest extends NetRequest<LoginResquest, LoginResponse
|
||||
this.Data = {
|
||||
p: Config.GetRunDevice(),
|
||||
device_info: ["Windows", "Windows"],
|
||||
d: "JianMiau",
|
||||
fcm_token: "",
|
||||
a: account,
|
||||
pw: password,
|
||||
|
77
src/script/MainControl/DataReceived/MainControlData.ts
Normal file
77
src/script/MainControl/DataReceived/MainControlData.ts
Normal file
@ -0,0 +1,77 @@
|
||||
import CSMessage from "../../Base/CSMessage";
|
||||
import { INetResponse } from "../../Engine/CatanEngine/NetManagerV2/Core/INetResponse";
|
||||
import { MainControl } from "../MainControl";
|
||||
|
||||
export default class MainControlData {
|
||||
private _disconnetErrorType: number = null;
|
||||
|
||||
constructor() {
|
||||
MainControl.DataReceivedEvent.AddCallback(this._dataReceivedEvent, this);
|
||||
}
|
||||
private _dataReceivedEvent(param: any[] = null): void {
|
||||
let type: MainControl.DataType = param[0];
|
||||
let data: any = param[1];
|
||||
switch (type) {
|
||||
case MainControl.DataType.ServerData:
|
||||
this._serverData(data);
|
||||
break;
|
||||
case MainControl.DataType.NetDisconnected:
|
||||
this._netDisconnected();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// =======================================================================================
|
||||
/** SERVER主動通知 */
|
||||
private _serverData(resp: INetResponse<any>): void {
|
||||
if (resp.IsValid) {
|
||||
switch (resp.Method) {
|
||||
case "sys.disconnect":
|
||||
let error: number = +resp.Data["c"];
|
||||
if (error > 100) {
|
||||
if (error != 201) {
|
||||
this._disconnetErrorType = +resp.Data["c"];
|
||||
} else {
|
||||
MainControl.Instance.IsLogout = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// =======================================================================================
|
||||
/** SOCKET斷線 */
|
||||
private _netDisconnected(): void {
|
||||
// 斷線不會收到回傳值
|
||||
let CommonStringNum: number = 9;
|
||||
if (this._disconnetErrorType != null) {
|
||||
if (this._disconnetErrorType === 101) {
|
||||
CSMessage.CreateYesNoMsg("帳號重複登入,請重新刷新網頁", () => {
|
||||
window.location.reload();
|
||||
});
|
||||
MainControl.Instance.IsLogout = true;
|
||||
}
|
||||
this._disconnetErrorType = null;
|
||||
}
|
||||
if (!MainControl.Instance.IsLogout) {
|
||||
// //遊戲維護中字串
|
||||
// let showStr: string = ""
|
||||
// if (CommonStringNum != 14) {
|
||||
// showStr = CSSettingsV3.prototype.CommonString(CommonStringNum);
|
||||
// } else {
|
||||
// showStr = Loading.maintainStr;
|
||||
// }
|
||||
// CSMessage.CreateYesMsg(
|
||||
// showStr,
|
||||
// this._type2GoLogin
|
||||
// );
|
||||
}
|
||||
MainControl.Instance.IsLogout = false;
|
||||
// MainControl.Instance.LastPlayGameID = 0;
|
||||
// MainControl.Instance.IsInGame = false;
|
||||
// AwardsNotifyManager.Instance?.Clear();
|
||||
}
|
||||
}
|
28
src/script/MainControl/MainControl.ts
Normal file
28
src/script/MainControl/MainControl.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { Action } from "../Engine/CatanEngine/CSharp/System/Action";
|
||||
import MainControlData from "./DataReceived/MainControlData";
|
||||
|
||||
export class MainControl {
|
||||
// =======================================================================================
|
||||
/** MainControl實例 */
|
||||
private static _instance: MainControl = null;
|
||||
public static get Instance(): MainControl { return this._instance; }
|
||||
public static readonly DataReceivedEvent: Action<any[]> = new Action<any[]>();
|
||||
/** false被動斷線true主動斷線 */
|
||||
public IsLogout: boolean = false;
|
||||
|
||||
public onLoad(): void {
|
||||
MainControl._instance = this;
|
||||
this._initialEngine();
|
||||
}
|
||||
|
||||
private _initialEngine(): void {
|
||||
new MainControlData();
|
||||
}
|
||||
}
|
||||
export module MainControl {
|
||||
export enum DataType {
|
||||
ServerData,
|
||||
ChangeDire,
|
||||
NetDisconnected,
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
"useDefineForClassFields": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
// "strict": true,
|
||||
"jsx": "preserve",
|
||||
"sourceMap": true,
|
||||
"resolveJsonModule": true,
|
||||
|
Loading…
Reference in New Issue
Block a user