@wsl233/dsh-gomoku 0.3.4 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -7
- package/client.js +1 -1
- package/index.js +161 -22
- package/lan-server.js +175 -7
- package/package.json +1 -1
- package/preview.html +1 -1
- package/ui/gomoku-ui.js +600 -42
- package/ui/gomoku.css +176 -5
- package/ui/lan.html +78 -2
package/ui/gomoku.css
CHANGED
|
@@ -23,7 +23,11 @@
|
|
|
23
23
|
--gk-board-line: #cd8640;
|
|
24
24
|
position: relative;
|
|
25
25
|
min-height: 100%;
|
|
26
|
+
height: 100%;
|
|
27
|
+
max-height: 100vh;
|
|
26
28
|
width: 100%;
|
|
29
|
+
overflow-y: auto;
|
|
30
|
+
overflow-x: hidden;
|
|
27
31
|
background:
|
|
28
32
|
radial-gradient(1100px 420px at 50% -160px, #fff7ee 0%, rgba(255, 247, 238, 0) 70%),
|
|
29
33
|
#ffffff;
|
|
@@ -650,6 +654,10 @@
|
|
|
650
654
|
border-top: 1px dashed #f2e4d4;
|
|
651
655
|
}
|
|
652
656
|
|
|
657
|
+
.gk-levels[hidden] {
|
|
658
|
+
display: none;
|
|
659
|
+
}
|
|
660
|
+
|
|
653
661
|
.gk-levels-label {
|
|
654
662
|
margin-right: 2px;
|
|
655
663
|
color: #9b8e80;
|
|
@@ -739,22 +747,54 @@
|
|
|
739
747
|
left: 50%;
|
|
740
748
|
bottom: 12px;
|
|
741
749
|
z-index: 26;
|
|
742
|
-
display:
|
|
750
|
+
display: grid;
|
|
751
|
+
grid-template-columns: auto auto auto auto;
|
|
752
|
+
grid-template-areas:
|
|
753
|
+
"chart chart chart chart"
|
|
754
|
+
"prev pos next close";
|
|
743
755
|
align-items: center;
|
|
744
|
-
|
|
745
|
-
|
|
756
|
+
justify-content: center;
|
|
757
|
+
gap: 5px 6px;
|
|
758
|
+
padding: 8px 10px;
|
|
759
|
+
width: min(560px, calc(100% - 16px));
|
|
746
760
|
border: 1px solid rgba(249, 115, 22, 0.22);
|
|
747
|
-
border-radius:
|
|
748
|
-
background: rgba(255, 255, 255, 0.
|
|
761
|
+
border-radius: 14px;
|
|
762
|
+
background: rgba(255, 255, 255, 0.96);
|
|
749
763
|
box-shadow: 0 6px 18px rgba(120, 72, 20, 0.16);
|
|
750
764
|
transform: translateX(-50%);
|
|
751
765
|
backdrop-filter: blur(8px);
|
|
766
|
+
max-width: calc(100% - 16px);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
.gk-app.is-panel-narrow .gk-reviewbar {
|
|
770
|
+
gap: 4px;
|
|
771
|
+
padding: 5px;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
.gk-app.is-panel-narrow .gk-review-chart {
|
|
775
|
+
height: 88px;
|
|
752
776
|
}
|
|
753
777
|
|
|
754
778
|
.gk-reviewbar[hidden] {
|
|
755
779
|
display: none;
|
|
756
780
|
}
|
|
757
781
|
|
|
782
|
+
.gk-review-step[data-review-step="-1"] {
|
|
783
|
+
grid-area: prev;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
.gk-review-step[data-review-step="1"] {
|
|
787
|
+
grid-area: next;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
.gk-review-pos {
|
|
791
|
+
grid-area: pos;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
.gk-review-close {
|
|
795
|
+
grid-area: close;
|
|
796
|
+
}
|
|
797
|
+
|
|
758
798
|
.gk-review-step,
|
|
759
799
|
.gk-review-close {
|
|
760
800
|
padding: 5px 10px;
|
|
@@ -790,6 +830,50 @@
|
|
|
790
830
|
color: var(--gk-orange-strong);
|
|
791
831
|
}
|
|
792
832
|
|
|
833
|
+
.gk-review-chart {
|
|
834
|
+
grid-area: chart;
|
|
835
|
+
width: 100%;
|
|
836
|
+
height: 112px;
|
|
837
|
+
border-radius: 8px;
|
|
838
|
+
background: #ffffff;
|
|
839
|
+
border: 1px solid #f4e6d5;
|
|
840
|
+
cursor: crosshair;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
.gk-review-tip {
|
|
844
|
+
position: absolute;
|
|
845
|
+
z-index: 2;
|
|
846
|
+
display: flex;
|
|
847
|
+
flex-direction: column;
|
|
848
|
+
gap: 1px;
|
|
849
|
+
padding: 4px 7px;
|
|
850
|
+
border: 1px solid #f1dcc4;
|
|
851
|
+
border-radius: 8px;
|
|
852
|
+
background: #ffffff;
|
|
853
|
+
box-shadow: 0 4px 12px rgba(120, 72, 20, 0.14);
|
|
854
|
+
color: #8a6a4e;
|
|
855
|
+
font-size: 10px;
|
|
856
|
+
line-height: 1.3;
|
|
857
|
+
white-space: nowrap;
|
|
858
|
+
pointer-events: none;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
.gk-review-tip strong {
|
|
862
|
+
color: #431407;
|
|
863
|
+
font-size: 11px;
|
|
864
|
+
font-weight: 600;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
.gk-review-tip[hidden] {
|
|
868
|
+
display: none;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
@media (max-width: 760px) {
|
|
872
|
+
.gk-review-chart {
|
|
873
|
+
height: 88px;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
|
|
793
877
|
.gk-tool.is-active {
|
|
794
878
|
background: var(--gk-orange-soft);
|
|
795
879
|
color: var(--gk-orange-strong);
|
|
@@ -1547,3 +1631,90 @@
|
|
|
1547
1631
|
transition-duration: 0.001ms !important;
|
|
1548
1632
|
}
|
|
1549
1633
|
}
|
|
1634
|
+
|
|
1635
|
+
/* --- 联机与品牌图标(0.3.9) --- */
|
|
1636
|
+
.gk-brand-mark {
|
|
1637
|
+
background: transparent;
|
|
1638
|
+
color: #3b2a1c;
|
|
1639
|
+
border-radius: 0;
|
|
1640
|
+
box-shadow: none;
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
.gk-brand-mark::before,
|
|
1644
|
+
.gk-brand-mark::after {
|
|
1645
|
+
display: none !important;
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
.gk-brand-mark svg {
|
|
1649
|
+
width: 34px;
|
|
1650
|
+
height: 34px;
|
|
1651
|
+
display: block;
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
.gk-avatar-glyph svg {
|
|
1655
|
+
width: 32px;
|
|
1656
|
+
height: 32px;
|
|
1657
|
+
display: block;
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
.gk-menu-thumb svg {
|
|
1661
|
+
width: 22px;
|
|
1662
|
+
height: 22px;
|
|
1663
|
+
display: block;
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
.gk-tool[hidden],
|
|
1667
|
+
.gk-lan-hint-toggle[hidden],
|
|
1668
|
+
.gk-lan-host-only[hidden] {
|
|
1669
|
+
display: none !important;
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
.gk-player.is-static {
|
|
1673
|
+
cursor: default;
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
.gk-player.is-host {
|
|
1677
|
+
cursor: pointer;
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
.gk-lan-hint-toggle {
|
|
1681
|
+
margin-top: 14px;
|
|
1682
|
+
display: flex;
|
|
1683
|
+
align-items: center;
|
|
1684
|
+
gap: 8px;
|
|
1685
|
+
padding: 9px 10px;
|
|
1686
|
+
border: 1px solid #f4e3d2;
|
|
1687
|
+
border-radius: 10px;
|
|
1688
|
+
background: #fffaf5;
|
|
1689
|
+
color: #6b5541;
|
|
1690
|
+
font-size: 11.5px;
|
|
1691
|
+
line-height: 1.4;
|
|
1692
|
+
cursor: pointer;
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
.gk-lan-hint-toggle input {
|
|
1696
|
+
width: 15px;
|
|
1697
|
+
height: 15px;
|
|
1698
|
+
accent-color: #f97316;
|
|
1699
|
+
flex: 0 0 auto;
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
.gk-lan-request-dialog {
|
|
1703
|
+
width: min(392px, 100%);
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
.gk-lan-request-dialog p {
|
|
1707
|
+
color: #6b5541;
|
|
1708
|
+
font-size: 12.5px;
|
|
1709
|
+
}
|
|
1710
|
+
.gk-btn.is-danger {
|
|
1711
|
+
border-color: #fdba74;
|
|
1712
|
+
background: #fff7ed;
|
|
1713
|
+
color: #c2410c;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
.gk-btn.is-danger:hover {
|
|
1717
|
+
border-color: #fb923c;
|
|
1718
|
+
background: #ffedd5;
|
|
1719
|
+
color: #9a3412;
|
|
1720
|
+
}
|
package/ui/lan.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
6
|
<meta name="color-scheme" content="light">
|
|
7
7
|
<title>五子棋 · 局域网加入</title>
|
|
8
|
-
<link rel="stylesheet" href="/ui/gomoku.css?v=0.2.0-
|
|
8
|
+
<link rel="stylesheet" href="/ui/gomoku.css?v=0.2.0-32">
|
|
9
9
|
<style>
|
|
10
10
|
html, body { margin: 0; min-height: 100%; background: #ffffff; }
|
|
11
11
|
body { min-height: 100vh; }
|
|
@@ -18,21 +18,97 @@
|
|
|
18
18
|
font: 500 12px/1.7 "Segoe UI", "Microsoft YaHei", sans-serif;
|
|
19
19
|
text-align: center;
|
|
20
20
|
}
|
|
21
|
+
.gk-join {
|
|
22
|
+
min-height: 100vh;
|
|
23
|
+
display: grid;
|
|
24
|
+
place-items: center;
|
|
25
|
+
padding: 24px;
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
background: #fffaf5;
|
|
28
|
+
}
|
|
29
|
+
.gk-join-card {
|
|
30
|
+
width: min(380px, 100%);
|
|
31
|
+
padding: 28px 26px;
|
|
32
|
+
border: 1px solid #f4e3d2;
|
|
33
|
+
border-radius: 24px;
|
|
34
|
+
background: #fff;
|
|
35
|
+
box-shadow: 0 18px 48px rgba(126, 86, 48, 0.12);
|
|
36
|
+
font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
|
|
37
|
+
color: #3b2a1c;
|
|
38
|
+
}
|
|
39
|
+
.gk-join-card h1 { margin: 0 0 8px; font-size: 22px; }
|
|
40
|
+
.gk-join-card p { margin: 0 0 20px; color: #8a6a4a; font-size: 13px; line-height: 1.7; }
|
|
41
|
+
.gk-join-card input {
|
|
42
|
+
width: 100%;
|
|
43
|
+
box-sizing: border-box;
|
|
44
|
+
height: 44px;
|
|
45
|
+
border: 1.5px solid #f0d9c2;
|
|
46
|
+
border-radius: 12px;
|
|
47
|
+
padding: 0 14px;
|
|
48
|
+
font: 600 18px/1 "Segoe UI", "Microsoft YaHei", sans-serif;
|
|
49
|
+
letter-spacing: 0.18em;
|
|
50
|
+
color: #3b2a1c;
|
|
51
|
+
outline: none;
|
|
52
|
+
}
|
|
53
|
+
.gk-join-card input:focus { border-color: #f97316; box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12); }
|
|
54
|
+
.gk-join-card button {
|
|
55
|
+
width: 100%;
|
|
56
|
+
height: 44px;
|
|
57
|
+
margin-top: 14px;
|
|
58
|
+
border: 0;
|
|
59
|
+
border-radius: 12px;
|
|
60
|
+
background: #f97316;
|
|
61
|
+
color: #fff;
|
|
62
|
+
font: 700 15px/1 "Segoe UI", "Microsoft YaHei", sans-serif;
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
}
|
|
65
|
+
.gk-join-card button:hover { background: #ea580c; }
|
|
66
|
+
.gk-join-error { min-height: 20px; margin: 10px 0 0; color: #c2410c; font-size: 12px; }
|
|
21
67
|
</style>
|
|
22
68
|
</head>
|
|
23
69
|
<body>
|
|
24
70
|
<div id="app"></div>
|
|
71
|
+
<div class="gk-join" id="join" hidden>
|
|
72
|
+
<form class="gk-join-card" id="join-form">
|
|
73
|
+
<h1>加入五子棋房间</h1>
|
|
74
|
+
<p>请输入房主提供的 4 位房间号,或直接打开带房间号的完整链接。</p>
|
|
75
|
+
<input id="join-room" inputmode="numeric" maxlength="4" pattern="[0-9]{4}" placeholder="例如 4821" autocomplete="off" aria-label="四位房间号">
|
|
76
|
+
<button type="submit">加入房间</button>
|
|
77
|
+
<div class="gk-join-error" id="join-error" role="alert"></div>
|
|
78
|
+
</form>
|
|
79
|
+
</div>
|
|
25
80
|
<div class="gk-lan-note">你已通过局域网加入对局。关掉本页即离开房间。</div>
|
|
26
81
|
|
|
27
82
|
<script src="/ui/engine/board.js"></script>
|
|
28
83
|
<script src="/ui/engine/evaluate.js"></script>
|
|
29
84
|
<script src="/ui/engine/ai.js"></script>
|
|
30
|
-
<script src="/ui/gomoku-ui.js?v=0.2.0-
|
|
85
|
+
<script src="/ui/gomoku-ui.js?v=0.2.0-32"></script>
|
|
31
86
|
<script>
|
|
32
87
|
(function () {
|
|
33
88
|
var params = new URLSearchParams(window.location.search);
|
|
34
89
|
var room = params.get('room') || '';
|
|
35
90
|
var host = params.get('host') === '1';
|
|
91
|
+
if (!/^\d{4}$/.test(room)) {
|
|
92
|
+
document.getElementById('app').hidden = true;
|
|
93
|
+
document.querySelector('.gk-lan-note').hidden = true;
|
|
94
|
+
var join = document.getElementById('join');
|
|
95
|
+
var form = document.getElementById('join-form');
|
|
96
|
+
var input = document.getElementById('join-room');
|
|
97
|
+
var error = document.getElementById('join-error');
|
|
98
|
+
join.hidden = false;
|
|
99
|
+
input.focus();
|
|
100
|
+
form.addEventListener('submit', function (event) {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
var value = String(input.value || '').replace(/\s+/g, '');
|
|
103
|
+
if (!/^\d{4}$/.test(value)) {
|
|
104
|
+
error.textContent = '房间号应为 4 位数字。';
|
|
105
|
+
input.focus();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
window.location.search = '?room=' + encodeURIComponent(value);
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
36
112
|
window.DshGomokuUI.mount(document.getElementById('app'), {
|
|
37
113
|
demo: false,
|
|
38
114
|
preview: false,
|