提交 e6fba19a 编写于 作者: Q qiang

Merge branch 'v3' of github.com:dcloudio/uni-app into v3

此差异已折叠。
......@@ -190,6 +190,7 @@ const warningMsg =
: `uni-app将于2019年11月1日起停止支持非自定义组件模式 [详情](https://ask.dcloud.net.cn/article/36385)`
const needWarning = !platformOptions.usingComponents || usingComponentsAbsent
let hasNVue = false
// 输出编译器版本等信息
if (process.env.UNI_USING_NATIVE) {
console.log('当前nvue编译模式:' + (isNVueCompiler ? 'uni-app' : 'weex') +
......@@ -207,9 +208,10 @@ if (process.env.UNI_USING_NATIVE) {
info = '编译器版本:' + pagesPkg['uni-app']['compilerVersion'] + (process.env.UNI_USING_V3 ? '(v3)' : '')
}
const glob = require('glob')
if (glob.sync('pages/**/*.nvue', {
hasNVue = !!glob.sync('pages/**/*.nvue', {
cwd: process.env.UNI_INPUT_DIR
}).length) {
}).length
if (hasNVue) {
console.log(info)
console.log(modeText)
if (needWarning) {
......@@ -231,6 +233,15 @@ if (process.env.UNI_USING_NATIVE) {
}
} catch (e) {}
}
if (process.env.NODE_ENV !== 'production') { // 运行模式性能提示
let perfMsg = `请注意运行模式下,因日志输出、sourcemap以及未压缩源码等原因,性能和包体积,均不如发行模式。`
if (hasNVue) { // app-nvue
perfMsg = perfMsg + `尤其是app-nvue的sourcemap影响较大`
} else if (process.env.UNI_PLATFORM.indexOf('mp-') === 0) { // 小程序
perfMsg = perfMsg + `若要正式发布,请点击发行菜单或使用cli发布命令进行发布`
}
console.log(perfMsg)
}
const moduleAlias = require('module-alias')
......
import {
parseProperties
} from './parser'
export default function createVueComponent (mpComponentOptions) {
const vueComponentOptions = {
watch: {},
mpObservers: []
}
parseProperties(mpComponentOptions.properties, vueComponentOptions)
return vueComponentOptions
}
export function parseBehaviors (behaviors, vueComponentOptions) {
if (!behaviors) {
}
}
export function parseData (data, vueComponentOptions) {
if (!data) {
return
}
const dataJson = JSON.stringify(data)
vueComponentOptions.data = function () {
return JSON.parse(dataJson)
}
}
export function parseDefinitionFilter (definitionFilter, vueComponentOptions) {
if (!definitionFilter) {
}
}
export function parseExternalClasses (externalClasses, vueComponentOptions) {
if (!externalClasses) {
}
}
export * from './proerties-parser'
export * from './data-parser'
export * from './observers-parser'
export * from './behaviors-parser'
export * from './methods-parser'
export * from './lifecycle-parser'
export * from './relations-parser'
export * from './external-classes-parser'
export * from './options-parser'
export * from './lifetimes-parser'
export * from './page-lifetimes-parser'
export * from './definition-filter-parser'
export function parseLifecycle (mpComponentOptions, vueComponentOptions) {
}
export function parseLifetimes (lifetimes, vueComponentOptions) {
if (!lifetimes) {
}
}
export function parseMethods (methods, vueComponentOptions) {
if (!methods) {
return
}
vueComponentOptions.methods = methods
}
function parseSinglePath (path) {
return path.split('.')
}
function parseMultiPaths (paths) {
return paths.split(',').map(path => parseSinglePath(path))
}
export function parseObservers (observers, vueComponentOptions) {
if (!observers) {
return
}
const {
mpObservers
} = vueComponentOptions
Object.keys(observers).forEach(path => {
mpObservers.push({
paths: parseMultiPaths(path),
observer: observers[path]
})
})
}
export function parseOptions (options, vueComponentOptions) {
if (!options) {
}
}
export function parsePageLifetimes (pageLifetimes, vueComponentOptions) {
if (!pageLifetimes) {
}
}
import {
hasOwn
} from 'uni-shared'
function parseProperty (name, property, watch) {
const type = [property.type]
if (Array.isArray(property.optionalTypes)) {
type.push(...property.optionalTypes)
}
const prop = Object.create(null)
prop.type = type
if (hasOwn(property, 'value')) {
prop['default'] = prop.value
}
if (hasOwn(property, 'observer')) {
watch[name] = property.observer
}
return prop
}
export function parseProperties (properties, vueComponentOptions) {
if (!properties) {
return
}
const props = Object.create(null)
const {
watch
} = vueComponentOptions
Object.keys(properties).forEach(name => {
props[name] = parseProperty(name, properties[name], watch)
})
vueComponentOptions.props = props
}
export function parseRelations (relations, vueComponentOptions) {
if (!relations) {
}
}
......@@ -59,6 +59,30 @@ const handleData = {
}
}
function broadcast (vm, componentName, eventName, ...params) {
vm.$children.forEach(child => {
const name = child.$options.name && child.$options.name.substr(1)
if (~componentName.indexOf(name)) {
child.$emit(eventName, ...params)
}
broadcast(child, componentName, eventName, ...params)
})
}
const NATIVE_COMPONENTS = ['Camera', 'LivePlayer', 'LivePusher', 'Map', 'Video']
function updateView () {
const pages = getCurrentPages()
const pageVm = pages[0] && pages[0].$vm
pageVm && broadcast(
pageVm,
NATIVE_COMPONENTS,
'uni-view-update'
)
}
window.addEventListener('resize', updateView)
function vdSync ({
data,
options
......@@ -71,8 +95,9 @@ function vdSync ({
handleData[data[0]](data[1])
})
vd.flush()
isVdCallback && Vue.nextTick(() => {
UniViewJSBridge.publishHandler(VD_SYNC_CALLBACK)
Vue.nextTick(() => {
updateView()
isVdCallback && UniViewJSBridge.publishHandler(VD_SYNC_CALLBACK)
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册