Skip to content

Commit

Permalink
Merge pull request #1383 from didi/feat-navigator-open-type-v2
Browse files Browse the repository at this point in the history
feat: 支持 getEnterOptionsSync api
  • Loading branch information
hiyuki authored Jan 23, 2024
2 parents 8865ad4 + 566c57f commit c3e69aa
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/api-proxy/src/platform/api/lifecycle/index.ali.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function getEnterOptionsSync () {
my.getEnterOptionsSync()
}

export {
getEnterOptionsSync
}
9 changes: 9 additions & 0 deletions packages/api-proxy/src/platform/api/lifecycle/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { getEnvObj, envError } from '../../../common/js'

const ENV_OBJ = getEnvObj()

const getEnterOptionsSync = ENV_OBJ.getEnterOptionsSync || envError('getEnterOptionsSync')

export {
getEnterOptionsSync
}
12 changes: 12 additions & 0 deletions packages/api-proxy/src/platform/api/lifecycle/index.web.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { isBrowser, throwSSRWarning } from '../../../common/js'
function getEnterOptionsSync () {
if (!isBrowser) {
throwSSRWarning('getEnterOptionsSync API is running in non browser environments')
return
}
return global.__mpxEnterOptions || {}
}

export {
getEnterOptionsSync
}
3 changes: 3 additions & 0 deletions packages/api-proxy/src/platform/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,6 @@ export * from './api/video'

// onWindowResize, offWindowResize
export * from './api/window'

// getEnterOptionsSync
export * from './api/lifecycle'
1 change: 1 addition & 0 deletions packages/core/src/platform/createApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default function createApp (option, config = {}) {
shareTicket: '',
referrerInfo: {}
}
global.__mpxEnterOptions = options
this.$options.onLaunch && this.$options.onLaunch.call(this, options)
global.__mpxAppCbs = global.__mpxAppCbs || {
show: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
url: this.url
})
break
case 'switchTab':
mpx.switchTab && mpx.switchTab({
url: this.url
})
break
}
}
})
Expand Down

0 comments on commit c3e69aa

Please sign in to comment.