@dcloudio/uni-app-plus 3.0.0-alpha-3030820220114006 → 3.0.0-alpha-3030820220114008

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.
@@ -11521,6 +11521,72 @@ var serviceContext = (function (vue) {
11521
11521
  return getLaunchOptions();
11522
11522
  });
11523
11523
 
11524
+ let cid = '';
11525
+ /**
11526
+ * @private
11527
+ * @param args
11528
+ */
11529
+ function invokePushCallback(args) {
11530
+ if (args.type === 'clientId') {
11531
+ cid = args.cid;
11532
+ invokeGetPushCidCallbacks(cid);
11533
+ }
11534
+ else if (args.type === 'pushMsg') {
11535
+ onPushMessageCallbacks.forEach((callback) => {
11536
+ callback({ data: args.message });
11537
+ });
11538
+ }
11539
+ }
11540
+ const getPushCidCallbacks = [];
11541
+ function invokeGetPushCidCallbacks(cid) {
11542
+ getPushCidCallbacks.forEach((callback) => {
11543
+ callback(cid);
11544
+ });
11545
+ getPushCidCallbacks.length = 0;
11546
+ }
11547
+ function getPushCid(args) {
11548
+ if (!isPlainObject(args)) {
11549
+ args = {};
11550
+ }
11551
+ const { success, fail, complete } = getApiCallbacks(args);
11552
+ const hasSuccess = isFunction(success);
11553
+ const hasFail = isFunction(fail);
11554
+ const hasComplete = isFunction(complete);
11555
+ getPushCidCallbacks.push((cid) => {
11556
+ let res;
11557
+ if (cid) {
11558
+ res = { errMsg: 'getPushCid:ok', cid };
11559
+ hasSuccess && success(res);
11560
+ }
11561
+ else {
11562
+ res = { errMsg: 'getPushCid:fail' };
11563
+ hasFail && fail(res);
11564
+ }
11565
+ hasComplete && complete(res);
11566
+ });
11567
+ if (cid) {
11568
+ Promise.resolve().then(() => invokeGetPushCidCallbacks(cid));
11569
+ }
11570
+ }
11571
+ const onPushMessageCallbacks = [];
11572
+ // 不使用 defineOnApi 实现,是因为 defineOnApi 依赖 UniServiceJSBridge ,该对象目前在小程序上未提供,故简单实现
11573
+ const onPushMessage = (fn) => {
11574
+ if (onPushMessageCallbacks.indexOf(fn) === -1) {
11575
+ onPushMessageCallbacks.push(fn);
11576
+ }
11577
+ };
11578
+ const offPushMessage = (fn) => {
11579
+ if (!fn) {
11580
+ onPushMessageCallbacks.length = 0;
11581
+ }
11582
+ else {
11583
+ const index = onPushMessageCallbacks.indexOf(fn);
11584
+ if (index > -1) {
11585
+ onPushMessageCallbacks.splice(index, 1);
11586
+ }
11587
+ }
11588
+ };
11589
+
11524
11590
  const API_GET_BACKGROUND_AUDIO_MANAGER = 'getBackgroundAudioManager';
11525
11591
 
11526
11592
  const API_MAKE_PHONE_CALL = 'makePhoneCall';
@@ -16612,6 +16678,67 @@ var serviceContext = (function (vue) {
16612
16678
  return new SubNvue(id, isSub);
16613
16679
  };
16614
16680
 
16681
+ let lastStatusBarStyle;
16682
+ let oldSetStatusBarStyle = plus.navigator.setStatusBarStyle;
16683
+ function restoreOldSetStatusBarStyle(setStatusBarStyle) {
16684
+ oldSetStatusBarStyle = setStatusBarStyle;
16685
+ }
16686
+ function newSetStatusBarStyle(style) {
16687
+ lastStatusBarStyle = style;
16688
+ oldSetStatusBarStyle(style);
16689
+ }
16690
+ plus.navigator.setStatusBarStyle = newSetStatusBarStyle;
16691
+ function setStatusBarStyle(statusBarStyle) {
16692
+ if (!statusBarStyle) {
16693
+ const page = getCurrentPage();
16694
+ if (!page) {
16695
+ return;
16696
+ }
16697
+ statusBarStyle = page.$page.statusBarStyle;
16698
+ if (!statusBarStyle || statusBarStyle === lastStatusBarStyle) {
16699
+ return;
16700
+ }
16701
+ }
16702
+ if (statusBarStyle === lastStatusBarStyle) {
16703
+ return;
16704
+ }
16705
+ if ((process.env.NODE_ENV !== 'production')) {
16706
+ console.log(formatLog('setStatusBarStyle', statusBarStyle));
16707
+ }
16708
+ lastStatusBarStyle = statusBarStyle;
16709
+ plus.navigator.setStatusBarStyle(statusBarStyle);
16710
+ }
16711
+
16712
+ function restoreGlobal(newVue, newWeex, newPlus, newSetTimeout, newClearTimeout, newSetInterval, newClearInterval) {
16713
+ // 确保部分全局变量 是 app-service 中的
16714
+ // 若首页 nvue 初始化比 app-service 快,导致框架处于该 nvue 环境下
16715
+ // plus 如果不用 app-service,资源路径会出问题
16716
+ // 若首页 nvue 被销毁,如 redirectTo 或 reLaunch,则这些全局功能会损坏
16717
+ // 设置 vue3
16718
+ // @ts-ignore 最终vue会被替换为vue
16719
+ vue = newVue;
16720
+ if (plus !== newPlus) {
16721
+ if ((process.env.NODE_ENV !== 'production')) {
16722
+ console.log(`[restoreGlobal][${Date.now()}]`);
16723
+ }
16724
+ weex = newWeex;
16725
+ // @ts-ignore
16726
+ plus = newPlus;
16727
+ restoreOldSetStatusBarStyle(plus.navigator.setStatusBarStyle);
16728
+ plus.navigator.setStatusBarStyle = newSetStatusBarStyle;
16729
+ /* eslint-disable no-global-assign */
16730
+ // @ts-ignore
16731
+ setTimeout = newSetTimeout;
16732
+ // @ts-ignore
16733
+ clearTimeout = newClearTimeout;
16734
+ // @ts-ignore
16735
+ setInterval = newSetInterval;
16736
+ // @ts-ignore
16737
+ clearInterval = newClearInterval;
16738
+ }
16739
+ __uniConfig.serviceReady = true;
16740
+ }
16741
+
16615
16742
  const providers = {
16616
16743
  oauth(callback) {
16617
16744
  plus.oauth.getServices((services) => {
@@ -17935,37 +18062,6 @@ var serviceContext = (function (vue) {
17935
18062
  });
17936
18063
  }
17937
18064
 
17938
- let lastStatusBarStyle;
17939
- let oldSetStatusBarStyle = plus.navigator.setStatusBarStyle;
17940
- function restoreOldSetStatusBarStyle(setStatusBarStyle) {
17941
- oldSetStatusBarStyle = setStatusBarStyle;
17942
- }
17943
- function newSetStatusBarStyle(style) {
17944
- lastStatusBarStyle = style;
17945
- oldSetStatusBarStyle(style);
17946
- }
17947
- plus.navigator.setStatusBarStyle = newSetStatusBarStyle;
17948
- function setStatusBarStyle(statusBarStyle) {
17949
- if (!statusBarStyle) {
17950
- const page = getCurrentPage();
17951
- if (!page) {
17952
- return;
17953
- }
17954
- statusBarStyle = page.$page.statusBarStyle;
17955
- if (!statusBarStyle || statusBarStyle === lastStatusBarStyle) {
17956
- return;
17957
- }
17958
- }
17959
- if (statusBarStyle === lastStatusBarStyle) {
17960
- return;
17961
- }
17962
- if ((process.env.NODE_ENV !== 'production')) {
17963
- console.log(formatLog('setStatusBarStyle', statusBarStyle));
17964
- }
17965
- lastStatusBarStyle = statusBarStyle;
17966
- plus.navigator.setStatusBarStyle(statusBarStyle);
17967
- }
17968
-
17969
18065
  function onWebviewPopGesture(webview) {
17970
18066
  let popStartStatusBarStyle;
17971
18067
  webview.addEventListener('popGesture', (e) => {
@@ -19226,36 +19322,6 @@ var serviceContext = (function (vue) {
19226
19322
  };
19227
19323
  }
19228
19324
 
19229
- function restoreGlobal(newVue, newWeex, newPlus, newSetTimeout, newClearTimeout, newSetInterval, newClearInterval) {
19230
- // 确保部分全局变量 是 app-service 中的
19231
- // 若首页 nvue 初始化比 app-service 快,导致框架处于该 nvue 环境下
19232
- // plus 如果不用 app-service,资源路径会出问题
19233
- // 若首页 nvue 被销毁,如 redirectTo 或 reLaunch,则这些全局功能会损坏
19234
- // 设置 vue3
19235
- // @ts-ignore 最终vue会被替换为vue
19236
- vue = newVue;
19237
- if (plus !== newPlus) {
19238
- if ((process.env.NODE_ENV !== 'production')) {
19239
- console.log(`[restoreGlobal][${Date.now()}]`);
19240
- }
19241
- weex = newWeex;
19242
- // @ts-ignore
19243
- plus = newPlus;
19244
- restoreOldSetStatusBarStyle(plus.navigator.setStatusBarStyle);
19245
- plus.navigator.setStatusBarStyle = newSetStatusBarStyle;
19246
- /* eslint-disable no-global-assign */
19247
- // @ts-ignore
19248
- setTimeout = newSetTimeout;
19249
- // @ts-ignore
19250
- clearTimeout = newClearTimeout;
19251
- // @ts-ignore
19252
- setInterval = newSetInterval;
19253
- // @ts-ignore
19254
- clearInterval = newClearInterval;
19255
- }
19256
- __uniConfig.serviceReady = true;
19257
- }
19258
-
19259
19325
  const EventType = {
19260
19326
  load: 'load',
19261
19327
  close: 'close',
@@ -19889,6 +19955,10 @@ var serviceContext = (function (vue) {
19889
19955
  setPageMeta: setPageMeta,
19890
19956
  getEnterOptionsSync: getEnterOptionsSync,
19891
19957
  getLaunchOptionsSync: getLaunchOptionsSync,
19958
+ getPushCid: getPushCid,
19959
+ onPushMessage: onPushMessage,
19960
+ offPushMessage: offPushMessage,
19961
+ invokePushCallback: invokePushCallback,
19892
19962
  setStorageSync: setStorageSync,
19893
19963
  setStorage: setStorage,
19894
19964
  getStorageSync: getStorageSync,
@@ -20009,6 +20079,7 @@ var serviceContext = (function (vue) {
20009
20079
  removeTabBarBadge: removeTabBarBadge,
20010
20080
  hideTabBarRedDot: hideTabBarRedDot,
20011
20081
  getSubNVueById: getSubNVueById,
20082
+ restoreGlobal: restoreGlobal,
20012
20083
  getProvider: getProvider,
20013
20084
  login: login,
20014
20085
  getUserInfo: getUserInfo,
@@ -20024,7 +20095,6 @@ var serviceContext = (function (vue) {
20024
20095
  requireNativePlugin: requireNativePlugin,
20025
20096
  sendNativeEvent: sendNativeEvent,
20026
20097
  __vuePlugin: index$1,
20027
- restoreGlobal: restoreGlobal,
20028
20098
  createRewardedVideoAd: createRewardedVideoAd,
20029
20099
  createFullScreenVideoAd: createFullScreenVideoAd,
20030
20100
  createInterstitialAd: createInterstitialAd,