[add] first
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"recommendations": ["johnsoncodehk.volar"]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
# Vue 3 + Typescript + Vite
|
||||
|
||||
This template should help get you started developing with Vue 3 and Typescript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
||||
|
||||
## Recommended IDE Setup
|
||||
|
||||
- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar)
|
||||
|
||||
## Type Support For `.vue` Imports in TS
|
||||
|
||||
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:
|
||||
|
||||
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
|
||||
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
|
||||
|
||||
You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<!-- <link href="./src/assets/style.css" rel="stylesheet" type="text/css" /> -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite App</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Generated
+2771
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "bj-casino-rank",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vue-tsc --noEmit && vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/icons-vue": "^6.1.0",
|
||||
"axios": "^0.26.1",
|
||||
"vue": "^3.2.25"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^2.3.0",
|
||||
"typescript": "^4.5.4",
|
||||
"vite": "^2.9.0",
|
||||
"vue-tsc": "^0.29.8"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 264 KiB |
+20
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import BJ_Casino_Rank from './components/BJ_Casino_Rank.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<BJ_Casino_Rank />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
#app {
|
||||
font-family: Avenir, Helvetica, Arial, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
text-align: center;
|
||||
color: #2c3e50;
|
||||
margin-top: 60px;
|
||||
}
|
||||
</style>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
@@ -0,0 +1,37 @@
|
||||
.main {
|
||||
width: 80%;
|
||||
margin: 20px auto;
|
||||
}
|
||||
table {
|
||||
border-spacing: 0;
|
||||
width: 100%;
|
||||
}
|
||||
tr {
|
||||
text-align: center;
|
||||
}
|
||||
th {
|
||||
padding: 10px;
|
||||
}
|
||||
table tbody tr:nth-child(odd){
|
||||
background-color: #eee
|
||||
}
|
||||
table thead {
|
||||
background-color: blue;
|
||||
color: white;
|
||||
}
|
||||
table thead th:first-child {
|
||||
border-radius: 5px 0 0 0;
|
||||
border: 1px solid blue;
|
||||
}
|
||||
table thead th:last-child {
|
||||
border-radius: 0 5px 0 0;
|
||||
border-right: 1px solid blue;
|
||||
}
|
||||
table tbody tr:last-child td:first-child {
|
||||
border-radius: 0 0 0 5px;
|
||||
}
|
||||
|
||||
table tbody tr:last-child td:last-child {
|
||||
border-radius: 0 0 5px 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import '../assets/style.css';
|
||||
import { BJ_Casino_Rank } from "../script/BJ_Casino_Rank";
|
||||
|
||||
let div_Main = ref(null);
|
||||
const self = {
|
||||
div_Main: div_Main
|
||||
}
|
||||
const Script = new BJ_Casino_Rank(self);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div ref="div_Main"></div>
|
||||
</template>
|
||||
@@ -0,0 +1,58 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { HelloWorld } from "../script/HelloWorld";
|
||||
|
||||
const self = {
|
||||
msg: ref('Hello Vue 3 + TypeScript'),
|
||||
count: ref(0),
|
||||
}
|
||||
const HW = new HelloWorld(self);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>{{ self.msg.value }}</h1>
|
||||
<button @click="HW.HandleChangeString">handleChangeString</button>
|
||||
|
||||
<p>
|
||||
Recommended IDE setup:
|
||||
<a href="https://code.visualstudio.com/" target="_blank">VSCode</a>
|
||||
+
|
||||
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
See
|
||||
<code>README.md</code> for more information.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="https://vitejs.dev/guide/features.html" target="_blank">Vite Docs</a>
|
||||
|
|
||||
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Docs</a>
|
||||
</p>
|
||||
count is: {{ self.count }}
|
||||
<br />
|
||||
<button type="button" @click="HW.AddCount">AddCount</button>
|
||||
<p>
|
||||
Edit
|
||||
<code>components/HelloWorld.vue</code> to test hot module replacement.
|
||||
</p>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
|
||||
label {
|
||||
margin: 0 0.5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
code {
|
||||
background-color: #eee;
|
||||
padding: 2px 4px;
|
||||
border-radius: 4px;
|
||||
color: #304455;
|
||||
}
|
||||
</style>
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
declare module '*.vue' {
|
||||
import type { DefineComponent } from 'vue'
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
|
||||
const component: DefineComponent<{}, {}, any>
|
||||
export default component
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
|
||||
createApp(App).mount('#app')
|
||||
@@ -0,0 +1,291 @@
|
||||
export class BJ_Casino_Rank {
|
||||
|
||||
//#region private
|
||||
|
||||
private _client: any;
|
||||
|
||||
private _ws: any;
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Lifecycle
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
constructor(client: any) {
|
||||
this._client = client;
|
||||
this.onLoad();
|
||||
}
|
||||
|
||||
public onLoad() {
|
||||
let self: this = this;
|
||||
try {
|
||||
// const URL = document.getElementById("URL").value;
|
||||
// const Port = document.getElementById("Port").value;
|
||||
|
||||
const URL = "wss://game.online-bj.com";
|
||||
const Port = "9005";
|
||||
const Account = { "p": 0, "device_info": ["Windows", "Windows"], "fcm_token": "", "a": "ct00000691", "pw": "4lsAyoalajm7", "ver": "1.3.0" };
|
||||
|
||||
// const URL = "ws://192.168.5.12";
|
||||
// const Port = "9487";
|
||||
|
||||
// const URL = "ws://220.134.195.1";
|
||||
// const Port = "19005";
|
||||
// const Account = { "p": 0, "device_info": ["Windows", "Windows"], "fcm_token": "", "a": "ct00002242", "pw": "n0tfHlVuEhpO", "ver": "1.3.0" };
|
||||
if (this._ws) {
|
||||
this.AddLog("中斷上一個連線");
|
||||
this._ws.close();
|
||||
}
|
||||
this._ws = new WebSocket(`${URL}:${Port}`);//连接服务器
|
||||
|
||||
//连接websocket
|
||||
this._ws.onopen = function (event: any, AlarmMessage: any) {
|
||||
self.AddLog("已經與服務器建立了連接,當前連接狀態:" + this.readyState);
|
||||
self.SendData("account.login", Account);
|
||||
};
|
||||
|
||||
//websocket传输数据
|
||||
this._ws.onmessage = this.OnWebSocketMessage.bind(this);
|
||||
|
||||
//websocket关闭连接
|
||||
this._ws.onclose = function (event: any) {
|
||||
self.AddLog("已經與服務器斷開連接,當前連接狀態:" + this.readyState);
|
||||
// let document = parent ? parent.document : document;
|
||||
// document.title = `已斷線`;
|
||||
};
|
||||
|
||||
//websocket连接异常
|
||||
this._ws.onerror = function (event: any) {
|
||||
// alert("WebSocket异常!");
|
||||
self.AddLog("WebSocket異常!");
|
||||
};
|
||||
} catch (ex) {
|
||||
// alert(ex.message);
|
||||
this.AddLog(ex);
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Custom
|
||||
|
||||
public SendData(Method: string, Data: any) {
|
||||
let json = [Method];
|
||||
if (Data != null && Data != undefined) {
|
||||
json[1] = Data;
|
||||
}
|
||||
|
||||
let str = JSON.stringify(json);
|
||||
if (str.length > 65535) {
|
||||
this.AddLog("要傳的資料太大囉");
|
||||
throw new Error('要傳的資料太大囉');
|
||||
}
|
||||
|
||||
if (Data != null && Data != undefined) {
|
||||
this.AddLog(`[RPC] 傳送server資料: ${Method}(${JSON.stringify(Data).replace(/\\/g, "")})`);
|
||||
} else {
|
||||
this.AddLog(`[RPC] 傳送server資料: ${Method}()`);
|
||||
}
|
||||
|
||||
let strary = this.GetBytes(str);
|
||||
let buffer = new Uint8Array(4 + strary.byteLength);
|
||||
let u16ary = new Uint16Array(buffer.buffer, 0, 3);
|
||||
u16ary[0] = strary.byteLength;
|
||||
buffer[3] = 0x01;
|
||||
buffer.set(strary, 4);
|
||||
this._ws.send(buffer);
|
||||
}
|
||||
|
||||
public ResData(Status: any, Method: any, Data: any = null) {
|
||||
// let document = parent ? parent.document : document;
|
||||
switch (Method) {
|
||||
case "account.login": {
|
||||
this.SendData("rank.info", { "t": 12, "p": 2 });
|
||||
break;
|
||||
}
|
||||
|
||||
case "rank.info": {
|
||||
this.SetData(Data);
|
||||
this._ws.close();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public SetData(data: any) {
|
||||
let rankdata = data["rank"];
|
||||
// let div_Main = document.getElementById("div_Main");
|
||||
let div_Main = this._client.div_Main;
|
||||
let div_main_s = "";
|
||||
div_main_s += `
|
||||
<table>
|
||||
<thead>
|
||||
`;
|
||||
div_main_s += `<th>排名</th>`;
|
||||
div_main_s += `<th>名稱</th>`;
|
||||
div_main_s += `<th>倍率</th>`;
|
||||
div_main_s += `<th>機台</th>`;
|
||||
div_main_s += `<th>桌號</th>`;
|
||||
div_main_s += `</thead>`;
|
||||
for (let i = 0; i < rankdata.length; i++) {
|
||||
const data = rankdata[i];
|
||||
const rank = data[0];
|
||||
const magnification = Math.floor(data[1]);
|
||||
const name = data[2][1];
|
||||
const slot = data[3][0];
|
||||
const table = data[3][1];
|
||||
div_main_s += `
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><font size="5"><b>${rank}</b></font></td>
|
||||
<td><font size="5"><b>${name}</b></font></td>
|
||||
<td><font size="5"><b>${magnification}</b></font></td>
|
||||
<td><font size="5"><b>${slot}</b></font></td>
|
||||
<td><font size="5"><b>${table}</b></font></td>
|
||||
<tr>
|
||||
</tbody>
|
||||
`;
|
||||
}
|
||||
div_main_s += `</table>`;
|
||||
div_Main.value.innerHTML = div_main_s;
|
||||
}
|
||||
|
||||
//#region WebSocke
|
||||
|
||||
public OnWebSocketMessage(e: any) {
|
||||
let self: this = this;
|
||||
if (e.data instanceof ArrayBuffer) {
|
||||
this.ParseRpcMessage(e.data);
|
||||
} else if (e.data instanceof Blob) {
|
||||
let reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
self.ParseRpcMessage(reader.result); reader.onload = null;
|
||||
}
|
||||
reader.readAsArrayBuffer(e.data);
|
||||
} else {
|
||||
this.AddLog(`未知的OnWebSocketMessage(e.data)類型: ${e.data}`);
|
||||
throw new Error(`未知的OnWebSocketMessage(e.data)類型: ${e.data}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ParseRpcMessage(buffer: any) {
|
||||
let startIndex = 0, byteLength = buffer.byteLength;
|
||||
while (startIndex + 4 < byteLength) {
|
||||
let strlen = new DataView(buffer, startIndex, 3).getUint16(0, true);
|
||||
let str = this.GetString(new Uint8Array(buffer, startIndex + 4, strlen));
|
||||
startIndex += strlen + 4;
|
||||
|
||||
try {
|
||||
let json = JSON.parse(str);
|
||||
let method = json[0];
|
||||
let status = json[1][0];
|
||||
let data = json[1][1];
|
||||
|
||||
let resp = {
|
||||
Method: method,
|
||||
Status: status,
|
||||
Data: data,
|
||||
IsValid: method && status === 0
|
||||
};
|
||||
|
||||
if (data) {
|
||||
this.AddLog(`[RPC] 收到server呼叫:(${resp.Status}): ${resp.Method}(${JSON.stringify(resp.Data)})`);
|
||||
this.ResData(resp.Status, resp.Method, resp.Data);
|
||||
} else {
|
||||
this.AddLog(`[RPC] 收到server呼叫:(${resp.Status}): ${resp.Method}()`);
|
||||
this.ResData(resp.Status, resp.Method);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
this.AddLog(`[RPC] 無法解析Server回應: ${str}`);
|
||||
throw new Error(`[RPC] 無法解析Server回應: ${str}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public seestate() {
|
||||
// alert(ws.readyState);
|
||||
this.AddLog(this._ws.readyState);
|
||||
}
|
||||
|
||||
public AddLog(log: any) {
|
||||
console.log(log);
|
||||
// var textarea = document.getElementById("Log");
|
||||
// textarea.value += log + "\n";
|
||||
// textarea.scrollTop = textarea.scrollHeight;
|
||||
}
|
||||
|
||||
public GetBytes(str: any) {
|
||||
let len = str.length, resPos = -1;
|
||||
let resArr = new Uint8Array(len * 3);
|
||||
for (let point = 0, nextcode = 0, i = 0; i !== len;) {
|
||||
point = str.charCodeAt(i), i += 1;
|
||||
if (point >= 0xD800 && point <= 0xDBFF) {
|
||||
if (i === len) {
|
||||
resArr[resPos += 1] = 0xef;
|
||||
resArr[resPos += 1] = 0xbf;
|
||||
resArr[resPos += 1] = 0xbd;
|
||||
break;
|
||||
}
|
||||
|
||||
nextcode = str.charCodeAt(i);
|
||||
if (nextcode >= 0xDC00 && nextcode <= 0xDFFF) {
|
||||
point = (point - 0xD800) * 0x400 + nextcode - 0xDC00 + 0x10000;
|
||||
i += 1;
|
||||
if (point > 0xffff) {
|
||||
resArr[resPos += 1] = (0x1e << 3) | (point >>> 18);
|
||||
resArr[resPos += 1] = (0x2 << 6) | ((point >>> 12) & 0x3f);
|
||||
resArr[resPos += 1] = (0x2 << 6) | ((point >>> 6) & 0x3f);
|
||||
resArr[resPos += 1] = (0x2 << 6) | (point & 0x3f);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
resArr[resPos += 1] = 0xef;
|
||||
resArr[resPos += 1] = 0xbf;
|
||||
resArr[resPos += 1] = 0xbd;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (point <= 0x007f) {
|
||||
resArr[resPos += 1] = (0x0 << 7) | point;
|
||||
} else if (point <= 0x07ff) {
|
||||
resArr[resPos += 1] = (0x6 << 5) | (point >>> 6);
|
||||
resArr[resPos += 1] = (0x2 << 6) | (point & 0x3f);
|
||||
} else {
|
||||
resArr[resPos += 1] = (0xe << 4) | (point >>> 12);
|
||||
resArr[resPos += 1] = (0x2 << 6) | ((point >>> 6) & 0x3f);
|
||||
resArr[resPos += 1] = (0x2 << 6) | (point & 0x3f);
|
||||
}
|
||||
}
|
||||
return resArr.subarray(0, resPos + 1);
|
||||
}
|
||||
|
||||
public GetString(array: any) {
|
||||
let str = "";
|
||||
let i = 0, len = array.length;
|
||||
while (i < len) {
|
||||
let c = array[i++];
|
||||
switch (c >> 4) {
|
||||
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
|
||||
str += String.fromCharCode(c);
|
||||
break;
|
||||
case 12: case 13:
|
||||
str += String.fromCharCode(((c & 0x1F) << 6) | (array[i++] & 0x3F));
|
||||
break;
|
||||
case 14:
|
||||
str += String.fromCharCode(((c & 0x0F) << 12) | ((array[i++] & 0x3F) << 6) | ((array[i++] & 0x3F) << 0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
export class HelloWorld {
|
||||
|
||||
//#region private
|
||||
|
||||
private _client: any;
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Lifecycle
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
constructor(client: any) {
|
||||
this._client = client;
|
||||
}
|
||||
|
||||
public HandleChangeString() {
|
||||
this._client.msg.value = "ChangeString HelloWorld";
|
||||
}
|
||||
|
||||
public AddCount() {
|
||||
this._client.count.value++;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
"jsx": "preserve",
|
||||
"sourceMap": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": false,
|
||||
"esModuleInterop": true,
|
||||
"lib": [
|
||||
"esnext",
|
||||
"dom"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.d.ts",
|
||||
"src/**/*.tsx",
|
||||
"src/**/*.vue"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.node.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node"
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { defineConfig } from 'vite'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
base: "./",
|
||||
plugins: [vue()]
|
||||
})
|
||||
Reference in New Issue
Block a user