提交 952982cc 编写于 作者: Q qiang

Merge branch 'dev' into alpha

......@@ -3,7 +3,9 @@ const path = require('path')
const {
runByHBuilderX,
isInHBuilderX,
parseJson
parseJson,
parsePagesJson,
parseManifestJson
} = require('@dcloudio/uni-cli-shared')
const uniI18n = require('@dcloudio/uni-cli-i18n')
......@@ -32,7 +34,8 @@ module.exports = (api, options) => {
'--auto-host': 'specify automator host',
'--auto-port': 'specify automator port',
'--subpackage': 'specify subpackage',
'--plugin': 'specify plugin'
'--plugin': 'specify plugin',
'--manifest': 'build manifest.json'
}
}, async (args) => {
for (const key in defaults) {
......@@ -41,6 +44,10 @@ module.exports = (api, options) => {
}
}
if (args.manifest && process.env.UNI_PLATFORM === 'app-plus') {
return buildManifestJson()
}
const platforms = ['mp-weixin', 'mp-qq', 'mp-baidu', 'mp-alipay', 'mp-toutiao', 'mp-lark']
if (args.subpackage && platforms.includes(process.env.UNI_PLATFORM)) {
process.env.UNI_SUBPACKGE = args.subpackage
......@@ -135,7 +142,10 @@ async function build (args, api, options) {
log()
if (!runByHBuilderX && !runByAliIde) {
logWithSpinner(uniI18n.__('pluginUni.startCompileProjectToPlatform', { 0: process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM, 1: process.env.UNI_MP_PLUGIN ? uniI18n.__('plugin') : uniI18n.__('platform') }))
logWithSpinner(uniI18n.__('pluginUni.startCompileProjectToPlatform', {
0: process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM,
1: process.env.UNI_MP_PLUGIN ? uniI18n.__('plugin') : uniI18n.__('platform')
}))
}
const targetDir = api.resolve(options.outputDir)
......@@ -161,7 +171,8 @@ async function build (args, api, options) {
process.env.UNI_USING_V3_NATIVE ||
(process.UNI_NVUE_ENTRY && Object.keys(process.UNI_NVUE_ENTRY).length)
) {
webpackConfigs.push(require('@dcloudio/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js')(process.UNI_NVUE_ENTRY))
webpackConfigs.push(require('@dcloudio/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js')(process
.UNI_NVUE_ENTRY))
}
return new Promise((resolve, reject) => {
......@@ -178,7 +189,8 @@ async function build (args, api, options) {
return reject('Build failed with errors.')
}
if (!args.silent && (process.env.UNI_PLATFORM !== 'app-plus' || process.env.UNI_AUTOMATOR_WS_ENDPOINT)) {
if (!args.silent && (process.env.UNI_PLATFORM !== 'app-plus' || process.env
.UNI_AUTOMATOR_WS_ENDPOINT)) {
const targetDirShort = path.relative(
api.service.context,
process.env.UNI_OUTPUT_DIR
......@@ -195,7 +207,8 @@ async function build (args, api, options) {
console.log('https://uniapp.dcloud.io/uniCloud/hosting')
}
} else {
const dirMsg = runByHBuilderX ? '' : `The ${chalk.cyan(targetDirShort)} directory is ready. `
const dirMsg = runByHBuilderX ? ''
: `The ${chalk.cyan(targetDirShort)} directory is ready. `
done(`Build complete. ${dirMsg}Watching for changes...`)
}
}
......@@ -221,7 +234,9 @@ function analysisPluginDir () {
if (!fs.pathExistsSync(pluginJsonPath)) {
console.log()
console.error(uniI18n.__('pluginUni.fileNoExistsCheckAfterRetry', { 0: pluginJsonName }))
console.error(uniI18n.__('pluginUni.fileNoExistsCheckAfterRetry', {
0: pluginJsonName
}))
console.log()
process.exit(0)
}
......@@ -235,8 +250,35 @@ function analysisPluginDir () {
if (UNI_MP_PLUGIN_MAIN && !fs.pathExistsSync(mainFilePath)) {
console.log()
console.error(uniI18n.__('pluginUni.entryDileNoExistsCheckAfterRetry', { 0: UNI_MP_PLUGIN_MAIN }))
console.error(uniI18n.__('pluginUni.entryDileNoExistsCheckAfterRetry', {
0: UNI_MP_PLUGIN_MAIN
}))
console.log()
process.exit(0)
}
}
function buildManifestJson () {
const fs = require('fs-extra')
const inputDir = process.env.UNI_INPUT_DIR
const outputDir = process.env.UNI_OUTPUT_DIR
const pagesJsonPath = path.resolve(inputDir, 'pages.json')
const manifestJsonPath = path.resolve(inputDir, 'manifest.json')
const pagesJson = parsePagesJson(fs.readFileSync(pagesJsonPath, 'utf8'))
const manifestJson = parseManifestJson(fs.readFileSync(manifestJsonPath, 'utf8'))
const res = require('@dcloudio/webpack-uni-pages-loader/lib/platforms/app-plus/index.js')(pagesJson,
manifestJson,
false)
if (res && res[0]) {
fs.outputFileSync(
path.resolve(outputDir, 'manifest.json'),
res[0].content
)
}
const {
done
} = require('@vue/cli-shared-utils')
done('Build complete.')
}
......@@ -131,7 +131,7 @@ export default {
w = img.width / 2
h = img.height / 2
}
const top = h - (h - y)
const top = h - (h - y * h)
if ('MarkerImage' in maps) {
icon = new maps.MarkerImage(
img.src,
......@@ -159,29 +159,34 @@ export default {
}
let label
if (labelOpt.content) {
const labelStyle = {
borderColor: labelOpt.borderColor,
borderWidth: (Number(labelOpt.borderWidth) || 0) + 'px',
padding: (Number(labelOpt.padding) || 0) + 'px',
borderRadius: (Number(labelOpt.borderRadius) || 0) + 'px',
backgroundColor: labelOpt.bgColor,
color: labelOpt.color,
fontSize: (labelOpt.fontSize || 14) + 'px',
lineHeight: (labelOpt.fontSize || 14) + 'px',
marginLeft: (Number(labelOpt.anchorX || labelOpt.x) || 0) + 'px',
marginTop: (Number(labelOpt.anchorY || labelOpt.y) || 0) + 'px'
}
if ('Label' in maps) {
label = new maps.Label({
position: position,
map: map,
clickable: false,
content: labelOpt.content,
style: {
border: 'none',
padding: '8px',
background: 'none',
color: labelOpt.color,
fontSize: (labelOpt.fontSize || 14) + 'px',
lineHeight: (labelOpt.fontSize || 14) + 'px',
marginLeft: labelOpt.x,
marginTop: labelOpt.y
}
style: labelStyle
})
marker.label = label
} else if ('setLabel' in marker) {
const className = this.updateMarkerLabelStyle(this.id, labelStyle)
marker.setLabel({
text: labelOpt.content,
color: labelOpt.color,
fontSize: (labelOpt.fontSize || 14) + 'px'
color: labelStyle.color,
fontSize: labelStyle.fontSize,
className
})
}
}
......@@ -189,6 +194,7 @@ export default {
let callout = marker.callout
let calloutStyle
if (calloutOpt.content || title) {
const boxShadow = '0px 0px 3px 1px rgba(0,0,0,0.5)'
calloutStyle = calloutOpt.content
? {
position,
......@@ -200,7 +206,7 @@ export default {
borderRadius: calloutOpt.borderRadius,
bgColor: calloutOpt.bgColor,
padding: calloutOpt.padding,
boxShadow: calloutOpt.boxShadow,
boxShadow: calloutOpt.boxShadow || boxShadow,
display: calloutOpt.display
}
: {
......@@ -208,7 +214,7 @@ export default {
map,
top,
content: title,
boxShadow: '0px 0px 3px 1px rgba(0,0,0,0.5)'
boxShadow: boxShadow
}
if (callout) {
callout.setOption(calloutStyle)
......@@ -231,12 +237,39 @@ export default {
}
}
}
img.src = getRealPath(option.iconPath)
if (option.iconPath) {
img.src = getRealPath(option.iconPath)
} else {
console.error('Marker.iconPath is required.')
}
},
updateMarkerLabelStyle (id, style) {
const className = 'uni-map-marker-label-' + id
let styleEl = document.getElementById(className)
if (!styleEl) {
styleEl = document.createElement('style')
styleEl.id = className
document.head.appendChild(styleEl)
this.$once('hook:destroyed', () => {
styleEl.remove()
})
}
const newStyle = Object.assign({}, style, {
position: 'absolute',
top: '70px',
borderStyle: 'solid'
})
const div = document.createElement('div')
Object.keys(newStyle).forEach(key => {
div.style[key] = newStyle[key] || ''
})
styleEl.innerText = `.${className}{${div.getAttribute('style')}}`
return className
},
removeMarker () {
const marker = this._marker
if (marker) {
if (marker.label) {
if (marker.label && 'setMap' in marker.label) {
marker.label.setMap(null)
}
if (marker.callout) {
......
......@@ -107,6 +107,11 @@ export function createCallout (maps) {
destroy = onRemove
}
Callout.prototype = overlay
const prototype = Callout.prototype
for (const key in overlay) {
if (!(key in prototype)) {
prototype[key] = overlay[key]
}
}
return Callout
}
......@@ -61,7 +61,7 @@ function initScopedSlotsParams () {
const has = center[vueId]
if (!has) {
parents[vueId] = this
this.$on('hook:destory', () => {
this.$on('hook:destroyed', () => {
delete parents[vueId]
})
}
......@@ -75,7 +75,7 @@ function initScopedSlotsParams () {
return key ? object[key] : object
} else {
parents[vueId] = this
this.$on('hook:destory', () => {
this.$on('hook:destroyed', () => {
delete parents[vueId]
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册