提交 502cbd00 编写于 作者: fxy060608's avatar fxy060608

wip(push): add newPath event

上级 2f1b877a
......@@ -1792,7 +1792,7 @@ function normalizeCustomEvent(name, domEvt, el, detail) {
};
}
const uniFormKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniForm" : "uf");
var index$A = /* @__PURE__ */ defineBuiltInComponent({
var index$B = /* @__PURE__ */ defineBuiltInComponent({
name: "Form",
emits: ["submit", "reset"],
setup(_props, {
......@@ -1852,7 +1852,7 @@ function useProvideLabel() {
});
return handlers;
}
var index$z = /* @__PURE__ */ defineBuiltInComponent({
var index$A = /* @__PURE__ */ defineBuiltInComponent({
name: "Label",
props: labelProps,
setup(props2, {
......@@ -1980,7 +1980,7 @@ const buttonProps = {
default: false
}
};
var index$y = /* @__PURE__ */ defineBuiltInComponent({
var index$z = /* @__PURE__ */ defineBuiltInComponent({
name: "Button",
props: buttonProps,
setup(props2, {
......@@ -4200,13 +4200,13 @@ const createMediaQueryObserver = /* @__PURE__ */ defineSyncApi("createMediaQuery
}
return new ServiceMediaQueryObserver(getCurrentPageVm());
});
let index$x = 0;
let index$y = 0;
let optionsCache = {};
function operateEditor(componentId, pageId, type, options) {
const data = { options };
const needCallOptions = options && ("success" in options || "fail" in options || "complete" in options);
if (needCallOptions) {
const callbackId = String(index$x++);
const callbackId = String(index$y++);
data.callbackId = callbackId;
optionsCache[callbackId] = options;
}
......@@ -6590,7 +6590,7 @@ const props$x = {
default: true
}
};
var index$w = /* @__PURE__ */ defineBuiltInComponent({
var index$x = /* @__PURE__ */ defineBuiltInComponent({
inheritAttrs: false,
name: "Canvas",
compatConfig: {
......@@ -7057,7 +7057,7 @@ const props$w = {
default: ""
}
};
var index$v = /* @__PURE__ */ defineBuiltInComponent({
var index$w = /* @__PURE__ */ defineBuiltInComponent({
name: "CheckboxGroup",
props: props$w,
emits: ["change"],
......@@ -7133,7 +7133,7 @@ const props$v = {
default: ""
}
};
var index$u = /* @__PURE__ */ defineBuiltInComponent({
var index$v = /* @__PURE__ */ defineBuiltInComponent({
name: "Checkbox",
props: props$v,
setup(props2, {
......@@ -8018,7 +8018,7 @@ const props$t = /* @__PURE__ */ extend({}, props$u, {
default: false
}
});
var index$t = /* @__PURE__ */ defineBuiltInComponent({
var index$u = /* @__PURE__ */ defineBuiltInComponent({
name: "Editor",
props: props$t,
emit: ["ready", "focus", "blur", "input", "statuschange", ...emit$1],
......@@ -8080,7 +8080,7 @@ const ICONS = {
c: GREY_COLOR
}
};
var index$s = /* @__PURE__ */ defineBuiltInComponent({
var index$t = /* @__PURE__ */ defineBuiltInComponent({
name: "Icon",
props: {
type: {
......@@ -8144,7 +8144,7 @@ const IMAGE_MODES = {
"bottom left": ["left bottom"],
"bottom right": ["right bottom"]
};
var index$r = /* @__PURE__ */ defineBuiltInComponent({
var index$s = /* @__PURE__ */ defineBuiltInComponent({
name: "Image",
props: props$s,
setup(props2, {
......@@ -10325,7 +10325,7 @@ function createNavigatorOnClick(props2) {
}
};
}
var index$q = /* @__PURE__ */ defineBuiltInComponent({
var index$r = /* @__PURE__ */ defineBuiltInComponent({
name: "Navigator",
inheritAttrs: false,
compatConfig: {
......@@ -11426,7 +11426,7 @@ const progressProps = {
default: 0
}
};
var index$p = /* @__PURE__ */ defineBuiltInComponent({
var index$q = /* @__PURE__ */ defineBuiltInComponent({
name: "Progress",
props: progressProps,
setup(props2) {
......@@ -11505,7 +11505,7 @@ const props$p = {
default: ""
}
};
var index$o = /* @__PURE__ */ defineBuiltInComponent({
var index$p = /* @__PURE__ */ defineBuiltInComponent({
name: "RadioGroup",
props: props$p,
setup(props2, {
......@@ -11612,7 +11612,7 @@ const props$o = {
default: ""
}
};
var index$n = /* @__PURE__ */ defineBuiltInComponent({
var index$o = /* @__PURE__ */ defineBuiltInComponent({
name: "Radio",
props: props$o,
setup(props2, {
......@@ -11939,7 +11939,7 @@ const props$n = {
}
}
};
var index$m = /* @__PURE__ */ defineBuiltInComponent({
var index$n = /* @__PURE__ */ defineBuiltInComponent({
name: "RichText",
compatConfig: {
MODE: 3
......@@ -12509,7 +12509,7 @@ const props$l = {
default: false
}
};
var index$l = /* @__PURE__ */ defineBuiltInComponent({
var index$m = /* @__PURE__ */ defineBuiltInComponent({
name: "Slider",
props: props$l,
emits: ["changing", "change"],
......@@ -13344,7 +13344,7 @@ const props$i = {
default: "#007aff"
}
};
var index$k = /* @__PURE__ */ defineBuiltInComponent({
var index$l = /* @__PURE__ */ defineBuiltInComponent({
name: "Switch",
props: props$i,
emits: ["change"],
......@@ -13446,7 +13446,7 @@ function normalizeText(text2, { space, decode: decode2 }) {
}
return text2.replace(/&nbsp;/g, SPACE_UNICODE.nbsp).replace(/&ensp;/g, SPACE_UNICODE.ensp).replace(/&emsp;/g, SPACE_UNICODE.emsp).replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'");
}
var index$j = /* @__PURE__ */ defineBuiltInComponent({
var index$k = /* @__PURE__ */ defineBuiltInComponent({
name: "Text",
props: {
selectable: {
......@@ -13522,7 +13522,7 @@ function setFixMargin() {
const DARK_TEST_STRING = "(prefers-color-scheme: dark)";
fixMargin = String(navigator.platform).indexOf("iP") === 0 && String(navigator.vendor).indexOf("Apple") === 0 && window.matchMedia(DARK_TEST_STRING).media !== DARK_TEST_STRING;
}
var index$i = /* @__PURE__ */ defineBuiltInComponent({
var index$j = /* @__PURE__ */ defineBuiltInComponent({
name: "Textarea",
props: props$h,
emits: ["confirm", "linechange", ...emit],
......@@ -13647,7 +13647,7 @@ var index$i = /* @__PURE__ */ defineBuiltInComponent({
};
}
});
var index$h = /* @__PURE__ */ defineBuiltInComponent({
var index$i = /* @__PURE__ */ defineBuiltInComponent({
name: "View",
props: extend({}, hoverProps),
setup(props2, {
......@@ -13711,13 +13711,13 @@ function useOn(name, callback) {
onMounted(() => UniViewJSBridge.on(name, callback));
onBeforeUnmount(() => UniViewJSBridge.off(name));
}
let index$g = 0;
let index$h = 0;
function useContextInfo(_id) {
const page = useCurrentPageId();
const instance2 = getCurrentInstance();
const vm = instance2.proxy;
const type = vm.$options.name.toLowerCase();
const id2 = _id || vm.id || `context${index$g++}`;
const id2 = _id || vm.id || `context${index$h++}`;
onMounted(() => {
const el = vm.$el;
el.__uniContextInfo = {
......@@ -14248,7 +14248,7 @@ function initHistory() {
});
return history2;
}
var index$f = {
var index$g = {
install(app) {
initApp$1(app);
initViewPlugin(app);
......@@ -15084,7 +15084,7 @@ const props$g = {
default: true
}
};
var index$e = /* @__PURE__ */ defineBuiltInComponent({
var index$f = /* @__PURE__ */ defineBuiltInComponent({
name: "Video",
props: props$g,
emits: ["fullscreenchange", "progress", "loadedmetadata", "waiting", "error", "play", "pause", "ended", "timeupdate"],
......@@ -15317,7 +15317,7 @@ const props$f = {
default: true
}
};
var index$d = /* @__PURE__ */ defineBuiltInComponent({
var index$e = /* @__PURE__ */ defineBuiltInComponent({
inheritAttrs: false,
name: "WebView",
props: props$f,
......@@ -17594,13 +17594,13 @@ const chooseImage = /* @__PURE__ */ defineAsyncApi(API_CHOOSE_IMAGE, ({
console.warn(t2("uni.chooseFile.notUserActivation"));
}
}, ChooseImageProtocol, ChooseImageOptions);
let index$c = 0;
let index$d = 0;
let overflow = "";
function preventScroll(prevent) {
let before = index$c;
index$c += prevent ? 1 : -1;
index$c = Math.max(0, index$c);
if (index$c > 0) {
let before = index$d;
index$d += prevent ? 1 : -1;
index$d = Math.max(0, index$d);
if (index$d > 0) {
if (before === 0) {
overflow = document.body.style.overflow;
document.body.style.overflow = "hidden";
......@@ -18366,10 +18366,11 @@ const onSocketOpen = /* @__PURE__ */ on("open");
const onSocketError = /* @__PURE__ */ on("error");
const onSocketMessage = /* @__PURE__ */ on("message");
const onSocketClose = /* @__PURE__ */ on("close");
let index$c = 0;
function getJSONP(url, options, success, error) {
var js = document.createElement("script");
var callbackKey = options.callback || "callback";
var callbackName = "__callback" + Date.now();
var callbackName = "__uni_jsonp_callback_" + index$c++;
var timeout = options.timeout || 3e4;
var timing;
function end() {
......@@ -22839,4 +22840,4 @@ var index = /* @__PURE__ */ defineSystemComponent({
return openBlock(), createBlock("div", clazz, [loadingVNode]);
}
});
export { $emit, $off, $on, $once, index$8 as Ad, index$7 as AdContentPage, index$6 as AdDraw, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, index$y as Button, index$5 as Camera, index$w as Canvas, index$u as Checkbox, index$v as CheckboxGroup, index$a as CoverImage, index$b as CoverView, index$t as Editor, index$A as Form, index$s as Icon, index$r as Image, Input, index$z as Label, LayoutComponent, index$4 as LivePlayer, index$3 as LivePusher, Map$1 as Map, MovableArea, MovableView, index$q as Navigator, index$2 as PageComponent, index$9 as Picker, PickerView, PickerViewColumn, index$p as Progress, index$n as Radio, index$o as RadioGroup, ResizeSensor, index$m as RichText, ScrollView, index$l as Slider, Swiper, SwiperItem, index$k as Switch, index$j as Text, index$i as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$e as Video, index$h as View, index$d as WebView, addInterceptor, addPhoneContact, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closePreviewImage, closeSocket, connectSocket, createAnimation$1 as createAnimation, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createLivePlayerContext, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, downloadFile, getApp$1 as getApp, getAppBaseInfo, getClipboardData, getCurrentPages$1 as getCurrentPages, getDeviceInfo, getEnterOptionsSync, getFileInfo, getImageInfo, getLaunchOptionsSync, getLeftWindowStyle, getLocale, getLocation, getNetworkType, getProvider, getPushClientId, getRealPath, getRecorderManager, getRightWindowStyle, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange$1 as getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, getWindowInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, interceptors, invokePushCallback, loadFontFace, login, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offAppHide, offAppShow, offCompassChange, offError, offNetworkStatusChange, offPageNotFound, offPushMessage, offUnhandledRejection, offWindowResize, onAccelerometerChange, onAppHide, onAppShow, onCompassChange, onError, onGyroscopeChange, onLocaleChange, onMemoryWarning, onNetworkStatusChange, onPageNotFound, onPushMessage, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUnhandledRejection, onUserCaptureScreen, onWindowResize, openDocument, openLocation, pageScrollTo, index$f as plugin, preloadPage, previewImage, reLaunch, redirectTo, removeInterceptor, removeSavedFileInfo, removeStorage, removeStorageSync, removeTabBarBadge, request, saveFile, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, sendSocketMessage, setClipboardData, setKeepScreenOn, setLeftWindowStyle, setLocale, setNavigationBarColor, setNavigationBarTitle, setPageMeta, setRightWindowStyle, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, setupWindow, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startGyroscope, startPullDownRefresh, stopAccelerometer, stopCompass, stopGyroscope, stopPullDownRefresh, switchTab, uni$1 as uni, uploadFile, upx2px, useI18n, useTabBar, vibrateLong, vibrateShort };
export { $emit, $off, $on, $once, index$8 as Ad, index$7 as AdContentPage, index$6 as AdDraw, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, index$z as Button, index$5 as Camera, index$x as Canvas, index$v as Checkbox, index$w as CheckboxGroup, index$a as CoverImage, index$b as CoverView, index$u as Editor, index$B as Form, index$t as Icon, index$s as Image, Input, index$A as Label, LayoutComponent, index$4 as LivePlayer, index$3 as LivePusher, Map$1 as Map, MovableArea, MovableView, index$r as Navigator, index$2 as PageComponent, index$9 as Picker, PickerView, PickerViewColumn, index$q as Progress, index$o as Radio, index$p as RadioGroup, ResizeSensor, index$n as RichText, ScrollView, index$m as Slider, Swiper, SwiperItem, index$l as Switch, index$k as Text, index$j as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$f as Video, index$i as View, index$e as WebView, addInterceptor, addPhoneContact, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closePreviewImage, closeSocket, connectSocket, createAnimation$1 as createAnimation, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createLivePlayerContext, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, downloadFile, getApp$1 as getApp, getAppBaseInfo, getClipboardData, getCurrentPages$1 as getCurrentPages, getDeviceInfo, getEnterOptionsSync, getFileInfo, getImageInfo, getLaunchOptionsSync, getLeftWindowStyle, getLocale, getLocation, getNetworkType, getProvider, getPushClientId, getRealPath, getRecorderManager, getRightWindowStyle, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange$1 as getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, getWindowInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, interceptors, invokePushCallback, loadFontFace, login, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offAppHide, offAppShow, offCompassChange, offError, offNetworkStatusChange, offPageNotFound, offPushMessage, offUnhandledRejection, offWindowResize, onAccelerometerChange, onAppHide, onAppShow, onCompassChange, onError, onGyroscopeChange, onLocaleChange, onMemoryWarning, onNetworkStatusChange, onPageNotFound, onPushMessage, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUnhandledRejection, onUserCaptureScreen, onWindowResize, openDocument, openLocation, pageScrollTo, index$g as plugin, preloadPage, previewImage, reLaunch, redirectTo, removeInterceptor, removeSavedFileInfo, removeStorage, removeStorageSync, removeTabBarBadge, request, saveFile, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, sendSocketMessage, setClipboardData, setKeepScreenOn, setLeftWindowStyle, setLocale, setNavigationBarColor, setNavigationBarTitle, setPageMeta, setRightWindowStyle, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, setupWindow, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startGyroscope, startPullDownRefresh, stopAccelerometer, stopCompass, stopGyroscope, stopPullDownRefresh, switchTab, uni$1 as uni, uploadFile, upx2px, useI18n, useTabBar, vibrateLong, vibrateShort };
......@@ -103,6 +103,36 @@ var GtPush = /*@__PURE__*/getDefaultExportFromCjs(gtpushMin);
function initPushNotification() {
// 仅 App 端
if (typeof plus !== 'undefined' && plus.push) {
plus.globalEvent.addEventListener('newPath', ({ path }) => {
if (!path) {
return;
}
// 指定的页面为当前页面
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
if (currentPage &&
currentPage.$page &&
currentPage.$page.fullPath === path) {
return;
}
// 简单起见,先尝试 navigateTo 跳转,失败后,再尝试 tabBar 跳转
uni.navigateTo({
url: path,
fail(res) {
if (res.errMsg.indexOf('tabbar') > -1) {
uni.switchTab({
url: path,
fail(res) {
console.error(res.errMsg);
},
});
}
else {
console.error(res.errMsg);
}
},
});
});
plus.push.addEventListener('click', (result) => {
// @ts-expect-error
uni.invokePushCallback({
......@@ -141,7 +171,9 @@ if (!appid) {
});
}
else {
// #ifdef APP
initPushNotification();
// #endif
GtPush.init({
appid,
onError: (res) => {
......
function initPushNotification() {
// 仅 App 端
if (typeof plus !== 'undefined' && plus.push) {
plus.globalEvent.addEventListener('newPath', ({ path }) => {
if (!path) {
return;
}
// 指定的页面为当前页面
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
if (currentPage &&
currentPage.$page &&
currentPage.$page.fullPath === path) {
return;
}
// 简单起见,先尝试 navigateTo 跳转,失败后,再尝试 tabBar 跳转
uni.navigateTo({
url: path,
fail(res) {
if (res.errMsg.indexOf('tabbar') > -1) {
uni.switchTab({
url: path,
fail(res) {
console.error(res.errMsg);
},
});
}
else {
console.error(res.errMsg);
}
},
});
});
plus.push.addEventListener('click', (result) => {
// @ts-expect-error
uni.invokePushCallback({
type: 'click',
message: result,
});
});
uni.onPushMessage((res) => {
if (res.type === 'receive' &&
res.data &&
res.data.force_notification) {
// 创建通知栏
uni.createPushMessage(res.data);
res.stopped = true;
}
});
}
}
// @ts-expect-error
uni.invokePushCallback({
type: 'enabled',
offline: true,
});
Promise.resolve().then(() => {
initPushNotification();
plus.push.setAutoNotification && plus.push.setAutoNotification(false);
plus.push.addEventListener('click', (result) => {
// @ts-expect-error
uni.invokePushCallback({
type: 'click',
message: result,
});
});
plus.push.addEventListener('receive', (result) => {
// @ts-expect-error
uni.invokePushCallback({
......
......@@ -21,7 +21,9 @@ if (!appid) {
})
})
} else {
// #ifdef APP
initPushNotification()
// #endif
GtPush.init({
appid,
onError: (res) => {
......
import { initPushNotification } from './route'
// @ts-expect-error
uni.invokePushCallback({
type: 'enabled',
offline: true,
})
Promise.resolve().then(() => {
initPushNotification()
plus.push.setAutoNotification && plus.push.setAutoNotification(false)
plus.push.addEventListener('click', (result) => {
// @ts-expect-error
uni.invokePushCallback({
type: 'click',
message: result,
})
})
plus.push.addEventListener('receive', (result) => {
// @ts-expect-error
uni.invokePushCallback({
......
export function initPushNotification() {
// 仅 App 端
if (typeof plus !== 'undefined' && plus.push) {
;(plus as any).globalEvent.addEventListener(
'newPath',
({ path }: { path: string }) => {
if (!path) {
return
}
// 指定的页面为当前页面
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
if (
currentPage &&
(currentPage as any).$page &&
(currentPage as any).$page.fullPath === path
) {
return
}
// 简单起见,先尝试 navigateTo 跳转,失败后,再尝试 tabBar 跳转
uni.navigateTo({
url: path,
fail(res) {
if (res.errMsg.indexOf('tabbar') > -1) {
uni.switchTab({
url: path,
fail(res) {
console.error(res.errMsg)
},
})
} else {
console.error(res.errMsg)
}
},
})
}
)
plus.push.addEventListener('click', (result) => {
// @ts-expect-error
uni.invokePushCallback({
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册