diff --git a/modules/api.js b/modules/api.js index 0ece71e..962f776 100644 --- a/modules/api.js +++ b/modules/api.js @@ -72,7 +72,7 @@ app.post('/api/sign_up', async (req, res) => { user = await User.findOne({ where: { email: req.body.email } }); if (user) throw 2009; - if (!req.body.nickname) { + if (!req.body.nickname.trim()) { res.send({ error_code: 2300, message : "昵称不能为空" diff --git a/views/ranklist.ejs b/views/ranklist.ejs index 1fd1afa..d461995 100644 --- a/views/ranklist.ejs +++ b/views/ranklist.ejs @@ -39,7 +39,7 @@ %> <%= i %> - <%= user.nickname %><% if (user.nameplate) { %><%- user.nameplate %><% } %> + <% if(!user.nickname || user.nickname.trim() === '') { %> <%= user.username %> <% } else { %> <%= user.nickname %> <% } %><% if (user.nameplate) { %><%- user.nameplate %><% } %> <%= user.ac_num %> <%= user.submit_num %> <%= user.ac_num && user.submit_num ? Math.round(user.ac_num / user.submit_num * 10000) / 100.00 + "%" : 0%>