From 67cdb5fdd49f3b481ddd6e3bb38885cb2e2a646d Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Fri, 03 Dec 2021 10:05:42 +0800 Subject: [PATCH] 优化边框触发条件 --- bases/Fetcher.js | 25 ++++++++++++++++++++----- 1 files changed, 20 insertions(+), 5 deletions(-) diff --git a/bases/Fetcher.js b/bases/Fetcher.js index b0abf5f..0d123b0 100644 --- a/bases/Fetcher.js +++ b/bases/Fetcher.js @@ -187,6 +187,7 @@ }); } + // 小程序中,保存 cookies _saveCookies(cookies) { const localCookies = JSON.parse(Taro.getStorageSync('cookies') || '{}'); cookies.forEach(cookie => { @@ -196,6 +197,7 @@ Taro.setStorageSync('cookies', JSON.stringify(localCookies)); } + // 小程序中,获取 cookies _getCookies() { const localCookies = JSON.parse(Taro.getStorageSync('cookies') || '{}'); const cookiesArr = []; @@ -386,10 +388,9 @@ if (process.env.TARO_ENV === 'weapp') { Taro.navigateTo({ url: '/pages/home/index/index?mode=login' }); } - // 在App中,直接跳转登陆页 + // 在App中,跳转到首页取消登陆 if (project.appHybrid) { - Taro.removeStorageSync('AiSim@UserInfo'); - Taro.navigateBack({ delta: Taro.getCurrentPages().length }); + Taro.navigateTo({ url: '/pages/home/index/index?mode=logout' }); } return null; } else { @@ -577,8 +578,22 @@ static inDevMod = (() => { // 网页 if (process.env.TARO_ENV === 'h5') { - // 当没有 url 指定时,只有内网 ip 和 33**/35** 的端口号,视为本地开发模式 - return /^(192|127|localhost).*?:3[35]\d{2}$/i.test(window.location.host); + // http协议访问 + if (window.location.protocol.indexOf('http') > 0) { + // 当内网 ip 且使用 33**/35** 的端口号时,视为本地开发模式 + return /^(192|127|localhost).*?:3[35]\d{2}$/i.test(window.location.host); + } + // 非http协议访问 + else { + // 开发编译 + if (process.env.NODE_ENV === 'development') { + return true; + } + // 生产编译 + else if (process.env.NODE_ENV === 'production') { + return false; + } + } } // 小程序 else if (process.env.TARO_ENV === 'weapp') { -- Gitblit v1.9.1