提交 e5637911 编写于 作者: D DCloud_LXH

feat(App): chooseLocation、openLocation

上级 117d73a2
...@@ -9,79 +9,79 @@ const __uniRoutes = instanceContext.__uniRoutes; ...@@ -9,79 +9,79 @@ const __uniRoutes = instanceContext.__uniRoutes;
var serviceContext = (function (vue) { var serviceContext = (function (vue) {
'use strict'; 'use strict';
/* /*
* base64-arraybuffer * base64-arraybuffer
* https://github.com/niklasvh/base64-arraybuffer * https://github.com/niklasvh/base64-arraybuffer
* *
* Copyright (c) 2012 Niklas von Hertzen * Copyright (c) 2012 Niklas von Hertzen
* Licensed under the MIT license. * Licensed under the MIT license.
*/ */
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// Use a lookup table to find the index. // Use a lookup table to find the index.
var lookup = /*#__PURE__*/ (function () { var lookup = /*#__PURE__*/ (function () {
const lookup = new Uint8Array(256); const lookup = new Uint8Array(256);
for (var i = 0; i < chars.length; i++) { for (var i = 0; i < chars.length; i++) {
lookup[chars.charCodeAt(i)] = i; lookup[chars.charCodeAt(i)] = i;
} }
return lookup return lookup
})(); })();
function encode$3(arraybuffer) { function encode$3(arraybuffer) {
var bytes = new Uint8Array(arraybuffer), var bytes = new Uint8Array(arraybuffer),
i, i,
len = bytes.length, len = bytes.length,
base64 = ''; base64 = '';
for (i = 0; i < len; i += 3) { for (i = 0; i < len; i += 3) {
base64 += chars[bytes[i] >> 2]; base64 += chars[bytes[i] >> 2];
base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)]; base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)]; base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
base64 += chars[bytes[i + 2] & 63]; base64 += chars[bytes[i + 2] & 63];
} }
if (len % 3 === 2) { if (len % 3 === 2) {
base64 = base64.substring(0, base64.length - 1) + '='; base64 = base64.substring(0, base64.length - 1) + '=';
} else if (len % 3 === 1) { } else if (len % 3 === 1) {
base64 = base64.substring(0, base64.length - 2) + '=='; base64 = base64.substring(0, base64.length - 2) + '==';
} }
return base64 return base64
} }
function decode$1(base64) { function decode$1(base64) {
var bufferLength = base64.length * 0.75, var bufferLength = base64.length * 0.75,
len = base64.length, len = base64.length,
i, i,
p = 0, p = 0,
encoded1, encoded1,
encoded2, encoded2,
encoded3, encoded3,
encoded4; encoded4;
if (base64[base64.length - 1] === '=') { if (base64[base64.length - 1] === '=') {
bufferLength--; bufferLength--;
if (base64[base64.length - 2] === '=') { if (base64[base64.length - 2] === '=') {
bufferLength--; bufferLength--;
} }
} }
var arraybuffer = new ArrayBuffer(bufferLength), var arraybuffer = new ArrayBuffer(bufferLength),
bytes = new Uint8Array(arraybuffer); bytes = new Uint8Array(arraybuffer);
for (i = 0; i < len; i += 4) { for (i = 0; i < len; i += 4) {
encoded1 = lookup[base64.charCodeAt(i)]; encoded1 = lookup[base64.charCodeAt(i)];
encoded2 = lookup[base64.charCodeAt(i + 1)]; encoded2 = lookup[base64.charCodeAt(i + 1)];
encoded3 = lookup[base64.charCodeAt(i + 2)]; encoded3 = lookup[base64.charCodeAt(i + 2)];
encoded4 = lookup[base64.charCodeAt(i + 3)]; encoded4 = lookup[base64.charCodeAt(i + 3)];
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4); bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2); bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63); bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
} }
return arraybuffer return arraybuffer
} }
/** /**
...@@ -1747,15 +1747,15 @@ var serviceContext = (function (vue) { ...@@ -1747,15 +1747,15 @@ var serviceContext = (function (vue) {
} }
} }
const callbacks$2 = {}; const callbacks$3 = {};
function createCallbacks(namespace) { function createCallbacks(namespace) {
let scopedCallbacks = callbacks$2[namespace]; let scopedCallbacks = callbacks$3[namespace];
if (!scopedCallbacks) { if (!scopedCallbacks) {
scopedCallbacks = { scopedCallbacks = {
id: 1, id: 1,
callbacks: Object.create(null), callbacks: Object.create(null),
}; };
callbacks$2[namespace] = scopedCallbacks; callbacks$3[namespace] = scopedCallbacks;
} }
return { return {
get(id) { get(id) {
...@@ -4016,6 +4016,13 @@ var serviceContext = (function (vue) { ...@@ -4016,6 +4016,13 @@ var serviceContext = (function (vue) {
const API_HIDE_KEYBOARD = 'hideKeyboard'; const API_HIDE_KEYBOARD = 'hideKeyboard';
const API_SHOW_KEYBOARD = 'showKeyboard'; const API_SHOW_KEYBOARD = 'showKeyboard';
const API_CHOOSE_LOCATION = 'chooseLocation';
const ChooseLocationProtocol = {
keyword: String,
latitude: Number,
longitude: Number,
};
const API_GET_LOCATION = 'getLocation'; const API_GET_LOCATION = 'getLocation';
const coordTypes = ['WGS84', 'GCJ02']; const coordTypes = ['WGS84', 'GCJ02'];
const GetLocationOptions = { const GetLocationOptions = {
...@@ -4039,6 +4046,29 @@ var serviceContext = (function (vue) { ...@@ -4039,6 +4046,29 @@ var serviceContext = (function (vue) {
altitude: Boolean, altitude: Boolean,
}; };
const API_OPEN_LOCATION = 'openLocation';
const OpenLocationOptions = {
formatArgs: {
scale(value, params) {
value = Math.floor(value);
params.scale = value >= 5 && value <= 18 ? value : 18;
},
},
};
const OpenLocationProtocol = {
latitude: {
type: Number,
required: true,
},
longitude: {
type: Number,
required: true,
},
scale: Number,
name: String,
address: String,
};
const API_CHOOSE_IMAGE = 'chooseImage'; const API_CHOOSE_IMAGE = 'chooseImage';
const ChooseImageOptions = { const ChooseImageOptions = {
formatArgs: { formatArgs: {
...@@ -5801,7 +5831,7 @@ var serviceContext = (function (vue) { ...@@ -5801,7 +5831,7 @@ var serviceContext = (function (vue) {
} }
}, },
}; };
const callbacks$1 = { const callbacks$2 = {
pause: null, pause: null,
resume: null, resume: null,
start: null, start: null,
...@@ -5812,29 +5842,29 @@ var serviceContext = (function (vue) { ...@@ -5812,29 +5842,29 @@ var serviceContext = (function (vue) {
const state = res.state; const state = res.state;
delete res.state; delete res.state;
delete res.errMsg; delete res.errMsg;
if (state && typeof callbacks$1[state] === 'function') { if (state && typeof callbacks$2[state] === 'function') {
callbacks$1[state](res); callbacks$2[state](res);
} }
} }
class RecorderManager { class RecorderManager {
constructor() { } constructor() { }
onError(callback) { onError(callback) {
callbacks$1.error = callback; callbacks$2.error = callback;
} }
onFrameRecorded(callback) { } onFrameRecorded(callback) { }
onInterruptionBegin(callback) { } onInterruptionBegin(callback) { }
onInterruptionEnd(callback) { } onInterruptionEnd(callback) { }
onPause(callback) { onPause(callback) {
callbacks$1.pause = callback; callbacks$2.pause = callback;
} }
onResume(callback) { onResume(callback) {
callbacks$1.resume = callback; callbacks$2.resume = callback;
} }
onStart(callback) { onStart(callback) {
callbacks$1.start = callback; callbacks$2.start = callback;
} }
onStop(callback) { onStop(callback) {
callbacks$1.stop = callback; callbacks$2.stop = callback;
} }
pause() { pause() {
Recorder.pause(); Recorder.pause();
...@@ -6365,7 +6395,7 @@ var serviceContext = (function (vue) { ...@@ -6365,7 +6395,7 @@ var serviceContext = (function (vue) {
const socketTasks = []; const socketTasks = [];
const socketsMap = {}; const socketsMap = {};
const globalEvent = { const globalEvent$1 = {
open: '', open: '',
close: '', close: '',
error: '', error: '',
...@@ -6467,8 +6497,8 @@ var serviceContext = (function (vue) { ...@@ -6467,8 +6497,8 @@ var serviceContext = (function (vue) {
} }
socketStateChange(name, res = {}) { socketStateChange(name, res = {}) {
const data = name === 'message' ? res : {}; const data = name === 'message' ? res : {};
if (this === socketTasks[0] && globalEvent[name]) { if (this === socketTasks[0] && globalEvent$1[name]) {
UniServiceJSBridge.invokeOnCallback(globalEvent[name], data); UniServiceJSBridge.invokeOnCallback(globalEvent$1[name], data);
} }
// WYQ fix: App平台修复websocket onOpen时发送数据报错的Bug // WYQ fix: App平台修复websocket onOpen时发送数据报错的Bug
this._callbacks[name].forEach((callback) => { this._callbacks[name].forEach((callback) => {
...@@ -6567,7 +6597,7 @@ var serviceContext = (function (vue) { ...@@ -6567,7 +6597,7 @@ var serviceContext = (function (vue) {
function on(event) { function on(event) {
const api = `onSocket${capitalize(event)}`; const api = `onSocket${capitalize(event)}`;
return defineOnApi(api, () => { return defineOnApi(api, () => {
globalEvent[event] = api; globalEvent$1[event] = api;
}); });
} }
const onSocketOpen = /*#__PURE__*/ on('open'); const onSocketOpen = /*#__PURE__*/ on('open');
...@@ -6949,7 +6979,7 @@ var serviceContext = (function (vue) { ...@@ -6949,7 +6979,7 @@ var serviceContext = (function (vue) {
'error', 'error',
'waiting', 'waiting',
]; ];
const callbacks = { const callbacks$1 = {
canplay: [], canplay: [],
play: [], play: [],
pause: [], pause: [],
...@@ -7128,7 +7158,7 @@ var serviceContext = (function (vue) { ...@@ -7128,7 +7158,7 @@ var serviceContext = (function (vue) {
}); });
} }
function onBackgroundAudioStateChange({ state, errMsg, errCode, dataUrl, }) { function onBackgroundAudioStateChange({ state, errMsg, errCode, dataUrl, }) {
callbacks[state].forEach((callback) => { callbacks$1[state].forEach((callback) => {
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(state === 'error' callback(state === 'error'
? { ? {
...@@ -7143,7 +7173,7 @@ var serviceContext = (function (vue) { ...@@ -7143,7 +7173,7 @@ var serviceContext = (function (vue) {
eventNames.forEach((item) => { eventNames.forEach((item) => {
BackgroundAudioManager.prototype[`on${capitalize(item)}`] = BackgroundAudioManager.prototype[`on${capitalize(item)}`] =
function (callback) { function (callback) {
callbacks[item].push(callback); callbacks$1[item].push(callback);
}; };
}); });
}); });
...@@ -7369,6 +7399,203 @@ var serviceContext = (function (vue) { ...@@ -7369,6 +7399,203 @@ var serviceContext = (function (vue) {
}); });
}, GetLocationProtocol, GetLocationOptions); }, GetLocationProtocol, GetLocationOptions);
let plus_;
let weex_;
let BroadcastChannel_;
function getRuntime() {
return typeof window === 'object' &&
typeof navigator === 'object' &&
typeof document === 'object'
? 'webview'
: 'v8';
}
function getPageId() {
return plus_.webview.currentWebview().id;
}
let channel;
let globalEvent;
const callbacks = {};
function onPlusMessage$1(res) {
const message = res.data && res.data.__message;
if (!message || !message.__page) {
return;
}
const pageId = message.__page;
const callback = callbacks[pageId];
callback && callback(message);
if (!message.keep) {
delete callbacks[pageId];
}
}
function addEventListener(pageId, callback) {
if (getRuntime() === 'v8') {
if (BroadcastChannel_) {
channel && channel.close();
channel = new BroadcastChannel_(getPageId());
channel.onmessage = onPlusMessage$1;
}
else if (!globalEvent) {
globalEvent = weex_.requireModule('globalEvent');
globalEvent.addEventListener('plusMessage', onPlusMessage$1);
}
}
else {
// @ts-ignore
window.__plusMessage = onPlusMessage$1;
}
callbacks[pageId] = callback;
}
class Page {
constructor(webview) {
this.webview = webview;
}
sendMessage(data) {
const message = {
__message: {
data,
},
};
const id = this.webview.id;
if (BroadcastChannel_) {
const channel = new BroadcastChannel_(id);
channel.postMessage(message);
}
else {
plus_.webview.postMessageToUniNView &&
plus_.webview.postMessageToUniNView(message, id);
}
}
close() {
this.webview.close();
}
}
function showPage({ context = {}, url, data = {}, style = {}, onMessage, onClose, }) {
// eslint-disable-next-line
plus_ = context.plus || plus;
// eslint-disable-next-line
weex_ = context.weex || (typeof weex === 'object' ? weex : null);
// eslint-disable-next-line
BroadcastChannel_ =
context.BroadcastChannel ||
(typeof BroadcastChannel === 'object' ? BroadcastChannel : null);
const titleNView = {
autoBackButton: true,
titleSize: '17px',
};
const pageId = `page${Date.now()}`;
style = Object.assign({}, style);
if (style.titleNView !== false && style.titleNView !== 'none') {
style.titleNView = Object.assign(titleNView, style.titleNView);
}
const defaultStyle = {
top: 0,
bottom: 0,
usingComponents: {},
popGesture: 'close',
scrollIndicator: 'none',
animationType: 'pop-in',
animationDuration: 200,
uniNView: {
path: `${(typeof process === 'object' &&
process.env &&
process.env.VUE_APP_TEMPLATE_PATH) ||
''}/${url}.js`,
defaultFontSize: plus_.screen.resolutionWidth / 20,
viewport: plus_.screen.resolutionWidth,
},
};
style = Object.assign(defaultStyle, style);
const page = plus_.webview.create('', pageId, style, {
extras: {
from: getPageId(),
runtime: getRuntime(),
data,
useGlobalEvent: !BroadcastChannel_,
},
});
page.addEventListener('close', onClose);
addEventListener(pageId, (message) => {
if (typeof onMessage === 'function') {
onMessage(message.data);
}
if (!message.keep) {
page.close('auto');
}
});
page.show(style.animationType, style.animationDuration);
return new Page(page);
}
function getStatusBarStyle() {
let style = plus.navigator.getStatusBarStyle();
if (style === 'UIStatusBarStyleBlackTranslucent' ||
style === 'UIStatusBarStyleBlackOpaque' ||
style === 'null') {
style = 'light';
}
else if (style === 'UIStatusBarStyleDefault') {
style = 'dark';
}
return style;
}
const chooseLocation = defineAsyncApi(API_CHOOSE_LOCATION, (options, { resolve, reject }) => {
const statusBarStyle = getStatusBarStyle();
const isDark = statusBarStyle !== 'light';
let result;
const page = showPage({
url: '__uniappchooselocation',
data: options,
style: {
// @ts-ignore
animationType: options.animationType || 'slide-in-bottom',
// @ts-ignore
titleNView: false,
popGesture: 'close',
scrollIndicator: 'none',
},
onMessage({ event, detail, }) {
if (event === 'selected') {
result = detail;
}
},
onClose() {
if (isDark) {
plus.navigator.setStatusBarStyle('dark');
}
result ? resolve(result) : reject('cancel');
},
});
if (isDark) {
plus.navigator.setStatusBarStyle('light');
page.webview.addEventListener('popGesture', ({ type, result }) => {
if (type === 'start') {
plus.navigator.setStatusBarStyle('dark');
}
else if (type === 'end' && !result) {
plus.navigator.setStatusBarStyle('light');
}
});
}
}, ChooseLocationProtocol);
const openLocation = defineAsyncApi(API_OPEN_LOCATION, (data, { resolve, reject }) => {
showPage({
url: '__uniappopenlocation',
data,
style: {
titleNView: {
type: 'transparent',
},
popGesture: 'close',
backButtonAutoControl: 'close',
},
onClose() {
reject('cancel');
},
});
return resolve();
}, OpenLocationProtocol, OpenLocationOptions);
const showModal = defineAsyncApi(API_SHOW_MODAL, ({ title = '', content = '', showCancel = true, cancelText, cancelColor, confirmText, confirmColor, } = {}, { resolve }) => { const showModal = defineAsyncApi(API_SHOW_MODAL, ({ title = '', content = '', showCancel = true, cancelText, cancelColor, confirmText, confirmColor, } = {}, { resolve }) => {
content = content || ' '; content = content || ' ';
plus.nativeUI.confirm(content, (e) => { plus.nativeUI.confirm(content, (e) => {
...@@ -10031,6 +10258,8 @@ var serviceContext = (function (vue) { ...@@ -10031,6 +10258,8 @@ var serviceContext = (function (vue) {
createInnerAudioContext: createInnerAudioContext, createInnerAudioContext: createInnerAudioContext,
getBackgroundAudioManager: getBackgroundAudioManager, getBackgroundAudioManager: getBackgroundAudioManager,
getLocation: getLocation, getLocation: getLocation,
chooseLocation: chooseLocation,
openLocation: openLocation,
showModal: showModal, showModal: showModal,
showActionSheet: showActionSheet, showActionSheet: showActionSheet,
showLoading: showLoading, showLoading: showLoading,
......
...@@ -35,6 +35,8 @@ export * from './context/createInnerAudioContext' ...@@ -35,6 +35,8 @@ export * from './context/createInnerAudioContext'
export * from './context/getBackgroundAudioManager' export * from './context/getBackgroundAudioManager'
export * from './location/getLocation' export * from './location/getLocation'
export * from './location/chooseLocation'
export * from './location/openLocation'
export * from './ui/popup/showModal' export * from './ui/popup/showModal'
export * from './ui/popup/showActionSheet' export * from './ui/popup/showActionSheet'
......
import {
API_CHOOSE_LOCATION,
API_TYPE_CHOOSE_LOCATION,
defineAsyncApi,
ChooseLocationProtocol,
} from '@dcloudio/uni-api'
import { showPage } from '../page'
function getStatusBarStyle() {
let style = plus.navigator.getStatusBarStyle()
if (
style === 'UIStatusBarStyleBlackTranslucent' ||
style === 'UIStatusBarStyleBlackOpaque' ||
style === 'null'
) {
style = 'light'
} else if (style === 'UIStatusBarStyleDefault') {
style = 'dark'
}
return style
}
export const chooseLocation = <API_TYPE_CHOOSE_LOCATION>defineAsyncApi(
API_CHOOSE_LOCATION,
(options, { resolve, reject }) => {
const statusBarStyle = getStatusBarStyle()
const isDark = statusBarStyle !== 'light'
let result: undefined | UniApp.ChooseLocationSuccess
const page = showPage({
url: '__uniappchooselocation',
data: options,
style: {
// @ts-ignore
animationType: options.animationType || 'slide-in-bottom',
// @ts-ignore
titleNView: false,
popGesture: 'close',
scrollIndicator: 'none',
},
onMessage({
event,
detail,
}: {
event: string
detail: UniApp.ChooseLocationSuccess
}) {
if (event === 'selected') {
result = detail
}
},
onClose() {
if (isDark) {
plus.navigator.setStatusBarStyle('dark')
}
result ? resolve(result) : reject('cancel')
},
})
if (isDark) {
plus.navigator.setStatusBarStyle('light')
page.webview.addEventListener('popGesture', ({ type, result }) => {
if (type === 'start') {
plus.navigator.setStatusBarStyle('dark')
} else if (type === 'end' && !result) {
plus.navigator.setStatusBarStyle('light')
}
})
}
},
ChooseLocationProtocol
)
import {
API_OPEN_LOCATION,
API_TYPE_OPEN_LOCATION,
defineAsyncApi,
OpenLocationProtocol,
OpenLocationOptions,
} from '@dcloudio/uni-api'
import { showPage } from '../page.js'
export const openLocation = <API_TYPE_OPEN_LOCATION>defineAsyncApi(
API_OPEN_LOCATION,
(data, { resolve, reject }) => {
showPage({
url: '__uniappopenlocation',
data,
style: {
titleNView: {
type: 'transparent',
},
popGesture: 'close',
backButtonAutoControl: 'close',
},
onClose() {
reject('cancel')
},
})
return resolve()
},
OpenLocationProtocol,
OpenLocationOptions
)
declare interface BroadcastChannel {
new (id: string): BroadcastChannel
name: string
postMessage: (message: any) => void
onmessage: (event: { type: string; data: any }) => void
close: () => void
}
let plus_: Plus & {
webview: {
postMessageToUniNView?: Function
}
}
let weex_: any
let BroadcastChannel_: BroadcastChannel
function getRuntime() {
return typeof window === 'object' &&
typeof navigator === 'object' &&
typeof document === 'object'
? 'webview'
: 'v8'
}
function getPageId() {
return plus_.webview.currentWebview().id
}
let channel: BroadcastChannel
let globalEvent: any
const callbacks: Record<string, CallBack> = {}
type CallBack = (result: any) => void
function onPlusMessage(res: {
data?: { __message: { __page: string; keep: boolean } }
}) {
const message = res.data && res.data.__message
if (!message || !message.__page) {
return
}
const pageId = message.__page
const callback = callbacks[pageId]
callback && callback(message)
if (!message.keep) {
delete callbacks[pageId]
}
}
function addEventListener(pageId: string, callback: CallBack) {
if (getRuntime() === 'v8') {
if (BroadcastChannel_) {
channel && channel.close()
channel = new BroadcastChannel_(getPageId())
channel.onmessage = onPlusMessage
} else if (!globalEvent) {
globalEvent = weex_.requireModule('globalEvent')
globalEvent.addEventListener('plusMessage', onPlusMessage)
}
} else {
// @ts-ignore
window.__plusMessage = onPlusMessage
}
callbacks[pageId] = callback
}
class Page {
webview: PlusWebviewWebviewObject
constructor(webview: PlusWebviewWebviewObject) {
this.webview = webview
}
sendMessage(data: any) {
const message = {
__message: {
data,
},
}
const id = this.webview.id
if (BroadcastChannel_) {
const channel = new BroadcastChannel_(id)
channel.postMessage(message)
} else {
plus_.webview.postMessageToUniNView &&
plus_.webview.postMessageToUniNView(message, id)
}
}
close() {
this.webview.close()
}
}
type PageShow = Parameters<PlusWebviewWebviewObject['show']>
type ShowPage = {
context?: { plus?: Plus; weex?: any; BroadcastChannel?: any }
url: string
data: any
style?: PlusWebviewWebviewStyles & {
animationType?: PageShow[0]
animationDuration?: PageShow[1]
}
onMessage?: CallBack
onClose: CallBack
}
export function showPage({
context = {},
url,
data = {},
style = {},
onMessage,
onClose,
}: ShowPage) {
// eslint-disable-next-line
plus_ = context.plus || plus
// eslint-disable-next-line
weex_ = context.weex || (typeof weex === 'object' ? weex : null)
// eslint-disable-next-line
BroadcastChannel_ =
context.BroadcastChannel ||
(typeof BroadcastChannel === 'object' ? BroadcastChannel : null)
const titleNView = {
autoBackButton: true,
titleSize: '17px',
}
const pageId = `page${Date.now()}`
style = Object.assign({}, style)
if (style.titleNView !== false && style.titleNView !== 'none') {
style.titleNView = Object.assign(titleNView, style.titleNView)
}
const defaultStyle = {
top: 0,
bottom: 0,
usingComponents: {},
popGesture: 'close',
scrollIndicator: 'none',
animationType: 'pop-in',
animationDuration: 200,
uniNView: {
path: `${
(typeof process === 'object' &&
process.env &&
process.env.VUE_APP_TEMPLATE_PATH) ||
''
}/${url}.js`,
defaultFontSize: plus_.screen.resolutionWidth! / 20,
viewport: plus_.screen.resolutionWidth,
},
}
style = Object.assign(defaultStyle, style)
const page = plus_.webview.create('', pageId, style, {
extras: {
from: getPageId(),
runtime: getRuntime(),
data,
useGlobalEvent: !BroadcastChannel_,
},
})
page.addEventListener('close', onClose)
addEventListener(pageId, (message) => {
if (typeof onMessage === 'function') {
onMessage(message.data)
}
if (!message.keep) {
page.close('auto')
}
})
page.show(style.animationType, style.animationDuration)
return new Page(page)
}
...@@ -737,7 +737,7 @@ var safeAreaInsets = { ...@@ -737,7 +737,7 @@ var safeAreaInsets = {
onChange, onChange,
offChange offChange
}; };
var out = safeAreaInsets; var D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out = safeAreaInsets;
const onEventPrevent = /* @__PURE__ */ withModifiers(() => { const onEventPrevent = /* @__PURE__ */ withModifiers(() => {
}, ["prevent"]); }, ["prevent"]);
const onEventStop = /* @__PURE__ */ withModifiers(() => { const onEventStop = /* @__PURE__ */ withModifiers(() => {
...@@ -749,10 +749,10 @@ function getWindowOffset() { ...@@ -749,10 +749,10 @@ function getWindowOffset() {
const left = parseInt(style.getPropertyValue("--window-left")); const left = parseInt(style.getPropertyValue("--window-left"));
const right = parseInt(style.getPropertyValue("--window-right")); const right = parseInt(style.getPropertyValue("--window-right"));
return { return {
top: top ? top + out.top : 0, top: top ? top + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top : 0,
bottom: bottom ? bottom + out.bottom : 0, bottom: bottom ? bottom + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom : 0,
left: left ? left + out.left : 0, left: left ? left + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left : 0,
right: right ? right + out.right : 0 right: right ? right + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right : 0
}; };
} }
function updateCssVar(cssVars) { function updateCssVar(cssVars) {
...@@ -13147,7 +13147,7 @@ function normalizePageMeta(pageMeta) { ...@@ -13147,7 +13147,7 @@ function normalizePageMeta(pageMeta) {
}, pageMeta.pullToRefresh)); }, pageMeta.pullToRefresh));
const { type, style } = navigationBar; const { type, style } = navigationBar;
if (style !== "custom" && type !== "transparent") { if (style !== "custom" && type !== "transparent") {
pullToRefresh.offset += NAVBAR_HEIGHT + out.top; pullToRefresh.offset += NAVBAR_HEIGHT + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top;
} }
pageMeta.pullToRefresh = pullToRefresh; pageMeta.pullToRefresh = pullToRefresh;
} }
...@@ -15329,7 +15329,7 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", () ...@@ -15329,7 +15329,7 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const windowWidth = getWindowWidth(screenWidth); const windowWidth = getWindowWidth(screenWidth);
let windowHeight = window.innerHeight; let windowHeight = window.innerHeight;
const language = navigator.language; const language = navigator.language;
const statusBarHeight = out.top; const statusBarHeight = D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top;
let osname; let osname;
let osversion; let osversion;
let model; let model;
...@@ -15442,12 +15442,12 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", () ...@@ -15442,12 +15442,12 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const system = `${osname} ${osversion}`; const system = `${osname} ${osversion}`;
const platform = osname.toLocaleLowerCase(); const platform = osname.toLocaleLowerCase();
const safeArea = { const safeArea = {
left: out.left, left: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left,
right: windowWidth - out.right, right: windowWidth - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right,
top: out.top, top: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top,
bottom: windowHeight - out.bottom, bottom: windowHeight - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom,
width: windowWidth - out.left - out.right, width: windowWidth - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right,
height: windowHeight - out.top - out.bottom height: windowHeight - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom
}; };
const { top: windowTop, bottom: windowBottom } = getWindowOffset(); const { top: windowTop, bottom: windowBottom } = getWindowOffset();
windowHeight -= windowTop; windowHeight -= windowTop;
...@@ -15467,10 +15467,10 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", () ...@@ -15467,10 +15467,10 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
model, model,
safeArea, safeArea,
safeAreaInsets: { safeAreaInsets: {
top: out.top, top: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top,
right: out.right, right: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right,
bottom: out.bottom, bottom: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom,
left: out.left left: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left
} }
}; };
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册