hejianhao
2026-08-20 3af23f908ed433e986005ce9f0eb11c9d5cd1e1e
feat0806: 直播间用户缓存问题
2个文件已修改
84 ■■■■■ 已修改文件
traditionalApp/pages/home/home.vue 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
traditionalApp/pages/settings/settings.vue 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
traditionalApp/pages/home/home.vue
@@ -331,21 +331,59 @@
    /**
     * 跳转后台配置的微赞直播 H5 页面。
     */
    const goWeiZanLive = () => {
    const goWeiZanLive = async () => {
        console.log('[goWeiZanLive] 点击微赞直播入口');
        console.log('[goWeiZanLive] weiZanLiveH5Url:', weiZanLiveH5Url.value);
        if (!weiZanLiveH5Url.value.trim()) {
            console.log('[goWeiZanLive] 直播间地址未配置');
            uni.showToast({ title: '直播间地址暂未配置', icon: 'none' });
            return;
        }
        if (weiZanLiveOpening.value) {
            console.log('[goWeiZanLive] 正在打开中,防止重复点击');
            return;
        }
        weiZanLiveOpening.value = true;
        uni.showLoading({ title: '正在进入直播间', mask: true });
        try {
            const cachedUser = uni.getStorageSync('appUserInfo');
            const userId = cachedUser?.id;
            console.log('[goWeiZanLive] 当前用户ID:', userId);
            if (!userId) {
                console.log('[goWeiZanLive] 用户未登录');
                uni.showToast({ title: '请先登录', icon: 'none' });
                return;
            }
            console.log('[goWeiZanLive] 开始调用 createLiveRoomEntry 接口');
            const res = await createLiveRoomEntry(userId);
            console.log('[goWeiZanLive] createLiveRoomEntry 返回:', JSON.stringify(res));
            const targetUrl = res?.data?.url?.trim();
            console.log('[goWeiZanLive] 解析目标URL:', targetUrl);
            if (res?.code !== 0 || !targetUrl) {
                console.log('[goWeiZanLive] 获取跳转地址失败,code:', res?.code, 'msg:', res?.msg);
                uni.showToast({ title: res?.msg || '获取直播间地址失败', icon: 'none' });
                return;
            }
            const webviewUrl = `/pages/webview/webview?url=${encodeURIComponent(targetUrl)}&title=${encodeURIComponent('微赞直播')}`;
            console.log('[goWeiZanLive] 准备跳转 WebView:', webviewUrl);
            uni.navigateTo({
                url: `/pages/webview/webview?url=${encodeURIComponent(weiZanLiveH5Url.value)}&title=${encodeURIComponent('微赞直播')}`
                url: webviewUrl
            });
            console.log('[goWeiZanLive] navigateTo 调用完成');
        } catch (error) {
            console.error('[goWeiZanLive] 异常捕获:', error);
            uni.showToast({ title: '获取直播间地址失败', icon: 'none' });
        } finally {
            uni.hideLoading();
            weiZanLiveOpening.value = false;
            console.log('[goWeiZanLive] 流程结束');
        }
    };
traditionalApp/pages/settings/settings.vue
@@ -281,6 +281,7 @@
                await logoutSettingsAccount()
            } finally {
                clearSettingsLoginSession()
                clearWebViewCache()
                uni.reLaunch({
                    url: '/pages/login/login',
                })
@@ -290,6 +291,47 @@
}
/**
 * 清除 WebView 缓存和 localStorage。
 */
function clearWebViewCache() {
    console.log('[clearWebViewCache] 函数被调用')
    try {
        // #ifdef APP-PLUS
        console.log('[clearWebViewCache] APP-PLUS 环境,开始清除 WebView 缓存')
        // 清除 localStorage
        if (plus.storage) {
            plus.storage.clear()
            console.log('[clearWebViewCache] localStorage 已清除')
        }
        // 清除 WebView 缓存
        const currentWebview = plus.webview.currentWebview()
        if (currentWebview && typeof currentWebview.clearCache === 'function') {
            currentWebview.clearCache()
            console.log('[clearWebViewCache] WebView 缓存已清除')
        }
        // 清除所有 WebView 的缓存
        const allWebviews = plus.webview.all()
        allWebviews.forEach((webview) => {
            if (webview && typeof webview.clearCache === 'function') {
                webview.clearCache()
            }
        })
        console.log('[clearWebViewCache] 所有 WebView 缓存已清除')
        // #endif
        // #ifndef APP-PLUS
        console.log('[clearWebViewCache] 非 APP-PLUS 环境,跳过清除')
        // #endif
    } catch (error) {
        console.error('[clearWebViewCache] 清除缓存失败:', error)
    }
}
/**
 * 打开注销账号确认弹窗。
 */
function handleCancelAccount() {