优化:个人信息改为独立页面
This commit is contained in:
@@ -1,18 +1,25 @@
|
||||
const DEFAULT_AVATAR_URL = 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
|
||||
|
||||
function cleanText(value) {
|
||||
return String(value || '').trim()
|
||||
}
|
||||
|
||||
function normalizeAvatar(value) {
|
||||
const avatar = cleanText(value)
|
||||
return avatar === DEFAULT_AVATAR_URL ? '' : avatar
|
||||
}
|
||||
|
||||
function buildProfileCard(userInfo, fallbackShopName) {
|
||||
const user = userInfo || {}
|
||||
const nickname = cleanText(user.nickname) || cleanText(user.account) || '未设置昵称'
|
||||
const shopName = cleanText(user.shopName) || cleanText(fallbackShopName) || '未设置门店'
|
||||
|
||||
return {
|
||||
avatar: cleanText(user.avatar),
|
||||
avatar: normalizeAvatar(user.avatar),
|
||||
avatarText: Array.from(nickname)[0] || '用',
|
||||
nickname,
|
||||
shopName
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { buildProfileCard }
|
||||
module.exports = { DEFAULT_AVATAR_URL, buildProfileCard, normalizeAvatar }
|
||||
|
||||
Reference in New Issue
Block a user