@dcloudio/uni-cli-shared 2.0.2-alpha-4080120250820001 → 2.0.2-alpha-4080120250919001

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -199,7 +199,10 @@ export default {
199
199
  if (adData.tmpl_type === 24) {
200
200
  this.customFullscreen = 'uni-ad-custom-fullscreen'
201
201
  }
202
- this.loading = true
202
+ this.loading = true
203
+ if (!adData.dcloudAdpid) {
204
+ adData.dcloudAdpid = this.adpid
205
+ }
203
206
  this.selectComponent('.uniad-plugin-wx').setConfig(adData)
204
207
  }
205
208
  })
@@ -224,14 +227,18 @@ export default {
224
227
  iv,
225
228
  version,
226
229
  expireTime
227
- }) => {
230
+ }) => {
231
+ const uniOptions = {
232
+ adpid: this.adpid
233
+ }
228
234
  adComponent.show({
229
235
  userId: this.urlCallback.userId || '',
230
236
  extra: this.urlCallback.extra || '',
231
237
  encryptKey,
232
238
  iv,
233
239
  version,
234
- expireTime
240
+ expireTime,
241
+ uniOptions
235
242
  })
236
243
  },
237
244
  fail: (err) => {
@@ -64,8 +64,9 @@ export default {
64
64
  }
65
65
  },
66
66
  created () {
67
- const page = getCurrentPages()[0]
68
- this.$pageVm = page.$vm || page
67
+ const pages = getCurrentPages()
68
+ const currentPage = pages[pages.length - 1]
69
+ this.$pageVm = currentPage.$vm || currentPage
69
70
  // event
70
71
  // h5 暂不支持生命周期 onResize,补充后,可以移除该条件编译
71
72
  // #ifdef H5
@@ -84,7 +85,7 @@ export default {
84
85
  })
85
86
 
86
87
  // #ifdef APP-PLUS
87
- this._currentWebview = page.$getAppWebview()
88
+ this._currentWebview = currentPage.$getAppWebview()
88
89
  if (this.enablePullDownRefresh) {
89
90
  this.setPullDownRefresh(this._currentWebview, true)
90
91
  }
@@ -102,7 +103,7 @@ export default {
102
103
  this.rootFontSize,
103
104
  this.pageStyle
104
105
  ], () => {
105
- this.setPageMeta()
106
+ this.setPageMeta(currentPage.$page.id)
106
107
  })
107
108
  this.$watch(() => [
108
109
  this.backgroundColor,
@@ -128,6 +129,11 @@ export default {
128
129
  mounted () {
129
130
  this.scrollTop && this.pageScrollTo()
130
131
  },
132
+ // #ifdef H5
133
+ activated () {
134
+ this.setPageMeta()
135
+ },
136
+ // #endif
131
137
  methods: {
132
138
  setPullDownRefresh (webview, enabled) {
133
139
  webview.setStyle({
@@ -137,12 +143,15 @@ export default {
137
143
  }
138
144
  })
139
145
  },
140
- setPageMeta () {
146
+ setPageMeta (pageId) {
141
147
  // h5 和 app-plus 设置 rootFontSize
142
148
  // #ifdef H5 || APP-PLUS
143
- uni.setPageMeta({
144
- pageStyle: this.pageStyle,
145
- rootFontSize: this.rootFontSize
149
+ this.$nextTick(() => {
150
+ uni.setPageMeta({
151
+ pageStyle: this.pageStyle,
152
+ rootFontSize: this.rootFontSize,
153
+ pageId
154
+ })
146
155
  })
147
156
  // #endif
148
157
  },
@@ -59,12 +59,36 @@ function createUniModulesSyncFilePreprocessor (
59
59
  } else if (extname === '.uts' || extname === '.ts') {
60
60
  return preJs(content)
61
61
  } else if (extname === '.uvue' || extname === '.vue') {
62
- return preJs(preHtml(content))
62
+ return preUTSSDKVueFile(fileName, preJs(preHtml(content)))
63
63
  }
64
64
  return content
65
65
  }
66
66
  }
67
67
 
68
+ function preUTSSDKVueFile (filename, content) {
69
+ if (
70
+ filename.includes('utssdk') &&
71
+ (filename.includes('app-android') || filename.includes('app-ios'))
72
+ ) {
73
+ const {
74
+ parseComponent
75
+ } = require('vue-template-compiler')
76
+ const descriptor = parseComponent(content, {
77
+ sourceMap: false,
78
+ pad: 'line'
79
+ })
80
+ if (descriptor.script?.content) {
81
+ return (
82
+ descriptor.script.content +
83
+ // 补充 template 内容
84
+ `/*${descriptor.template?.content}*/`
85
+ )
86
+ }
87
+ return content
88
+ }
89
+ return content
90
+ }
91
+
68
92
  function once (fn, ctx = null) {
69
93
  let res
70
94
  return (...args) => {
@@ -96,7 +120,8 @@ module.exports = async function (content) {
96
120
 
97
121
  const {
98
122
  syncUniModuleFilesByCompiler,
99
- resolveTscUniModuleIndexFileName
123
+ resolveTscUniModuleIndexFileName,
124
+ resolveTscUniModuleUTSSDKVueFileNames
100
125
  } = resolveUTSCompiler()
101
126
 
102
127
  const compilePlugin = async (pluginDir) => {
@@ -127,8 +152,16 @@ module.exports = async function (content) {
127
152
  if (!utsPlugins.has(pluginId)) {
128
153
  utsPlugins.add(pluginId)
129
154
  if (uniXKotlinCompiler) {
155
+ const platform = 'app-android'
156
+ const vueFiles = resolveTscUniModuleUTSSDKVueFileNames(
157
+ platform,
158
+ pluginDir
159
+ )
160
+ for (const vueFile of vueFiles) {
161
+ await uniXKotlinCompiler.addRootFile(vueFile)
162
+ }
130
163
  const indexFileName = resolveTscUniModuleIndexFileName(
131
- 'app-android',
164
+ platform,
132
165
  pluginDir
133
166
  )
134
167
  if (indexFileName) {
@@ -136,8 +169,16 @@ module.exports = async function (content) {
136
169
  }
137
170
  }
138
171
  if (uniXSwiftCompiler) {
172
+ const platform = 'app-ios'
173
+ const vueFiles = resolveTscUniModuleUTSSDKVueFileNames(
174
+ platform,
175
+ pluginDir
176
+ )
177
+ for (const vueFile of vueFiles) {
178
+ await uniXSwiftCompiler.addRootFile(vueFile)
179
+ }
139
180
  const indexFileName = resolveTscUniModuleIndexFileName(
140
- 'app-ios',
181
+ platform,
141
182
  pluginDir
142
183
  )
143
184
  if (indexFileName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "2.0.2-alpha-4080120250820001",
3
+ "version": "2.0.2-alpha-4080120250919001",
4
4
  "description": "uni-cli-shared",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -27,5 +27,5 @@
27
27
  "postcss-urlrewrite": "^0.2.2",
28
28
  "strip-json-comments": "^2.0.1"
29
29
  },
30
- "gitHead": "1b189efe8ae8539a5bc8263bccc28b25d9816771"
30
+ "gitHead": "6cf28674bc4528abb52eda389d5a207e74af785d"
31
31
  }