shensuming commited on
Commit
bf6f6d7
·
verified ·
1 Parent(s): b1285ca

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +4 -1
app.js CHANGED
@@ -214,10 +214,13 @@ window.handleAuthSubmit = async function(type) {
214
  // [新增] 抓取当前环境探测到的精确语种(优先查持久记忆 -> 查本次探测 -> 兜底英文)
215
  const currentLang = localStorage.getItem('cx_lang') || sessionStorage.getItem('cx_auto_lang') || 'en';
216
 
 
 
 
217
  const registerRes = await fetch('/api/auth/register', {
218
  method: 'POST',
219
  headers: { 'Content-Type': 'application/json' },
220
- // 【核心修复】:把抓取到的 username 也一起打包发给后端
221
  body: JSON.stringify({ email, password, username, lang: currentLang })
222
  });
223
 
 
214
  // [新增] 抓取当前环境探测到的精确语种(优先查持久记忆 -> 查本次探测 -> 兜底英文)
215
  const currentLang = localStorage.getItem('cx_lang') || sessionStorage.getItem('cx_auto_lang') || 'en';
216
 
217
+ // 【核心补全】:自动截取邮箱前缀作为 username,满足后端的必填校验
218
+ const username = email.split('@')[0] || 'User';
219
+
220
  const registerRes = await fetch('/api/auth/register', {
221
  method: 'POST',
222
  headers: { 'Content-Type': 'application/json' },
223
+ // 【核心补全】:将 username 一并打包发给后端
224
  body: JSON.stringify({ email, password, username, lang: currentLang })
225
  });
226