dsh-share-chat 0.29.1 → 0.37.1
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/client.js +1177 -79
- package/docs/GAME.md +69 -0
- package/docs/INSTALL.md +95 -0
- package/docs/MEETING.md +69 -0
- package/index.js +156 -0
- package/package.json +2 -2
package/client.js
CHANGED
|
@@ -433,7 +433,7 @@ window.__ModuleLoader__.load({
|
|
|
433
433
|
.sc-char-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.1))}
|
|
434
434
|
.sc-face-mask{position:fixed;inset:0;z-index:2147483645;display:flex;align-items:center;justify-content:center;background:rgba(4,10,14,.72);backdrop-filter:blur(6px)}
|
|
435
435
|
.sc-face{width:min(1040px,94vw);height:min(720px,92vh);display:flex;flex-direction:column;border-radius:18px;overflow:hidden;
|
|
436
|
-
background:
|
|
436
|
+
background:var(--dsw-alias-bg-base,#ffffff);color:var(--dsw-alias-label-primary,#e9f2f6);
|
|
437
437
|
border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.24));box-shadow:0 30px 80px rgba(0,0,0,.55)}
|
|
438
438
|
.sc-face-head{display:flex;align-items:center;gap:8px;padding:12px 16px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.2));flex:0 0 auto;flex-wrap:wrap}
|
|
439
439
|
.sc-face-title{font-size:14px;font-weight:600}
|
|
@@ -479,6 +479,26 @@ window.__ModuleLoader__.load({
|
|
|
479
479
|
--dopa-pink:#ff5fa2; --dopa-pink-soft:#ffe3ef; --dopa-violet:#a86bff;
|
|
480
480
|
--dopa-blue:#4d9fff; --dopa-mint:#3ddc97; --dopa-yellow:#ffcf3d; --dopa-ink:#3b2b45;
|
|
481
481
|
background:linear-gradient(180deg,#fff8fc 0%,#f7faff 100%);
|
|
482
|
+
background-color:#fff8fc;
|
|
483
|
+
color:#3b2b45;
|
|
484
|
+
/* 这套主题是浅色,必须把 DSH 的暗色 token 全部覆盖掉,否则白字落在白底上 */
|
|
485
|
+
--dsw-alias-label-primary:#3b2b45;
|
|
486
|
+
--dsw-alias-label-secondary:#7a5b8a;
|
|
487
|
+
--dsw-alias-label-tertiary:#9b86a8;
|
|
488
|
+
--dsw-alias-label-quaternary:#b5a3c0;
|
|
489
|
+
--dsw-alias-label-on-color:#ffffff;
|
|
490
|
+
--dsw-alias-border-l2:rgba(160,120,180,.22);
|
|
491
|
+
--dsw-alias-border-l3:rgba(160,120,180,.32);
|
|
492
|
+
--dsw-alias-fill-l1:rgba(160,120,180,.07);
|
|
493
|
+
--dsw-alias-fill-l2:rgba(160,120,180,.12);
|
|
494
|
+
--dsw-alias-card-fill:rgba(255,255,255,.78);
|
|
495
|
+
--dsw-alias-card-fill-hover:rgba(255,255,255,.95);
|
|
496
|
+
--dsw-alias-bg-base:#ffffff;
|
|
497
|
+
--dsw-alias-bg-elevated:#ffffff;
|
|
498
|
+
--dsw-alias-interactive-bg-hover:rgba(160,120,180,.10);
|
|
499
|
+
--dsw-alias-brand-primary:#ff5fa2;
|
|
500
|
+
--dsw-alias-state-success-primary:#2f8f65;
|
|
501
|
+
--dsw-alias-label-error:#c2417a;
|
|
482
502
|
}
|
|
483
503
|
/* 顶栏 */
|
|
484
504
|
.sc-chat-head{background:linear-gradient(96deg,#ffeaf4 0%,#fff7e8 45%,#eaf4ff 100%);border-bottom:2px solid #ffd9ec;box-shadow:0 4px 14px rgba(255,120,180,.10)}
|
|
@@ -1643,7 +1663,7 @@ window.__ModuleLoader__.load({
|
|
|
1643
1663
|
'div',
|
|
1644
1664
|
{ style: { minWidth: 0 } },
|
|
1645
1665
|
h('div', { className: 'sc-chat-name' }, '@' + (auth.displayName || auth.id)),
|
|
1646
|
-
h('div', { className: 'sc-chat-sub' },
|
|
1666
|
+
h('div', { className: 'sc-chat-sub' }, '在线'),
|
|
1647
1667
|
),
|
|
1648
1668
|
h('span', { className: 'sc-grow' }),
|
|
1649
1669
|
err
|
|
@@ -1724,6 +1744,24 @@ window.__ModuleLoader__.load({
|
|
|
1724
1744
|
},
|
|
1725
1745
|
'🀄 麻将',
|
|
1726
1746
|
),
|
|
1747
|
+
h(
|
|
1748
|
+
'button',
|
|
1749
|
+
{
|
|
1750
|
+
className: 'sc-btn',
|
|
1751
|
+
onClick: () => openAvalon({ auth, onToast: (m) => setErr(m) }),
|
|
1752
|
+
title: '阿瓦隆(5-10 人,缺的位置机器人补)',
|
|
1753
|
+
},
|
|
1754
|
+
'🏰 阿瓦隆',
|
|
1755
|
+
),
|
|
1756
|
+
h(
|
|
1757
|
+
'button',
|
|
1758
|
+
{
|
|
1759
|
+
className: 'sc-btn',
|
|
1760
|
+
onClick: () => openMobilePreview({ auth, onToast: (m) => setErr(m) }),
|
|
1761
|
+
title: '手机浏览器预览(开发用)',
|
|
1762
|
+
},
|
|
1763
|
+
'📱 预览',
|
|
1764
|
+
),
|
|
1727
1765
|
h(
|
|
1728
1766
|
'button',
|
|
1729
1767
|
{
|
|
@@ -4393,6 +4431,8 @@ window.__ModuleLoader__.load({
|
|
|
4393
4431
|
*/
|
|
4394
4432
|
const MEET_ICE = [
|
|
4395
4433
|
{ urls: ['stun:stun.cloudflare.com:3478', 'stun:stun.l.google.com:19302'] },
|
|
4434
|
+
{ urls: 'turn:152.136.125.55:3478?transport=udp', username: 'dsh', credential: 'dshnD1K5Ouo' },
|
|
4435
|
+
{ urls: 'turn:152.136.125.55:3478?transport=tcp', username: 'dsh', credential: 'dshnD1K5Ouo' },
|
|
4396
4436
|
// 以后加 TURN:{ urls: 'turn:turn.example.com:3478', username: 'u', credential: 'p' }
|
|
4397
4437
|
]
|
|
4398
4438
|
|
|
@@ -5561,6 +5601,19 @@ window.__ModuleLoader__.load({
|
|
|
5561
5601
|
let room = null
|
|
5562
5602
|
let timer = null
|
|
5563
5603
|
let stopped = false
|
|
5604
|
+
let winds = [0, 1, 2, 3]
|
|
5605
|
+
let dealerSeat = 0
|
|
5606
|
+
let deadlineIn = 0
|
|
5607
|
+
let discuss = null
|
|
5608
|
+
let phase = ''
|
|
5609
|
+
let draft = null
|
|
5610
|
+
let leaderLeft = 0
|
|
5611
|
+
let finalLeft = 0
|
|
5612
|
+
let speakSelfFirst = true
|
|
5613
|
+
let speakReverse = false
|
|
5614
|
+
let speakOpts = null
|
|
5615
|
+
let lobbySig = ''
|
|
5616
|
+
const WIND_NAMES = ['东', '南', '西', '北']
|
|
5564
5617
|
|
|
5565
5618
|
const api2 = (m, path, b) =>
|
|
5566
5619
|
api(auth.server, path, { method: m, token: auth.token, body: b })
|
|
@@ -5583,7 +5636,48 @@ window.__ModuleLoader__.load({
|
|
|
5583
5636
|
return b
|
|
5584
5637
|
}
|
|
5585
5638
|
|
|
5639
|
+
/** 解散牌桌:房主专用,删完回大厅 */
|
|
5640
|
+
const dissolveRoom = async () => {
|
|
5641
|
+
if (!window.confirm('解散这张牌桌?里面的人会被请回大厅。')) return
|
|
5642
|
+
try {
|
|
5643
|
+
await api2('POST', '/api/mj/rooms/' + roomId + '/dismiss')
|
|
5644
|
+
onToast('牌桌已解散')
|
|
5645
|
+
state = null
|
|
5646
|
+
room = null
|
|
5647
|
+
roomId = ''
|
|
5648
|
+
seat = -1
|
|
5649
|
+
await renderLobby()
|
|
5650
|
+
} catch (e) {
|
|
5651
|
+
onToast('解散失败:' + friendly(e))
|
|
5652
|
+
}
|
|
5653
|
+
}
|
|
5654
|
+
|
|
5586
5655
|
/* ---------- 大厅 ---------- */
|
|
5656
|
+
/** 座位头像:真人用首字+色相,机器人 🤖,空位虚线 + */
|
|
5657
|
+
const seatAvatarEl = (s, size) => {
|
|
5658
|
+
const sz = size || 26
|
|
5659
|
+
const el = document.createElement('div')
|
|
5660
|
+
if (s && s.bot) {
|
|
5661
|
+
el.textContent = '🤖'
|
|
5662
|
+
el.style.cssText =
|
|
5663
|
+
'width:' + sz + 'px;height:' + sz + 'px;border-radius:50%;display:flex;align-items:center;justify-content:center;' +
|
|
5664
|
+
'font-size:' + Math.round(sz * 0.5) + 'px;background:#ece4f6;box-shadow:0 0 0 2px #fff'
|
|
5665
|
+
} else if (!s || s.empty || !s.id) {
|
|
5666
|
+
el.textContent = '+'
|
|
5667
|
+
el.style.cssText =
|
|
5668
|
+
'width:' + sz + 'px;height:' + sz + 'px;border-radius:50%;display:flex;align-items:center;justify-content:center;' +
|
|
5669
|
+
'font-size:' + Math.round(sz * 0.55) + 'px;color:#c9a8d8;background:#faf5ff;border:1.5px dashed #e3c8ef;box-sizing:border-box'
|
|
5670
|
+
} else {
|
|
5671
|
+
const hue = hueOf(s.id)
|
|
5672
|
+
el.textContent = String(s.name || '?').slice(-1)
|
|
5673
|
+
el.style.cssText =
|
|
5674
|
+
'width:' + sz + 'px;height:' + sz + 'px;border-radius:50%;display:flex;align-items:center;justify-content:center;' +
|
|
5675
|
+
'font-weight:700;font-size:' + Math.round(sz * 0.45) + 'px;color:#fff;background:hsl(' + hue + ' 55% 58%);box-shadow:0 0 0 2px #fff'
|
|
5676
|
+
if (s.ready) el.style.boxShadow = '0 0 0 2px #fff, 0 0 0 4px #3ddc97'
|
|
5677
|
+
}
|
|
5678
|
+
return el
|
|
5679
|
+
}
|
|
5680
|
+
|
|
5587
5681
|
const renderLobby = async () => {
|
|
5588
5682
|
bodyEl.textContent = ''
|
|
5589
5683
|
roomEl.textContent = ''
|
|
@@ -5608,6 +5702,7 @@ window.__ModuleLoader__.load({
|
|
|
5608
5702
|
try {
|
|
5609
5703
|
const r = await api2('GET', '/api/mj/rooms')
|
|
5610
5704
|
const rooms = (r.rooms || []).filter((x) => !x.ended)
|
|
5705
|
+
lobbySig = JSON.stringify(rooms.map((x) => [x.id, x.humanCount, x.started, x.freeSeats]))
|
|
5611
5706
|
if (!rooms.length) {
|
|
5612
5707
|
const e = document.createElement('div')
|
|
5613
5708
|
e.textContent = '还没有牌桌,点上面新建一个'
|
|
@@ -5619,12 +5714,17 @@ window.__ModuleLoader__.load({
|
|
|
5619
5714
|
row.style.cssText =
|
|
5620
5715
|
'display:flex;align-items:center;gap:8px;padding:7px 9px;border-radius:10px;background:#fff;border:1.5px solid #ffe3f0'
|
|
5621
5716
|
const t = document.createElement('span')
|
|
5622
|
-
t.textContent = '#' + rm.id
|
|
5623
|
-
t.style.cssText = '
|
|
5717
|
+
t.textContent = '#' + rm.id
|
|
5718
|
+
t.style.cssText = 'font-size:12px;font-weight:650;color:#5b3a63'
|
|
5624
5719
|
row.appendChild(t)
|
|
5625
|
-
|
|
5720
|
+
const seatsBox = document.createElement('div')
|
|
5721
|
+
seatsBox.style.cssText = 'display:flex;gap:3px;flex:1;justify-content:center'
|
|
5722
|
+
const rmSeats = rm.seats || []
|
|
5723
|
+
for (let si = 0; si < 4; si++) seatsBox.appendChild(seatAvatarEl(rmSeats[si], 24))
|
|
5724
|
+
row.appendChild(seatsBox)
|
|
5725
|
+
row.appendChild(chip(rm.started ? (rm.ended ? '已结束' : '进行中') : '等人 ' + (rm.humanCount || 0) + '/4'))
|
|
5626
5726
|
row.appendChild(
|
|
5627
|
-
btn('加入', async () => {
|
|
5727
|
+
btn(rm.started ? '接管' : '加入', async () => {
|
|
5628
5728
|
try {
|
|
5629
5729
|
const j = await api2('POST', '/api/mj/rooms/' + rm.id + '/join')
|
|
5630
5730
|
roomId = rm.id
|
|
@@ -5651,47 +5751,78 @@ window.__ModuleLoader__.load({
|
|
|
5651
5751
|
|
|
5652
5752
|
const meInfo = room.players[seat] || { name: '我' }
|
|
5653
5753
|
|
|
5654
|
-
//
|
|
5655
|
-
const
|
|
5656
|
-
top.style.cssText = 'display:flex;align-items:center;gap:8px;justify-content:center;margin-bottom:8px'
|
|
5657
|
-
const opp2 = room.players[2] || { name: '空位' }
|
|
5658
|
-
top.appendChild(
|
|
5659
|
-
chip(opp2.name + ' · ' + (opp2.score || 0) + '分 · ' + (s.seats[2].handCount || 0) + ' 张'),
|
|
5660
|
-
)
|
|
5661
|
-
if (s.turn === 2 && !s.ended) top.appendChild(chip('出牌中'))
|
|
5662
|
-
bodyEl.appendChild(top)
|
|
5663
|
-
|
|
5664
|
-
// 左右 + 牌河
|
|
5665
|
-
const mid = document.createElement('div')
|
|
5666
|
-
mid.style.cssText = 'display:flex;gap:8px;align-items:flex-start'
|
|
5667
|
-
const side = (i) => {
|
|
5668
|
-
const box = document.createElement('div')
|
|
5669
|
-
box.style.cssText = 'width:78px;flex:0 0 auto;display:flex;flex-direction:column;gap:4px'
|
|
5754
|
+
// 座位信息(东南西北 + 庄)
|
|
5755
|
+
const seatLabel = (i) => {
|
|
5670
5756
|
const p = room.players[i] || { name: '空位' }
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
if (s.turn === i && !s.ended) box.appendChild(chip('出牌中'))
|
|
5675
|
-
return box
|
|
5757
|
+
const w = WIND_NAMES[(winds[i] || 0) % 4]
|
|
5758
|
+
const zhuang = i === dealerSeat ? '庄' : ''
|
|
5759
|
+
return w + zhuang + ' ' + p.name
|
|
5676
5760
|
}
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5761
|
+
const seatChip = (i, size) => {
|
|
5762
|
+
const p = room.players[i] || { name: '空位' }
|
|
5763
|
+
const hc = (s.seats[i] && s.seats[i].handCount) || 0
|
|
5764
|
+
return chip(
|
|
5765
|
+
seatLabel(i) + ' · ' + (p.score || 0) + '分 · ' + hc + '张' + (s.turn === i && !s.ended ? ' · 出牌中' : ''),
|
|
5766
|
+
)
|
|
5767
|
+
}
|
|
5768
|
+
const discardZone = (i, size) => {
|
|
5769
|
+
const z = document.createElement('div')
|
|
5770
|
+
z.style.cssText =
|
|
5771
|
+
'display:flex;flex-wrap:wrap;gap:2px;align-content:flex-start;padding:5px;border-radius:10px;' +
|
|
5772
|
+
'background:rgba(2,77,58,.55);min-height:' + (size * 1.38 + 10) + 'px;' +
|
|
5773
|
+
'max-width:' + (size * 1.38 * 4 + 18) + 'px;min-width:' + (size * 1.38 * 2 + 10) + 'px'
|
|
5774
|
+
for (const t of s.discards[i] || []) {
|
|
5775
|
+
const tile = mjTileEl(tileBase, t, size)
|
|
5776
|
+
if (s.lastDiscard && s.lastDiscard.tile === t && s.lastDiscard.seat === i) {
|
|
5686
5777
|
tile.style.outline = '2px solid #ffcf3d'
|
|
5687
5778
|
}
|
|
5688
|
-
|
|
5779
|
+
z.appendChild(tile)
|
|
5689
5780
|
}
|
|
5690
|
-
|
|
5781
|
+
return z
|
|
5782
|
+
}
|
|
5783
|
+
|
|
5784
|
+
// 上(对家)
|
|
5785
|
+
const topWrap = document.createElement('div')
|
|
5786
|
+
topWrap.style.cssText = 'display:flex;flex-direction:column;align-items:center;gap:4px;margin-bottom:6px'
|
|
5787
|
+
topWrap.appendChild(seatChip((seat + 2) % 4))
|
|
5788
|
+
topWrap.appendChild(discardZone((seat + 2) % 4, 18))
|
|
5789
|
+
bodyEl.appendChild(topWrap)
|
|
5790
|
+
|
|
5791
|
+
// 中:左 / 中 / 右
|
|
5792
|
+
const mid = document.createElement('div')
|
|
5793
|
+
mid.style.cssText = 'display:flex;gap:8px;align-items:flex-start;justify-content:center'
|
|
5794
|
+
const sideCol = (i) => {
|
|
5795
|
+
const col = document.createElement('div')
|
|
5796
|
+
col.style.cssText = 'display:flex;flex-direction:column;gap:4px;align-items:center'
|
|
5797
|
+
col.appendChild(seatChip(i))
|
|
5798
|
+
col.appendChild(discardZone(i, 15))
|
|
5799
|
+
return col
|
|
5800
|
+
}
|
|
5801
|
+
mid.appendChild(sideCol((seat + 3) % 4))
|
|
5802
|
+
const pool = document.createElement('div')
|
|
5803
|
+
pool.style.cssText =
|
|
5804
|
+
'flex:0 1 auto;min-width:0;display:flex;flex-direction:column;align-items:center;gap:4px;padding:6px;' +
|
|
5805
|
+
'background:#024d3a;border-radius:12px;min-height:96px;justify-content:center'
|
|
5806
|
+
const wallChip = chip('牌墙 ' + s.wallCount)
|
|
5807
|
+
pool.appendChild(wallChip)
|
|
5808
|
+
if (!s.ended) {
|
|
5809
|
+
const left = deadlineIn > 0 ? Math.ceil(deadlineIn / 1000) : 0
|
|
5810
|
+
if (s.turn === seat) pool.appendChild(chip('轮到你 · 剩 ' + left + 's'))
|
|
5811
|
+
else if (left) pool.appendChild(chip('剩余 ' + left + 's'))
|
|
5812
|
+
}
|
|
5691
5813
|
mid.appendChild(pool)
|
|
5692
|
-
mid.appendChild(
|
|
5814
|
+
mid.appendChild(sideCol((seat + 1) % 4))
|
|
5693
5815
|
bodyEl.appendChild(mid)
|
|
5694
5816
|
|
|
5817
|
+
// 下(我自己)
|
|
5818
|
+
const meWrap = document.createElement('div')
|
|
5819
|
+
meWrap.style.cssText = 'display:flex;flex-direction:column;align-items:center;gap:4px;margin-top:8px'
|
|
5820
|
+
meWrap.appendChild(seatChip(seat))
|
|
5821
|
+
const myDiscard = discardZone(seat, 18)
|
|
5822
|
+
myDiscard.style.cssText = myDiscard.style.cssText.replace('rgba(2,77,58,.55)', 'rgba(2,77,58,.75)')
|
|
5823
|
+
meWrap.appendChild(myDiscard)
|
|
5824
|
+
bodyEl.appendChild(meWrap)
|
|
5825
|
+
|
|
5695
5826
|
// 我的副露
|
|
5696
5827
|
const melds = document.createElement('div')
|
|
5697
5828
|
melds.style.cssText = 'display:flex;gap:4px;flex-wrap:wrap;margin:8px 0 4px;min-height:26px'
|
|
@@ -5706,9 +5837,8 @@ window.__ModuleLoader__.load({
|
|
|
5706
5837
|
|
|
5707
5838
|
// 顶部状态
|
|
5708
5839
|
const status = document.createElement('div')
|
|
5709
|
-
status.style.cssText = 'display:flex;gap:6px;align-items:center;margin:2px 0 6px'
|
|
5710
|
-
status.appendChild(chip('
|
|
5711
|
-
status.appendChild(chip(meInfo.name))
|
|
5840
|
+
status.style.cssText = 'display:flex;gap:6px;align-items:center;margin:2px 0 6px;flex-wrap:wrap'
|
|
5841
|
+
status.appendChild(chip('你是 ' + seatLabel(seat)))
|
|
5712
5842
|
if (s.ended) {
|
|
5713
5843
|
status.appendChild(
|
|
5714
5844
|
chip(s.winner === null ? '流局' : (room.players[s.winner] || {}).name + ' 胡了'),
|
|
@@ -5759,6 +5889,21 @@ window.__ModuleLoader__.load({
|
|
|
5759
5889
|
// 操作
|
|
5760
5890
|
const acts = document.createElement('div')
|
|
5761
5891
|
acts.style.cssText = 'display:flex;gap:6px;flex-wrap:wrap;align-items:center'
|
|
5892
|
+
acts.appendChild(
|
|
5893
|
+
btn('← 大厅', async () => {
|
|
5894
|
+
if (room && room.owner === auth.id && !window.confirm('你是房主,离开会转让或解散这张牌桌,确定?')) return
|
|
5895
|
+
try {
|
|
5896
|
+
await api2('POST', '/api/mj/rooms/' + roomId + '/leave')
|
|
5897
|
+
} catch (e) {
|
|
5898
|
+
/* 忽略 */
|
|
5899
|
+
}
|
|
5900
|
+
state = null
|
|
5901
|
+
room = null
|
|
5902
|
+
roomId = ''
|
|
5903
|
+
seat = -1
|
|
5904
|
+
renderLobby()
|
|
5905
|
+
}),
|
|
5906
|
+
)
|
|
5762
5907
|
if (!s.ended) {
|
|
5763
5908
|
for (const op of s.options || []) {
|
|
5764
5909
|
const label = op === 'hu' ? '胡' : op === 'gang' ? '杠' : '碰'
|
|
@@ -5777,6 +5922,7 @@ window.__ModuleLoader__.load({
|
|
|
5777
5922
|
seat = -1
|
|
5778
5923
|
renderLobby()
|
|
5779
5924
|
}))
|
|
5925
|
+
if (room && room.owner === auth.id) acts.appendChild(btn('解散牌桌', dissolveRoom))
|
|
5780
5926
|
}
|
|
5781
5927
|
bodyEl.appendChild(acts)
|
|
5782
5928
|
}
|
|
@@ -5788,39 +5934,172 @@ window.__ModuleLoader__.load({
|
|
|
5788
5934
|
room = r.room
|
|
5789
5935
|
seat = r.seat
|
|
5790
5936
|
state = r.state
|
|
5937
|
+
winds = r.winds || [0, 1, 2, 3]
|
|
5938
|
+
dealerSeat = r.dealerSeat || 0
|
|
5939
|
+
deadlineIn = r.deadlineIn || 0
|
|
5791
5940
|
if (room && seat >= 0 && room.players[seat]) {
|
|
5792
5941
|
$('[data-score]').textContent = '积分 ' + (room.players[seat].score || 0)
|
|
5793
5942
|
}
|
|
5794
5943
|
if (!state) renderWaiting()
|
|
5795
5944
|
else renderTable()
|
|
5796
5945
|
} catch (e) {
|
|
5797
|
-
|
|
5946
|
+
const code = String((e && e.code) || '')
|
|
5947
|
+
if (code === 'not-found' || /not-found|404/.test(String((e && e.message) || ''))) {
|
|
5948
|
+
onToast('牌桌已解散')
|
|
5949
|
+
state = null
|
|
5950
|
+
room = null
|
|
5951
|
+
roomId = ''
|
|
5952
|
+
seat = -1
|
|
5953
|
+
await renderLobby()
|
|
5954
|
+
return
|
|
5955
|
+
}
|
|
5956
|
+
hint.textContent = '状态读取失败:' + friendly(e)
|
|
5798
5957
|
}
|
|
5799
5958
|
}
|
|
5800
5959
|
|
|
5801
5960
|
const renderWaiting = () => {
|
|
5802
5961
|
bodyEl.textContent = ''
|
|
5803
5962
|
roomEl.textContent = '房间 ' + roomId
|
|
5804
|
-
const
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
const
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5963
|
+
const seats = room.seats || []
|
|
5964
|
+
const meSeat = seats[seat] || null
|
|
5965
|
+
const iAmOwner = room.owner === auth.id
|
|
5966
|
+
|
|
5967
|
+
const head = document.createElement('div')
|
|
5968
|
+
head.style.cssText = 'display:flex;align-items:center;gap:8px;margin:2px 0 10px'
|
|
5969
|
+
const code = document.createElement('span')
|
|
5970
|
+
code.textContent = '牌桌 #' + roomId
|
|
5971
|
+
code.style.cssText = 'font-size:13px;font-weight:700;color:#5b3a63'
|
|
5972
|
+
head.appendChild(code)
|
|
5973
|
+
head.appendChild(
|
|
5974
|
+
btn('复制房间号', async () => {
|
|
5975
|
+
try {
|
|
5976
|
+
await navigator.clipboard.writeText(String(roomId))
|
|
5977
|
+
onToast('房间号已复制,发给好友就能进')
|
|
5978
|
+
} catch (e) {
|
|
5979
|
+
onToast('复制失败,手动记一下:' + roomId)
|
|
5980
|
+
}
|
|
5981
|
+
}),
|
|
5982
|
+
)
|
|
5983
|
+
bodyEl.appendChild(head)
|
|
5984
|
+
|
|
5985
|
+
const grid = document.createElement('div')
|
|
5986
|
+
grid.style.cssText = 'display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:10px'
|
|
5987
|
+
for (let i = 0; i < 4; i++) {
|
|
5988
|
+
const st = seats[i] || { seat: i, empty: true }
|
|
5989
|
+
const mine = i === seat
|
|
5990
|
+
const card = document.createElement('div')
|
|
5991
|
+
card.style.cssText =
|
|
5992
|
+
'display:flex;align-items:center;gap:9px;padding:9px 10px;border-radius:14px;background:#fff;' +
|
|
5993
|
+
'border:1.5px solid ' + (mine ? '#ff9ec4' : '#ffe3f0') + ';' +
|
|
5994
|
+
(mine ? 'box-shadow:0 4px 12px rgba(255,120,180,.16);' : '')
|
|
5995
|
+
card.appendChild(seatAvatarEl(st, 38))
|
|
5996
|
+
const info = document.createElement('div')
|
|
5997
|
+
info.style.cssText = 'min-width:0;flex:1'
|
|
5998
|
+
const nm = document.createElement('div')
|
|
5999
|
+
nm.textContent = st.empty ? '空位' : st.bot ? '机器人' : st.name || '座位 ' + (i + 1)
|
|
6000
|
+
nm.style.cssText =
|
|
6001
|
+
'font-size:12.5px;font-weight:650;color:#4a2b52;white-space:nowrap;overflow:hidden;text-overflow:ellipsis'
|
|
6002
|
+
info.appendChild(nm)
|
|
6003
|
+
const stt = document.createElement('div')
|
|
6004
|
+
stt.textContent = st.empty
|
|
6005
|
+
? '等人进来'
|
|
6006
|
+
: st.bot
|
|
6007
|
+
? '机器人补位'
|
|
6008
|
+
: st.ready
|
|
6009
|
+
? mine
|
|
6010
|
+
? '你已准备'
|
|
6011
|
+
: '已准备'
|
|
6012
|
+
: mine
|
|
6013
|
+
? '你还没准备'
|
|
6014
|
+
: '准备中…'
|
|
6015
|
+
stt.style.cssText = 'font-size:11px;color:' + (st.ready || st.bot ? '#2f8f65' : '#a184b3')
|
|
6016
|
+
info.appendChild(stt)
|
|
6017
|
+
card.appendChild(info)
|
|
6018
|
+
if (st.bot && iAmOwner) {
|
|
6019
|
+
card.appendChild(
|
|
6020
|
+
btn('移除', async () => {
|
|
6021
|
+
try {
|
|
6022
|
+
await api2('POST', '/api/mj/rooms/' + roomId + '/removebot', { seat: i })
|
|
6023
|
+
await render()
|
|
6024
|
+
} catch (e) {
|
|
6025
|
+
onToast('移除失败:' + friendly(e))
|
|
6026
|
+
}
|
|
6027
|
+
}),
|
|
6028
|
+
)
|
|
6029
|
+
}
|
|
6030
|
+
grid.appendChild(card)
|
|
6031
|
+
}
|
|
6032
|
+
bodyEl.appendChild(grid)
|
|
6033
|
+
|
|
6034
|
+
const acts = document.createElement('div')
|
|
6035
|
+
acts.style.cssText = 'display:flex;gap:6px;flex-wrap:wrap;align-items:center'
|
|
6036
|
+
if (meSeat && meSeat.id) {
|
|
6037
|
+
acts.appendChild(
|
|
6038
|
+
btn(
|
|
6039
|
+
meSeat.ready ? '取消准备' : '准备',
|
|
6040
|
+
async () => {
|
|
6041
|
+
try {
|
|
6042
|
+
await api2('POST', '/api/mj/rooms/' + roomId + '/ready', {})
|
|
6043
|
+
await render()
|
|
6044
|
+
} catch (e) {
|
|
6045
|
+
onToast('操作失败:' + friendly(e))
|
|
6046
|
+
}
|
|
6047
|
+
},
|
|
6048
|
+
!meSeat.ready,
|
|
6049
|
+
),
|
|
6050
|
+
)
|
|
6051
|
+
}
|
|
6052
|
+
if (iAmOwner) {
|
|
6053
|
+
if (room.freeSeats > 0) {
|
|
6054
|
+
acts.appendChild(
|
|
6055
|
+
btn('+ 添加机器人', async () => {
|
|
6056
|
+
try {
|
|
6057
|
+
await api2('POST', '/api/mj/rooms/' + roomId + '/bots', {})
|
|
6058
|
+
await render()
|
|
6059
|
+
} catch (e) {
|
|
6060
|
+
onToast('加机器人失败:' + friendly(e))
|
|
6061
|
+
}
|
|
6062
|
+
}),
|
|
6063
|
+
)
|
|
6064
|
+
}
|
|
6065
|
+
const startBtn = btn(
|
|
6066
|
+
room.canStart ? '开局' : '等待准备…',
|
|
6067
|
+
async () => {
|
|
5815
6068
|
try {
|
|
5816
6069
|
await api2('POST', '/api/mj/rooms/' + roomId + '/start')
|
|
5817
|
-
render()
|
|
6070
|
+
await render()
|
|
5818
6071
|
} catch (e) {
|
|
5819
6072
|
onToast('开局失败:' + friendly(e))
|
|
5820
6073
|
}
|
|
5821
|
-
},
|
|
6074
|
+
},
|
|
6075
|
+
!!room.canStart,
|
|
5822
6076
|
)
|
|
6077
|
+
if (!room.canStart) startBtn.style.opacity = '.45'
|
|
6078
|
+
acts.appendChild(startBtn)
|
|
5823
6079
|
}
|
|
6080
|
+
acts.appendChild(
|
|
6081
|
+
btn('退出牌桌', async () => {
|
|
6082
|
+
try {
|
|
6083
|
+
await api2('POST', '/api/mj/rooms/' + roomId + '/leave')
|
|
6084
|
+
} catch (e) {
|
|
6085
|
+
/* 忽略 */
|
|
6086
|
+
}
|
|
6087
|
+
state = null
|
|
6088
|
+
room = null
|
|
6089
|
+
roomId = ''
|
|
6090
|
+
seat = -1
|
|
6091
|
+
renderLobby()
|
|
6092
|
+
}),
|
|
6093
|
+
)
|
|
6094
|
+
if (iAmOwner) acts.appendChild(btn('解散牌桌', dissolveRoom))
|
|
6095
|
+
bodyEl.appendChild(acts)
|
|
6096
|
+
|
|
6097
|
+
const tip = document.createElement('div')
|
|
6098
|
+
tip.style.cssText = 'font-size:11.5px;color:#a184b3;margin-top:8px;line-height:1.6'
|
|
6099
|
+
tip.textContent = room.canStart
|
|
6100
|
+
? '人齐了、都准备好了 —— 点「开局」开打'
|
|
6101
|
+
: '空位可以等人进来,也可以由房主加机器人补上;满 4 人且所有真人准备后自动开局'
|
|
6102
|
+
bodyEl.appendChild(tip)
|
|
5824
6103
|
}
|
|
5825
6104
|
|
|
5826
6105
|
const act = async (payload) => {
|
|
@@ -5838,7 +6117,19 @@ window.__ModuleLoader__.load({
|
|
|
5838
6117
|
|
|
5839
6118
|
// 只轮询牌桌;大厅不刷,避免列表一直闪
|
|
5840
6119
|
const tick = async () => {
|
|
5841
|
-
if (stopped
|
|
6120
|
+
if (stopped) return
|
|
6121
|
+
if (!roomId) {
|
|
6122
|
+
// 在大厅:每 3 秒看看有没有新桌 / 有没有人进来
|
|
6123
|
+
try {
|
|
6124
|
+
const r = await api2('GET', '/api/mj/rooms')
|
|
6125
|
+
const rooms = (r.rooms || []).filter((x) => !x.ended)
|
|
6126
|
+
const sig = JSON.stringify(rooms.map((x) => [x.id, x.humanCount, x.started, x.freeSeats]))
|
|
6127
|
+
if (sig !== lobbySig) renderLobby()
|
|
6128
|
+
} catch (e) {
|
|
6129
|
+
/* 忽略 */
|
|
6130
|
+
}
|
|
6131
|
+
return
|
|
6132
|
+
}
|
|
5842
6133
|
await render()
|
|
5843
6134
|
}
|
|
5844
6135
|
|
|
@@ -5947,6 +6238,782 @@ window.__ModuleLoader__.load({
|
|
|
5947
6238
|
})
|
|
5948
6239
|
}
|
|
5949
6240
|
|
|
6241
|
+
/* ---------- 阿瓦隆 ---------- */
|
|
6242
|
+
const AV_ROLES = {
|
|
6243
|
+
merlin: '梅林', percival: '派西维尔', loyalServant: '忠臣', minion: '爪牙',
|
|
6244
|
+
morgana: '莫甘娜', assassin: '刺客', oberon: '奥伯伦', mordred: '莫德雷德',
|
|
6245
|
+
lancelotGood: '兰斯洛特(善)', lancelotEvil: '兰斯洛特(恶)',
|
|
6246
|
+
}
|
|
6247
|
+
const AV_STAGE = {
|
|
6248
|
+
teamBuilding: '组队', teamVote: '投票', quest: '任务', excalibur: '圣剑', discussion: '发言', lead: '队长选车', final: '最终定车', vote: '投票',
|
|
6249
|
+
ladyOfTheLake: '湖中仙女', assassination: '刺杀', ended: '结束',
|
|
6250
|
+
}
|
|
6251
|
+
|
|
6252
|
+
function openAvalon(opts) {
|
|
6253
|
+
const avSeatAvatar = (st, size) => {
|
|
6254
|
+
const sz = size || 32
|
|
6255
|
+
const el = document.createElement('div')
|
|
6256
|
+
if (st && st.bot) {
|
|
6257
|
+
el.textContent = '🤖'
|
|
6258
|
+
el.style.cssText = 'width:' + sz + 'px;height:' + sz + 'px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:' + Math.round(sz * 0.5) + 'px;background:#ece4f6'
|
|
6259
|
+
} else if (!st || !st.id) {
|
|
6260
|
+
el.textContent = '+'
|
|
6261
|
+
el.style.cssText = 'width:' + sz + 'px;height:' + sz + 'px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:' + Math.round(sz * 0.55) + 'px;color:#c9a8d8;background:#faf5ff;border:1.5px dashed #e3c8ef;box-sizing:border-box'
|
|
6262
|
+
} else {
|
|
6263
|
+
const hue = hueOf(st.id)
|
|
6264
|
+
el.textContent = String(st.name || '?').slice(-1)
|
|
6265
|
+
el.style.cssText = 'width:' + sz + 'px;height:' + sz + 'px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:' + Math.round(sz * 0.45) + 'px;color:#fff;background:hsl(' + hue + ' 55% 58%)'
|
|
6266
|
+
if (st.ready) el.style.boxShadow = '0 0 0 2px #0f1b2e, 0 0 0 4px #3ddc97'
|
|
6267
|
+
}
|
|
6268
|
+
return el
|
|
6269
|
+
}
|
|
6270
|
+
|
|
6271
|
+
const auth = opts.auth
|
|
6272
|
+
const onToast = opts.onToast || (() => {})
|
|
6273
|
+
const api3 = (m, path, b) => api(auth.server, path, { method: m, token: auth.token, body: b })
|
|
6274
|
+
|
|
6275
|
+
const wrap = document.createElement('div')
|
|
6276
|
+
wrap.style.cssText = [
|
|
6277
|
+
'position:fixed', 'right:18px', 'bottom:18px', 'width:520px', 'max-width:calc(100vw - 16px)',
|
|
6278
|
+
'height:640px', 'max-height:calc(100vh - 24px)', 'z-index:2147483646', 'display:flex',
|
|
6279
|
+
'flex-direction:column', 'border-radius:16px', 'overflow:hidden',
|
|
6280
|
+
'background:linear-gradient(180deg,#0f1b2e,#0b1522)', 'color:#e8eefc',
|
|
6281
|
+
'border:1px solid rgba(140,170,220,.28)', 'box-shadow:0 18px 50px rgba(0,0,0,.5),0 0 0 1px rgba(255,255,255,.04) inset',
|
|
6282
|
+
].join(';')
|
|
6283
|
+
|
|
6284
|
+
const head = document.createElement('div')
|
|
6285
|
+
head.style.cssText = 'display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid rgba(140,170,220,.2)'
|
|
6286
|
+
const title = document.createElement('div')
|
|
6287
|
+
title.textContent = '🏰 阿瓦隆'
|
|
6288
|
+
title.style.cssText = 'font-size:13px;font-weight:700'
|
|
6289
|
+
head.appendChild(title)
|
|
6290
|
+
const hint = document.createElement('div')
|
|
6291
|
+
hint.style.cssText = 'font-size:11px;color:#8fa6c8;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap'
|
|
6292
|
+
head.appendChild(hint)
|
|
6293
|
+
let micStream = null
|
|
6294
|
+
let micOn = false
|
|
6295
|
+
const voiceBtn = document.createElement('button')
|
|
6296
|
+
voiceBtn.textContent = '🎤 语音'
|
|
6297
|
+
voiceBtn.style.cssText = 'padding:4px 10px;border-radius:8px;border:1px solid rgba(140,170,220,.3);background:transparent;color:inherit;font:inherit;font-size:11.5px;cursor:pointer'
|
|
6298
|
+
voiceBtn.addEventListener('click', async () => {
|
|
6299
|
+
if (micOn) {
|
|
6300
|
+
try { micStream.getTracks().forEach((t) => t.stop()) } catch (e) {}
|
|
6301
|
+
micStream = null
|
|
6302
|
+
micOn = false
|
|
6303
|
+
voiceBtn.textContent = '🎤 语音'
|
|
6304
|
+
onToast('已关闭麦克风')
|
|
6305
|
+
return
|
|
6306
|
+
}
|
|
6307
|
+
try {
|
|
6308
|
+
micStream = await navigator.mediaDevices.getUserMedia({ audio: true })
|
|
6309
|
+
micOn = true
|
|
6310
|
+
voiceBtn.textContent = '🎤 已开麦'
|
|
6311
|
+
onToast('麦克风已开启')
|
|
6312
|
+
} catch (e) {
|
|
6313
|
+
onToast('打不开麦克风:' + ((e && e.message) || e))
|
|
6314
|
+
}
|
|
6315
|
+
})
|
|
6316
|
+
head.appendChild(voiceBtn)
|
|
6317
|
+
const closeBtn = document.createElement('button')
|
|
6318
|
+
closeBtn.textContent = '关闭'
|
|
6319
|
+
closeBtn.style.cssText = 'padding:4px 10px;border-radius:8px;border:1px solid rgba(140,170,220,.3);background:transparent;color:inherit;font:inherit;font-size:11.5px;cursor:pointer'
|
|
6320
|
+
head.appendChild(closeBtn)
|
|
6321
|
+
wrap.appendChild(head)
|
|
6322
|
+
|
|
6323
|
+
const body = document.createElement('div')
|
|
6324
|
+
body.style.cssText = 'flex:1;min-height:0;overflow:auto;padding:12px'
|
|
6325
|
+
wrap.appendChild(body)
|
|
6326
|
+
|
|
6327
|
+
const foot = document.createElement('div')
|
|
6328
|
+
foot.style.cssText = 'padding:8px 12px;border-top:1px solid rgba(140,170,220,.2);display:flex;gap:6px;flex-wrap:wrap'
|
|
6329
|
+
wrap.appendChild(foot)
|
|
6330
|
+
|
|
6331
|
+
const btn = (t, fn, primary) => {
|
|
6332
|
+
const b = document.createElement('button')
|
|
6333
|
+
b.textContent = t
|
|
6334
|
+
b.style.cssText =
|
|
6335
|
+
'padding:6px 12px;border-radius:9px;font:inherit;font-size:12px;cursor:pointer;' +
|
|
6336
|
+
(primary
|
|
6337
|
+
? 'border:none;background:linear-gradient(135deg,#5b8cff,#7a5cff);color:#fff;font-weight:700;'
|
|
6338
|
+
: 'border:1px solid rgba(140,170,220,.3);background:rgba(255,255,255,.04);color:inherit;')
|
|
6339
|
+
b.addEventListener('click', fn)
|
|
6340
|
+
return b
|
|
6341
|
+
}
|
|
6342
|
+
const chipEl = (t) => {
|
|
6343
|
+
const c = document.createElement('span')
|
|
6344
|
+
c.textContent = t
|
|
6345
|
+
c.style.cssText = 'font-size:11px;padding:2px 8px;border-radius:99px;background:rgba(120,150,220,.16);border:1px solid rgba(140,170,220,.28);color:#cfe0ff'
|
|
6346
|
+
return c
|
|
6347
|
+
}
|
|
6348
|
+
|
|
6349
|
+
let roomId = ''
|
|
6350
|
+
let room = null
|
|
6351
|
+
let seat = -1
|
|
6352
|
+
let view = null
|
|
6353
|
+
let picking = []
|
|
6354
|
+
let stopped = false
|
|
6355
|
+
let timer = null
|
|
6356
|
+
|
|
6357
|
+
const reset = () => {
|
|
6358
|
+
roomId = ''
|
|
6359
|
+
room = null
|
|
6360
|
+
seat = -1
|
|
6361
|
+
view = null
|
|
6362
|
+
picking = []
|
|
6363
|
+
}
|
|
6364
|
+
|
|
6365
|
+
const renderLobby = async () => {
|
|
6366
|
+
body.textContent = ''
|
|
6367
|
+
foot.textContent = ''
|
|
6368
|
+
hint.textContent = '选人数开房,或加入一张桌子'
|
|
6369
|
+
const row = document.createElement('div')
|
|
6370
|
+
row.style.cssText = 'display:flex;gap:6px;align-items:center;margin-bottom:10px'
|
|
6371
|
+
const sel = document.createElement('select')
|
|
6372
|
+
sel.style.cssText = 'padding:6px 8px;border-radius:9px;background:#122238;color:inherit;border:1px solid rgba(140,170,220,.3);font:inherit;font-size:12px'
|
|
6373
|
+
for (let n = 5; n <= 10; n++) {
|
|
6374
|
+
const o = document.createElement('option')
|
|
6375
|
+
o.value = String(n)
|
|
6376
|
+
o.textContent = n + ' 人'
|
|
6377
|
+
if (n === 7) o.selected = true
|
|
6378
|
+
sel.appendChild(o)
|
|
6379
|
+
}
|
|
6380
|
+
row.appendChild(sel)
|
|
6381
|
+
const mk = (label) => {
|
|
6382
|
+
const lab = document.createElement('label')
|
|
6383
|
+
lab.style.cssText = 'display:flex;align-items:center;gap:4px;font-size:11.5px;color:#a9bede;cursor:pointer'
|
|
6384
|
+
const cb = document.createElement('input')
|
|
6385
|
+
cb.type = 'checkbox'
|
|
6386
|
+
cb.style.accentColor = '#5b8cff'
|
|
6387
|
+
lab.appendChild(cb)
|
|
6388
|
+
lab.appendChild(document.createTextNode(label))
|
|
6389
|
+
return { lab, cb }
|
|
6390
|
+
}
|
|
6391
|
+
const optLady = mk('湖中仙女')
|
|
6392
|
+
const optEx = mk('圣剑')
|
|
6393
|
+
row.appendChild(optLady.lab)
|
|
6394
|
+
row.appendChild(optEx.lab)
|
|
6395
|
+
row.appendChild(btn('+ 新建房间', async () => {
|
|
6396
|
+
try {
|
|
6397
|
+
const r = await api3('POST', '/api/av/rooms', {
|
|
6398
|
+
size: Number(sel.value),
|
|
6399
|
+
options: { ladyOfTheLake: optLady.cb.checked, excalibur: optEx.cb.checked },
|
|
6400
|
+
})
|
|
6401
|
+
roomId = r.room.id
|
|
6402
|
+
seat = 0
|
|
6403
|
+
await render()
|
|
6404
|
+
} catch (e) {
|
|
6405
|
+
onToast('建房失败:' + friendly(e))
|
|
6406
|
+
}
|
|
6407
|
+
}, true))
|
|
6408
|
+
body.appendChild(row)
|
|
6409
|
+
|
|
6410
|
+
try {
|
|
6411
|
+
const r = await api3('GET', '/api/av/rooms')
|
|
6412
|
+
const rooms = (r.rooms || []).filter((x) => !x.ended)
|
|
6413
|
+
if (!rooms.length) {
|
|
6414
|
+
const e = document.createElement('div')
|
|
6415
|
+
e.textContent = '还没有房间,新建一个吧'
|
|
6416
|
+
e.style.cssText = 'font-size:12px;color:#8fa6c8'
|
|
6417
|
+
body.appendChild(e)
|
|
6418
|
+
}
|
|
6419
|
+
for (const rm of rooms) {
|
|
6420
|
+
const line = document.createElement('div')
|
|
6421
|
+
line.style.cssText = 'display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:10px;background:rgba(255,255,255,.04);border:1px solid rgba(140,170,220,.2);margin-bottom:6px'
|
|
6422
|
+
const t = document.createElement('span')
|
|
6423
|
+
t.textContent = '#' + rm.id + ' · ' + rm.seats.filter((x) => x.id).length + '/' + rm.size + (rm.started ? ' · 进行中' : '')
|
|
6424
|
+
t.style.cssText = 'flex:1;font-size:12px'
|
|
6425
|
+
line.appendChild(t)
|
|
6426
|
+
line.appendChild(btn(rm.started ? '观战' : '加入', async () => {
|
|
6427
|
+
try {
|
|
6428
|
+
const j = await api3('POST', '/api/av/rooms/' + rm.id + '/join')
|
|
6429
|
+
roomId = rm.id
|
|
6430
|
+
seat = j.seat
|
|
6431
|
+
await render()
|
|
6432
|
+
} catch (e) {
|
|
6433
|
+
onToast('加入失败:' + friendly(e))
|
|
6434
|
+
}
|
|
6435
|
+
}))
|
|
6436
|
+
body.appendChild(line)
|
|
6437
|
+
}
|
|
6438
|
+
} catch (e) {
|
|
6439
|
+
hint.textContent = '房间列表读取失败'
|
|
6440
|
+
}
|
|
6441
|
+
}
|
|
6442
|
+
|
|
6443
|
+
const renderWaiting = () => {
|
|
6444
|
+
body.textContent = ''
|
|
6445
|
+
foot.textContent = ''
|
|
6446
|
+
hint.textContent = '房间 #' + roomId + ' · 准备中'
|
|
6447
|
+
const isOwner = room.owner === auth.id
|
|
6448
|
+
const pv = room.preview || {}
|
|
6449
|
+
const chars = pv.characters || []
|
|
6450
|
+
const quests = pv.quests || []
|
|
6451
|
+
const cnt = {}
|
|
6452
|
+
chars.forEach((k) => { cnt[k] = (cnt[k] || 0) + 1 })
|
|
6453
|
+
|
|
6454
|
+
// 座位(头像 + 准备状态)
|
|
6455
|
+
const grid = document.createElement('div')
|
|
6456
|
+
grid.style.cssText = 'display:grid;grid-template-columns:repeat(2,1fr);gap:6px;margin-bottom:10px'
|
|
6457
|
+
room.seats.forEach((st, i) => {
|
|
6458
|
+
const line = document.createElement('div')
|
|
6459
|
+
line.style.cssText = 'display:flex;align-items:center;gap:8px;padding:7px 9px;border-radius:10px;background:rgba(255,255,255,.04);border:1px solid rgba(140,170,220,.2)'
|
|
6460
|
+
line.appendChild(avSeatAvatar({ ...st, ready: !!((room.ready || [])[i] || st.bot) }, 32))
|
|
6461
|
+
const info = document.createElement('div')
|
|
6462
|
+
info.style.cssText = 'min-width:0;flex:1'
|
|
6463
|
+
const nm = document.createElement('div')
|
|
6464
|
+
nm.textContent = (i === 0 ? '👑 ' : '') + (st.empty ? '空位' : st.bot ? '机器人' : st.name)
|
|
6465
|
+
nm.style.cssText = 'font-size:12px;color:' + (i === seat ? '#9fc0ff' : '#e8eefc')
|
|
6466
|
+
info.appendChild(nm)
|
|
6467
|
+
const sd = document.createElement('div')
|
|
6468
|
+
sd.textContent = st.empty ? '等人' : st.bot ? '机器人补位' : ((room.ready || [])[i] ? '已准备' : '未准备')
|
|
6469
|
+
sd.style.cssText = 'font-size:10.5px;color:' + ((room.ready || [])[i] || st.bot ? '#7ef0b0' : '#8fa6c8')
|
|
6470
|
+
info.appendChild(sd)
|
|
6471
|
+
line.appendChild(info)
|
|
6472
|
+
grid.appendChild(line)
|
|
6473
|
+
})
|
|
6474
|
+
body.appendChild(grid)
|
|
6475
|
+
|
|
6476
|
+
// 角色配置
|
|
6477
|
+
const roleBox = document.createElement('div')
|
|
6478
|
+
roleBox.style.cssText = 'padding:8px 10px;border-radius:10px;background:rgba(90,130,220,.12);border:1px solid rgba(140,170,220,.28);margin-bottom:8px'
|
|
6479
|
+
roleBox.innerHTML =
|
|
6480
|
+
'<div style="font-size:12px;font-weight:700;margin-bottom:4px">角色配置(' + room.size + ' 人)</div>' +
|
|
6481
|
+
'<div style="font-size:11.5px;color:#a9bede">' + Object.keys(cnt).map((k) => (AV_ROLES[k] || k) + (cnt[k] > 1 ? '×' + cnt[k] : '')).join('、') + '</div>'
|
|
6482
|
+
body.appendChild(roleBox)
|
|
6483
|
+
|
|
6484
|
+
// 规则:5 轮
|
|
6485
|
+
const ruleBox = document.createElement('div')
|
|
6486
|
+
ruleBox.style.cssText = 'padding:8px 10px;border-radius:10px;background:rgba(255,255,255,.04);border:1px solid rgba(140,170,220,.22);margin-bottom:8px'
|
|
6487
|
+
let html = '<div style="font-size:12px;font-weight:700;margin-bottom:4px">规则</div>'
|
|
6488
|
+
html += '<div style="font-size:11px;color:#a9bede;line-height:1.7">5 轮任务 · 3 轮成功正义胜(再刺杀梅林)· 3 轮失败邪恶胜<br>每轮否决额度 ' + (pv.teamProposalLimit || room.size + 1) + ' 次,用尽则本轮任务判失败</div>'
|
|
6489
|
+
html += '<div style="display:grid;grid-template-columns:repeat(5,1fr);gap:4px;margin-top:6px">'
|
|
6490
|
+
quests.forEach((q, i) => {
|
|
6491
|
+
html += '<div style="padding:4px;border-radius:7px;background:rgba(120,150,220,.14);text-align:center;font-size:10px;line-height:1.5">第' + (i + 1) + '轮<br>' + q.teamSize + '人上车<br>需' + q.failsRequired + '败</div>'
|
|
6492
|
+
})
|
|
6493
|
+
html += '</div>'
|
|
6494
|
+
ruleBox.innerHTML = html
|
|
6495
|
+
body.appendChild(ruleBox)
|
|
6496
|
+
|
|
6497
|
+
// 房主选项
|
|
6498
|
+
if (isOwner) {
|
|
6499
|
+
const opt = document.createElement('div')
|
|
6500
|
+
opt.style.cssText = 'display:flex;gap:8px;margin-bottom:8px;font-size:11.5px'
|
|
6501
|
+
const mk = (label, checked, onChange) => {
|
|
6502
|
+
const lab = document.createElement('label')
|
|
6503
|
+
lab.style.cssText = 'display:flex;align-items:center;gap:4px;cursor:pointer'
|
|
6504
|
+
const cb = document.createElement('input')
|
|
6505
|
+
cb.type = 'checkbox'
|
|
6506
|
+
cb.checked = !!checked
|
|
6507
|
+
cb.style.accentColor = '#5b8cff'
|
|
6508
|
+
cb.addEventListener('change', onChange)
|
|
6509
|
+
lab.appendChild(cb)
|
|
6510
|
+
lab.appendChild(document.createTextNode(label))
|
|
6511
|
+
return lab
|
|
6512
|
+
}
|
|
6513
|
+
opt.appendChild(mk('湖中仙女', room.options && room.options.ladyOfTheLake, async (e) => {
|
|
6514
|
+
try { await api3('POST', '/api/av/rooms/' + roomId + '/options', { ladyOfTheLake: e.target.checked, excalibur: !!(room.options && room.options.excalibur) }); await render() } catch (err) { onToast('设置失败:' + friendly(err)) }
|
|
6515
|
+
}))
|
|
6516
|
+
opt.appendChild(mk('圣剑', room.options && room.options.excalibur, async (e) => {
|
|
6517
|
+
try { await api3('POST', '/api/av/rooms/' + roomId + '/options', { ladyOfTheLake: !!(room.options && room.options.ladyOfTheLake), excalibur: e.target.checked }); await render() } catch (err) { onToast('设置失败:' + friendly(err)) }
|
|
6518
|
+
}))
|
|
6519
|
+
body.appendChild(opt)
|
|
6520
|
+
}
|
|
6521
|
+
|
|
6522
|
+
// 底部操作
|
|
6523
|
+
if (seat >= 0) {
|
|
6524
|
+
const rd = (room.ready || [])[seat]
|
|
6525
|
+
foot.appendChild(btn(rd ? '取消准备' : '准备', async () => {
|
|
6526
|
+
try { await api3('POST', '/api/av/rooms/' + roomId + '/ready'); await render() } catch (e) { onToast('操作失败:' + friendly(e)) }
|
|
6527
|
+
}, !rd))
|
|
6528
|
+
}
|
|
6529
|
+
if (isOwner) {
|
|
6530
|
+
if (room.seats.some((x) => x.empty)) {
|
|
6531
|
+
foot.appendChild(btn('+ 机器人', async () => {
|
|
6532
|
+
try { await api3('POST', '/api/av/rooms/' + roomId + '/bots'); await render() } catch (e) { onToast('加机器人失败:' + friendly(e)) }
|
|
6533
|
+
}))
|
|
6534
|
+
}
|
|
6535
|
+
const humans = room.seats.map((x, i) => (x.id ? i : -1)).filter((i) => i >= 0)
|
|
6536
|
+
const allReady = humans.every((i) => (room.ready || [])[i])
|
|
6537
|
+
const sb = btn(allReady ? '开始游戏' : '等待准备…', async () => {
|
|
6538
|
+
try { await api3('POST', '/api/av/rooms/' + roomId + '/start'); await render() } catch (e) { onToast('开局失败:' + friendly(e)) }
|
|
6539
|
+
}, allReady)
|
|
6540
|
+
if (!allReady) sb.style.opacity = '.5'
|
|
6541
|
+
foot.appendChild(sb)
|
|
6542
|
+
}
|
|
6543
|
+
foot.appendChild(btn('复制房间号', async () => {
|
|
6544
|
+
try { await navigator.clipboard.writeText(String(roomId)); onToast('已复制') } catch (e) { onToast('房间号:' + roomId) }
|
|
6545
|
+
}))
|
|
6546
|
+
foot.appendChild(btn('退出', async () => {
|
|
6547
|
+
try { await api3('POST', '/api/av/rooms/' + roomId + '/leave') } catch (e) {}
|
|
6548
|
+
reset()
|
|
6549
|
+
await renderLobby()
|
|
6550
|
+
}))
|
|
6551
|
+
if (isOwner) {
|
|
6552
|
+
foot.appendChild(btn('解散房间', async () => {
|
|
6553
|
+
if (!window.confirm('解散房间?')) return
|
|
6554
|
+
try { await api3('POST', '/api/av/rooms/' + roomId + '/leave') } catch (e) {}
|
|
6555
|
+
reset()
|
|
6556
|
+
await renderLobby()
|
|
6557
|
+
}))
|
|
6558
|
+
}
|
|
6559
|
+
}
|
|
6560
|
+
|
|
6561
|
+
const renderGame = () => {
|
|
6562
|
+
body.textContent = ''
|
|
6563
|
+
foot.textContent = ''
|
|
6564
|
+
const v = view
|
|
6565
|
+
const quests = v.quests || []
|
|
6566
|
+
const activeIdx = quests.findIndex((q) => q.status === 'active')
|
|
6567
|
+
const doneOf = (q) => q && (q.status === 'succeeded' || q.status === 'failed' || q.status === 'resolved')
|
|
6568
|
+
const roundNo = (activeIdx >= 0 ? activeIdx : quests.filter(doneOf).length) + 1
|
|
6569
|
+
const active = quests[activeIdx] || null
|
|
6570
|
+
const proposals = active ? active.teams.length : 0
|
|
6571
|
+
const maxProposals = (v.rule && v.rule.teamProposalLimit && v.rule.teamProposalLimit.max) || 5
|
|
6572
|
+
const quota = room.size + 1 // 允许否决「人数」次,第「人数+1」次判本轮失败
|
|
6573
|
+
const left = Math.max(0, quota - proposals)
|
|
6574
|
+
const voteSeat = active && active.teams.length ? active.teams[active.teams.length - 1] : null
|
|
6575
|
+
const votedCount = voteSeat ? voteSeat.voted.filter(Boolean).length : 0
|
|
6576
|
+
|
|
6577
|
+
hint.textContent = '第 ' + roundNo + '/5 轮 · ' + (AV_STAGE[phase] || AV_STAGE[v.stage] || v.stage)
|
|
6578
|
+
|
|
6579
|
+
// 进度条:轮次 + 组队次数
|
|
6580
|
+
const strip = document.createElement('div')
|
|
6581
|
+
strip.style.cssText = 'display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px'
|
|
6582
|
+
strip.appendChild(chipEl('第 ' + roundNo + ' / 5 轮'))
|
|
6583
|
+
strip.appendChild(chipEl('第 ' + (proposals + (active && active.teams.length && (v.stage === 'teamVote' || v.stage === 'quest') ? 0 : 1)) + ' 次组队'))
|
|
6584
|
+
strip.appendChild(chipEl('本轮否决 ' + proposals + '/' + quota + ' 次'))
|
|
6585
|
+
if (phase === 'lead') strip.appendChild(chipEl('队长选车 ' + Math.ceil(leaderLeft / 1000) + 's'))
|
|
6586
|
+
if (phase === 'final') strip.appendChild(chipEl('最终定车 ' + Math.ceil(finalLeft / 1000) + 's'))
|
|
6587
|
+
if (voteSeat && v.stage === 'teamVote') strip.appendChild(chipEl('已投票 ' + votedCount + '/' + room.size))
|
|
6588
|
+
body.appendChild(strip)
|
|
6589
|
+
|
|
6590
|
+
if (left === 1) {
|
|
6591
|
+
const warn = document.createElement('div')
|
|
6592
|
+
warn.textContent = '⚠️ 再否决一次,本轮任务直接判失败,进入下一轮'
|
|
6593
|
+
warn.style.cssText = 'font-size:11.5px;color:#ffcf3d;margin:-4px 0 8px'
|
|
6594
|
+
body.appendChild(warn)
|
|
6595
|
+
}
|
|
6596
|
+
|
|
6597
|
+
// 5 轮任务标记
|
|
6598
|
+
const track = document.createElement('div')
|
|
6599
|
+
track.style.cssText = 'display:grid;grid-template-columns:repeat(5,1fr);gap:5px;margin-bottom:10px'
|
|
6600
|
+
quests.forEach((q, i) => {
|
|
6601
|
+
const box = document.createElement('div')
|
|
6602
|
+
const done = doneOf(q)
|
|
6603
|
+
const ok = done && (q.status === 'succeeded' || (q.result && q.result.success))
|
|
6604
|
+
box.style.cssText =
|
|
6605
|
+
'padding:6px 4px;border-radius:9px;text-align:center;font-size:10.5px;line-height:1.5;' +
|
|
6606
|
+
'border:1px solid ' + (i === activeIdx ? 'rgba(120,170,255,.7)' : 'rgba(140,170,220,.22)') + ';' +
|
|
6607
|
+
'background:' + (done ? (ok ? 'rgba(60,200,140,.18)' : 'rgba(255,95,162,.16)') : i === activeIdx ? 'rgba(90,130,220,.18)' : 'rgba(255,255,255,.03)')
|
|
6608
|
+
box.textContent = '第' + (i + 1) + '轮\n' + q.teamSize + '人/需' + q.failsRequired + '败\n' + (done ? (ok ? '✅ 成功' : '❌ 失败') : i === activeIdx ? '▶ 进行中' : '· 未开始')
|
|
6609
|
+
box.style.whiteSpace = 'pre-line'
|
|
6610
|
+
track.appendChild(box)
|
|
6611
|
+
})
|
|
6612
|
+
body.appendChild(track)
|
|
6613
|
+
|
|
6614
|
+
// 发言阶段
|
|
6615
|
+
if (discuss) {
|
|
6616
|
+
const box = document.createElement('div')
|
|
6617
|
+
box.style.cssText = 'padding:10px;border-radius:12px;background:rgba(255,207,61,.12);border:1px solid rgba(255,207,61,.4);margin-bottom:9px'
|
|
6618
|
+
const left = Math.max(0, Math.ceil((discuss.deadlineIn || 0) / 1000))
|
|
6619
|
+
const sp = discuss.spoke || []
|
|
6620
|
+
const t1 = document.createElement('div')
|
|
6621
|
+
t1.textContent = '💬 发言阶段:' + discuss.speaking + ' 号发言中 · 剩 ' + Math.floor(left / 60) + ':' + String(left % 60).padStart(2, '0')
|
|
6622
|
+
t1.style.cssText = 'font-size:12.5px;font-weight:700;color:#ffe9a8'
|
|
6623
|
+
box.appendChild(t1)
|
|
6624
|
+
const t2 = document.createElement('div')
|
|
6625
|
+
const ord = document.createElement('div')
|
|
6626
|
+
ord.textContent = '顺序:' + (speakOpts && speakOpts.selfFirst === false ? '队长最后' : '队长先') + ' · ' + (speakOpts && speakOpts.reverse ? '倒序' : '正序')
|
|
6627
|
+
ord.style.cssText = 'font-size:11px;color:#d8c79a;margin-top:3px'
|
|
6628
|
+
box.appendChild(ord)
|
|
6629
|
+
t2.textContent = '已发言:' + sp.map((x, i) => (x ? i + '号' : '')).filter(Boolean).join('、') + '(全员发完自动进入投票)'
|
|
6630
|
+
t2.style.cssText = 'font-size:11px;color:#d8c79a;margin-top:4px'
|
|
6631
|
+
box.appendChild(t2)
|
|
6632
|
+
if (discuss.speaking === seat) {
|
|
6633
|
+
box.appendChild(
|
|
6634
|
+
btn('我说完了', () => sendAction({ type: 'finishSpeak' }), true),
|
|
6635
|
+
)
|
|
6636
|
+
}
|
|
6637
|
+
body.appendChild(box)
|
|
6638
|
+
}
|
|
6639
|
+
|
|
6640
|
+
// 角色配置(公开信息)
|
|
6641
|
+
const comp = document.createElement('div')
|
|
6642
|
+
const cnt = {}
|
|
6643
|
+
;((v.rule && v.rule.characters) || []).forEach((k) => { cnt[k] = (cnt[k] || 0) + 1 })
|
|
6644
|
+
comp.textContent = '本局角色:' + Object.keys(cnt).map((k) => (AV_ROLES[k] || k) + (cnt[k] > 1 ? '×' + cnt[k] : '')).join('、')
|
|
6645
|
+
comp.style.cssText = 'font-size:11px;color:#9fb6d8;margin-bottom:6px'
|
|
6646
|
+
body.appendChild(comp)
|
|
6647
|
+
|
|
6648
|
+
// 我的身份
|
|
6649
|
+
const card = document.createElement('div')
|
|
6650
|
+
card.style.cssText = 'padding:9px 11px;border-radius:12px;background:rgba(90,130,220,.14);border:1px solid rgba(140,170,220,.3);margin-bottom:9px'
|
|
6651
|
+
const rc = document.createElement('div')
|
|
6652
|
+
rc.textContent = '你是 ' + (AV_ROLES[v.character] || v.character || '观战') + '(' + (v.alignment === 'evil' ? '邪恶' : '正义') + ')'
|
|
6653
|
+
rc.style.cssText = 'font-size:13px;font-weight:700'
|
|
6654
|
+
card.appendChild(rc)
|
|
6655
|
+
if (v.knownPlayers && v.knownPlayers.length) {
|
|
6656
|
+
const kp = document.createElement('div')
|
|
6657
|
+
kp.textContent = '你看到:' + v.knownPlayers.map((k) => k.seat + '号' + (k.character ? '(' + (AV_ROLES[k.character] || k.character) + ')' : '')).join('、')
|
|
6658
|
+
kp.style.cssText = 'font-size:11.5px;color:#a9bede;margin-top:3px'
|
|
6659
|
+
card.appendChild(kp)
|
|
6660
|
+
}
|
|
6661
|
+
body.appendChild(card)
|
|
6662
|
+
|
|
6663
|
+
// 初版车型(尚未提交引擎)
|
|
6664
|
+
if (draft && draft.length) {
|
|
6665
|
+
const dEl = document.createElement('div')
|
|
6666
|
+
dEl.textContent = '📝 初版车型(队长 ' + v.leader + ' 号):' + draft.map((m) => m + '号').join('、') + (phase === 'final' ? ' · 待最终确认' : '')
|
|
6667
|
+
dEl.style.cssText = 'font-size:11.5px;color:#ffe9a8;background:rgba(255,207,61,.1);border:1px solid rgba(255,207,61,.3);border-radius:9px;padding:6px 9px;margin-bottom:8px'
|
|
6668
|
+
body.appendChild(dEl)
|
|
6669
|
+
}
|
|
6670
|
+
|
|
6671
|
+
// 当前车队
|
|
6672
|
+
if (voteSeat) {
|
|
6673
|
+
const team = document.createElement('div')
|
|
6674
|
+
team.style.cssText = 'padding:8px 10px;border-radius:10px;background:rgba(255,255,255,.05);border:1px solid rgba(140,170,220,.25);margin-bottom:8px'
|
|
6675
|
+
team.textContent = '本轮车队(' + (voteSeat.leader) + '号 队长):' + voteSeat.members.map((m) => m + '号').join('、')
|
|
6676
|
+
team.style.cssText += ';font-size:12px'
|
|
6677
|
+
if (v.stage === 'teamVote') team.textContent += ' · 投票中 ' + votedCount + '/' + room.size
|
|
6678
|
+
body.appendChild(team)
|
|
6679
|
+
}
|
|
6680
|
+
|
|
6681
|
+
// 玩家
|
|
6682
|
+
const players = document.createElement('div')
|
|
6683
|
+
players.style.cssText = 'display:grid;grid-template-columns:repeat(2,1fr);gap:6px;margin-bottom:8px'
|
|
6684
|
+
for (let i = 0; i < room.size; i++) {
|
|
6685
|
+
const st = room.seats[i]
|
|
6686
|
+
const line = document.createElement('div')
|
|
6687
|
+
line.style.cssText = 'display:flex;align-items:center;gap:6px;padding:6px 8px;border-radius:9px;background:rgba(255,255,255,.04);border:1px solid rgba(140,170,220,.18)'
|
|
6688
|
+
const nm = document.createElement('span')
|
|
6689
|
+
nm.textContent = (i === v.leader ? '👑 ' : '') + i + '号 ' + (st.bot ? '机器人' : st.name || '')
|
|
6690
|
+
nm.style.cssText = 'flex:1;font-size:11.5px'
|
|
6691
|
+
line.appendChild(nm)
|
|
6692
|
+
if (voteSeat && voteSeat.members.includes(i)) line.appendChild(chipEl(voteSeat.voted[i] ? '已投' : '在队'))
|
|
6693
|
+
players.appendChild(line)
|
|
6694
|
+
}
|
|
6695
|
+
body.appendChild(players)
|
|
6696
|
+
|
|
6697
|
+
const acts = document.createElement('div')
|
|
6698
|
+
acts.style.cssText = 'display:flex;gap:6px;flex-wrap:wrap'
|
|
6699
|
+
body.appendChild(acts)
|
|
6700
|
+
const pend = (v.pendingActions || [])
|
|
6701
|
+
const mine = pend.filter((p) => (p.players || []).includes(seat))
|
|
6702
|
+
|
|
6703
|
+
const picker = (prefill, submitLabel, submitFn) => {
|
|
6704
|
+
const need = (active && active.teamSize) || 2
|
|
6705
|
+
const grid = document.createElement('div')
|
|
6706
|
+
grid.style.cssText = 'display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px;width:100%'
|
|
6707
|
+
if (prefill && prefill.length && picking.length === 0) picking = prefill.slice()
|
|
6708
|
+
for (let i = 0; i < room.size; i++) {
|
|
6709
|
+
const on = picking.includes(i)
|
|
6710
|
+
const b = btn(i + '号' + (on ? ' ✓' : ''), () => {
|
|
6711
|
+
picking = on ? picking.filter((x) => x !== i) : picking.concat([i])
|
|
6712
|
+
renderGame()
|
|
6713
|
+
})
|
|
6714
|
+
if (on) b.style.background = 'rgba(90,140,255,.35)'
|
|
6715
|
+
grid.appendChild(b)
|
|
6716
|
+
}
|
|
6717
|
+
acts.appendChild(grid)
|
|
6718
|
+
const sub = btn(submitLabel + '(' + picking.length + '/' + need + ')', submitFn, true)
|
|
6719
|
+
if (picking.length !== need) sub.disabled = true
|
|
6720
|
+
acts.appendChild(sub)
|
|
6721
|
+
}
|
|
6722
|
+
|
|
6723
|
+
if (phase === 'lead' && v.leader === seat) {
|
|
6724
|
+
const optsBox = document.createElement('div')
|
|
6725
|
+
optsBox.style.cssText = 'display:flex;gap:6px;flex-wrap:wrap;width:100%;margin-bottom:6px'
|
|
6726
|
+
const mk = (label, on, fn) => {
|
|
6727
|
+
const b = btn(label, fn)
|
|
6728
|
+
b.style.fontSize = '11.5px'
|
|
6729
|
+
if (on) b.style.background = 'rgba(90,140,255,.35)'
|
|
6730
|
+
return b
|
|
6731
|
+
}
|
|
6732
|
+
optsBox.appendChild(mk(speakSelfFirst ? '我先发言' : '我最后发言', true, () => {
|
|
6733
|
+
speakSelfFirst = !speakSelfFirst
|
|
6734
|
+
renderGame()
|
|
6735
|
+
}))
|
|
6736
|
+
optsBox.appendChild(mk(speakReverse ? '倒序发言 ←' : '正序发言 →', true, () => {
|
|
6737
|
+
speakReverse = !speakReverse
|
|
6738
|
+
renderGame()
|
|
6739
|
+
}))
|
|
6740
|
+
acts.appendChild(optsBox)
|
|
6741
|
+
picker([], '给出初版车型', async () => {
|
|
6742
|
+
try { await sendAction({ type: 'leadDraft', members: picking.slice(), selfFirst: speakSelfFirst, reverse: speakReverse }); picking = [] } catch (e) { onToast('提交失败:' + friendly(e)) }
|
|
6743
|
+
})
|
|
6744
|
+
acts.appendChild(btn('不给车型,直接开始发言', async () => {
|
|
6745
|
+
try { await sendAction({ type: 'leadSkip', selfFirst: speakSelfFirst, reverse: speakReverse }) } catch (e) { onToast('操作失败:' + friendly(e)) }
|
|
6746
|
+
}))
|
|
6747
|
+
} else if (phase === 'lead') {
|
|
6748
|
+
const w = document.createElement('div')
|
|
6749
|
+
w.textContent = '队长 ' + v.leader + ' 号在选车…(' + Math.ceil(leaderLeft / 1000) + 's)'
|
|
6750
|
+
w.style.cssText = 'font-size:12px;color:#8fa6c8'
|
|
6751
|
+
acts.appendChild(w)
|
|
6752
|
+
} else if (phase === 'final' && v.leader === seat) {
|
|
6753
|
+
picker(draft || [], '提交最终车型', async () => {
|
|
6754
|
+
try { await sendAction({ type: 'leadFinal', members: picking.slice() }); picking = [] } catch (e) { onToast('提交失败:' + friendly(e)) }
|
|
6755
|
+
})
|
|
6756
|
+
} else if (phase === 'final') {
|
|
6757
|
+
const w = document.createElement('div')
|
|
6758
|
+
w.textContent = '队长 ' + v.leader + ' 号最终定车中…(' + Math.ceil(finalLeft / 1000) + 's)'
|
|
6759
|
+
w.style.cssText = 'font-size:12px;color:#8fa6c8'
|
|
6760
|
+
acts.appendChild(w)
|
|
6761
|
+
} else if (v.stage === 'teamBuilding' && v.leader === seat) {
|
|
6762
|
+
const need = (active && active.teamSize) || 2
|
|
6763
|
+
const grid = document.createElement('div')
|
|
6764
|
+
grid.style.cssText = 'display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px;width:100%'
|
|
6765
|
+
for (let i = 0; i < room.size; i++) {
|
|
6766
|
+
const on = picking.includes(i)
|
|
6767
|
+
const b = btn(i + '号' + (on ? ' ✓' : ''), () => {
|
|
6768
|
+
picking = on ? picking.filter((x) => x !== i) : picking.concat([i])
|
|
6769
|
+
renderGame()
|
|
6770
|
+
})
|
|
6771
|
+
if (on) b.style.background = 'rgba(90,140,255,.35)'
|
|
6772
|
+
grid.appendChild(b)
|
|
6773
|
+
}
|
|
6774
|
+
acts.appendChild(grid)
|
|
6775
|
+
const sub = btn('提交车队(' + picking.length + '/' + need + ')', async () => {
|
|
6776
|
+
try {
|
|
6777
|
+
await sendAction({ type: 'proposeTeam', members: picking.slice() })
|
|
6778
|
+
picking = []
|
|
6779
|
+
} catch (e) {
|
|
6780
|
+
onToast('提交失败:' + friendly(e))
|
|
6781
|
+
}
|
|
6782
|
+
}, true)
|
|
6783
|
+
if (picking.length !== need) sub.disabled = true
|
|
6784
|
+
acts.appendChild(sub)
|
|
6785
|
+
} else if (v.stage === 'teamVote' && mine.some((p) => p.type === 'voteTeam')) {
|
|
6786
|
+
acts.appendChild(btn('同意', () => sendAction({ type: 'voteTeam', approve: true }), true))
|
|
6787
|
+
acts.appendChild(btn('反对(只换队长,不算任务失败)', () => sendAction({ type: 'voteTeam', approve: false })))
|
|
6788
|
+
} else if (v.stage === 'quest' && mine.some((p) => p.type === 'playQuestCard')) {
|
|
6789
|
+
acts.appendChild(btn('任务成功', () => sendAction({ type: 'playQuestCard', success: true }), true))
|
|
6790
|
+
if (v.alignment === 'evil') acts.appendChild(btn('破坏任务', () => sendAction({ type: 'playQuestCard', success: false })))
|
|
6791
|
+
} else if (v.stage === 'assassination' && mine.some((p) => p.type === 'assassinate')) {
|
|
6792
|
+
for (let i = 0; i < room.size; i++) {
|
|
6793
|
+
if (i === seat) continue
|
|
6794
|
+
acts.appendChild(btn('刺杀 ' + i + '号', () => sendAction({ type: 'assassinate', target: i })))
|
|
6795
|
+
}
|
|
6796
|
+
} else {
|
|
6797
|
+
const w = document.createElement('div')
|
|
6798
|
+
if (v.result) {
|
|
6799
|
+
const reasons = {
|
|
6800
|
+
threeQuestsSucceeded: '三轮任务成功',
|
|
6801
|
+
threeQuestsFailed: '三轮任务失败',
|
|
6802
|
+
teamProposalLimitReached: '否决额度用尽',
|
|
6803
|
+
assassinationHit: '刺客刺杀梅林成功',
|
|
6804
|
+
assassinationMissed: '刺客没刺中梅林',
|
|
6805
|
+
merlinAssassinated: '梅林被刺杀',
|
|
6806
|
+
}
|
|
6807
|
+
w.textContent = (v.result.winner === 'good' ? '✅ 正义方胜利' : '❌ 邪恶方胜利') + ' · ' + (reasons[v.result.reason] || v.result.reason || '')
|
|
6808
|
+
w.style.color = v.result.winner === 'good' ? '#7ef0b0' : '#ff9aa8'
|
|
6809
|
+
} else {
|
|
6810
|
+
w.textContent = v.stage === 'teamBuilding' ? '等队长(' + v.leader + '号)组队…' : '等待其他人行动…(机器人会自动推进)'
|
|
6811
|
+
}
|
|
6812
|
+
w.style.cssText = 'font-size:12px;color:#8fa6c8'
|
|
6813
|
+
acts.appendChild(w)
|
|
6814
|
+
}
|
|
6815
|
+
|
|
6816
|
+
// 房间操作
|
|
6817
|
+
foot.textContent = ''
|
|
6818
|
+
foot.appendChild(btn('← 大厅', async () => {
|
|
6819
|
+
reset()
|
|
6820
|
+
await renderLobby()
|
|
6821
|
+
}))
|
|
6822
|
+
foot.appendChild(btn('复制房间号', async () => {
|
|
6823
|
+
try { await navigator.clipboard.writeText(String(roomId)); onToast('房间号已复制') } catch (e) { onToast('复制失败:' + roomId) }
|
|
6824
|
+
}))
|
|
6825
|
+
foot.appendChild(btn('退出房间', async () => {
|
|
6826
|
+
try { await api3('POST', '/api/av/rooms/' + roomId + '/leave') } catch (e) {}
|
|
6827
|
+
reset()
|
|
6828
|
+
await renderLobby()
|
|
6829
|
+
}))
|
|
6830
|
+
if (room && room.owner === auth.id) {
|
|
6831
|
+
foot.appendChild(btn('解散房间', async () => {
|
|
6832
|
+
if (!window.confirm('解散这个房间?')) return
|
|
6833
|
+
try { await api3('POST', '/api/av/rooms/' + roomId + '/leave') } catch (e) {}
|
|
6834
|
+
reset()
|
|
6835
|
+
await renderLobby()
|
|
6836
|
+
}))
|
|
6837
|
+
}
|
|
6838
|
+
|
|
6839
|
+
if (v.result && v.players) {
|
|
6840
|
+
const reveal = document.createElement('div')
|
|
6841
|
+
reveal.style.cssText = 'margin-top:9px;font-size:11.5px;color:#a9bede;line-height:1.7'
|
|
6842
|
+
reveal.textContent = v.players.map((p, i) => i + '号 ' + (AV_ROLES[p.character] || p.character) + '(' + (p.alignment === 'evil' ? '恶' : '善') + ')').join(' · ')
|
|
6843
|
+
body.appendChild(reveal)
|
|
6844
|
+
}
|
|
6845
|
+
}
|
|
6846
|
+
|
|
6847
|
+
const sendAction = async (action) => {
|
|
6848
|
+
try {
|
|
6849
|
+
const r = await api3('POST', '/api/av/rooms/' + roomId + '/act', { action })
|
|
6850
|
+
if (r && r.view) view = r.view
|
|
6851
|
+
if (r && r.room) room = r.room
|
|
6852
|
+
renderGame()
|
|
6853
|
+
} catch (e) {
|
|
6854
|
+
onToast('操作失败:' + friendly(e))
|
|
6855
|
+
}
|
|
6856
|
+
}
|
|
6857
|
+
|
|
6858
|
+
const render = async () => {
|
|
6859
|
+
if (stopped || !roomId) return
|
|
6860
|
+
try {
|
|
6861
|
+
const r = await api3('GET', '/api/av/rooms/' + roomId + '/view')
|
|
6862
|
+
room = r.room
|
|
6863
|
+
seat = r.seat
|
|
6864
|
+
view = r.view
|
|
6865
|
+
discuss = r.discuss || null
|
|
6866
|
+
phase = r.phase || ''
|
|
6867
|
+
speakOpts = r.speakOpts || null
|
|
6868
|
+
if (speakOpts && (phase === 'lead' || phase === 'discuss')) {
|
|
6869
|
+
speakSelfFirst = speakOpts.selfFirst !== false
|
|
6870
|
+
speakReverse = !!speakOpts.reverse
|
|
6871
|
+
}
|
|
6872
|
+
draft = r.draft || null
|
|
6873
|
+
leaderLeft = r.leaderDeadlineIn || 0
|
|
6874
|
+
finalLeft = r.finalDeadlineIn || 0
|
|
6875
|
+
if (!view) renderWaiting()
|
|
6876
|
+
else renderGame()
|
|
6877
|
+
} catch (e) {
|
|
6878
|
+
if (String((e && e.code) || '') === 'not-found') {
|
|
6879
|
+
onToast('房间已解散')
|
|
6880
|
+
reset()
|
|
6881
|
+
await renderLobby()
|
|
6882
|
+
return
|
|
6883
|
+
}
|
|
6884
|
+
hint.textContent = '状态读取失败'
|
|
6885
|
+
}
|
|
6886
|
+
}
|
|
6887
|
+
|
|
6888
|
+
closeBtn.addEventListener('click', () => {
|
|
6889
|
+
stopped = true
|
|
6890
|
+
window.clearInterval(timer)
|
|
6891
|
+
if (micStream) { try { micStream.getTracks().forEach((t) => t.stop()) } catch (e) {} }
|
|
6892
|
+
wrap.remove()
|
|
6893
|
+
})
|
|
6894
|
+
|
|
6895
|
+
document.body.appendChild(wrap)
|
|
6896
|
+
attachDragger(wrap, 'avalon')
|
|
6897
|
+
attachScaler(wrap, 'avalon')
|
|
6898
|
+
renderLobby()
|
|
6899
|
+
timer = window.setInterval(async () => {
|
|
6900
|
+
if (!roomId) return
|
|
6901
|
+
await render()
|
|
6902
|
+
}, 1200)
|
|
6903
|
+
return { close: () => wrap.remove() }
|
|
6904
|
+
}
|
|
6905
|
+
|
|
6906
|
+
/* ---------- 手机预览(开发工具) ---------- */
|
|
6907
|
+
function openMobilePreview(opts) {
|
|
6908
|
+
const auth = opts && opts.auth
|
|
6909
|
+
const onToast = (opts && opts.onToast) || (() => {})
|
|
6910
|
+
const DEVICES = [
|
|
6911
|
+
{ name: 'iPhone 15 (393×852)', w: 393, h: 852 },
|
|
6912
|
+
{ name: 'iPhone SE (375×667)', w: 375, h: 667 },
|
|
6913
|
+
{ name: 'iPhone 14 Pro Max (430×932)', w: 430, h: 932 },
|
|
6914
|
+
{ name: 'Pixel 8 (412×915)', w: 412, h: 915 },
|
|
6915
|
+
{ name: '安卓小屏 (360×780)', w: 360, h: 780 },
|
|
6916
|
+
{ name: 'iPad mini (768×1024)', w: 768, h: 1024 },
|
|
6917
|
+
]
|
|
6918
|
+
let idx = 0
|
|
6919
|
+
let rotate = false
|
|
6920
|
+
let scale = 1
|
|
6921
|
+
|
|
6922
|
+
const wrap = document.createElement('div')
|
|
6923
|
+
wrap.style.cssText = [
|
|
6924
|
+
'position:fixed', 'right:16px', 'bottom:16px', 'width:520px', 'max-width:calc(100vw - 12px)',
|
|
6925
|
+
'height:760px', 'max-height:calc(100vh - 24px)', 'z-index:2147483646', 'display:flex',
|
|
6926
|
+
'flex-direction:column', 'border-radius:16px', 'overflow:hidden',
|
|
6927
|
+
'background:linear-gradient(180deg,#0f1b2e,#0b1522)', 'color:#e8eefc',
|
|
6928
|
+
'border:1px solid rgba(140,170,220,.28)', 'box-shadow:0 18px 50px rgba(0,0,0,.5)',
|
|
6929
|
+
].join(';')
|
|
6930
|
+
|
|
6931
|
+
const head = document.createElement('div')
|
|
6932
|
+
head.style.cssText = 'display:flex;align-items:center;gap:6px;padding:9px 12px;border-bottom:1px solid rgba(140,170,220,.2);flex-wrap:wrap'
|
|
6933
|
+
const title = document.createElement('div')
|
|
6934
|
+
title.textContent = '📱 手机预览'
|
|
6935
|
+
title.style.cssText = 'font-size:13px;font-weight:700'
|
|
6936
|
+
head.appendChild(title)
|
|
6937
|
+
|
|
6938
|
+
const sel = document.createElement('select')
|
|
6939
|
+
sel.style.cssText = 'font:inherit;font-size:11.5px;padding:3px 6px;border-radius:8px;background:#122238;color:inherit;border:1px solid rgba(140,170,220,.3)'
|
|
6940
|
+
DEVICES.forEach((d, i) => {
|
|
6941
|
+
const o = document.createElement('option')
|
|
6942
|
+
o.value = String(i)
|
|
6943
|
+
o.textContent = d.name
|
|
6944
|
+
sel.appendChild(o)
|
|
6945
|
+
})
|
|
6946
|
+
head.appendChild(sel)
|
|
6947
|
+
|
|
6948
|
+
const btn = (t, fn) => {
|
|
6949
|
+
const b = document.createElement('button')
|
|
6950
|
+
b.textContent = t
|
|
6951
|
+
b.style.cssText = 'padding:3px 9px;border-radius:8px;border:1px solid rgba(140,170,220,.3);background:transparent;color:inherit;font:inherit;font-size:11.5px;cursor:pointer'
|
|
6952
|
+
b.addEventListener('click', fn)
|
|
6953
|
+
return b
|
|
6954
|
+
}
|
|
6955
|
+
head.appendChild(btn('旋转', () => { rotate = !rotate; layout() }))
|
|
6956
|
+
head.appendChild(btn('刷新', () => { const u = iframe.src; iframe.src = 'about:blank'; setTimeout(() => { iframe.src = u }, 60) }))
|
|
6957
|
+
head.appendChild(btn('新窗口', () => window.open(iframe.src, '_blank')))
|
|
6958
|
+
head.appendChild(btn('关闭', () => wrap.remove()))
|
|
6959
|
+
wrap.appendChild(head)
|
|
6960
|
+
|
|
6961
|
+
const urlBar = document.createElement('div')
|
|
6962
|
+
urlBar.style.cssText = 'display:flex;gap:6px;padding:7px 10px;border-bottom:1px solid rgba(140,170,220,.15)'
|
|
6963
|
+
const url = document.createElement('input')
|
|
6964
|
+
url.value = (auth && auth.mobileUrl) || 'https://xdxy-pet.com/dl/m/'
|
|
6965
|
+
url.style.cssText = 'flex:1;min-width:0;padding:6px 9px;border-radius:8px;border:1px solid rgba(140,170,220,.3);background:rgba(255,255,255,.05);color:inherit;font:inherit;font-size:12px'
|
|
6966
|
+
urlBar.appendChild(url)
|
|
6967
|
+
urlBar.appendChild(btn('打开', () => { iframe.src = url.value.trim() }))
|
|
6968
|
+
wrap.appendChild(urlBar)
|
|
6969
|
+
|
|
6970
|
+
const stage = document.createElement('div')
|
|
6971
|
+
stage.style.cssText = 'flex:1;min-height:0;overflow:auto;display:flex;align-items:flex-start;justify-content:center;padding:12px;background:rgba(0,0,0,.25)'
|
|
6972
|
+
const frame = document.createElement('div')
|
|
6973
|
+
frame.style.cssText = 'border-radius:22px;overflow:hidden;background:#000;box-shadow:0 12px 40px rgba(0,0,0,.5);border:8px solid #1b2331;flex:0 0 auto'
|
|
6974
|
+
const iframe = document.createElement('iframe')
|
|
6975
|
+
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-forms allow-popups allow-modals')
|
|
6976
|
+
iframe.style.cssText = 'display:block;border:0;background:#0b1522'
|
|
6977
|
+
frame.appendChild(iframe)
|
|
6978
|
+
stage.appendChild(frame)
|
|
6979
|
+
wrap.appendChild(stage)
|
|
6980
|
+
|
|
6981
|
+
const foot = document.createElement('div')
|
|
6982
|
+
foot.style.cssText = 'display:flex;align-items:center;gap:8px;padding:7px 12px;border-top:1px solid rgba(140,170,220,.2);font-size:11.5px;color:#8fa6c8'
|
|
6983
|
+
const sizeLabel = document.createElement('span')
|
|
6984
|
+
foot.appendChild(sizeLabel)
|
|
6985
|
+
const slider = document.createElement('input')
|
|
6986
|
+
slider.type = 'range'
|
|
6987
|
+
slider.min = '0.4'
|
|
6988
|
+
slider.max = '1'
|
|
6989
|
+
slider.step = '0.05'
|
|
6990
|
+
slider.value = '0.8'
|
|
6991
|
+
slider.style.cssText = 'flex:1;accent-color:#5b8cff'
|
|
6992
|
+
slider.addEventListener('input', () => { scale = Number(slider.value); layout() })
|
|
6993
|
+
foot.appendChild(slider)
|
|
6994
|
+
wrap.appendChild(foot)
|
|
6995
|
+
|
|
6996
|
+
function layout() {
|
|
6997
|
+
const d = DEVICES[idx]
|
|
6998
|
+
const w = rotate ? d.h : d.w
|
|
6999
|
+
const h = rotate ? d.w : d.h
|
|
7000
|
+
iframe.style.width = w + 'px'
|
|
7001
|
+
iframe.style.height = h + 'px'
|
|
7002
|
+
frame.style.transform = 'scale(' + scale + ')'
|
|
7003
|
+
frame.style.transformOrigin = 'top center'
|
|
7004
|
+
frame.style.marginBottom = (-(h * (1 - scale)) + 20) + 'px'
|
|
7005
|
+
sizeLabel.textContent = w + '×' + h + ' · ' + Math.round(scale * 100) + '%'
|
|
7006
|
+
}
|
|
7007
|
+
sel.addEventListener('change', () => { idx = Number(sel.value); layout() })
|
|
7008
|
+
layout()
|
|
7009
|
+
iframe.src = url.value.trim()
|
|
7010
|
+
|
|
7011
|
+
document.body.appendChild(wrap)
|
|
7012
|
+
attachDragger(wrap, 'mobile-preview')
|
|
7013
|
+
attachScaler(wrap, 'mobile-preview')
|
|
7014
|
+
return { close: () => wrap.remove() }
|
|
7015
|
+
}
|
|
7016
|
+
|
|
5950
7017
|
/* ---------- 每日杀手数独 ---------- */
|
|
5951
7018
|
/* ---------- 每日杀手数独 ---------- */
|
|
5952
7019
|
function openKiller(opts) {
|
|
@@ -7672,31 +8739,62 @@ window.__ModuleLoader__.load({
|
|
|
7672
8739
|
const PANEL_ID = 'dsh-share-chat'
|
|
7673
8740
|
|
|
7674
8741
|
/** 左侧栏图标:用 currentColor,跟着主题走 */
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
8742
|
+
const UNREAD = { n: 0, subs: new Set() }
|
|
8743
|
+
function setUnread(n) {
|
|
8744
|
+
UNREAD.n = Math.max(0, n | 0)
|
|
8745
|
+
UNREAD.subs.forEach((fn) => { try { fn() } catch { /* ignore */ } })
|
|
8746
|
+
}
|
|
8747
|
+
function useUnread() {
|
|
8748
|
+
const [n, setN] = React.useState(UNREAD.n)
|
|
8749
|
+
React.useEffect(() => {
|
|
8750
|
+
const fn = () => setN(UNREAD.n)
|
|
8751
|
+
UNREAD.subs.add(fn)
|
|
8752
|
+
return () => UNREAD.subs.delete(fn)
|
|
8753
|
+
}, [])
|
|
8754
|
+
return n
|
|
8755
|
+
}
|
|
8756
|
+
function UnreadPoller() {
|
|
8757
|
+
React.useEffect(() => {
|
|
8758
|
+
let cursor = 0
|
|
8759
|
+
const tick = async () => {
|
|
8760
|
+
const auth = readJson(K_AUTH)
|
|
8761
|
+
if (!auth || !auth.token) return
|
|
8762
|
+
try {
|
|
8763
|
+
const r = await api(auth.server || DEFAULT_SERVER, '/api/messages?since=' + cursor, { token: auth.token })
|
|
8764
|
+
const list = (r && (r.messages || r.list)) || []
|
|
8765
|
+
if (r && typeof r.cursor === 'number') cursor = r.cursor
|
|
8766
|
+
const incoming = list.filter((m) => m && m.from && m.from !== auth.id)
|
|
8767
|
+
if (incoming.length) setUnread(UNREAD.n + incoming.length)
|
|
8768
|
+
} catch { /* offline */ }
|
|
7696
8769
|
}
|
|
8770
|
+
tick()
|
|
8771
|
+
const t = window.setInterval(tick, 4000)
|
|
8772
|
+
return () => window.clearInterval(t)
|
|
8773
|
+
}, [])
|
|
8774
|
+
return null
|
|
8775
|
+
}
|
|
8776
|
+
|
|
8777
|
+
function SocialIcon() {
|
|
8778
|
+
const n = useUnread()
|
|
8779
|
+
return h(
|
|
8780
|
+
'span',
|
|
8781
|
+
{ style: { position: 'relative', display: 'inline-flex', alignItems: 'center' } },
|
|
8782
|
+
h('span', { style: { display: 'inline-flex' } }, h(UnreadPoller)),
|
|
8783
|
+
n > 0
|
|
8784
|
+
? h('span', {
|
|
8785
|
+
style: {
|
|
8786
|
+
position: 'absolute', top: '-8px', right: '-12px', padding: '0 4px', height: '14px',
|
|
8787
|
+
lineHeight: '14px', borderRadius: '7px', background: '#ff4d6d', color: '#fff',
|
|
8788
|
+
fontSize: '9.5px', fontWeight: 700, whiteSpace: 'nowrap', pointerEvents: 'none',
|
|
8789
|
+
},
|
|
8790
|
+
}, '⚡×' + (n > 99 ? '99+' : n))
|
|
8791
|
+
: null,
|
|
8792
|
+
)
|
|
8793
|
+
}
|
|
7697
8794
|
|
|
7698
8795
|
/** 主区域的整页版本:给标题栏让出 top clearance */
|
|
7699
8796
|
function SocialPanel() {
|
|
8797
|
+
React.useEffect(() => { setUnread(0) }, [])
|
|
7700
8798
|
return h(
|
|
7701
8799
|
'div',
|
|
7702
8800
|
{
|
|
@@ -7754,7 +8852,7 @@ window.__ModuleLoader__.load({
|
|
|
7754
8852
|
name: 'sidebar.panellist',
|
|
7755
8853
|
id: PANEL_ID,
|
|
7756
8854
|
order: 20,
|
|
7757
|
-
label: () => '社交',
|
|
8855
|
+
label: () => (UNREAD.n > 0 ? '社交 ⚡×' + UNREAD.n : '社交'),
|
|
7758
8856
|
},
|
|
7759
8857
|
SocialIcon,
|
|
7760
8858
|
),
|