提交 7751d337 编写于 作者: fxy060608's avatar fxy060608

Merge branch 'dev' of https://github.com/dcloudio/uni-app into alpha

# Conflicts:
#	packages/uni-h5/dist/index.umd.min.js
...@@ -68,6 +68,11 @@ function processPagesJson (pagesJson, loader = { ...@@ -68,6 +68,11 @@ function processPagesJson (pagesJson, loader = {
console.error(`${pagesJsonJsFileName} 必须导出 function`) console.error(`${pagesJsonJsFileName} 必须导出 function`)
} }
} }
// 将 subpackages 转换成 subPackages
if (pagesJson.subpackages && !pagesJson.subPackages) {
pagesJson.subPackages = pagesJson.subpackages
delete pagesJson.subpackages
}
let uniNVueEntryPagePath let uniNVueEntryPagePath
if (pagesJson.pages && pagesJson.pages.length) { // 如果首页是 nvue if (pagesJson.pages && pagesJson.pages.length) { // 如果首页是 nvue
......
...@@ -10,12 +10,6 @@ const defaultOptions = { ...@@ -10,12 +10,6 @@ const defaultOptions = {
loader: 'file-loader', loader: 'file-loader',
options: { options: {
publicPath (url, resourcePath, context) { publicPath (url, resourcePath, context) {
if (
process.env.UNI_PLATFORM === 'app-plus' &&
process.env.UNI_USING_V3
) { // app-plus v3 下路径不能以/开头
return normalizePath(path.relative(process.env.UNI_INPUT_DIR, resourcePath))
}
return '/' + normalizePath(path.relative(process.env.UNI_INPUT_DIR, resourcePath)) return '/' + normalizePath(path.relative(process.env.UNI_INPUT_DIR, resourcePath))
}, },
outputPath (url, resourcePath, context) { outputPath (url, resourcePath, context) {
......
...@@ -46,14 +46,15 @@ module.exports = { ...@@ -46,14 +46,15 @@ module.exports = {
if (!state.scopedSlots) { if (!state.scopedSlots) {
state.scopedSlots = {} state.scopedSlots = {}
} }
let componentName = `${ownerName}-${parentName}-${slotName}` const baseName = `${ownerName}-${parentName}-${slotName}`
if (!hasOwn(state.scopedSlots, componentName)) { let componentName = baseName
state.scopedSlots[componentName] = 0 if (!hasOwn(state.scopedSlots, baseName)) {
state.scopedSlots[baseName] = 0
} }
if (state.scopedSlots[componentName]) { if (state.scopedSlots[baseName]) {
componentName = componentName + state.scopedSlots[componentName] componentName = baseName + state.scopedSlots[baseName]
} }
state.scopedSlots[componentName]++ state.scopedSlots[baseName]++
parentNode.attr['generic:scoped-slots-' + slotName] = componentName parentNode.attr['generic:scoped-slots-' + slotName] = componentName
if (!parentNode.attr.generic) { if (!parentNode.attr.generic) {
parentNode.attr.generic = {} parentNode.attr.generic = {}
......
...@@ -172,7 +172,7 @@ describe('codegen', () => { ...@@ -172,7 +172,7 @@ describe('codegen', () => {
) )
assertCodegen( assertCodegen(
'<image src="../static/logo.png"/>', '<image src="../static/logo.png"/>',
`with(this){return _c('image',{attrs:{"src":_$s(0,'a-src',"/"+require("../static/logo.png")),"_i":0}})}` `with(this){return _c('image',{attrs:{"src":_$s(0,'a-src',require("../static/logo.png")),"_i":0}})}`
) )
assertCodegen( assertCodegen(
'<image src="@/static/logo.png"/>', '<image src="@/static/logo.png"/>',
......
...@@ -16,7 +16,7 @@ function assertCodegen (template, templateCode, renderCode = 'with(this){}', opt ...@@ -16,7 +16,7 @@ function assertCodegen (template, templateCode, renderCode = 'with(this){}', opt
renderCode(res) renderCode(res)
} else { } else {
expect(res.render).toBe(renderCode) expect(res.render).toBe(renderCode)
} }
} }
describe('mp:compiler-mp-weixin', () => { describe('mp:compiler-mp-weixin', () => {
...@@ -72,7 +72,7 @@ describe('mp:compiler-mp-weixin', () => { ...@@ -72,7 +72,7 @@ describe('mp:compiler-mp-weixin', () => {
}) })
it('generate scoped slot', () => { it('generate scoped slot', () => {
assertCodegen(// TODO vue-id assertCodegen( // TODO vue-id
'<span><slot v-bind:user="user">{{ user.lastName }}</slot></span>', '<span><slot v-bind:user="user">{{ user.lastName }}</slot></span>',
'<label class="_span"><block wx:if="{{$slots.default}}"><scoped-slots-default user="{{user}}" bind:__l="__l"></scoped-slots-default></block><block wx:else>{{user.lastName}}</block></label>', '<label class="_span"><block wx:if="{{$slots.default}}"><scoped-slots-default user="{{user}}" bind:__l="__l"></scoped-slots-default></block><block wx:else>{{user.lastName}}</block></label>',
function (res) { function (res) {
...@@ -86,11 +86,31 @@ describe('mp:compiler-mp-weixin', () => { ...@@ -86,11 +86,31 @@ describe('mp:compiler-mp-weixin', () => {
expect(res.componentGenerics['scoped-slots-header']).toBe(true) expect(res.componentGenerics['scoped-slots-header']).toBe(true)
} }
) )
}) })
it('generate page-meta', () => { it('generate page-meta', () => {
assertCodegen(// TODO vue-id assertCodegen( // TODO vue-id
'<view><page-meta/><view><button></button></view></view>', '<view><page-meta/><view><button></button></view></view>',
'<page-meta vue-id="551070e6-1" bind:__l="__l"></page-meta><view><button></button></view>' '<page-meta vue-id="551070e6-1" bind:__l="__l"></page-meta><view><button></button></view>'
) )
})
it('generate v-slot', () => {
assertCodegen(
`<view>
<slot-comp v-slot:test="{label}">
<view>{{label}}</view>
</slot-comp>
<slot-comp v-slot:test="{label}">
<view>{{label}}</view>
</slot-comp>
<slot-comp v-slot:test="{label}">
<view>{{label}}</view>
</slot-comp>
<slot-comp v-slot:test="{label}">
<view class="red">{{label}}</view>
</slot-comp>
</view>`,
'<view><slot-comp generic:scoped-slots-test="test-slot-comp-test" vue-id="551070e6-1" bind:__l="__l" vue-slots="{{[\'test\']}}"></slot-comp><slot-comp generic:scoped-slots-test="test-slot-comp-test1" vue-id="551070e6-2" bind:__l="__l" vue-slots="{{[\'test\']}}"></slot-comp><slot-comp generic:scoped-slots-test="test-slot-comp-test2" vue-id="551070e6-3" bind:__l="__l" vue-slots="{{[\'test\']}}"></slot-comp><slot-comp generic:scoped-slots-test="test-slot-comp-test3" vue-id="551070e6-4" bind:__l="__l" vue-slots="{{[\'test\']}}"></slot-comp></view>'
)
}) })
}) })
...@@ -19,7 +19,20 @@ const scopedPath = path.resolve(__dirname, '../../') ...@@ -19,7 +19,20 @@ const scopedPath = path.resolve(__dirname, '../../')
const compiler = require('../lib') const compiler = require('../lib')
const res = compiler.compile( const res = compiler.compile(
` `
<video controls=""/> <view>
<slot-comp v-slot:test="{label}">
<view>{{label}}</view>
</slot-comp>
<slot-comp v-slot:test="{label}">
<view>{{label}}</view>
</slot-comp>
<slot-comp v-slot:test="{label}">
<view>{{label}}</view>
</slot-comp>
<slot-comp v-slot:test="{label}">
<view class="red">{{label}}</view>
</slot-comp>
</view>
`, { `, {
miniprogram: true, miniprogram: true,
resourcePath: '/User/fxy/Documents/test.wxml', resourcePath: '/User/fxy/Documents/test.wxml',
......
...@@ -43,14 +43,14 @@ function urlToRequire (url) { ...@@ -43,14 +43,14 @@ function urlToRequire (url) {
* @param urlString an url as a string * @param urlString an url as a string
*/ */
function parseUriParts (urlString) { function parseUriParts (urlString) {
// initialize return value // initialize return value
/* eslint-disable node/no-deprecated-api */ /* eslint-disable node/no-deprecated-api */
const returnValue = url.parse('') const returnValue = url.parse('')
if (urlString) { if (urlString) {
// A TypeError is thrown if urlString is not a string // A TypeError is thrown if urlString is not a string
// @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost // @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
if (typeof urlString === 'string') { if (typeof urlString === 'string') {
// check is an uri // check is an uri
/* eslint-disable node/no-deprecated-api */ /* eslint-disable node/no-deprecated-api */
return url.parse(urlString) // take apart the uri return url.parse(urlString) // take apart the uri
} }
...@@ -72,14 +72,13 @@ function rewrite (attr, name, options) { ...@@ -72,14 +72,13 @@ function rewrite (attr, name, options) {
const needRequire = options.service || options.view || options.h5 const needRequire = options.service || options.view || options.h5
if (needRequire) { if (needRequire) {
attr.value = urlToRequire(attr.value.slice(1, -1)) attr.value = urlToRequire(attr.value.slice(1, -1))
if (attr.value.startsWith('require("')) { // require if (
// v3 需要增加前缀 / options.h5 &&
if (options.service || options.view) { options.publicPath === './' &&
attr.value = `"/"+${attr.value}` attr.value.startsWith('require("')
} else if (options.h5 && options.publicPath === './') { ) { // require
// h5 且 publicPath 为 ./ (仅生产模式可能为./) // h5 且 publicPath 为 ./ (仅生产模式可能为./)
attr.value = `(${attr.value}).substr(1)` attr.value = `(${attr.value}).substr(1)`
}
} }
} }
return true return true
......
...@@ -53,8 +53,13 @@ module.exports = (api, options) => { ...@@ -53,8 +53,13 @@ module.exports = (api, options) => {
vueConfig = vueConfig(options, api) vueConfig = vueConfig(options, api)
} }
if (options.pages) { // 允许 vue.config.js pages 覆盖 if (options.pages) {
delete vueConfig.pages // h5平台 允许 vue.config.js pages 覆盖,其他平台移除 pages 配置
if (process.env.UNI_PLATFORM === 'h5') {
delete vueConfig.pages
} else {
delete options.pages
}
} }
Object.assign(options, { // TODO 考虑非 HBuilderX 运行时,可以支持自定义输出目录 Object.assign(options, { // TODO 考虑非 HBuilderX 运行时,可以支持自定义输出目录
......
'use strict'
module.exports = function (url, options) {
if (!options) {
// eslint-disable-next-line no-param-reassign
options = {}
} // eslint-disable-next-line no-underscore-dangle, no-param-reassign
url = url && url.__esModule ? url.default : url
if (typeof url !== 'string') {
return url
} // If url is already wrapped in quotes, remove them
if (/^['"].*['"]$/.test(url)) {
// eslint-disable-next-line no-param-reassign
url = url.slice(1, -1)
}
if (options.hash) {
// eslint-disable-next-line no-param-reassign
url += options.hash
} // Should url be wrapped?
// See https://drafts.csswg.org/css-values-3/#urls
if (/["'() \t\n]/.test(url) || options.needQuotes) {
return '"'.concat(url.replace(/"/g, '\\"').replace(/\n/g, '\\n'), '"')
}
if (url.indexOf('/') === 0) {
return url.substr(1)
}
return url
}
...@@ -2,8 +2,8 @@ const fs = require('fs') ...@@ -2,8 +2,8 @@ const fs = require('fs')
const path = require('path') const path = require('path')
const mkdirp = require('mkdirp') const mkdirp = require('mkdirp')
const loaderUtils = require('loader-utils') const loaderUtils = require('loader-utils')
require('./error-reporting') require('./error-reporting')
const hasOwnProperty = Object.prototype.hasOwnProperty const hasOwnProperty = Object.prototype.hasOwnProperty
...@@ -335,7 +335,8 @@ moduleAlias.addAlias('mpvue-template-compiler', '@dcloudio/vue-cli-plugin-uni/pa ...@@ -335,7 +335,8 @@ moduleAlias.addAlias('mpvue-template-compiler', '@dcloudio/vue-cli-plugin-uni/pa
// vue-loader // vue-loader
moduleAlias.addAlias('vue-loader', '@dcloudio/vue-cli-plugin-uni/packages/vue-loader') moduleAlias.addAlias('vue-loader', '@dcloudio/vue-cli-plugin-uni/packages/vue-loader')
if (process.env.UNI_USING_V3 && process.env.UNI_PLATFORM === 'app-plus') { if (process.env.UNI_USING_V3 && process.env.UNI_PLATFORM === 'app-plus') {
moduleAlias.addAlias('../runtime/getUrl.js', '@dcloudio/vue-cli-plugin-uni/lib/app-plus/getUrl.js')
moduleAlias.addAlias('vue-style-loader', '@dcloudio/vue-cli-plugin-uni/packages/app-vue-style-loader') moduleAlias.addAlias('vue-style-loader', '@dcloudio/vue-cli-plugin-uni/packages/app-vue-style-loader')
} }
......
...@@ -59,7 +59,7 @@ function getLocation (base = '/') { ...@@ -59,7 +59,7 @@ function getLocation (base = '/') {
export default { export default {
install (Vue, { install (Vue, {
routes routes
} = {}) { } = {}) {
if ( if (
__PLATFORM__ === 'h5' && __PLATFORM__ === 'h5' &&
Vue.config.devtools && Vue.config.devtools &&
...@@ -73,7 +73,11 @@ export default { ...@@ -73,7 +73,11 @@ export default {
initPolyfill(Vue) initPolyfill(Vue)
lifecycleMixin(Vue) lifecycleMixin(Vue)
/* eslint-disable no-undef */
if (typeof __UNI_ROUTER_BASE__ !== 'undefined') {
__uniConfig.router.base = __UNI_ROUTER_BASE__
}
const minId = getMinId(routes) const minId = getMinId(routes)
const router = new VueRouter({ const router = new VueRouter({
id: minId, id: minId,
...@@ -107,6 +111,7 @@ export default { ...@@ -107,6 +111,7 @@ export default {
// 需跨平台,根据用户配置 hash 或 history 来调用 // 需跨平台,根据用户配置 hash 或 history 来调用
const entryRoute = router.match(__uniConfig.router.mode === 'history' ? getLocation(__uniConfig.router.base) const entryRoute = router.match(__uniConfig.router.mode === 'history' ? getLocation(__uniConfig.router.base)
: getHash()) : getHash())
if (entryRoute.meta.name) { if (entryRoute.meta.name) {
if (entryRoute.meta.id) { if (entryRoute.meta.id) {
keepAliveInclude.push(entryRoute.meta.name + '-' + entryRoute.meta.id) keepAliveInclude.push(entryRoute.meta.name + '-' + entryRoute.meta.id)
......
...@@ -21,7 +21,7 @@ export default { ...@@ -21,7 +21,7 @@ export default {
if (key === 'top' || key === 'left') { if (key === 'top' || key === 'left') {
val = Math.max(valNumber, parentValNumber) + 'px' val = Math.max(valNumber, parentValNumber) + 'px'
} else if (key === 'width' || key === 'height') { } else if (key === 'width' || key === 'height') {
const base = key === 'width' ? 'left' : 'left' const base = key === 'width' ? 'left' : 'top'
const parentStart = parseFloat(this._nativeParent.position[base]) const parentStart = parseFloat(this._nativeParent.position[base])
const viewStart = parseFloat(this.position[base]) const viewStart = parseFloat(this.position[base])
const diff1 = Math.max(parentStart - viewStart, 0) const diff1 = Math.max(parentStart - viewStart, 0)
......
...@@ -16,8 +16,10 @@ const isIOS = /iphone|ipad|ipod/i.test(ua) ...@@ -16,8 +16,10 @@ const isIOS = /iphone|ipad|ipod/i.test(ua)
export function getSystemInfoSync () { export function getSystemInfoSync () {
var screen = window.screen var screen = window.screen
var pixelRatio = window.devicePixelRatio var pixelRatio = window.devicePixelRatio
var screenWidth = screen.width // 横屏时 iOS 获取的屏幕宽高颠倒,进行纠正
var screenHeight = screen.height var landscape = Math.abs(window.orientation) === 90
var screenWidth = Math[landscape ? 'max' : 'min'](screen.width, screen.height)
var screenHeight = Math[landscape ? 'min' : 'max'](screen.height, screen.width)
var windowWidth = Math.min(window.innerWidth, document.documentElement.clientWidth, screenWidth) var windowWidth = Math.min(window.innerWidth, document.documentElement.clientWidth, screenWidth)
var windowHeight = window.innerHeight var windowHeight = window.innerHeight
var language = navigator.language var language = navigator.language
......
<template> <template>
<uni-video <uni-video
:id="id" :id="id"
v-on="$listeners" v-on="$listeners"
> >
<div <div
ref="container" ref="container"
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
> >
<video <video
ref="video" ref="video"
:style="{opacity:!start?0.8:1,objectFit:objectFit}" :style="{objectFit:objectFit}"
:muted="muted" :muted="muted"
:loop="loop" :loop="loop"
:src="srcSync" :src="srcSync"
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<div <div
v-show="controlsShow" v-show="controlsShow"
class="uni-video-bar uni-video-bar-full" class="uni-video-bar uni-video-bar-full"
@click.stop @click.stop
> >
<div class="uni-video-controls"> <div class="uni-video-controls">
<div <div
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
class="uni-video-control-button" class="uni-video-control-button"
@click.stop="trigger" @click.stop="trigger"
/> />
<div class="uni-video-current-time"> <div class="uni-video-current-time">
{{ currentTime|time }} {{ currentTime|time }}
</div> </div>
<div <div
ref="progress" ref="progress"
...@@ -62,19 +62,19 @@ ...@@ -62,19 +62,19 @@
<div class="uni-video-progress"> <div class="uni-video-progress">
<div <div
:style="{width:buffered+'%'}" :style="{width:buffered+'%'}"
class="uni-video-progress-buffered" class="uni-video-progress-buffered"
/> />
<div <div
ref="ball" ref="ball"
:style="{left:progress+'%'}" :style="{left:progress+'%'}"
class="uni-video-ball" class="uni-video-ball"
> >
<div class="uni-video-inner" /> <div class="uni-video-inner" />
</div> </div>
</div> </div>
</div> </div>
<div class="uni-video-duration"> <div class="uni-video-duration">
{{ (duration||durationTime)|time }} {{ (duration||durationTime)|time }}
</div> </div>
</div> </div>
<div <div
...@@ -82,8 +82,8 @@ ...@@ -82,8 +82,8 @@
:class="{'uni-video-danmu-button-active':enableDanmuSync}" :class="{'uni-video-danmu-button-active':enableDanmuSync}"
class="uni-video-danmu-button" class="uni-video-danmu-button"
@click.stop="triggerDanmu" @click.stop="triggerDanmu"
> >
弹幕 弹幕
</div> </div>
<div <div
v-show="showFullscreenBtn" v-show="showFullscreenBtn"
...@@ -96,27 +96,27 @@ ...@@ -96,27 +96,27 @@
v-show="start&&enableDanmuSync" v-show="start&&enableDanmuSync"
ref="danmu" ref="danmu"
style="z-index: 0;" style="z-index: 0;"
class="uni-video-danmu" class="uni-video-danmu"
/> />
<div <div
v-if="!start" v-if="centerPlayBtnShow"
class="uni-video-cover" class="uni-video-cover"
@click.stop @click.stop
> >
<div <div
class="uni-video-cover-play-button" class="uni-video-cover-play-button"
@click.stop="play" @click.stop="play"
/> />
<p class="uni-video-cover-duration"> <p class="uni-video-cover-duration">
{{ (duration||durationTime)|time }} {{ (duration||durationTime)|time }}
</p> </p>
</div> </div>
<div <div
:class="{'uni-video-toast-volume':gestureType==='volume'}" :class="{'uni-video-toast-volume':gestureType==='volume'}"
class="uni-video-toast" class="uni-video-toast"
> >
<div class="uni-video-toast-title"> <div class="uni-video-toast-title">
音量 音量
</div> </div>
<svg <svg
class="uni-video-toast-icon" class="uni-video-toast-icon"
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
<div class="uni-video-toast-value"> <div class="uni-video-toast-value">
<div <div
:style="{width:volumeNew*100+'%'}" :style="{width:volumeNew*100+'%'}"
class="uni-video-toast-value-content" class="uni-video-toast-value-content"
> >
<div class="uni-video-toast-volume-grids"> <div class="uni-video-toast-volume-grids">
<div <div
...@@ -147,10 +147,10 @@ ...@@ -147,10 +147,10 @@
</div> </div>
<div <div
:class="{'uni-video-toast-progress':gestureType=='progress'}" :class="{'uni-video-toast-progress':gestureType=='progress'}"
class="uni-video-toast" class="uni-video-toast"
> >
<div class="uni-video-toast-title"> <div class="uni-video-toast-title">
{{ currentTimeNew|time }} / {{ durationTime|time }} {{ currentTimeNew|time }} / {{ durationTime|time }}
</div> </div>
</div> </div>
</div> </div>
...@@ -278,6 +278,10 @@ export default { ...@@ -278,6 +278,10 @@ export default {
showPlayBtn: { showPlayBtn: {
type: [Boolean, String], type: [Boolean, String],
default: true default: true
},
showCenterPlayBtn: {
type: [Boolean, String],
default: true
} }
}, },
data () { data () {
...@@ -306,8 +310,11 @@ export default { ...@@ -306,8 +310,11 @@ export default {
} }
}, },
computed: { computed: {
centerPlayBtnShow () {
return this.showCenterPlayBtn && !this.start
},
controlsShow () { controlsShow () {
return this.start && this.controls && this.controlsVisible return !this.centerPlayBtnShow && this.controls && this.controlsVisible
}, },
autoHideContorls () { autoHideContorls () {
return this.controlsShow && this.playing && !this.controlsTouching return this.controlsShow && this.playing && !this.controlsTouching
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册