diff --git a/docs/index.html b/docs/index.html index 392f13f3..898f6ade 100644 --- a/docs/index.html +++ b/docs/index.html @@ -354,7 +354,7 @@ footer{padding:12px 18px 16px;padding-bottom:max(16px,env(safe-area-inset-bottom
- @@ -366,8 +366,14 @@ footer{padding:12px 18px 16px;padding-bottom:max(16px,env(safe-area-inset-bottom +
+
@@ -751,6 +757,9 @@ const ROLE_MAP = { 'Awen': {role:'dev', title:'通知中心开发', emoji:'💻', badgeCls:'rb-dev', devId:'DEV-012'}, }; +// Custom dev ID format validation (DEV-001, DEV-013, etc.) +const DEV_ID_RE = /^DEV-\d{3,}$/; + // Known API endpoints for fallback auto-detect (when user doesn't provide endpoint) const KNOWN_ENDPOINTS = [ {label:'云雾 AI', base:'https://api.yunwu.ai/v1'}, @@ -1370,14 +1379,53 @@ function doDemo(){ showApp(); } +function onTeamSelectChange(){ + var sel = document.getElementById('tuid').value; + var customBox = document.getElementById('team-custom-input'); + if(sel==='__custom__'){ + customBox.style.display=''; + document.getElementById('tcustom-id').value=''; + document.getElementById('tcustom-id').focus(); + } else { + customBox.style.display='none'; + } + updateTeamIdPreview(); +} + function updateTeamIdPreview(){ - const un = document.getElementById('tuid').value; - const el = document.getElementById('team-id-preview'); - if(!un||!el) return; - const meta = ROLE_MAP[un]; + var sel = document.getElementById('tuid').value; + var el = document.getElementById('team-id-preview'); + if(!el) return; + + // Custom dev ID input mode + if(sel==='__custom__'){ + var raw = (document.getElementById('tcustom-id').value||'').trim().toUpperCase(); + if(!raw){ + el.innerHTML = '
' + + '✏️ 请输入你的开发者编号(格式:DEV-XXX)' + + '
'; + return; + } + // Validate format + if(DEV_ID_RE.test(raw)){ + el.innerHTML = '
' + + '💻 '+esc(raw)+' · 自定义开发者' + + '
✅ 使用服务器端 API 代理 · 128k 上下文 · 首次登录将自动注册' + + '
'; + } else { + el.innerHTML = '
' + + '⚠️ 编号格式不正确,请使用 DEV-XXX 格式(如 DEV-013)' + + '
'; + } + return; + } + + // Normal dropdown selection mode + if(!sel){ el.innerHTML=''; return; } + var meta = ROLE_MAP[sel]; if(meta){ el.innerHTML = '
' - + meta.emoji+' '+esc(un)+' · '+meta.title + + meta.emoji+' '+esc(sel)+' · '+meta.title + (meta.devId ? ' · '+meta.devId+'' : '') + '
✅ 使用服务器端 API 代理 · 128k 上下文 · 无需密钥' + '
'; @@ -1387,7 +1435,23 @@ function updateTeamIdPreview(){ } function doTeamLogin(){ - const un = document.getElementById('tuid').value; + var sel = document.getElementById('tuid').value; + var un = sel; + + // Handle custom dev ID + if(sel==='__custom__'){ + var raw = (document.getElementById('tcustom-id').value||'').trim().toUpperCase(); + if(!raw){ + alert('请输入你的开发者编号(格式:DEV-XXX)'); + return; + } + if(!DEV_ID_RE.test(raw)){ + alert('开发者编号格式不正确,请使用 DEV-XXX 格式(如 DEV-013)'); + return; + } + un = raw; + } + if(!un){ alert('请选择你的开发者身份'); return; @@ -2186,6 +2250,10 @@ function setIdentity(userName, ghUser){ A.userName = userName||''; A.ghUser = ghUser||''; A.userMeta = userName ? (ROLE_MAP[userName]||null) : null; + // Fallback metadata for custom dev IDs (DEV-XXX not in ROLE_MAP) + if(!A.userMeta && userName && DEV_ID_RE.test(userName)){ + A.userMeta = {role:'dev', title:'开发者', emoji:'💻', badgeCls:'rb-dev', devId:userName}; + } A.role = A.userMeta?.role || 'guest'; lss('zy_uname', A.userName); lss('zy_ghuser', A.ghUser);