提交 9e09cee1 编写于 作者: Q qiang

Merge branch 'dev' into alpha

......@@ -122,6 +122,37 @@ global['__wxVueOptions'] = {
source: '../icon/loading.vue'
}
])
assertCodegen(
`import myButton from '@/components/my-button/my-button.vue';
export default {
components: {
myButton
}
}
import VanButton from '../button/index.vue'
import VanSearch from '../search/index.vue'
exports.default.components = Object.assign({
'van-button': VanButton,
'van-search': VanSearch,
},exports.default.components || {})`,
[
{
name: 'van-button',
value: 'VanButton',
source: '../button/index.vue'
},
{
name: 'van-search',
value: 'VanSearch',
source: '../search/index.vue'
},
{
name: 'myButton',
value: 'myButton',
source: '@/components/my-button/my-button.vue'
}
])
})
it('parse global component', () => {
......@@ -147,4 +178,4 @@ global['__wxVueOptions'] = {
source: '@/components/tab-nvue/mediaList.vue'
}], false)
})
})
})
......@@ -34,15 +34,16 @@ function handleObjectExpression (declaration, path, state) {
}
}
function handleComponentsObjectExpression (componentsObjExpr, path, state) {
function handleComponentsObjectExpression (componentsObjExpr, path, state, prepend) {
const properties = componentsObjExpr.properties
.filter(prop => t.isObjectProperty(prop) && t.isIdentifier(prop.value))
state.components = parseComponents(properties.map(prop => {
const components = parseComponents(properties.map(prop => {
return {
name: prop.key.name || prop.key.value,
value: prop.value.name
}
}), path.scope.bindings, path)
state.components = prepend ? components.concat(state.components) : components
}
module.exports = function (ast, state = {
......@@ -74,7 +75,7 @@ module.exports = function (ast, state = {
rightExpression.arguments.length === 2 &&
t.isObjectExpression(rightExpression.arguments[0])
) {
handleComponentsObjectExpression(rightExpression.arguments[0], path, state)
handleComponentsObjectExpression(rightExpression.arguments[0], path, state, true)
}
},
ExportDefaultDeclaration (path) {
......@@ -105,4 +106,4 @@ module.exports = function (ast, state = {
ast,
state
}
}
}
const fs = require('fs')
const path = require('path')
const {
removeExt,
......@@ -50,8 +51,10 @@ function findComponentModuleId (modules, concatenatedModules, resource, altResou
resource
}
let lastComponents = []
// TODO 解决方案不太理想
module.exports = function generateComponent (compilation) {
const curComponents = []
const components = getComponentSet()
if (components.size) {
const assets = compilation.assets
......@@ -62,6 +65,7 @@ module.exports = function generateComponent (compilation) {
Object.keys(assets).forEach(name => {
if (components.has(name.replace('.js', ''))) {
curComponents.push(name.replace('.js', ''))
const chunkName = name.replace('.js', '-create-component')
let moduleId = ''
......@@ -107,4 +111,35 @@ module.exports = function generateComponent (compilation) {
}
})
}
if (process.env.UNI_FEATURE_OBSOLETE !== false) {
if (lastComponents.length) {
for (const name of lastComponents) {
if (!curComponents.includes(name)) {
removeUnusedComponent(name) // 组件被移除
}
}
}
for (const name of curComponents) {
if (!lastComponents.includes(name)) {
addComponent(name) // 新增组件
}
}
lastComponents = curComponents
}
}
function addComponent (name) {
const bakJson = path.join(process.env.UNI_OUTPUT_DIR, name + '.bak.json')
if (fs.existsSync(bakJson)) {
try {
fs.renameSync(bakJson, path.join(process.env.UNI_OUTPUT_DIR, name + '.json'))
} catch (e) {}
}
}
function removeUnusedComponent (name) {
try {
fs.renameSync(path.join(process.env.UNI_OUTPUT_DIR, name + '.json'), path.join(process.env.UNI_OUTPUT_DIR, name +
'.bak.json'))
} catch (e) {}
}
......@@ -10,7 +10,7 @@ module.exports = function (pagesJson, manifestJson) {
} = require('../mp')(pagesJson, manifestJson, require('./project.config.json'))
const baseJson = {
minPlatformVersion: 1053
minPlatformVersion: 1070
}
manifestJson.name && (baseJson.name = manifestJson.name)
manifestJson.versionName && (baseJson.versionName = manifestJson.versionName)
......
......@@ -14,7 +14,7 @@
"libVersion": "",
"appid": "touristappid",
"projectname": "",
"quickappRoot": "",
"quickappRoot": "./",
"condition": {
"search": {
"current": -1,
......
......@@ -106,8 +106,9 @@ if (pixelRatio !== 1) {
args[1] *= pixelRatio
args[2] *= pixelRatio
this.font = this.font.replace(
/(\d+)(px|em|rem|pt)/g,
var font = this.font
this.font = font.replace(
/(\d+\.?\d*)(px|em|rem|pt)/g,
function (w, m, u) {
return (m * pixelRatio) + u
}
......@@ -115,12 +116,7 @@ if (pixelRatio !== 1) {
_super.apply(this, args)
this.font = this.font.replace(
/(\d+)(px|em|rem|pt)/g,
function (w, m, u) {
return (m / pixelRatio) + u
}
)
this.font = font
}
})(proto.fillText)
......@@ -134,21 +130,16 @@ if (pixelRatio !== 1) {
args[1] *= pixelRatio // x
args[2] *= pixelRatio // y
this.font = this.font.replace(
/(\d+)(px|em|rem|pt)/g,
var font = this.font
this.font = font.replace(
/(\d+\.?\d*)(px|em|rem|pt)/g,
function (w, m, u) {
return (m * pixelRatio) + u
}
)
_super.apply(this, args)
this.font = this.font.replace(
/(\d+)(px|em|rem|pt)/g,
function (w, m, u) {
return (m / pixelRatio) + u
}
)
this.font = font
}
})(proto.strokeText)
......@@ -168,4 +159,4 @@ export function wrapper (canvas) {
canvas.width = canvas.offsetWidth * pixelRatio
canvas.height = canvas.offsetHeight * pixelRatio
canvas.getContext('2d').__hidpi__ = true
}
}
......@@ -360,7 +360,7 @@ export default {
} else {
// 解决 PLUS-APP(wkwebview)以及 H5 图像跨域问题(H5图像响应头需包含access-control-allow-origin)
if (window.plus && src.indexOf('http://') !== 0 && src.indexOf('https://') !==
0) {
0 && !/^data:.*,.*/.test(src)) {
loadFile(src)
} else if (/^data:.*,.*/.test(src)) {
self._images[src].src = src
......
......@@ -80,7 +80,9 @@ export function createWebview (path, routeOptions, query) {
webviewStyle.uniPageUrl = getUniPageUrl(path, query)
if (process.env.NODE_ENV !== 'production') {
console.log('[uni-app] createWebview', webviewId, path, webviewStyle)
}
}
// android 需要使用
webviewStyle.isTab = !!routeOptions.meta.isTabBar
return plus.webview.create('', String(webviewId), webviewStyle, {
nvue: true
})
......
......@@ -17,7 +17,8 @@ import native from '../../mixins/native'
const methods = [
'play',
'pause',
'pause',
'stop',
'seek',
'sendDanmu',
'playbackRate',
......
import {
isPlainObject
} from 'uni-shared'
// 不支持的 API 列表
const todos = [
// 'getRecorderManager',
......@@ -86,6 +89,7 @@ const protocols = { // 需要做转换的 API 列表
request: {
name: my.canIUse('request') ? 'request' : 'httpRequest',
args (fromArgs) {
const method = fromArgs.method || 'GET'
if (!fromArgs.header) { // 默认增加 header 参数,方便格式化 content-type
fromArgs.header = {}
}
......@@ -103,8 +107,8 @@ const protocols = { // 需要做转换的 API 列表
}
},
data (data) {
// 钉钉在content-type为application/json时,不会自动序列化
if (my.dd && headers['content-type'].indexOf('application/json') === 0) {
// 钉钉小程序在content-type为application/json时需上传字符串形式data,使用my.dd在真机运行钉钉小程序时不能正确判断
if (my.canIUse('saveFileToDingTalk') && method.toUpperCase() === 'POST' && headers['content-type'].indexOf('application/json') === 0 && isPlainObject(data)) {
return {
name: 'data',
value: JSON.stringify(data)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册