Skip to content

Commit

Permalink
fix ts error
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind committed Sep 26, 2022
1 parent 863eb1d commit f01e90f
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions packages/nextjs/taro/src/internal/taroApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import type {TaroPage, CustomRoutes} from '../_util/typings'

function isAbsoluteUrl(url?: string): boolean {
if (!url) {
return false;
return false
}
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url)
}

class TaroApp {
Expand Down Expand Up @@ -39,8 +39,8 @@ class TaroApp {

navigateTo: typeof swan.navigateTo = ({url, success, fail, complete}) => {
if (!Router.router) {
fail()
complete()
fail?.()
complete?.()
return
}

Expand All @@ -62,31 +62,31 @@ class TaroApp {
route: urlObj.pathname
}
this.pageStack.push(page)
success()
success?.()
})
.catch(fail)
.finally(complete)
}

navigateBack: typeof swan.navigateBack = ({success, fail, complete}) => {
if (!Router.router) {
fail()
complete()
fail?.()
complete?.()
return
}

// Next.js internal router apis aren't support to go back twice or many times.
// https://github.com/vercel/next.js/discussions/18333
Router.router.back()
this.pageStack.pop()
success()
complete()
success?.()
complete?.()
}

redirectTo: typeof swan.redirectTo = ({url, complete, fail, success}) => {
if (!Router.router) {
fail()
complete()
fail?.()
complete?.()
return
}

Expand All @@ -105,16 +105,16 @@ class TaroApp {
}
this.pageStack.pop()
this.pageStack.push(page)
success()
success?.()
})
.catch(fail)
.finally(complete)
}

reLaunch: typeof swan.reLaunch = ({url, complete, fail, success}) => {
if (!Router.router) {
fail()
complete()
fail?.()
complete?.()
return
}

Expand All @@ -132,7 +132,7 @@ class TaroApp {
route: urlObj.pathname
}
this.pageStack = [page]
success()
success?.()
})
.catch(fail)
.finally(complete)
Expand Down

0 comments on commit f01e90f

Please sign in to comment.