feat: 注册页去掉主学学科,进入系统后新建会话再选学科
这个提交包含在:
+3
-13
@@ -37,8 +37,6 @@ select{width:100%;border:1.5px solid var(--line);border-radius:9px;padding:11px
|
||||
<input id="pass" type="password" autocomplete="new-password" placeholder="同时用作你的 Hydro 判题账号密码">
|
||||
<label>确认密码</label>
|
||||
<input id="pass2" type="password" autocomplete="new-password">
|
||||
<label>主学学科</label>
|
||||
<select id="course"><option value="">加载中…</option></select>
|
||||
<button class="btn" onclick="doReg()">注 册</button>
|
||||
<div class="msg" id="msg"></div>
|
||||
|
||||
@@ -49,25 +47,17 @@ select{width:100%;border:1.5px solid var(--line);border-radius:9px;padding:11px
|
||||
<script>
|
||||
var API_BASE=(location.hostname==='127.0.0.1'||location.hostname==='localhost'||location.protocol==='file:')?'http://127.0.0.1:18100':'';
|
||||
function $(id){return document.getElementById(id);}
|
||||
/* 学科列表来自 /api/courses(后端配置表,管理员可增删) */
|
||||
fetch(API_BASE+'/api/courses').then(function(r){return r.json();}).then(function(list){
|
||||
var sel=$('course'); sel.innerHTML='';
|
||||
if(!list||!list.length){ sel.innerHTML='<option value="ap-csa">AP CSA(Java 编程)</option>'; return; }
|
||||
list.forEach(function(c){
|
||||
var o=document.createElement('option'); o.value=c.code; o.textContent=c.name;
|
||||
if(c.code==='ap-csa') o.selected=true; sel.appendChild(o);
|
||||
});
|
||||
}).catch(function(){});
|
||||
/* 学科不再在注册时选择:进入系统后新建会话时再选(学科窗口) */
|
||||
$('pass2').addEventListener('keydown',function(e){if(e.key==='Enter')doReg();});
|
||||
async function doReg(){
|
||||
var u=$('uname').value.trim(), p=$('pass').value, p2=$('pass2').value, c=$('course').value;
|
||||
var u=$('uname').value.trim(), p=$('pass').value, p2=$('pass2').value;
|
||||
var msg=$('msg');
|
||||
if(!u){msg.className='msg err';msg.textContent='请输入用户名';return;}
|
||||
if(p.length<6){msg.className='msg err';msg.textContent='密码至少 6 位';return;}
|
||||
if(p!==p2){msg.className='msg err';msg.textContent='两次密码不一致';return;}
|
||||
msg.className='msg';msg.textContent='注册中:创建本地账号 + Hydro 判题账号…';
|
||||
try{
|
||||
var r=await fetch(API_BASE+'/api/auth/register',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({uname:u,password:p,course:c})});
|
||||
var r=await fetch(API_BASE+'/api/auth/register',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({uname:u,password:p})});
|
||||
var d=await r.json();
|
||||
if(!r.ok){msg.className='msg err';msg.textContent=d.detail||'注册失败';return;}
|
||||
localStorage.setItem('fl_token',d.token);
|
||||
|
||||
在新工单中引用
屏蔽一个用户