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

add route

上级 19a0fe58
...@@ -1816,7 +1816,7 @@ function invokeCallbackHandler (invokeCallbackId, res) { ...@@ -1816,7 +1816,7 @@ function invokeCallbackHandler (invokeCallbackId, res) {
} }
function wrapperUnimplemented (name) { function wrapperUnimplemented (name) {
return function unimplemented (args) { return function todo (args) {
console.error('API `' + name + '` is not yet implemented'); console.error('API `' + name + '` is not yet implemented');
} }
} }
...@@ -6806,12 +6806,98 @@ function createVideoContext$1 (id, vm) { ...@@ -6806,12 +6806,98 @@ function createVideoContext$1 (id, vm) {
return new VideoContext(id, elm) return new VideoContext(id, elm)
} }
const ANI_DURATION$1 = 300;
const ANI_SHOW$1 = 'pop-in';
function showWebview (webview, animationType, animationDuration) {
setTimeout(() => {
webview.show(
animationType || ANI_SHOW$1,
animationDuration || ANI_DURATION$1,
() => {
console.log('show.callback');
}
);
}, 50);
}
let firstBackTime = 0;
function navigateBack$1 ({
delta,
animationType,
animationDuration
}) {
const pages = getCurrentPages();
const len = pages.length - 1;
const page = pages[len];
if (page.$page.meta.isQuit) {
if (!firstBackTime) {
firstBackTime = Date.now();
plus.nativeUI.toast('再按一次退出应用');
setTimeout(() => {
firstBackTime = null;
}, 2000);
} else if (Date.now() - firstBackTime < 2000) {
plus.runtime.quit();
}
} else {
pages.splice(len, 1);
if (animationType) {
page.$getAppWebview().close(animationType, animationDuration || ANI_DURATION$1);
} else {
page.$getAppWebview().close('auto');
}
UniServiceJSBridge.emit('onAppRoute', {
type: 'navigateBack'
});
}
}
function navigateTo$1 ({
url,
animationType,
animationDuration
}) {
const path = url.split('?')[0];
UniServiceJSBridge.emit('onAppRoute', {
type: 'navigateTo',
path
});
showWebview(
__registerPage({
path
}),
animationType,
animationDuration
);
}
function reLaunch$1 ({
path
}) {}
function redirectTo$1 ({
path
}) {}
function switchTab$1 ({
path
}) {}
var nvueApi = /*#__PURE__*/Object.freeze({ var nvueApi = /*#__PURE__*/Object.freeze({
createLivePusherContext: createLivePusherContext, createLivePusherContext: createLivePusherContext,
createMapContext: createMapContext$1, createMapContext: createMapContext$1,
createVideoContext: createVideoContext$1 createVideoContext: createVideoContext$1,
navigateBack: navigateBack$1,
navigateTo: navigateTo$1,
reLaunch: reLaunch$1,
redirectTo: redirectTo$1,
switchTab: switchTab$1
}); });
var platformApi = Object.assign({}, appApi, nvueApi); var platformApi = Object.assign({}, appApi, nvueApi);
......
...@@ -234,7 +234,7 @@ export function invokeCallbackHandler (invokeCallbackId, res) { ...@@ -234,7 +234,7 @@ export function invokeCallbackHandler (invokeCallbackId, res) {
} }
export function wrapperUnimplemented (name) { export function wrapperUnimplemented (name) {
return function unimplemented (args) { return function todo (args) {
console.error('API `' + name + '` is not yet implemented') console.error('API `' + name + '` is not yet implemented')
} }
} }
......
export * from './context/live-pusher' export * from './context/live-pusher'
export * from './context/map' export * from './context/map'
export * from './context/video' export * from './context/video'
export * from './route/navigate-back'
export * from './route/navigate-to'
export * from './route/re-launch'
export * from './route/redirect-to'
export * from './route/switch-tab'
import {
ANI_DURATION
} from './util'
let firstBackTime = 0
export function navigateBack ({
delta,
animationType,
animationDuration
}) {
const pages = getCurrentPages()
const len = pages.length - 1
const page = pages[len]
if (page.$page.meta.isQuit) {
if (!firstBackTime) {
firstBackTime = Date.now()
plus.nativeUI.toast('再按一次退出应用')
setTimeout(() => {
firstBackTime = null
}, 2000)
} else if (Date.now() - firstBackTime < 2000) {
plus.runtime.quit()
}
} else {
pages.splice(len, 1)
if (animationType) {
page.$getAppWebview().close(animationType, animationDuration || ANI_DURATION)
} else {
page.$getAppWebview().close('auto')
}
UniServiceJSBridge.emit('onAppRoute', {
type: 'navigateBack'
})
}
}
import {
showWebview
} from './util'
export function navigateTo ({
url,
animationType,
animationDuration
}) {
const path = url.split('?')[0]
UniServiceJSBridge.emit('onAppRoute', {
type: 'navigateTo',
path
})
showWebview(
__registerPage({
path
}),
animationType,
animationDuration
)
}
export const ANI_DURATION = 300
const ANI_SHOW = 'pop-in'
export function showWebview (webview, animationType, animationDuration) {
setTimeout(() => {
webview.show(
animationType || ANI_SHOW,
animationDuration || ANI_DURATION,
() => {
console.log('show.callback')
}
)
}, 50)
}
...@@ -15,8 +15,8 @@ import { ...@@ -15,8 +15,8 @@ import {
registerPlusMessage registerPlusMessage
} from '../../framework/plus-message' } from '../../framework/plus-message'
const SCAN_ID = '__UNIAPP_SCAN' export const SCAN_ID = '__UNIAPP_SCAN'
const SCAN_PATH = '_www/__uniappscan.html' export const SCAN_PATH = '_www/__uniappscan.html'
const MESSAGE_TYPE = 'scanCode' const MESSAGE_TYPE = 'scanCode'
......
...@@ -7,7 +7,15 @@ let waitingTimeout ...@@ -7,7 +7,15 @@ let waitingTimeout
let toast = false let toast = false
let toastTimeout let toastTimeout
export function showToast ({ export function showLoading(args) {
return showToast(args).replace('showToast', 'showLoading')
}
export function hideLoading() {
return hideToast().replace('hideToast', 'hideLoading')
}
export function showToast({
title = '', title = '',
icon = 'success', icon = 'success',
image = '', image = '',
...@@ -96,7 +104,7 @@ export function showToast ({ ...@@ -96,7 +104,7 @@ export function showToast ({
} }
} }
export function hideToast () { export function hideToast() {
if (toast) { if (toast) {
toastTimeout && clearTimeout(toastTimeout) toastTimeout && clearTimeout(toastTimeout)
plus.nativeUI.closeToast() plus.nativeUI.closeToast()
...@@ -112,7 +120,7 @@ export function hideToast () { ...@@ -112,7 +120,7 @@ export function hideToast () {
errMsg: 'hideToast:ok' errMsg: 'hideToast:ok'
} }
} }
export function showModal ({ export function showModal({
title = '', title = '',
content = '', content = '',
showCancel = true, showCancel = true,
...@@ -137,7 +145,7 @@ export function showModal ({ ...@@ -137,7 +145,7 @@ export function showModal ({
} }
}, title, showCancel ? [cancelText, confirmText] : [confirmText]) }, title, showCancel ? [cancelText, confirmText] : [confirmText])
} }
export function showActionSheet ({ export function showActionSheet({
itemList = [], itemList = [],
itemColor = '#000000', itemColor = '#000000',
title = '' title = ''
...@@ -167,4 +175,4 @@ export function showActionSheet ({ ...@@ -167,4 +175,4 @@ export function showActionSheet ({
}) })
} }
}) })
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册