Skip to content

Commit

Permalink
feat(uni-app-x mp): page.options调整为UTSJSONObject类型
Browse files Browse the repository at this point in the history
  • Loading branch information
Wangyaqi committed Nov 30, 2024
1 parent 3fd0074 commit 4d76da4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
7 changes: 6 additions & 1 deletion packages/uni-mp-alipay/src/runtime/createPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ export function initCreatePage() {
vueOptions = vueOptions.default || vueOptions
const pageOptions: tinyapp.PageOptions = {
onLoad(query) {
this.options = query
if (__X__) {
// query并非多层级结构,无需递归处理
this.options = new UTSJSONObject(query || {})
} else {
this.options = query
}
this.$page = {
fullPath: addLeadingSlash(this.route + stringifyQuery(query)),
}
Expand Down
8 changes: 7 additions & 1 deletion packages/uni-mp-baidu/src/runtime/parsePageOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ export function parse(pageOptions: MPComponentOptions) {
;(this as any)._$loaded = true
const copyQuery = extend({}, query)
delete copyQuery.__id__
;(this as any).options = copyQuery

if (__X__) {
// query并非多层级结构,无需递归处理
;(this as any).options = new UTSJSONObject(copyQuery || {})
} else {
;(this as any).options = copyQuery
}
;(this as any).pageinstance.$page = (this as any).$page = {
fullPath:
'/' + (this as any).pageinstance.route + stringifyQuery(copyQuery),
Expand Down
7 changes: 6 additions & 1 deletion packages/uni-mp-core/src/runtime/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ function parsePage(
this: CustomComponentInstanceProperty,
query: Record<string, any>
) {
;(this as any).options = query
if (__X__) {
// query并非多层级结构,无需递归处理
;(this as any).options = new UTSJSONObject(query || {})
} else {
;(this as any).options = query
}
;(this as any).$page = {
fullPath: addLeadingSlash((this as any).route + stringifyQuery(query)),
}
Expand Down
7 changes: 6 additions & 1 deletion packages/uni-mp-jd/src/runtime/createPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ function parsePage(
this: CustomComponentInstanceProperty,
query: Record<string, any>
) {
;(this as any).options = query
if (__X__) {
// query并非多层级结构,无需递归处理
;(this as any).options = new UTSJSONObject(query || {})
} else {
;(this as any).options = query
}
;(this as any).$page = {
fullPath: addLeadingSlash((this as any).route + stringifyQuery(query)),
}
Expand Down
7 changes: 6 additions & 1 deletion packages/uni-mp-xhs/src/runtime/createPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export function initCreatePage() {
vueOptions = vueOptions.default || vueOptions
const pageOptions: tinyapp.PageOptions = {
onLoad(query) {
this.options = query
if (__X__) {
// query并非多层级结构,无需递归处理
this.options = new UTSJSONObject(query || {})
} else {
this.options = query
}
this.$page = {
fullPath: addLeadingSlash(this.route + stringifyQuery(query)),
}
Expand Down

0 comments on commit 4d76da4

Please sign in to comment.