The copied invite link carries an invitation line: 「{name}邀请你加入卫戍协议:盟约【{difficulty}】」 (#103)

Only the clipboard text changes. Contributed by @LongQianChen.
This commit is contained in:
龙千尘 authored and GitHub committed 2026-10-05 22:36:01 +08:00
1 parent 777aee7e24
commit 94b6f6ac14
1 file changed
+3 -3
+3 -3
View File
@@ -153,9 +153,9 @@ function SpectatorBar({ facts, myId, busy, onRemove, onSit }) {
</section>`;
}
function InviteBox({ code }) {
function InviteBox({ code, name, difficulty }) {
const copy = async (what) => {
const ok = await copyText(what === 'code' ? code : inviteLink(code));
const ok = await copyText(what === 'code' ? code : `${inviteLink(code)} ${name}邀请你加入卫戍协议:盟约【${DIFFICULTY_NAMES[difficulty]}】`);
if (ok) toast(what === 'code' ? `已复制同盟密钥 ${code}` : '已复制邀请链接', 'success');
else toast('复制失败,请手动复制', 'warn');
};
@@ -280,7 +280,7 @@ export function RoomScreen() {
<h1 class="topbar__title">${coop ? '同盟模拟' : '独立模拟'}<span class="topbar__sep"></span><${DifficultyTag} difficulty=${room.difficulty} size="lg" /></h1>
</div>
<div class="topbar__right">
${coop ? html`<${InviteBox} code=${room.code} />` : html`<div class="solo-note"><${MicroLabel}>SINGLE OPERATOR<//><span>仅限 1 名博士</span></div>`}
${coop ? html`<${InviteBox} code=${room.code} name=${me.name} difficulty=${room.difficulty} />` : html`<div class="solo-note"><${MicroLabel}>SINGLE OPERATOR<//><span>仅限 1 名博士</span></div>`}
</div>
</header>