Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qianlong66
uni-app
提交
08a578bc
U
uni-app
项目概览
qianlong66
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
08a578bc
编写于
8月 10, 2021
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: remove useless code
上级
9e2e54cd
变更
23
展开全部
隐藏空白更改
内联
并排
Showing
23 changed file
with
236 addition
and
2425 deletion
+236
-2425
packages/uni-app-plus/dist/uni-app-service.es.js
packages/uni-app-plus/dist/uni-app-service.es.js
+85
-122
packages/uni-app-plus/dist/uni-app-view.umd.js
packages/uni-app-plus/dist/uni-app-view.umd.js
+73
-73
packages/uni-components/src/components/audio/index.vue
packages/uni-components/src/components/audio/index.vue
+0
-164
packages/uni-components/src/components/index.ts
packages/uni-components/src/components/index.ts
+0
-2
packages/uni-components/src/mixins/animation.js
packages/uni-components/src/mixins/animation.js
+0
-123
packages/uni-components/src/mixins/base-input.js
packages/uni-components/src/mixins/base-input.js
+0
-49
packages/uni-components/src/mixins/base.js
packages/uni-components/src/mixins/base.js
+0
-16
packages/uni-components/src/mixins/emitter.js
packages/uni-components/src/mixins/emitter.js
+0
-59
packages/uni-components/src/mixins/hover.js
packages/uni-components/src/mixins/hover.js
+0
-69
packages/uni-components/src/mixins/index.ts
packages/uni-components/src/mixins/index.ts
+0
-14
packages/uni-components/src/mixins/interact.js
packages/uni-components/src/mixins/interact.js
+0
-61
packages/uni-components/src/mixins/keyboard.js
packages/uni-components/src/mixins/keyboard.js
+0
-127
packages/uni-components/src/mixins/listeners.js
packages/uni-components/src/mixins/listeners.js
+0
-100
packages/uni-components/src/mixins/scroller/Friction.js
packages/uni-components/src/mixins/scroller/Friction.js
+0
-67
packages/uni-components/src/mixins/scroller/Scroll.js
packages/uni-components/src/mixins/scroller/Scroll.js
+0
-84
packages/uni-components/src/mixins/scroller/Scroller.js
packages/uni-components/src/mixins/scroller/Scroller.js
+0
-305
packages/uni-components/src/mixins/scroller/Spring.js
packages/uni-components/src/mixins/scroller/Spring.js
+0
-196
packages/uni-components/src/mixins/scroller/index.js
packages/uni-components/src/mixins/scroller/index.js
+0
-126
packages/uni-components/src/mixins/subscriber.js
packages/uni-components/src/mixins/subscriber.js
+0
-59
packages/uni-components/src/mixins/touchtrack.js
packages/uni-components/src/mixins/touchtrack.js
+0
-141
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+30
-225
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+48
-242
packages/uni-h5/src/index.ts
packages/uni-h5/src/index.ts
+0
-1
未找到文件。
packages/uni-app-plus/dist/uni-app-service.es.js
浏览文件 @
08a578bc
...
@@ -10,79 +10,79 @@ const __uniRoutes = instanceContext.__uniRoutes;
...
@@ -10,79 +10,79 @@ const __uniRoutes = instanceContext.__uniRoutes;
var serviceContext = (function (vue) {
var serviceContext = (function (vue) {
'use strict';
'use strict';
/*
/*
* base64-arraybuffer
* base64-arraybuffer
* https://github.com/niklasvh/base64-arraybuffer
* https://github.com/niklasvh/base64-arraybuffer
*
*
* Copyright (c) 2012 Niklas von Hertzen
* Copyright (c) 2012 Niklas von Hertzen
* Licensed under the MIT license.
* Licensed under the MIT license.
*/
*/
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// Use a lookup table to find the index.
// Use a lookup table to find the index.
var lookup = /*#__PURE__*/ (function () {
var lookup = /*#__PURE__*/ (function () {
const lookup = new Uint8Array(256);
const lookup = new Uint8Array(256);
for (var i = 0; i < chars.length; i++) {
for (var i = 0; i < chars.length; i++) {
lookup[chars.charCodeAt(i)] = i;
lookup[chars.charCodeAt(i)] = i;
}
}
return lookup
return lookup
})();
})();
function encode$3(arraybuffer) {
function encode$3(arraybuffer) {
var bytes = new Uint8Array(arraybuffer),
var bytes = new Uint8Array(arraybuffer),
i,
i,
len = bytes.length,
len = bytes.length,
base64 = '';
base64 = '';
for (i = 0; i < len; i += 3) {
for (i = 0; i < len; i += 3) {
base64 += chars[bytes[i] >> 2];
base64 += chars[bytes[i] >> 2];
base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
base64 += chars[bytes[i + 2] & 63];
base64 += chars[bytes[i + 2] & 63];
}
}
if (len % 3 === 2) {
if (len % 3 === 2) {
base64 = base64.substring(0, base64.length - 1) + '=';
base64 = base64.substring(0, base64.length - 1) + '=';
} else if (len % 3 === 1) {
} else if (len % 3 === 1) {
base64 = base64.substring(0, base64.length - 2) + '==';
base64 = base64.substring(0, base64.length - 2) + '==';
}
}
return base64
return base64
}
}
function decode$1(base64) {
function decode$1(base64) {
var bufferLength = base64.length * 0.75,
var bufferLength = base64.length * 0.75,
len = base64.length,
len = base64.length,
i,
i,
p = 0,
p = 0,
encoded1,
encoded1,
encoded2,
encoded2,
encoded3,
encoded3,
encoded4;
encoded4;
if (base64[base64.length - 1] === '=') {
if (base64[base64.length - 1] === '=') {
bufferLength--;
bufferLength--;
if (base64[base64.length - 2] === '=') {
if (base64[base64.length - 2] === '=') {
bufferLength--;
bufferLength--;
}
}
}
}
var arraybuffer = new ArrayBuffer(bufferLength),
var arraybuffer = new ArrayBuffer(bufferLength),
bytes = new Uint8Array(arraybuffer);
bytes = new Uint8Array(arraybuffer);
for (i = 0; i < len; i += 4) {
for (i = 0; i < len; i += 4) {
encoded1 = lookup[base64.charCodeAt(i)];
encoded1 = lookup[base64.charCodeAt(i)];
encoded2 = lookup[base64.charCodeAt(i + 1)];
encoded2 = lookup[base64.charCodeAt(i + 1)];
encoded3 = lookup[base64.charCodeAt(i + 2)];
encoded3 = lookup[base64.charCodeAt(i + 2)];
encoded4 = lookup[base64.charCodeAt(i + 3)];
encoded4 = lookup[base64.charCodeAt(i + 3)];
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
}
}
return arraybuffer
return arraybuffer
}
}
/**
/**
...
@@ -7057,7 +7057,7 @@ var serviceContext = (function (vue) {
...
@@ -7057,7 +7057,7 @@ var serviceContext = (function (vue) {
plus.gallery.save(options.filePath, warpPlusSuccessCallback(resolve), warpPlusErrorCallback(reject));
plus.gallery.save(options.filePath, warpPlusSuccessCallback(resolve), warpPlusErrorCallback(reject));
}, SaveImageToPhotosAlbumProtocol, SaveImageToPhotosAlbumOptions);
}, SaveImageToPhotosAlbumProtocol, SaveImageToPhotosAlbumOptions);
const compressImage
$1
= defineAsyncApi(API_COMPRESS_IMAGE, (options, { resolve, reject }) => {
const compressImage = defineAsyncApi(API_COMPRESS_IMAGE, (options, { resolve, reject }) => {
const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`;
const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`;
plus.zip.compressImage(extend({}, options, {
plus.zip.compressImage(extend({}, options, {
dst,
dst,
...
@@ -7091,23 +7091,6 @@ var serviceContext = (function (vue) {
...
@@ -7091,23 +7091,6 @@ var serviceContext = (function (vue) {
}, reject);
}, reject);
});
});
}
}
function compressImage(tempFilePath) {
const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(tempFilePath)}`;
return new Promise((resolve) => {
plus.nativeUI.showWaiting();
plus.zip.compressImage({
src: tempFilePath,
dst,
overwrite: true,
}, () => {
plus.nativeUI.closeWaiting();
resolve(dst);
}, () => {
plus.nativeUI.closeWaiting();
resolve(tempFilePath);
});
});
}
const chooseImage = defineAsyncApi(API_CHOOSE_IMAGE,
const chooseImage = defineAsyncApi(API_CHOOSE_IMAGE,
// @ts-ignore crop 属性App特有
// @ts-ignore crop 属性App特有
({ count, sizeType, sourceType, crop } = {}, { resolve, reject }) => {
({ count, sizeType, sourceType, crop } = {}, { resolve, reject }) => {
...
@@ -7117,37 +7100,13 @@ var serviceContext = (function (vue) {
...
@@ -7117,37 +7100,13 @@ var serviceContext = (function (vue) {
function successCallback(paths) {
function successCallback(paths) {
const tempFiles = [];
const tempFiles = [];
const tempFilePaths = [];
const tempFilePaths = [];
// plus.zip.compressImage 压缩文件并发调用在iOS端容易出现问题(图像错误、闪退),改为队列执行
Promise.all(paths.map((path) => getFileInfo(path)))
paths
.then((filesInfo) => {
.reduce((promise, path) => {
filesInfo.forEach((file, index) => {
return promise
const path = paths[index];
.then(() => {
return getFileInfo(path);
})
.then((fileInfo) => {
const size = fileInfo.size;
// 压缩阈值 0.5 兆
const THRESHOLD = 1024 * 1024 * 0.5;
// 判断是否需要压缩
if (!crop &&
sizeType.includes('compressed') &&
size > THRESHOLD) {
return compressImage(path).then((dstPath) => {
path = dstPath;
return getFileInfo(path);
});
}
return fileInfo;
})
.then(({ size }) => {
tempFilePaths.push(path);
tempFilePaths.push(path);
tempFiles.push({
tempFiles.push({ path, size: file.size });
path,
size: size,
});
});
});
}, Promise.resolve())
.then(() => {
resolve({
resolve({
tempFilePaths,
tempFilePaths,
tempFiles,
tempFiles,
...
@@ -7173,6 +7132,8 @@ var serviceContext = (function (vue) {
...
@@ -7173,6 +7132,8 @@ var serviceContext = (function (vue) {
filename: TEMP_PATH + '/gallery/',
filename: TEMP_PATH + '/gallery/',
permissionAlert: true,
permissionAlert: true,
crop,
crop,
// @ts-expect-error
sizeType,
});
});
}
}
if (sourceType.length === 1) {
if (sourceType.length === 1) {
...
@@ -10061,7 +10022,9 @@ var serviceContext = (function (vue) {
...
@@ -10061,7 +10022,9 @@ var serviceContext = (function (vue) {
function createPreloadWebview() {
function createPreloadWebview() {
if (!preloadWebview$1 || preloadWebview$1.__uniapp_route) {
if (!preloadWebview$1 || preloadWebview$1.__uniapp_route) {
// 不存在,或已被使用
// 不存在,或已被使用
preloadWebview$1 = plus.webview.create(VIEW_WEBVIEW_PATH, String(genWebviewId()));
preloadWebview$1 = plus.webview.create(VIEW_WEBVIEW_PATH, String(genWebviewId()),
// @ts-expect-error
{ contentAdjust: false });
if ((process.env.NODE_ENV !== 'production')) {
if ((process.env.NODE_ENV !== 'production')) {
console.log(formatLog('createPreloadWebview', preloadWebview$1.id));
console.log(formatLog('createPreloadWebview', preloadWebview$1.id));
}
}
...
@@ -11999,7 +11962,7 @@ var serviceContext = (function (vue) {
...
@@ -11999,7 +11962,7 @@ var serviceContext = (function (vue) {
getRecorderManager: getRecorderManager,
getRecorderManager: getRecorderManager,
saveVideoToPhotosAlbum: saveVideoToPhotosAlbum,
saveVideoToPhotosAlbum: saveVideoToPhotosAlbum,
saveImageToPhotosAlbum: saveImageToPhotosAlbum,
saveImageToPhotosAlbum: saveImageToPhotosAlbum,
compressImage: compressImage
$1
,
compressImage: compressImage,
compressVideo: compressVideo,
compressVideo: compressVideo,
chooseImage: chooseImage,
chooseImage: chooseImage,
chooseVideo: chooseVideo,
chooseVideo: chooseVideo,
...
...
packages/uni-app-plus/dist/uni-app-view.umd.js
浏览文件 @
08a578bc
此差异已折叠。
点击以展开。
packages/uni-components/src/components/audio/index.vue
已删除
100644 → 0
浏览文件 @
9e2e54cd
<
template
>
<uni-audio
:id=
"id"
:controls=
"!!controls"
v-bind=
"$attrs"
>
<audio
ref=
"audio"
:loop=
"loop"
style=
"display:none;"
/>
<div
class=
"uni-audio-default"
>
<div
:style=
"'background-image: url('+$getRealPath(poster)+');'"
class=
"uni-audio-left"
>
<div
:class=
"
{play:!playing,pause:playing}"
class="uni-audio-button"
@click="trigger"
/>
</div>
<div
class=
"uni-audio-right"
>
<div
class=
"uni-audio-time"
>
{{
currentTime
}}
</div>
<div
class=
"uni-audio-info"
>
<div
class=
"uni-audio-name"
>
{{
name
}}
</div>
<div
class=
"uni-audio-author"
>
{{
author
}}
</div>
</div>
</div>
</div>
</uni-audio>
</
template
>
<
script
>
import
{
subscriber
}
from
'
../../mixins
'
export
default
{
name
:
'
Audio
'
,
mixins
:
[
subscriber
],
props
:
{
id
:
{
type
:
String
,
default
:
''
},
src
:
{
type
:
String
,
default
:
''
},
loop
:
{
type
:
[
Boolean
,
String
],
default
:
false
},
controls
:
{
type
:
[
Boolean
,
String
],
default
:
false
},
poster
:
{
type
:
String
,
default
:
''
},
name
:
{
type
:
String
,
default
:
''
},
author
:
{
type
:
String
,
default
:
''
}
},
data
()
{
return
{
playing
:
false
,
currentTime
:
this
.
getTime
(
0
)
}
},
watch
:
{
src
(
val
)
{
if
(
this
.
$refs
.
audio
)
{
this
.
$refs
.
audio
.
src
=
this
.
$getRealPath
(
val
)
}
}
},
mounted
()
{
const
audio
=
this
.
$refs
.
audio
audio
.
addEventListener
(
'
error
'
,
$event
=>
{
this
.
playing
=
false
this
.
$trigger
(
'
error
'
,
$event
,
{})
})
audio
.
addEventListener
(
'
play
'
,
$event
=>
{
this
.
playing
=
true
this
.
$trigger
(
'
play
'
,
$event
,
{})
})
audio
.
addEventListener
(
'
pause
'
,
$event
=>
{
this
.
playing
=
false
this
.
$trigger
(
'
pause
'
,
$event
,
{})
})
audio
.
addEventListener
(
'
ended
'
,
$event
=>
{
this
.
playing
=
false
this
.
$trigger
(
'
ended
'
,
$event
,
{})
})
audio
.
addEventListener
(
'
timeupdate
'
,
$event
=>
{
var
currentTime
=
audio
.
currentTime
this
.
currentTime
=
this
.
getTime
(
currentTime
)
var
duration
=
audio
.
duration
this
.
$trigger
(
'
timeupdate
'
,
$event
,
{
currentTime
,
duration
})
})
audio
.
src
=
this
.
$getRealPath
(
this
.
src
)
},
methods
:
{
_handleSubscribe
({
type
,
data
=
{}
})
{
var
audio
=
this
.
$refs
.
audio
switch
(
type
)
{
case
'
setSrc
'
:
audio
.
src
=
this
.
$getRealPath
(
data
.
src
)
this
.
$emit
(
'
update:src
'
,
data
.
src
)
break
case
'
play
'
:
audio
.
play
()
break
case
'
pause
'
:
audio
.
pause
()
break
case
'
seek
'
:
audio
.
currentTime
=
data
.
position
break
}
},
trigger
()
{
if
(
this
.
playing
)
{
this
.
$refs
.
audio
.
pause
()
}
else
{
this
.
$refs
.
audio
.
play
()
}
},
getTime
(
time
)
{
var
h
=
Math
.
floor
(
time
/
3600
)
var
m
=
Math
.
floor
(
time
%
3600
/
60
)
var
s
=
Math
.
floor
(
time
%
3600
%
60
)
h
=
(
h
<
10
?
'
0
'
:
''
)
+
h
m
=
(
m
<
10
?
'
0
'
:
''
)
+
m
s
=
(
s
<
10
?
'
0
'
:
''
)
+
s
var
str
=
m
+
'
:
'
+
s
if
(
h
!==
'
00
'
)
{
str
=
h
+
'
:
'
+
str
}
return
str
}
}
}
</
script
>
packages/uni-components/src/components/index.ts
浏览文件 @
08a578bc
import
Audio
from
'
./audio/index.vue
'
import
Button
from
'
./button/index
'
import
Button
from
'
./button/index
'
import
Canvas
from
'
./canvas/index
'
import
Canvas
from
'
./canvas/index
'
import
Checkbox
from
'
./checkbox/index
'
import
Checkbox
from
'
./checkbox/index
'
...
@@ -28,7 +27,6 @@ import Text from './text/index'
...
@@ -28,7 +27,6 @@ import Text from './text/index'
import
Textarea
from
'
./textarea/index
'
import
Textarea
from
'
./textarea/index
'
import
View
from
'
./view/index
'
import
View
from
'
./view/index
'
export
{
export
{
Audio
,
Button
,
Button
,
Canvas
,
Canvas
,
Checkbox
,
Checkbox
,
...
...
packages/uni-components/src/mixins/animation.js
已删除
100644 → 0
浏览文件 @
9e2e54cd
import
{
upx2px
}
from
'
@dcloudio/uni-api
'
function
converPx
(
value
)
{
if
(
/^-
?\d
+
[
ur
]
px$/i
.
test
(
value
))
{
return
value
.
replace
(
/
(
^-
?\d
+
)[
ur
]
px$/i
,
(
text
,
num
)
=>
{
return
`
${
upx2px
(
parseFloat
(
num
))}
px`
})
// eslint-disable-next-line no-useless-escape
}
else
if
(
/^-
?[\d\.]
+$/
.
test
(
value
))
{
return
`
${
value
}
px`
}
return
value
||
''
}
function
converType
(
type
)
{
return
type
.
replace
(
/
[
A-Z
]
/g
,
text
=>
{
return
`-
${
text
.
toLowerCase
()}
`
})
.
replace
(
'
webkit
'
,
'
-webkit
'
)
}
function
getStyle
(
action
)
{
const
animateTypes1
=
[
'
matrix
'
,
'
matrix3d
'
,
'
scale
'
,
'
scale3d
'
,
'
rotate3d
'
,
'
skew
'
,
'
translate
'
,
'
translate3d
'
]
const
animateTypes2
=
[
'
scaleX
'
,
'
scaleY
'
,
'
scaleZ
'
,
'
rotate
'
,
'
rotateX
'
,
'
rotateY
'
,
'
rotateZ
'
,
'
skewX
'
,
'
skewY
'
,
'
translateX
'
,
'
translateY
'
,
'
translateZ
'
]
const
animateTypes3
=
[
'
opacity
'
,
'
background-color
'
]
const
animateTypes4
=
[
'
width
'
,
'
height
'
,
'
left
'
,
'
right
'
,
'
top
'
,
'
bottom
'
]
const
animates
=
action
.
animates
const
option
=
action
.
option
const
transition
=
option
.
transition
const
style
=
{}
const
transform
=
[]
animates
.
forEach
(
animate
=>
{
let
type
=
animate
.
type
let
args
=
[...
animate
.
args
]
if
(
animateTypes1
.
concat
(
animateTypes2
).
includes
(
type
))
{
if
(
type
.
startsWith
(
'
rotate
'
)
||
type
.
startsWith
(
'
skew
'
))
{
args
=
args
.
map
(
value
=>
parseFloat
(
value
)
+
'
deg
'
)
}
else
if
(
type
.
startsWith
(
'
translate
'
))
{
args
=
args
.
map
(
converPx
)
}
if
(
animateTypes2
.
indexOf
(
type
)
>=
0
)
{
args
.
length
=
1
}
transform
.
push
(
`
${
type
}
(
${
args
.
join
(
'
,
'
)}
)`
)
}
else
if
(
animateTypes3
.
concat
(
animateTypes4
).
includes
(
args
[
0
]))
{
type
=
args
[
0
]
const
value
=
args
[
1
]
style
[
type
]
=
animateTypes4
.
includes
(
type
)
?
converPx
(
value
)
:
value
}
})
style
.
transform
=
style
.
webkitTransform
=
transform
.
join
(
'
'
)
style
.
transition
=
style
.
webkitTransition
=
Object
.
keys
(
style
)
.
map
(
type
=>
`
${
converType
(
type
)}
${
transition
.
duration
}
ms
${
transition
.
timingFunction
}
${
transition
.
delay
}
ms`
)
.
join
(
'
,
'
)
style
.
transformOrigin
=
style
.
webkitTransformOrigin
=
option
.
transformOrigin
return
style
}
function
startAnimation
(
context
)
{
const
animation
=
context
.
animation
if
(
!
animation
||
!
animation
.
actions
||
!
animation
.
actions
.
length
)
{
return
}
let
index
=
0
const
actions
=
animation
.
actions
const
length
=
animation
.
actions
.
length
function
animate
()
{
const
action
=
actions
[
index
]
const
transition
=
action
.
option
.
transition
const
style
=
getStyle
(
action
)
Object
.
keys
(
style
).
forEach
(
key
=>
{
context
.
$el
.
style
[
key
]
=
style
[
key
]
})
index
+=
1
if
(
index
<
length
)
{
setTimeout
(
animate
,
transition
.
duration
+
transition
.
delay
)
}
}
setTimeout
(()
=>
{
animate
()
},
0
)
}
export
default
{
props
:
[
'
animation
'
],
watch
:
{
animation
()
{
startAnimation
(
this
)
}
},
mounted
()
{
startAnimation
(
this
)
}
}
packages/uni-components/src/mixins/base-input.js
已删除
100644 → 0
浏览文件 @
9e2e54cd
import
{
debounce
}
from
'
@dcloudio/uni-shared
'
import
{
throttle
}
from
'
../helpers/throttle
'
import
emitter
from
'
./emitter
'
import
keyboard
from
'
./keyboard
'
export
default
{
name
:
'
BaseInput
'
,
mixins
:
[
emitter
,
keyboard
],
model
:
{
prop
:
'
value
'
,
event
:
'
update:value
'
},
props
:
{
value
:
{
type
:
[
String
,
Number
],
default
:
''
}
},
data
()
{
return
{
valueSync
:
this
.
_getValueString
(
this
.
value
)
}
},
created
()
{
const
valueChange
=
(
this
.
__valueChange
=
debounce
(
val
=>
{
this
.
valueSync
=
this
.
_getValueString
(
val
)
},
100
))
this
.
$watch
(
'
value
'
,
valueChange
)
this
.
__triggerInput
=
throttle
((
$event
,
detail
)
=>
{
this
.
$emit
(
'
update:value
'
,
detail
.
value
)
this
.
$trigger
(
'
input
'
,
$event
,
detail
)
},
100
)
this
.
$triggerInput
=
(
$event
,
detail
)
=>
{
this
.
__valueChange
.
cancel
()
this
.
__triggerInput
(
$event
,
detail
)
}
},
beforeDestroy
()
{
this
.
__valueChange
.
cancel
()
this
.
__triggerInput
.
cancel
()
},
methods
:
{
_getValueString
(
value
)
{
return
value
===
null
?
''
:
String
(
value
)
}
}
}
packages/uni-components/src/mixins/base.js
已删除
100644 → 0
浏览文件 @
9e2e54cd
import
getRealPath
from
'
uni-platform/helpers/get-real-path
'
import
{
processEvent
}
from
'
uni-view/plugins/events
'
export
default
{
methods
:
{
$getRealPath
(
src
)
{
return
src
?
getRealPath
(
src
)
:
src
},
$trigger
(
name
,
$event
,
detail
)
{
this
.
$emit
(
name
,
processEvent
.
call
(
this
,
name
,
$event
,
detail
,
this
.
$el
,
this
.
$el
)
)
}
}
}
packages/uni-components/src/mixins/emitter.js
已删除
100644 → 0
浏览文件 @
9e2e54cd
// 暂不提供通知所有
// function broadcast (componentName, eventName, ...params) {
// this.$children.forEach(child => {
// const name = child.$options.name && child.$options.name.substr(1)
// if (~componentName.indexOf(name)) {
// child.$emit.apply(child, [eventName].concat(params))
// } else {
// broadcast.apply(child, [componentName, eventName].concat([params]))
// }
// })
// }
function
broadcast
(
componentName
,
eventName
,
...
params
)
{
const
children
=
this
.
$children
const
len
=
children
.
length
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
const
child
=
children
[
i
]
const
name
=
child
.
$options
.
name
&&
child
.
$options
.
name
.
substr
(
4
)
if
(
~
componentName
.
indexOf
(
name
))
{
child
.
$emit
.
apply
(
child
,
[
eventName
].
concat
(
params
))
return
false
}
else
{
if
(
broadcast
.
apply
(
child
,
[
componentName
,
eventName
].
concat
([
params
]))
===
false
)
{
return
false
}
}
}
}
export
default
{
methods
:
{
$dispatch
(
componentName
,
eventName
,
...
params
)
{
console
.
log
(
'
$dispatch
'
,
componentName
,
eventName
,
params
)
// if (typeof componentName === 'string') {
// componentName = [componentName]
// }
// let parent = this.$parent || this.$root
// let name = parent.$options.name && parent.$options.name.substr(4)
// while (parent && (!name || !~componentName.indexOf(name))) {
// parent = parent.$parent
// if (parent) {
// name = parent.$options.name && parent.$options.name.substr(4)
// }
// }
// if (parent) {
// parent.$emit.apply(parent, [eventName].concat(params))
// }
},
$broadcast
(
componentName
,
eventName
,
...
params
)
{
if
(
typeof
componentName
===
'
string
'
)
{
componentName
=
[
componentName
]
}
broadcast
.
apply
(
this
,
[
componentName
,
eventName
].
concat
(
params
))
},
},
}
packages/uni-components/src/mixins/hover.js
已删除
100644 → 0
浏览文件 @
9e2e54cd
export
default
{
data
()
{
return
{
hovering
:
false
}
},
props
:
{
hoverClass
:
{
type
:
String
,
default
:
'
none
'
},
hoverStopPropagation
:
{
type
:
Boolean
,
default
:
false
},
hoverStartTime
:
{
type
:
[
Number
,
String
],
default
:
50
},
hoverStayTime
:
{
type
:
[
Number
,
String
],
default
:
400
}
},
methods
:
{
_hoverTouchStart
(
evt
)
{
// TODO detect scrolling
if
(
evt
.
_hoverPropagationStopped
)
{
return
}
if
(
!
this
.
hoverClass
||
this
.
hoverClass
===
'
none
'
||
this
.
disabled
)
{
return
}
if
(
evt
.
touches
.
length
>
1
)
{
return
}
if
(
this
.
hoverStopPropagation
)
{
evt
.
_hoverPropagationStopped
=
true
}
this
.
_hoverTouch
=
true
this
.
_hoverStartTimer
=
setTimeout
(()
=>
{
this
.
hovering
=
true
if
(
!
this
.
_hoverTouch
)
{
// 防止在hoverStartTime时间内触发了 touchend 或 touchcancel
this
.
_hoverReset
()
}
},
this
.
hoverStartTime
)
},
_hoverTouchEnd
(
evt
)
{
this
.
_hoverTouch
=
false
if
(
this
.
hovering
)
{
this
.
_hoverReset
()
}
},
_hoverReset
()
{
requestAnimationFrame
(()
=>
{
clearTimeout
(
this
.
_hoverStayTimer
)
this
.
_hoverStayTimer
=
setTimeout
(()
=>
{
this
.
hovering
=
false
},
this
.
hoverStayTime
)
})
},
_hoverTouchCancel
(
evt
)
{
this
.
_hoverTouch
=
false
this
.
hovering
=
false
clearTimeout
(
this
.
_hoverStartTimer
)
}
}
}
packages/uni-components/src/mixins/index.ts
已删除
100644 → 0
浏览文件 @
9e2e54cd
// @ts-ignore
export
{
default
as
emitter
}
from
'
./emitter
'
// @ts-ignore
export
{
default
as
listeners
}
from
'
./listeners
'
// @ts-ignore
export
{
default
as
hover
}
from
'
./hover
'
// @ts-ignore
export
{
default
as
subscriber
}
from
'
./subscriber
'
// @ts-ignore
export
{
default
as
keyboard
}
from
'
./keyboard
'
// @ts-ignore
export
{
default
as
baseInput
}
from
'
./base-input
'
// @ts-ignore
export
{
default
as
interact
}
from
'
./interact
'
packages/uni-components/src/mixins/interact.js
已删除
100644 → 0
浏览文件 @
9e2e54cd
const
passiveOptions
=
{
passive
:
true
,
capture
:
true
,
}
const
vms
=
[]
let
userInteract
=
0
let
inited
function
addInteractListener
(
vm
)
{
if
(
!
inited
)
{
inited
=
true
const
eventNames
=
[
'
touchstart
'
,
'
touchmove
'
,
'
touchend
'
,
'
mousedown
'
,
'
mouseup
'
,
]
eventNames
.
forEach
((
eventName
)
=>
{
document
.
addEventListener
(
eventName
,
function
()
{
vms
.
forEach
((
vm
)
=>
{
vm
.
userInteract
=
true
userInteract
++
setTimeout
(()
=>
{
userInteract
--
if
(
!
userInteract
)
{
vm
.
userInteract
=
false
}
},
0
)
})
},
passiveOptions
)
})
}
vms
.
push
(
vm
)
}
function
removeInteractListener
(
vm
)
{
const
index
=
vms
.
indexOf
(
vm
)
if
(
index
>=
0
)
{
vms
.
splice
(
index
,
1
)
}
}
export
default
{
data
()
{
return
{
/**
* 是否用户交互行为
*/
userInteract
:
false
,
}
},
mounted
()
{
addInteractListener
(
this
)
},
beforeDestroy
()
{
removeInteractListener
(
this
)
},
}
packages/uni-components/src/mixins/keyboard.js
已删除
100644 → 0
浏览文件 @
9e2e54cd
import
{
plusReady
}
from
'
@dcloudio/uni-shared
'
function
hideKeyboard
()
{
document
.
activeElement
.
blur
()
}
/**
* 保证iOS点击输入框外隐藏键盘
*/
function
iosHideKeyboard
()
{}
export
default
{
name
:
'
Keyboard
'
,
props
:
{
cursorSpacing
:
{
type
:
[
Number
,
String
],
default
:
0
},
showConfirmBar
:
{
type
:
[
Boolean
,
String
],
default
:
'
auto
'
},
adjustPosition
:
{
type
:
Boolean
,
default
:
true
}
},
watch
:
{
focus
(
val
)
{
if
(
val
&&
__PLATFORM__
===
'
app-plus
'
)
{
this
.
showSoftKeybord
()
}
}
},
mounted
()
{
if
(
this
.
autoFocus
||
this
.
focus
)
{
this
.
showSoftKeybord
()
}
},
beforeDestroy
()
{
this
.
onKeyboardHide
()
},
methods
:
{
initKeyboard
(
el
)
{
el
.
addEventListener
(
'
focus
'
,
()
=>
{
this
.
hideKeyboardTemp
=
function
()
{
hideKeyboard
()
}
UniViewJSBridge
.
subscribe
(
'
hideKeyboard
'
,
this
.
hideKeyboardTemp
)
document
.
addEventListener
(
'
click
'
,
iosHideKeyboard
,
false
)
if
(
__PLATFORM__
===
'
app-plus
'
)
{
this
.
setSoftinputNavBar
()
this
.
setSoftinputTemporary
()
}
})
el
.
addEventListener
(
'
blur
'
,
this
.
onKeyboardHide
.
bind
(
this
))
},
showSoftKeybord
()
{
plusReady
(()
=>
{
plus
.
key
.
showSoftKeybord
()
})
},
setSoftinputTemporary
()
{
plusReady
(()
=>
{
const
currentWebview
=
plus
.
webview
.
currentWebview
()
const
style
=
currentWebview
.
getStyle
()
||
{}
const
rect
=
this
.
$el
.
getBoundingClientRect
()
currentWebview
.
setSoftinputTemporary
&&
currentWebview
.
setSoftinputTemporary
({
mode
:
style
.
softinputMode
===
'
adjustResize
'
?
'
adjustResize
'
:
this
.
adjustPosition
?
'
adjustPan
'
:
'
nothing
'
,
position
:
{
top
:
rect
.
top
,
height
:
rect
.
height
+
(
Number
(
this
.
cursorSpacing
)
||
0
)
}
})
})
},
setSoftinputNavBar
()
{
if
(
this
.
showConfirmBar
===
'
auto
'
)
{
delete
this
.
__softinputNavBar
return
}
plusReady
(()
=>
{
const
currentWebview
=
plus
.
webview
.
currentWebview
()
const
{
softinputNavBar
}
=
currentWebview
.
getStyle
()
||
{}
const
showConfirmBar
=
softinputNavBar
!==
'
none
'
if
(
showConfirmBar
!==
this
.
showConfirmBar
)
{
this
.
__softinputNavBar
=
softinputNavBar
||
'
auto
'
currentWebview
.
setStyle
({
softinputNavBar
:
this
.
showConfirmBar
?
'
auto
'
:
'
none
'
})
}
else
{
delete
this
.
__softinputNavBar
}
})
},
resetSoftinputNavBar
()
{
const
softinputNavBar
=
this
.
__softinputNavBar
if
(
softinputNavBar
)
{
plusReady
(()
=>
{
const
currentWebview
=
plus
.
webview
.
currentWebview
()
currentWebview
.
setStyle
({
softinputNavBar
})
})
}
},
onKeyboardHide
()
{
UniViewJSBridge
.
unsubscribe
(
'
hideKeyboard
'
,
this
.
hideKeyboardTemp
)
document
.
removeEventListener
(
'
click
'
,
iosHideKeyboard
,
false
)
if
(
__PLATFORM__
===
'
app-plus
'
)
{
this
.
resetSoftinputNavBar
()
}
// 修复ios端显示与点击位置错位的Bug by:wyq
if
(
String
(
navigator
.
vendor
).
indexOf
(
'
Apple
'
)
===
0
)
{
document
.
documentElement
.
scrollTo
(
document
.
documentElement
.
scrollLeft
,
document
.
documentElement
.
scrollTop
)
}
}
}
}
packages/uni-components/src/mixins/listeners.js
已删除
100644 → 0
浏览文件 @
9e2e54cd
import
{
isPlainObject
}
from
'
@vue/shared
'
export
default
{
props
:
{
id
:
{
type
:
String
,
default
:
''
}
},
created
()
{
this
.
_addListeners
(
this
.
id
)
// 初始化监听
this
.
$watch
(
'
id
'
,
(
newId
,
oldId
)
=>
{
// watch id
this
.
_removeListeners
(
oldId
,
true
)
this
.
_addListeners
(
newId
,
true
)
})
},
beforeDestroy
()
{
// 销毁时移除
this
.
_removeListeners
(
this
.
id
)
},
methods
:
{
_addListeners
(
id
,
watch
)
{
if
(
watch
&&
!
id
)
{
// id被置空
return
}
const
{
listeners
}
=
this
.
$options
if
(
!
isPlainObject
(
listeners
))
{
return
}
Object
.
keys
(
listeners
).
forEach
(
name
=>
{
if
(
watch
)
{
// watch id
if
(
name
.
indexOf
(
'
@
'
)
!==
0
&&
name
.
indexOf
(
'
uni-
'
)
!==
0
)
{
/* eslint-disable standard/computed-property-even-spacing */
UniViewJSBridge
.
on
(
`uni-
${
name
}
-
${
this
.
$page
.
id
}
-
${
id
}
`
,
this
[
listeners
[
name
]]
)
}
}
else
{
if
(
name
.
indexOf
(
'
@
'
)
===
0
)
{
/* eslint-disable standard/computed-property-even-spacing */
this
.
$on
(
`uni-
${
name
.
substr
(
1
)}
`
,
this
[
listeners
[
name
]])
}
else
if
(
name
.
indexOf
(
'
uni-
'
)
===
0
)
{
// 完全限定
/* eslint-disable standard/computed-property-even-spacing */
UniViewJSBridge
.
on
(
name
,
this
[
listeners
[
name
]])
}
else
if
(
id
)
{
// scoped
/* eslint-disable standard/computed-property-even-spacing */
UniViewJSBridge
.
on
(
`uni-
${
name
}
-
${
this
.
$page
.
id
}
-
${
id
}
`
,
this
[
listeners
[
name
]]
)
}
}
})
},
_removeListeners
(
id
,
watch
)
{
if
(
watch
&&
!
id
)
{
// id之前不存在
return
}
const
{
listeners
}
=
this
.
$options
if
(
!
isPlainObject
(
listeners
))
{
return
}
Object
.
keys
(
listeners
).
forEach
(
name
=>
{
if
(
watch
)
{
// watch id
if
(
name
.
indexOf
(
'
@
'
)
!==
0
&&
name
.
indexOf
(
'
uni-
'
)
!==
0
)
{
/* eslint-disable standard/computed-property-even-spacing */
UniViewJSBridge
.
off
(
`uni-
${
name
}
-
${
this
.
$page
.
id
}
-
${
id
}
`
,
this
[
listeners
[
name
]]
)
}
}
else
{
if
(
name
.
indexOf
(
'
@
'
)
===
0
)
{
/* eslint-disable standard/computed-property-even-spacing */
this
.
$off
(
`uni-
${
name
.
substr
(
1
)}
`
,
this
[
listeners
[
name
]])
}
else
if
(
name
.
indexOf
(
'
uni-
'
)
===
0
)
{
// 完全限定
/* eslint-disable standard/computed-property-even-spacing */
UniViewJSBridge
.
off
(
name
,
this
[
listeners
[
name
]])
}
else
if
(
id
)
{
// scoped
/* eslint-disable standard/computed-property-even-spacing */
UniViewJSBridge
.
off
(
`uni-
${
name
}
-
${
this
.
$page
.
id
}
-
${
id
}
`
,
this
[
listeners
[
name
]]
)
}
}
})
}
}
}
packages/uni-components/src/mixins/scroller/Friction.js
已删除
100644 → 0
浏览文件 @
9e2e54cd
export
function
Friction
(
e
)
{
this
.
_drag
=
e
this
.
_dragLog
=
Math
.
log
(
e
)
this
.
_x
=
0
this
.
_v
=
0
this
.
_startTime
=
0
}
Friction
.
prototype
.
set
=
function
(
e
,
t
)
{
this
.
_x
=
e
this
.
_v
=
t
this
.
_startTime
=
new
Date
().
getTime
()
}
Friction
.
prototype
.
setVelocityByEnd
=
function
(
e
)
{
this
.
_v
=
((
e
-
this
.
_x
)
*
this
.
_dragLog
)
/
(
Math
.
pow
(
this
.
_drag
,
100
)
-
1
)
}
Friction
.
prototype
.
x
=
function
(
e
)
{
if
(
e
===
undefined
)
{
e
=
(
new
Date
().
getTime
()
-
this
.
_startTime
)
/
1
e3
}
var
t
t
=
e
===
this
.
_dt
&&
this
.
_powDragDt
?
this
.
_powDragDt
:
(
this
.
_powDragDt
=
Math
.
pow
(
this
.
_drag
,
e
))
this
.
_dt
=
e
return
this
.
_x
+
(
this
.
_v
*
t
)
/
this
.
_dragLog
-
this
.
_v
/
this
.
_dragLog
}
Friction
.
prototype
.
dx
=
function
(
e
)
{
if
(
e
===
undefined
)
{
e
=
(
new
Date
().
getTime
()
-
this
.
_startTime
)
/
1
e3
}
var
t
t
=
e
===
this
.
_dt
&&
this
.
_powDragDt
?
this
.
_powDragDt
:
(
this
.
_powDragDt
=
Math
.
pow
(
this
.
_drag
,
e
))
this
.
_dt
=
e
return
this
.
_v
*
t
}
Friction
.
prototype
.
done
=
function
()
{
return
Math
.
abs
(
this
.
dx
())
<
3
}
Friction
.
prototype
.
reconfigure
=
function
(
e
)
{
var
t
=
this
.
x
()
var
n
=
this
.
dx
()
this
.
_drag
=
e
this
.
_dragLog
=
Math
.
log
(
e
)
this
.
set
(
t
,
n
)
}
Friction
.
prototype
.
configuration
=
function
()
{
var
e
=
this
return
[
{
label
:
'
Friction
'
,
read
:
function
()
{
return
e
.
_drag
},
write
:
function
(
t
)
{
e
.
reconfigure
(
t
)
},
min
:
0.001
,
max
:
0.1
,
step
:
0.001
,
},
]
}
packages/uni-components/src/mixins/scroller/Scroll.js
已删除
100644 → 0
浏览文件 @
9e2e54cd
import
{
Friction
}
from
'
./Friction
'
import
{
Spring
}
from
'
./Spring
'
export
function
Scroll
(
extent
,
friction
,
spring
)
{
this
.
_extent
=
extent
this
.
_friction
=
friction
||
new
Friction
(
0.01
)
this
.
_spring
=
spring
||
new
Spring
(
1
,
90
,
20
)
this
.
_startTime
=
0
this
.
_springing
=
false
this
.
_springOffset
=
0
}
Scroll
.
prototype
.
snap
=
function
(
e
,
t
)
{
this
.
_springOffset
=
0
this
.
_springing
=
true
this
.
_spring
.
snap
(
e
)
this
.
_spring
.
setEnd
(
t
)
}
Scroll
.
prototype
.
set
=
function
(
e
,
t
)
{
this
.
_friction
.
set
(
e
,
t
)
if
(
e
>
0
&&
t
>=
0
)
{
this
.
_springOffset
=
0
this
.
_springing
=
true
this
.
_spring
.
snap
(
e
)
this
.
_spring
.
setEnd
(
0
)
}
else
{
if
(
e
<
-
this
.
_extent
&&
t
<=
0
)
{
this
.
_springOffset
=
0
this
.
_springing
=
true
this
.
_spring
.
snap
(
e
)
this
.
_spring
.
setEnd
(
-
this
.
_extent
)
}
else
{
this
.
_springing
=
false
}
}
this
.
_startTime
=
new
Date
().
getTime
()
}
Scroll
.
prototype
.
x
=
function
(
e
)
{
if
(
!
this
.
_startTime
)
{
return
0
}
if
(
!
e
)
{
e
=
(
new
Date
().
getTime
()
-
this
.
_startTime
)
/
1
e3
}
if
(
this
.
_springing
)
{
return
this
.
_spring
.
x
()
+
this
.
_springOffset
}
var
t
=
this
.
_friction
.
x
(
e
)
var
n
=
this
.
dx
(
e
)
if
((
t
>
0
&&
n
>=
0
)
||
(
t
<
-
this
.
_extent
&&
n
<=
0
))
{
this
.
_springing
=
true
this
.
_spring
.
setEnd
(
0
,
n
)
if
(
t
<
-
this
.
_extent
)
{
this
.
_springOffset
=
-
this
.
_extent
}
else
{
this
.
_springOffset
=
0
}
t
=
this
.
_spring
.
x
()
+
this
.
_springOffset
}
return
t
}
Scroll
.
prototype
.
dx
=
function
(
e
)
{
var
t
=
0
t
=
this
.
_lastTime
===
e
?
this
.
_lastDx
:
this
.
_springing
?
this
.
_spring
.
dx
(
e
)
:
this
.
_friction
.
dx
(
e
)
this
.
_lastTime
=
e
this
.
_lastDx
=
t
return
t
}
Scroll
.
prototype
.
done
=
function
()
{
return
this
.
_springing
?
this
.
_spring
.
done
()
:
this
.
_friction
.
done
()
}
Scroll
.
prototype
.
setVelocityByEnd
=
function
(
e
)
{
this
.
_friction
.
setVelocityByEnd
(
e
)
}
Scroll
.
prototype
.
configuration
=
function
()
{
var
e
=
this
.
_friction
.
configuration
()
e
.
push
.
apply
(
e
,
this
.
_spring
.
configuration
())
return
e
}
packages/uni-components/src/mixins/scroller/Scroller.js
已删除
100644 → 0
浏览文件 @
9e2e54cd
import
{
Scroll
}
from
'
./Scroll
'
function
i
(
scroll
,
t
,
n
)
{
function
i
(
t
,
scroll
,
r
,
o
)
{
if
(
!
t
||
!
t
.
cancelled
)
{
r
(
scroll
)
var
a
=
scroll
.
done
()
if
(
!
a
)
{
if
(
!
t
.
cancelled
)
{
t
.
id
=
requestAnimationFrame
(
i
.
bind
(
null
,
t
,
scroll
,
r
,
o
))
}
}
if
(
a
&&
o
)
{
o
(
scroll
)
}
}
}
function
r
(
scroll
)
{
if
(
scroll
&&
scroll
.
id
)
{
cancelAnimationFrame
(
scroll
.
id
)
}
if
(
scroll
)
{
scroll
.
cancelled
=
true
}
}
var
o
=
{
id
:
0
,
cancelled
:
false
,
}
i
(
o
,
scroll
,
t
,
n
)
return
{
cancel
:
r
.
bind
(
null
,
o
),
model
:
scroll
,
}
}
export
function
Scroller
(
element
,
options
)
{
options
=
options
||
{}
this
.
_element
=
element
this
.
_options
=
options
this
.
_enableSnap
=
options
.
enableSnap
||
false
this
.
_itemSize
=
options
.
itemSize
||
0
this
.
_enableX
=
options
.
enableX
||
false
this
.
_enableY
=
options
.
enableY
||
false
this
.
_shouldDispatchScrollEvent
=
!!
options
.
onScroll
if
(
this
.
_enableX
)
{
this
.
_extent
=
(
options
.
scrollWidth
||
this
.
_element
.
offsetWidth
)
-
this
.
_element
.
parentElement
.
offsetWidth
this
.
_scrollWidth
=
options
.
scrollWidth
}
else
{
this
.
_extent
=
(
options
.
scrollHeight
||
this
.
_element
.
offsetHeight
)
-
this
.
_element
.
parentElement
.
offsetHeight
this
.
_scrollHeight
=
options
.
scrollHeight
}
this
.
_position
=
0
this
.
_scroll
=
new
Scroll
(
this
.
_extent
,
options
.
friction
,
options
.
spring
)
this
.
_onTransitionEnd
=
this
.
onTransitionEnd
.
bind
(
this
)
this
.
updatePosition
()
}
Scroller
.
prototype
.
onTouchStart
=
function
()
{
this
.
_startPosition
=
this
.
_position
this
.
_lastChangePos
=
this
.
_startPosition
if
(
this
.
_startPosition
>
0
)
{
this
.
_startPosition
/=
0.5
}
else
{
if
(
this
.
_startPosition
<
-
this
.
_extent
)
{
this
.
_startPosition
=
(
this
.
_startPosition
+
this
.
_extent
)
/
0.5
-
this
.
_extent
}
}
if
(
this
.
_animation
)
{
this
.
_animation
.
cancel
()
this
.
_scrolling
=
false
}
this
.
updatePosition
()
}
Scroller
.
prototype
.
onTouchMove
=
function
(
x
,
y
)
{
var
startPosition
=
this
.
_startPosition
if
(
this
.
_enableX
)
{
startPosition
+=
x
}
else
if
(
this
.
_enableY
)
{
startPosition
+=
y
}
if
(
startPosition
>
0
)
{
startPosition
*=
0.5
}
else
if
(
startPosition
<
-
this
.
_extent
)
{
startPosition
=
0.5
*
(
startPosition
+
this
.
_extent
)
-
this
.
_extent
}
this
.
_position
=
startPosition
this
.
updatePosition
()
this
.
dispatchScroll
()
}
Scroller
.
prototype
.
onTouchEnd
=
function
(
e
,
r
,
o
)
{
if
(
this
.
_enableSnap
&&
this
.
_position
>
-
this
.
_extent
&&
this
.
_position
<
0
)
{
if
(
this
.
_enableY
&&
((
Math
.
abs
(
r
)
<
this
.
_itemSize
&&
Math
.
abs
(
o
.
y
)
<
300
)
||
Math
.
abs
(
o
.
y
)
<
150
)
)
{
this
.
snap
()
return
}
if
(
this
.
_enableX
&&
((
Math
.
abs
(
e
)
<
this
.
_itemSize
&&
Math
.
abs
(
o
.
x
)
<
300
)
||
Math
.
abs
(
o
.
x
)
<
150
)
)
{
this
.
snap
()
return
}
}
if
(
this
.
_enableX
)
{
this
.
_scroll
.
set
(
this
.
_position
,
o
.
x
)
}
else
if
(
this
.
_enableY
)
{
this
.
_scroll
.
set
(
this
.
_position
,
o
.
y
)
}
if
(
this
.
_enableSnap
)
{
var
s
=
this
.
_scroll
.
_friction
.
x
(
100
)
var
l
=
s
%
this
.
_itemSize
var
c
=
Math
.
abs
(
l
)
>
this
.
_itemSize
/
2
?
s
-
(
this
.
_itemSize
-
Math
.
abs
(
l
))
:
s
-
l
if
(
c
<=
0
&&
c
>=
-
this
.
_extent
)
{
this
.
_scroll
.
setVelocityByEnd
(
c
)
}
}
this
.
_lastTime
=
Date
.
now
()
this
.
_lastDelay
=
0
this
.
_scrolling
=
true
this
.
_lastChangePos
=
this
.
_position
this
.
_lastIdx
=
Math
.
floor
(
Math
.
abs
(
this
.
_position
/
this
.
_itemSize
))
this
.
_animation
=
i
(
this
.
_scroll
,
()
=>
{
var
e
=
Date
.
now
()
var
i
=
(
e
-
this
.
_scroll
.
_startTime
)
/
1
e3
var
r
=
this
.
_scroll
.
x
(
i
)
this
.
_position
=
r
this
.
updatePosition
()
var
o
=
this
.
_scroll
.
dx
(
i
)
if
(
this
.
_shouldDispatchScrollEvent
&&
e
-
this
.
_lastTime
>
this
.
_lastDelay
)
{
this
.
dispatchScroll
()
this
.
_lastDelay
=
Math
.
abs
(
2
e3
/
o
)
this
.
_lastTime
=
e
}
},
()
=>
{
if
(
this
.
_enableSnap
)
{
if
(
c
<=
0
&&
c
>=
-
this
.
_extent
)
{
this
.
_position
=
c
this
.
updatePosition
()
}
if
(
typeof
this
.
_options
.
onSnap
===
'
function
'
)
{
this
.
_options
.
onSnap
(
Math
.
floor
(
Math
.
abs
(
this
.
_position
)
/
this
.
_itemSize
)
)
}
}
if
(
this
.
_shouldDispatchScrollEvent
)
{
this
.
dispatchScroll
()
}
this
.
_scrolling
=
false
}
)
}
Scroller
.
prototype
.
onTransitionEnd
=
function
()
{
this
.
_element
.
style
.
transition
=
''
this
.
_element
.
style
.
webkitTransition
=
''
this
.
_element
.
removeEventListener
(
'
transitionend
'
,
this
.
_onTransitionEnd
)
this
.
_element
.
removeEventListener
(
'
webkitTransitionEnd
'
,
this
.
_onTransitionEnd
)
if
(
this
.
_snapping
)
{
this
.
_snapping
=
false
}
this
.
dispatchScroll
()
}
Scroller
.
prototype
.
snap
=
function
()
{
var
e
=
this
.
_itemSize
var
t
=
this
.
_position
%
e
var
i
=
Math
.
abs
(
t
)
>
this
.
_itemSize
/
2
?
this
.
_position
-
(
e
-
Math
.
abs
(
t
))
:
this
.
_position
-
t
if
(
this
.
_position
!==
i
)
{
this
.
_snapping
=
true
this
.
scrollTo
(
-
i
)
if
(
typeof
this
.
_options
.
onSnap
===
'
function
'
)
{
this
.
_options
.
onSnap
(
Math
.
floor
(
Math
.
abs
(
this
.
_position
)
/
this
.
_itemSize
)
)
}
}
}
Scroller
.
prototype
.
scrollTo
=
function
(
e
,
t
)
{
if
(
this
.
_animation
)
{
this
.
_animation
.
cancel
()
this
.
_scrolling
=
false
}
if
(
typeof
e
===
'
number
'
)
{
this
.
_position
=
-
e
}
if
(
this
.
_position
<
-
this
.
_extent
)
{
this
.
_position
=
-
this
.
_extent
}
else
{
if
(
this
.
_position
>
0
)
{
this
.
_position
=
0
}
}
this
.
_element
.
style
.
transition
=
'
transform
'
+
(
t
||
0.2
)
+
'
s ease-out
'
this
.
_element
.
style
.
webkitTransition
=
'
-webkit-transform
'
+
(
t
||
0.2
)
+
'
s ease-out
'
this
.
updatePosition
()
this
.
_element
.
addEventListener
(
'
transitionend
'
,
this
.
_onTransitionEnd
)
this
.
_element
.
addEventListener
(
'
webkitTransitionEnd
'
,
this
.
_onTransitionEnd
)
}
Scroller
.
prototype
.
dispatchScroll
=
function
()
{
if
(
typeof
this
.
_options
.
onScroll
===
'
function
'
&&
Math
.
round
(
this
.
_lastPos
)
!==
Math
.
round
(
this
.
_position
)
)
{
this
.
_lastPos
=
this
.
_position
var
e
=
{
target
:
{
scrollLeft
:
this
.
_enableX
?
-
this
.
_position
:
0
,
scrollTop
:
this
.
_enableY
?
-
this
.
_position
:
0
,
scrollHeight
:
this
.
_scrollHeight
||
this
.
_element
.
offsetHeight
,
scrollWidth
:
this
.
_scrollWidth
||
this
.
_element
.
offsetWidth
,
offsetHeight
:
this
.
_element
.
parentElement
.
offsetHeight
,
offsetWidth
:
this
.
_element
.
parentElement
.
offsetWidth
,
},
}
this
.
_options
.
onScroll
(
e
)
}
}
Scroller
.
prototype
.
update
=
function
(
e
,
t
,
n
)
{
var
i
=
0
var
r
=
this
.
_position
if
(
this
.
_enableX
)
{
i
=
this
.
_element
.
childNodes
.
length
?
(
t
||
this
.
_element
.
offsetWidth
)
-
this
.
_element
.
parentElement
.
offsetWidth
:
0
this
.
_scrollWidth
=
t
}
else
{
i
=
this
.
_element
.
childNodes
.
length
?
(
t
||
this
.
_element
.
offsetHeight
)
-
this
.
_element
.
parentElement
.
offsetHeight
:
0
this
.
_scrollHeight
=
t
}
if
(
typeof
e
===
'
number
'
)
{
this
.
_position
=
-
e
}
if
(
this
.
_position
<
-
i
)
{
this
.
_position
=
-
i
}
else
{
if
(
this
.
_position
>
0
)
{
this
.
_position
=
0
}
}
this
.
_itemSize
=
n
||
this
.
_itemSize
this
.
updatePosition
()
if
(
r
!==
this
.
_position
)
{
this
.
dispatchScroll
()
if
(
typeof
this
.
_options
.
onSnap
===
'
function
'
)
{
this
.
_options
.
onSnap
(
Math
.
floor
(
Math
.
abs
(
this
.
_position
)
/
this
.
_itemSize
)
)
}
}
this
.
_extent
=
i
this
.
_scroll
.
_extent
=
i
}
Scroller
.
prototype
.
updatePosition
=
function
()
{
var
transform
=
''
if
(
this
.
_enableX
)
{
transform
=
'
translateX(
'
+
this
.
_position
+
'
px) translateZ(0)
'
}
else
{
if
(
this
.
_enableY
)
{
transform
=
'
translateY(
'
+
this
.
_position
+
'
px) translateZ(0)
'
}
}
this
.
_element
.
style
.
webkitTransform
=
transform
this
.
_element
.
style
.
transform
=
transform
}
Scroller
.
prototype
.
isScrolling
=
function
()
{
return
this
.
_scrolling
||
this
.
_snapping
}
packages/uni-components/src/mixins/scroller/Spring.js
已删除
100644 → 0
浏览文件 @
9e2e54cd
function
o
(
e
,
t
,
n
)
{
return
e
>
t
-
n
&&
e
<
t
+
n
}
function
a
(
e
,
t
)
{
return
o
(
e
,
0
,
t
)
}
export
function
Spring
(
e
,
t
,
n
)
{
this
.
_m
=
e
this
.
_k
=
t
this
.
_c
=
n
this
.
_solution
=
null
this
.
_endPosition
=
0
this
.
_startTime
=
0
}
Spring
.
prototype
.
_solve
=
function
(
e
,
t
)
{
var
n
=
this
.
_c
var
i
=
this
.
_m
var
r
=
this
.
_k
var
o
=
n
*
n
-
4
*
i
*
r
if
(
o
===
0
)
{
const
a
=
-
n
/
(
2
*
i
)
const
s
=
e
const
l
=
t
/
(
a
*
e
)
return
{
x
:
function
(
e
)
{
return
(
s
+
l
*
e
)
*
Math
.
pow
(
Math
.
E
,
a
*
e
)
},
dx
:
function
(
e
)
{
var
t
=
Math
.
pow
(
Math
.
E
,
a
*
e
)
return
a
*
(
s
+
l
*
e
)
*
t
+
l
*
t
},
}
}
if
(
o
>
0
)
{
const
c
=
(
-
n
-
Math
.
sqrt
(
o
))
/
(
2
*
i
)
const
u
=
(
-
n
+
Math
.
sqrt
(
o
))
/
(
2
*
i
)
const
l
=
(
t
-
c
*
e
)
/
(
u
-
c
)
const
s
=
e
-
l
return
{
x
:
function
(
e
)
{
let
t
let
n
if
(
e
===
this
.
_t
)
{
t
=
this
.
_powER1T
n
=
this
.
_powER2T
}
this
.
_t
=
e
if
(
!
t
)
{
t
=
this
.
_powER1T
=
Math
.
pow
(
Math
.
E
,
c
*
e
)
}
if
(
!
n
)
{
n
=
this
.
_powER2T
=
Math
.
pow
(
Math
.
E
,
u
*
e
)
}
return
s
*
t
+
l
*
n
},
dx
:
function
(
e
)
{
let
t
let
n
if
(
e
===
this
.
_t
)
{
t
=
this
.
_powER1T
n
=
this
.
_powER2T
}
this
.
_t
=
e
if
(
!
t
)
{
t
=
this
.
_powER1T
=
Math
.
pow
(
Math
.
E
,
c
*
e
)
}
if
(
!
n
)
{
n
=
this
.
_powER2T
=
Math
.
pow
(
Math
.
E
,
u
*
e
)
}
return
s
*
c
*
t
+
l
*
u
*
n
},
}
}
var
d
=
Math
.
sqrt
(
4
*
i
*
r
-
n
*
n
)
/
(
2
*
i
)
var
a
=
(
-
n
/
2
)
*
i
var
s
=
e
var
l
=
(
t
-
a
*
e
)
/
d
return
{
x
:
function
(
e
)
{
return
(
Math
.
pow
(
Math
.
E
,
a
*
e
)
*
(
s
*
Math
.
cos
(
d
*
e
)
+
l
*
Math
.
sin
(
d
*
e
))
)
},
dx
:
function
(
e
)
{
var
t
=
Math
.
pow
(
Math
.
E
,
a
*
e
)
var
n
=
Math
.
cos
(
d
*
e
)
var
i
=
Math
.
sin
(
d
*
e
)
return
t
*
(
l
*
d
*
n
-
s
*
d
*
i
)
+
a
*
t
*
(
l
*
i
+
s
*
n
)
},
}
}
Spring
.
prototype
.
x
=
function
(
e
)
{
if
(
e
===
undefined
)
{
e
=
(
new
Date
().
getTime
()
-
this
.
_startTime
)
/
1
e3
}
return
this
.
_solution
?
this
.
_endPosition
+
this
.
_solution
.
x
(
e
)
:
0
}
Spring
.
prototype
.
dx
=
function
(
e
)
{
if
(
e
===
undefined
)
{
e
=
(
new
Date
().
getTime
()
-
this
.
_startTime
)
/
1
e3
}
return
this
.
_solution
?
this
.
_solution
.
dx
(
e
)
:
0
}
Spring
.
prototype
.
setEnd
=
function
(
e
,
t
,
n
)
{
if
(
!
n
)
{
n
=
new
Date
().
getTime
()
}
if
(
e
!==
this
.
_endPosition
||
!
a
(
t
,
0.4
))
{
t
=
t
||
0
var
i
=
this
.
_endPosition
if
(
this
.
_solution
)
{
if
(
a
(
t
,
0.4
))
{
t
=
this
.
_solution
.
dx
((
n
-
this
.
_startTime
)
/
1
e3
)
}
i
=
this
.
_solution
.
x
((
n
-
this
.
_startTime
)
/
1
e3
)
if
(
a
(
t
,
0.4
))
{
t
=
0
}
if
(
a
(
i
,
0.4
))
{
i
=
0
}
i
+=
this
.
_endPosition
}
if
(
!
(
this
.
_solution
&&
a
(
i
-
e
,
0.4
)
&&
a
(
t
,
0.4
)))
{
this
.
_endPosition
=
e
this
.
_solution
=
this
.
_solve
(
i
-
this
.
_endPosition
,
t
)
this
.
_startTime
=
n
}
}
}
Spring
.
prototype
.
snap
=
function
(
e
)
{
this
.
_startTime
=
new
Date
().
getTime
()
this
.
_endPosition
=
e
this
.
_solution
=
{
x
:
function
()
{
return
0
},
dx
:
function
()
{
return
0
},
}
}
Spring
.
prototype
.
done
=
function
(
e
)
{
if
(
!
e
)
{
e
=
new
Date
().
getTime
()
}
return
o
(
this
.
x
(),
this
.
_endPosition
,
0.4
)
&&
a
(
this
.
dx
(),
0.4
)
}
Spring
.
prototype
.
reconfigure
=
function
(
e
,
t
,
n
)
{
this
.
_m
=
e
this
.
_k
=
t
this
.
_c
=
n
if
(
!
this
.
done
())
{
this
.
_solution
=
this
.
_solve
(
this
.
x
()
-
this
.
_endPosition
,
this
.
dx
())
this
.
_startTime
=
new
Date
().
getTime
()
}
}
Spring
.
prototype
.
springConstant
=
function
()
{
return
this
.
_k
}
Spring
.
prototype
.
damping
=
function
()
{
return
this
.
_c
}
Spring
.
prototype
.
configuration
=
function
()
{
function
e
(
e
,
t
)
{
e
.
reconfigure
(
1
,
t
,
e
.
damping
())
}
function
t
(
e
,
t
)
{
e
.
reconfigure
(
1
,
e
.
springConstant
(),
t
)
}
return
[
{
label
:
'
Spring Constant
'
,
read
:
this
.
springConstant
.
bind
(
this
),
write
:
e
.
bind
(
this
,
this
),
min
:
100
,
max
:
1
e3
,
},
{
label
:
'
Damping
'
,
read
:
this
.
damping
.
bind
(
this
),
write
:
t
.
bind
(
this
,
this
),
min
:
1
,
max
:
500
,
},
]
}
packages/uni-components/src/mixins/scroller/index.js
已删除
100644 → 0
浏览文件 @
9e2e54cd
import
{
Scroller
}
from
'
./Scroller
'
export
default
{
methods
:
{
initScroller
:
function
(
element
,
options
)
{
this
.
_touchInfo
=
{
trackingID
:
-
1
,
maxDy
:
0
,
maxDx
:
0
,
}
this
.
_scroller
=
new
Scroller
(
element
,
options
)
this
.
__handleTouchStart
=
this
.
_handleTouchStart
.
bind
(
this
)
this
.
__handleTouchMove
=
this
.
_handleTouchMove
.
bind
(
this
)
this
.
__handleTouchEnd
=
this
.
_handleTouchEnd
.
bind
(
this
)
this
.
_initedScroller
=
true
},
_findDelta
:
function
(
event
)
{
var
touchInfo
=
this
.
_touchInfo
return
event
.
detail
.
state
===
'
move
'
||
event
.
detail
.
state
===
'
end
'
?
{
x
:
event
.
detail
.
dx
,
y
:
event
.
detail
.
dy
,
}
:
{
x
:
event
.
screenX
-
touchInfo
.
x
,
y
:
event
.
screenY
-
touchInfo
.
y
,
}
},
_handleTouchStart
:
function
(
e
)
{
var
t
=
this
.
_touchInfo
var
n
=
this
.
_scroller
if
(
n
)
{
if
(
e
.
detail
.
state
===
'
start
'
)
{
t
.
trackingID
=
'
touch
'
t
.
x
=
e
.
detail
.
x
t
.
y
=
e
.
detail
.
y
}
else
{
t
.
trackingID
=
'
mouse
'
t
.
x
=
e
.
screenX
t
.
y
=
e
.
screenY
}
t
.
maxDx
=
0
t
.
maxDy
=
0
t
.
historyX
=
[
0
]
t
.
historyY
=
[
0
]
t
.
historyTime
=
[
e
.
detail
.
timeStamp
]
t
.
listener
=
n
if
(
n
.
onTouchStart
)
{
n
.
onTouchStart
()
}
e
.
preventDefault
()
}
},
_handleTouchMove
:
function
(
event
)
{
var
touchInfo
=
this
.
_touchInfo
if
(
touchInfo
.
trackingID
!==
-
1
)
{
event
.
preventDefault
()
var
delta
=
this
.
_findDelta
(
event
)
if
(
delta
)
{
for
(
touchInfo
.
maxDy
=
Math
.
max
(
touchInfo
.
maxDy
,
Math
.
abs
(
delta
.
y
)),
touchInfo
.
maxDx
=
Math
.
max
(
touchInfo
.
maxDx
,
Math
.
abs
(
delta
.
x
)),
touchInfo
.
historyX
.
push
(
delta
.
x
),
touchInfo
.
historyY
.
push
(
delta
.
y
),
touchInfo
.
historyTime
.
push
(
event
.
detail
.
timeStamp
);
touchInfo
.
historyTime
.
length
>
10
;
)
{
touchInfo
.
historyTime
.
shift
()
touchInfo
.
historyX
.
shift
()
touchInfo
.
historyY
.
shift
()
}
if
(
touchInfo
.
listener
&&
touchInfo
.
listener
.
onTouchMove
)
{
touchInfo
.
listener
.
onTouchMove
(
delta
.
x
,
delta
.
y
,
event
.
detail
.
timeStamp
)
}
}
}
},
_handleTouchEnd
:
function
(
event
)
{
var
touchInfo
=
this
.
_touchInfo
if
(
touchInfo
.
trackingID
!==
-
1
)
{
event
.
preventDefault
()
var
delta
=
this
.
_findDelta
(
event
)
if
(
delta
)
{
var
listener
=
touchInfo
.
listener
touchInfo
.
trackingID
=
-
1
touchInfo
.
listener
=
null
var
r
=
touchInfo
.
historyTime
.
length
var
o
=
{
x
:
0
,
y
:
0
,
}
if
(
r
>
2
)
{
for
(
var
a
=
touchInfo
.
historyTime
.
length
-
1
,
s
=
touchInfo
.
historyTime
[
a
],
l
=
touchInfo
.
historyX
[
a
],
c
=
touchInfo
.
historyY
[
a
];
a
>
0
;
)
{
a
--
var
u
=
touchInfo
.
historyTime
[
a
]
var
d
=
s
-
u
if
(
d
>
30
&&
d
<
50
)
{
o
.
x
=
(
l
-
touchInfo
.
historyX
[
a
])
/
(
d
/
1
e3
)
o
.
y
=
(
c
-
touchInfo
.
historyY
[
a
])
/
(
d
/
1
e3
)
break
}
}
}
touchInfo
.
historyTime
=
[]
touchInfo
.
historyX
=
[]
touchInfo
.
historyY
=
[]
if
(
listener
&&
listener
.
onTouchEnd
)
{
listener
.
onTouchEnd
(
delta
.
x
,
delta
.
y
,
o
)
}
}
}
},
},
}
packages/uni-components/src/mixins/subscriber.js
已删除
100644 → 0
浏览文件 @
9e2e54cd
import
{
isFunction
}
from
'
@vue/shared
'
export
default
{
// 取消id的定义,某些组件(canvas)内不在props内定义id
// props: {
// id: {
// type: String,
// default: ''
// }
// },
mounted
()
{
this
.
_toggleListeners
(
'
subscribe
'
,
this
.
id
)
// 初始化监听
this
.
$watch
(
'
id
'
,
(
newId
,
oldId
)
=>
{
// watch id
this
.
_toggleListeners
(
'
unsubscribe
'
,
oldId
,
true
)
this
.
_toggleListeners
(
'
subscribe
'
,
newId
,
true
)
})
},
beforeDestroy
()
{
// 销毁时移除
this
.
_toggleListeners
(
'
unsubscribe
'
,
this
.
id
)
if
(
this
.
_contextId
)
{
this
.
_toggleListeners
(
'
unsubscribe
'
,
this
.
_contextId
)
}
},
methods
:
{
_toggleListeners
(
type
,
id
,
watch
)
{
if
(
watch
&&
!
id
)
{
// id被置空
return
}
if
(
!
isFunction
(
this
.
_handleSubscribe
))
{
return
}
// 纠正VUniVideo等组件命名为Video
UniViewJSBridge
[
type
](
this
.
$page
.
id
+
'
-
'
+
this
.
$options
.
name
.
replace
(
/VUni
([
A-Z
])
/
,
'
$1
'
).
toLowerCase
()
+
'
-
'
+
id
,
this
.
_handleSubscribe
)
},
_getContextInfo
()
{
const
id
=
`context-
${
this
.
_uid
}
`
if
(
!
this
.
_contextId
)
{
this
.
_toggleListeners
(
'
subscribe
'
,
id
)
this
.
_contextId
=
id
}
return
{
name
:
this
.
$options
.
name
.
replace
(
/VUni
([
A-Z
])
/
,
'
$1
'
).
toLowerCase
(),
id
,
page
:
this
.
$page
.
id
}
}
}
}
packages/uni-components/src/mixins/touchtrack.js
已删除
100644 → 0
浏览文件 @
9e2e54cd
const
addListenerToElement
=
function
(
element
,
type
,
callback
,
capture
)
{
// 暂时忽略 capture
element
.
addEventListener
(
type
,
$event
=>
{
if
(
typeof
callback
===
'
function
'
)
{
if
(
callback
(
$event
)
===
false
)
{
$event
.
preventDefault
()
$event
.
stopPropagation
()
}
}
},
{
passive
:
false
}
)
}
export
default
{
beforeDestroy
()
{
document
.
removeEventListener
(
'
mousemove
'
,
this
.
__mouseMoveEventListener
)
document
.
removeEventListener
(
'
mouseup
'
,
this
.
__mouseUpEventListener
)
},
methods
:
{
touchtrack
:
function
(
element
,
method
,
useCancel
)
{
const
self
=
this
let
x0
=
0
let
y0
=
0
let
x1
=
0
let
y1
=
0
const
fn
=
function
(
$event
,
state
,
x
,
y
)
{
if
(
self
[
method
]({
target
:
$event
.
target
,
currentTarget
:
$event
.
currentTarget
,
preventDefault
:
$event
.
preventDefault
.
bind
(
$event
),
stopPropagation
:
$event
.
stopPropagation
.
bind
(
$event
),
touches
:
$event
.
touches
,
changedTouches
:
$event
.
changedTouches
,
detail
:
{
state
,
x0
:
x
,
y0
:
y
,
dx
:
x
-
x0
,
dy
:
y
-
y0
,
ddx
:
x
-
x1
,
ddy
:
y
-
y1
,
timeStamp
:
$event
.
timeStamp
}
})
===
false
)
{
return
false
}
}
let
$eventOld
=
null
let
hasTouchStart
let
hasMouseDown
addListenerToElement
(
element
,
'
touchstart
'
,
function
(
$event
)
{
hasTouchStart
=
true
if
(
$event
.
touches
.
length
===
1
&&
!
$eventOld
)
{
$eventOld
=
$event
x0
=
x1
=
$event
.
touches
[
0
].
pageX
y0
=
y1
=
$event
.
touches
[
0
].
pageY
return
fn
(
$event
,
'
start
'
,
x0
,
y0
)
}
})
addListenerToElement
(
element
,
'
mousedown
'
,
function
(
$event
)
{
hasMouseDown
=
true
if
(
!
hasTouchStart
&&
!
$eventOld
)
{
// TODO touches changedTouches
$eventOld
=
$event
x0
=
x1
=
$event
.
pageX
y0
=
y1
=
$event
.
pageY
return
fn
(
$event
,
'
start
'
,
x0
,
y0
)
}
})
addListenerToElement
(
element
,
'
touchmove
'
,
function
(
$event
)
{
if
(
$event
.
touches
.
length
===
1
&&
$eventOld
)
{
const
res
=
fn
(
$event
,
'
move
'
,
$event
.
touches
[
0
].
pageX
,
$event
.
touches
[
0
].
pageY
)
x1
=
$event
.
touches
[
0
].
pageX
y1
=
$event
.
touches
[
0
].
pageY
return
res
}
})
const
mouseMoveEventListener
=
(
this
.
__mouseMoveEventListener
=
function
(
$event
)
{
if
(
!
hasTouchStart
&&
hasMouseDown
&&
$eventOld
)
{
// TODO target currentTarget touches changedTouches
const
res
=
fn
(
$event
,
'
move
'
,
$event
.
pageX
,
$event
.
pageY
)
x1
=
$event
.
pageX
y1
=
$event
.
pageY
return
res
}
})
document
.
addEventListener
(
'
mousemove
'
,
mouseMoveEventListener
)
addListenerToElement
(
element
,
'
touchend
'
,
function
(
$event
)
{
if
(
$event
.
touches
.
length
===
0
&&
$eventOld
)
{
hasTouchStart
=
false
$eventOld
=
null
return
fn
(
$event
,
'
end
'
,
$event
.
changedTouches
[
0
].
pageX
,
$event
.
changedTouches
[
0
].
pageY
)
}
})
const
mouseUpEventListener
=
(
this
.
__mouseUpEventListener
=
function
(
$event
)
{
hasMouseDown
=
false
if
(
!
hasTouchStart
&&
$eventOld
)
{
// TODO target currentTarget touches changedTouches
$eventOld
=
null
return
fn
(
$event
,
'
end
'
,
$event
.
pageX
,
$event
.
pageY
)
}
})
document
.
addEventListener
(
'
mouseup
'
,
mouseUpEventListener
)
addListenerToElement
(
element
,
'
touchcancel
'
,
function
(
$event
)
{
if
(
$eventOld
)
{
hasTouchStart
=
false
const
$eventTemp
=
$eventOld
$eventOld
=
null
return
fn
(
$event
,
useCancel
?
'
cancel
'
:
'
end
'
,
$eventTemp
.
touches
[
0
].
pageX
,
$eventTemp
.
touches
[
0
].
pageY
)
}
})
}
}
}
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
08a578bc
"
use strict
"
;
"
use strict
"
;
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
[
Symbol
.
toStringTag
]
=
"
Module
"
;
exports
[
Symbol
.
toStringTag
]
=
"
Module
"
;
var
shared
=
require
(
"
@vue/shared
"
);
var
uniShared
=
require
(
"
@dcloudio/uni-shared
"
);
var
vue
=
require
(
"
vue
"
);
var
vue
=
require
(
"
vue
"
);
var
uniShared
=
require
(
"
@dcloudio/uni-shared
"
);
var
uniI18n
=
require
(
"
@dcloudio/uni-i18n
"
);
var
uniI18n
=
require
(
"
@dcloudio/uni-i18n
"
);
var
shared
=
require
(
"
@vue/shared
"
);
var
vueRouter
=
require
(
"
vue-router
"
);
var
vueRouter
=
require
(
"
vue-router
"
);
var
subscriber
=
{
mounted
()
{
this
.
_toggleListeners
(
"
subscribe
"
,
this
.
id
);
this
.
$watch
(
"
id
"
,
(
newId
,
oldId
)
=>
{
this
.
_toggleListeners
(
"
unsubscribe
"
,
oldId
,
true
);
this
.
_toggleListeners
(
"
subscribe
"
,
newId
,
true
);
});
},
beforeDestroy
()
{
this
.
_toggleListeners
(
"
unsubscribe
"
,
this
.
id
);
if
(
this
.
_contextId
)
{
this
.
_toggleListeners
(
"
unsubscribe
"
,
this
.
_contextId
);
}
},
methods
:
{
_toggleListeners
(
type
,
id
,
watch
)
{
if
(
watch
&&
!
id
)
{
return
;
}
if
(
!
shared
.
isFunction
(
this
.
_handleSubscribe
))
{
return
;
}
UniViewJSBridge
[
type
](
this
.
$page
.
id
+
"
-
"
+
this
.
$options
.
name
.
replace
(
/VUni
([
A-Z
])
/
,
"
$1
"
).
toLowerCase
()
+
"
-
"
+
id
,
this
.
_handleSubscribe
);
},
_getContextInfo
()
{
const
id
=
`context-
${
this
.
_uid
}
`
;
if
(
!
this
.
_contextId
)
{
this
.
_toggleListeners
(
"
subscribe
"
,
id
);
this
.
_contextId
=
id
;
}
return
{
name
:
this
.
$options
.
name
.
replace
(
/VUni
([
A-Z
])
/
,
"
$1
"
).
toLowerCase
(),
id
,
page
:
this
.
$page
.
id
};
}
}
};
function
throttle
(
fn
,
wait
)
{
let
last
=
0
;
let
timeout
;
let
waitCallback
;
const
newFn
=
function
(...
arg
)
{
const
now
=
Date
.
now
();
clearTimeout
(
timeout
);
waitCallback
=
()
=>
{
waitCallback
=
null
;
last
=
now
;
fn
.
apply
(
this
,
arg
);
};
if
(
now
-
last
<
wait
)
{
timeout
=
setTimeout
(
waitCallback
,
wait
-
(
now
-
last
));
return
;
}
waitCallback
();
};
newFn
.
cancel
=
function
()
{
clearTimeout
(
timeout
);
waitCallback
=
null
;
};
newFn
.
flush
=
function
()
{
clearTimeout
(
timeout
);
waitCallback
&&
waitCallback
();
};
return
newFn
;
}
const
_sfc_main$1
=
{
name
:
"
Audio
"
,
mixins
:
[
subscriber
],
props
:
{
id
:
{
type
:
String
,
default
:
""
},
src
:
{
type
:
String
,
default
:
""
},
loop
:
{
type
:
[
Boolean
,
String
],
default
:
false
},
controls
:
{
type
:
[
Boolean
,
String
],
default
:
false
},
poster
:
{
type
:
String
,
default
:
""
},
name
:
{
type
:
String
,
default
:
""
},
author
:
{
type
:
String
,
default
:
""
}
},
data
()
{
return
{
playing
:
false
,
currentTime
:
this
.
getTime
(
0
)
};
},
watch
:
{
src
(
val
)
{
if
(
this
.
$refs
.
audio
)
{
this
.
$refs
.
audio
.
src
=
this
.
$getRealPath
(
val
);
}
}
},
mounted
()
{
const
audio
=
this
.
$refs
.
audio
;
audio
.
addEventListener
(
"
error
"
,
(
$event
)
=>
{
this
.
playing
=
false
;
this
.
$trigger
(
"
error
"
,
$event
,
{});
});
audio
.
addEventListener
(
"
play
"
,
(
$event
)
=>
{
this
.
playing
=
true
;
this
.
$trigger
(
"
play
"
,
$event
,
{});
});
audio
.
addEventListener
(
"
pause
"
,
(
$event
)
=>
{
this
.
playing
=
false
;
this
.
$trigger
(
"
pause
"
,
$event
,
{});
});
audio
.
addEventListener
(
"
ended
"
,
(
$event
)
=>
{
this
.
playing
=
false
;
this
.
$trigger
(
"
ended
"
,
$event
,
{});
});
audio
.
addEventListener
(
"
timeupdate
"
,
(
$event
)
=>
{
var
currentTime
=
audio
.
currentTime
;
this
.
currentTime
=
this
.
getTime
(
currentTime
);
var
duration
=
audio
.
duration
;
this
.
$trigger
(
"
timeupdate
"
,
$event
,
{
currentTime
,
duration
});
});
audio
.
src
=
this
.
$getRealPath
(
this
.
src
);
},
methods
:
{
_handleSubscribe
({
type
,
data
=
{}
})
{
var
audio
=
this
.
$refs
.
audio
;
switch
(
type
)
{
case
"
setSrc
"
:
audio
.
src
=
this
.
$getRealPath
(
data
.
src
);
this
.
$emit
(
"
update:src
"
,
data
.
src
);
break
;
case
"
play
"
:
audio
.
play
();
break
;
case
"
pause
"
:
audio
.
pause
();
break
;
case
"
seek
"
:
audio
.
currentTime
=
data
.
position
;
break
;
}
},
trigger
()
{
if
(
this
.
playing
)
{
this
.
$refs
.
audio
.
pause
();
}
else
{
this
.
$refs
.
audio
.
play
();
}
},
getTime
(
time
)
{
var
h
=
Math
.
floor
(
time
/
3600
);
var
m
=
Math
.
floor
(
time
%
3600
/
60
);
var
s
=
Math
.
floor
(
time
%
3600
%
60
);
h
=
(
h
<
10
?
"
0
"
:
""
)
+
h
;
m
=
(
m
<
10
?
"
0
"
:
""
)
+
m
;
s
=
(
s
<
10
?
"
0
"
:
""
)
+
s
;
var
str
=
m
+
"
:
"
+
s
;
if
(
h
!==
"
00
"
)
{
str
=
h
+
"
:
"
+
str
;
}
return
str
;
}
}
};
const
_hoisted_1$1
=
{
class
:
"
uni-audio-default
"
};
const
_hoisted_2$1
=
{
class
:
"
uni-audio-right
"
};
const
_hoisted_3$1
=
{
class
:
"
uni-audio-time
"
};
const
_hoisted_4$1
=
{
class
:
"
uni-audio-info
"
};
const
_hoisted_5
=
{
class
:
"
uni-audio-name
"
};
const
_hoisted_6
=
{
class
:
"
uni-audio-author
"
};
function
_sfc_render$1
(
_ctx
,
_cache
,
$props
,
$setup
,
$data
,
$options
)
{
return
vue
.
openBlock
(),
vue
.
createBlock
(
"
uni-audio
"
,
vue
.
mergeProps
({
id
:
$props
.
id
,
controls
:
!!
$props
.
controls
},
_ctx
.
$attrs
),
[
vue
.
createVNode
(
"
audio
"
,
{
ref
:
"
audio
"
,
loop
:
$props
.
loop
,
style
:
{
"
display
"
:
"
none
"
}
},
null
,
8
,
[
"
loop
"
]),
vue
.
createVNode
(
"
div
"
,
_hoisted_1$1
,
[
vue
.
createVNode
(
"
div
"
,
{
style
:
"
background-image: url(
"
+
_ctx
.
$getRealPath
(
$props
.
poster
)
+
"
);
"
,
class
:
"
uni-audio-left
"
},
[
vue
.
createVNode
(
"
div
"
,
{
class
:
[{
play
:
!
$data
.
playing
,
pause
:
$data
.
playing
},
"
uni-audio-button
"
],
onClick
:
_cache
[
1
]
||
(
_cache
[
1
]
=
(...
args
)
=>
$options
.
trigger
&&
$options
.
trigger
(...
args
))
},
null
,
2
)
],
4
),
vue
.
createVNode
(
"
div
"
,
_hoisted_2$1
,
[
vue
.
createVNode
(
"
div
"
,
_hoisted_3$1
,
vue
.
toDisplayString
(
$data
.
currentTime
),
1
),
vue
.
createVNode
(
"
div
"
,
_hoisted_4$1
,
[
vue
.
createVNode
(
"
div
"
,
_hoisted_5
,
vue
.
toDisplayString
(
$props
.
name
),
1
),
vue
.
createVNode
(
"
div
"
,
_hoisted_6
,
vue
.
toDisplayString
(
$props
.
author
),
1
)
])
])
])
],
16
,
[
"
id
"
,
"
controls
"
]);
}
_sfc_main$1
.
render
=
_sfc_render$1
;
let
i18n
;
let
i18n
;
function
useI18n
()
{
function
useI18n
()
{
if
(
!
i18n
)
{
if
(
!
i18n
)
{
...
@@ -2914,6 +2692,34 @@ function useImageSize(rootRef, props2, state) {
...
@@ -2914,6 +2692,34 @@ function useImageSize(rootRef, props2, state) {
resetSize
resetSize
};
};
}
}
function
throttle
(
fn
,
wait
)
{
let
last
=
0
;
let
timeout
;
let
waitCallback
;
const
newFn
=
function
(...
arg
)
{
const
now
=
Date
.
now
();
clearTimeout
(
timeout
);
waitCallback
=
()
=>
{
waitCallback
=
null
;
last
=
now
;
fn
.
apply
(
this
,
arg
);
};
if
(
now
-
last
<
wait
)
{
timeout
=
setTimeout
(
waitCallback
,
wait
-
(
now
-
last
));
return
;
}
waitCallback
();
};
newFn
.
cancel
=
function
()
{
clearTimeout
(
timeout
);
waitCallback
=
null
;
};
newFn
.
flush
=
function
()
{
clearTimeout
(
timeout
);
waitCallback
&&
waitCallback
();
};
return
newFn
;
}
uniShared
.
passive
(
true
);
uniShared
.
passive
(
true
);
function
useUserAction
()
{
function
useUserAction
()
{
const
state
=
vue
.
reactive
({
const
state
=
vue
.
reactive
({
...
@@ -10876,7 +10682,6 @@ var index = /* @__PURE__ */ defineSystemComponent({
...
@@ -10876,7 +10682,6 @@ var index = /* @__PURE__ */ defineSystemComponent({
});
});
exports
.
AsyncErrorComponent
=
index$1
;
exports
.
AsyncErrorComponent
=
index$1
;
exports
.
AsyncLoadingComponent
=
index
;
exports
.
AsyncLoadingComponent
=
index
;
exports
.
Audio
=
_sfc_main$1
;
exports
.
Button
=
index$w
;
exports
.
Button
=
index$w
;
exports
.
Canvas
=
index$v
;
exports
.
Canvas
=
index$v
;
exports
.
Checkbox
=
index$t
;
exports
.
Checkbox
=
index$t
;
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
08a578bc
import {
isFunction, extend, isString, hyphenate, isPlainObject, isArray, hasOwn, isObject, capitalize, toRawType, makeMap as makeMap$1, isPromise, invokeArrayFns as invokeArrayFns$1 } from "@vue/shared
";
import {
withModifiers, createVNode, getCurrentInstance, defineComponent, ref, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, mergeProps, reactive, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, createTextVNode, injectHook, onBeforeActivate, onBeforeDeactivate, openBlock, createBlock, renderList, onDeactivated, createApp, Transition, withCtx, KeepAlive, resolveDynamicComponent, renderSlot } from "vue
";
import { once, passive, initCustomDataset, invokeArrayFns, normalizeTarget, isBuiltInComponent, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, EventChannel, SCHEME_RE, DATA_RE, getCustomDataset, ON_ERROR, callOptions, PRIMARY_COLOR, removeLeadingSlash, getLen, debounce, NAVBAR_HEIGHT, parseQuery, ON_UNLOAD, ON_REACH_BOTTOM_DISTANCE, decodedQuery, WEB_INVOKE_APPSERVICE, ON_WEB_INVOKE_APP_SERVICE, updateElementStyle, ON_BACK_PRESS, parseUrl, addFont, scrollTo, RESPONSIVE_MIN_WIDTH, formatDateTime, ON_PULL_DOWN_REFRESH } from "@dcloudio/uni-shared";
import { once, passive, initCustomDataset, invokeArrayFns, normalizeTarget, isBuiltInComponent, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, EventChannel, SCHEME_RE, DATA_RE, getCustomDataset, ON_ERROR, callOptions, PRIMARY_COLOR, removeLeadingSlash, getLen, debounce, NAVBAR_HEIGHT, parseQuery, ON_UNLOAD, ON_REACH_BOTTOM_DISTANCE, decodedQuery, WEB_INVOKE_APPSERVICE, ON_WEB_INVOKE_APP_SERVICE, updateElementStyle, ON_BACK_PRESS, parseUrl, addFont, scrollTo, RESPONSIVE_MIN_WIDTH, formatDateTime, ON_PULL_DOWN_REFRESH } from "@dcloudio/uni-shared";
import { openBlock, createBlock, mergeProps, createVNode, toDisplayString, withModifiers, getCurrentInstance, defineComponent, ref, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, reactive, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, createTextVNode, injectHook, onBeforeActivate, onBeforeDeactivate, renderList, onDeactivated, createApp, Transition, withCtx, KeepAlive, resolveDynamicComponent, renderSlot } from "vue";
import { initVueI18n, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT } from "@dcloudio/uni-i18n";
import { initVueI18n, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT } from "@dcloudio/uni-i18n";
import { extend, isString, hyphenate, isPlainObject, isFunction, isArray, hasOwn, isObject, capitalize, toRawType, makeMap as makeMap$1, isPromise, invokeArrayFns as invokeArrayFns$1 } from "@vue/shared";
import { useRoute, createRouter, createWebHistory, createWebHashHistory, useRouter, isNavigationFailure, RouterView } from "vue-router";
import { useRoute, createRouter, createWebHistory, createWebHashHistory, useRouter, isNavigationFailure, RouterView } from "vue-router";
var subscriber = {
mounted() {
this._toggleListeners("subscribe", this.id);
this.$watch("id", (newId, oldId) => {
this._toggleListeners("unsubscribe", oldId, true);
this._toggleListeners("subscribe", newId, true);
});
},
beforeDestroy() {
this._toggleListeners("unsubscribe", this.id);
if (this._contextId) {
this._toggleListeners("unsubscribe", this._contextId);
}
},
methods: {
_toggleListeners(type, id2, watch2) {
if (watch2 && !id2) {
return;
}
if (!isFunction(this._handleSubscribe)) {
return;
}
UniViewJSBridge[type](this.$page.id + "-" + this.$options.name.replace(/VUni([A-Z])/, "$1").toLowerCase() + "-" + id2, this._handleSubscribe);
},
_getContextInfo() {
const id2 = `context-${this._uid}`;
if (!this._contextId) {
this._toggleListeners("subscribe", id2);
this._contextId = id2;
}
return {
name: this.$options.name.replace(/VUni([A-Z])/, "$1").toLowerCase(),
id: id2,
page: this.$page.id
};
}
}
};
function throttle(fn, wait) {
let last = 0;
let timeout;
let waitCallback;
const newFn = function(...arg) {
const now = Date.now();
clearTimeout(timeout);
waitCallback = () => {
waitCallback = null;
last = now;
fn.apply(this, arg);
};
if (now - last < wait) {
timeout = setTimeout(waitCallback, wait - (now - last));
return;
}
waitCallback();
};
newFn.cancel = function() {
clearTimeout(timeout);
waitCallback = null;
};
newFn.flush = function() {
clearTimeout(timeout);
waitCallback && waitCallback();
};
return newFn;
}
const _sfc_main$1 = {
name: "Audio",
mixins: [subscriber],
props: {
id: {
type: String,
default: ""
},
src: {
type: String,
default: ""
},
loop: {
type: [Boolean, String],
default: false
},
controls: {
type: [Boolean, String],
default: false
},
poster: {
type: String,
default: ""
},
name: {
type: String,
default: ""
},
author: {
type: String,
default: ""
}
},
data() {
return {
playing: false,
currentTime: this.getTime(0)
};
},
watch: {
src(val) {
if (this.$refs.audio) {
this.$refs.audio.src = this.$getRealPath(val);
}
}
},
mounted() {
const audio = this.$refs.audio;
audio.addEventListener("error", ($event) => {
this.playing = false;
this.$trigger("error", $event, {});
});
audio.addEventListener("play", ($event) => {
this.playing = true;
this.$trigger("play", $event, {});
});
audio.addEventListener("pause", ($event) => {
this.playing = false;
this.$trigger("pause", $event, {});
});
audio.addEventListener("ended", ($event) => {
this.playing = false;
this.$trigger("ended", $event, {});
});
audio.addEventListener("timeupdate", ($event) => {
var currentTime = audio.currentTime;
this.currentTime = this.getTime(currentTime);
var duration = audio.duration;
this.$trigger("timeupdate", $event, {
currentTime,
duration
});
});
audio.src = this.$getRealPath(this.src);
},
methods: {
_handleSubscribe({
type,
data = {}
}) {
var audio = this.$refs.audio;
switch (type) {
case "setSrc":
audio.src = this.$getRealPath(data.src);
this.$emit("update:src", data.src);
break;
case "play":
audio.play();
break;
case "pause":
audio.pause();
break;
case "seek":
audio.currentTime = data.position;
break;
}
},
trigger() {
if (this.playing) {
this.$refs.audio.pause();
} else {
this.$refs.audio.play();
}
},
getTime(time) {
var h = Math.floor(time / 3600);
var m = Math.floor(time % 3600 / 60);
var s = Math.floor(time % 3600 % 60);
h = (h < 10 ? "0" : "") + h;
m = (m < 10 ? "0" : "") + m;
s = (s < 10 ? "0" : "") + s;
var str = m + ":" + s;
if (h !== "00") {
str = h + ":" + str;
}
return str;
}
}
};
const _hoisted_1$1 = { class: "uni-audio-default" };
const _hoisted_2$1 = { class: "uni-audio-right" };
const _hoisted_3$1 = { class: "uni-audio-time" };
const _hoisted_4$1 = { class: "uni-audio-info" };
const _hoisted_5 = { class: "uni-audio-name" };
const _hoisted_6 = { class: "uni-audio-author" };
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createBlock("uni-audio", mergeProps({
id: $props.id,
controls: !!$props.controls
}, _ctx.$attrs), [
createVNode("audio", {
ref: "audio",
loop: $props.loop,
style: { "display": "none" }
}, null, 8, ["loop"]),
createVNode("div", _hoisted_1$1, [
createVNode("div", {
style: "background-image: url(" + _ctx.$getRealPath($props.poster) + ");",
class: "uni-audio-left"
}, [
createVNode("div", {
class: [{ play: !$data.playing, pause: $data.playing }, "uni-audio-button"],
onClick: _cache[1] || (_cache[1] = (...args) => $options.trigger && $options.trigger(...args))
}, null, 2)
], 4),
createVNode("div", _hoisted_2$1, [
createVNode("div", _hoisted_3$1, toDisplayString($data.currentTime), 1),
createVNode("div", _hoisted_4$1, [
createVNode("div", _hoisted_5, toDisplayString($props.name), 1),
createVNode("div", _hoisted_6, toDisplayString($props.author), 1)
])
])
])
], 16, ["id", "controls"]);
}
_sfc_main$1.render = _sfc_render$1;
let i18n;
let i18n;
function useI18n() {
function useI18n() {
if (!i18n) {
if (!i18n) {
...
@@ -786,7 +564,7 @@ var safeAreaInsets = {
...
@@ -786,7 +564,7 @@ var safeAreaInsets = {
onChange,
onChange,
offChange
offChange
};
};
var out = safeAreaInsets;
var
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out = safeAreaInsets;
const onEventPrevent = /* @__PURE__ */ withModifiers(() => {
const onEventPrevent = /* @__PURE__ */ withModifiers(() => {
}, ["prevent"]);
}, ["prevent"]);
const onEventStop = /* @__PURE__ */ withModifiers(() => {
const onEventStop = /* @__PURE__ */ withModifiers(() => {
...
@@ -798,10 +576,10 @@ function getWindowOffset() {
...
@@ -798,10 +576,10 @@ function getWindowOffset() {
const left = parseInt(style.getPropertyValue("--window-left"));
const left = parseInt(style.getPropertyValue("--window-left"));
const right = parseInt(style.getPropertyValue("--window-right"));
const right = parseInt(style.getPropertyValue("--window-right"));
return {
return {
top: top ? top + out.top : 0,
top: top ? top +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top : 0,
bottom: bottom ? bottom + out.bottom : 0,
bottom: bottom ? bottom +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom : 0,
left: left ? left + out.left : 0,
left: left ? left +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.left : 0,
right: right ? right + out.right : 0
right: right ? right +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right : 0
};
};
}
}
function updateCssVar(cssVars) {
function updateCssVar(cssVars) {
...
@@ -7945,6 +7723,34 @@ function useImageSize(rootRef, props2, state2) {
...
@@ -7945,6 +7723,34 @@ function useImageSize(rootRef, props2, state2) {
resetSize
resetSize
};
};
}
}
function throttle(fn, wait) {
let last = 0;
let timeout;
let waitCallback;
const newFn = function(...arg) {
const now = Date.now();
clearTimeout(timeout);
waitCallback = () => {
waitCallback = null;
last = now;
fn.apply(this, arg);
};
if (now - last < wait) {
timeout = setTimeout(waitCallback, wait - (now - last));
return;
}
waitCallback();
};
newFn.cancel = function() {
clearTimeout(timeout);
waitCallback = null;
};
newFn.flush = function() {
clearTimeout(timeout);
waitCallback && waitCallback();
};
return newFn;
}
const passiveOptions$1 = passive(true);
const passiveOptions$1 = passive(true);
const states = [];
const states = [];
let userInteract = 0;
let userInteract = 0;
...
@@ -13350,7 +13156,7 @@ function normalizePageMeta(pageMeta) {
...
@@ -13350,7 +13156,7 @@ function normalizePageMeta(pageMeta) {
}, pageMeta.pullToRefresh));
}, pageMeta.pullToRefresh));
const { type, style } = navigationBar;
const { type, style } = navigationBar;
if (style !== "custom" && type !== "transparent") {
if (style !== "custom" && type !== "transparent") {
pullToRefresh.offset += NAVBAR_HEIGHT + out.top;
pullToRefresh.offset += NAVBAR_HEIGHT +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top;
}
}
pageMeta.pullToRefresh = pullToRefresh;
pageMeta.pullToRefresh = pullToRefresh;
}
}
...
@@ -15548,7 +15354,7 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
...
@@ -15548,7 +15354,7 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const windowWidth = getWindowWidth(screenWidth);
const windowWidth = getWindowWidth(screenWidth);
let windowHeight = window.innerHeight;
let windowHeight = window.innerHeight;
const language = navigator.language;
const language = navigator.language;
const statusBarHeight = out.top;
const statusBarHeight =
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top;
let osname;
let osname;
let osversion;
let osversion;
let model;
let model;
...
@@ -15661,12 +15467,12 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
...
@@ -15661,12 +15467,12 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const system = `${osname} ${osversion}`;
const system = `${osname} ${osversion}`;
const platform = osname.toLocaleLowerCase();
const platform = osname.toLocaleLowerCase();
const safeArea = {
const safeArea = {
left: out.left,
left:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.left,
right: windowWidth - out.right,
right: windowWidth -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right,
top: out.top,
top:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top,
bottom: windowHeight - out.bottom,
bottom: windowHeight -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom,
width: windowWidth -
out.left -
out.right,
width: windowWidth -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right,
height: windowHeight -
out.top -
out.bottom
height: windowHeight -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom
};
};
const { top: windowTop, bottom: windowBottom } = getWindowOffset();
const { top: windowTop, bottom: windowBottom } = getWindowOffset();
windowHeight -= windowTop;
windowHeight -= windowTop;
...
@@ -15686,10 +15492,10 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
...
@@ -15686,10 +15492,10 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
model,
model,
safeArea,
safeArea,
safeAreaInsets: {
safeAreaInsets: {
top: out.top,
top:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top,
right: out.right,
right:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right,
bottom: out.bottom,
bottom:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom,
left: out.left
left:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.left
}
}
};
};
});
});
...
@@ -21286,4 +21092,4 @@ var index = /* @__PURE__ */ defineSystemComponent({
...
@@ -21286,4 +21092,4 @@ var index = /* @__PURE__ */ defineSystemComponent({
return openBlock(), createBlock("div", clazz, [loadingVNode]);
return openBlock(), createBlock("div", clazz, [loadingVNode]);
}
}
});
});
export { $emit, $off, $on, $once, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent,
_sfc_main$1 as Audio,
index$s as Button, index$q as Canvas, index$o as Checkbox, index$p as CheckboxGroup, index$4 as CoverImage, index$5 as CoverView, index$n as Editor, index$u as Form, index$m as Icon, index$l as Image, Input, index$t as Label, LayoutComponent, Map$1 as Map, MovableArea, MovableView, index$k as Navigator, index$2 as PageComponent, index$3 as Picker, PickerView, PickerViewColumn, index$j as Progress, index$h as Radio, index$i as RadioGroup, ResizeSensor, index$g as RichText, ScrollView, index$f as Slider, Swiper, SwiperItem, index$e as Switch, index$d as Text, index$c as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$8 as Video, index$b as View, index$7 as WebView, addInterceptor, addPhoneContact, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closeSocket, connectSocket, createAnimation$1 as createAnimation, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createLivePlayerContext, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, downloadFile, getApp$1 as getApp, getCurrentPages$1 as getCurrentPages, getFileInfo, getImageInfo, getLeftWindowStyle, getLocation, getNetworkType, getProvider, getRealPath, getRecorderManager, getRightWindowStyle, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange$1 as getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, loadFontFace, login, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offWindowResize, onAccelerometerChange, onCompassChange, onGyroscopeChange, onMemoryWarning, onNetworkStatusChange, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUserCaptureScreen, onWindowResize, openDocument, openLocation, pageScrollTo, index$9 as plugin, preloadPage, previewImage, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, removeSavedFileInfo, removeStorage, removeStorageSync, removeTabBarBadge, request, saveFile, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, sendSocketMessage, setKeepScreenOn, setLeftWindowStyle, setNavigationBarColor, setNavigationBarTitle, setRightWindowStyle, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, setupWindow, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startGyroscope, startPullDownRefresh, stopAccelerometer, stopCompass, stopGyroscope, stopPullDownRefresh, switchTab, uni$1 as uni, uploadFile, upx2px, useTabBar, vibrateLong, vibrateShort };
export { $emit, $off, $on, $once, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, index$s as Button, index$q as Canvas, index$o as Checkbox, index$p as CheckboxGroup, index$4 as CoverImage, index$5 as CoverView, index$n as Editor, index$u as Form, index$m as Icon, index$l as Image, Input, index$t as Label, LayoutComponent, Map$1 as Map, MovableArea, MovableView, index$k as Navigator, index$2 as PageComponent, index$3 as Picker, PickerView, PickerViewColumn, index$j as Progress, index$h as Radio, index$i as RadioGroup, ResizeSensor, index$g as RichText, ScrollView, index$f as Slider, Swiper, SwiperItem, index$e as Switch, index$d as Text, index$c as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$8 as Video, index$b as View, index$7 as WebView, addInterceptor, addPhoneContact, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closeSocket, connectSocket, createAnimation$1 as createAnimation, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createLivePlayerContext, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, downloadFile, getApp$1 as getApp, getCurrentPages$1 as getCurrentPages, getFileInfo, getImageInfo, getLeftWindowStyle, getLocation, getNetworkType, getProvider, getRealPath, getRecorderManager, getRightWindowStyle, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange$1 as getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, loadFontFace, login, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offWindowResize, onAccelerometerChange, onCompassChange, onGyroscopeChange, onMemoryWarning, onNetworkStatusChange, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUserCaptureScreen, onWindowResize, openDocument, openLocation, pageScrollTo, index$9 as plugin, preloadPage, previewImage, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, removeSavedFileInfo, removeStorage, removeStorageSync, removeTabBarBadge, request, saveFile, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, sendSocketMessage, setKeepScreenOn, setLeftWindowStyle, setNavigationBarColor, setNavigationBarTitle, setRightWindowStyle, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, setupWindow, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startGyroscope, startPullDownRefresh, stopAccelerometer, stopCompass, stopGyroscope, stopPullDownRefresh, switchTab, uni$1 as uni, uploadFile, upx2px, useTabBar, vibrateLong, vibrateShort };
packages/uni-h5/src/index.ts
浏览文件 @
08a578bc
export
{
export
{
Audio
,
Button
,
Button
,
Canvas
,
Canvas
,
Checkbox
,
Checkbox
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录