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