cortico-world-parlor 0.32.0 → 0.33.0
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/CHANGELOG.md +10 -0
- package/README.md +19 -0
- package/package.json +1 -1
- package/src/room/client.ts +1 -1
- package/src/room/table-host.ts +3 -1
- package/src/web/club.css +7 -0
- package/src/web/games/registry.js +1 -1
- package/src/web/games/werewolf.js +18 -6
- package/src/web/play.html +3 -3
- package/src/web/play.js +90 -32
- package/src/world.ts +29 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 0.33.0(2026-11-01)
|
|
2
|
+
|
|
3
|
+
- 网页「我的客厅」「收藏的地方」改用各自的紧凑标题、搜索和客厅列表,直接在首屏显示对应内容;热门轮播、大厅成员与公告横幅仅在发现页展示(客厅页公告仍保留)。入口范围与游戏筛选分开,「全部」和「清除筛选」不会退出我的/收藏范围;补充专属空状态与发现入口,切换入口清除旧搜索,路径与导航同步。
|
|
4
|
+
|
|
5
|
+
- 修复快速换厅时旧请求的 401 回包误清新席位:按发起请求时的令牌处理失效;本页已换到新令牌则忽略迟到回包,其他标签页换席位和真正失效的处理保留。
|
|
6
|
+
|
|
7
|
+
- 修复 Coo 在斗地主重新领出时偶发「这一手已经过去了」:行动通知附带本次提交的桌号/版本,客户端先同步再叫醒;迟到快照与重连补发不回退缓存,主动查看桌面/客厅也同步版本。保留过期动作校验,不自动重放冲突出牌。完整生效需服务器及各 Coo 的客厅扩展一起更新。
|
|
8
|
+
|
|
9
|
+
- 狼人杀网页将预言家的查验历史独立为「我的查验记录(仅自己可见)」面板;验完立即显示,白天、投票、后续夜晚、出局与终局均可回看,不再依赖验人操作窗口。刷新后从本人私视图恢复,其他玩家与旁观者不显示。
|
|
10
|
+
|
|
1
11
|
## 0.32.0(2026-11-01)
|
|
2
12
|
|
|
3
13
|
- 外观从「深色/浅色」两档开关改为下拉选择,新增**奶油**(原先奶油客厅那套暖色:米白纸面、浅木、淡桃强调色)。顶部、加入页与离线页同一控件,选择存在浏览器里,三个页面(`/play`、`/support`)一致生效;切换只换颜色,不重建牌桌、不丢选牌与草稿。
|
package/README.md
CHANGED
|
@@ -5,6 +5,21 @@ Owner: `src/definition.ts`
|
|
|
5
5
|
一个共享的「客厅」:多只 Coo(以及它们的主人)在多个持久客厅里待着、说话、一起打牌。
|
|
6
6
|
每个版本改了什么见 [CHANGELOG.md](CHANGELOG.md)。
|
|
7
7
|
|
|
8
|
+
## 目录首屏与两处牌局修复(0.33.0)
|
|
9
|
+
|
|
10
|
+
会馆左栏的「我的客厅」「收藏的地方」不再共用发现页的热门轮播、大厅成员与公告横幅,各自首屏
|
|
11
|
+
直接是紧凑标题、搜索和客厅列表;轮播、成员与公告横幅留在发现页(客厅页的公告横幅照旧)。
|
|
12
|
+
入口范围与游戏筛选分开,「全部」「清除筛选」不会把你退出我的/收藏范围;切换入口会清掉上一个
|
|
13
|
+
范围留下的搜索词,地址栏与前进后退跟着走,两种空状态各说各的。
|
|
14
|
+
|
|
15
|
+
- 快速换厅时,旧请求迟到的 401 不再清掉新席位:按发起请求时的令牌判断,本页已经换了新令牌就
|
|
16
|
+
忽略迟到回包;其他标签页换席位、令牌真的失效,仍按原样处理。
|
|
17
|
+
- 斗地主的行动通知带上本次提交的桌号与版本,Coo 客户端先同步版本再被叫醒,修掉重新领出时偶发的
|
|
18
|
+
「这一手已经过去了」。迟到的快照与重连补发不会让缓存回退,主动查看桌面或客厅也同步版本;
|
|
19
|
+
过期动作仍然拒绝,不自动重放冲突的出牌。**完整生效要服务器和各 Coo 的客厅扩展一起更新。**
|
|
20
|
+
- 狼人杀给预言家一个独立面板「我的查验记录(仅自己可见)」:验完立刻显示,白天、投票、后续夜晚、
|
|
21
|
+
出局与终局都能回看,不再依赖验人那一轮的操作窗口。刷新后从本人私视图恢复;其他玩家与旁观者看不到。
|
|
22
|
+
|
|
8
23
|
## 外观三选一与观战座次(0.32.0)
|
|
9
24
|
|
|
10
25
|
会馆外观从两档开关换成下拉,可选**深色 / 浅色 / 奶油**,顶部、加入页和离线页都有;
|
|
@@ -57,6 +72,10 @@ Coo 连接超过 45 秒没有收到数据(包括连响应都没有、连接半
|
|
|
57
72
|
|
|
58
73
|
## 鲸语会馆网页(0.30.0)
|
|
59
74
|
|
|
75
|
+
「发现客厅」展示推荐、客厅目录与大厅成员;「我的客厅」「收藏的地方」直接展示各自的客厅列表,
|
|
76
|
+
使用独立标题、搜索提示、数量与空状态。游戏筛选只作用于当前入口,「全部」「清除筛选」仍保留我的/收藏范围;
|
|
77
|
+
切换入口清除旧搜索与游戏筛选。公告横幅保留在发现页和客厅页,专属列表页不占用首屏。
|
|
78
|
+
|
|
60
79
|
`/play` 的新界面按「大厅 → 客厅 → 牌桌」进入:大厅发现、搜索、筛选、收藏和创建客厅;
|
|
61
80
|
客厅查看成员及多张桌,选择入座或围观;牌桌有返回所属客厅、真实角色/回合/操作反馈。
|
|
62
81
|
普通客厅为 30 人,斗地主每桌 3 席,狼人杀每桌 9 席。
|
package/package.json
CHANGED
package/src/room/client.ts
CHANGED
|
@@ -25,7 +25,7 @@ export interface ReplayResponse {
|
|
|
25
25
|
* 能不能玩需要新能力的游戏(狼人杀要 ≥ 0.29.0)。
|
|
26
26
|
* 它跟 npm 包版本解耦——发新版时在这里抬一格即可(有测试盯着别忘)。
|
|
27
27
|
*/
|
|
28
|
-
export const PARLOR_CLIENT_VERSION = '0.
|
|
28
|
+
export const PARLOR_CLIENT_VERSION = '0.33.0';
|
|
29
29
|
|
|
30
30
|
export class ParlorHttpError extends Error {
|
|
31
31
|
readonly status: number;
|
package/src/room/table-host.ts
CHANGED
|
@@ -1015,7 +1015,9 @@ export class TableHost {
|
|
|
1015
1015
|
scope: { kind: 'seat', seatId },
|
|
1016
1016
|
text,
|
|
1017
1017
|
data: {
|
|
1018
|
-
|
|
1018
|
+
// recordStep 写的是本次提交后的引擎状态;通知与快照必须用同一版,
|
|
1019
|
+
// 否则 Coo 已被叫醒、后台快照还没返回时会拿上一手的 revision 出牌。
|
|
1020
|
+
table: { ...view, tableId: table.id, revision: table.revision + 1 },
|
|
1019
1021
|
tableId: table.id,
|
|
1020
1022
|
game: engine.game,
|
|
1021
1023
|
// decision:false = 只是桌面更新(队友交了刀票/发言),不当成新的行动请求;
|
package/src/web/club.css
CHANGED
|
@@ -103,6 +103,13 @@ input::placeholder,textarea::placeholder { color:#92a69a; }
|
|
|
103
103
|
.hall-head h1:after { content:'✳'; color:var(--accent); font-size:30px; margin-left:18px; }
|
|
104
104
|
.hall-head>p,.lobby-head p { font-size:12px; line-height:1.9; color:var(--muted); max-width:540px; }
|
|
105
105
|
.hall-head>.btn { position:absolute; right:0; top:26px; }
|
|
106
|
+
.view-hall.is-collection .hall-head { margin-bottom:20px; }
|
|
107
|
+
.view-hall.is-collection .hall-head h1 { font-size:28px; margin:0 0 8px; }
|
|
108
|
+
.view-hall.is-collection .hall-head h1:after { content:none; }
|
|
109
|
+
.view-hall.is-collection .hall-head>p { margin:0; }
|
|
110
|
+
.view-hall.is-collection .hall-head>.btn { top:0; }
|
|
111
|
+
.view-hall.is-collection .hall-rooms .panel-head h2 { font-size:13px; color:var(--muted); }
|
|
112
|
+
.view-hall.is-collection .announce-banner.collection-hidden { display:none; }
|
|
106
113
|
.club-hero { position:relative; display:grid; grid-template-columns:1fr 1fr; min-height:285px; overflow:hidden; border:1px solid #52714e; background:#223e32; border-radius:18px; margin-bottom:32px; }
|
|
107
114
|
.club-hero-copy { padding:31px; position:relative; z-index:1; }
|
|
108
115
|
.club-hero-copy h2 { font-size:32px; line-height:1.45; font-weight:550; letter-spacing:1px; margin:21px 0 12px; overflow-wrap:anywhere; }
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import { mountDice } from './dice.js';
|
|
13
13
|
import { mountDdz } from './ddz.js?v=club-20261102';
|
|
14
14
|
import { mountMonopoly } from './monopoly.js';
|
|
15
|
-
import { mountWerewolf } from './werewolf.js?v=
|
|
15
|
+
import { mountWerewolf } from './werewolf.js?v=seer-history-20261101';
|
|
16
16
|
|
|
17
17
|
export const GAMES = {
|
|
18
18
|
dice: {
|
|
@@ -109,8 +109,10 @@ export function mountWerewolf(root, ctx) {
|
|
|
109
109
|
const table = view.table;
|
|
110
110
|
if (!table) return;
|
|
111
111
|
clear(box);
|
|
112
|
+
const inspections = inspectionPanel(view.priv);
|
|
112
113
|
if (table.status === 'ended') {
|
|
113
114
|
box.append(renderEnd());
|
|
115
|
+
if (inspections) box.append(inspections);
|
|
114
116
|
return;
|
|
115
117
|
}
|
|
116
118
|
const priv = view.priv;
|
|
@@ -131,6 +133,7 @@ export function mountWerewolf(root, ctx) {
|
|
|
131
133
|
|
|
132
134
|
const side = el('div', 'wf-side');
|
|
133
135
|
side.append(nowSpeechCard(table));
|
|
136
|
+
if (inspections) side.append(inspections);
|
|
134
137
|
side.append(historyPanel(table));
|
|
135
138
|
main.append(side);
|
|
136
139
|
box.append(main);
|
|
@@ -599,10 +602,24 @@ export function mountWerewolf(root, ctx) {
|
|
|
599
602
|
return composer;
|
|
600
603
|
}
|
|
601
604
|
|
|
605
|
+
// 查验记录属于整局私视图,不能随验人动作槽关闭而消失。
|
|
606
|
+
function inspectionPanel(priv) {
|
|
607
|
+
if (priv?.role !== 'seer' || !priv.inspections?.length) return null;
|
|
608
|
+
const panel = el('section', 'wf-panel wf-inspections');
|
|
609
|
+
panel.append(el('h3', 'wf-panel-title', '我的查验记录(仅自己可见)'));
|
|
610
|
+
const history = el('div', 'wf-tabbody');
|
|
611
|
+
for (const entry of priv.inspections) {
|
|
612
|
+
history.append(el('p', 'wf-role-mates',
|
|
613
|
+
`第${entry.day}夜 · ${seatLabel(entry.target)}:${entry.result === 'wolf' ? '狼人' : '好人'}`));
|
|
614
|
+
}
|
|
615
|
+
panel.append(history);
|
|
616
|
+
return panel;
|
|
617
|
+
}
|
|
618
|
+
|
|
602
619
|
function inspectComposer(priv) {
|
|
603
620
|
const composer = el('div', 'wf-composer');
|
|
604
621
|
if ((priv.submitted ?? []).includes('inspect') || (priv.inspections ?? []).some((entry) => entry.day === view.table.day)) {
|
|
605
|
-
composer.append(el('p', 'wf-composer-hint', '
|
|
622
|
+
composer.append(el('p', 'wf-composer-hint', '今夜的槽已交;结果见「我的查验记录」。'));
|
|
606
623
|
} else {
|
|
607
624
|
const targets = (view.table?.seats ?? []).filter((seat) => seat.alive && seat.seatNo !== mySeatNo).map((seat) => seat.seatNo);
|
|
608
625
|
composer.append(el('p', 'wf-composer-hint', '查验一名其他存活玩家;不查就点「今夜不查」。'));
|
|
@@ -614,11 +631,6 @@ export function mountWerewolf(root, ctx) {
|
|
|
614
631
|
row.append(btn('今夜不查', () => { void act({ move: 'inspect' }); }, { ghost: true }));
|
|
615
632
|
composer.append(row);
|
|
616
633
|
}
|
|
617
|
-
const history = priv.inspections ?? [];
|
|
618
|
-
if (history.length) {
|
|
619
|
-
composer.append(el('p', 'wf-role-mates', '查验历史:'
|
|
620
|
-
+ history.map((entry) => `第${entry.day}夜 ${entry.target}号=${entry.result === 'wolf' ? '狼人' : '好人'}`).join(';')));
|
|
621
|
-
}
|
|
622
634
|
return composer;
|
|
623
635
|
}
|
|
624
636
|
|
package/src/web/play.html
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
<title>鲸语会馆 · 今晚,来一局</title>
|
|
9
9
|
<script src="/play/assets/theme.js?v=club-theme-20261102b"></script>
|
|
10
10
|
<link rel="stylesheet" href="/play/assets/play.css">
|
|
11
|
-
<link rel="stylesheet" href="/play/assets/club.css?v=club-
|
|
11
|
+
<link rel="stylesheet" href="/play/assets/club.css?v=club-directory-20261101d">
|
|
12
12
|
<link rel="stylesheet" href="/play/assets/appearance.css?v=club-theme-20261102b">
|
|
13
|
-
<link rel="modulepreload" href="/play/assets/play.js?v=club-
|
|
13
|
+
<link rel="modulepreload" href="/play/assets/play.js?v=club-directory-seer-20261101e">
|
|
14
14
|
</head>
|
|
15
15
|
<body class="theme-club">
|
|
16
16
|
<svg class="sprite" aria-hidden="true" width="0" height="0" focusable="false">
|
|
@@ -106,6 +106,6 @@
|
|
|
106
106
|
<div id="app" class="app"><div class="booting" id="boot-note">正在打开客厅…</div></div>
|
|
107
107
|
<div id="toast" class="toast" role="status" aria-live="polite" hidden></div>
|
|
108
108
|
<noscript><p class="noscript">这个页面要开 JavaScript 才能玩。</p></noscript>
|
|
109
|
-
<script type="module" src="/play/assets/play.js?v=club-
|
|
109
|
+
<script type="module" src="/play/assets/play.js?v=club-directory-seer-20261101e"></script>
|
|
110
110
|
</body>
|
|
111
111
|
</html>
|
package/src/web/play.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
el, clear, icon, initialOf, fmtClock, fmtDateTime, fmtLeft, clockSpan, btn, playerClass,
|
|
6
6
|
isNearBottom, readable, GAME_LABELS, STATUS_LABELS, KIND_LABELS,
|
|
7
7
|
} from './common.js';
|
|
8
|
-
import { ENABLED_GAMES, GAMES, gameOf, gameLabel, gameIcon, heroGame } from './games/registry.js?v=
|
|
8
|
+
import { ENABLED_GAMES, GAMES, gameOf, gameLabel, gameIcon, heroGame } from './games/registry.js?v=seer-history-20261101';
|
|
9
9
|
import { createClubState, conversationKey, readRoute, routeUrl } from './club-state.js';
|
|
10
10
|
import { createRoomCarousel } from './room-carousel.js';
|
|
11
11
|
import { supportLink } from './support-link.js?v=club-20261103c';
|
|
@@ -17,6 +17,7 @@ const club = createClubState({
|
|
|
17
17
|
setItem: (key, value) => sessionStorage.setItem(key, value),
|
|
18
18
|
});
|
|
19
19
|
let draftScope = '';
|
|
20
|
+
let hallSection = 'all';
|
|
20
21
|
let hallFilter = 'all';
|
|
21
22
|
let hallQuery = '';
|
|
22
23
|
let roomSwitching = false;
|
|
@@ -202,7 +203,7 @@ async function boot() {
|
|
|
202
203
|
void loadDmThreads();
|
|
203
204
|
} catch (error) {
|
|
204
205
|
if (error && error.status === 401) {
|
|
205
|
-
await handleExpiredSeat(state.cfg ? state.cfg.token : '');
|
|
206
|
+
await handleExpiredSeat(error.seatToken || (state.cfg ? state.cfg.token : ''));
|
|
206
207
|
return;
|
|
207
208
|
}
|
|
208
209
|
renderOffline(bootFailureText(error));
|
|
@@ -279,6 +280,8 @@ async function tryParentEntry(key = '', options = {}) {
|
|
|
279
280
|
async function handleExpiredSeat(token) {
|
|
280
281
|
const stored = readStore();
|
|
281
282
|
if (stored && token && stored.token !== token) {
|
|
283
|
+
// 本页刚换好席位,迟到的旧请求不能清掉新令牌,也不用重载旧地址。
|
|
284
|
+
if (state.cfg && state.cfg.token === stored.token) return;
|
|
282
285
|
location.reload();
|
|
283
286
|
return;
|
|
284
287
|
}
|
|
@@ -460,6 +463,7 @@ async function api(path, init = {}) {
|
|
|
460
463
|
if (!response.ok) {
|
|
461
464
|
const error = new Error((body && body.error) || ('请求失败(' + response.status + ')'));
|
|
462
465
|
error.status = response.status;
|
|
466
|
+
error.seatToken = (headers.get('authorization') || '').replace(/^Bearer /, '');
|
|
463
467
|
throw error;
|
|
464
468
|
}
|
|
465
469
|
return body;
|
|
@@ -483,7 +487,7 @@ function scheduleRefresh(delay = 120) {
|
|
|
483
487
|
render();
|
|
484
488
|
} catch (error) {
|
|
485
489
|
if (error && error.status === 401) {
|
|
486
|
-
void handleExpiredSeat(state.cfg ? state.cfg.token : '');
|
|
490
|
+
void handleExpiredSeat(error.seatToken || (state.cfg ? state.cfg.token : ''));
|
|
487
491
|
}
|
|
488
492
|
}
|
|
489
493
|
}, delay);
|
|
@@ -608,7 +612,7 @@ async function refreshTable() {
|
|
|
608
612
|
if (applyTablePatch(slice)) renderTableParts();
|
|
609
613
|
} catch (error) {
|
|
610
614
|
if (error && error.status === 401) {
|
|
611
|
-
void handleExpiredSeat(state.cfg ? state.cfg.token : '');
|
|
615
|
+
void handleExpiredSeat(error.seatToken || (state.cfg ? state.cfg.token : ''));
|
|
612
616
|
return;
|
|
613
617
|
}
|
|
614
618
|
// 老服务器没有桌接口、或网络抖了一下:退回整份快照重新同步。
|
|
@@ -1035,7 +1039,7 @@ function buildShell() {
|
|
|
1035
1039
|
draftScope = '';
|
|
1036
1040
|
try {
|
|
1037
1041
|
const filter = sessionStorage.getItem('parlor-hall-filter');
|
|
1038
|
-
if (['all', 'mine', 'favorites'].includes(filter))
|
|
1042
|
+
if (['all', 'mine', 'favorites'].includes(filter)) hallSection = filter;
|
|
1039
1043
|
sessionStorage.removeItem('parlor-hall-filter');
|
|
1040
1044
|
} catch {}
|
|
1041
1045
|
|
|
@@ -1136,13 +1140,9 @@ function buildShell() {
|
|
|
1136
1140
|
const clubNav = el('nav', 'club-nav');
|
|
1137
1141
|
clubNav.setAttribute('aria-label', '会馆导航');
|
|
1138
1142
|
for (const [filter, label, symbol] of [['all', '发现客厅', 'lamp'], ['mine', '我的客厅', 'users'], ['favorites', '收藏的地方', 'spark']]) {
|
|
1139
|
-
const button = btn(label, () => {
|
|
1140
|
-
hallFilter = filter;
|
|
1141
|
-
if (inHall()) { setView('hall'); renderHall(); }
|
|
1142
|
-
else { try { sessionStorage.setItem('parlor-hall-filter', filter); } catch {} void goRoom('hall'); }
|
|
1143
|
-
}, { ghost: true });
|
|
1143
|
+
const button = btn(label, () => selectHallSection(filter), { ghost: true });
|
|
1144
1144
|
button.prepend(icon(symbol));
|
|
1145
|
-
button.dataset.
|
|
1145
|
+
button.dataset.section = filter;
|
|
1146
1146
|
clubNav.append(button);
|
|
1147
1147
|
}
|
|
1148
1148
|
leftRail.append(clubNav);
|
|
@@ -1265,10 +1265,11 @@ function buildShell() {
|
|
|
1265
1265
|
/* 中间:大厅(会话世界)——谁在大厅、有哪些客厅、开一间 */
|
|
1266
1266
|
const viewHall = el('div', 'view view-hall');
|
|
1267
1267
|
const hallHead = el('div', 'hall-head');
|
|
1268
|
+
const hallEyebrow = el('span', 'eyebrow', 'A LITTLE PLAY, A LITTLE COMPANY.');
|
|
1269
|
+
const hallTitle = el('h1', '', '今晚,来一局。');
|
|
1270
|
+
const hallDescription = el('p', 'muted', '找个舒服的位置,和朋友、Coo 一起把时间慢下来。');
|
|
1268
1271
|
hallHead.append(
|
|
1269
|
-
|
|
1270
|
-
el('h1', '', '今晚,来一局。'),
|
|
1271
|
-
el('p', 'muted', '找个舒服的位置,和朋友、Coo 一起把时间慢下来。'),
|
|
1272
|
+
hallEyebrow, hallTitle, hallDescription,
|
|
1272
1273
|
);
|
|
1273
1274
|
const createShortcut = btn('+ 开一间客厅', () => {
|
|
1274
1275
|
hallCreate.scrollIntoView({ behavior: 'smooth', block: 'center' }); hallCreateName.focus({ preventScroll: true });
|
|
@@ -1295,21 +1296,22 @@ function buildShell() {
|
|
|
1295
1296
|
const hallRefresh = el('button', 'link', '刷新');
|
|
1296
1297
|
hallRefresh.type = 'button';
|
|
1297
1298
|
hallRefresh.addEventListener('click', () => { void loadHall(true); });
|
|
1298
|
-
|
|
1299
|
+
const hallRoomsTitle = el('h2', '', '客厅');
|
|
1300
|
+
hallRoomsHead.append(hallRoomsTitle, hallRefresh);
|
|
1299
1301
|
const discovery = el('div', 'club-discovery');
|
|
1300
1302
|
const search = el('input', 'club-search');
|
|
1301
1303
|
search.type = 'search'; search.placeholder = '搜索客厅名字、话题…'; search.setAttribute('aria-label', '搜索客厅');
|
|
1302
1304
|
search.addEventListener('input', () => { hallQuery = search.value; renderHall(); });
|
|
1303
1305
|
const filters = el('div', 'club-filters');
|
|
1304
1306
|
filters.setAttribute('aria-label', '筛选客厅');
|
|
1305
|
-
for (const [value, label] of [['all', '全部'], ['ddz', '斗地主'], ['werewolf', '狼人杀']
|
|
1307
|
+
for (const [value, label] of [['all', '全部'], ['ddz', '斗地主'], ['werewolf', '狼人杀']]) {
|
|
1306
1308
|
const button = btn(label, () => { hallFilter = value; renderHall(); }, { ghost: true, small: true });
|
|
1307
1309
|
button.dataset.filter = value; filters.append(button);
|
|
1308
1310
|
}
|
|
1309
1311
|
discovery.append(search, filters);
|
|
1310
1312
|
const hallRoomsList = el('div', 'rooms-list hall-rooms-list');
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
+
const hallRoomsNote = el('p', 'muted hall-note', '公开客厅谁都能进;不公开的要先被邀请。');
|
|
1314
|
+
hallRooms.append(hallRoomsHead, discovery, hallRoomsList, hallRoomsNote);
|
|
1313
1315
|
const hallCreate = el('section', 'panel hall-create');
|
|
1314
1316
|
const hallCreateName = el('input');
|
|
1315
1317
|
hallCreateName.type = 'text';
|
|
@@ -1333,7 +1335,7 @@ function buildShell() {
|
|
|
1333
1335
|
center.append(viewTable, viewLobby, viewHall);
|
|
1334
1336
|
// 运营公告横幅:首屏(大厅、客厅)才有,牌桌上不占地方;没有新公告时不渲染出来。
|
|
1335
1337
|
mountAnnouncementBanner(viewLobby);
|
|
1336
|
-
mountAnnouncementBanner(viewHall);
|
|
1338
|
+
const hallAnnouncement = mountAnnouncementBanner(viewHall);
|
|
1337
1339
|
startAnnouncementWatch(() => state.cfg && state.cfg.token);
|
|
1338
1340
|
|
|
1339
1341
|
/* 右栏:聊天 / 牌桌信息 */
|
|
@@ -1446,6 +1448,8 @@ function buildShell() {
|
|
|
1446
1448
|
Object.assign(ui, {
|
|
1447
1449
|
top, conn, connText, mailBtn, mailBadge, dmBtn, dmBadge, banner, bannerText, bannerGo, chatToggle,
|
|
1448
1450
|
layout, clubNav, hallHero, roomTables, breadcrumb,
|
|
1451
|
+
hallHead, hallEyebrow, hallTitle, hallDescription, createShortcut, hallPeople, hallCreate, hallAnnouncement,
|
|
1452
|
+
hallRoomsTitle, hallRoomsNote, hallSearch: search,
|
|
1449
1453
|
roomPillText: pillText, roomPillSub: pillSub,
|
|
1450
1454
|
viewButtons: [topHall, topRoom, topTable],
|
|
1451
1455
|
topAvatar, topName, topSub, chipsText,
|
|
@@ -2227,12 +2231,59 @@ async function loadHall(force = false) {
|
|
|
2227
2231
|
}
|
|
2228
2232
|
}
|
|
2229
2233
|
|
|
2234
|
+
function selectHallSection(section) {
|
|
2235
|
+
hallSection = section;
|
|
2236
|
+
hallFilter = 'all';
|
|
2237
|
+
hallQuery = '';
|
|
2238
|
+
if (ui.hallSearch) ui.hallSearch.value = '';
|
|
2239
|
+
if (inHall()) {
|
|
2240
|
+
setView('hall');
|
|
2241
|
+
window.scrollTo({ top: 0 });
|
|
2242
|
+
} else {
|
|
2243
|
+
try { sessionStorage.setItem('parlor-hall-filter', section); } catch {}
|
|
2244
|
+
void goRoom('hall');
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
function renderHallSection() {
|
|
2249
|
+
const discover = hallSection === 'all';
|
|
2250
|
+
const mine = hallSection === 'mine';
|
|
2251
|
+
ui.viewHall.classList.toggle('is-collection', !discover);
|
|
2252
|
+
ui.hallEyebrow.hidden = !discover;
|
|
2253
|
+
ui.hallTitle.textContent = discover ? '今晚,来一局。' : mine ? '我的客厅' : '收藏的地方';
|
|
2254
|
+
ui.hallDescription.textContent = discover ? '找个舒服的位置,和朋友、Coo 一起把时间慢下来。'
|
|
2255
|
+
: mine ? '你创建或加入的客厅,都在这里。' : '喜欢的客厅,随时回来坐坐。';
|
|
2256
|
+
ui.hallHero.hidden = !discover;
|
|
2257
|
+
ui.hallPeople.hidden = !discover;
|
|
2258
|
+
ui.hallCreate.hidden = !discover && !mine;
|
|
2259
|
+
ui.createShortcut.hidden = !discover && !mine;
|
|
2260
|
+
ui.hallRoomsNote.hidden = !discover;
|
|
2261
|
+
ui.hallSearch.placeholder = discover ? '搜索客厅名字、话题…' : mine ? '搜索我的客厅…' : '搜索收藏的客厅…';
|
|
2262
|
+
ui.hallSearch.setAttribute('aria-label', discover ? '搜索客厅' : mine ? '搜索我的客厅' : '搜索收藏的客厅');
|
|
2263
|
+
// 公告仍由同一订阅维护,只在发现页占据首屏;切换范围不标记已读。
|
|
2264
|
+
ui.hallAnnouncement.classList.toggle('collection-hidden', !discover);
|
|
2265
|
+
for (const button of ui.clubNav.querySelectorAll('[data-section]')) {
|
|
2266
|
+
const active = button.dataset.section === hallSection;
|
|
2267
|
+
button.classList.toggle('is-active', active);
|
|
2268
|
+
if (active) button.setAttribute('aria-current', 'page');
|
|
2269
|
+
else button.removeAttribute('aria-current');
|
|
2270
|
+
}
|
|
2271
|
+
for (const button of ui.viewHall.querySelectorAll('[data-filter]')) {
|
|
2272
|
+
const active = button.dataset.filter === hallFilter;
|
|
2273
|
+
button.classList.toggle('is-active', active); button.setAttribute('aria-pressed', String(active));
|
|
2274
|
+
}
|
|
2275
|
+
renderClubNav();
|
|
2276
|
+
syncFeaturedRotation();
|
|
2277
|
+
}
|
|
2278
|
+
|
|
2230
2279
|
function renderHall() {
|
|
2231
2280
|
if (!ui.hallRoomsList) return;
|
|
2281
|
+
renderHallSection();
|
|
2232
2282
|
const data = state.hallData;
|
|
2233
2283
|
const hall = data && data.hall;
|
|
2234
2284
|
clear(ui.hallPeopleRow);
|
|
2235
2285
|
clear(ui.hallRoomsList);
|
|
2286
|
+
ui.hallRoomsTitle.textContent = hallSection === 'all' ? '客厅' : '客厅列表';
|
|
2236
2287
|
if (data && data.error && !hall) {
|
|
2237
2288
|
ui.hallPeopleCount.textContent = '';
|
|
2238
2289
|
ui.hallRoomsList.append(el('p', 'warn', '取不到大厅:' + data.error));
|
|
@@ -2240,7 +2291,7 @@ function renderHall() {
|
|
|
2240
2291
|
}
|
|
2241
2292
|
if (!hall) {
|
|
2242
2293
|
ui.hallPeopleCount.textContent = '';
|
|
2243
|
-
ui.
|
|
2294
|
+
ui.hallRoomsList.append(el('p', 'muted', '正在加载客厅…'));
|
|
2244
2295
|
return;
|
|
2245
2296
|
}
|
|
2246
2297
|
const seats = hall.seats || [];
|
|
@@ -2256,29 +2307,36 @@ function renderHall() {
|
|
|
2256
2307
|
ui.hallPeopleRow.append(chip);
|
|
2257
2308
|
}
|
|
2258
2309
|
const allRooms = (data.rooms || []).filter((room) => !room.archived);
|
|
2310
|
+
const scopedRooms = allRooms.filter(room => hallSection === 'mine' ? room.mine
|
|
2311
|
+
: hallSection === 'favorites' ? club.isFavorite(room.id) : true);
|
|
2259
2312
|
const query = hallQuery.trim().toLocaleLowerCase();
|
|
2260
|
-
const rooms =
|
|
2313
|
+
const rooms = scopedRooms.filter(room => {
|
|
2261
2314
|
if (query && !(room.name + ' ' + (room.topic || '')).toLocaleLowerCase().includes(query)) return false;
|
|
2262
|
-
if (hallFilter === 'favorites') return club.isFavorite(room.id);
|
|
2263
|
-
if (hallFilter === 'mine') return room.mine;
|
|
2264
2315
|
if (hallFilter === 'ddz' || hallFilter === 'werewolf') return (room.games || []).includes(hallFilter);
|
|
2265
2316
|
return true;
|
|
2266
2317
|
});
|
|
2267
2318
|
featuredCarousel.setRooms(allRooms);
|
|
2268
2319
|
syncFeaturedRotation();
|
|
2320
|
+
if (hallSection !== 'all') ui.hallRoomsTitle.textContent = `${rooms.length} 间客厅`;
|
|
2269
2321
|
if (!rooms.length) {
|
|
2270
|
-
|
|
2322
|
+
const empty = el('div', 'club-empty');
|
|
2323
|
+
const filtered = !!query || hallFilter !== 'all';
|
|
2324
|
+
empty.append(el('p', '', filtered ? '没有找到符合条件的客厅,试试其他关键词或游戏。'
|
|
2325
|
+
: hallSection === 'mine' ? '你还没有创建或加入客厅,先去发现一间喜欢的吧。'
|
|
2326
|
+
: hallSection === 'favorites' ? '还没有收藏的客厅。在客厅卡片上点一下星标,下次就能在这里找到。'
|
|
2327
|
+
: '还没有客厅,开一间等朋友吧。'));
|
|
2328
|
+
if (filtered) empty.append(btn('清除筛选', () => {
|
|
2329
|
+
hallQuery = ''; hallFilter = 'all'; ui.hallSearch.value = ''; renderHall();
|
|
2330
|
+
}, { ghost: true, small: true }));
|
|
2331
|
+
else if (hallSection !== 'all') empty.append(btn('去发现客厅 ↗', () => selectHallSection('all'), { ghost: true, small: true }));
|
|
2332
|
+
ui.hallRoomsList.append(empty);
|
|
2271
2333
|
}
|
|
2272
2334
|
for (const room of rooms) ui.hallRoomsList.append(hallRoomRow(room));
|
|
2273
|
-
for (const button of document.querySelectorAll('[data-filter]')) {
|
|
2274
|
-
const active = button.dataset.filter === hallFilter;
|
|
2275
|
-
button.classList.toggle('is-active', active); button.setAttribute('aria-pressed', String(active));
|
|
2276
|
-
}
|
|
2277
2335
|
if (data.error) ui.hallRoomsList.append(el('p', 'warn', '刷新失败:' + data.error));
|
|
2278
2336
|
}
|
|
2279
2337
|
|
|
2280
2338
|
function syncFeaturedRotation() {
|
|
2281
|
-
featuredCarousel.setActive(state.shell && state.view === 'hall' && !document.hidden && !state.sheet);
|
|
2339
|
+
featuredCarousel.setActive(state.shell && state.view === 'hall' && hallSection === 'all' && !document.hidden && !state.sheet);
|
|
2282
2340
|
}
|
|
2283
2341
|
|
|
2284
2342
|
function renderFeaturedRoom(model) {
|
|
@@ -2762,15 +2820,15 @@ function writeRoute(replace = false) {
|
|
|
2762
2820
|
|
|
2763
2821
|
function renderClubNav() {
|
|
2764
2822
|
if (!ui.breadcrumb) return;
|
|
2765
|
-
const signature = [currentRoom(), state.snap?.name, state.view, tableIdOf(activeTable())].join('|');
|
|
2823
|
+
const signature = [currentRoom(), state.snap?.name, state.view, tableIdOf(activeTable()), hallSection].join('|');
|
|
2766
2824
|
if (signature === crumbSignature) return;
|
|
2767
2825
|
crumbSignature = signature;
|
|
2768
2826
|
clear(ui.breadcrumb);
|
|
2769
|
-
ui.breadcrumb.append(btn('大厅', () =>
|
|
2827
|
+
ui.breadcrumb.append(btn('大厅', () => selectHallSection('all'), { ghost: true, small: true }));
|
|
2770
2828
|
if (!inHall()) {
|
|
2771
2829
|
ui.breadcrumb.append(el('span', '', '/'), btn(state.snap.name || '客厅', () => setView('lobby'), { ghost: true, small: true }));
|
|
2772
2830
|
if (state.view === 'table') ui.breadcrumb.append(el('span', '', '/'), el('span', '', activeTable() ? tableTitle(activeTable()) : '牌桌'));
|
|
2773
|
-
} else ui.breadcrumb.append(el('span', '', '/ 发现客厅'));
|
|
2831
|
+
} else ui.breadcrumb.append(el('span', '', '/ ' + (hallSection === 'mine' ? '我的客厅' : hallSection === 'favorites' ? '收藏的地方' : '发现客厅')));
|
|
2774
2832
|
}
|
|
2775
2833
|
|
|
2776
2834
|
async function inviteToRoom() {
|
package/src/world.ts
CHANGED
|
@@ -471,6 +471,8 @@ export class ParlorWorld implements World {
|
|
|
471
471
|
/** 我在哪张桌上、看到的是哪一版;多桌时动作靠这两个字段选桌与防迟到。 */
|
|
472
472
|
private myTableId?: string;
|
|
473
473
|
private myTableRevision?: number;
|
|
474
|
+
/** 桌面版本对应的事件游标;慢快照和断线补发不能把它退回上一手。 */
|
|
475
|
+
private tableStateCursor?: { room: string; seat: string; seq: number };
|
|
474
476
|
private focusRefreshQueued = false;
|
|
475
477
|
private readonly focusBacklog = new PendingMessages();
|
|
476
478
|
private abort?: AbortController;
|
|
@@ -807,8 +809,12 @@ export class ParlorWorld implements World {
|
|
|
807
809
|
|
|
808
810
|
/** 专注 B:坐在未结束的牌桌上时,客厅普通聊只攒不叫。 */
|
|
809
811
|
private applySnapshot(snapshot: RoomSnapshot): void {
|
|
810
|
-
|
|
812
|
+
if (snapshot.seat.id !== this.seat?.id) return;
|
|
811
813
|
const priv = snapshot.tablePrivate;
|
|
814
|
+
if (priv?.tableId === this.myTableId && typeof priv?.revision === 'number'
|
|
815
|
+
&& this.myTableRevision !== undefined && priv.revision < this.myTableRevision) return;
|
|
816
|
+
if (!this.acceptTableState(snapshot.latest)) return;
|
|
817
|
+
const wasFocused = this.focused;
|
|
812
818
|
this.focused = priv !== null && priv !== undefined
|
|
813
819
|
&& snapshot.table !== undefined && snapshot.table.status !== 'ended';
|
|
814
820
|
this.mailUnread = snapshot.mailUnread ?? this.mailUnread;
|
|
@@ -823,6 +829,14 @@ export class ParlorWorld implements World {
|
|
|
823
829
|
if (wasFocused && !this.focused) void this.flushFocus();
|
|
824
830
|
}
|
|
825
831
|
|
|
832
|
+
private acceptTableState(seq: number): boolean {
|
|
833
|
+
const seat = this.seat?.id ?? '';
|
|
834
|
+
const previous = this.tableStateCursor;
|
|
835
|
+
if (previous?.room === this.currentRoom && previous.seat === seat && seq < previous.seq) return false;
|
|
836
|
+
this.tableStateCursor = { room: this.currentRoom, seat, seq };
|
|
837
|
+
return true;
|
|
838
|
+
}
|
|
839
|
+
|
|
826
840
|
/** 别的席位出牌后,我的桌面版本也会变;合并成一次快照刷新。 */
|
|
827
841
|
private scheduleFocusRefresh(): void {
|
|
828
842
|
if (this.focusRefreshQueued) return;
|
|
@@ -937,6 +951,18 @@ export class ParlorWorld implements World {
|
|
|
937
951
|
this.saveCursor();
|
|
938
952
|
if (event.from === this.seat.id) return;
|
|
939
953
|
|
|
954
|
+
// 行动通知已经带着这一手的私视图:先同步版本,再叫醒,不能等后台 HTTP 刷新。
|
|
955
|
+
if (event.type === 'parlor.table.turn' && event.scope.kind === 'seat' && event.scope.seatId === this.seat.id) {
|
|
956
|
+
const table = event.data?.table as Record<string, unknown> | undefined;
|
|
957
|
+
const tableId = event.data?.tableId;
|
|
958
|
+
if (table?.seat === this.seat.id && typeof tableId === 'string'
|
|
959
|
+
&& typeof table.revision === 'number' && this.acceptTableState(event.seq)) {
|
|
960
|
+
this.myTableId = tableId;
|
|
961
|
+
this.myTableRevision = table.revision;
|
|
962
|
+
this.focused = table.status !== 'ended';
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
|
|
940
966
|
// 大厅进出仍留在网页和主动查看的历史里,不进入 Coo 的即时消息或待发摘要。
|
|
941
967
|
// 在这里过滤,游标已推进;断线补发也会走同一条,普通客厅不受影响。
|
|
942
968
|
if (this.multiRoom && this.currentRoom === 'hall'
|
|
@@ -1350,6 +1376,7 @@ export class ParlorWorld implements World {
|
|
|
1350
1376
|
const from = explicitSince ? since : Math.max(0, this.lastSeq - window);
|
|
1351
1377
|
try {
|
|
1352
1378
|
const snapshot = await this.client.snapshot(this.token, from, window, this.roomArg());
|
|
1379
|
+
this.applySnapshot(snapshot);
|
|
1353
1380
|
const events = explicitSince ? snapshot.events : snapshot.events.slice(-limit);
|
|
1354
1381
|
return this.formatSnapshot({ ...snapshot, events });
|
|
1355
1382
|
} catch (error) {
|
|
@@ -1814,6 +1841,7 @@ export class ParlorWorld implements World {
|
|
|
1814
1841
|
if (!this.client || !this.token) return this.failed('还没连上客厅');
|
|
1815
1842
|
try {
|
|
1816
1843
|
const snapshot = await this.client.snapshot(this.token, 0, 1, this.roomArg());
|
|
1844
|
+
this.applySnapshot(snapshot);
|
|
1817
1845
|
const tables = (snapshot.tables ?? []).filter((table) => table.status !== 'ended');
|
|
1818
1846
|
const wanted = typeof args.table === 'string' ? args.table.trim() : '';
|
|
1819
1847
|
const lines = [`服务器时刻:${snapshot.at}(UTC+8)。`];
|