提交 d2e80217 编写于 作者: Q qiang

Merge branch 'dev' into alpha

......@@ -20,7 +20,7 @@ module.exports = {
subPackages: true
},
copyWebpackOptions (platformOptions, vueOptions) {
const copyOptions = ['mycomponents', 'customize-tab-bar']
const copyOptions = ['mycomponents', 'customize-tab-bar', 'ext.json']
global.uniModules.forEach(module => {
copyOptions.push('uni_modules/' + module + '/mycomponents')
......
......@@ -17,10 +17,10 @@ module.exports = {
subPackages: true
},
copyWebpackOptions (platformOptions, vueOptions) {
const copyOptions = ['swancomponents']
const copyOptions = ['swancomponents', 'ext.json']
global.uniModules.forEach(module => {
copyOptions.push('uni_modules/' + module + '/swancomponents')
})
return copyOptions
}
}
}
......@@ -14,10 +14,10 @@ module.exports = {
project: 'project.ks.json'
},
copyWebpackOptions (platformOptions, vueOptions) {
const copyOptions = ['kscomponents']
const copyOptions = ['kscomponents', 'ext.json']
global.uniModules.forEach(module => {
copyOptions.push('uni_modules/' + module + '/kscomponents')
})
return copyOptions
}
}
}
......@@ -15,7 +15,7 @@ module.exports = {
project: 'project.tt.json'
},
copyWebpackOptions (platformOptions, vueOptions) {
const copyOptions = ['ttcomponents']
const copyOptions = ['ttcomponents', 'ext.json']
global.uniModules.forEach(module => {
copyOptions.push('uni_modules/' + module + '/ttcomponents')
})
......
......@@ -182,16 +182,25 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
for (let i = rawRules.length - 1; i >= 0; i--) {
const uses = rawRules[i].use
if (Array.isArray(uses)) {
if (uses.find(use => babelLoaderRe.test(use.loader))) {
const index = uses.findIndex(use => cacheLoaderRe.test(use.loader))
if (index >= 0) {
const babelLoader = uses.find(use => babelLoaderRe.test(use.loader))
if (babelLoader) {
const options = api.genCacheConfig('babel-loader/' + process.env.UNI_PLATFORM, getPartialIdentifier())
if (webpack.version[0] > 4) {
if (process.env.UNI_USING_CACHE) {
Object.assign(uses[index].options, api.genCacheConfig(
'babel-loader/' + process.env.UNI_PLATFORM,
getPartialIdentifier()
))
Object.assign(babelLoader.options, options)
} else {
uses.splice(index, 1)
Object.assign(babelLoader.options, {
cacheDirectory: false
})
}
} else {
const index = uses.findIndex(use => cacheLoaderRe.test(use.loader))
if (index >= 0) {
if (process.env.UNI_USING_CACHE) {
Object.assign(uses[index].options, options)
} else {
uses.splice(index, 1)
}
}
}
}
......
......@@ -169,6 +169,10 @@ module.exports = {
webpackConfig.optimization.splitChunks = require('../split-chunks')()
if (webpack.version[0] > 4) {
webpackConfig.optimization.chunkIds = 'named'
}
parseEntry()
const statCode = getPlatformStat()
......@@ -330,6 +334,11 @@ ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__ = __webpack_require__;`
}
}
if (process.env.NODE_ENV === 'production' && webpack.version[0] > 4) {
// 暂时禁用,否则导致 provide 被压缩和裁剪
webpackConfig.optimization.usedExports(false)
}
if (process.env.UNI_SUBPACKGE || process.env.UNI_MP_PLUGIN) {
initSubpackageConfig(webpackConfig, vueOptions)
}
......
......@@ -5,8 +5,6 @@ module.exports = function ({
visitor: {
MemberExpression (path, state) {
if (
// main.js main.ts
state.filename.startsWith(require('path').join(process.env.UNI_INPUT_DIR, 'main.')) &&
t.isIdentifier(path.node.property) &&
path.node.property.name === '$mount' &&
!path.node.$createApp
......
......@@ -96,12 +96,21 @@ createPage(Page)
components: []
})
const babelLoader = findBabelLoader(this.loaders)
let babelLoader = findBabelLoader(this.loaders)
if (!babelLoader) {
throw new Error(uniI18n.__('mpLoader.findFail', {
0: 'babel-loader'
}))
} else {
const webpack = require('webpack')
if (webpack.version[0] > 4) {
// clone babelLoader and options
const index = this.loaders.indexOf(babelLoader)
const newBabelLoader = Object.assign({}, babelLoader)
Object.assign(newBabelLoader, { options: Object.assign({}, babelLoader.options) })
this.loaders.splice(index, 1, newBabelLoader)
babelLoader = newBabelLoader
}
addCreateApp(babelLoader)
}
......@@ -147,4 +156,4 @@ createPage(Page)
callback(err, content, map)
})
}
}
}
......@@ -70,7 +70,11 @@ module.exports = function generateComponent (compilation, jsonpFunction = 'webpa
const modules = compilation.modules
const concatenatedModules = modules.filter(module => module.modules)
const uniModuleId = modules.find(module => module.resource && normalizePath(module.resource) === uniPath).id
let uniModule = modules.find(module => module.resource && normalizePath(module.resource) === uniPath)
if (!uniModule && webpack.version[0] > 4) {
uniModule = modules.find(module => module.rootModule && module.rootModule.resource && normalizePath(module.rootModule.resource) === uniPath)
}
const uniModuleId = uniModule.id
const styleImports = {}
const fixSlots = {}
const vueOuterComponentSting = 'vueOuterComponents'
......
......@@ -69,6 +69,35 @@ export function initHooks (mpOptions, hooks, vueOptions) {
})
}
export function initUnknownHooks (mpOptions, vueOptions, excludes = []) {
findHooks(vueOptions).forEach((hook) => initHook(mpOptions, hook, excludes))
}
function findHooks (vueOptions, hooks = []) {
if (vueOptions) {
Object.keys(vueOptions).forEach((name) => {
if (name.indexOf('on') === 0 && isFn(vueOptions[name])) {
hooks.push(name)
}
})
}
return hooks
}
function initHook (mpOptions, hook, excludes) {
if (excludes.indexOf(hook) === -1 && !hasOwn(mpOptions, hook)) {
mpOptions[hook] = function (args) {
if (
(__PLATFORM__ === 'mp-toutiao' || __PLATFORM__ === 'mp-lark') &&
hook === 'onError'
) {
return getApp().$vm.$callHook(hook, args)
}
return this.$vm && this.$vm.__call_hook(hook, args)
}
}
}
export function initVueComponent (Vue, vueOptions) {
vueOptions = vueOptions.default || vueOptions
let VueComponent
......
......@@ -12,11 +12,15 @@ export default function createPage (pageVm, options) {
}
const id = hasOwn($route.params, '__id__') ? $route.params.__id__ : $route.meta.id
let fullPath = $route.fullPath
if ($route.meta.isEntry && fullPath.indexOf($route.meta.pagePath) === -1) {
fullPath = '/' + $route.meta.pagePath + fullPath.replace('/', '')
}
pageVm.__page__ = {
id,
path: $route.path,
route: $route.meta.pagePath,
fullPath: $route.meta.isEntry ? $route.meta.pagePath : $route.fullPath,
fullPath,
options: options,
meta: Object.assign({}, $route.meta)
}
......
......@@ -46,7 +46,8 @@ export function getAppBaseInfo () {
const {
hostPackageName, hostName, osLanguage,
hostVersion, hostLanguage, hostTheme,
appId, appName, appVersion, appVersionCode
appId, appName, appVersion, appVersionCode,
appWgtVersion
} = systemInfo
const appLanguage = uni
......@@ -60,6 +61,7 @@ export function getAppBaseInfo () {
appName,
appVersion,
appVersionCode,
appWgtVersion,
appLanguage,
enableDebug: false,
hostSDKVersion: undefined,
......
......@@ -229,6 +229,10 @@ export default {
methods: {
handleAMapClick (e) {
if (IS_AMAP) {
// The mobile terminal prevent not map click event trigger map click
if (e.target.nodeName !== 'CANVAS') {
return
}
const { pageX, pageY } = e.changedTouches[0]
this.$trigger('click', { x: pageX, y: pageY }, {})
this.$trigger('tap', { x: pageX, y: pageY }, {})
......@@ -611,6 +615,7 @@ export default {
style.height = 0
style.top = 0
style.left = 0
style.zIndex = 999
img.onload = () => {
if (option.position.width) {
img.width = option.position.width
......
......@@ -96,17 +96,18 @@ export default {
})
this.$parent._markers[this.idString] = marker
this.updateMarker(props)
maps.event.addListener(marker, 'click', (e) => {
const callout = marker.callout
if (callout && !callout.alwaysVisible) {
if (IS_AMAP) {
callout.visible = !callout.visible
if (callout.visible) {
marker.callout.createAMapText()
} else {
marker.callout.removeAMapText()
}
} else {
if (IS_AMAP) {
// 不通过 addListener 方式绑定事件,为了规避高德地图覆盖物点击触发map点击问题
marker.dom.addEventListener('click', e => {
this.handleAMapMarkerClick(e, marker)
})
marker.dom.addEventListener('touchend', e => {
this.handleAMapMarkerClick(e, marker)
})
} else {
maps.event.addListener(marker, 'click', (e) => {
const callout = marker.callout
if (callout && !callout.alwaysVisible) {
callout.set('visible', !callout.visible)
if (callout.visible) {
const div = callout.div
......@@ -115,19 +116,26 @@ export default {
parent.appendChild(div)
}
}
}
if (this.idString) {
const { latitude, longitude } = this.getMarkerLatitudeLongitude(e)
this.$parent.$trigger('markertap', {}, {
markerId: Number(this.idString),
latitude,
longitude
})
}
const event = e.event || e.domEvent || e.originEvent
event.stopPropagation()
})
const event = e.event || e.domEvent
if (this.idString) {
const { latitude, longitude } = this.getMarkerLatitudeLongitude(e)
this.$parent.$trigger('markertap', event, {
markerId: Number(this.idString),
latitude,
longitude
})
}
event.stopPropagation()
})
// 处理 google H5移动端 maker 点击触发 map 点击问题
maps.event.addListener(marker, 'mousedown', (e) => {
if (e.domEvent) {
e.domEvent.stopPropagation()
}
})
}
},
updateMarker (option) {
const map = this._map
......@@ -274,9 +282,9 @@ export default {
callout.setOption(calloutStyle)
} else {
if (IS_AMAP) {
const callback = (self) => {
const callback = ($event, self) => {
if (self.idString) {
self.$parent.$trigger('callouttap', {}, {
self.$parent.$trigger('callouttap', $event, {
markerId: Number(self.idString)
})
}
......@@ -308,6 +316,25 @@ export default {
console.error('Marker.iconPath is required.')
}
},
handleAMapMarkerClick (e, marker) {
const callout = marker.callout
if (callout && !callout.alwaysVisible) {
callout.visible = !callout.visible
if (callout.visible) {
marker.callout.createAMapText()
} else {
marker.callout.removeAMapText()
}
}
if (this.idString) {
this.$parent.$trigger('markertap', e, {
markerId: Number(this.idString),
latitude: marker._position.lat,
longitude: marker._position.lng
})
}
e.stopPropagation()
},
updateMarkerLabelStyle (id, style) {
const className = 'uni-map-marker-label-' + id
let styleEl = document.getElementById(className)
......
......@@ -18,9 +18,8 @@ export function createCallout (maps) {
this.Text = new maps.Text({
text: option.content,
anchor: 'bottom-center', // 设置文本标记锚点
offset: new maps.Pixel(0, option.offsetY),
offset: new maps.Pixel(0, option.offsetY - 16),
style: {
'margin-bottom': '1rem',
padding: (option.padding || 8) + 'px',
'line-height': (option.fontSize || 14) + 'px',
'border-radius': (option.borderRadius || 0) + 'px',
......@@ -33,14 +32,22 @@ export function createCallout (maps) {
},
position: option.position
})
maps.event.addListener(this.Text, 'click', () => {
this.callback(this.parent)
// 不通过 addListener 方式绑定事件,为了规避高德地图覆盖物点击触发map点击问题
this.Text.dom.addEventListener('click', e => {
handleAMapTextClick(this, e)
})
this.Text.dom.addEventListener('touchend', e => {
handleAMapTextClick(this, e)
})
this.Text.setMap(option.map)
}
function handleAMapTextClick (self, e) {
self.callback(e, self.parent)
e.stopPropagation()
}
function removeAMapText () {
if (this.Text) {
this.option.map.remove(this.Text)
......
......@@ -466,12 +466,6 @@ const protocols = { // 需要做转换的 API 列表
hideHomeButton: {
name: 'hideBackHome'
},
saveImageToPhotosAlbum: {
name: 'saveImage',
args: {
filePath: 'url'
}
},
saveVideoToPhotosAlbum: {
args: {
filePath: 'src'
......
......@@ -7,6 +7,7 @@ import {
import {
initData,
initHooks,
initUnknownHooks,
handleEvent,
initBehaviors,
initVueComponent,
......@@ -93,6 +94,7 @@ export default function parsePage (vuePageOptions) {
}
initHooks(pageOptions, hooks, vuePageOptions)
initUnknownHooks(pageOptions, vuePageOptions)
if (Array.isArray(vueOptions.wxsCallMethods)) {
vueOptions.wxsCallMethods.forEach(callMethod => {
......
......@@ -2,6 +2,7 @@ import Vue from 'vue'
import {
initHooks,
initUnknownHooks,
initMocks
} from 'uni-wrapper/util'
......@@ -190,6 +191,7 @@ export default function parseBaseApp (vm, {
initAppLocale(Vue, vm, normalizeLocale(__GLOBAL__.getSystemInfoSync().language) || LOCALE_EN)
initHooks(appOptions, hooks)
initUnknownHooks(appOptions, vm.$options)
return appOptions
}
......@@ -4,6 +4,7 @@ import {
import {
initHooks,
initUnknownHooks,
PAGE_EVENT_HOOKS
} from 'uni-wrapper/util'
......@@ -27,6 +28,7 @@ export default function parseBasePage (vuePageOptions, {
})
initHooks(pageOptions.methods, hooks, vuePageOptions)
initUnknownHooks(pageOptions.methods, vuePageOptions)
pageOptions.methods.onLoad = function (query) {
this.options = query
......@@ -40,4 +42,4 @@ export default function parseBasePage (vuePageOptions, {
}
return pageOptions
}
}
......@@ -7,6 +7,7 @@ import {
import {
initData,
initHooks,
initUnknownHooks,
handleEvent,
initBehaviors,
initVueComponent,
......@@ -80,6 +81,7 @@ export default function parsePage (vuePageOptions) {
}
initHooks(pageOptions, hooks, vuePageOptions)
initUnknownHooks(pageOptions, vuePageOptions)
if (Array.isArray(vueOptions.wxsCallMethods)) {
vueOptions.wxsCallMethods.forEach(callMethod => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册