feat: 删除发现页、添加隐私授权、修复头像上传

This commit is contained in:
wangwuww111
2026-03-17 18:37:02 +08:00
parent 95b6348029
commit 89cf6021b5
3 changed files with 43 additions and 9 deletions

View File

@@ -374,7 +374,6 @@ export default class HomeScene extends BaseScene {
const tabs = [
{ icon: '🏠', label: '首页' },
{ icon: '🔥', label: '发现' },
{ icon: '✨', label: '创作' },
{ icon: '👤', label: '我的' }
];
@@ -395,7 +394,7 @@ export default class HomeScene extends BaseScene {
ctx.fill();
}
ctx.font = index === 2 ? '24px sans-serif' : '20px sans-serif';
ctx.font = index === 1 ? '24px sans-serif' : '20px sans-serif';
ctx.textAlign = 'center';
ctx.fillText(tab.icon, centerX, y + 28);
@@ -503,7 +502,7 @@ export default class HomeScene extends BaseScene {
// 底部Tab点击
if (y > this.screenHeight - 60) {
const tabW = this.screenWidth / 4;
const tabW = this.screenWidth / 3; // 3个Tab
const tabIndex = Math.floor(x / tabW);
this.handleBottomTabClick(tabIndex);
return;
@@ -551,14 +550,12 @@ export default class HomeScene extends BaseScene {
if (tabIndex === this.bottomTab && tabIndex === 0) return;
if (tabIndex === 0) {
// 首页
this.bottomTab = 0;
} else if (tabIndex === 1) {
// 发现页(可跳转或在本页切换)
this.bottomTab = 1;
} else if (tabIndex === 2) {
// 创作页
this.main.sceneManager.switchScene('aiCreate');
} else if (tabIndex === 3) {
} else if (tabIndex === 2) {
// 我的
this.main.sceneManager.switchScene('profile');
}

View File

@@ -1461,6 +1461,42 @@ export default class ProfileScene extends BaseScene {
// 选择并上传头像
chooseAndUploadAvatar() {
console.log('[ProfileScene] 开始选择头像');
// 检查隐私授权状态
if (wx.getPrivacySetting) {
wx.getPrivacySetting({
success: (res) => {
console.log('[ProfileScene] 隐私设置:', res);
if (res.needAuthorization) {
// 需要授权,弹出隐私弹窗
wx.requirePrivacyAuthorize({
success: () => {
console.log('[ProfileScene] 隐私授权成功');
this.doChooseMedia();
},
fail: (err) => {
console.error('[ProfileScene] 隐私授权失败:', err);
wx.showToast({ title: '需要授权才能选择图片', icon: 'none' });
}
});
} else {
// 已授权,直接选择图片
this.doChooseMedia();
}
},
fail: () => {
// 获取隐私设置失败,尝试直接调用
this.doChooseMedia();
}
});
} else {
// 不支持隐私API直接调用
this.doChooseMedia();
}
}
// 实际选择图片
doChooseMedia() {
wx.chooseMedia({
count: 1,
mediaType: ['image'],
@@ -1516,7 +1552,7 @@ export default class ProfileScene extends BaseScene {
uploadAvatar(filePath) {
return new Promise((resolve, reject) => {
const token = this.main.userManager.token || '';
const baseUrl = 'http://172.20.10.8:8000'; // 与 http.js 保持一致
const baseUrl = 'http://localhost:8002'; // 与 http.js 保持一致
wx.uploadFile({
url: `${baseUrl}/api/upload/avatar`,