@dcloudio/vue-cli-plugin-uni 2.0.1-alpha-35520220824002 → 2.0.1-alpha-36020220901001

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.
package/lib/mp/index.js CHANGED
@@ -26,6 +26,8 @@ function createUniMPPlugin () {
26
26
  }
27
27
 
28
28
  const createWxMpIndependentPlugins = require('@dcloudio/uni-mp-weixin/lib/createIndependentPlugin')
29
+
30
+ const UniTips = require('./tips')
29
31
 
30
32
  function getProvides () {
31
33
  const uniPath = require('@dcloudio/uni-cli-shared/lib/platform').getMPRuntimePath()
@@ -190,7 +192,7 @@ module.exports = {
190
192
 
191
193
  if ((process.env.UNI_SUBPACKGE || process.env.UNI_MP_PLUGIN) && process.env.UNI_SUBPACKGE !== 'main') {
192
194
  plugins.push(new PreprocessAssetsPlugin())
193
- }
195
+ }
194
196
 
195
197
  {
196
198
  const globalEnv = process.env.UNI_PLATFORM === 'mp-alipay' ? 'my' : 'wx';
@@ -228,7 +230,12 @@ ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__ = __webpack_require__;`
228
230
  }
229
231
  if (process.env.NODE_ENV === 'production' || process.env.UNI_MINIMIZE === 'true') {
230
232
  output.pathinfo = false
231
- }
233
+ }
234
+
235
+ if (process.env.UNI_PLATFORM === 'mp-weixin' && process.env.NODE_ENV === 'production') {
236
+ plugins.push(new UniTips())
237
+ }
238
+
232
239
  return {
233
240
  mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
234
241
  entry () {
package/lib/mp/tips.js ADDED
@@ -0,0 +1,67 @@
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+ const {
4
+ isInHBuilderX
5
+ } = require('@dcloudio/uni-cli-shared')
6
+
7
+ class UniTips {
8
+ apply (compiler) {
9
+ compiler.hooks.emit.tap('PreprocessAssetsPlugin', compilation => {
10
+ const assets = compilation.assets
11
+ let hasAd = false
12
+
13
+ try {
14
+ Object.keys(assets).forEach(name => {
15
+ if (hasAd) {
16
+ return
17
+ }
18
+
19
+ if (!name.startsWith('common') && !name.startsWith('pages')) {
20
+ return
21
+ }
22
+
23
+ const extname = path.extname(name)
24
+ if (extname !== '.js') {
25
+ return
26
+ }
27
+
28
+ if (!hasAd && !process.env.USE_UNI_AD) {
29
+ hasAd = assets[name]._value.match(/createRewardedVideoAd|createInterstitialAd/)
30
+ }
31
+ })
32
+
33
+ setTimeout(() => {
34
+ if (hasAd) {
35
+ console.log(
36
+ '推荐使用uni-ad微信小程序版广告,无开通门槛、提前结算、插件丰富,助力广告变现。详情: https://uniapp.dcloud.net.cn/component/ad-weixin.html'
37
+ )
38
+ }
39
+
40
+ let projectRoot = ''
41
+ if (isInHBuilderX) {
42
+ projectRoot = process.env.UNI_INPUT_DIR
43
+ } else {
44
+ projectRoot = process.env.UNI_CLI_CONTEXT
45
+ }
46
+
47
+ const paths = fs.readdirSync(projectRoot)
48
+ const useUniCloud = paths.find((name) => {
49
+ return name.includes('uniCloud-')
50
+ })
51
+
52
+ if (!useUniCloud && assets['project.config.json']) {
53
+ const pcjString = assets['project.config.json'].source()
54
+ const pcjJson = JSON.parse(pcjString)
55
+ if (typeof pcjJson.cloudfunctionRoot === 'string' && pcjJson.cloudfunctionRoot.length > 0) {
56
+ console.log(
57
+ '欢迎使用uniCloud,价格更便宜、开发更方便、生态更丰富的云开发。详情: https://uniapp.dcloud.net.cn/uniCloud/wx2unicloud.html'
58
+ )
59
+ }
60
+ }
61
+ }, 100)
62
+ } catch (e) {}
63
+ })
64
+ }
65
+ }
66
+
67
+ module.exports = UniTips
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/vue-cli-plugin-uni",
3
- "version": "2.0.1-alpha-35520220824002",
3
+ "version": "2.0.1-alpha-36020220901001",
4
4
  "description": "uni-app plugin for vue-cli 3",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -17,7 +17,7 @@
17
17
  "author": "fxy060608",
18
18
  "license": "Apache-2.0",
19
19
  "dependencies": {
20
- "@dcloudio/uni-stat": "^2.0.1-alpha-35520220824002",
20
+ "@dcloudio/uni-stat": "^2.0.1-alpha-36020220901001",
21
21
  "buffer-json": "^2.0.0",
22
22
  "clone-deep": "^4.0.1",
23
23
  "cross-env": "^5.2.0",
@@ -41,5 +41,5 @@
41
41
  "copy-webpack-plugin": ">=5",
42
42
  "postcss": ">=7"
43
43
  },
44
- "gitHead": "3af59a95da3633a0740861405065ef6452bf72ae"
44
+ "gitHead": "734c563240436d5f63a8200d676ccc8bead9f10d"
45
45
  }
@@ -2230,17 +2230,17 @@ function updateListeners (
2230
2230
 
2231
2231
  /* */
2232
2232
 
2233
- // fixed by xxxxxx (mp properties)
2234
- function extractPropertiesFromVNodeData(data, Ctor, res, context) {
2235
- var propOptions = Ctor.options.mpOptions && Ctor.options.mpOptions.properties;
2236
- if (isUndef(propOptions)) {
2237
- return res
2233
+ // fixed by xxxxxx (mp properties)
2234
+ function extractPropertiesFromVNodeData(data, Ctor, res, context) {
2235
+ var propOptions = Ctor.options.mpOptions && Ctor.options.mpOptions.properties;
2236
+ if (isUndef(propOptions)) {
2237
+ return res
2238
2238
  }
2239
- var externalClasses = Ctor.options.mpOptions.externalClasses || [];
2239
+ var externalClasses = Ctor.options.mpOptions.externalClasses || [];
2240
2240
  var attrs = data.attrs;
2241
- var props = data.props;
2242
- if (isDef(attrs) || isDef(props)) {
2243
- for (var key in propOptions) {
2241
+ var props = data.props;
2242
+ if (isDef(attrs) || isDef(props)) {
2243
+ for (var key in propOptions) {
2244
2244
  var altKey = hyphenate(key);
2245
2245
  var result = checkProp(res, props, key, altKey, true) ||
2246
2246
  checkProp(res, attrs, key, altKey, false);
@@ -2253,10 +2253,10 @@ function extractPropertiesFromVNodeData(data, Ctor, res, context) {
2253
2253
  ) {
2254
2254
  // 赋值 externalClass 真正的值(模板里 externalClass 的值可能是字符串)
2255
2255
  res[key] = context[camelize(res[key])];
2256
- }
2257
- }
2258
- }
2259
- return res
2256
+ }
2257
+ }
2258
+ }
2259
+ return res
2260
2260
  }
2261
2261
 
2262
2262
  function extractPropsFromVNodeData (
@@ -5522,138 +5522,138 @@ function type(obj) {
5522
5522
  return Object.prototype.toString.call(obj)
5523
5523
  }
5524
5524
 
5525
- /* */
5526
-
5527
- function flushCallbacks$1(vm) {
5528
- if (vm.__next_tick_callbacks && vm.__next_tick_callbacks.length) {
5529
- if (process.env.VUE_APP_DEBUG) {
5530
- var mpInstance = vm.$scope;
5531
- console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + vm._uid +
5532
- ']:flushCallbacks[' + vm.__next_tick_callbacks.length + ']');
5533
- }
5534
- var copies = vm.__next_tick_callbacks.slice(0);
5535
- vm.__next_tick_callbacks.length = 0;
5536
- for (var i = 0; i < copies.length; i++) {
5537
- copies[i]();
5538
- }
5539
- }
5540
- }
5541
-
5542
- function hasRenderWatcher(vm) {
5543
- return queue.find(function (watcher) { return vm._watcher === watcher; })
5544
- }
5545
-
5546
- function nextTick$1(vm, cb) {
5547
- //1.nextTick 之前 已 setData 且 setData 还未回调完成
5548
- //2.nextTick 之前存在 render watcher
5525
+ /* */
5526
+
5527
+ function flushCallbacks$1(vm) {
5528
+ if (vm.__next_tick_callbacks && vm.__next_tick_callbacks.length) {
5529
+ if (process.env.VUE_APP_DEBUG) {
5530
+ var mpInstance = vm.$scope;
5531
+ console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + vm._uid +
5532
+ ']:flushCallbacks[' + vm.__next_tick_callbacks.length + ']');
5533
+ }
5534
+ var copies = vm.__next_tick_callbacks.slice(0);
5535
+ vm.__next_tick_callbacks.length = 0;
5536
+ for (var i = 0; i < copies.length; i++) {
5537
+ copies[i]();
5538
+ }
5539
+ }
5540
+ }
5541
+
5542
+ function hasRenderWatcher(vm) {
5543
+ return queue.find(function (watcher) { return vm._watcher === watcher; })
5544
+ }
5545
+
5546
+ function nextTick$1(vm, cb) {
5547
+ //1.nextTick 之前 已 setData 且 setData 还未回调完成
5548
+ //2.nextTick 之前存在 render watcher
5549
5549
  if (!vm.__next_tick_pending && !hasRenderWatcher(vm)) {
5550
5550
  if(process.env.VUE_APP_DEBUG){
5551
5551
  var mpInstance = vm.$scope;
5552
5552
  console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + vm._uid +
5553
5553
  ']:nextVueTick');
5554
- }
5555
- return nextTick(cb, vm)
5554
+ }
5555
+ return nextTick(cb, vm)
5556
5556
  }else{
5557
5557
  if(process.env.VUE_APP_DEBUG){
5558
5558
  var mpInstance$1 = vm.$scope;
5559
5559
  console.log('[' + (+new Date) + '][' + (mpInstance$1.is || mpInstance$1.route) + '][' + vm._uid +
5560
5560
  ']:nextMPTick');
5561
5561
  }
5562
- }
5563
- var _resolve;
5564
- if (!vm.__next_tick_callbacks) {
5565
- vm.__next_tick_callbacks = [];
5566
- }
5567
- vm.__next_tick_callbacks.push(function () {
5568
- if (cb) {
5569
- try {
5570
- cb.call(vm);
5571
- } catch (e) {
5572
- handleError(e, vm, 'nextTick');
5573
- }
5574
- } else if (_resolve) {
5575
- _resolve(vm);
5576
- }
5577
- });
5578
- // $flow-disable-line
5579
- if (!cb && typeof Promise !== 'undefined') {
5580
- return new Promise(function (resolve) {
5581
- _resolve = resolve;
5582
- })
5583
- }
5584
- }
5585
-
5586
- /* */
5587
-
5588
- function cloneWithData(vm) {
5589
- // 确保当前 vm 所有数据被同步
5590
- var ret = Object.create(null);
5591
- var dataKeys = [].concat(
5592
- Object.keys(vm._data || {}),
5593
- Object.keys(vm._computedWatchers || {}));
5594
-
5595
- dataKeys.reduce(function(ret, key) {
5596
- ret[key] = vm[key];
5597
- return ret
5598
- }, ret);
5599
-
5600
- // vue-composition-api
5601
- var compositionApiState = vm.__composition_api_state__ || vm.__secret_vfa_state__;
5602
- var rawBindings = compositionApiState && compositionApiState.rawBindings;
5603
- if (rawBindings) {
5604
- Object.keys(rawBindings).forEach(function (key) {
5605
- ret[key] = vm[key];
5606
- });
5607
- }
5608
-
5609
- //TODO 需要把无用数据处理掉,比如 list=>l0 则 list 需要移除,否则多传输一份数据
5610
- Object.assign(ret, vm.$mp.data || {});
5611
- if (
5612
- Array.isArray(vm.$options.behaviors) &&
5613
- vm.$options.behaviors.indexOf('uni://form-field') !== -1
5614
- ) { //form-field
5615
- ret['name'] = vm.name;
5616
- ret['value'] = vm.value;
5617
- }
5618
-
5619
- return JSON.parse(JSON.stringify(ret))
5620
- }
5621
-
5562
+ }
5563
+ var _resolve;
5564
+ if (!vm.__next_tick_callbacks) {
5565
+ vm.__next_tick_callbacks = [];
5566
+ }
5567
+ vm.__next_tick_callbacks.push(function () {
5568
+ if (cb) {
5569
+ try {
5570
+ cb.call(vm);
5571
+ } catch (e) {
5572
+ handleError(e, vm, 'nextTick');
5573
+ }
5574
+ } else if (_resolve) {
5575
+ _resolve(vm);
5576
+ }
5577
+ });
5578
+ // $flow-disable-line
5579
+ if (!cb && typeof Promise !== 'undefined') {
5580
+ return new Promise(function (resolve) {
5581
+ _resolve = resolve;
5582
+ })
5583
+ }
5584
+ }
5585
+
5586
+ /* */
5587
+
5588
+ function cloneWithData(vm) {
5589
+ // 确保当前 vm 所有数据被同步
5590
+ var ret = Object.create(null);
5591
+ var dataKeys = [].concat(
5592
+ Object.keys(vm._data || {}),
5593
+ Object.keys(vm._computedWatchers || {}));
5594
+
5595
+ dataKeys.reduce(function(ret, key) {
5596
+ ret[key] = vm[key];
5597
+ return ret
5598
+ }, ret);
5599
+
5600
+ // vue-composition-api
5601
+ var compositionApiState = vm.__composition_api_state__ || vm.__secret_vfa_state__;
5602
+ var rawBindings = compositionApiState && compositionApiState.rawBindings;
5603
+ if (rawBindings) {
5604
+ Object.keys(rawBindings).forEach(function (key) {
5605
+ ret[key] = vm[key];
5606
+ });
5607
+ }
5608
+
5609
+ //TODO 需要把无用数据处理掉,比如 list=>l0 则 list 需要移除,否则多传输一份数据
5610
+ Object.assign(ret, vm.$mp.data || {});
5611
+ if (
5612
+ Array.isArray(vm.$options.behaviors) &&
5613
+ vm.$options.behaviors.indexOf('uni://form-field') !== -1
5614
+ ) { //form-field
5615
+ ret['name'] = vm.name;
5616
+ ret['value'] = vm.value;
5617
+ }
5618
+
5619
+ return JSON.parse(JSON.stringify(ret))
5620
+ }
5621
+
5622
5622
  var patch = function(oldVnode, vnode) {
5623
5623
  var this$1 = this;
5624
-
5625
- if (vnode === null) { //destroy
5626
- return
5627
- }
5628
- if (this.mpType === 'page' || this.mpType === 'component') {
5629
- var mpInstance = this.$scope;
5630
- var data = Object.create(null);
5631
- try {
5632
- data = cloneWithData(this);
5633
- } catch (err) {
5634
- console.error(err);
5635
- }
5636
- data.__webviewId__ = mpInstance.data.__webviewId__;
5637
- var mpData = Object.create(null);
5638
- Object.keys(data).forEach(function (key) { //仅同步 data 中有的数据
5639
- mpData[key] = mpInstance.data[key];
5640
- });
5641
- var diffData = this.$shouldDiffData === false ? data : diff(data, mpData);
5642
- if (Object.keys(diffData).length) {
5643
- if (process.env.VUE_APP_DEBUG) {
5644
- console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + this._uid +
5645
- ']差量更新',
5646
- JSON.stringify(diffData));
5647
- }
5648
- this.__next_tick_pending = true;
5649
- mpInstance.setData(diffData, function () {
5650
- this$1.__next_tick_pending = false;
5651
- flushCallbacks$1(this$1);
5652
- });
5653
- } else {
5654
- flushCallbacks$1(this);
5655
- }
5656
- }
5624
+
5625
+ if (vnode === null) { //destroy
5626
+ return
5627
+ }
5628
+ if (this.mpType === 'page' || this.mpType === 'component') {
5629
+ var mpInstance = this.$scope;
5630
+ var data = Object.create(null);
5631
+ try {
5632
+ data = cloneWithData(this);
5633
+ } catch (err) {
5634
+ console.error(err);
5635
+ }
5636
+ data.__webviewId__ = mpInstance.data.__webviewId__;
5637
+ var mpData = Object.create(null);
5638
+ Object.keys(data).forEach(function (key) { //仅同步 data 中有的数据
5639
+ mpData[key] = mpInstance.data[key];
5640
+ });
5641
+ var diffData = this.$shouldDiffData === false ? data : diff(data, mpData);
5642
+ if (Object.keys(diffData).length) {
5643
+ if (process.env.VUE_APP_DEBUG) {
5644
+ console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + this._uid +
5645
+ ']差量更新',
5646
+ JSON.stringify(diffData));
5647
+ }
5648
+ this.__next_tick_pending = true;
5649
+ mpInstance.setData(diffData, function () {
5650
+ this$1.__next_tick_pending = false;
5651
+ flushCallbacks$1(this$1);
5652
+ });
5653
+ } else {
5654
+ flushCallbacks$1(this);
5655
+ }
5656
+ }
5657
5657
  };
5658
5658
 
5659
5659
  /* */
@@ -5794,252 +5794,253 @@ function normalizeStyleBinding (bindingStyle) {
5794
5794
  return bindingStyle
5795
5795
  }
5796
5796
 
5797
- /* */
5798
-
5799
- var MP_METHODS = ['createSelectorQuery', 'createIntersectionObserver', 'selectAllComponents', 'selectComponent'];
5800
-
5801
- function getTarget(obj, path) {
5802
- var parts = path.split('.');
5803
- var key = parts[0];
5804
- if (key.indexOf('__$n') === 0) { //number index
5805
- key = parseInt(key.replace('__$n', ''));
5806
- }
5807
- if (parts.length === 1) {
5808
- return obj[key]
5809
- }
5810
- return getTarget(obj[key], parts.slice(1).join('.'))
5811
- }
5812
-
5813
- function internalMixin(Vue) {
5814
-
5815
- Vue.config.errorHandler = function(err, vm, info) {
5816
- Vue.util.warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
5817
- console.error(err);
5818
- /* eslint-disable no-undef */
5819
- var app = typeof getApp === 'function' && getApp();
5820
- if (app && app.onError) {
5821
- app.onError(err);
5822
- }
5823
- };
5824
-
5825
- var oldEmit = Vue.prototype.$emit;
5826
-
5827
- Vue.prototype.$emit = function(event) {
5828
- if (this.$scope && event) {
5829
- (this.$scope['_triggerEvent'] || this.$scope['triggerEvent']).call(this.$scope, event, {
5830
- __args__: toArray(arguments, 1)
5831
- });
5832
- }
5833
- return oldEmit.apply(this, arguments)
5834
- };
5835
-
5836
- Vue.prototype.$nextTick = function(fn) {
5837
- return nextTick$1(this, fn)
5838
- };
5839
-
5840
- MP_METHODS.forEach(function (method) {
5841
- Vue.prototype[method] = function(args) {
5842
- if (this.$scope && this.$scope[method]) {
5843
- return this.$scope[method](args)
5844
- }
5845
- // mp-alipay
5846
- if (typeof my === 'undefined') {
5847
- return
5848
- }
5849
- if (method === 'createSelectorQuery') {
5850
- /* eslint-disable no-undef */
5851
- return my.createSelectorQuery(args)
5852
- } else if (method === 'createIntersectionObserver') {
5853
- /* eslint-disable no-undef */
5854
- return my.createIntersectionObserver(args)
5855
- }
5856
- // TODO mp-alipay 暂不支持 selectAllComponents,selectComponent
5857
- };
5858
- });
5859
-
5860
- Vue.prototype.__init_provide = initProvide;
5861
-
5862
- Vue.prototype.__init_injections = initInjections;
5863
-
5864
- Vue.prototype.__call_hook = function(hook, args) {
5865
- var vm = this;
5866
- // #7573 disable dep collection when invoking lifecycle hooks
5867
- pushTarget();
5868
- var handlers = vm.$options[hook];
5869
- var info = hook + " hook";
5870
- var ret;
5871
- if (handlers) {
5872
- for (var i = 0, j = handlers.length; i < j; i++) {
5873
- ret = invokeWithErrorHandling(handlers[i], vm, args ? [args] : null, vm, info);
5874
- }
5875
- }
5876
- if (vm._hasHookEvent) {
5877
- vm.$emit('hook:' + hook, args);
5878
- }
5879
- popTarget();
5880
- return ret
5881
- };
5882
-
5883
- Vue.prototype.__set_model = function(target, key, value, modifiers) {
5884
- if (Array.isArray(modifiers)) {
5885
- if (modifiers.indexOf('trim') !== -1) {
5886
- value = value.trim();
5887
- }
5888
- if (modifiers.indexOf('number') !== -1) {
5889
- value = this._n(value);
5890
- }
5891
- }
5892
- if (!target) {
5893
- target = this;
5894
- }
5895
- // 解决动态属性添加
5896
- Vue.set(target, key, value);
5897
- };
5898
-
5899
- Vue.prototype.__set_sync = function(target, key, value) {
5900
- if (!target) {
5901
- target = this;
5902
- }
5903
- // 解决动态属性添加
5904
- Vue.set(target, key, value);
5905
- };
5906
-
5907
- Vue.prototype.__get_orig = function(item) {
5908
- if (isPlainObject(item)) {
5909
- return item['$orig'] || item
5910
- }
5911
- return item
5912
- };
5913
-
5914
- Vue.prototype.__get_value = function(dataPath, target) {
5915
- return getTarget(target || this, dataPath)
5916
- };
5917
-
5918
-
5919
- Vue.prototype.__get_class = function(dynamicClass, staticClass) {
5920
- return renderClass(staticClass, dynamicClass)
5921
- };
5922
-
5923
- Vue.prototype.__get_style = function(dynamicStyle, staticStyle) {
5924
- if (!dynamicStyle && !staticStyle) {
5925
- return ''
5926
- }
5927
- var dynamicStyleObj = normalizeStyleBinding(dynamicStyle);
5928
- var styleObj = staticStyle ? extend(staticStyle, dynamicStyleObj) : dynamicStyleObj;
5929
- return Object.keys(styleObj).map(function (name) { return ((hyphenate(name)) + ":" + (styleObj[name])); }).join(';')
5930
- };
5931
-
5932
- Vue.prototype.__map = function(val, iteratee) {
5933
- //TODO 暂不考虑 string
5934
- var ret, i, l, keys, key;
5935
- if (Array.isArray(val)) {
5936
- ret = new Array(val.length);
5937
- for (i = 0, l = val.length; i < l; i++) {
5938
- ret[i] = iteratee(val[i], i);
5939
- }
5940
- return ret
5941
- } else if (isObject(val)) {
5942
- keys = Object.keys(val);
5943
- ret = Object.create(null);
5944
- for (i = 0, l = keys.length; i < l; i++) {
5945
- key = keys[i];
5946
- ret[key] = iteratee(val[key], key, i);
5947
- }
5948
- return ret
5949
- } else if (typeof val === 'number') {
5950
- ret = new Array(val);
5951
- for (i = 0, l = val; i < l; i++) {
5952
- // 第一个参数暂时仍和小程序一致
5953
- ret[i] = iteratee(i, i);
5954
- }
5955
- return ret
5956
- }
5957
- return []
5958
- };
5959
-
5960
- }
5961
-
5962
- /* */
5963
-
5964
- var LIFECYCLE_HOOKS$1 = [
5965
- //App
5966
- 'onLaunch',
5967
- 'onShow',
5968
- 'onHide',
5969
- 'onUniNViewMessage',
5970
- 'onPageNotFound',
5971
- 'onThemeChange',
5972
- 'onError',
5973
- 'onUnhandledRejection',
5974
- //Page
5975
- 'onInit',
5976
- 'onLoad',
5977
- // 'onShow',
5978
- 'onReady',
5979
- // 'onHide',
5980
- 'onUnload',
5981
- 'onPullDownRefresh',
5982
- 'onReachBottom',
5983
- 'onTabItemTap',
5984
- 'onAddToFavorites',
5985
- 'onShareTimeline',
5986
- 'onShareAppMessage',
5987
- 'onResize',
5988
- 'onPageScroll',
5989
- 'onNavigationBarButtonTap',
5990
- 'onBackPress',
5991
- 'onNavigationBarSearchInputChanged',
5992
- 'onNavigationBarSearchInputConfirmed',
5993
- 'onNavigationBarSearchInputClicked',
5994
- //Component
5995
- // 'onReady', // 兼容旧版本,应该移除该事件
5996
- 'onPageShow',
5997
- 'onPageHide',
5998
- 'onPageResize'
5999
- ];
6000
- function lifecycleMixin$1(Vue) {
6001
-
6002
- //fixed vue-class-component
6003
- var oldExtend = Vue.extend;
6004
- Vue.extend = function(extendOptions) {
6005
- extendOptions = extendOptions || {};
6006
-
6007
- var methods = extendOptions.methods;
6008
- if (methods) {
6009
- Object.keys(methods).forEach(function (methodName) {
6010
- if (LIFECYCLE_HOOKS$1.indexOf(methodName)!==-1) {
6011
- extendOptions[methodName] = methods[methodName];
6012
- delete methods[methodName];
6013
- }
6014
- });
6015
- }
6016
-
6017
- return oldExtend.call(this, extendOptions)
6018
- };
6019
-
6020
- var strategies = Vue.config.optionMergeStrategies;
6021
- var mergeHook = strategies.created;
6022
- LIFECYCLE_HOOKS$1.forEach(function (hook) {
6023
- strategies[hook] = mergeHook;
6024
- });
6025
-
6026
- Vue.prototype.__lifecycle_hooks__ = LIFECYCLE_HOOKS$1;
6027
- }
6028
-
6029
- /* */
6030
-
6031
- // install platform patch function
6032
- Vue.prototype.__patch__ = patch;
6033
-
6034
- // public mount method
6035
- Vue.prototype.$mount = function(
6036
- el ,
6037
- hydrating
6038
- ) {
6039
- return mountComponent$1(this, el, hydrating)
6040
- };
6041
-
6042
- lifecycleMixin$1(Vue);
5797
+ /* */
5798
+
5799
+ var MP_METHODS = ['createSelectorQuery', 'createIntersectionObserver', 'selectAllComponents', 'selectComponent'];
5800
+
5801
+ function getTarget(obj, path) {
5802
+ var parts = path.split('.');
5803
+ var key = parts[0];
5804
+ if (key.indexOf('__$n') === 0) { //number index
5805
+ key = parseInt(key.replace('__$n', ''));
5806
+ }
5807
+ if (parts.length === 1) {
5808
+ return obj[key]
5809
+ }
5810
+ return getTarget(obj[key], parts.slice(1).join('.'))
5811
+ }
5812
+
5813
+ function internalMixin(Vue) {
5814
+
5815
+ Vue.config.errorHandler = function(err, vm, info) {
5816
+ Vue.util.warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
5817
+ console.error(err);
5818
+ /* eslint-disable no-undef */
5819
+ var app = typeof getApp === 'function' && getApp();
5820
+ if (app && app.onError) {
5821
+ app.onError(err);
5822
+ }
5823
+ };
5824
+
5825
+ var oldEmit = Vue.prototype.$emit;
5826
+
5827
+ Vue.prototype.$emit = function(event) {
5828
+ if (this.$scope && event) {
5829
+ (this.$scope['_triggerEvent'] || this.$scope['triggerEvent']).call(this.$scope, event, {
5830
+ __args__: toArray(arguments, 1)
5831
+ });
5832
+ }
5833
+ return oldEmit.apply(this, arguments)
5834
+ };
5835
+
5836
+ Vue.prototype.$nextTick = function(fn) {
5837
+ return nextTick$1(this, fn)
5838
+ };
5839
+
5840
+ MP_METHODS.forEach(function (method) {
5841
+ Vue.prototype[method] = function(args) {
5842
+ if (this.$scope && this.$scope[method]) {
5843
+ return this.$scope[method](args)
5844
+ }
5845
+ // mp-alipay
5846
+ if (typeof my === 'undefined') {
5847
+ return
5848
+ }
5849
+ if (method === 'createSelectorQuery') {
5850
+ /* eslint-disable no-undef */
5851
+ return my.createSelectorQuery(args)
5852
+ } else if (method === 'createIntersectionObserver') {
5853
+ /* eslint-disable no-undef */
5854
+ return my.createIntersectionObserver(args)
5855
+ }
5856
+ // TODO mp-alipay 暂不支持 selectAllComponents,selectComponent
5857
+ };
5858
+ });
5859
+
5860
+ Vue.prototype.__init_provide = initProvide;
5861
+
5862
+ Vue.prototype.__init_injections = initInjections;
5863
+
5864
+ Vue.prototype.__call_hook = function(hook, args) {
5865
+ var vm = this;
5866
+ // #7573 disable dep collection when invoking lifecycle hooks
5867
+ pushTarget();
5868
+ var handlers = vm.$options[hook];
5869
+ var info = hook + " hook";
5870
+ var ret;
5871
+ if (handlers) {
5872
+ for (var i = 0, j = handlers.length; i < j; i++) {
5873
+ ret = invokeWithErrorHandling(handlers[i], vm, args ? [args] : null, vm, info);
5874
+ }
5875
+ }
5876
+ if (vm._hasHookEvent) {
5877
+ vm.$emit('hook:' + hook, args);
5878
+ }
5879
+ popTarget();
5880
+ return ret
5881
+ };
5882
+
5883
+ Vue.prototype.__set_model = function(target, key, value, modifiers) {
5884
+ if (Array.isArray(modifiers)) {
5885
+ if (modifiers.indexOf('trim') !== -1) {
5886
+ value = value.trim();
5887
+ }
5888
+ if (modifiers.indexOf('number') !== -1) {
5889
+ value = this._n(value);
5890
+ }
5891
+ }
5892
+ if (!target) {
5893
+ target = this;
5894
+ }
5895
+ // 解决动态属性添加
5896
+ Vue.set(target, key, value);
5897
+ };
5898
+
5899
+ Vue.prototype.__set_sync = function(target, key, value) {
5900
+ if (!target) {
5901
+ target = this;
5902
+ }
5903
+ // 解决动态属性添加
5904
+ Vue.set(target, key, value);
5905
+ };
5906
+
5907
+ Vue.prototype.__get_orig = function(item) {
5908
+ if (isPlainObject(item)) {
5909
+ return item['$orig'] || item
5910
+ }
5911
+ return item
5912
+ };
5913
+
5914
+ Vue.prototype.__get_value = function(dataPath, target) {
5915
+ return getTarget(target || this, dataPath)
5916
+ };
5917
+
5918
+
5919
+ Vue.prototype.__get_class = function(dynamicClass, staticClass) {
5920
+ return renderClass(staticClass, dynamicClass)
5921
+ };
5922
+
5923
+ Vue.prototype.__get_style = function(dynamicStyle, staticStyle) {
5924
+ if (!dynamicStyle && !staticStyle) {
5925
+ return ''
5926
+ }
5927
+ var dynamicStyleObj = normalizeStyleBinding(dynamicStyle);
5928
+ var styleObj = staticStyle ? extend(staticStyle, dynamicStyleObj) : dynamicStyleObj;
5929
+ return Object.keys(styleObj).map(function (name) { return ((hyphenate(name)) + ":" + (styleObj[name])); }).join(';')
5930
+ };
5931
+
5932
+ Vue.prototype.__map = function(val, iteratee) {
5933
+ //TODO 暂不考虑 string
5934
+ var ret, i, l, keys, key;
5935
+ if (Array.isArray(val)) {
5936
+ ret = new Array(val.length);
5937
+ for (i = 0, l = val.length; i < l; i++) {
5938
+ ret[i] = iteratee(val[i], i);
5939
+ }
5940
+ return ret
5941
+ } else if (isObject(val)) {
5942
+ keys = Object.keys(val);
5943
+ ret = Object.create(null);
5944
+ for (i = 0, l = keys.length; i < l; i++) {
5945
+ key = keys[i];
5946
+ ret[key] = iteratee(val[key], key, i);
5947
+ }
5948
+ return ret
5949
+ } else if (typeof val === 'number') {
5950
+ ret = new Array(val);
5951
+ for (i = 0, l = val; i < l; i++) {
5952
+ // 第一个参数暂时仍和小程序一致
5953
+ ret[i] = iteratee(i, i);
5954
+ }
5955
+ return ret
5956
+ }
5957
+ return []
5958
+ };
5959
+
5960
+ }
5961
+
5962
+ /* */
5963
+
5964
+ var LIFECYCLE_HOOKS$1 = [
5965
+ //App
5966
+ 'onLaunch',
5967
+ 'onShow',
5968
+ 'onHide',
5969
+ 'onUniNViewMessage',
5970
+ 'onPageNotFound',
5971
+ 'onThemeChange',
5972
+ 'onError',
5973
+ 'onUnhandledRejection',
5974
+ //Page
5975
+ 'onInit',
5976
+ 'onLoad',
5977
+ // 'onShow',
5978
+ 'onReady',
5979
+ // 'onHide',
5980
+ 'onUnload',
5981
+ 'onPullDownRefresh',
5982
+ 'onReachBottom',
5983
+ 'onTabItemTap',
5984
+ 'onAddToFavorites',
5985
+ 'onShareTimeline',
5986
+ 'onShareAppMessage',
5987
+ 'onResize',
5988
+ 'onPageScroll',
5989
+ 'onNavigationBarButtonTap',
5990
+ 'onBackPress',
5991
+ 'onNavigationBarSearchInputChanged',
5992
+ 'onNavigationBarSearchInputConfirmed',
5993
+ 'onNavigationBarSearchInputClicked',
5994
+ //Component
5995
+ // 'onReady', // 兼容旧版本,应该移除该事件
5996
+ 'onPageShow',
5997
+ 'onPageHide',
5998
+ 'onPageResize',
5999
+ 'onUploadDouyinVideo'
6000
+ ];
6001
+ function lifecycleMixin$1(Vue) {
6002
+
6003
+ //fixed vue-class-component
6004
+ var oldExtend = Vue.extend;
6005
+ Vue.extend = function(extendOptions) {
6006
+ extendOptions = extendOptions || {};
6007
+
6008
+ var methods = extendOptions.methods;
6009
+ if (methods) {
6010
+ Object.keys(methods).forEach(function (methodName) {
6011
+ if (LIFECYCLE_HOOKS$1.indexOf(methodName)!==-1) {
6012
+ extendOptions[methodName] = methods[methodName];
6013
+ delete methods[methodName];
6014
+ }
6015
+ });
6016
+ }
6017
+
6018
+ return oldExtend.call(this, extendOptions)
6019
+ };
6020
+
6021
+ var strategies = Vue.config.optionMergeStrategies;
6022
+ var mergeHook = strategies.created;
6023
+ LIFECYCLE_HOOKS$1.forEach(function (hook) {
6024
+ strategies[hook] = mergeHook;
6025
+ });
6026
+
6027
+ Vue.prototype.__lifecycle_hooks__ = LIFECYCLE_HOOKS$1;
6028
+ }
6029
+
6030
+ /* */
6031
+
6032
+ // install platform patch function
6033
+ Vue.prototype.__patch__ = patch;
6034
+
6035
+ // public mount method
6036
+ Vue.prototype.$mount = function(
6037
+ el ,
6038
+ hydrating
6039
+ ) {
6040
+ return mountComponent$1(this, el, hydrating)
6041
+ };
6042
+
6043
+ lifecycleMixin$1(Vue);
6043
6044
  internalMixin(Vue);
6044
6045
 
6045
6046
  /* */
@@ -133,22 +133,6 @@ function initPushNotification() {
133
133
  },
134
134
  });
135
135
  });
136
- plus.push.addEventListener('click', (result) => {
137
- // @ts-expect-error
138
- uni.invokePushCallback({
139
- type: 'click',
140
- message: result,
141
- });
142
- });
143
- uni.onPushMessage((res) => {
144
- if (res.type === 'receive' &&
145
- res.data &&
146
- res.data.force_notification) {
147
- // 创建通知栏
148
- uni.createPushMessage(res.data);
149
- res.stopped = true;
150
- }
151
- });
152
136
  }
153
137
  }
154
138
 
@@ -207,4 +191,16 @@ else {
207
191
  });
208
192
  },
209
193
  });
194
+ // 仅在 jssdk 中监听
195
+ // #ifdef APP
196
+ uni.onPushMessage((res) => {
197
+ if (res.type === 'receive' &&
198
+ res.data &&
199
+ res.data.force_notification) {
200
+ // 创建通知栏
201
+ uni.createPushMessage(res.data);
202
+ res.stopped = true;
203
+ }
204
+ });
205
+ // #endif
210
206
  }
@@ -31,22 +31,6 @@ function initPushNotification() {
31
31
  },
32
32
  });
33
33
  });
34
- plus.push.addEventListener('click', (result) => {
35
- // @ts-expect-error
36
- uni.invokePushCallback({
37
- type: 'click',
38
- message: result,
39
- });
40
- });
41
- uni.onPushMessage((res) => {
42
- if (res.type === 'receive' &&
43
- res.data &&
44
- res.data.force_notification) {
45
- // 创建通知栏
46
- uni.createPushMessage(res.data);
47
- res.stopped = true;
48
- }
49
- });
50
34
  }
51
35
  }
52
36
 
@@ -58,11 +42,4 @@ uni.invokePushCallback({
58
42
  Promise.resolve().then(() => {
59
43
  initPushNotification();
60
44
  plus.push.setAutoNotification && plus.push.setAutoNotification(false);
61
- plus.push.addEventListener('receive', (result) => {
62
- // @ts-expect-error
63
- uni.invokePushCallback({
64
- type: 'pushMsg',
65
- message: result,
66
- });
67
- });
68
45
  });