提交 9c3954ea 编写于 作者: fxy060608's avatar fxy060608

feat: createIntersectionObserver

上级 313f1354
此差异已折叠。
import { initIntersectionObserverPolyfill } from './intersection-observer'
export interface RequestComponentObserverOptions {
selector?: string
rootMargin?: string
relativeToSelector?: string
}
function normalizeRect(rect: DOMRect) {
const { bottom, height, left, right, top, width } = rect || {}
return {
bottom,
height,
left,
right,
top,
width,
}
}
export function requestComponentObserver(
$el: HTMLElement,
options: UniApp.CreateIntersectionObserverOptions &
RequestComponentObserverOptions,
callback: WechatMiniprogram.IntersectionObserverObserveCallback
) {
// 为了摇树优化,不直接引入该polyfill
initIntersectionObserverPolyfill()
const root = options.relativeToSelector
? $el.querySelector(options.relativeToSelector)
: null
const intersectionObserver = new IntersectionObserver(
(entries) => {
entries.forEach((entrie) => {
callback({
intersectionRatio: entrie.intersectionRatio,
intersectionRect: normalizeRect(entrie.intersectionRect),
boundingClientRect: normalizeRect(entrie.boundingClientRect),
relativeRect: normalizeRect(entrie.rootBounds!),
time: Date.now(),
// dataset: normalizeDataset(entrie.target),
// id: entrie.target.id,
})
})
},
{
root,
rootMargin: options.rootMargin,
threshold: options.thresholds,
}
)
if (options.observeAll) {
;(intersectionObserver as any).USE_MUTATION_OBSERVER = true
const nodeList = $el.querySelectorAll(options.selector!)
for (let i = 0; i < nodeList.length; i++) {
intersectionObserver.observe(nodeList[i])
}
} else {
;(intersectionObserver as any).USE_MUTATION_OBSERVER = false
const el = $el.querySelector(options.selector!)
if (!el) {
console.warn(
`Node ${options.selector} is not found. Intersection observer will not trigger.`
)
} else {
intersectionObserver.observe(el)
}
}
return intersectionObserver
}
...@@ -38,3 +38,4 @@ export { getCurrentPageVm } from './helpers/utils' ...@@ -38,3 +38,4 @@ export { getCurrentPageVm } from './helpers/utils'
export { handlePromise } from './helpers/api/promise' export { handlePromise } from './helpers/api/promise'
export { invokeApi, wrapperReturnValue } from './helpers/interceptor' export { invokeApi, wrapperReturnValue } from './helpers/interceptor'
export { requestComponentObserver } from './helpers/requestComponentObserver'
import { extend } from '@vue/shared' import { ComponentPublicInstance } from 'vue'
import { extend, isFunction } from '@vue/shared'
import {
addIntersectionObserver,
removeIntersectionObserver,
} from '@dcloudio/uni-platform'
import { defineSyncApi } from '../../helpers/api' import { defineSyncApi } from '../../helpers/api'
import { getCurrentPageVm } from '../../helpers/utils' import { getCurrentPageVm } from '../../helpers/utils'
import { RequestComponentObserverOptions } from '../../helpers/requestComponentObserver'
const defaultOptions = { export interface AddIntersectionObserverArgs {
thresholds: [0], reqId: number
initialRatio: 0, component: ComponentPublicInstance
observeAll: false, options: ServiceIntersectionObserverOptions
} callback: WechatMiniprogram.IntersectionObserverObserveCallback
interface Margins {
bottom?: number
left?: number
right?: number
top?: number
}
interface RelativeInfo {
selector: string
margins: Margins
} }
type ObserveResultCallback = (result: UniApp.ObserveResult) => void export interface RemoveIntersectionObserverArgs {
interface requestComponentObserver {
reqId: number reqId: number
reqEnd: boolean component: ComponentPublicInstance
res: UniApp.ObserveResult
} }
let reqComponentObserverId = 1 type ServiceIntersectionObserverOptions = UniApp.CreateIntersectionObserverOptions &
RequestComponentObserverOptions
const reqComponentObserverCallbacks: Record<number, ObserveResultCallback> = {} const defaultOptions = {
thresholds: [0],
initialRatio: 0,
observeAll: false,
}
export const API_CREATE_INTERSECTION_OBSERVER = 'createIntersectionObserver' const MARGINS = ['top', 'right', 'bottom', 'left']
UniServiceJSBridge.subscribe( let reqComponentObserverId = 1
'requestComponentObserver',
({ reqId, reqEnd, res }: requestComponentObserver) => {
const callback = reqComponentObserverCallbacks[reqId]
if (callback) {
if (reqEnd) {
return delete reqComponentObserverCallbacks[reqId]
}
callback(res)
}
}
)
function normalizeRootMargin(margins: WechatMiniprogram.Margins = {}) {
return MARGINS.map(
(name) =>
`${Number(margins[name as keyof WechatMiniprogram.Margins]) || 0}px`
).join(' ')
}
class ServiceIntersectionObserver { class ServiceIntersectionObserver {
private _reqId?: number private _reqId?: number
private _options: UniApp.CreateIntersectionObserverOptions
private _component: any
private _pageId: number private _pageId: number
private _component: ComponentPublicInstance
private _relativeInfo: RelativeInfo[] private _options: ServiceIntersectionObserverOptions
constructor( constructor(
component: any, component: ComponentPublicInstance,
options: UniApp.CreateIntersectionObserverOptions options: UniApp.CreateIntersectionObserverOptions
) { ) {
this._pageId = component.$page.id this._pageId = component.$page && component.$page.id
this._component = component._$id || component // app-plus 平台传输_$id this._component = component
this._options = extend({}, defaultOptions, options || {}) this._options = extend({}, defaultOptions, options)
this._relativeInfo = []
} }
relativeTo(selector: string, margins: Margins) { relativeTo(selector: string, margins?: WechatMiniprogram.Margins) {
if (this._reqId) { this._options.relativeToSelector = selector
throw new Error( this._options.rootMargin = normalizeRootMargin(margins)
'Relative nodes cannot be added after "observe" call in IntersectionObserver'
)
}
this._relativeInfo.push({
selector,
margins,
})
return this return this
} }
relativeToViewport(margins: Margins) { relativeToViewport(margins?: WechatMiniprogram.Margins) {
return this.relativeTo((null as unknown) as string, margins) this._options.relativeToSelector = undefined
this._options.rootMargin = normalizeRootMargin(margins)
return this
} }
observe(selector: string, callback: ObserveResultCallback) { observe(
if (typeof callback !== 'function') { selector: string,
callback: WechatMiniprogram.IntersectionObserverObserveCallback
) {
if (!isFunction(callback)) {
return return
} }
if (this._reqId) { this._options.selector = selector
throw new Error(
'"observe" call can be only called once in IntersectionObserver'
)
}
this._reqId = reqComponentObserverId++ this._reqId = reqComponentObserverId++
reqComponentObserverCallbacks[this._reqId] = callback addIntersectionObserver(
UniServiceJSBridge.publishHandler(
'addIntersectionObserver',
{ {
selector,
reqId: this._reqId, reqId: this._reqId,
component: this._component, component: this._component,
options: this._options, options: this._options,
relativeInfo: this._relativeInfo, callback,
}, },
this._pageId this._pageId
) )
} }
disconnect() { disconnect() {
UniServiceJSBridge.publishHandler( this._reqId &&
'removeIntersectionObserver', removeIntersectionObserver(
{ { reqId: this._reqId, component: this._component },
reqId: this._reqId, this._pageId
}, )
this._pageId
)
} }
} }
export const createIntersectionObserver = defineSyncApi< export const createIntersectionObserver = defineSyncApi<
typeof uni.createIntersectionObserver typeof uni.createIntersectionObserver
>(API_CREATE_INTERSECTION_OBSERVER, (context?, options?) => { >('createIntersectionObserver', (context?, options?) => {
if (!context) { if (context && !context.$page) {
context = getCurrentPageVm() options = context
context = null
}
if (context) {
return new ServiceIntersectionObserver(context, options)
} }
return new ServiceIntersectionObserver(context, options) return new ServiceIntersectionObserver(getCurrentPageVm(), options)
}) })
...@@ -19,10 +19,7 @@ ...@@ -19,10 +19,7 @@
}" }"
class="uni-scroll-view-refresher" class="uni-scroll-view-refresher"
> >
<div <div v-if="refresherDefaultStyle !== 'none'" class="uni-scroll-view-refresh">
v-if="refresherDefaultStyle !== 'none'"
class="uni-scroll-view-refresh"
>
<div class="uni-scroll-view-refresh-inner"> <div class="uni-scroll-view-refresh-inner">
<svg <svg
v-if="refreshState == 'pulling'" v-if="refreshState == 'pulling'"
...@@ -65,10 +62,12 @@ ...@@ -65,10 +62,12 @@
</uni-scroll-view> </uni-scroll-view>
</template> </template>
<script> <script>
import { passive } from '@dcloudio/uni-shared'
import scroller from '../../mixins/scroller/index' import scroller from '../../mixins/scroller/index'
import { disableScrollBounce } from '../../helpers/disable-scroll-bounce' import { disableScrollBounce } from '../../helpers/disable-scroll-bounce'
const passiveOptions = { passive: true } const passiveOptions = passive(true)
// const PULLING = 'pulling' // const PULLING = 'pulling'
// const REFRESHING = 'refreshing' // const REFRESHING = 'refreshing'
...@@ -185,14 +184,14 @@ export default { ...@@ -185,14 +184,14 @@ export default {
this._scrollTopChanged(this.scrollTopNumber) this._scrollTopChanged(this.scrollTopNumber)
this._scrollLeftChanged(this.scrollLeftNumber) this._scrollLeftChanged(this.scrollLeftNumber)
this._scrollIntoViewChanged(this.scrollIntoView) this._scrollIntoViewChanged(this.scrollIntoView)
this.__handleScroll = function (e) { this.__handleScroll = function(e) {
event.preventDefault() event.preventDefault()
event.stopPropagation() event.stopPropagation()
self._handleScroll.bind(self, event)() self._handleScroll.bind(self, event)()
} }
var touchStart = null var touchStart = null
var needStop = null var needStop = null
this.__handleTouchMove = function (event) { this.__handleTouchMove = function(event) {
var x = event.touches[0].pageX var x = event.touches[0].pageX
var y = event.touches[0].pageY var y = event.touches[0].pageY
var main = self.$refs.main var main = self.$refs.main
...@@ -255,7 +254,7 @@ export default { ...@@ -255,7 +254,7 @@ export default {
} }
} }
this.__handleTouchStart = function (event) { this.__handleTouchStart = function(event) {
if (event.touches.length === 1) { if (event.touches.length === 1) {
disableScrollBounce({ disableScrollBounce({
disable: true, disable: true,
...@@ -274,7 +273,7 @@ export default { ...@@ -274,7 +273,7 @@ export default {
} }
} }
} }
this.__handleTouchEnd = function (event) { this.__handleTouchEnd = function(event) {
touchStart = null touchStart = null
disableScrollBounce({ disableScrollBounce({
disable: false, disable: false,
...@@ -296,9 +295,7 @@ export default { ...@@ -296,9 +295,7 @@ export default {
this.__handleTouchMove, this.__handleTouchMove,
passiveOptions passiveOptions
) )
this.$refs.main.addEventListener('scroll', this.__handleScroll, { this.$refs.main.addEventListener('scroll', this.__handleScroll, passive(false))
passive: false,
})
this.$refs.main.addEventListener( this.$refs.main.addEventListener(
'touchend', 'touchend',
this.__handleTouchEnd, this.__handleTouchEnd,
...@@ -321,9 +318,7 @@ export default { ...@@ -321,9 +318,7 @@ export default {
this.__handleTouchMove, this.__handleTouchMove,
passiveOptions passiveOptions
) )
this.$refs.main.removeEventListener('scroll', this.__handleScroll, { this.$refs.main.removeEventListener('scroll', this.__handleScroll, passive(false))
passive: false,
})
this.$refs.main.removeEventListener( this.$refs.main.removeEventListener(
'touchend', 'touchend',
this.__handleTouchEnd, this.__handleTouchEnd,
...@@ -331,13 +326,13 @@ export default { ...@@ -331,13 +326,13 @@ export default {
) )
}, },
methods: { methods: {
scrollTo: function (t, n) { scrollTo: function(t, n) {
var i = this.$refs.main var i = this.$refs.main
t < 0 t < 0
? (t = 0) ? (t = 0)
: n === 'x' && t > i.scrollWidth - i.offsetWidth : n === 'x' && t > i.scrollWidth - i.offsetWidth
? (t = i.scrollWidth - i.offsetWidth) ? (t = i.scrollWidth - i.offsetWidth)
: n === 'y' && : n === 'y' &&
t > i.scrollHeight - i.offsetHeight && t > i.scrollHeight - i.offsetHeight &&
(t = i.scrollHeight - i.offsetHeight) (t = i.scrollHeight - i.offsetHeight)
var r = 0 var r = 0
...@@ -381,7 +376,7 @@ export default { ...@@ -381,7 +376,7 @@ export default {
this.$refs.content.style.webkitTransform = o this.$refs.content.style.webkitTransform = o
} }
}, },
_handleTrack: function ($event) { _handleTrack: function($event) {
if ($event.detail.state === 'start') { if ($event.detail.state === 'start') {
this._x = $event.detail.x this._x = $event.detail.x
this._y = $event.detail.y this._y = $event.detail.y
...@@ -394,7 +389,7 @@ export default { ...@@ -394,7 +389,7 @@ export default {
if (this._noBubble === null && this.scrollY) { if (this._noBubble === null && this.scrollY) {
if ( if (
Math.abs(this._y - $event.detail.y) / Math.abs(this._y - $event.detail.y) /
Math.abs(this._x - $event.detail.x) > Math.abs(this._x - $event.detail.x) >
1 1
) { ) {
this._noBubble = true this._noBubble = true
...@@ -405,7 +400,7 @@ export default { ...@@ -405,7 +400,7 @@ export default {
if (this._noBubble === null && this.scrollX) { if (this._noBubble === null && this.scrollX) {
if ( if (
Math.abs(this._x - $event.detail.x) / Math.abs(this._x - $event.detail.x) /
Math.abs(this._y - $event.detail.y) > Math.abs(this._y - $event.detail.y) >
1 1
) { ) {
this._noBubble = true this._noBubble = true
...@@ -419,7 +414,7 @@ export default { ...@@ -419,7 +414,7 @@ export default {
$event.stopPropagation() $event.stopPropagation()
} }
}, },
_handleScroll: function ($event) { _handleScroll: function($event) {
if (!($event.timeStamp - this._lastScrollTime < 20)) { if (!($event.timeStamp - this._lastScrollTime < 20)) {
this._lastScrollTime = $event.timeStamp this._lastScrollTime = $event.timeStamp
const target = $event.target const target = $event.target
...@@ -444,9 +439,9 @@ export default { ...@@ -444,9 +439,9 @@ export default {
} }
if ( if (
target.scrollTop + target.scrollTop +
target.offsetHeight + target.offsetHeight +
this.lowerThresholdNumber >= this.lowerThresholdNumber >=
target.scrollHeight && target.scrollHeight &&
this.lastScrollTop - target.scrollTop < 0 && this.lastScrollTop - target.scrollTop < 0 &&
$event.timeStamp - this.lastScrollToLowerTime > 200 $event.timeStamp - this.lastScrollToLowerTime > 200
) { ) {
...@@ -469,9 +464,9 @@ export default { ...@@ -469,9 +464,9 @@ export default {
} }
if ( if (
target.scrollLeft + target.scrollLeft +
target.offsetWidth + target.offsetWidth +
this.lowerThresholdNumber >= this.lowerThresholdNumber >=
target.scrollWidth && target.scrollWidth &&
this.lastScrollLeft - target.scrollLeft < 0 && this.lastScrollLeft - target.scrollLeft < 0 &&
$event.timeStamp - this.lastScrollToLowerTime > 200 $event.timeStamp - this.lastScrollToLowerTime > 200
) { ) {
...@@ -485,7 +480,7 @@ export default { ...@@ -485,7 +480,7 @@ export default {
this.lastScrollLeft = target.scrollLeft this.lastScrollLeft = target.scrollLeft
} }
}, },
_scrollTopChanged: function (val) { _scrollTopChanged: function(val) {
if (this.scrollY) { if (this.scrollY) {
if (this._innerSetScrollTop) { if (this._innerSetScrollTop) {
this._innerSetScrollTop = false this._innerSetScrollTop = false
...@@ -498,7 +493,7 @@ export default { ...@@ -498,7 +493,7 @@ export default {
} }
} }
}, },
_scrollLeftChanged: function (val) { _scrollLeftChanged: function(val) {
if (this.scrollX) { if (this.scrollX) {
if (this._innerSetScrollLeft) { if (this._innerSetScrollLeft) {
this._innerSetScrollLeft = false this._innerSetScrollLeft = false
...@@ -511,7 +506,7 @@ export default { ...@@ -511,7 +506,7 @@ export default {
} }
} }
}, },
_scrollIntoViewChanged: function (val) { _scrollIntoViewChanged: function(val) {
if (val) { if (val) {
if (!/^[_a-zA-Z][-_a-zA-Z0-9:]*$/.test(val)) { if (!/^[_a-zA-Z][-_a-zA-Z0-9:]*$/.test(val)) {
console.group('scroll-into-view="' + val + '" 有误') console.group('scroll-into-view="' + val + '" 有误')
...@@ -546,7 +541,7 @@ export default { ...@@ -546,7 +541,7 @@ export default {
} }
} }
}, },
_transitionEnd: function (val, type) { _transitionEnd: function(val, type) {
this.$refs.content.style.transition = '' this.$refs.content.style.transition = ''
this.$refs.content.style.webkitTransition = '' this.$refs.content.style.webkitTransition = ''
this.$refs.content.style.transform = '' this.$refs.content.style.transform = ''
...@@ -590,96 +585,4 @@ export default { ...@@ -590,96 +585,4 @@ export default {
}, },
}, },
} }
</script> </script>
<style> \ No newline at end of file
uni-scroll-view {
display: block;
width: 100%;
}
uni-scroll-view[hidden] {
display: none;
}
.uni-scroll-view {
position: relative;
-webkit-overflow-scrolling: touch;
width: 100%;
/* display: flex; 时在安卓下会导致scrollWidth和offsetWidth一样 */
height: 100%;
max-height: inherit;
}
.uni-scroll-view-content {
width: 100%;
height: 100%;
}
.uni-scroll-view-refresher {
position: relative;
overflow: hidden;
}
.uni-scroll-view-refresh {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.uni-scroll-view-refresh-inner {
display: flex;
align-items: center;
justify-content: center;
line-height: 0;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #fff;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.117647),
0 1px 4px rgba(0, 0, 0, 0.117647);
}
.uni-scroll-view-refresh__spinner {
transform-origin: center center;
animation: uni-scroll-view-refresh-rotate 2s linear infinite;
}
.uni-scroll-view-refresh__spinner > circle {
stroke: currentColor;
stroke-linecap: round;
animation: uni-scroll-view-refresh-dash 2s linear infinite;
}
@keyframes uni-scroll-view-refresh-rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes uni-scroll-view-refresh-dash {
0% {
stroke-dasharray: 1, 200;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -35px;
}
100% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -124px;
}
}
</style>
{ {
"private": true, "private": true,
"name": "@dcloudio/uni-view", "name": "@dcloudio/uni-core",
"version": "3.0.0", "version": "3.0.0",
"description": "@dcloudio/uni-view", "description": "@dcloudio/uni-core",
"sideEffects": false, "sideEffects": false,
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git", "url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-view" "directory": "packages/uni-core"
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"bugs": { "bugs": {
......
export * from './util' export * from './util'
export * from './icon' export * from './icon'
export * from './getRealRoute' export * from './getRealRoute'
export * from './getWindowOffset'
export * from './bridge' export * from './bridge'
export * from './plugin' export * from './plugin'
export { getWindowOffset } from './helpers/getWindowOffset'
import { extend } from '@vue/shared' import { extend } from '@vue/shared'
import { getWindowOffset } from '../helpers/getWindowOffset' import { getWindowOffset } from '../../helpers/getWindowOffset'
export function findUniTarget($event: Event, $el: HTMLElement): HTMLElement { export function findUniTarget($event: Event, $el: HTMLElement): HTMLElement {
let target = $event.target as HTMLElement let target = $event.target as HTMLElement
......
import { passive } from '@dcloudio/uni-shared'
const LONGPRESS_TIMEOUT = 350 const LONGPRESS_TIMEOUT = 350
const LONGPRESS_THRESHOLD = 10 const LONGPRESS_THRESHOLD = 10
const passiveOptions = { passive: true } // TODO caniuse? const passiveOptions = passive(true)
let longPressTimer = 0 let longPressTimer = 0
......
uni-canvas {
width: 300px;
height: 150px;
display: block;
position: relative;
}
uni-canvas > canvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
uni-checkbox-group[hidden] {
display: none;
}
.ql-container {
display: block;
position: relative;
box-sizing: border-box;
-webkit-user-select: text;
user-select: text;
outline: none;
overflow: hidden;
width: 100%;
height: 200px;
min-height: 200px;
}
.ql-container[hidden] {
display: none;
}
.ql-container .ql-editor {
position: relative;
font-size: inherit;
line-height: inherit;
font-family: inherit;
min-height: inherit;
width: 100%;
height: 100%;
padding: 0;
overflow-x: hidden;
overflow-y: auto;
-webkit-tap-highlight-color: transparent;
-webkit-touch-callout: none;
-webkit-overflow-scrolling: touch;
}
.ql-container .ql-editor::-webkit-scrollbar {
width: 0 !important;
}
.ql-container .ql-editor.scroll-disabled {
overflow: hidden;
}
.ql-container .ql-image-overlay {
display: flex;
position: absolute;
box-sizing: border-box;
border: 1px dashed #ccc;
justify-content: center;
align-items: center;
-webkit-user-select: none;
user-select: none;
}
.ql-container .ql-image-overlay .ql-image-size {
position: absolute;
padding: 4px 8px;
text-align: center;
background-color: #fff;
color: #888;
border: 1px solid #ccc;
box-sizing: border-box;
opacity: 0.8;
right: 4px;
top: 4px;
font-size: 12px;
display: inline-block;
width: auto;
}
.ql-container .ql-image-overlay .ql-image-toolbar {
position: relative;
text-align: center;
box-sizing: border-box;
background: #000;
border-radius: 5px;
color: #fff;
font-size: 0;
min-height: 24px;
z-index: 100;
}
.ql-container .ql-image-overlay .ql-image-toolbar span {
display: inline-block;
cursor: pointer;
padding: 5px;
font-size: 12px;
border-right: 1px solid #fff;
}
.ql-container .ql-image-overlay .ql-image-toolbar span:last-child {
border-right: 0;
}
.ql-container .ql-image-overlay .ql-image-toolbar span.triangle-up {
padding: 0;
position: absolute;
top: -12px;
left: 50%;
transform: translatex(-50%);
width: 0;
height: 0;
border-width: 6px;
border-style: solid;
border-color: transparent transparent black transparent;
}
.ql-container .ql-image-overlay .ql-image-handle {
position: absolute;
height: 12px;
width: 12px;
border-radius: 50%;
border: 1px solid #ccc;
box-sizing: border-box;
background: #fff;
}
.ql-container img {
display: inline-block;
max-width: 100%;
}
.ql-clipboard p {
margin: 0;
padding: 0;
}
.ql-editor {
box-sizing: border-box;
height: 100%;
outline: none;
overflow-y: auto;
tab-size: 4;
-moz-tab-size: 4;
text-align: left;
white-space: pre-wrap;
word-wrap: break-word;
}
.ql-editor > * {
cursor: text;
}
.ql-editor p,
.ql-editor ol,
.ql-editor ul,
.ql-editor pre,
.ql-editor blockquote,
.ql-editor h1,
.ql-editor h2,
.ql-editor h3,
.ql-editor h4,
.ql-editor h5,
.ql-editor h6 {
margin: 0;
padding: 0;
counter-reset: list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;
}
.ql-editor ol > li,
.ql-editor ul > li {
list-style-type: none;
}
.ql-editor ul > li::before {
content: '\2022';
}
.ql-editor ul[data-checked=true],
.ql-editor ul[data-checked=false] {
pointer-events: none;
}
.ql-editor ul[data-checked=true] > li *,
.ql-editor ul[data-checked=false] > li * {
pointer-events: all;
}
.ql-editor ul[data-checked=true] > li::before,
.ql-editor ul[data-checked=false] > li::before {
color: #777;
cursor: pointer;
pointer-events: all;
}
.ql-editor ul[data-checked=true] > li::before {
content: '\2611';
}
.ql-editor ul[data-checked=false] > li::before {
content: '\2610';
}
.ql-editor li::before {
display: inline-block;
white-space: nowrap;
width: 2em;
}
.ql-editor ol li {
counter-reset: list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;
counter-increment: list-0;
}
.ql-editor ol li:before {
content: counter(list-0, decimal) '. ';
}
.ql-editor ol li.ql-indent-1 {
counter-increment: list-1;
}
.ql-editor ol li.ql-indent-1:before {
content: counter(list-1, lower-alpha) '. ';
}
.ql-editor ol li.ql-indent-1 {
counter-reset: list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;
}
.ql-editor ol li.ql-indent-2 {
counter-increment: list-2;
}
.ql-editor ol li.ql-indent-2:before {
content: counter(list-2, lower-roman) '. ';
}
.ql-editor ol li.ql-indent-2 {
counter-reset: list-3 list-4 list-5 list-6 list-7 list-8 list-9;
}
.ql-editor ol li.ql-indent-3 {
counter-increment: list-3;
}
.ql-editor ol li.ql-indent-3:before {
content: counter(list-3, decimal) '. ';
}
.ql-editor ol li.ql-indent-3 {
counter-reset: list-4 list-5 list-6 list-7 list-8 list-9;
}
.ql-editor ol li.ql-indent-4 {
counter-increment: list-4;
}
.ql-editor ol li.ql-indent-4:before {
content: counter(list-4, lower-alpha) '. ';
}
.ql-editor ol li.ql-indent-4 {
counter-reset: list-5 list-6 list-7 list-8 list-9;
}
.ql-editor ol li.ql-indent-5 {
counter-increment: list-5;
}
.ql-editor ol li.ql-indent-5:before {
content: counter(list-5, lower-roman) '. ';
}
.ql-editor ol li.ql-indent-5 {
counter-reset: list-6 list-7 list-8 list-9;
}
.ql-editor ol li.ql-indent-6 {
counter-increment: list-6;
}
.ql-editor ol li.ql-indent-6:before {
content: counter(list-6, decimal) '. ';
}
.ql-editor ol li.ql-indent-6 {
counter-reset: list-7 list-8 list-9;
}
.ql-editor ol li.ql-indent-7 {
counter-increment: list-7;
}
.ql-editor ol li.ql-indent-7:before {
content: counter(list-7, lower-alpha) '. ';
}
.ql-editor ol li.ql-indent-7 {
counter-reset: list-8 list-9;
}
.ql-editor ol li.ql-indent-8 {
counter-increment: list-8;
}
.ql-editor ol li.ql-indent-8:before {
content: counter(list-8, lower-roman) '. ';
}
.ql-editor ol li.ql-indent-8 {
counter-reset: list-9;
}
.ql-editor ol li.ql-indent-9 {
counter-increment: list-9;
}
.ql-editor ol li.ql-indent-9:before {
content: counter(list-9, decimal) '. ';
}
.ql-editor .ql-indent-1:not(.ql-direction-rtl) {
padding-left: 2em;
}
.ql-editor li.ql-indent-1:not(.ql-direction-rtl) {
padding-left: 2em;
}
.ql-editor .ql-indent-1.ql-direction-rtl.ql-align-right {
padding-right: 2em;
}
.ql-editor li.ql-indent-1.ql-direction-rtl.ql-align-right {
padding-right: 2em;
}
.ql-editor .ql-indent-2:not(.ql-direction-rtl) {
padding-left: 4em;
}
.ql-editor li.ql-indent-2:not(.ql-direction-rtl) {
padding-left: 4em;
}
.ql-editor .ql-indent-2.ql-direction-rtl.ql-align-right {
padding-right: 4em;
}
.ql-editor li.ql-indent-2.ql-direction-rtl.ql-align-right {
padding-right: 4em;
}
.ql-editor .ql-indent-3:not(.ql-direction-rtl) {
padding-left: 6em;
}
.ql-editor li.ql-indent-3:not(.ql-direction-rtl) {
padding-left: 6em;
}
.ql-editor .ql-indent-3.ql-direction-rtl.ql-align-right {
padding-right: 6em;
}
.ql-editor li.ql-indent-3.ql-direction-rtl.ql-align-right {
padding-right: 6em;
}
.ql-editor .ql-indent-4:not(.ql-direction-rtl) {
padding-left: 8em;
}
.ql-editor li.ql-indent-4:not(.ql-direction-rtl) {
padding-left: 8em;
}
.ql-editor .ql-indent-4.ql-direction-rtl.ql-align-right {
padding-right: 8em;
}
.ql-editor li.ql-indent-4.ql-direction-rtl.ql-align-right {
padding-right: 8em;
}
.ql-editor .ql-indent-5:not(.ql-direction-rtl) {
padding-left: 10em;
}
.ql-editor li.ql-indent-5:not(.ql-direction-rtl) {
padding-left: 10em;
}
.ql-editor .ql-indent-5.ql-direction-rtl.ql-align-right {
padding-right: 10em;
}
.ql-editor li.ql-indent-5.ql-direction-rtl.ql-align-right {
padding-right: 10em;
}
.ql-editor .ql-indent-6:not(.ql-direction-rtl) {
padding-left: 12em;
}
.ql-editor li.ql-indent-6:not(.ql-direction-rtl) {
padding-left: 12em;
}
.ql-editor .ql-indent-6.ql-direction-rtl.ql-align-right {
padding-right: 12em;
}
.ql-editor li.ql-indent-6.ql-direction-rtl.ql-align-right {
padding-right: 12em;
}
.ql-editor .ql-indent-7:not(.ql-direction-rtl) {
padding-left: 14em;
}
.ql-editor li.ql-indent-7:not(.ql-direction-rtl) {
padding-left: 14em;
}
.ql-editor .ql-indent-7.ql-direction-rtl.ql-align-right {
padding-right: 14em;
}
.ql-editor li.ql-indent-7.ql-direction-rtl.ql-align-right {
padding-right: 14em;
}
.ql-editor .ql-indent-8:not(.ql-direction-rtl) {
padding-left: 16em;
}
.ql-editor li.ql-indent-8:not(.ql-direction-rtl) {
padding-left: 16em;
}
.ql-editor .ql-indent-8.ql-direction-rtl.ql-align-right {
padding-right: 16em;
}
.ql-editor li.ql-indent-8.ql-direction-rtl.ql-align-right {
padding-right: 16em;
}
.ql-editor .ql-indent-9:not(.ql-direction-rtl) {
padding-left: 18em;
}
.ql-editor li.ql-indent-9:not(.ql-direction-rtl) {
padding-left: 18em;
}
.ql-editor .ql-indent-9.ql-direction-rtl.ql-align-right {
padding-right: 18em;
}
.ql-editor li.ql-indent-9.ql-direction-rtl.ql-align-right {
padding-right: 18em;
}
.ql-editor .ql-direction-rtl {
direction: rtl;
text-align: inherit;
}
.ql-editor .ql-align-center {
text-align: center;
}
.ql-editor .ql-align-justify {
text-align: justify;
}
.ql-editor .ql-align-right {
text-align: right;
}
.ql-editor.ql-blank::before {
color: rgba(0, 0, 0, 0.6);
content: attr(data-placeholder);
font-style: italic;
pointer-events: none;
position: absolute;
}
.ql-container.ql-disabled .ql-editor ul[data-checked] > li::before {
pointer-events: none;
}
.ql-clipboard {
left: -100000px;
height: 1px;
overflow-y: hidden;
position: absolute;
top: 50%;
}
@keyframes once-show {
from {
top: 0;
}
}
uni-resize-sensor,
uni-resize-sensor > div {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
overflow: hidden;
}
uni-resize-sensor {
display: block;
z-index: -1;
visibility: hidden;
animation: once-show 1ms;
}
uni-resize-sensor > div > div {
position: absolute;
left: 0;
top: 0;
}
uni-resize-sensor > div:first-child > div {
width: 100000px;
height: 100000px;
}
uni-resize-sensor > div:last-child > div {
width: 200%;
height: 200%;
}
.uni-label-pointer {
cursor: pointer;
}
uni-movable-view {
display: inline-block;
width: 10px;
height: 10px;
top: 0px;
left: 0px;
position: absolute;
cursor: grab;
}
uni-movable-view[hidden] {
display: none;
}
uni-radio {
-webkit-tap-highlight-color: transparent;
display: inline-block;
cursor: pointer;
}
uni-radio[hidden] {
display: none;
}
uni-radio[disabled] {
cursor: not-allowed;
}
uni-radio .uni-radio-wrapper {
display: -webkit-inline-flex;
display: inline-flex;
-webkit-align-items: center;
align-items: center;
vertical-align: middle;
}
uni-radio .uni-radio-input {
-webkit-appearance: none;
appearance: none;
margin-right: 5px;
outline: 0;
border: 1px solid #D1D1D1;
background-color: #ffffff;
border-radius: 50%;
width: 22px;
height: 22px;
position: relative;
}
uni-radio:not([disabled]) .uni-radio-input:hover {
border-color: #007aff;
}
uni-radio .uni-radio-input.uni-radio-input-checked:before {
font: normal normal normal 14px/1 "uni";
content: "\EA08";
color: #ffffff;
font-size: 18px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -48%) scale(0.73);
-webkit-transform: translate(-50%, -48%) scale(0.73);
}
uni-radio .uni-radio-input.uni-radio-input-disabled {
background-color: #E1E1E1;
border-color: #D1D1D1;
}
uni-radio .uni-radio-input.uni-radio-input-disabled:before {
color: #ADADAD;
}
uni-radio-group {
display: block;
}
uni-radio-group[hidden] {
display: none;
}
uni-swiper-item {
display: block;
overflow: hidden;
will-change: transform;
position: absolute;
width: 100%;
height: 100%;
cursor: grab;
}
uni-swiper-item[hidden] {
display: none;
}
uni-switch {
-webkit-tap-highlight-color: transparent;
display: inline-block;
cursor: pointer;
}
uni-switch[hidden] {
display: none;
}
uni-switch[disabled] {
cursor: not-allowed;
}
uni-switch .uni-switch-wrapper {
display: -webkit-inline-flex;
display: inline-flex;
-webkit-align-items: center;
align-items: center;
vertical-align: middle;
}
uni-switch .uni-switch-input {
-webkit-appearance: none;
appearance: none;
position: relative;
width: 52px;
height: 32px;
margin-right: 5px;
border: 1px solid #DFDFDF;
outline: 0;
border-radius: 16px;
box-sizing: border-box;
background-color: #DFDFDF;
transition: background-color 0.1s, border 0.1s;
}
uni-switch[disabled] .uni-switch-input {
opacity: .7;
}
uni-switch .uni-switch-input:before {
content: " ";
position: absolute;
top: 0;
left: 0;
width: 50px;
height: 30px;
border-radius: 15px;
background-color: #FDFDFD;
transition: -webkit-transform 0.3s;
transition: transform 0.3s;
transition: transform 0.3s, -webkit-transform 0.3s;
}
uni-switch .uni-switch-input:after {
content: " ";
position: absolute;
top: 0;
left: 0;
width: 30px;
height: 30px;
border-radius: 15px;
background-color: #FFFFFF;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
transition: -webkit-transform 0.3s;
transition: transform 0.3s;
transition: transform 0.3s, -webkit-transform 0.3s;
}
uni-switch .uni-switch-input.uni-switch-input-checked {
border-color: #007aff;
background-color: #007aff;
}
uni-switch .uni-switch-input.uni-switch-input-checked:before {
-webkit-transform: scale(0);
transform: scale(0);
}
uni-switch .uni-switch-input.uni-switch-input-checked:after {
-webkit-transform: translateX(20px);
transform: translateX(20px);
}
uni-switch .uni-checkbox-input {
margin-right: 5px;
-webkit-appearance: none;
appearance: none;
outline: 0;
border: 1px solid #D1D1D1;
background-color: #FFFFFF;
border-radius: 3px;
width: 22px;
height: 22px;
position: relative;
color: #007aff;
}
uni-switch:not([disabled]) .uni-checkbox-input:hover {
border-color: #007aff;
}
uni-switch .uni-checkbox-input.uni-checkbox-input-checked:before {
font: normal normal normal 14px/1 "uni";
content: "\EA08";
color: inherit;
font-size: 22px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -48%) scale(0.73);
-webkit-transform: translate(-50%, -48%) scale(0.73);
}
uni-switch .uni-checkbox-input.uni-checkbox-input-disabled {
background-color: #E1E1E1;
}
uni-switch .uni-checkbox-input.uni-checkbox-input-disabled:before {
color: #ADADAD;
}
uni-textarea {
width: 300px;
height: 150px;
display: block;
position: relative;
font-size: 16px;
line-height: normal;
white-space: pre-wrap;
word-break: break-all;
}
uni-textarea[hidden] {
display: none;
}
.uni-textarea-wrapper,
.uni-textarea-placeholder,
.uni-textarea-line,
.uni-textarea-compute,
.uni-textarea-textarea {
outline: none;
border: none;
padding: 0;
margin: 0;
text-decoration: inherit;
}
.uni-textarea-wrapper {
display: block;
position: relative;
width: 100%;
height: 100%;
}
.uni-textarea-placeholder,
.uni-textarea-line,
.uni-textarea-compute,
.uni-textarea-textarea {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
white-space: inherit;
word-break: inherit;
}
.uni-textarea-placeholder {
color: grey;
overflow: hidden;
}
.uni-textarea-line,
.uni-textarea-compute {
visibility: hidden;
height: auto;
}
.uni-textarea-line {
width: 1em;
}
.uni-textarea-textarea {
resize: none;
background: none;
color: inherit;
opacity: 1;
-webkit-text-fill-color: currentcolor;
font: inherit;
line-height: inherit;
letter-spacing: inherit;
text-align: inherit;
text-indent: inherit;
text-transform: inherit;
text-shadow: inherit;
}
/* 用于解决 iOS textarea 内部默认边距 */
.uni-textarea-textarea-fix-margin {
width: auto;
right: 0;
margin: 0 -3px;
}
.uni-async-error {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
color: #999;
padding: 100px 10px;
text-align: center;
}
.uni-async-loading {
box-sizing: border-box;
width: 100%;
padding: 50px;
text-align: center;
}
.uni-async-loading .uni-loading {
width: 30px;
height: 30px;
}
此差异已折叠。
...@@ -25,6 +25,6 @@ ...@@ -25,6 +25,6 @@
}, },
"dependencies": { "dependencies": {
"safe-area-insets": "^1.4.1", "safe-area-insets": "^1.4.1",
"vue-router": "^4.0.5" "vue-router": "^4.0.6"
} }
} }
import { ComponentPublicInstance } from 'vue'
const WINDOW_NAMES = ['VUniLeftWindow', 'VUniTopWindow', 'VUniRightWindow']
export function isInWindows(vm: ComponentPublicInstance) {
while (vm) {
const name = vm.$options.name
if (name && WINDOW_NAMES.indexOf(name) !== -1) {
return true
}
vm = vm.$parent!
}
return false
}
import { ComponentPublicInstance } from 'vue'
import { getRealRoute } from '@dcloudio/uni-core' import { getRealRoute } from '@dcloudio/uni-core'
export function findElem(vm: ComponentPublicInstance) {
return vm.$el
}
const SCHEME_RE = /^([a-z-]+:)?\/\//i const SCHEME_RE = /^([a-z-]+:)?\/\//i
const DATA_RE = /^data:.*,.*/ const DATA_RE = /^data:.*,.*/
......
export * from './getRealPath' export * from './dom'
export { getBaseSystemInfo } from '../service/api/base/getBaseSystemInfo' export { getBaseSystemInfo } from '../service/api/base/getBaseSystemInfo'
export { operateVideoPlayer } from '../service/api/context/operateVideoPlayer' export { operateVideoPlayer } from '../service/api/context/operateVideoPlayer'
export {
addIntersectionObserver,
removeIntersectionObserver,
} from '../service/api/ui/intersectionObserver'
import {
requestComponentObserver,
AddIntersectionObserverArgs,
RemoveIntersectionObserverArgs,
} from '@dcloudio/uni-api'
import { findElem } from '../../../platform/dom'
export function addIntersectionObserver(
{ reqId, component, options, callback }: AddIntersectionObserverArgs,
_pageId: number
) {
const $el = findElem(component)
;($el.__io || ($el.__io = {}))[reqId] = requestComponentObserver(
$el,
options,
callback
)
}
export function removeIntersectionObserver(
{ reqId, component }: RemoveIntersectionObserverArgs,
_pageId: number
) {
const $el = findElem(component)
const intersectionObserver = $el.__io && $el.__io[reqId]
if (intersectionObserver) {
intersectionObserver.disconnect()
delete $el.__io[reqId]
}
}
<template> <template>
<uni-video <uni-video :id="id" v-on="$listeners">
:id="id"
v-on="$listeners"
>
<div <div
ref="container" ref="container"
class="uni-video-container" class="uni-video-container"
...@@ -10,11 +7,11 @@ ...@@ -10,11 +7,11 @@
@touchend="touchend" @touchend="touchend"
@touchmove="touchmove" @touchmove="touchmove"
@fullscreenchange.stop="onFullscreenChange" @fullscreenchange.stop="onFullscreenChange"
@webkitfullscreenchange.stop="onFullscreenChange($event,true)" @webkitfullscreenchange.stop="onFullscreenChange($event, true)"
> >
<video <video
ref="video" ref="video"
:style="{objectFit:objectFit}" :style="{ objectFit: objectFit }"
:muted="muted" :muted="muted"
:loop="loop" :loop="loop"
:src="srcSync" :src="srcSync"
...@@ -39,85 +36,49 @@ ...@@ -39,85 +36,49 @@
@webkitendfullscreen="emitFullscreenChange(false)" @webkitendfullscreen="emitFullscreenChange(false)"
@x5videoexitfullscreen="emitFullscreenChange(false)" @x5videoexitfullscreen="emitFullscreenChange(false)"
/> />
<div <div v-show="controlsShow" class="uni-video-bar uni-video-bar-full" @click.stop>
v-show="controlsShow"
class="uni-video-bar uni-video-bar-full"
@click.stop
>
<div class="uni-video-controls"> <div class="uni-video-controls">
<div <div
v-show="showPlayBtn" v-show="showPlayBtn"
:class="{'uni-video-control-button-play':!playing,'uni-video-control-button-pause':playing}" :class="{ 'uni-video-control-button-play': !playing, 'uni-video-control-button-pause': playing }"
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 }}</div>
{{ currentTime|time }}
</div>
<div <div
ref="progress" ref="progress"
class="uni-video-progress-container" class="uni-video-progress-container"
@click.stop="clickProgress($event)" @click.stop="clickProgress($event)"
> >
<div class="uni-video-progress"> <div class="uni-video-progress">
<div <div :style="{ width: buffered + '%' }" class="uni-video-progress-buffered" />
:style="{width:buffered+'%'}" <div ref="ball" :style="{ left: progress + '%' }" class="uni-video-ball">
class="uni-video-progress-buffered"
/>
<div
ref="ball"
:style="{left:progress+'%'}"
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 }}</div>
{{ (duration||durationTime)|time }}
</div>
</div> </div>
<div <div
v-if="danmuBtn" v-if="danmuBtn"
: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"
> >{{ $$t("uni.video.danmu") }}</div>
{{ $$t("uni.video.danmu") }}
</div>
<div <div
v-show="showFullscreenBtn" v-show="showFullscreenBtn"
:class="{'uni-video-type-fullscreen':fullscreen}" :class="{ 'uni-video-type-fullscreen': fullscreen }"
class="uni-video-fullscreen" class="uni-video-fullscreen"
@click.stop="triggerFullscreen(!fullscreen)" @click.stop="triggerFullscreen(!fullscreen)"
/> />
</div> </div>
<div <div v-show="start && enableDanmuSync" ref="danmu" style="z-index: 0;" class="uni-video-danmu" />
v-show="start&&enableDanmuSync" <div v-if="centerPlayBtnShow" class="uni-video-cover" @click.stop>
ref="danmu" <div class="uni-video-cover-play-button" @click.stop="play" />
style="z-index: 0;" <p class="uni-video-cover-duration">{{ (duration || durationTime) | time }}</p>
class="uni-video-danmu"
/>
<div
v-if="centerPlayBtnShow"
class="uni-video-cover"
@click.stop
>
<div
class="uni-video-cover-play-button"
@click.stop="play"
/>
<p class="uni-video-cover-duration">
{{ (duration||durationTime)|time }}
</p>
</div> </div>
<div <div :class="{ 'uni-video-toast-volume': gestureType === 'volume' }" class="uni-video-toast">
:class="{'uni-video-toast-volume':gestureType==='volume'}" <div class="uni-video-toast-title">{{ $$t("uni.video.volume") }}</div>
class="uni-video-toast"
>
<div class="uni-video-toast-title">
{{ $$t("uni.video.volume") }}
</div>
<svg <svg
class="uni-video-toast-icon" class="uni-video-toast-icon"
width="200px" width="200px"
...@@ -131,10 +92,7 @@ ...@@ -131,10 +92,7 @@
/> />
</svg> </svg>
<div class="uni-video-toast-value"> <div class="uni-video-toast-value">
<div <div :style="{ width: volumeNew * 100 + '%' }" class="uni-video-toast-value-content">
:style="{width:volumeNew*100+'%'}"
class="uni-video-toast-value-content"
>
<div class="uni-video-toast-volume-grids"> <div class="uni-video-toast-volume-grids">
<div <div
v-for="(item,index) in 10" v-for="(item,index) in 10"
...@@ -145,13 +103,8 @@ ...@@ -145,13 +103,8 @@
</div> </div>
</div> </div>
</div> </div>
<div <div :class="{ 'uni-video-toast-progress': gestureType == 'progress' }" class="uni-video-toast">
:class="{'uni-video-toast-progress':gestureType=='progress'}" <div class="uni-video-toast-title">{{ currentTimeNew | time }} / {{ durationTime | time }}</div>
class="uni-video-toast"
>
<div class="uni-video-toast-title">
{{ currentTimeNew|time }} / {{ durationTime|time }}
</div>
</div> </div>
<div class="uni-video-slots"> <div class="uni-video-slots">
<slot /> <slot />
...@@ -160,20 +113,19 @@ ...@@ -160,20 +113,19 @@
</uni-video> </uni-video>
</template> </template>
<script> <script>
import {
passive
} from '@dcloudio/uni-shared'
import { import {
subscriber, subscriber,
interact interact
} from 'uni-mixins' } from 'uni-mixins'
import {
supportsPassive
} from 'uni-shared'
import { import {
i18nMixin i18nMixin
} from 'uni-core/helpers/i18n' } from 'uni-core/helpers/i18n'
const passiveOptions = supportsPassive ? { const passiveOptions = passive(false)
passive: false
} : false
const GestureType = { const GestureType = {
NONE: 'none', NONE: 'none',
...@@ -185,7 +137,7 @@ const GestureType = { ...@@ -185,7 +137,7 @@ const GestureType = {
export default { export default {
name: 'Video', name: 'Video',
filters: { filters: {
time (val) { time(val) {
val = val > 0 && val < Infinity ? val : 0 val = val > 0 && val < Infinity ? val : 0
let h = Math.floor(val / 3600) let h = Math.floor(val / 3600)
let m = Math.floor(val % 3600 / 60) let m = Math.floor(val % 3600 / 60)
...@@ -220,7 +172,7 @@ export default { ...@@ -220,7 +172,7 @@ export default {
}, },
danmuList: { danmuList: {
type: Array, type: Array,
default () { default() {
return [] return []
} }
}, },
...@@ -285,7 +237,7 @@ export default { ...@@ -285,7 +237,7 @@ export default {
default: true default: true
} }
}, },
data () { data() {
return { return {
start: false, start: false,
playing: false, playing: false,
...@@ -311,41 +263,41 @@ export default { ...@@ -311,41 +263,41 @@ export default {
} }
}, },
computed: { computed: {
centerPlayBtnShow () { centerPlayBtnShow() {
return this.showCenterPlayBtn && !this.start return this.showCenterPlayBtn && !this.start
}, },
controlsShow () { controlsShow() {
return !this.centerPlayBtnShow && 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
}, },
srcSync () { srcSync() {
return this.$getRealPath(this.src) return this.$getRealPath(this.src)
} }
}, },
watch: { watch: {
enableDanmuSync (val) { enableDanmuSync(val) {
this.$emit('update:enableDanmu', val) this.$emit('update:enableDanmu', val)
}, },
autoHideContorls (val) { autoHideContorls(val) {
if (val) { if (val) {
this.autoHideStart() this.autoHideStart()
} else { } else {
this.autoHideEnd() this.autoHideEnd()
} }
}, },
srcSync (val) { srcSync(val) {
this.playing = false this.playing = false
this.currentTime = 0 this.currentTime = 0
}, },
currentTime () { currentTime() {
this.updateProgress() this.updateProgress()
}, },
duration () { duration() {
this.updateProgress() this.updateProgress()
}, },
buffered (buffered) { buffered(buffered) {
if (buffered !== 0) { if (buffered !== 0) {
this.$trigger('progress', {}, { this.$trigger('progress', {}, {
buffered buffered
...@@ -353,7 +305,7 @@ export default { ...@@ -353,7 +305,7 @@ export default {
} }
} }
}, },
created () { created() {
this.otherData = { this.otherData = {
danmuList: [], danmuList: [],
danmuIndex: { danmuIndex: {
...@@ -363,11 +315,11 @@ export default { ...@@ -363,11 +315,11 @@ export default {
hideTiming: null hideTiming: null
} }
const danmuList = this.otherData.danmuList = JSON.parse(JSON.stringify(this.danmuList || [])) const danmuList = this.otherData.danmuList = JSON.parse(JSON.stringify(this.danmuList || []))
danmuList.sort(function (a, b) { danmuList.sort(function(a, b) {
return (a.time || 0) - (a.time || 0) return (a.time || 0) - (a.time || 0)
}) })
}, },
mounted () { mounted() {
const self = this const self = this
let originX let originX
let originY let originY
...@@ -385,7 +337,7 @@ export default { ...@@ -385,7 +337,7 @@ export default {
ball.addEventListener('touchmove', touchmove, passiveOptions) ball.addEventListener('touchmove', touchmove, passiveOptions)
}) })
function touchmove (event) { function touchmove(event) {
const toucher = event.targetTouches[0] const toucher = event.targetTouches[0]
const pageX = toucher.pageX const pageX = toucher.pageX
const pageY = toucher.pageY const pageY = toucher.pageY
...@@ -406,7 +358,7 @@ export default { ...@@ -406,7 +358,7 @@ export default {
event.stopPropagation() event.stopPropagation()
} }
function touchend (event) { function touchend(event) {
self.controlsTouching = false self.controlsTouching = false
if (self.touching) { if (self.touching) {
ball.removeEventListener('touchmove', touchmove, passiveOptions) ball.removeEventListener('touchmove', touchmove, passiveOptions)
...@@ -421,12 +373,12 @@ export default { ...@@ -421,12 +373,12 @@ export default {
ball.addEventListener('touchend', touchend) ball.addEventListener('touchend', touchend)
ball.addEventListener('touchcancel', touchend) ball.addEventListener('touchcancel', touchend)
}, },
beforeDestroy () { beforeDestroy() {
this.triggerFullscreen(false) this.triggerFullscreen(false)
clearTimeout(this.otherData.hideTiming) clearTimeout(this.otherData.hideTiming)
}, },
methods: { methods: {
_handleSubscribe ({ _handleSubscribe({
type, type,
data = {} data = {}
}) { }) {
...@@ -447,27 +399,27 @@ export default { ...@@ -447,27 +399,27 @@ export default {
this[type](options) this[type](options)
} }
}, },
trigger () { trigger() {
if (this.playing) { if (this.playing) {
this.$refs.video.pause() this.$refs.video.pause()
} else { } else {
this.$refs.video.play() this.$refs.video.play()
} }
}, },
play () { play() {
this.start = true this.start = true
this.$refs.video.play() this.$refs.video.play()
}, },
pause () { pause() {
this.$refs.video.pause() this.$refs.video.pause()
}, },
seek (position) { seek(position) {
position = Number(position) position = Number(position)
if (typeof position === 'number' && !isNaN(position)) { if (typeof position === 'number' && !isNaN(position)) {
this.$refs.video.currentTime = position this.$refs.video.currentTime = position
} }
}, },
clickProgress (event) { clickProgress(event) {
const $progress = this.$refs.progress const $progress = this.$refs.progress
let element = event.target let element = event.target
let x = event.offsetX let x = event.offsetX
...@@ -482,25 +434,25 @@ export default { ...@@ -482,25 +434,25 @@ export default {
this.seek(this.$refs.video.duration * progress) this.seek(this.$refs.video.duration * progress)
} }
}, },
triggerDanmu () { triggerDanmu() {
this.enableDanmuSync = !this.enableDanmuSync this.enableDanmuSync = !this.enableDanmuSync
}, },
playDanmu (danmu) { playDanmu(danmu) {
const p = document.createElement('p') const p = document.createElement('p')
p.className = 'uni-video-danmu-item' p.className = 'uni-video-danmu-item'
p.innerText = danmu.text p.innerText = danmu.text
let style = `bottom: ${Math.random() * 100}%;color: ${danmu.color};` let style = `bottom: ${Math.random() * 100}%;color: ${danmu.color};`
p.setAttribute('style', style) p.setAttribute('style', style)
this.$refs.danmu.appendChild(p) this.$refs.danmu.appendChild(p)
setTimeout(function () { setTimeout(function() {
style += 'left: 0;-webkit-transform: translateX(-100%);transform: translateX(-100%);' style += 'left: 0;-webkit-transform: translateX(-100%);transform: translateX(-100%);'
p.setAttribute('style', style) p.setAttribute('style', style)
setTimeout(function () { setTimeout(function() {
p.remove() p.remove()
}, 4000) }, 4000)
}, 17) }, 17)
}, },
sendDanmu (danmu) { sendDanmu(danmu) {
const otherData = this.otherData const otherData = this.otherData
otherData.danmuList.splice(otherData.danmuIndex.index + 1, 0, { otherData.danmuList.splice(otherData.danmuIndex.index + 1, 0, {
text: String(danmu.text), text: String(danmu.text),
...@@ -508,10 +460,10 @@ export default { ...@@ -508,10 +460,10 @@ export default {
time: this.$refs.video.currentTime || 0 time: this.$refs.video.currentTime || 0
}) })
}, },
playbackRate (rate) { playbackRate(rate) {
this.$refs.video.playbackRate = rate this.$refs.video.playbackRate = rate
}, },
triggerFullscreen (val) { triggerFullscreen(val) {
const container = this.$refs.container const container = this.$refs.container
const video = this.$refs.video const video = this.$refs.video
let mockFullScreen let mockFullScreen
...@@ -546,29 +498,29 @@ export default { ...@@ -546,29 +498,29 @@ export default {
this.emitFullscreenChange(val) this.emitFullscreenChange(val)
} }
}, },
onFullscreenChange ($event, webkit) { onFullscreenChange($event, webkit) {
if (webkit && document.fullscreenEnabled) { if (webkit && document.fullscreenEnabled) {
return return
} }
this.emitFullscreenChange(!!(document.fullscreenElement || document.webkitFullscreenElement)) this.emitFullscreenChange(!!(document.fullscreenElement || document.webkitFullscreenElement))
}, },
emitFullscreenChange (val) { emitFullscreenChange(val) {
this.fullscreen = val this.fullscreen = val
this.$trigger('fullscreenchange', {}, { this.$trigger('fullscreenchange', {}, {
fullScreen: val, fullScreen: val,
direction: 'vertical' direction: 'vertical'
}) })
}, },
requestFullScreen () { requestFullScreen() {
this.triggerFullscreen(true) this.triggerFullscreen(true)
}, },
exitFullScreen () { exitFullScreen() {
this.triggerFullscreen(false) this.triggerFullscreen(false)
}, },
onDurationChange ({ target }) { onDurationChange({ target }) {
this.durationTime = target.duration this.durationTime = target.duration
}, },
onLoadedMetadata ($event) { onLoadedMetadata($event) {
const initialTime = Number(this.initialTime) || 0 const initialTime = Number(this.initialTime) || 0
const video = $event.target const video = $event.target
if (initialTime > 0) { if (initialTime > 0) {
...@@ -581,34 +533,34 @@ export default { ...@@ -581,34 +533,34 @@ export default {
}) })
this.onProgress($event) this.onProgress($event)
}, },
onProgress ($event) { onProgress($event) {
const video = $event.target const video = $event.target
const buffered = video.buffered const buffered = video.buffered
if (buffered.length) { if (buffered.length) {
this.buffered = buffered.end(buffered.length - 1) / video.duration * 100 this.buffered = buffered.end(buffered.length - 1) / video.duration * 100
} }
}, },
onWaiting ($event) { onWaiting($event) {
this.$trigger('waiting', $event, {}) this.$trigger('waiting', $event, {})
}, },
onVideoError ($event) { onVideoError($event) {
this.playing = false this.playing = false
this.$trigger('error', $event, {}) this.$trigger('error', $event, {})
}, },
onPlay ($event) { onPlay($event) {
this.start = true this.start = true
this.playing = true this.playing = true
this.$trigger('play', $event, {}) this.$trigger('play', $event, {})
}, },
onPause ($event) { onPause($event) {
this.playing = false this.playing = false
this.$trigger('pause', $event, {}) this.$trigger('pause', $event, {})
}, },
onEnded ($event) { onEnded($event) {
this.playing = false this.playing = false
this.$trigger('ended', $event, {}) this.$trigger('ended', $event, {})
}, },
onTimeUpdate ($event) { onTimeUpdate($event) {
const video = $event.target const video = $event.target
const otherData = this.otherData const otherData = this.otherData
const currentTime = this.currentTime = video.currentTime const currentTime = this.currentTime = video.currentTime
...@@ -646,10 +598,10 @@ export default { ...@@ -646,10 +598,10 @@ export default {
duration: video.duration duration: video.duration
}) })
}, },
triggerControls () { triggerControls() {
this.controlsVisible = !this.controlsVisible this.controlsVisible = !this.controlsVisible
}, },
touchstart (event) { touchstart(event) {
const toucher = event.targetTouches[0] const toucher = event.targetTouches[0]
this.touchStartOrigin = { this.touchStartOrigin = {
x: toucher.pageX, x: toucher.pageX,
...@@ -659,8 +611,8 @@ export default { ...@@ -659,8 +611,8 @@ export default {
this.volumeOld = null this.volumeOld = null
this.currentTimeOld = this.currentTimeNew = 0 this.currentTimeOld = this.currentTimeNew = 0
}, },
touchmove (event) { touchmove(event) {
function stop () { function stop() {
event.stopPropagation() event.stopPropagation()
event.preventDefault() event.preventDefault()
} }
...@@ -705,7 +657,7 @@ export default { ...@@ -705,7 +657,7 @@ export default {
} }
} }
}, },
touchend (event) { touchend(event) {
if (this.gestureType !== GestureType.NONE && this.gestureType !== GestureType.STOP) { if (this.gestureType !== GestureType.NONE && this.gestureType !== GestureType.STOP) {
event.stopPropagation() event.stopPropagation()
event.preventDefault() event.preventDefault()
...@@ -715,7 +667,7 @@ export default { ...@@ -715,7 +667,7 @@ export default {
} }
this.gestureType = GestureType.NONE this.gestureType = GestureType.NONE
}, },
changeProgress (x) { changeProgress(x) {
const duration = this.$refs.video.duration const duration = this.$refs.video.duration
let currentTimeNew = x / 600 * duration + this.currentTimeOld let currentTimeNew = x / 600 * duration + this.currentTimeOld
if (currentTimeNew < 0) { if (currentTimeNew < 0) {
...@@ -725,7 +677,7 @@ export default { ...@@ -725,7 +677,7 @@ export default {
} }
this.currentTimeNew = currentTimeNew this.currentTimeNew = currentTimeNew
}, },
changeVolume (y) { changeVolume(y) {
const valueOld = this.volumeOld const valueOld = this.volumeOld
let value let value
if (typeof valueOld === 'number') { if (typeof valueOld === 'number') {
...@@ -739,19 +691,19 @@ export default { ...@@ -739,19 +691,19 @@ export default {
this.volumeNew = value this.volumeNew = value
} }
}, },
autoHideStart () { autoHideStart() {
this.otherData.hideTiming = setTimeout(() => { this.otherData.hideTiming = setTimeout(() => {
this.controlsVisible = false this.controlsVisible = false
}, 3000) }, 3000)
}, },
autoHideEnd () { autoHideEnd() {
const otherData = this.otherData const otherData = this.otherData
if (otherData.hideTiming) { if (otherData.hideTiming) {
clearTimeout(otherData.hideTiming) clearTimeout(otherData.hideTiming)
otherData.hideTiming = null otherData.hideTiming = null
} }
}, },
updateProgress () { updateProgress() {
if (!this.touching) { if (!this.touching) {
this.progress = this.currentTime / this.durationTime * 100 this.progress = this.currentTime / this.durationTime * 100
} }
......
uni-scroll-view {
display: block;
width: 100%;
}
uni-scroll-view[hidden] {
display: none;
}
.uni-scroll-view {
position: relative;
-webkit-overflow-scrolling: touch;
width: 100%;
/* display: flex; 时在安卓下会导致scrollWidth和offsetWidth一样 */
height: 100%;
max-height: inherit;
}
.uni-scroll-view-content {
width: 100%;
height: 100%;
}
.uni-scroll-view-refresher {
position: relative;
overflow: hidden;
}
.uni-scroll-view-refresh {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.uni-scroll-view-refresh-inner {
display: flex;
align-items: center;
justify-content: center;
line-height: 0;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #fff;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.117647),
0 1px 4px rgba(0, 0, 0, 0.117647);
}
.uni-scroll-view-refresh__spinner {
transform-origin: center center;
animation: uni-scroll-view-refresh-rotate 2s linear infinite;
}
.uni-scroll-view-refresh__spinner > circle {
stroke: currentColor;
stroke-linecap: round;
animation: uni-scroll-view-refresh-dash 2s linear infinite;
}
@keyframes uni-scroll-view-refresh-rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes uni-scroll-view-refresh-dash {
0% {
stroke-dasharray: 1, 200;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -35px;
}
100% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -124px;
}
}
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
{ {
"find": "@dcloudio/uni-platform", "find": "@dcloudio/uni-platform",
"replacement": "packages/uni-mp-alipay/src/platform/index.ts" "replacement": "packages/uni-mp-alipay/src/platform/index.ts"
},
{
"find": "@dcloudio/uni-mp-platform",
"replacement": "packages/uni-mp-core/src/platform/index.ts"
} }
] ]
}, },
......
export {
getRealPath,
addIntersectionObserver,
removeIntersectionObserver,
} from '@dcloudio/uni-mp-platform'
export function getBaseSystemInfo() { export function getBaseSystemInfo() {
return my.getSystemInfoSync() return my.getSystemInfoSync()
} }
export function getRealPath() {}
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
{ {
"find": "@dcloudio/uni-platform", "find": "@dcloudio/uni-platform",
"replacement": "packages/uni-mp-baidu/src/platform/index.ts" "replacement": "packages/uni-mp-baidu/src/platform/index.ts"
},
{
"find": "@dcloudio/uni-mp-platform",
"replacement": "packages/uni-mp-core/src/platform/index.ts"
} }
] ]
}, },
......
export {
getRealPath,
addIntersectionObserver,
removeIntersectionObserver,
} from '@dcloudio/uni-mp-platform'
export function getBaseSystemInfo() { export function getBaseSystemInfo() {
return swan.getSystemInfoSync() return swan.getSystemInfoSync()
} }
export function getRealPath() {}
...@@ -27,8 +27,8 @@ export { initMocks, initComponentInstance } from './runtime/componentInstance' ...@@ -27,8 +27,8 @@ export { initMocks, initComponentInstance } from './runtime/componentInstance'
export { handleEvent } from './runtime/componentEvents' export { handleEvent } from './runtime/componentEvents'
export { $createComponent, $destroyComponent } from './runtime/component' export { $createComponent, $destroyComponent } from './runtime/component'
export { export {
initVueIds,
initRefs, initRefs,
initVueIds,
initWxsCallMethods, initWxsCallMethods,
findVmByVueId, findVmByVueId,
} from './runtime/util' } from './runtime/util'
......
export function getRealPath() {}
export function addIntersectionObserver() {}
export function removeIntersectionObserver() {}
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
{ {
"find": "@dcloudio/uni-platform", "find": "@dcloudio/uni-platform",
"replacement": "packages/uni-mp-qq/src/platform/index.ts" "replacement": "packages/uni-mp-qq/src/platform/index.ts"
},
{
"find": "@dcloudio/uni-mp-platform",
"replacement": "packages/uni-mp-core/src/platform/index.ts"
} }
] ]
}, },
......
export {
getRealPath,
addIntersectionObserver,
removeIntersectionObserver,
} from '@dcloudio/uni-mp-platform'
export function getBaseSystemInfo() { export function getBaseSystemInfo() {
return qq.getSystemInfoSync() return qq.getSystemInfoSync()
} }
export function getRealPath() {}
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
{ {
"find": "@dcloudio/uni-platform", "find": "@dcloudio/uni-platform",
"replacement": "packages/uni-mp-toutiao/src/platform/index.ts" "replacement": "packages/uni-mp-toutiao/src/platform/index.ts"
},
{
"find": "@dcloudio/uni-mp-platform",
"replacement": "packages/uni-mp-core/src/platform/index.ts"
} }
] ]
}, },
......
export {
getRealPath,
addIntersectionObserver,
removeIntersectionObserver,
} from '@dcloudio/uni-mp-platform'
export function getBaseSystemInfo() { export function getBaseSystemInfo() {
return tt.getSystemInfoSync() return tt.getSystemInfoSync()
} }
export function getRealPath() {}
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
{ {
"find": "@dcloudio/uni-platform", "find": "@dcloudio/uni-platform",
"replacement": "packages/uni-mp-weixin/src/platform/index.ts" "replacement": "packages/uni-mp-weixin/src/platform/index.ts"
},
{
"find": "@dcloudio/uni-mp-platform",
"replacement": "packages/uni-mp-core/src/platform/index.ts"
} }
] ]
}, },
......
export {
getRealPath,
addIntersectionObserver,
removeIntersectionObserver,
} from '@dcloudio/uni-mp-platform'
export function getBaseSystemInfo() { export function getBaseSystemInfo() {
return wx.getSystemInfoSync() return wx.getSystemInfoSync()
} }
export function getRealPath() {}
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
{ {
"find": "@dcloudio/uni-platform", "find": "@dcloudio/uni-platform",
"replacement": "packages/uni-quickapp-webview/src/platform/index.ts" "replacement": "packages/uni-quickapp-webview/src/platform/index.ts"
},
{
"find": "@dcloudio/uni-mp-platform",
"replacement": "packages/uni-mp-core/src/platform/index.ts"
} }
] ]
}, },
......
export {
getRealPath,
addIntersectionObserver,
removeIntersectionObserver,
} from '@dcloudio/uni-mp-platform'
export function getBaseSystemInfo() { export function getBaseSystemInfo() {
return qa.getSystemInfoSync() return qa.getSystemInfoSync()
} }
export function getRealPath() {}
...@@ -4,23 +4,12 @@ Object.defineProperty(exports, '__esModule', { value: true }); ...@@ -4,23 +4,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
var shared = require('@vue/shared'); var shared = require('@vue/shared');
const NAVBAR_HEIGHT = 44; function passive(passive) {
const TABBAR_HEIGHT = 50; return { passive };
const RESPONSIVE_MIN_WIDTH = 768; }
const COMPONENT_NAME_PREFIX = 'VUni'; function normalizeDataset(el) {
const PRIMARY_COLOR = '#007aff'; // TODO
return JSON.parse(JSON.stringify(el.dataset || {}));
function debounce(fn, delay) {
let timeout;
const newFn = function () {
clearTimeout(timeout);
const timerFn = () => fn.apply(this, arguments);
timeout = setTimeout(timerFn, delay);
};
newFn.cancel = function () {
clearTimeout(timeout);
};
return newFn;
} }
function plusReady(callback) { function plusReady(callback) {
...@@ -33,26 +22,6 @@ function plusReady(callback) { ...@@ -33,26 +22,6 @@ function plusReady(callback) {
document.addEventListener('plusready', callback); document.addEventListener('plusready', callback);
} }
const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map((key) => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
}
else if (shared.isPlainObject(val)) {
val = JSON.stringify(val);
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter((x) => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
}
const BUILT_IN_TAGS = [ const BUILT_IN_TAGS = [
'ad', 'ad',
'audio', 'audio',
...@@ -128,6 +97,45 @@ function isNativeTag(tag) { ...@@ -128,6 +97,45 @@ function isNativeTag(tag) {
const COMPONENT_SELECTOR_PREFIX = 'uni-'; const COMPONENT_SELECTOR_PREFIX = 'uni-';
const COMPONENT_PREFIX = 'v-' + COMPONENT_SELECTOR_PREFIX; const COMPONENT_PREFIX = 'v-' + COMPONENT_SELECTOR_PREFIX;
const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map((key) => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
}
else if (shared.isPlainObject(val)) {
val = JSON.stringify(val);
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter((x) => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
}
function debounce(fn, delay) {
let timeout;
const newFn = function () {
clearTimeout(timeout);
const timerFn = () => fn.apply(this, arguments);
timeout = setTimeout(timerFn, delay);
};
newFn.cancel = function () {
clearTimeout(timeout);
};
return newFn;
}
const NAVBAR_HEIGHT = 44;
const TABBAR_HEIGHT = 50;
const RESPONSIVE_MIN_WIDTH = 768;
const COMPONENT_NAME_PREFIX = 'VUni';
const PRIMARY_COLOR = '#007aff';
exports.BUILT_IN_TAGS = BUILT_IN_TAGS; exports.BUILT_IN_TAGS = BUILT_IN_TAGS;
exports.COMPONENT_NAME_PREFIX = COMPONENT_NAME_PREFIX; exports.COMPONENT_NAME_PREFIX = COMPONENT_NAME_PREFIX;
exports.COMPONENT_PREFIX = COMPONENT_PREFIX; exports.COMPONENT_PREFIX = COMPONENT_PREFIX;
...@@ -141,5 +149,7 @@ exports.debounce = debounce; ...@@ -141,5 +149,7 @@ exports.debounce = debounce;
exports.isBuiltInComponent = isBuiltInComponent; exports.isBuiltInComponent = isBuiltInComponent;
exports.isCustomElement = isCustomElement; exports.isCustomElement = isCustomElement;
exports.isNativeTag = isNativeTag; exports.isNativeTag = isNativeTag;
exports.normalizeDataset = normalizeDataset;
exports.passive = passive;
exports.plusReady = plusReady; exports.plusReady = plusReady;
exports.stringifyQuery = stringifyQuery; exports.stringifyQuery = stringifyQuery;
...@@ -20,6 +20,12 @@ export declare function isNativeTag(tag: string): boolean; ...@@ -20,6 +20,12 @@ export declare function isNativeTag(tag: string): boolean;
export declare const NAVBAR_HEIGHT = 44; export declare const NAVBAR_HEIGHT = 44;
export declare function normalizeDataset(el: Element): any;
export declare function passive(passive: boolean): {
passive: boolean;
};
export declare function plusReady(callback: () => void): void; export declare function plusReady(callback: () => void): void;
export declare const PRIMARY_COLOR = "#007aff"; export declare const PRIMARY_COLOR = "#007aff";
......
import { isPlainObject, isHTMLTag, isSVGTag } from '@vue/shared'; import { isHTMLTag, isSVGTag, isPlainObject } from '@vue/shared';
const NAVBAR_HEIGHT = 44; function passive(passive) {
const TABBAR_HEIGHT = 50; return { passive };
const RESPONSIVE_MIN_WIDTH = 768; }
const COMPONENT_NAME_PREFIX = 'VUni'; function normalizeDataset(el) {
const PRIMARY_COLOR = '#007aff'; // TODO
return JSON.parse(JSON.stringify(el.dataset || {}));
function debounce(fn, delay) {
let timeout;
const newFn = function () {
clearTimeout(timeout);
const timerFn = () => fn.apply(this, arguments);
timeout = setTimeout(timerFn, delay);
};
newFn.cancel = function () {
clearTimeout(timeout);
};
return newFn;
} }
function plusReady(callback) { function plusReady(callback) {
...@@ -29,26 +18,6 @@ function plusReady(callback) { ...@@ -29,26 +18,6 @@ function plusReady(callback) {
document.addEventListener('plusready', callback); document.addEventListener('plusready', callback);
} }
const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map((key) => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
}
else if (isPlainObject(val)) {
val = JSON.stringify(val);
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter((x) => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
}
const BUILT_IN_TAGS = [ const BUILT_IN_TAGS = [
'ad', 'ad',
'audio', 'audio',
...@@ -124,4 +93,43 @@ function isNativeTag(tag) { ...@@ -124,4 +93,43 @@ function isNativeTag(tag) {
const COMPONENT_SELECTOR_PREFIX = 'uni-'; const COMPONENT_SELECTOR_PREFIX = 'uni-';
const COMPONENT_PREFIX = 'v-' + COMPONENT_SELECTOR_PREFIX; const COMPONENT_PREFIX = 'v-' + COMPONENT_SELECTOR_PREFIX;
export { BUILT_IN_TAGS, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, NAVBAR_HEIGHT, PRIMARY_COLOR, RESPONSIVE_MIN_WIDTH, TABBAR_HEIGHT, TAGS, debounce, isBuiltInComponent, isCustomElement, isNativeTag, plusReady, stringifyQuery }; const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map((key) => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
}
else if (isPlainObject(val)) {
val = JSON.stringify(val);
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter((x) => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
}
function debounce(fn, delay) {
let timeout;
const newFn = function () {
clearTimeout(timeout);
const timerFn = () => fn.apply(this, arguments);
timeout = setTimeout(timerFn, delay);
};
newFn.cancel = function () {
clearTimeout(timeout);
};
return newFn;
}
const NAVBAR_HEIGHT = 44;
const TABBAR_HEIGHT = 50;
const RESPONSIVE_MIN_WIDTH = 768;
const COMPONENT_NAME_PREFIX = 'VUni';
const PRIMARY_COLOR = '#007aff';
export { BUILT_IN_TAGS, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, NAVBAR_HEIGHT, PRIMARY_COLOR, RESPONSIVE_MIN_WIDTH, TABBAR_HEIGHT, TAGS, debounce, isBuiltInComponent, isCustomElement, isNativeTag, normalizeDataset, passive, plusReady, stringifyQuery };
export function passive(passive: boolean) {
return { passive }
}
export function normalizeDataset(el: Element) {
// TODO
return JSON.parse(JSON.stringify((el as HTMLElement).dataset || {}))
}
export * from './constants' export * from './dom'
export * from './debounce' export * from './plus'
export * from './plusReady'
export * from './query'
export * from './tags' export * from './tags'
export * from './query'
export * from './debounce'
export * from './constants'
...@@ -41,7 +41,8 @@ ...@@ -41,7 +41,8 @@
}, },
"devDependencies": { "devDependencies": {
"@types/mime": "^2.0.3", "@types/mime": "^2.0.3",
"@types/sass": "^1.16.0" "@types/sass": "^1.16.0",
"@vue/compiler-sfc": "^3.0.11"
}, },
"uni-app": { "uni-app": {
"compilerVersion": "3.1.2" "compilerVersion": "3.1.2"
......
...@@ -145,11 +145,11 @@ function resolveManifestFeature( ...@@ -145,11 +145,11 @@ function resolveManifestFeature(
options: VitePluginUniResolvedOptions options: VitePluginUniResolvedOptions
): ManifestFeatures { ): ManifestFeatures {
const features: ManifestFeatures = { const features: ManifestFeatures = {
wx: true, wx: false,
wxs: true, // 是否启用 wxs 支持,如:getComponentDescriptor 等(uni-core/src/view/plugin/appConfig) wxs: true,
promise: false, // 是否启用旧版本的 promise 支持(即返回[err,res]的格式) promise: false,
longpress: true, // 是否启用longpress longpress: true,
routerMode: '"hash"', // 启用的 router 类型(uni-h5/src/framework/plugin/router) routerMode: '"hash"',
} }
const manifest = parse( const manifest = parse(
fs.readFileSync(path.join(options.inputDir, 'manifest.json'), 'utf8') fs.readFileSync(path.join(options.inputDir, 'manifest.json'), 'utf8')
......
...@@ -30,7 +30,10 @@ ...@@ -30,7 +30,10 @@
"@dcloudio/uni-mp-polyfill": [ "@dcloudio/uni-mp-polyfill": [
"packages/uni-mp-core/src/runtime/polyfill" "packages/uni-mp-core/src/runtime/polyfill"
], ],
"@dcloudio/uni-platform": ["packages/uni-h5/src/platform/index.ts"] "@dcloudio/uni-platform": ["packages/uni-h5/src/platform/index.ts"],
"@dcloudio/uni-mp-platform": [
"packages/uni-mp-core/src/platform/index.ts"
]
} }
}, },
"include": [ "include": [
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册