[add] 加了一堆東西

This commit is contained in:
建喵 2022-08-10 09:31:29 +08:00
parent 1927034da9
commit 6e2920f616
20 changed files with 547 additions and 494 deletions

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

View File

@ -8,8 +8,8 @@
<!-- <link href="https://fonts.googleapis.com/css2?family=Zen+Maru+Gothic&display=swap" rel="stylesheet"> --> <!-- <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" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BJ_Casino_Rank</title> <title>BJ_Casino_Rank</title>
<script type="module" crossorigin src="./assets/index.eabf07ba.js"></script> <script type="module" crossorigin src="./assets/index.4d99bed5.js"></script>
<link rel="stylesheet" href="./assets/index.b312efde.css"> <link rel="stylesheet" href="./assets/index.89f466a5.css">
</head> </head>
<body> <body>

View File

@ -4,11 +4,29 @@ import { ref } from "vue";
import Loading from 'vue-loading-overlay'; import Loading from 'vue-loading-overlay';
import 'vue-loading-overlay/dist/vue-loading.css'; import 'vue-loading-overlay/dist/vue-loading.css';
import BJ_Casino_Magnification from './components/BJ_Casino_Magnification.vue'; 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'; import { BJ_Casino_Data } from './script/BJ_Casino_Data';
let isLoading = ref(true) 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 = { const self = {
isLoading: isLoading, isLoading: isLoading,
PopupVisible: PopupVisible,
Popup: PopupData,
} }
const BJ_Casino = new BJ_Casino_Data(self) const BJ_Casino = new BJ_Casino_Data(self)
@ -16,6 +34,40 @@ const activeName = ref('first')
const handleClick = (tab: TabsPaneContext, event: Event) => { const handleClick = (tab: TabsPaneContext, event: Event) => {
console.log(tab, 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> </script>
<template> <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> <loading v-model:active="isLoading" :active.sync="isLoading" :can-cancel="false" :is-full-page="true"></loading>
<div> <div>
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick"> <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" /> <BJ_Casino_Magnification :BJ_Casino="BJ_Casino" />
</el-tab-pane> </el-tab-pane>
@ -33,6 +85,10 @@ const handleClick = (tab: TabsPaneContext, event: Event) => {
</el-tabs> </el-tabs>
</div> </div>
<!-- <BJ_Casino_Magnification /> --> <!-- <BJ_Casino_Magnification /> -->
<el-dialog v-model="PopupVisible" :show-close="false">
<Popup :APP="self" />
</el-dialog>
</template> </template>
<style> <style>

View File

@ -1,73 +1,13 @@
.table { .table {
width: inherit; width: inherit;
} }
.el-tabs__nav-scroll { .el-tabs__nav-scroll {
/* width: 50%; */ /* width: 50%; */
margin: 0 auto; margin: 0 auto;
} }
/* .main { .xyhot {
width: 80%; width: auto;
margin: 20px 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;
} */

View File

@ -0,0 +1,4 @@
.xyhot {
width: auto;
overflow-y: hidden;
}

View File

@ -0,0 +1,4 @@
.xyhot {
width: auto;
overflow-y: hidden;
}

View File

@ -0,0 +1,4 @@
.xyhot {
width: 100%;
overflow-y: hidden;
}

View File

@ -0,0 +1,4 @@
/* .xyhot {
width: auto;
overflow-y: hidden;
} */

View File

@ -13,6 +13,7 @@ const self = {
BJ_Casino: props.BJ_Casino, BJ_Casino: props.BJ_Casino,
} }
const Script = new BJ_Casino_Magnification(self); const Script = new BJ_Casino_Magnification(self);
const IsMobile = self.BJ_Casino.IsMobile;
</script> </script>
@ -25,9 +26,13 @@ const Script = new BJ_Casino_Magnification(self);
</el-button> --> </el-button> -->
</h1> </h1>
<div class="d-flex justify-content-center"> <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"> <table class="table table-striped table-info table-hover">
<thead> <thead>
<tr> <tr>
<!-- <th align="left" nowrap="nowrap">排名</th> -->
<th align="left">排名</th> <th align="left">排名</th>
<th align="left">名稱</th> <th align="left">名稱</th>
<th align="left">廳別</th> <th align="left">廳別</th>

41
src/components/Popup.vue Normal file
View 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>

View File

@ -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-modelv-model:openopen: {...}
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>

View File

@ -6,13 +6,18 @@ import "./Engine/CatanEngine/CSharp/String";
import { INetResponse } from "./Engine/CatanEngine/NetManagerV2/Core/INetResponse"; import { INetResponse } from "./Engine/CatanEngine/NetManagerV2/Core/INetResponse";
import { NetConnector } from "./Engine/CatanEngine/NetManagerV2/NetConnector"; import { NetConnector } from "./Engine/CatanEngine/NetManagerV2/NetConnector";
import { NetManager } from "./Engine/CatanEngine/NetManagerV2/NetManager"; import { NetManager } from "./Engine/CatanEngine/NetManagerV2/NetManager";
import { MainControl } from "./MainControl/MainControl";
import { Tools } from "./Tools"; import { Tools } from "./Tools";
export class BJ_Casino_Data { export class BJ_Casino_Data {
//#region public //#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]; public ThisUseType: number[] = [1, 2, 3];
@ -82,6 +87,9 @@ export class BJ_Casino_Data {
} }
public async onLoad(): Promise<void> { public async onLoad(): Promise<void> {
let mainControl: MainControl = new MainControl();
mainControl.onLoad();
CSMessage.Initialize(this.Client);
await this.ConnectServer(); await this.ConnectServer();
await this.SendRankData(); await this.SendRankData();
} }
@ -142,12 +150,12 @@ export class BJ_Casino_Data {
private _onNetDisconnected(): void { private _onNetDisconnected(): void {
console.log("[事件] 收到連線中斷事件"); console.log("[事件] 收到連線中斷事件");
this._conn.OnDataReceived.RemoveAllCallbacks(); this._conn.OnDataReceived.RemoveAllCallbacks();
// MainControl.DataReceivedEvent.DispatchCallback([MainControl.DataType.NetDisconnected]); MainControl.DataReceivedEvent.DispatchCallback([MainControl.DataType.NetDisconnected]);
} }
private _onNetDataReceived(resp: INetResponse<any>): void { private _onNetDataReceived(resp: INetResponse<any>): void {
console.log(`[事件] 收到server呼叫: ${resp.Method}(${JSON.stringify(resp.Data)}), 狀態: ${resp.Status}`); 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 //#endregion
@ -278,9 +286,12 @@ export class BJ_Casino_Data {
rankdata = rankdata.filter((rankdata: any, index: any, arr: any) => { rankdata = rankdata.filter((rankdata: any, index: any, arr: any) => {
return arr.findIndex((s: any) => rankdata[2][1] === s[2][1]) === index; return arr.findIndex((s: any) => rankdata[2][1] === s[2][1]) === index;
}); });
rankdata = rankdata.filter((rankdata: any, index: any, arr: any) => { if (this.ThisUseSlot) {
return +rankdata[3][0] === 1303; let useSlot = this.ThisUseSlot;
}); rankdata = rankdata.filter((rankdata: any, index: any, arr: any) => {
return +rankdata[3][0] === useSlot;
});
}
for (let i: number = 0; i < rankdata.length; i++) { for (let i: number = 0; i < rankdata.length; i++) {
rankdata[i][0] = i + 1; rankdata[i][0] = i + 1;
} }

View File

@ -1,8 +1,57 @@
/** 訊息框相關 */ /** 訊息框相關 */
export default class CSMessage { export default class CSMessage {
/** 網路錯誤訊息 */ private static _client: any;
public static NetError(method: string, state: number, str: string = ""): void { public static Initialize(client: any): void {
let error: string = String.Format("[{0}] state:{1} {2}", method, state, str); this._client = client;
console.warn("網路錯誤訊息: ", error); }
}
/** 一個按鈕的訊息框 */
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);
console.warn("網路錯誤訊息: ", error);
}
} }

View File

@ -5,233 +5,235 @@ import Config from "../Config";
// ======================================================================================= // =======================================================================================
/** 通用回傳SERVER創的帳號 */ /** 通用回傳SERVER創的帳號 */
interface CommonAccountResponse { interface CommonAccountResponse {
a: string; a: string;
pw: string; pw: string;
} }
// ======================================================================================= // =======================================================================================
interface CreateResquest { interface CreateResquest {
p: number; p: number;
} }
/** 直接玩(訪客給SERVER創帳號) */ /** 直接玩(訪客給SERVER創帳號) */
export class AccountCreateRequest extends NetRequest<CreateResquest, CommonAccountResponse> { export class AccountCreateRequest extends NetRequest<CreateResquest, CommonAccountResponse> {
get Method(): string { get Method(): string {
return "account.create"; return "account.create";
} }
constructor() { constructor() {
super(); super();
this.Data = { this.Data = {
p: Config.GetRunDevice(), p: Config.GetRunDevice(),
}; };
} }
} }
// ======================================================================================= // =======================================================================================
interface LoginResquest { interface LoginResquest {
p: number; p: number;
device_info: string[]; device_info: string[];
fcm_token: string; d: string;
a: string; fcm_token: string;
pw: string; a: string;
ver: string; pw: string;
ver: string;
} }
interface LoginResponse { interface LoginResponse {
pr: string; pr: string;
cu: string; cu: string;
} }
/** 通用登入 */ /** 通用登入 */
export class AccountLoginRequest extends NetRequest<LoginResquest, LoginResponse> { export class AccountLoginRequest extends NetRequest<LoginResquest, LoginResponse> {
get Method(): string { get Method(): string {
return "account.login"; return "account.login";
} }
constructor(account: string, password: string) { constructor(account: string, password: string) {
super(); super();
this.Data = { this.Data = {
p: Config.GetRunDevice(), p: Config.GetRunDevice(),
device_info: ["Windows", "Windows"], device_info: ["Windows", "Windows"],
fcm_token: "", d: "JianMiau",
a: account, fcm_token: "",
pw: password, a: account,
ver: BusinessTypeSetting.COMPILE_VERSION pw: password,
}; ver: BusinessTypeSetting.COMPILE_VERSION
} };
}
} }
// ======================================================================================= // =======================================================================================
interface CustomResquest { interface CustomResquest {
a: string; a: string;
pw: string; pw: string;
} }
/** 自定帳號榜定 */ /** 自定帳號榜定 */
export class CustomBindRequest extends NetRequest<CustomResquest, null> { export class CustomBindRequest extends NetRequest<CustomResquest, null> {
get Method(): string { get Method(): string {
return "register.account_bind"; return "register.account_bind";
} }
constructor(account: string, password: string) { constructor(account: string, password: string) {
super(); super();
this.Data = { this.Data = {
a: account, a: account,
pw: password, pw: password,
}; };
} }
} }
/** 自定帳號登入(回傳SERVER帳號) */ /** 自定帳號登入(回傳SERVER帳號) */
export class CustomLoginRequest extends NetRequest<CustomResquest, CommonAccountResponse> { export class CustomLoginRequest extends NetRequest<CustomResquest, CommonAccountResponse> {
get Method(): string { get Method(): string {
return "register.account_login"; return "register.account_login";
} }
constructor(account: string, password: string) { constructor(account: string, password: string) {
super(); super();
this.Data = { this.Data = {
a: account, a: account,
pw: password, pw: password,
}; };
} }
} }
// ======================================================================================= // =======================================================================================
interface FBResquest { interface FBResquest {
t: string; t: string;
} }
/** FB綁定 */ /** FB綁定 */
export class FBBindRequest extends NetRequest<FBResquest, null> { export class FBBindRequest extends NetRequest<FBResquest, null> {
get Method(): string { get Method(): string {
return "register.fb_bind"; return "register.fb_bind";
} }
constructor(token: string) { constructor(token: string) {
super(); super();
this.Data = { this.Data = {
t: token, t: token,
}; };
} }
} }
/** FB登入(回傳SERVER帳號) */ /** FB登入(回傳SERVER帳號) */
export class FBLoginRequest extends NetRequest<FBResquest, CommonAccountResponse> { export class FBLoginRequest extends NetRequest<FBResquest, CommonAccountResponse> {
get Method(): string { get Method(): string {
return "register.fb_login"; return "register.fb_login";
} }
constructor(token: string) { constructor(token: string) {
super(); super();
this.Data = { this.Data = {
t: token, t: token,
}; };
} }
} }
// ======================================================================================= // =======================================================================================
interface GoogleResquest { interface GoogleResquest {
c: string; c: string;
} }
/** GOOGLE綁定 */ /** GOOGLE綁定 */
export class GoogleBindRequest extends NetRequest<GoogleResquest, null> { export class GoogleBindRequest extends NetRequest<GoogleResquest, null> {
get Method(): string { get Method(): string {
return "register.google_bind"; return "register.google_bind";
} }
constructor(token: string) { constructor(token: string) {
super(); super();
this.Data = { this.Data = {
c: token, c: token,
}; };
} }
} }
/** GOOGLE登入(回傳SERVER帳號) */ /** GOOGLE登入(回傳SERVER帳號) */
export class GoogleLoginRequest extends NetRequest<GoogleResquest, CommonAccountResponse> { export class GoogleLoginRequest extends NetRequest<GoogleResquest, CommonAccountResponse> {
get Method(): string { get Method(): string {
return "register.google_login"; return "register.google_login";
} }
constructor(token: string) { constructor(token: string) {
super(); super();
this.Data = { this.Data = {
c: token, c: token,
}; };
} }
} }
// ======================================================================================= // =======================================================================================
interface AppleResquest { interface AppleResquest {
c: string; c: string;
} }
/** APPEL綁定 */ /** APPEL綁定 */
export class AppleBindRequest extends NetRequest<AppleResquest, null> { export class AppleBindRequest extends NetRequest<AppleResquest, null> {
get Method(): string { get Method(): string {
return "register.apple_bind"; return "register.apple_bind";
} }
constructor(token: string) { constructor(token: string) {
super(); super();
this.Data = { this.Data = {
c: token, c: token,
}; };
} }
} }
/** APPLE登入(回傳SERVER帳號) */ /** APPLE登入(回傳SERVER帳號) */
export class AppleLoginRequest extends NetRequest<AppleResquest, CommonAccountResponse> { export class AppleLoginRequest extends NetRequest<AppleResquest, CommonAccountResponse> {
get Method(): string { get Method(): string {
return "register.apple_login"; return "register.apple_login";
} }
constructor(token: string) { constructor(token: string) {
super(); super();
this.Data = { this.Data = {
c: token, c: token,
}; };
} }
} }
// ======================================================================================= // =======================================================================================
/** 電話驗證 */ /** 電話驗證 */
export interface PhoneCodeRequest { export interface PhoneCodeRequest {
p: string; p: string;
} }
export class PhoneGet extends NetRequest<PhoneCodeRequest, string> { export class PhoneGet extends NetRequest<PhoneCodeRequest, string> {
get Method(): string { get Method(): string {
return "register.phone_code"; return "register.phone_code";
} }
constructor(p: string) { constructor(p: string) {
super(); super();
this.Data = { this.Data = {
p: p p: p
}; };
} }
} }
export interface PhoneBindRequest { export interface PhoneBindRequest {
c: string; c: string;
} }
export class PhoneBind extends NetRequest<PhoneBindRequest, string> { export class PhoneBind extends NetRequest<PhoneBindRequest, string> {
get Method(): string { get Method(): string {
return "register.phone_bind"; return "register.phone_bind";
} }
constructor(c: string) { constructor(c: string) {
super(); super();
this.Data = { this.Data = {
c: c c: c
}; };
} }
} }
// ======================================================================================= // =======================================================================================
/** 旗標更新 */ /** 旗標更新 */
export class FlagOpenAdd extends NetRequest<number, string> { export class FlagOpenAdd extends NetRequest<number, string> {
get Method(): string { get Method(): string {
return "flag.open_add"; return "flag.open_add";
} }
constructor(type: number) { constructor(type: number) {
super(); super();
this.Data = type; this.Data = type;
} }
} }
// ======================================================================================== // ========================================================================================
export interface ForgotInfo { export interface ForgotInfo {
a: string; a: string;
p: string; p: string;
} }
/** 忘記密碼 */ /** 忘記密碼 */
export class ForgotPassword extends NetRequest<ForgotInfo, null> { export class ForgotPassword extends NetRequest<ForgotInfo, null> {
get Method(): string { get Method(): string {
return "register.account_forget"; return "register.account_forget";
} }
constructor(account: string, phone: string) { constructor(account: string, phone: string) {
super(); super();
this.Data = { this.Data = {
a: account, a: account,
p: phone, p: phone,
}; };
} }
} }

View 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();
}
}

View 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,
}
}

View File

@ -1,29 +1,29 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "esnext", "target": "esnext",
"useDefineForClassFields": true, "useDefineForClassFields": true,
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"strict": true, // "strict": true,
"jsx": "preserve", "jsx": "preserve",
"sourceMap": true, "sourceMap": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": false, "isolatedModules": false,
"esModuleInterop": true, "esModuleInterop": true,
"lib": [ "lib": [
"esnext", "esnext",
"dom" "dom"
] ]
}, },
"include": [ "include": [
"src/**/*.ts", "src/**/*.ts",
"src/**/*.d.ts", "src/**/*.d.ts",
"src/**/*.tsx", "src/**/*.tsx",
"src/**/*.vue" "src/**/*.vue"
], ],
"references": [ "references": [
{ {
"path": "./tsconfig.node.json" "path": "./tsconfig.node.json"
} }
] ]
} }

View File

@ -3,10 +3,10 @@ import { defineConfig } from "vite";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
base: "./", base: "./",
plugins: [vue()], plugins: [vue()],
build: { build: {
// 輸出路徑 // 輸出路徑
outDir: "./public", outDir: "./public",
}, },
}); });