From 929f173b95b070c65ee4b5376a4a523a31469062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Wed, 25 Feb 2026 13:14:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(share):=20=E6=9B=B4=E6=96=B0=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E6=A0=87=E9=A2=98=E6=98=BE=E7=A4=BA=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=98=B5=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改分享功能使用用户昵称替代用户ID作为标题前缀 - 添加微信昵称存储逻辑到本地缓存 - 实现用户昵称、真实姓名或用户名的优先级取值 - 添加注释说明微信显示名称的存储用途 --- src/pages/index/index.tsx | 6 +++++- src/utils/server.ts | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index a8333b9..d49297d 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -20,9 +20,12 @@ function Home() { useShareAppMessage(() => { // 获取当前用户ID,用于生成邀请链接 const userId = Taro.getStorageSync('UserId'); + const user = Taro.getStorageSync('User') || {}; + const nickname = + (user && (user.nickname || user.realName || user.username)) || ''; return { - title: userId + '超值推荐', + title: (nickname || '') + '超值推荐', path: userId ? `/pages/index/index?inviter=${userId}&source=share&t=${Date.now()}` : `/pages/index/index`, success: function () { console.log('首页分享成功'); @@ -164,6 +167,7 @@ function Home() { Taro.getUserInfo({ success: (res) => { const avatar = res.userInfo.avatarUrl; + // Keep WeChat display name in storage so share title can use it. console.log(avatar, 'avatarUrl') } }); diff --git a/src/utils/server.ts b/src/utils/server.ts index f597704..a3be738 100644 --- a/src/utils/server.ts +++ b/src/utils/server.ts @@ -16,5 +16,7 @@ export function saveStorageByLoginUser(token: string, user: User) { Taro.setStorageSync('access_token', token) Taro.setStorageSync('UserId', user.userId) Taro.setStorageSync('Phone', user.phone) + Taro.setStorageSync('WxNickName', user.nickname); Taro.setStorageSync('User', user) + }