@dcloudio/uni-cli-shared 2.0.1-32920211122002 → 2.0.1-alpha-33120211210001

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.
@@ -147,7 +147,7 @@ export default {
147
147
  setBackgroundTextStyle () {
148
148
  // TODO h5 app-plus 暂不支持
149
149
  // #ifdef MP
150
- uni.setBackgroundTextStyle({
150
+ uni.setBackgroundTextStyle && uni.setBackgroundTextStyle({
151
151
  textStyle: this.backgroundTextStyle
152
152
  })
153
153
  // #endif
@@ -155,7 +155,7 @@ export default {
155
155
  setBackgroundColor () {
156
156
  // TODO h5 app-plus 暂不支持
157
157
  // #ifdef MP
158
- uni.setBackgroundColor({
158
+ uni.setBackgroundColor && uni.setBackgroundColor({
159
159
  backgroundColor: this.backgroundColor,
160
160
  backgroundColorTop: this.backgroundColorTop,
161
161
  backgroundColorBottom: this.backgroundColorBottom
package/lib/platform.js CHANGED
@@ -17,7 +17,26 @@ function getShadowCss () {
17
17
  if (process.env.UNI_PLATFORM === 'h5') {
18
18
  tagName = 'body'
19
19
  }
20
- return `${tagName}::after{position:fixed;content:'';left:-1000px;top:-1000px;-webkit-animation:shadow-preload .1s;-webkit-animation-delay:3s;animation:shadow-preload .1s;animation-delay:3s}@-webkit-keyframes shadow-preload{0%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}100%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}}@keyframes shadow-preload{0%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}100%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}}`
20
+ const cdn = getShadowCdn()
21
+ return `${tagName}::after{position:fixed;content:'';left:-1000px;top:-1000px;-webkit-animation:shadow-preload .1s;-webkit-animation-delay:3s;animation:shadow-preload .1s;animation-delay:3s}@-webkit-keyframes shadow-preload{0%{background-image:url(${cdn}/img/shadow-grey.png)}100%{background-image:url(${cdn}/img/shadow-grey.png)}}@keyframes shadow-preload{0%{background-image:url(${cdn}/img/shadow-grey.png)}100%{background-image:url(${cdn}/img/shadow-grey.png)}}`
22
+ }
23
+ const cdns = {
24
+ 'mp-weixin': 1,
25
+ 'mp-alipay': 2,
26
+ 'mp-baidu': 3,
27
+ 'mp-toutiao': 4,
28
+ 'mp-qq': 5,
29
+ 'mp-360': 7,
30
+ 'mp-dingtalk': 8,
31
+ 'mp-kuaishou': 9,
32
+ 'mp-lark': 10,
33
+ 'quickapp-webview-huawei': 200,
34
+ 'quickapp-webview-union': 201
35
+ }
36
+
37
+ function getShadowCdn () {
38
+ const index = cdns[process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM] || ''
39
+ return `https://cdn${index}.dcloud.net.cn`
21
40
  }
22
41
 
23
42
  // 解决 vue-cli-service lint 时 UNI_PLATFORM 不存在
@@ -34,7 +53,8 @@ module.exports = {
34
53
  normalizeNodeModules,
35
54
  isInHBuilderX,
36
55
  isInHBuilderXAlpha,
37
- runByHBuilderX: isInHBuilderX || fs.existsSync(path.resolve(process.env.UNI_HBUILDERX_PLUGINS || '', 'weapp-tools')),
56
+ runByHBuilderX: isInHBuilderX || fs.existsSync(path.resolve(process.env.UNI_HBUILDERX_PLUGINS || '',
57
+ 'weapp-tools')),
38
58
  getFlexDirection (json) {
39
59
  let flexDir = 'column'
40
60
  if (json && json.nvue && json.nvue['flex-direction']) {
@@ -90,7 +110,11 @@ module.exports = {
90
110
  },
91
111
  getMPRuntimePath () {
92
112
  if (process.env.UNI_USING_VUE3) {
93
- return require.resolve('@dcloudio/uni-' + process.env.UNI_PLATFORM + '/dist/uni.mp.esm.js')
113
+ try {
114
+ return require.resolve('@dcloudio/uni-' + process.env.UNI_PLATFORM + '/dist/uni.mp.esm.js')
115
+ } catch (error) {
116
+ throw new Error('Vue3 项目暂不支持当前小程序')
117
+ }
94
118
  }
95
119
  return require.resolve('@dcloudio/uni-' + process.env.UNI_PLATFORM)
96
120
  },
@@ -125,7 +149,7 @@ module.exports = {
125
149
  if (process.env.UNI_PLATFORM === 'mp-toutiao' || process.env.UNI_PLATFORM === 'mp-lark') {
126
150
  tagName = 'image'
127
151
  }
128
- return `<${tagName} src="https://cdn.dcloud.net.cn/img/shadow-${colorType}.png" style="z-index:998;position:fixed;left:0;top:0;width:100%;height:3px;"/>`
152
+ return `<${tagName} src="${getShadowCdn()}/img/shadow-${colorType}.png" style="z-index:998;position:fixed;left:0;top:0;width:100%;height:3px;"/>`
129
153
  },
130
154
  getPlatformScss () {
131
155
  return SCSS
@@ -137,7 +161,9 @@ module.exports = {
137
161
  return {
138
162
  sourceType: 'module',
139
163
  plugins: [
140
- ['pipelineOperator', { proposal: 'minimal' }],
164
+ ['pipelineOperator', {
165
+ proposal: 'minimal'
166
+ }],
141
167
  'doExpressions',
142
168
  'optionalChaining',
143
169
  'typescript',
@@ -148,4 +174,4 @@ module.exports = {
148
174
  ]
149
175
  }
150
176
  }
151
- }
177
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "2.0.1-32920211122002",
3
+ "version": "2.0.1-alpha-33120211210001",
4
4
  "description": "uni-cli-shared",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -23,5 +23,5 @@
23
23
  "postcss-urlrewrite": "^0.2.2",
24
24
  "strip-json-comments": "^2.0.1"
25
25
  },
26
- "gitHead": "dc33ced4b2fff3063385d9eda8dd1f3539133a67"
26
+ "gitHead": "698a2bcefffbf659284ae128b465f514e8adaefa"
27
27
  }