提交 812e5eb0 编写于 作者: Q qiang

Merge branch 'dev' into alpha

# Conflicts:
#	packages/uni-app-plus/dist/index.v3.js
#	packages/uni-h5/dist/index.umd.min.js
......@@ -17,6 +17,11 @@ if (process.env.UNI_VIEW !== 'true') {
commonjs: 'vue-router',
commonjs2: 'vue-router',
root: 'VueRouter'
}
externals['@dcloudio/uni-i18n'] = {
commonjs: '@dcloudio/uni-i18n',
commonjs2: '@dcloudio/uni-i18n',
root: '@dcloudio/uni-i18n'
}
}
......
......@@ -64,6 +64,7 @@ var serviceContext = (function () {
'chooseImage',
'chooseFile',
'previewImage',
'closePreviewImage',
'getImageInfo',
'getVideoInfo',
'saveImageToPhotosAlbum',
......@@ -254,7 +255,8 @@ var serviceContext = (function () {
'sendNativeEvent',
'preloadPage',
'unPreloadPage',
'loadSubPackage'
'loadSubPackage',
'sendHostEvent'
];
const ad = [
......@@ -1642,7 +1644,7 @@ var serviceContext = (function () {
"uni.chooseVideo.cancel": "取消",
"uni.chooseVideo.sourceType.album": "从相册选择",
"uni.chooseVideo.sourceType.camera": "拍摄",
"uni.chooseFile.notUserActivation": "文件选择器对话框只能在用户激活时显示",
"uni.chooseFile.notUserActivation": "文件选择器对话框只能在用户激活时显示",
"uni.previewImage.cancel": "取消",
"uni.previewImage.button.save": "保存图像",
"uni.previewImage.save.success": "保存图像到相册成功",
......@@ -1678,7 +1680,7 @@ var serviceContext = (function () {
"uni.chooseVideo.cancel": "取消",
"uni.chooseVideo.sourceType.album": "從相冊選擇",
"uni.chooseVideo.sourceType.camera": "拍攝",
"uni.chooseFile.notUserActivation": "文件選擇器對話框只能在用戶激活時顯示",
"uni.chooseFile.notUserActivation": "文件選擇器對話框只能在用戶激活時顯示",
"uni.previewImage.cancel": "取消",
"uni.previewImage.button.save": "保存圖像",
"uni.previewImage.save.success": "保存圖像到相冊成功",
......@@ -1718,6 +1720,26 @@ var serviceContext = (function () {
}
}
function initI18nMessages () {
if (!isEnableLocale()) {
return
}
const localeKeys = Object.keys(__uniConfig.locales);
if (localeKeys.length) {
localeKeys.forEach((locale) => {
const curMessages = messages[locale];
const userMessages = __uniConfig.locales[locale];
if (curMessages) {
Object.assign(curMessages, userMessages);
} else {
messages[locale] = userMessages;
}
});
}
}
initI18nMessages();
const i18n = initVueI18n(
locale,
messages
......@@ -1813,7 +1835,7 @@ var serviceContext = (function () {
}
function isEnableLocale () {
return __uniConfig.locales && !!Object.keys(__uniConfig.locales).length
return typeof __uniConfig !== 'undefined' && __uniConfig.locales && !!Object.keys(__uniConfig.locales).length
}
function initNavigationBarI18n (navigationBar) {
......@@ -1825,14 +1847,14 @@ var serviceContext = (function () {
}
}
function initI18n () {
const localeKeys = Object.keys(__uniConfig.locales || {});
if (localeKeys.length) {
localeKeys.forEach((locale) =>
i18n.add(locale, __uniConfig.locales[locale])
);
}
}
// export function initI18n() {
// const localeKeys = Object.keys(__uniConfig.locales || {})
// if (localeKeys.length) {
// localeKeys.forEach((locale) =>
// i18n.add(locale, __uniConfig.locales[locale])
// )
// }
// }
const setClipboardData = {
data: {
......@@ -2362,7 +2384,8 @@ var serviceContext = (function () {
PUT: 'PUT',
DELETE: 'DELETE',
TRACE: 'TRACE',
CONNECT: 'CONNECT'
CONNECT: 'CONNECT',
PATCH: 'PATCH'
};
const dataType = {
JSON: 'json'
......@@ -4339,13 +4362,15 @@ var serviceContext = (function () {
return array.length > 1 ? '.' + array[array.length - 1] : ''
}
const AUDIO_DEFAULT_CATEGORY = 'ambient';
const audios = {};
const evts = ['play', 'canplay', 'ended', 'stop', 'waiting', 'seeking', 'seeked', 'pause'];
const publishAudioStateChange = (state, res = {}) => publish('onAudioStateChange', Object.assign({
state
}, res));
}, res));
const initStateChage = audioId => {
const audio = audios[audioId];
......@@ -4384,7 +4409,8 @@ var serviceContext = (function () {
const audio = audios[audioId] = plus.audio.createPlayer('');
audio.src = '';
audio.volume = 1;
audio.startTime = 0;
audio.startTime = 0;
audio.setSessionCategory(AUDIO_DEFAULT_CATEGORY);
return {
errMsg: 'createAudioInstance:ok',
audioId
......@@ -4411,7 +4437,8 @@ var serviceContext = (function () {
autoplay = false,
loop = false,
obeyMuteSwitch,
volume
volume,
category = AUDIO_DEFAULT_CATEGORY
}) {
const audio = audios[audioId];
if (audio) {
......@@ -4428,7 +4455,10 @@ var serviceContext = (function () {
if (typeof volume === 'number') {
audio.volume = style.volume = volume;
}
audio.setStyles(style);
audio.setStyles(style);
if (category) {
audio.setSessionCategory(category);
}
initStateChage(audioId);
}
return {
......@@ -7220,6 +7250,19 @@ var serviceContext = (function () {
return {
errMsg: 'previewImage:ok'
}
}
function closePreviewImagePlus () {
try {
plus.nativeUI.closePreviewImage();
return {
errMsg: 'closePreviewImagePlus:ok'
}
} catch (error) {
return {
errMsg: 'closePreviewImagePlus:fail'
}
}
}
let recorder$1;
......@@ -8668,6 +8711,25 @@ var serviceContext = (function () {
});
}
const sendHostEvent = sendNativeEvent;
function navigateToMiniProgram (data, callbackId) {
sendHostEvent(
'navigateToUniMP',
data,
(res) => {
if (res.errMsg && res.errMsg.indexOf(':ok') === -1) {
return invoke$1(callbackId, {
errMsg: res.errMsg
})
}
invoke$1(callbackId, {
errMsg: 'navigateToMiniProgram:ok'
});
}
);
}
const VD_SYNC_VERSION = 2;
const PAGE_CREATE = 2;
......@@ -10839,6 +10901,11 @@ var serviceContext = (function () {
pagePath,
visible
}) {
if (!isTabBarPage()) {
return {
errMsg: 'setTabBarItem:fail not TabBar page'
}
}
tabBar$1.setTabBarItem(index, text, iconPath, selectedIconPath, visible);
const route = pagePath && __uniRoutes.find(({ path }) => path === pagePath);
if (route) {
......@@ -11742,6 +11809,7 @@ var serviceContext = (function () {
getImageInfo: getImageInfo$1,
getVideoInfo: getVideoInfo$1,
previewImagePlus: previewImagePlus,
closePreviewImagePlus: closePreviewImagePlus,
operateRecorder: operateRecorder,
saveImageToPhotosAlbum: saveImageToPhotosAlbum$1,
saveVideoToPhotosAlbum: saveVideoToPhotosAlbum,
......@@ -11779,6 +11847,8 @@ var serviceContext = (function () {
onNativeEventReceive: onNativeEventReceive,
sendNativeEvent: sendNativeEvent,
loadSubPackage: loadSubPackage$2,
sendHostEvent: sendHostEvent,
navigateToMiniProgram: navigateToMiniProgram,
navigateBack: navigateBack$1,
navigateTo: navigateTo$1,
reLaunch: reLaunch$1,
......@@ -20217,11 +20287,16 @@ var serviceContext = (function () {
}
return invokeMethod('previewImagePlus', args)
}
function closePreviewImage (args = {}) {
return invokeMethod('closePreviewImagePlus', args)
}
var require_context_module_1_15 = /*#__PURE__*/Object.freeze({
__proto__: null,
previewImage: previewImage$1
previewImage: previewImage$1,
closePreviewImage: closePreviewImage
});
const callbacks$8 = {
......@@ -22969,8 +23044,6 @@ var serviceContext = (function () {
}
};
initI18n();
// 挂靠在uni上,暂不做全局导出
uni$1.__$wx__ = wx;
......
......@@ -2,4 +2,4 @@ export const NAVBAR_HEIGHT = 44
export const TABBAR_HEIGHT = 50
// 576:landscape phones,768:tablets,992:desktops,1200:large desktops
export const RESPONSIVE_MIN_WIDTH = 768
export const DC_LOCALE = '__DC_LOCALE'
export const UNI_STORAGE_LOCALE = 'UNI_LOCALE'
......@@ -4,10 +4,10 @@ import {
} from '@dcloudio/uni-i18n'
import {
isStr
} from 'uni-shared'
import {
DC_LOCALE
} from 'uni-shared'
import {
UNI_STORAGE_LOCALE
} from '../constants'
import en from './en.json'
......@@ -27,7 +27,7 @@ const messages = {
let locale
if (__PLATFORM__ === 'h5') {
locale = (window.localStorage && localStorage[DC_LOCALE]) || __uniConfig.locale || navigator.language
locale = (window.localStorage && localStorage[UNI_STORAGE_LOCALE]) || __uniConfig.locale || navigator.language
} else if (__PLATFORM__ === 'app-plus') {
if (typeof weex === 'object') {
locale = weex.requireModule('plus').getLanguage()
......@@ -38,6 +38,26 @@ if (__PLATFORM__ === 'h5') {
locale = __GLOBAL__.getSystemInfoSync().language
}
function initI18nMessages () {
if (!isEnableLocale()) {
return
}
const localeKeys = Object.keys(__uniConfig.locales)
if (localeKeys.length) {
localeKeys.forEach((locale) => {
const curMessages = messages[locale]
const userMessages = __uniConfig.locales[locale]
if (curMessages) {
Object.assign(curMessages, userMessages)
} else {
messages[locale] = userMessages
}
})
}
}
initI18nMessages()
export const i18n = initVueI18n(
locale,
__PLATFORM__ === 'app-plus' || __PLATFORM__ === 'h5' ? messages : {}
......@@ -134,7 +154,7 @@ export function defineI18nProperty (obj, names) {
}
function isEnableLocale () {
return __uniConfig.locales && !!Object.keys(__uniConfig.locales).length
return typeof __uniConfig !== 'undefined' && __uniConfig.locales && !!Object.keys(__uniConfig.locales).length
}
export function initNavigationBarI18n (navigationBar) {
......@@ -166,11 +186,11 @@ export function initTabBarI18n (tabBar) {
return tabBar
}
export function initI18n () {
const localeKeys = Object.keys(__uniConfig.locales || {})
if (localeKeys.length) {
localeKeys.forEach((locale) =>
i18n.add(locale, __uniConfig.locales[locale])
)
}
}
// export function initI18n() {
// const localeKeys = Object.keys(__uniConfig.locales || {})
// if (localeKeys.length) {
// localeKeys.forEach((locale) =>
// i18n.add(locale, __uniConfig.locales[locale])
// )
// }
// }
......@@ -12,7 +12,8 @@ const method = {
PUT: 'PUT',
DELETE: 'DELETE',
TRACE: 'TRACE',
CONNECT: 'CONNECT'
CONNECT: 'CONNECT',
PATCH: 'PATCH'
}
const dataType = {
JSON: 'json'
......
......@@ -5,7 +5,7 @@ import {
i18n
} from 'uni-helpers/i18n'
import {
DC_LOCALE
UNI_STORAGE_LOCALE
} from 'uni-helpers/constants'
export function getLocale () {
......@@ -35,7 +35,7 @@ export function setLocale (locale) {
weex.requireModule('plus').setLanguage(locale)
}
if (__PLATFORM__ === 'h5') {
window.localStorage && (localStorage[DC_LOCALE] = locale)
window.localStorage && (localStorage[UNI_STORAGE_LOCALE] = locale)
}
callbacks.forEach(callbackId => {
invoke(callbackId, { locale })
......
......@@ -147,11 +147,7 @@ function normalizeNodes (nodes, ctx, options) {
}
function getRichText (weex) {
const {
scale,
deviceWidth
} = weex.config.env
const defaultFontSize = deviceWidth / scale / 20
const defaultFontSize = 16
return {
props: {
nodes: {
......
......@@ -101,7 +101,7 @@ export function showPage ({
animationDuration: 200,
uniNView: {
path: `${(typeof process === 'object' && process.env && process.env.VUE_APP_TEMPLATE_PATH) || ''}/${url}.js`,
defaultFontSize: plus_.screen.resolutionWidth / 20,
defaultFontSize: 16,
viewport: plus_.screen.resolutionWidth
}
}
......
......@@ -27,7 +27,7 @@ export function registerConfig (config, Vue) {
if (__uniConfig.nvueCompiler === 'uni-app') {
__uniConfig.viewport = plus.screen.resolutionWidth
__uniConfig.defaultFontSize = __uniConfig.viewport / 20
__uniConfig.defaultFontSize = 16
}
parseRoutes(__uniConfig)
......@@ -90,4 +90,4 @@ export function initEntryPage () {
if (process.env.NODE_ENV !== 'production') {
console.log(`[uni-app] entryPagePath(${entryPagePath + entryPageQuery})`)
}
}
}
......@@ -31,12 +31,6 @@ import {
import vuePlugin from './framework/plugins'
import {
initI18n
} from 'uni-helpers/i18n'
initI18n()
// 挂靠在uni上,暂不做全局导出
uni.__$wx__ = wx
......
......@@ -101,7 +101,7 @@ export function showPage ({
animationDuration: 200,
uniNView: {
path: `${(typeof process === 'object' && process.env && process.env.VUE_APP_TEMPLATE_PATH) || ''}/${url}.js`,
defaultFontSize: plus_.screen.resolutionWidth / 20,
defaultFontSize: 16,
viewport: plus_.screen.resolutionWidth
}
}
......
......@@ -10,11 +10,6 @@ import {
getCurrentPages
}
from 'uni-core/service/plugins/app'
import {
initI18n
} from 'uni-helpers/i18n'
initI18n()
initOn(UniServiceJSBridge.on, {
getApp,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册