init: initial commit

This commit is contained in:
Blizzard
2026-04-10 13:49:04 +08:00
commit 7b1588e2ff
56 changed files with 5499 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title>Betting-Assistant</title>
</head>
<body>
<div id="root"></div>
<script src="./src/main.tsx" type="module"></script>
</body>
</html>
+1430
View File
File diff suppressed because it is too large Load Diff
+22
View File
@@ -0,0 +1,22 @@
{
"name": "frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@vitejs/plugin-react": "^2.0.1",
"typescript": "^4.6.4",
"vite": "^3.0.7"
}
}
+1
View File
@@ -0,0 +1 @@
f26173c7304a0bf8ea5c86eb567e7db2
+116
View File
@@ -0,0 +1,116 @@
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');
:root {
/* Background layers */
--bg-primary: #070b14;
--bg-secondary: #0d1117;
--bg-card: #111827;
--bg-card-hover: #1a2235;
--bg-input: #0d1321;
--bg-sidebar: #0a0f1a;
/* Border */
--border-color: #1e293b;
--border-subtle: #162032;
/* Text */
--text-primary: #e2e8f0;
--text-secondary: #94a3b8;
--text-muted: #64748b;
--text-dim: #475569;
/* Accent */
--accent-blue: #3b82f6;
--accent-blue-hover: #2563eb;
--accent-blue-glow: rgba(59, 130, 246, 0.25);
/* Status */
--status-success: #22c55e;
--status-error: #ef4444;
--status-warn: #f59e0b;
/* Method colors */
--method-get: #22c55e;
--method-post: #3b82f6;
--method-put: #f59e0b;
--method-delete: #ef4444;
/* Sizing */
--sidebar-width: 180px;
--header-height: 56px;
--radius-sm: 6px;
--radius-md: 10px;
--radius-lg: 14px;
/* Shadows */
--shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
--shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
/* Transitions */
--transition-fast: 150ms ease;
--transition-normal: 250ms ease;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body, #root {
height: 100%;
width: 100%;
overflow: hidden;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
background: var(--bg-primary);
color: var(--text-primary);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* Scrollbar */
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: var(--border-color);
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--text-dim);
}
/* App Layout */
.app-layout {
display: flex;
height: 100vh;
width: 100vw;
}
.main-content {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
background: var(--bg-primary);
}
.content-area {
flex: 1;
overflow-y: auto;
padding: 24px 28px;
display: flex;
flex-direction: column;
gap: 20px;
}
/* Utility */
.mono {
font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
+155
View File
@@ -0,0 +1,155 @@
import { useState, useEffect } from 'react';
import './App.css';
import Sidebar from './components/Sidebar';
import Header from './components/Header';
import ConfigCard from './components/ConfigCard';
import XRayViewer from './components/XRayViewer';
import FloatingButton from './components/FloatingButton';
import AddGameModal from './components/AddGameModal';
import { Game } from './types';
import {
GetAllGames,
GetActiveGameID,
SetActiveGame,
AddGame,
UpdateGame,
DeleteGame,
TestConnection,
XRayConnection,
} from '../wailsjs/go/main/App';
function App() {
const [games, setGames] = useState<Game[]>([]);
const [activeGameId, setActiveGameId] = useState('');
const [showAddModal, setShowAddModal] = useState(false);
// X-Ray State
const [xrayData, setXrayData] = useState<string | null>(null);
const [xrayError, setXrayError] = useState<string | null>(null);
const [xrayLoading, setXrayLoading] = useState(false);
const [xrayLatency, setXrayLatency] = useState(0);
// Track local edits for the active game config
const [editGame, setEditGame] = useState<Game | null>(null);
const activeGame = games.find((g) => g.id === activeGameId) || null;
// Load data on mount
useEffect(() => {
Promise.all([GetAllGames(), GetActiveGameID()]).then(
([g, id]) => {
setGames(g || []);
setActiveGameId(id || '');
}
);
}, []);
// Sync editGame when active game changes
useEffect(() => {
setEditGame(activeGame ? { ...activeGame } : null);
// Reset X-Ray when switching games
setXrayData(null);
setXrayError(null);
setXrayLatency(0);
}, [activeGameId, games]);
const handleSelectGame = async (id: string) => {
setActiveGameId(id);
await SetActiveGame(id);
};
const handleAddGame = async (g: Omit<Game, 'id'>) => {
const newGame = await AddGame(g as Game);
setGames((prev) => [...prev, newGame]);
setActiveGameId(newGame.id);
await SetActiveGame(newGame.id);
setShowAddModal(false);
};
const handleDeleteGame = async (id: string) => {
await DeleteGame(id);
setGames((prev) => prev.filter((g) => g.id !== id));
if (activeGameId === id) {
const remaining = games.filter((g) => g.id !== id);
const newId = remaining.length > 0 ? remaining[0].id : '';
setActiveGameId(newId);
if (newId) await SetActiveGame(newId);
}
};
const handleSave = async () => {
if (!editGame) return;
await UpdateGame(editGame);
setGames((prev) =>
prev.map((g) => (g.id === editGame.id ? editGame : g))
);
};
const handleTest = async () => {
if (!editGame) throw new Error('No game');
return await TestConnection(editGame);
};
const handleXRay = async () => {
if (!editGame) return;
setXrayLoading(true);
setXrayError(null);
setXrayData(null);
try {
const res = await XRayConnection(editGame);
setXrayLatency(res.latency);
if (res.success) {
setXrayData(res.body);
} else {
setXrayError(res.error || '请求失败');
}
} catch (e: any) {
setXrayError(e.message || '系统错误');
} finally {
setXrayLoading(false);
}
};
const title = activeGame
? `控制中心 — ${activeGame.name}`
: '控制中心';
return (
<div className="app-layout">
<Sidebar
games={games}
activeGameId={activeGameId}
onSelectGame={handleSelectGame}
onAddGame={() => setShowAddModal(true)}
onDeleteGame={handleDeleteGame}
/>
<div className="main-content">
<Header title={title} />
<div className="content-area">
<ConfigCard
game={editGame}
onGameUpdate={setEditGame}
onSave={handleSave}
onTest={handleTest}
onXRay={handleXRay}
/>
<XRayViewer
data={xrayData}
error={xrayError}
loading={xrayLoading}
latency={xrayLatency}
/>
</div>
</div>
<FloatingButton />
<AddGameModal
open={showAddModal}
onClose={() => setShowAddModal(false)}
onAdd={handleAddGame}
/>
</div>
);
}
export default App;
+93
View File
@@ -0,0 +1,93 @@
Copyright 2016 The Nunito Project Authors (contact@sansoxygen.com),
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

+142
View File
@@ -0,0 +1,142 @@
.modal-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.6);
backdrop-filter: blur(4px);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.modal-card {
background: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: var(--radius-lg);
width: 460px;
max-width: 90vw;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
animation: slideUp 0.25s ease;
}
@keyframes slideUp {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
.modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 18px 22px;
border-bottom: 1px solid var(--border-subtle);
}
.modal-header h3 {
font-size: 15px;
font-weight: 600;
color: var(--text-primary);
}
.modal-close {
width: 28px;
height: 28px;
display: flex;
align-items: center;
justify-content: center;
background: transparent;
border: none;
color: var(--text-muted);
font-size: 20px;
cursor: pointer;
border-radius: 4px;
transition: all var(--transition-fast);
}
.modal-close:hover {
background: rgba(255, 255, 255, 0.06);
color: var(--text-primary);
}
.modal-body {
padding: 20px 22px;
display: flex;
flex-direction: column;
gap: 16px;
}
.modal-field {
display: flex;
flex-direction: column;
gap: 6px;
}
.modal-field label {
font-size: 12px;
font-weight: 500;
color: var(--text-secondary);
}
.modal-field input {
background: var(--bg-input);
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
padding: 10px 12px;
color: var(--text-primary);
font-size: 13px;
font-family: inherit;
outline: none;
transition: border-color var(--transition-fast);
}
.modal-field input:focus {
border-color: var(--accent-blue);
box-shadow: 0 0 0 2px var(--accent-blue-glow);
}
.modal-field input::placeholder {
color: var(--text-dim);
}
.icon-grid {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.icon-option {
width: 36px;
height: 36px;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
border: 1px solid var(--border-color);
background: var(--bg-input);
border-radius: var(--radius-sm);
cursor: pointer;
transition: all var(--transition-fast);
}
.icon-option:hover {
border-color: var(--text-muted);
}
.icon-option.selected {
border-color: var(--accent-blue);
background: rgba(59, 130, 246, 0.12);
box-shadow: 0 0 0 2px var(--accent-blue-glow);
}
.modal-actions {
display: flex;
justify-content: flex-end;
gap: 10px;
padding-top: 4px;
}
+99
View File
@@ -0,0 +1,99 @@
import { useState } from 'react';
import { Game } from '../types';
import './AddGameModal.css';
const ICON_OPTIONS = ['⚽', '🏀', '🎾', '🎮', '🏈', '⚾', '🏒', '🎯', '🏆', '🎲', '♠️', '🃏'];
interface AddGameModalProps {
open: boolean;
onClose: () => void;
onAdd: (game: Omit<Game, 'id'>) => void;
}
export default function AddGameModal({ open, onClose, onAdd }: AddGameModalProps) {
const [name, setName] = useState('');
const [icon, setIcon] = useState('🎯');
const [url, setUrl] = useState('');
const [token, setToken] = useState('');
if (!open) return null;
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
if (!name.trim() || !url.trim()) return;
onAdd({ name: name.trim(), icon, url: url.trim(), token: token.trim() });
// Reset form
setName(''); setIcon('🎯'); setUrl(''); setToken('');
};
return (
<div className="modal-overlay" onClick={onClose}>
<div className="modal-card" onClick={(e) => e.stopPropagation()}>
<div className="modal-header">
<h3></h3>
<button className="modal-close" onClick={onClose}>×</button>
</div>
<form className="modal-body" onSubmit={handleSubmit}>
<div className="modal-field">
<label></label>
<input
type="text"
value={name}
onChange={(e) => setName(e.target.value)}
placeholder="例如:英超联赛"
autoFocus
/>
</div>
<div className="modal-field">
<label></label>
<div className="icon-grid">
{ICON_OPTIONS.map((ic) => (
<button
key={ic}
type="button"
className={`icon-option ${icon === ic ? 'selected' : ''}`}
onClick={() => setIcon(ic)}
>
{ic}
</button>
))}
</div>
</div>
<div className="modal-field">
<label></label>
<input
type="text"
className="mono"
value={url}
onChange={(e) => setUrl(e.target.value)}
placeholder="https://api.example.com/v1/market/odds"
/>
</div>
<div className="modal-field">
<label> (User-Token)</label>
<input
type="password"
className="mono"
value={token}
onChange={(e) => setToken(e.target.value)}
placeholder="用户令牌"
/>
</div>
<div className="modal-actions">
<button type="button" className="btn btn-secondary" onClick={onClose}>
</button>
<button type="submit" className="btn btn-primary" disabled={!name.trim() || !url.trim()}>
</button>
</div>
</form>
</div>
</div>
);
}
+201
View File
@@ -0,0 +1,201 @@
.config-card {
background: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: var(--radius-lg);
padding: 24px 28px;
box-shadow: var(--shadow-card);
}
.config-header {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 22px;
}
.config-icon {
font-size: 18px;
}
.config-title {
font-size: 15px;
font-weight: 600;
color: var(--text-primary);
}
.config-game-badge {
margin-left: auto;
display: inline-flex;
align-items: center;
gap: 6px;
padding: 4px 12px;
background: rgba(59, 130, 246, 0.1);
border: 1px solid rgba(59, 130, 246, 0.2);
border-radius: 20px;
font-size: 12px;
color: var(--accent-blue);
font-weight: 500;
}
.config-empty {
display: flex;
align-items: center;
justify-content: center;
padding: 40px;
color: var(--text-dim);
font-size: 13px;
}
.config-fields {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 20px;
margin-bottom: 20px;
}
.field-group {
display: flex;
flex-direction: column;
gap: 6px;
}
.field-label {
font-size: 12px;
font-weight: 500;
color: var(--text-secondary);
letter-spacing: 0.3px;
}
.field-input-wrap {
display: flex;
align-items: center;
background: var(--bg-input);
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
overflow: hidden;
transition: border-color var(--transition-fast);
}
.field-input-wrap:focus-within {
border-color: var(--accent-blue);
box-shadow: 0 0 0 2px var(--accent-blue-glow);
}
.field-input {
flex: 1;
background: transparent;
border: none;
padding: 10px 12px;
color: var(--text-primary);
font-size: 13px;
outline: none;
}
.field-input::placeholder {
color: var(--text-dim);
}
.field-action {
padding: 8px 10px;
background: transparent;
border: none;
border-left: 1px solid var(--border-color);
color: var(--text-muted);
cursor: pointer;
transition: color var(--transition-fast);
display: flex;
align-items: center;
}
.field-action:hover {
color: var(--text-primary);
}
.field-hint {
font-size: 11px;
color: var(--text-dim);
}
.test-result {
padding: 8px 14px;
border-radius: var(--radius-sm);
font-size: 12px;
margin-bottom: 16px;
font-family: 'JetBrains Mono', monospace;
}
.test-result.success {
background: rgba(34, 197, 94, 0.1);
color: var(--status-success);
border: 1px solid rgba(34, 197, 94, 0.2);
}
.test-result.error {
background: rgba(239, 68, 68, 0.1);
color: var(--status-error);
border: 1px solid rgba(239, 68, 68, 0.2);
}
.config-actions {
display: flex;
justify-content: flex-end;
gap: 10px;
}
/* Buttons */
.btn {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 9px 18px;
border: none;
border-radius: var(--radius-sm);
font-size: 13px;
font-weight: 500;
font-family: inherit;
cursor: pointer;
transition: all var(--transition-fast);
}
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.btn-icon {
font-size: 14px;
}
.btn-secondary {
background: rgba(255, 255, 255, 0.05);
color: var(--text-secondary);
border: 1px solid var(--border-color);
}
.btn-secondary:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.08);
color: var(--text-primary);
}
.btn-primary {
background: var(--accent-blue);
color: white;
}
.btn-primary:hover:not(:disabled) {
background: var(--accent-blue-hover);
box-shadow: var(--shadow-glow);
}
.spinner {
width: 14px;
height: 14px;
border: 2px solid rgba(255, 255, 255, 0.2);
border-top-color: currentColor;
border-radius: 50%;
animation: spin 0.6s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
+127
View File
@@ -0,0 +1,127 @@
import { useState } from 'react';
import { Game, ConnectionResult } from '../types';
import './ConfigCard.css';
interface ConfigCardProps {
game: Game | null;
onGameUpdate: (game: Game) => void;
onSave: () => void;
onTest: () => Promise<ConnectionResult>;
onXRay: () => void;
}
export default function ConfigCard({
game,
onGameUpdate,
onSave,
onTest,
onXRay,
}: ConfigCardProps) {
const [showToken, setShowToken] = useState(false);
const [testing, setTesting] = useState(false);
const [testResult, setTestResult] = useState<ConnectionResult | null>(null);
if (!game) {
return (
<div className="config-card">
<div className="config-empty">
<p></p>
</div>
</div>
);
}
const handleTest = async () => {
setTesting(true);
setTestResult(null);
try {
const result = await onTest();
setTestResult(result);
} finally {
setTesting(false);
}
};
const update = (fields: Partial<Game>) => {
onGameUpdate({ ...game, ...fields });
};
return (
<div className="config-card">
<div className="config-header">
<span className="config-icon"></span>
<h3 className="config-title"></h3>
<span className="config-game-badge">
<span>{game.icon}</span> {game.name}
</span>
</div>
<div className="config-fields">
<div className="field-group">
<label className="field-label"></label>
<div className="field-input-wrap">
<input
type="text"
className="field-input mono"
value={game.url}
onChange={(e) => update({ url: e.target.value })}
placeholder="https://api.example.com/v1/market/odds"
/>
<button className="field-action" title="复制">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none"
stroke="currentColor" strokeWidth="2">
<rect x="9" y="9" width="13" height="13" rx="2"/>
<path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/>
</svg>
</button>
</div>
<span className="field-hint"></span>
</div>
<div className="field-group">
<label className="field-label"> (User-Token)</label>
<div className="field-input-wrap">
<input
type={showToken ? 'text' : 'password'}
className="field-input mono"
value={game.token}
onChange={(e) => update({ token: e.target.value })}
placeholder="用户令牌"
/>
<button
className="field-action"
onClick={() => setShowToken(!showToken)}
title={showToken ? '隐藏' : '显示'}
>
{showToken ? '🙈' : '👁️'}
</button>
</div>
<span className="field-hint">访 HTTP User-Token</span>
</div>
</div>
{testResult && (
<div className={`test-result ${testResult.success ? 'success' : 'error'}`}>
{testResult.success ? '✓' : '✗'} {testResult.message}
{testResult.latency > 0 && ` (${testResult.latency}ms)`}
</div>
)}
<div className="config-actions">
<button className="btn btn-secondary" onClick={handleTest} disabled={testing}>
{testing ? (
<><span className="spinner" /> ...</>
) : (
<><span className="btn-icon"></span> </>
)}
</button>
<button className="btn btn-secondary" onClick={onXRay} disabled={testing}>
<span className="btn-icon">🔍</span>
</button>
<button className="btn btn-primary" onClick={onSave}>
<span className="btn-icon">💾</span>
</button>
</div>
</div>
);
}
@@ -0,0 +1,31 @@
.fab {
position: fixed;
bottom: 28px;
right: 28px;
width: 52px;
height: 52px;
border-radius: 50%;
border: none;
background: linear-gradient(135deg, #3b82f6, #6366f1);
color: white;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
box-shadow:
0 4px 16px rgba(59, 130, 246, 0.4),
0 0 30px rgba(59, 130, 246, 0.15);
transition: all 0.25s ease;
z-index: 100;
}
.fab:hover {
transform: scale(1.08);
box-shadow:
0 6px 24px rgba(59, 130, 246, 0.5),
0 0 40px rgba(59, 130, 246, 0.25);
}
.fab:active {
transform: scale(0.95);
}
@@ -0,0 +1,12 @@
import './FloatingButton.css';
export default function FloatingButton() {
return (
<button className="fab" title="AI 助手">
<svg width="22" height="22" viewBox="0 0 24 24" fill="none"
stroke="currentColor" strokeWidth="2" strokeLinecap="round">
<path d="M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z"/>
</svg>
</button>
);
}
+92
View File
@@ -0,0 +1,92 @@
.header {
height: var(--header-height);
min-height: var(--header-height);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 28px;
border-bottom: 1px solid var(--border-subtle);
background: var(--bg-secondary);
}
.header-title {
font-size: 16px;
font-weight: 600;
color: var(--text-primary);
letter-spacing: 0.3px;
}
.header-actions {
display: flex;
align-items: center;
gap: 6px;
}
.header-btn {
width: 34px;
height: 34px;
display: flex;
align-items: center;
justify-content: center;
background: transparent;
border: 1px solid transparent;
border-radius: var(--radius-sm);
color: var(--text-muted);
cursor: pointer;
transition: all var(--transition-fast);
}
.header-btn:hover {
background: rgba(255, 255, 255, 0.05);
color: var(--text-primary);
border-color: var(--border-color);
}
.header-divider {
width: 1px;
height: 20px;
background: var(--border-color);
margin: 0 8px;
}
.header-user {
display: flex;
align-items: center;
gap: 8px;
}
.user-name {
font-size: 12px;
color: var(--text-secondary);
}
.user-avatar {
position: relative;
}
.avatar-circle {
width: 30px;
height: 30px;
border-radius: 50%;
background: linear-gradient(135deg, #3b82f6, #8b5cf6);
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
font-weight: 600;
color: white;
}
.status-dot {
position: absolute;
bottom: -1px;
right: -1px;
width: 10px;
height: 10px;
border-radius: 50%;
border: 2px solid var(--bg-secondary);
}
.status-dot.online {
background: var(--status-success);
}
+39
View File
@@ -0,0 +1,39 @@
import './Header.css';
interface HeaderProps {
title: string;
}
export default function Header({ title }: HeaderProps) {
return (
<header className="header" style={{ '--wails-draggable': 'drag' } as any}>
<h2 className="header-title">{title}</h2>
<div className="header-actions" style={{ '--wails-draggable': 'no-drag' } as any}>
<button className="header-btn" title="通知">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/>
<path d="M13.73 21a2 2 0 0 1-3.46 0"/>
</svg>
</button>
<button className="header-btn" title="截图">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<rect x="2" y="3" width="20" height="14" rx="2" ry="2"/>
<line x1="8" y1="21" x2="16" y2="21"/>
<line x1="12" y1="17" x2="12" y2="21"/>
</svg>
</button>
<div className="header-divider" />
<div className="header-user">
<span className="user-name"></span>
<div className="user-avatar">
<div className="avatar-circle">B</div>
<span className="status-dot online" />
</div>
</div>
</div>
</header>
);
}
+152
View File
@@ -0,0 +1,152 @@
.sidebar {
width: var(--sidebar-width);
min-width: var(--sidebar-width);
height: 100vh;
background: var(--bg-sidebar);
border-right: 1px solid var(--border-subtle);
display: flex;
flex-direction: column;
padding: 0;
user-select: none;
--wails-draggable: drag;
}
.sidebar-brand {
padding: 28px 20px 24px;
border-bottom: 1px solid var(--border-subtle);
}
.sidebar-title {
font-size: 18px;
font-weight: 700;
color: var(--text-primary);
letter-spacing: 0.5px;
}
.sidebar-subtitle {
font-size: 11px;
color: var(--text-dim);
margin-top: 4px;
letter-spacing: 0.3px;
}
.sidebar-nav {
flex: 1;
padding: 12px 10px;
display: flex;
flex-direction: column;
gap: 2px;
}
.nav-item {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 14px;
border: none;
background: transparent;
color: var(--text-secondary);
font-size: 13.5px;
font-weight: 500;
font-family: inherit;
border-radius: var(--radius-sm);
cursor: pointer;
transition: all var(--transition-fast);
text-align: left;
width: 100%;
position: relative;
}
.nav-item:hover {
background: rgba(59, 130, 246, 0.08);
color: var(--text-primary);
}
.nav-item.active {
background: rgba(59, 130, 246, 0.12);
color: var(--accent-blue);
}
.nav-item.active .nav-icon {
transform: scale(1.1);
}
.nav-delete {
display: none;
position: absolute;
right: 8px;
width: 20px;
height: 20px;
border: none;
background: rgba(239, 68, 68, 0.15);
color: var(--status-error);
border-radius: 4px;
cursor: pointer;
font-size: 14px;
line-height: 1;
align-items: center;
justify-content: center;
transition: all var(--transition-fast);
}
.nav-item:hover .nav-delete {
display: flex;
}
.nav-delete:hover {
background: rgba(239, 68, 68, 0.3);
}
.nav-add-btn {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 14px;
margin-top: 4px;
border: 1px dashed var(--border-color);
background: transparent;
color: var(--text-dim);
font-size: 13px;
font-weight: 500;
font-family: inherit;
border-radius: var(--radius-sm);
cursor: pointer;
transition: all var(--transition-fast);
width: 100%;
text-align: left;
}
.nav-add-btn:hover {
border-color: var(--accent-blue);
color: var(--accent-blue);
background: rgba(59, 130, 246, 0.05);
}
.nav-add-icon {
font-size: 16px;
width: 22px;
text-align: center;
font-weight: 300;
}
.nav-icon {
font-size: 16px;
width: 22px;
text-align: center;
transition: transform var(--transition-fast);
}
.nav-label {
white-space: nowrap;
}
.sidebar-footer {
padding: 16px 20px;
border-top: 1px solid var(--border-subtle);
}
.version-badge {
font-size: 10px;
color: var(--text-dim);
font-family: 'JetBrains Mono', monospace;
}
+61
View File
@@ -0,0 +1,61 @@
import { Game } from '../types';
import './Sidebar.css';
interface SidebarProps {
games: Game[];
activeGameId: string;
onSelectGame: (id: string) => void;
onAddGame: () => void;
onDeleteGame: (id: string) => void;
}
export default function Sidebar({
games,
activeGameId,
onSelectGame,
onAddGame,
onDeleteGame,
}: SidebarProps) {
return (
<aside className="sidebar">
<div className="sidebar-brand">
<h1 className="sidebar-title"></h1>
<p className="sidebar-subtitle"></p>
</div>
<nav className="sidebar-nav">
{games.map((game) => (
<div
key={game.id}
className={`nav-item ${activeGameId === game.id ? 'active' : ''}`}
onClick={() => onSelectGame(game.id)}
>
<span className="nav-icon">{game.icon}</span>
<span className="nav-label">{game.name}</span>
{games.length > 1 && (
<button
className="nav-delete"
onClick={(e) => {
e.stopPropagation();
onDeleteGame(game.id);
}}
title="删除游戏"
>
×
</button>
)}
</div>
))}
<button className="nav-add-btn" onClick={onAddGame}>
<span className="nav-add-icon">+</span>
<span className="nav-label"></span>
</button>
</nav>
<div className="sidebar-footer">
<div className="version-badge">v1.0.0</div>
</div>
</aside>
);
}
+422
View File
@@ -0,0 +1,422 @@
.xray-panel {
background: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: var(--radius-lg);
display: flex;
flex-direction: column;
flex: 1;
min-height: 300px;
overflow: hidden;
box-shadow: var(--shadow-card);
}
.xray-titlebar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 16px;
border-bottom: 1px solid var(--border-subtle);
background: rgba(0, 0, 0, 0.15);
}
.titlebar-left {
display: flex;
align-items: center;
gap: 8px;
}
.xray-icon {
font-size: 14px;
}
.xray-label {
font-size: 13px;
font-weight: 500;
color: var(--text-secondary);
}
.titlebar-right {
display: flex;
align-items: center;
}
.xray-loading {
display: flex;
align-items: center;
gap: 6px;
font-size: 12px;
color: var(--text-muted);
}
.spinner.small {
width: 10px;
height: 10px;
border-width: 1.5px;
}
.latency-badge {
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 12px;
color: var(--text-muted);
font-family: 'JetBrains Mono', monospace;
}
.latency-dot {
width: 7px;
height: 7px;
border-radius: 50%;
}
.latency-badge.online .latency-dot {
background: var(--status-success);
box-shadow: 0 0 6px var(--status-success);
}
.xray-body {
flex: 1;
overflow-y: auto;
background: rgba(0, 0, 0, 0.2);
}
.xray-placeholder {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
padding: 40px;
gap: 12px;
color: var(--text-dim);
font-size: 13px;
}
.placeholder-icon {
font-size: 32px;
opacity: 0.5;
}
.placeholder-icon.rotating {
animation: spin 3s linear infinite;
}
.xray-error {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
padding: 40px;
gap: 12px;
}
.error-icon {
font-size: 32px;
}
.error-text {
color: var(--status-error);
font-weight: 500;
background: rgba(239, 68, 68, 0.1);
padding: 8px 16px;
border-radius: var(--radius-md);
border: 1px solid rgba(239, 68, 68, 0.2);
}
.xray-json {
padding: 20px;
margin: 0;
font-size: 13px;
line-height: 1.6;
color: var(--text-primary);
white-space: pre-wrap;
word-break: break-all;
}
/* Moles Viewer Specifics */
.moles-viewer {
padding: 20px;
display: flex;
flex-direction: column;
gap: 20px;
}
.moles-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.moles-badge {
background: rgba(59, 130, 246, 0.15);
color: var(--accent-blue);
border: 1px solid rgba(59, 130, 246, 0.3);
padding: 6px 12px;
border-radius: 20px;
font-size: 13px;
font-weight: 600;
}
.moles-uid {
font-family: 'JetBrains Mono', monospace;
font-size: 12px;
color: var(--text-dim);
}
.moles-stats {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
}
.stat-card {
background: rgba(255, 255, 255, 0.03);
border: 1px solid var(--border-subtle);
border-radius: var(--radius-md);
padding: 16px;
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
}
.stat-label {
font-size: 12px;
color: var(--text-secondary);
}
.stat-value {
font-size: 20px;
font-family: 'JetBrains Mono', monospace;
font-weight: 600;
color: var(--text-primary);
}
.text-accent {
color: var(--accent-blue);
}
.text-danger {
color: #ef4444;
}
.moles-section-title {
font-size: 14px;
color: var(--text-primary);
margin: 0;
padding-bottom: 8px;
border-bottom: 1px solid var(--border-subtle);
}
.moles-boards {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 12px;
}
.board-card {
background: rgba(255, 255, 255, 0.02);
border: 1px solid var(--border-subtle);
border-radius: var(--radius-md);
padding: 14px;
display: flex;
flex-direction: column;
gap: 10px;
transition: all var(--transition-fast);
}
.board-card.played {
opacity: 0.7;
}
.board-card:hover {
background: rgba(255, 255, 255, 0.04);
}
.board-round {
font-size: 13px;
font-weight: 500;
color: var(--text-primary);
}
.board-status {
display: flex;
}
.status-badge {
font-size: 11px;
padding: 2px 8px;
border-radius: 10px;
}
.status-badge.played {
background: rgba(34, 197, 94, 0.1);
color: #22c55e;
}
.status-badge.upcoming {
background: rgba(168, 162, 158, 0.1);
color: #a8a29e;
}
.board-positions {
display: flex;
flex-direction: column;
gap: 6px;
margin-top: 4px;
}
.pos-label {
font-size: 12px;
color: var(--text-dim);
}
.pos-tags {
display: flex;
flex-wrap: wrap;
gap: 4px;
}
.pos-tag {
background: rgba(239, 68, 68, 0.1);
border: 1px solid rgba(239, 68, 68, 0.2);
color: #ef4444;
padding: 2px 6px;
border-radius: 4px;
font-family: 'JetBrains Mono', monospace;
font-size: 12px;
}
/* ===== Mines Viewer ===== */
.mines-viewer {
padding: 20px;
display: flex;
flex-direction: column;
gap: 20px;
}
.mines-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.mines-badge {
background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(251, 146, 60, 0.15));
color: #f97316;
border: 1px solid rgba(251, 146, 60, 0.3);
padding: 6px 14px;
border-radius: 20px;
font-size: 13px;
font-weight: 600;
}
.mines-uid {
font-family: 'JetBrains Mono', monospace;
font-size: 12px;
color: var(--text-dim);
}
.mines-grid {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 6px;
max-width: 380px;
}
.mines-cell {
aspect-ratio: 1;
border-radius: var(--radius-md);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 2px;
cursor: default;
transition: all 0.2s ease;
position: relative;
overflow: hidden;
}
.mines-cell.is-safe {
background: rgba(34, 197, 94, 0.08);
border: 1px solid rgba(34, 197, 94, 0.2);
}
.mines-cell.is-safe:hover {
background: rgba(34, 197, 94, 0.15);
border-color: rgba(34, 197, 94, 0.4);
transform: scale(1.05);
}
.mines-cell.is-bomb {
background: rgba(239, 68, 68, 0.12);
border: 1px solid rgba(239, 68, 68, 0.35);
animation: bombPulse 2s ease-in-out infinite;
}
.mines-cell.is-bomb:hover {
background: rgba(239, 68, 68, 0.22);
border-color: rgba(239, 68, 68, 0.5);
box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
transform: scale(1.05);
}
@keyframes bombPulse {
0%, 100% { box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
50% { box-shadow: 0 0 8px rgba(239, 68, 68, 0.2); }
}
.cell-index {
font-family: 'JetBrains Mono', monospace;
font-size: 10px;
color: var(--text-dim);
opacity: 0.6;
}
.cell-icon {
font-size: 20px;
line-height: 1;
}
.mines-legend {
display: flex;
align-items: center;
gap: 20px;
padding: 10px 14px;
background: rgba(255, 255, 255, 0.02);
border: 1px solid var(--border-subtle);
border-radius: var(--radius-md);
font-size: 12px;
color: var(--text-secondary);
}
.legend-item {
display: flex;
align-items: center;
gap: 6px;
}
.legend-dot {
width: 8px;
height: 8px;
border-radius: 50%;
}
.legend-dot.safe {
background: #22c55e;
box-shadow: 0 0 4px rgba(34, 197, 94, 0.4);
}
.legend-dot.bomb {
background: #ef4444;
box-shadow: 0 0 4px rgba(239, 68, 68, 0.4);
}
.legend-raw {
margin-left: auto;
font-family: 'JetBrains Mono', monospace;
color: var(--text-dim);
font-size: 11px;
}
+194
View File
@@ -0,0 +1,194 @@
import React, { useMemo } from 'react';
import './XRayViewer.css';
interface XRayViewerProps {
data: string | null;
error: string | null;
loading: boolean;
latency: number;
}
export default function XRayViewer({ data, error, loading, latency }: XRayViewerProps) {
// 尝试解析 Moles 数据格式以进行美化展示
const parsedMolesData = useMemo(() => {
if (!data) return null;
try {
const parsed = JSON.parse(data);
if (parsed.data && parsed.data.allBoards && typeof parsed.data.molesCount === 'number') {
return parsed.data;
}
} catch {
// Not valid JSON
}
return null;
}, [data]);
// 解析 Mines (扫雷) 数据
const parsedMinesData = useMemo(() => {
if (!data) return null;
try {
const parsed = JSON.parse(data);
if (parsed.data && parsed.data.board && typeof parsed.data.minesCount === 'number') {
return parsed.data;
}
} catch {
// Not valid JSON
}
return null;
}, [data]);
const renderContent = () => {
if (loading) {
return (
<div className="xray-placeholder">
<span className="placeholder-icon rotating"></span>
<p>...</p>
</div>
);
}
if (error) {
return (
<div className="xray-error">
<span className="error-icon"></span>
<p className="error-text">{error}</p>
</div>
);
}
if (!data) {
return (
<div className="xray-placeholder">
<span className="placeholder-icon">👁</span>
<p></p>
</div>
);
}
if (parsedMolesData) {
return (
<div className="moles-viewer">
<div className="moles-header">
<div className="moles-badge">🐹 Moles </div>
<div className="moles-uid">UID: {parsedMolesData.uid}</div>
</div>
<div className="moles-stats">
<div className="stat-card">
<span className="stat-label"></span>
<span className="stat-value text-accent">{parseFloat(parsedMolesData.currentMultiplier).toFixed(2)}x</span>
</div>
<div className="stat-card">
<span className="stat-label"></span>
<span className="stat-value">{parsedMolesData.currentRound} / {parsedMolesData.totalRounds}</span>
</div>
<div className="stat-card">
<span className="stat-label"> (Moles)</span>
<span className="stat-value text-danger">{parsedMolesData.molesCount} </span>
</div>
</div>
<h4 className="moles-section-title">🔮 ()</h4>
<div className="moles-boards">
{parsedMolesData.allBoards.map((board: any, idx: number) => (
<div key={idx} className={`board-card ${board.played ? 'played' : 'upcoming'}`}>
<div className="board-round"> {board.round} </div>
<div className="board-status">
{board.played ? (
<span className="status-badge played"></span>
) : (
<span className="status-badge upcoming"></span>
)}
</div>
<div className="board-positions">
<span className="pos-label">:</span>
<div className="pos-tags">
{board.molePositions.map((p: number, i: number) => (
<span key={i} className="pos-tag">[{p}]</span>
))}
</div>
</div>
</div>
))}
</div>
</div>
);
}
if (parsedMinesData) {
const gridSize = 5;
const minesIndexes = (parsedMinesData.minesIndex || '').split(',').map(Number);
return (
<div className="mines-viewer">
<div className="mines-header">
<div className="mines-badge">💣 Mines </div>
<div className="mines-uid">UID: {parsedMinesData.uid}</div>
</div>
<div className="moles-stats">
<div className="stat-card">
<span className="stat-label"></span>
<span className="stat-value text-accent">
{parsedMinesData.nextMultiplier ? `${parsedMinesData.nextMultiplier}x` : '--'}
</span>
</div>
<div className="stat-card">
<span className="stat-label"></span>
<span className="stat-value">{parsedMinesData.currentRound}</span>
</div>
<div className="stat-card">
<span className="stat-label"></span>
<span className="stat-value text-danger">{parsedMinesData.minesCount} </span>
</div>
</div>
<h4 className="moles-section-title">🗺 ({gridSize}×{gridSize})</h4>
<div className="mines-grid">
{parsedMinesData.board.map((cell: any) => (
<div
key={cell.id}
className={`mines-cell ${cell.isBomb ? 'is-bomb' : 'is-safe'} ${cell.revealed ? 'revealed' : ''}`}
title={`#${cell.index} ${cell.isBomb ? '💣 地雷' : '✅ 安全'}`}
>
<span className="cell-index">{cell.index}</span>
<span className="cell-icon">{cell.isBomb ? '💣' : '💎'}</span>
</div>
))}
</div>
<div className="mines-legend">
<span className="legend-item safe"><span className="legend-dot safe" /> </span>
<span className="legend-item bomb"><span className="legend-dot bomb" /> </span>
<span className="legend-raw">: [{parsedMinesData.minesIndex}]</span>
</div>
</div>
);
}
return <pre className="xray-json mono">{data}</pre>;
};
return (
<div className="xray-panel">
<div className="xray-titlebar">
<div className="titlebar-left">
<span className="xray-icon">🔍</span>
<span className="xray-label"></span>
</div>
<div className="titlebar-right">
{loading && <span className="xray-loading"><span className="spinner small"/> ...</span>}
{!loading && latency > 0 && (
<span className="latency-badge online">
<span className="latency-dot" />
{latency} ms
</span>
)}
</div>
</div>
<div className="xray-body">
{renderContent()}
</div>
</div>
);
}
+12
View File
@@ -0,0 +1,12 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
const container = document.getElementById('root');
const root = createRoot(container!);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
+25
View File
@@ -0,0 +1,25 @@
export interface Game {
id: string;
name: string;
icon: string;
url: string;
token: string;
}
export interface ConnectionResult {
success: boolean;
message: string;
latency: number;
status: number;
}
export interface RequestEntry {
id: string;
timestamp: string;
method: string;
path: string;
status: number;
statusText: string;
body: string;
latency: number;
}
+1
View File
@@ -0,0 +1 @@
/// <reference types="vite/client" />
+31
View File
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": [
"DOM",
"DOM.Iterable",
"ESNext"
],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}
+11
View File
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": [
"vite.config.ts"
]
}
+7
View File
@@ -0,0 +1,7 @@
import {defineConfig} from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()]
})
+19
View File
@@ -0,0 +1,19 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
import {main} from '../models';
export function AddGame(arg1:main.Game):Promise<main.Game>;
export function DeleteGame(arg1:string):Promise<void>;
export function GetActiveGameID():Promise<string>;
export function GetAllGames():Promise<Array<main.Game>>;
export function SetActiveGame(arg1:string):Promise<void>;
export function TestConnection(arg1:main.Game):Promise<main.ConnectionResult>;
export function UpdateGame(arg1:main.Game):Promise<void>;
export function XRayConnection(arg1:main.Game):Promise<main.XRayResult>;
+35
View File
@@ -0,0 +1,35 @@
// @ts-check
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
export function AddGame(arg1) {
return window['go']['main']['App']['AddGame'](arg1);
}
export function DeleteGame(arg1) {
return window['go']['main']['App']['DeleteGame'](arg1);
}
export function GetActiveGameID() {
return window['go']['main']['App']['GetActiveGameID']();
}
export function GetAllGames() {
return window['go']['main']['App']['GetAllGames']();
}
export function SetActiveGame(arg1) {
return window['go']['main']['App']['SetActiveGame'](arg1);
}
export function TestConnection(arg1) {
return window['go']['main']['App']['TestConnection'](arg1);
}
export function UpdateGame(arg1) {
return window['go']['main']['App']['UpdateGame'](arg1);
}
export function XRayConnection(arg1) {
return window['go']['main']['App']['XRayConnection'](arg1);
}
+61
View File
@@ -0,0 +1,61 @@
export namespace main {
export class ConnectionResult {
success: boolean;
message: string;
latency: number;
status: number;
static createFrom(source: any = {}) {
return new ConnectionResult(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.success = source["success"];
this.message = source["message"];
this.latency = source["latency"];
this.status = source["status"];
}
}
export class Game {
id: string;
name: string;
icon: string;
url: string;
token: string;
static createFrom(source: any = {}) {
return new Game(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.id = source["id"];
this.name = source["name"];
this.icon = source["icon"];
this.url = source["url"];
this.token = source["token"];
}
}
export class XRayResult {
success: boolean;
body: string;
latency: number;
error: string;
static createFrom(source: any = {}) {
return new XRayResult(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.success = source["success"];
this.body = source["body"];
this.latency = source["latency"];
this.error = source["error"];
}
}
}
+24
View File
@@ -0,0 +1,24 @@
{
"name": "@wailsapp/runtime",
"version": "2.0.0",
"description": "Wails Javascript runtime library",
"main": "runtime.js",
"types": "runtime.d.ts",
"scripts": {
},
"repository": {
"type": "git",
"url": "git+https://github.com/wailsapp/wails.git"
},
"keywords": [
"Wails",
"Javascript",
"Go"
],
"author": "Lea Anthony <lea.anthony@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/wailsapp/wails/issues"
},
"homepage": "https://github.com/wailsapp/wails#readme"
}
+330
View File
@@ -0,0 +1,330 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
export interface Position {
x: number;
y: number;
}
export interface Size {
w: number;
h: number;
}
export interface Screen {
isCurrent: boolean;
isPrimary: boolean;
width : number
height : number
}
// Environment information such as platform, buildtype, ...
export interface EnvironmentInfo {
buildType: string;
platform: string;
arch: string;
}
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
// emits the given event. Optional data may be passed with the event.
// This will trigger any event listeners.
export function EventsEmit(eventName: string, ...data: any): void;
// [EventsOn](https://wails.io/docs/reference/runtime/events#eventson) sets up a listener for the given event name.
export function EventsOn(eventName: string, callback: (...data: any) => void): () => void;
// [EventsOnMultiple](https://wails.io/docs/reference/runtime/events#eventsonmultiple)
// sets up a listener for the given event name, but will only trigger a given number times.
export function EventsOnMultiple(eventName: string, callback: (...data: any) => void, maxCallbacks: number): () => void;
// [EventsOnce](https://wails.io/docs/reference/runtime/events#eventsonce)
// sets up a listener for the given event name, but will only trigger once.
export function EventsOnce(eventName: string, callback: (...data: any) => void): () => void;
// [EventsOff](https://wails.io/docs/reference/runtime/events#eventsoff)
// unregisters the listener for the given event name.
export function EventsOff(eventName: string, ...additionalEventNames: string[]): void;
// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall)
// unregisters all listeners.
export function EventsOffAll(): void;
// [LogPrint](https://wails.io/docs/reference/runtime/log#logprint)
// logs the given message as a raw message
export function LogPrint(message: string): void;
// [LogTrace](https://wails.io/docs/reference/runtime/log#logtrace)
// logs the given message at the `trace` log level.
export function LogTrace(message: string): void;
// [LogDebug](https://wails.io/docs/reference/runtime/log#logdebug)
// logs the given message at the `debug` log level.
export function LogDebug(message: string): void;
// [LogError](https://wails.io/docs/reference/runtime/log#logerror)
// logs the given message at the `error` log level.
export function LogError(message: string): void;
// [LogFatal](https://wails.io/docs/reference/runtime/log#logfatal)
// logs the given message at the `fatal` log level.
// The application will quit after calling this method.
export function LogFatal(message: string): void;
// [LogInfo](https://wails.io/docs/reference/runtime/log#loginfo)
// logs the given message at the `info` log level.
export function LogInfo(message: string): void;
// [LogWarning](https://wails.io/docs/reference/runtime/log#logwarning)
// logs the given message at the `warning` log level.
export function LogWarning(message: string): void;
// [WindowReload](https://wails.io/docs/reference/runtime/window#windowreload)
// Forces a reload by the main application as well as connected browsers.
export function WindowReload(): void;
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
// Reloads the application frontend.
export function WindowReloadApp(): void;
// [WindowSetAlwaysOnTop](https://wails.io/docs/reference/runtime/window#windowsetalwaysontop)
// Sets the window AlwaysOnTop or not on top.
export function WindowSetAlwaysOnTop(b: boolean): void;
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
// *Windows only*
// Sets window theme to system default (dark/light).
export function WindowSetSystemDefaultTheme(): void;
// [WindowSetLightTheme](https://wails.io/docs/next/reference/runtime/window#windowsetlighttheme)
// *Windows only*
// Sets window to light theme.
export function WindowSetLightTheme(): void;
// [WindowSetDarkTheme](https://wails.io/docs/next/reference/runtime/window#windowsetdarktheme)
// *Windows only*
// Sets window to dark theme.
export function WindowSetDarkTheme(): void;
// [WindowCenter](https://wails.io/docs/reference/runtime/window#windowcenter)
// Centers the window on the monitor the window is currently on.
export function WindowCenter(): void;
// [WindowSetTitle](https://wails.io/docs/reference/runtime/window#windowsettitle)
// Sets the text in the window title bar.
export function WindowSetTitle(title: string): void;
// [WindowFullscreen](https://wails.io/docs/reference/runtime/window#windowfullscreen)
// Makes the window full screen.
export function WindowFullscreen(): void;
// [WindowUnfullscreen](https://wails.io/docs/reference/runtime/window#windowunfullscreen)
// Restores the previous window dimensions and position prior to full screen.
export function WindowUnfullscreen(): void;
// [WindowIsFullscreen](https://wails.io/docs/reference/runtime/window#windowisfullscreen)
// Returns the state of the window, i.e. whether the window is in full screen mode or not.
export function WindowIsFullscreen(): Promise<boolean>;
// [WindowSetSize](https://wails.io/docs/reference/runtime/window#windowsetsize)
// Sets the width and height of the window.
export function WindowSetSize(width: number, height: number): void;
// [WindowGetSize](https://wails.io/docs/reference/runtime/window#windowgetsize)
// Gets the width and height of the window.
export function WindowGetSize(): Promise<Size>;
// [WindowSetMaxSize](https://wails.io/docs/reference/runtime/window#windowsetmaxsize)
// Sets the maximum window size. Will resize the window if the window is currently larger than the given dimensions.
// Setting a size of 0,0 will disable this constraint.
export function WindowSetMaxSize(width: number, height: number): void;
// [WindowSetMinSize](https://wails.io/docs/reference/runtime/window#windowsetminsize)
// Sets the minimum window size. Will resize the window if the window is currently smaller than the given dimensions.
// Setting a size of 0,0 will disable this constraint.
export function WindowSetMinSize(width: number, height: number): void;
// [WindowSetPosition](https://wails.io/docs/reference/runtime/window#windowsetposition)
// Sets the window position relative to the monitor the window is currently on.
export function WindowSetPosition(x: number, y: number): void;
// [WindowGetPosition](https://wails.io/docs/reference/runtime/window#windowgetposition)
// Gets the window position relative to the monitor the window is currently on.
export function WindowGetPosition(): Promise<Position>;
// [WindowHide](https://wails.io/docs/reference/runtime/window#windowhide)
// Hides the window.
export function WindowHide(): void;
// [WindowShow](https://wails.io/docs/reference/runtime/window#windowshow)
// Shows the window, if it is currently hidden.
export function WindowShow(): void;
// [WindowMaximise](https://wails.io/docs/reference/runtime/window#windowmaximise)
// Maximises the window to fill the screen.
export function WindowMaximise(): void;
// [WindowToggleMaximise](https://wails.io/docs/reference/runtime/window#windowtogglemaximise)
// Toggles between Maximised and UnMaximised.
export function WindowToggleMaximise(): void;
// [WindowUnmaximise](https://wails.io/docs/reference/runtime/window#windowunmaximise)
// Restores the window to the dimensions and position prior to maximising.
export function WindowUnmaximise(): void;
// [WindowIsMaximised](https://wails.io/docs/reference/runtime/window#windowismaximised)
// Returns the state of the window, i.e. whether the window is maximised or not.
export function WindowIsMaximised(): Promise<boolean>;
// [WindowMinimise](https://wails.io/docs/reference/runtime/window#windowminimise)
// Minimises the window.
export function WindowMinimise(): void;
// [WindowUnminimise](https://wails.io/docs/reference/runtime/window#windowunminimise)
// Restores the window to the dimensions and position prior to minimising.
export function WindowUnminimise(): void;
// [WindowIsMinimised](https://wails.io/docs/reference/runtime/window#windowisminimised)
// Returns the state of the window, i.e. whether the window is minimised or not.
export function WindowIsMinimised(): Promise<boolean>;
// [WindowIsNormal](https://wails.io/docs/reference/runtime/window#windowisnormal)
// Returns the state of the window, i.e. whether the window is normal or not.
export function WindowIsNormal(): Promise<boolean>;
// [WindowSetBackgroundColour](https://wails.io/docs/reference/runtime/window#windowsetbackgroundcolour)
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
export function WindowSetBackgroundColour(R: number, G: number, B: number, A: number): void;
// [ScreenGetAll](https://wails.io/docs/reference/runtime/window#screengetall)
// Gets the all screens. Call this anew each time you want to refresh data from the underlying windowing system.
export function ScreenGetAll(): Promise<Screen[]>;
// [BrowserOpenURL](https://wails.io/docs/reference/runtime/browser#browseropenurl)
// Opens the given URL in the system browser.
export function BrowserOpenURL(url: string): void;
// [Environment](https://wails.io/docs/reference/runtime/intro#environment)
// Returns information about the environment
export function Environment(): Promise<EnvironmentInfo>;
// [Quit](https://wails.io/docs/reference/runtime/intro#quit)
// Quits the application.
export function Quit(): void;
// [Hide](https://wails.io/docs/reference/runtime/intro#hide)
// Hides the application.
export function Hide(): void;
// [Show](https://wails.io/docs/reference/runtime/intro#show)
// Shows the application.
export function Show(): void;
// [ClipboardGetText](https://wails.io/docs/reference/runtime/clipboard#clipboardgettext)
// Returns the current text stored on clipboard
export function ClipboardGetText(): Promise<string>;
// [ClipboardSetText](https://wails.io/docs/reference/runtime/clipboard#clipboardsettext)
// Sets a text on the clipboard
export function ClipboardSetText(text: string): Promise<boolean>;
// [OnFileDrop](https://wails.io/docs/reference/runtime/draganddrop#onfiledrop)
// OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings.
export function OnFileDrop(callback: (x: number, y: number ,paths: string[]) => void, useDropTarget: boolean) :void
// [OnFileDropOff](https://wails.io/docs/reference/runtime/draganddrop#dragandddropoff)
// OnFileDropOff removes the drag and drop listeners and handlers.
export function OnFileDropOff() :void
// Check if the file path resolver is available
export function CanResolveFilePaths(): boolean;
// Resolves file paths for an array of files
export function ResolveFilePaths(files: File[]): void
// Notification types
export interface NotificationOptions {
id: string;
title: string;
subtitle?: string; // macOS and Linux only
body?: string;
categoryId?: string;
data?: { [key: string]: any };
}
export interface NotificationAction {
id?: string;
title?: string;
destructive?: boolean; // macOS-specific
}
export interface NotificationCategory {
id?: string;
actions?: NotificationAction[];
hasReplyField?: boolean;
replyPlaceholder?: string;
replyButtonTitle?: string;
}
// [InitializeNotifications](https://wails.io/docs/reference/runtime/notification#initializenotifications)
// Initializes the notification service for the application.
// This must be called before sending any notifications.
export function InitializeNotifications(): Promise<void>;
// [CleanupNotifications](https://wails.io/docs/reference/runtime/notification#cleanupnotifications)
// Cleans up notification resources and releases any held connections.
export function CleanupNotifications(): Promise<void>;
// [IsNotificationAvailable](https://wails.io/docs/reference/runtime/notification#isnotificationavailable)
// Checks if notifications are available on the current platform.
export function IsNotificationAvailable(): Promise<boolean>;
// [RequestNotificationAuthorization](https://wails.io/docs/reference/runtime/notification#requestnotificationauthorization)
// Requests notification authorization from the user (macOS only).
export function RequestNotificationAuthorization(): Promise<boolean>;
// [CheckNotificationAuthorization](https://wails.io/docs/reference/runtime/notification#checknotificationauthorization)
// Checks the current notification authorization status (macOS only).
export function CheckNotificationAuthorization(): Promise<boolean>;
// [SendNotification](https://wails.io/docs/reference/runtime/notification#sendnotification)
// Sends a basic notification with the given options.
export function SendNotification(options: NotificationOptions): Promise<void>;
// [SendNotificationWithActions](https://wails.io/docs/reference/runtime/notification#sendnotificationwithactions)
// Sends a notification with action buttons. Requires a registered category.
export function SendNotificationWithActions(options: NotificationOptions): Promise<void>;
// [RegisterNotificationCategory](https://wails.io/docs/reference/runtime/notification#registernotificationcategory)
// Registers a notification category that can be used with SendNotificationWithActions.
export function RegisterNotificationCategory(category: NotificationCategory): Promise<void>;
// [RemoveNotificationCategory](https://wails.io/docs/reference/runtime/notification#removenotificationcategory)
// Removes a previously registered notification category.
export function RemoveNotificationCategory(categoryId: string): Promise<void>;
// [RemoveAllPendingNotifications](https://wails.io/docs/reference/runtime/notification#removeallpendingnotifications)
// Removes all pending notifications from the notification center.
export function RemoveAllPendingNotifications(): Promise<void>;
// [RemovePendingNotification](https://wails.io/docs/reference/runtime/notification#removependingnotification)
// Removes a specific pending notification by its identifier.
export function RemovePendingNotification(identifier: string): Promise<void>;
// [RemoveAllDeliveredNotifications](https://wails.io/docs/reference/runtime/notification#removealldeliverednotifications)
// Removes all delivered notifications from the notification center.
export function RemoveAllDeliveredNotifications(): Promise<void>;
// [RemoveDeliveredNotification](https://wails.io/docs/reference/runtime/notification#removedeliverednotification)
// Removes a specific delivered notification by its identifier.
export function RemoveDeliveredNotification(identifier: string): Promise<void>;
// [RemoveNotification](https://wails.io/docs/reference/runtime/notification#removenotification)
// Removes a notification by its identifier (cross-platform convenience function).
export function RemoveNotification(identifier: string): Promise<void>;
+298
View File
@@ -0,0 +1,298 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
export function LogPrint(message) {
window.runtime.LogPrint(message);
}
export function LogTrace(message) {
window.runtime.LogTrace(message);
}
export function LogDebug(message) {
window.runtime.LogDebug(message);
}
export function LogInfo(message) {
window.runtime.LogInfo(message);
}
export function LogWarning(message) {
window.runtime.LogWarning(message);
}
export function LogError(message) {
window.runtime.LogError(message);
}
export function LogFatal(message) {
window.runtime.LogFatal(message);
}
export function EventsOnMultiple(eventName, callback, maxCallbacks) {
return window.runtime.EventsOnMultiple(eventName, callback, maxCallbacks);
}
export function EventsOn(eventName, callback) {
return EventsOnMultiple(eventName, callback, -1);
}
export function EventsOff(eventName, ...additionalEventNames) {
return window.runtime.EventsOff(eventName, ...additionalEventNames);
}
export function EventsOffAll() {
return window.runtime.EventsOffAll();
}
export function EventsOnce(eventName, callback) {
return EventsOnMultiple(eventName, callback, 1);
}
export function EventsEmit(eventName) {
let args = [eventName].slice.call(arguments);
return window.runtime.EventsEmit.apply(null, args);
}
export function WindowReload() {
window.runtime.WindowReload();
}
export function WindowReloadApp() {
window.runtime.WindowReloadApp();
}
export function WindowSetAlwaysOnTop(b) {
window.runtime.WindowSetAlwaysOnTop(b);
}
export function WindowSetSystemDefaultTheme() {
window.runtime.WindowSetSystemDefaultTheme();
}
export function WindowSetLightTheme() {
window.runtime.WindowSetLightTheme();
}
export function WindowSetDarkTheme() {
window.runtime.WindowSetDarkTheme();
}
export function WindowCenter() {
window.runtime.WindowCenter();
}
export function WindowSetTitle(title) {
window.runtime.WindowSetTitle(title);
}
export function WindowFullscreen() {
window.runtime.WindowFullscreen();
}
export function WindowUnfullscreen() {
window.runtime.WindowUnfullscreen();
}
export function WindowIsFullscreen() {
return window.runtime.WindowIsFullscreen();
}
export function WindowGetSize() {
return window.runtime.WindowGetSize();
}
export function WindowSetSize(width, height) {
window.runtime.WindowSetSize(width, height);
}
export function WindowSetMaxSize(width, height) {
window.runtime.WindowSetMaxSize(width, height);
}
export function WindowSetMinSize(width, height) {
window.runtime.WindowSetMinSize(width, height);
}
export function WindowSetPosition(x, y) {
window.runtime.WindowSetPosition(x, y);
}
export function WindowGetPosition() {
return window.runtime.WindowGetPosition();
}
export function WindowHide() {
window.runtime.WindowHide();
}
export function WindowShow() {
window.runtime.WindowShow();
}
export function WindowMaximise() {
window.runtime.WindowMaximise();
}
export function WindowToggleMaximise() {
window.runtime.WindowToggleMaximise();
}
export function WindowUnmaximise() {
window.runtime.WindowUnmaximise();
}
export function WindowIsMaximised() {
return window.runtime.WindowIsMaximised();
}
export function WindowMinimise() {
window.runtime.WindowMinimise();
}
export function WindowUnminimise() {
window.runtime.WindowUnminimise();
}
export function WindowSetBackgroundColour(R, G, B, A) {
window.runtime.WindowSetBackgroundColour(R, G, B, A);
}
export function ScreenGetAll() {
return window.runtime.ScreenGetAll();
}
export function WindowIsMinimised() {
return window.runtime.WindowIsMinimised();
}
export function WindowIsNormal() {
return window.runtime.WindowIsNormal();
}
export function BrowserOpenURL(url) {
window.runtime.BrowserOpenURL(url);
}
export function Environment() {
return window.runtime.Environment();
}
export function Quit() {
window.runtime.Quit();
}
export function Hide() {
window.runtime.Hide();
}
export function Show() {
window.runtime.Show();
}
export function ClipboardGetText() {
return window.runtime.ClipboardGetText();
}
export function ClipboardSetText(text) {
return window.runtime.ClipboardSetText(text);
}
/**
* Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
*
* @export
* @callback OnFileDropCallback
* @param {number} x - x coordinate of the drop
* @param {number} y - y coordinate of the drop
* @param {string[]} paths - A list of file paths.
*/
/**
* OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings.
*
* @export
* @param {OnFileDropCallback} callback - Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
* @param {boolean} [useDropTarget=true] - Only call the callback when the drop finished on an element that has the drop target style. (--wails-drop-target)
*/
export function OnFileDrop(callback, useDropTarget) {
return window.runtime.OnFileDrop(callback, useDropTarget);
}
/**
* OnFileDropOff removes the drag and drop listeners and handlers.
*/
export function OnFileDropOff() {
return window.runtime.OnFileDropOff();
}
export function CanResolveFilePaths() {
return window.runtime.CanResolveFilePaths();
}
export function ResolveFilePaths(files) {
return window.runtime.ResolveFilePaths(files);
}
export function InitializeNotifications() {
return window.runtime.InitializeNotifications();
}
export function CleanupNotifications() {
return window.runtime.CleanupNotifications();
}
export function IsNotificationAvailable() {
return window.runtime.IsNotificationAvailable();
}
export function RequestNotificationAuthorization() {
return window.runtime.RequestNotificationAuthorization();
}
export function CheckNotificationAuthorization() {
return window.runtime.CheckNotificationAuthorization();
}
export function SendNotification(options) {
return window.runtime.SendNotification(options);
}
export function SendNotificationWithActions(options) {
return window.runtime.SendNotificationWithActions(options);
}
export function RegisterNotificationCategory(category) {
return window.runtime.RegisterNotificationCategory(category);
}
export function RemoveNotificationCategory(categoryId) {
return window.runtime.RemoveNotificationCategory(categoryId);
}
export function RemoveAllPendingNotifications() {
return window.runtime.RemoveAllPendingNotifications();
}
export function RemovePendingNotification(identifier) {
return window.runtime.RemovePendingNotification(identifier);
}
export function RemoveAllDeliveredNotifications() {
return window.runtime.RemoveAllDeliveredNotifications();
}
export function RemoveDeliveredNotification(identifier) {
return window.runtime.RemoveDeliveredNotification(identifier);
}
export function RemoveNotification(identifier) {
return window.runtime.RemoveNotification(identifier);
}