[add] exe

This commit is contained in:
2024-08-30 15:56:28 +08:00
parent 0271674764
commit 3b84cd0511
78 changed files with 25 additions and 5580 deletions
-3
View File
@@ -1,3 +0,0 @@
/dist
/node_modules
/release
-20
View File
@@ -1,20 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Main Process",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
},
"args": ["."],
"outputCapture": "std",
"sourceMaps": true,
"restart": true
}
]
}
-20
View File
@@ -1,20 +0,0 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "npm: build",
"type": "shell",
"command": "npm",
"args": ["run", "build"],
"problemMatcher": []
},
{
"label": "npm: start",
"type": "shell",
"command": "npm",
"args": ["start"],
"problemMatcher": []
}
]
}
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
-10
View File
@@ -1,10 +0,0 @@
{
"watch": [
"src"
],
"ext": "ts",
"exec": "npm run build",
"ignore": [
"dist"
]
}
-5233
View File
File diff suppressed because it is too large Load Diff
-51
View File
@@ -1,51 +0,0 @@
{
"name": "sdserver",
"version": "1.0.0",
"main": "dist/main.js",
"scripts": {
"start": "electron .",
"build": "tsc && copyfiles -u 1 src/index.html dist/",
"pack": "electron-packager . SDServer --platform=win32 --arch=x64 --out=dist/",
"buildexe": "npx electron-builder",
"watch": "nodemon"
},
"build": {
"appId": "SDServer",
"files": [
"dist/**/*",
"node_modules/**/*",
"package.json"
],
"directories": {
"output": "release"
}
},
"dependencies": {
"ws": "^8.18.0"
},
"devDependencies": {
"@types/electron": "^1.6.10",
"@types/node": "^22.5.0",
"@types/ws": "^8.5.12",
"copyfiles": "^2.4.1",
"electron": "^32.0.1",
"electron-builder": "^24.7.0",
"electron-packager": "^17.1.2",
"nodemon": "^3.1.4",
"ts-node": "^10.9.2",
"typescript": "^5.5.4"
},
"bin": "dist/server.js",
"pkg": {
"assets": [
"public/**/*"
],
"outputPath": "executables",
"targets": [
"node18-win-x64"
]
},
"author": "",
"license": "ISC",
"description": ""
}
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
+25
View File
@@ -0,0 +1,25 @@
{
"slotData": [
{"slot":[11,4,8,9,5,2,13,10,7,9,10,6,6,12,4],"line":[[[5,11,12],161,200]]},
{"slot":[9,6,2,5,4,14,10,9,13,10,4,5,5,2,2]},
{"slot":[4,3,3,3,9,10,14,14,9,4,7,8,8,5,10],"free":[[1,2,3],3],"scatter":[[[1,2,3],300]]},
{"slot":[1,2,4,5,6,7,3,3,3,8,9,10,11,12,13],"free":[[6,7,8],10],"scatter":[[[6,7,8],300]]}
],
"slotFreeData": [
{"slot":[9,9,10,13,4,5,4,3,4,11,10,14,14,14,5]},
{"slot":[12,6,8,12,11,7,12,11,5,5,11,5,3,10,9]},
{"slot":[4,6,11,13,8,12,12,3,4,10,7,5,14,14,4]},
{"slot":[12,11,9,14,6,7,2,3,8,8,11,10,10,7,14]},
{"slot":[9,14,13,4,11,4,7,6,14,6,12,13,9,12,12]},
{"slot":[10,3,12,13,5,6,4,8,4,9,13,14,11,14,4]},
{"slot":[11,13,9,8,5,8,5,5,13,9,14,9,12,4,7]},
{"slot":[10,14,13,9,8,6,6,6,4,13,13,12,9,14,4],"line":[[[5,6,7],122,300]]},
{"slot":[13,9,5,14,4,9,4,12,12,11,4,14,8,7,6],"line":[[[10,6],195,300],[[10,6],213,300]]},
{"slot":[5,9,9,3,11,10,4,5,12,5,4,14,12,5,9],"line":[[[10,6],195,300],[[10,6],213,300]]},
{"slot":[2,8,13,2,10,9,12,5,11,4,5,2,12,5,8],"line":[[[0,6,12],49,150],[[0,11,2],61,150],[[0,11,7,13],70,3000],[[0,11,12],79,150],[[10,11,7,13],234,3000]]},
{"slot":[5,12,13,3,4,10,2,5,8,8,2,9,12,10,9],"line":[[[10,1,12],183,150],[[10,6,2],195,150],[[10,6,12],213,150]]},
{"slot":[14,4,10,3,11,5,14,3,12,6,10,6,14,5,12],"line":[[[0,6,12],49,750]],"scatter":[[[3,7],300]]},
{"slot":[6,3,12,4,8,14,10,3,7,9,10,4,10,6,7],"line":[[[10,6,12],213,75]],"scatter":[[[1,7],300]]},
{"slot":[9,12,3,7,2,6,13,11,3,11,13,3,8,6,6],"free":[[2,8,11],10],"scatter":[[[2,8,11],900]]}
]
}
-9
View File
@@ -1,9 +0,0 @@
// src/global.d.ts
interface Window {
electron: {
startWebSocket: (port: number) => void;
stopWebSocket: () => void;
openDevTools: () => void;
onWebSocketStatus: (callback: (message: string) => void) => void;
};
}
-33
View File
@@ -1,33 +0,0 @@
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<title>WebSocket Control</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
button {
margin: 5px;
}
</style>
</head>
<body>
<h1>SD Server Control</h1>
<label for="port">Port:</label>
<input type="number" id="port" value="8080">
<button id="startBtn">Start WebSocket Server</button>
<button id="stopBtn">Stop WebSocket Server</button>
<button id="devToolsBtn">Open DevTools</button>
<p id="status">Status: Waiting for actions...</p>
<script src="renderer.js"></script>
</body>
</html>
-96
View File
@@ -1,96 +0,0 @@
// src/main.ts
import { app, BrowserWindow, ipcMain } from 'electron';
import * as path from 'path';
import { WebSocketServer } from 'ws';
let server: WebSocketServer | null = null;
let port = 8080; // 默认端口
function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true,
nodeIntegration: false,
// contextIsolation: false, // 使渲染進程能夠使用 Node.js
// nodeIntegration: true, // 使渲染進程可以使用 Node.js 模組
},
});
win.loadFile(path.join(__dirname, 'index.html'));
win.webContents.openDevTools();
return win;
}
let mainWindow: BrowserWindow | null = null;
app.whenReady().then(() => {
mainWindow = createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
// 启动 WebSocket 服务器
ipcMain.on('start-websocket', (event, portNumber: number) => {
if (server) {
server.close();
}
port = portNumber || 8080;
server = new WebSocketServer({ port: port });
server.on('connection', (socket) => {
console.log(`WebSocket server started on port ${port}`);
socket.send('Welcome to the WebSocket server');
socket.on('message', (message: string) => {
console.log(`Received message: ${message}`);
socket.send(`Server received your message: ${message}`);
});
socket.on('close', () => {
console.log('Client disconnected');
});
});
event.reply('websocket-status', `WebSocket server started on port ${port} 88`);
});
// 关闭 WebSocket 服务器
ipcMain.on('stop-websocket', (event) => {
if (server) {
server.clients.forEach(client => {
if (client.readyState === 1) {
client.close();
}
});
server.close((err) => {
if (err) {
event.reply('websocket-status', 'Failed to stop WebSocket server');
} else {
event.reply('websocket-status', 'WebSocket server stopped');
}
});
} else {
event.reply('websocket-status', 'No WebSocket server is running');
}
});
// 打开开发者工具
ipcMain.on('open-devtools', () => {
mainWindow.webContents.openDevTools();
});
-9
View File
@@ -1,9 +0,0 @@
// src/preload.ts
import { contextBridge, ipcRenderer } from 'electron';
contextBridge.exposeInMainWorld('electron', {
startWebSocket: (port: number) => ipcRenderer.send('start-websocket', port),
stopWebSocket: () => ipcRenderer.send('stop-websocket'),
openDevTools: () => ipcRenderer.send('open-devtools'),
onWebSocketStatus: (callback: (message: string) => void) => ipcRenderer.on('websocket-status', (event, message) => callback(message))
});
-51
View File
@@ -1,51 +0,0 @@
document.getElementById('startBtn')?.addEventListener('click', () => {
// console.log('Start WebSocket button clicked');
const portElement = document.getElementById('port') as HTMLInputElement;
const port = parseInt(portElement.value, 10);
window.electron.startWebSocket(port);
});
document.getElementById('stopBtn')?.addEventListener('click', () => {
// console.log('Stop WebSocket button clicked');
window.electron.stopWebSocket();
});
document.getElementById('devToolsBtn')?.addEventListener('click', () => {
// console.log('Open DevTools button clicked');
window.electron.openDevTools();
});
window.electron.onWebSocketStatus((message: string) => {
console.log(`WebSocket status: ${message}`);
const statusElement = document.getElementById('status');
if (statusElement) {
statusElement.innerText = `Status: ${message}`;
}
});
// document.getElementById('startBtn')?.addEventListener('click', () => {
// // console.log('Start WebSocket button clicked');
// const portElement = document.getElementById('port') as HTMLInputElement;
// const port = parseInt(portElement.value, 10);
// ipcRenderer.send('start-websocket', port);
// });
// document.getElementById('stopBtn')?.addEventListener('click', () => {
// // console.log('Stop WebSocket button clicked');
// ipcRenderer.send('stop-websocket');
// });
// document.getElementById('devToolsBtn')?.addEventListener('click', () => {
// // console.log('Open DevTools button clicked');
// ipcRenderer.send('open-devtools');
// });
// function onWebSocketStatus(callback: (message: string) => void) {
// ipcRenderer.on('websocket-status', (event, message) => callback(message));
// }
// // 監聽 WebSocket 狀態
// onWebSocketStatus((message) => {
// console.log('WebSocket status:', message);
// });
-25
View File
@@ -1,25 +0,0 @@
import WebSocket, { WebSocketServer } from 'ws';
const server = new WebSocketServer({ port: 8080 });
server.on('connection', (socket: WebSocket) => {
console.log('客户端已连接');
// 发送消息到客户端
socket.send('欢迎连接到WebSocket服务器');
// 接收来自客户端的消息
socket.on('message', (message: string) => {
console.log(`收到客户端消息: ${message}`);
// 回应消息
socket.send(`服务器收到你的消息: ${message}`);
});
// 处理客户端断开连接
socket.on('close', () => {
console.log('客户端已断开连接');
});
});
console.log('WebSocket服务器运行在 ws://localhost:8080');
-20
View File
@@ -1,20 +0,0 @@
{
"compilerOptions": {
"target": "ES2020", // 设置 ECMAScript 版本
"module": "CommonJS", // 使用 CommonJS 模块系统
"sourceMap": true,
"strict": false, // 启用严格模式
"esModuleInterop": true, // 启用 ES 模块的兼容性
"skipLibCheck": true, // 跳过库的类型检查
"forceConsistentCasingInFileNames": true,
"paths": {
"@/*": [
"./src/*"
]
},
"outDir": "./dist",
"rootDir": "./src",
},
"include": ["src/**/*"] // 包含 src 目录下的所有文件
}
Binary file not shown.