From 6314080ad7acb0c574b42ebc2611b056817bec45 Mon Sep 17 00:00:00 2001 From: Aex Date: Wed, 4 Aug 2021 13:51:13 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E5=86=99?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/iwx/index.ts | 6 +++--- src/router/index.ts | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/iwx/index.ts b/src/iwx/index.ts index b2f8203..1b92782 100644 --- a/src/iwx/index.ts +++ b/src/iwx/index.ts @@ -21,7 +21,7 @@ const async = ( args?: any, self?: WechatMiniprogram.Component.TrivialInstance | WechatMiniprogram.Page.TrivialInstance ) => - new Promise((resolve) => + new Promise((resolve) => func( { ...args, @@ -30,7 +30,7 @@ const async = ( }, self ) - ) as Promise + ) const async_void = (func: (...args: any[]) => any, args?: any) => new Promise((resolve) => @@ -268,7 +268,7 @@ export default new (class { } async checkLoginCode(arg?: WechatMiniprogram.LoginOption) { - const res = await this.login(arg) + const res = (await this.login(arg)) || { code: '' } return res.code || error('微信登陆失败,无法获取code') } diff --git a/src/router/index.ts b/src/router/index.ts index 260dfa1..2670698 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,6 +1,6 @@ import config from '../config' -import { Dic } from '../typing' import { iwx } from '../index' +import { Dic } from '../typing' export default new (class { go(path: string, isRedirect = false) { @@ -15,7 +15,7 @@ export default new (class { const realPath = path.substr(colonIndex + 1) // 本小程序页面 - if (appId === config.selfAppId) return this.goInner(realPath, isRedirect) + if (appId === config.selfAppId) return this._goInner(realPath, isRedirect) const accountInfo = iwx.getAccountInfoSync() || ({} as any) const miniProgram = accountInfo.miniProgram || {} @@ -26,10 +26,10 @@ export default new (class { } //以'/'或者'./'开头则为内部链接 - if (path.startsWith('/') || path.startsWith('./')) return this.goInner(path, isRedirect) + if (path.startsWith('/') || path.startsWith('./')) return this._goInner(path, isRedirect) //以http://或者https:// 则为外部h5链接 - if (path.startsWith('http://') || path.startsWith('https://')) return this.goInner(`/web/pages/link?link=${encodeURIComponent(path)}`, isRedirect) + if (path.startsWith('http://') || path.startsWith('https://')) return this._goInner(`/web/pages/link?link=${encodeURIComponent(path)}`, isRedirect) // 不是以上情况则警告 console.warn('please provide correct path') @@ -94,7 +94,7 @@ export default new (class { return '/' + (route + querySting).replace(/\?$/g, '').replace(/&$/g, '') } - private goInner(path: string, isRedirect = false) { + _goInner(path: string, isRedirect = false) { //重定向 关闭当前页面 if (isRedirect) return wx.redirectTo({ url: path, fail: (e) => wx.switchTab({ url: path, fail: (e) => console.warn('please provide correct inner path') }) })