From 69de3b5418a024b46e916ae26bbd028b771855da Mon Sep 17 00:00:00 2001 From: Longmain Date: Mon, 18 Jan 2021 21:38:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=B8=AD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AF=B9promise.finally=E6=93=8D=E4=BD=9C=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20(#458)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- litemall-wx/app.js | 11 +++++++++++ renard-wx/app.js | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/litemall-wx/app.js b/litemall-wx/app.js index 1fb78e95..d9b0acc9 100644 --- a/litemall-wx/app.js +++ b/litemall-wx/app.js @@ -4,6 +4,17 @@ var user = require('./utils/user.js'); App({ onLaunch: function() { + Promise.prototype.finally = function(callback){ + let P = this.constructor; + return this.then( + value => { + P.resolve(callback()).then(() => value) + }, + reason => { + P.resolve(callback()).then(() => { throw reason }) + } + ) + } const updateManager = wx.getUpdateManager(); wx.getUpdateManager().onUpdateReady(function() { wx.showModal({ diff --git a/renard-wx/app.js b/renard-wx/app.js index 1fb78e95..2c55319f 100644 --- a/renard-wx/app.js +++ b/renard-wx/app.js @@ -4,7 +4,20 @@ var user = require('./utils/user.js'); App({ onLaunch: function() { + Promise.prototype.finally = function(callback){ + let P = this.constructor; + return this.then( + value => { + P.resolve(callback()).then(() => value) + }, + reason => { + P.resolve(callback()).then(() => { throw reason }) + } + ) + } + const updateManager = wx.getUpdateManager(); + wx.getUpdateManager().onUpdateReady(function() { wx.showModal({ title: '更新提示',