团队共享 Hub。每个人只能看到自己的会话和机器。
-Namespace:' + body.namespace + '
' - + '' + body.accessToken + '
' - + ''; - history.replaceState(null, '', location.pathname); - }).catch(error => { - if (storedToken) { - showSavedToken('这个链接已经用过或过期了,但你在这台设备上已经领取过(Token 如下):'); - return; - } - status.className = 'error'; - status.textContent = error && error.status === 410 - ? '这个邀请链接已经用过或过期了。请联系管理员重新发一个(每条链接只能用一次)。' - : '领取失败,请检查网络后重试,或联系管理员。'; + status.textContent = '欢迎加入 Team HAPI!打开链接不会消耗邀请,点下面的按钮领取你的账号。'; + const claimButton = document.createElement('button'); + claimButton.className = 'button'; + claimButton.textContent = '领取我的账号'; + claimButton.addEventListener('click', () => { + claimButton.disabled = true; + claimButton.textContent = '领取中…'; + fetch('/api/team/onboarding/claim', { + method: 'POST', + headers: { 'content-type': 'application/json' }, + body: JSON.stringify({ invite }) + }).then(async response => { + const body = await response.json().catch(() => ({})); + if (!response.ok || !body.accessToken) { + const error = new Error(body.error || '邀请链接无效或已使用'); + error.status = response.status; + throw error; + } + try { localStorage.setItem(storageKey, body.accessToken); } catch {} + const promptBlock = document.getElementById('codex-prompt'); + if (promptBlock) { + promptBlock.textContent = promptBlock.textContent.split('【你的个人 Token】').join(body.accessToken); + } + status.className = 'muted'; + status.textContent = '账号已创建,请保存下面的 Token(刷新本页仍可看到)。'; + result.innerHTML = 'Namespace:' + body.namespace + '
' + + '' + body.accessToken + '
' + + ''; + history.replaceState(null, '', location.pathname); + }).catch(error => { + if (storedToken) { + showSavedToken('这个链接已经用过或过期了,但你在这台设备上已经领取过(Token 如下):'); + return; + } + if (error && error.status === 410) { + showClaimError(); + return; + } + status.className = 'error'; + status.textContent = '领取失败:网络异常,请重试;如果一直失败,请联系管理员。'; + claimButton.disabled = false; + claimButton.textContent = '领取我的账号'; + }); }); + result.append(claimButton); })();