Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
m0_68066342
uni-app
提交
22ce471a
U
uni-app
项目概览
m0_68066342
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
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,发现更多精彩内容 >>
提交
22ce471a
编写于
1月 08, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of
https://github.com/dcloudio/uni-app
into alpha
上级
b2711a00
3ecbc789
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
173 addition
and
71 deletion
+173
-71
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+31
-12
packages/uni-app-plus/dist/service.runtime.esm.js
packages/uni-app-plus/dist/service.runtime.esm.js
+48
-0
packages/uni-cli-shared/lib/pages.js
packages/uni-cli-shared/lib/pages.js
+22
-9
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+8
-5
packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.common.js
...ugin-uni/packages/h5-vue-router/dist/vue-router.common.js
+2
-3
packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.esm.js
...-plugin-uni/packages/h5-vue-router/dist/vue-router.esm.js
+2
-3
packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.js
...-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.js
+2
-3
packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.min.js
...-plugin-uni/packages/h5-vue-router/dist/vue-router.min.js
+2
-2
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/plugin/index.js
...lugin-uni/packages/webpack-uni-app-loader/plugin/index.js
+3
-1
packages/webpack-uni-pages-loader/lib/index-new.js
packages/webpack-uni-pages-loader/lib/index-new.js
+2
-1
src/core/helpers/hidpi.js
src/core/helpers/hidpi.js
+19
-19
src/core/service/api/context/audio.js
src/core/service/api/context/audio.js
+32
-13
未找到文件。
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
22ce471a
...
@@ -8962,14 +8962,14 @@ var serviceContext = (function () {
...
@@ -8962,14 +8962,14 @@ var serviceContext = (function () {
'
pause
'
,
'
pause
'
,
'
stop
'
,
'
stop
'
,
'
ended
'
,
'
ended
'
,
'
time
u
pdate
'
,
'
time
U
pdate
'
,
'
error
'
,
'
error
'
,
'
waiting
'
,
'
waiting
'
,
'
seeking
'
,
'
seeking
'
,
'
seeked
'
'
seeked
'
];
];
const
props
=
[
const
props
=
[
{
{
name
:
'
src
'
,
name
:
'
src
'
,
cache
:
true
cache
:
true
...
@@ -9022,7 +9022,7 @@ var serviceContext = (function () {
...
@@ -9022,7 +9022,7 @@ var serviceContext = (function () {
this
.
_callbacks
=
{};
this
.
_callbacks
=
{};
this
.
_options
=
{};
this
.
_options
=
{};
eventNames
.
forEach
(
name
=>
{
eventNames
.
forEach
(
name
=>
{
this
.
_callbacks
[
name
]
=
[];
this
.
_callbacks
[
name
.
toLowerCase
()
]
=
[];
});
});
props
.
forEach
(
item
=>
{
props
.
forEach
(
item
=>
{
const
name
=
item
.
name
;
const
name
=
item
.
name
;
...
@@ -9056,11 +9056,12 @@ var serviceContext = (function () {
...
@@ -9056,11 +9056,12 @@ var serviceContext = (function () {
this
.
_operate
(
'
stop
'
);
this
.
_operate
(
'
stop
'
);
}
}
seek
(
position
)
{
seek
(
position
)
{
this
.
_operate
(
'
play
'
,
{
this
.
_operate
(
'
seek
'
,
{
currentTime
:
position
currentTime
:
position
*
1
e3
});
});
}
}
destroy
()
{
destroy
()
{
clearInterval
(
this
.
__timing
);
invokeMethod
(
'
destroyAudioInstance
'
,
{
invokeMethod
(
'
destroyAudioInstance
'
,
{
audioId
:
this
.
id
audioId
:
this
.
id
});
});
...
@@ -9076,6 +9077,7 @@ var serviceContext = (function () {
...
@@ -9076,6 +9077,7 @@ var serviceContext = (function () {
eventNames
.
forEach
(
item
=>
{
eventNames
.
forEach
(
item
=>
{
const
name
=
item
[
0
].
toUpperCase
()
+
item
.
substr
(
1
);
const
name
=
item
[
0
].
toUpperCase
()
+
item
.
substr
(
1
);
item
=
item
.
toLowerCase
();
InnerAudioContext
.
prototype
[
`on
${
name
}
`
]
=
function
(
callback
)
{
InnerAudioContext
.
prototype
[
`on
${
name
}
`
]
=
function
(
callback
)
{
this
.
_callbacks
[
item
].
push
(
callback
);
this
.
_callbacks
[
item
].
push
(
callback
);
};
};
...
@@ -9088,6 +9090,17 @@ var serviceContext = (function () {
...
@@ -9088,6 +9090,17 @@ var serviceContext = (function () {
};
};
});
});
function
emit
(
audio
,
state
,
errMsg
,
errCode
)
{
audio
.
_callbacks
[
state
].
forEach
(
callback
=>
{
if
(
typeof
callback
===
'
function
'
)
{
callback
(
state
===
'
error
'
?
{
errMsg
,
errCode
}
:
{});
}
});
}
onMethod
(
'
onAudioStateChange
'
,
({
onMethod
(
'
onAudioStateChange
'
,
({
state
,
state
,
audioId
,
audioId
,
...
@@ -9095,14 +9108,20 @@ var serviceContext = (function () {
...
@@ -9095,14 +9108,20 @@ var serviceContext = (function () {
errCode
errCode
})
=>
{
})
=>
{
const
audio
=
innerAudioContexts
[
audioId
];
const
audio
=
innerAudioContexts
[
audioId
];
audio
&&
audio
.
_callbacks
[
state
].
forEach
(
callback
=>
{
if
(
audio
)
{
if
(
typeof
callback
===
'
function
'
)
{
emit
(
audio
,
state
,
errMsg
,
errCode
);
callback
(
state
===
'
error
'
?
{
if
(
state
===
'
play
'
)
{
errMsg
,
const
oldCurrentTime
=
audio
.
currentTime
;
errCode
audio
.
__timing
=
setInterval
(()
=>
{
}
:
{});
const
currentTime
=
audio
.
currentTime
;
if
(
currentTime
!==
oldCurrentTime
)
{
emit
(
audio
,
'
timeupdate
'
);
}
},
200
);
}
else
if
(
state
===
'
pause
'
||
state
===
'
stop
'
||
state
===
'
error
'
)
{
clearInterval
(
audio
.
__timing
);
}
}
}
);
}
});
});
const
innerAudioContexts
=
Object
.
create
(
null
);
const
innerAudioContexts
=
Object
.
create
(
null
);
...
...
packages/uni-app-plus/dist/service.runtime.esm.js
浏览文件 @
22ce471a
...
@@ -6642,6 +6642,53 @@ var baseModules = [
...
@@ -6642,6 +6642,53 @@ var baseModules = [
directives
directives
];
];
/* */
function
updateWxsProps
(
oldVnode
,
vnode
)
{
if
(
isUndef
(
oldVnode
.
data
.
wxsProps
)
&&
isUndef
(
vnode
.
data
.
wxsProps
)
)
{
return
}
var
oldWxsWatches
=
oldVnode
.
$wxsWatches
;
var
wxsPropsKey
=
Object
.
keys
(
vnode
.
data
.
wxsProps
);
if
(
!
oldWxsWatches
&&
!
wxsPropsKey
.
length
)
{
return
}
if
(
!
oldWxsWatches
)
{
oldWxsWatches
=
{};
}
var
wxsProps
=
vnode
.
data
.
wxsProps
;
vnode
.
$wxsWatches
=
{};
Object
.
keys
(
wxsProps
).
forEach
(
function
(
prop
)
{
var
watchProp
=
wxsProps
[
prop
];
vnode
.
$wxsWatches
[
prop
]
=
oldWxsWatches
[
prop
]
||
vnode
.
context
.
$watch
(
watchProp
,
function
()
{
this
.
$forceUpdate
();
},
{
deep
:
true
});
});
Object
.
keys
(
oldWxsWatches
).
forEach
(
function
(
oldName
)
{
if
(
!
vnode
.
$wxsWatches
[
oldName
])
{
oldWxsWatches
[
oldName
]();
delete
oldWxsWatches
[
oldName
];
}
});
}
var
wxs
=
{
create
:
updateWxsProps
,
update
:
updateWxsProps
};
function
parseDataset
(
attrs
)
{
function
parseDataset
(
attrs
)
{
var
dataset
=
Object
.
create
(
null
);
var
dataset
=
Object
.
create
(
null
);
Object
.
keys
(
attrs
).
forEach
(
function
(
name
)
{
Object
.
keys
(
attrs
).
forEach
(
function
(
name
)
{
...
@@ -6765,6 +6812,7 @@ var events = {
...
@@ -6765,6 +6812,7 @@ var events = {
};
};
var
platformModules
=
[
var
platformModules
=
[
wxs
,
attrs
,
attrs
,
events
events
];
];
...
...
packages/uni-cli-shared/lib/pages.js
浏览文件 @
22ce471a
...
@@ -334,7 +334,7 @@ let uniAutoImportComponents = []
...
@@ -334,7 +334,7 @@ let uniAutoImportComponents = []
let
uniAutoImportScanComponents
=
[]
let
uniAutoImportScanComponents
=
[]
function
initAutoImportScanComponents
()
{
function
initAutoImportScanComponents
()
{
const
componentsPath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
components
'
)
const
componentsPath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
components
'
)
const
components
=
{}
const
components
=
{}
try
{
try
{
...
@@ -347,12 +347,22 @@ function initAutoImportScanComponents () {
...
@@ -347,12 +347,22 @@ function initAutoImportScanComponents () {
})
})
}
catch
(
e
)
{}
}
catch
(
e
)
{}
uniAutoImportScanComponents
=
parseUsingAutoImportComponents
(
components
)
uniAutoImportScanComponents
=
parseUsingAutoImportComponents
(
components
)
refreshAutoComponentMap
()
refreshAutoComponentMap
()
}
}
function
initAutoImportComponents
(
usingAutoImportComponents
=
{})
{
const
_toString
=
Object
.
prototype
.
toString
function
isPlainObject
(
obj
)
{
return
_toString
.
call
(
obj
)
===
'
[object Object]
'
}
function
initAutoImportComponents
(
easycom
=
{})
{
let
usingAutoImportComponents
=
easycom
.
custom
||
easycom
||
{}
if
(
!
isPlainObject
(
usingAutoImportComponents
))
{
usingAutoImportComponents
=
{}
}
// 目前仅 mp-weixin 内置支持 page-meta 等组件
// 目前仅 mp-weixin 内置支持 page-meta 等组件
if
(
process
.
env
.
UNI_PLATFORM
!==
'
mp-weixin
'
)
{
if
(
process
.
env
.
UNI_PLATFORM
!==
'
mp-weixin
'
)
{
if
(
!
usingAutoImportComponents
[
'
^page-meta$
'
])
{
if
(
!
usingAutoImportComponents
[
'
^page-meta$
'
])
{
...
@@ -415,10 +425,13 @@ function parseUsingAutoImportComponents (usingAutoImportComponents) {
...
@@ -415,10 +425,13 @@ function parseUsingAutoImportComponents (usingAutoImportComponents) {
const
autoImportComponents
=
[]
const
autoImportComponents
=
[]
if
(
usingAutoImportComponents
)
{
if
(
usingAutoImportComponents
)
{
Object
.
keys
(
usingAutoImportComponents
).
forEach
(
pattern
=>
{
Object
.
keys
(
usingAutoImportComponents
).
forEach
(
pattern
=>
{
autoImportComponents
.
push
({
const
replacement
=
usingAutoImportComponents
[
pattern
]
pattern
:
new
RegExp
(
pattern
),
if
(
replacement
&&
typeof
replacement
===
'
string
'
)
{
replacement
:
usingAutoImportComponents
[
pattern
]
autoImportComponents
.
push
({
})
pattern
:
new
RegExp
(
pattern
),
replacement
:
replacement
})
}
})
})
}
}
return
autoImportComponents
return
autoImportComponents
...
@@ -432,7 +445,7 @@ module.exports = {
...
@@ -432,7 +445,7 @@ module.exports = {
parsePagesJson
,
parsePagesJson
,
pagesJsonJsFileName
,
pagesJsonJsFileName
,
getAutoComponents
,
getAutoComponents
,
initAutoImportComponents
,
initAutoImportComponents
,
initAutoImportScanComponents
,
initAutoImportScanComponents
,
addPageUsingComponents
,
addPageUsingComponents
,
getUsingComponentsCode
,
getUsingComponentsCode
,
...
...
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
22ce471a
...
@@ -312,12 +312,15 @@ if (
...
@@ -312,12 +312,15 @@ if (
}
}
const
{
const
{
initAutoImportComponents
,
initAutoImportComponents
,
initAutoImportScanComponents
initAutoImportScanComponents
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
initAutoImportScanComponents
()
process
.
UNI_AUTO_SCAN_COMPONENTS
=
!
(
pagesJsonObj
.
easycom
&&
pagesJsonObj
.
easycom
.
autoscan
===
false
)
initAutoImportComponents
(
pagesJsonObj
.
easycom
)
initAutoImportComponents
(
pagesJsonObj
.
easycom
)
if
(
process
.
UNI_AUTO_SCAN_COMPONENTS
)
{
initAutoImportScanComponents
()
}
runByHBuilderX
&&
console
.
log
(
`正在编译中...`
)
runByHBuilderX
&&
console
.
log
(
`正在编译中...`
)
...
...
packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.common.js
浏览文件 @
22ce471a
/*!
/*!
* vue-router v3.0.1
* vue-router v3.0.1
* (c) 20
19
Evan You
* (c) 20
20
Evan You
* @license MIT
* @license MIT
*/
*/
'
use strict
'
;
'
use strict
'
;
...
@@ -1325,7 +1325,6 @@ function normalizeLocation (
...
@@ -1325,7 +1325,6 @@ function normalizeLocation (
/* */
/* */
function
createMatcher
(
function
createMatcher
(
routes
,
routes
,
router
router
...
@@ -1495,7 +1494,7 @@ function createMatcher (
...
@@ -1495,7 +1494,7 @@ function createMatcher (
if
(
record
.
meta
.
id
)
{
if
(
record
.
meta
.
id
)
{
record
.
components
.
default
.
name
=
record
.
meta
.
name
+
'
-
'
+
location
.
params
.
__id__
;
record
.
components
.
default
.
name
=
record
.
meta
.
name
+
'
-
'
+
location
.
params
.
__id__
;
}
else
{
}
else
{
record
=
Object
.
assign
({},
record
);
record
=
extend
({},
record
);
record
.
components
=
{
record
.
components
=
{
'
default
'
:
{
'
default
'
:
{
name
:
record
.
meta
.
name
+
'
-
'
+
location
.
params
.
__id__
,
name
:
record
.
meta
.
name
+
'
-
'
+
location
.
params
.
__id__
,
...
...
packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.esm.js
浏览文件 @
22ce471a
/*!
/*!
* vue-router v3.0.1
* vue-router v3.0.1
* (c) 20
19
Evan You
* (c) 20
20
Evan You
* @license MIT
* @license MIT
*/
*/
/* */
/* */
...
@@ -1323,7 +1323,6 @@ function normalizeLocation (
...
@@ -1323,7 +1323,6 @@ function normalizeLocation (
/* */
/* */
function
createMatcher
(
function
createMatcher
(
routes
,
routes
,
router
router
...
@@ -1493,7 +1492,7 @@ function createMatcher (
...
@@ -1493,7 +1492,7 @@ function createMatcher (
if
(
record
.
meta
.
id
)
{
if
(
record
.
meta
.
id
)
{
record
.
components
.
default
.
name
=
record
.
meta
.
name
+
'
-
'
+
location
.
params
.
__id__
;
record
.
components
.
default
.
name
=
record
.
meta
.
name
+
'
-
'
+
location
.
params
.
__id__
;
}
else
{
}
else
{
record
=
Object
.
assign
({},
record
);
record
=
extend
({},
record
);
record
.
components
=
{
record
.
components
=
{
'
default
'
:
{
'
default
'
:
{
name
:
record
.
meta
.
name
+
'
-
'
+
location
.
params
.
__id__
,
name
:
record
.
meta
.
name
+
'
-
'
+
location
.
params
.
__id__
,
...
...
packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.js
浏览文件 @
22ce471a
/*!
/*!
* vue-router v3.0.1
* vue-router v3.0.1
* (c) 20
19
Evan You
* (c) 20
20
Evan You
* @license MIT
* @license MIT
*/
*/
(
function
(
global
,
factory
)
{
(
function
(
global
,
factory
)
{
...
@@ -1329,7 +1329,6 @@ function normalizeLocation (
...
@@ -1329,7 +1329,6 @@ function normalizeLocation (
/* */
/* */
function
createMatcher
(
function
createMatcher
(
routes
,
routes
,
router
router
...
@@ -1499,7 +1498,7 @@ function createMatcher (
...
@@ -1499,7 +1498,7 @@ function createMatcher (
if
(
record
.
meta
.
id
)
{
if
(
record
.
meta
.
id
)
{
record
.
components
.
default
.
name
=
record
.
meta
.
name
+
'
-
'
+
location
.
params
.
__id__
;
record
.
components
.
default
.
name
=
record
.
meta
.
name
+
'
-
'
+
location
.
params
.
__id__
;
}
else
{
}
else
{
record
=
Object
.
assign
({},
record
);
record
=
extend
({},
record
);
record
.
components
=
{
record
.
components
=
{
'
default
'
:
{
'
default
'
:
{
name
:
record
.
meta
.
name
+
'
-
'
+
location
.
params
.
__id__
,
name
:
record
.
meta
.
name
+
'
-
'
+
location
.
params
.
__id__
,
...
...
packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.min.js
浏览文件 @
22ce471a
此差异已折叠。
点击以展开。
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/plugin/index.js
浏览文件 @
22ce471a
...
@@ -13,7 +13,9 @@ class WebpackUniAppPlugin {
...
@@ -13,7 +13,9 @@ class WebpackUniAppPlugin {
compiler
.
hooks
.
invalid
.
tap
(
'
webpack-uni-app-invalid
'
,
(
fileName
,
changeTime
)
=>
{
compiler
.
hooks
.
invalid
.
tap
(
'
webpack-uni-app-invalid
'
,
(
fileName
,
changeTime
)
=>
{
if
(
fileName
&&
typeof
fileName
===
'
string
'
)
{
if
(
fileName
&&
typeof
fileName
===
'
string
'
)
{
if
(
fileName
.
indexOf
(
'
.vue
'
)
!==
-
1
||
fileName
.
indexOf
(
'
.nvue
'
)
!==
-
1
)
{
if
(
fileName
.
indexOf
(
'
.vue
'
)
!==
-
1
||
fileName
.
indexOf
(
'
.nvue
'
)
!==
-
1
)
{
initAutoImportScanComponents
()
if
(
process
.
UNI_AUTO_SCAN_COMPONENTS
)
{
initAutoImportScanComponents
()
}
}
}
}
}
})
})
...
...
packages/webpack-uni-pages-loader/lib/index-new.js
浏览文件 @
22ce471a
...
@@ -56,6 +56,7 @@ module.exports = function (content) {
...
@@ -56,6 +56,7 @@ module.exports = function (content) {
})
})
// 组件自动导入配置
// 组件自动导入配置
process
.
UNI_AUTO_SCAN_COMPONENTS
=
!
(
pagesJson
.
easycom
&&
pagesJson
.
easycom
.
autoscan
===
false
)
initAutoImportComponents
(
pagesJson
.
easycom
)
initAutoImportComponents
(
pagesJson
.
easycom
)
// TODO 与 usingComponents 放在一块读取设置
// TODO 与 usingComponents 放在一块读取设置
...
@@ -128,4 +129,4 @@ module.exports = function (content) {
...
@@ -128,4 +129,4 @@ module.exports = function (content) {
}
}
return
''
return
''
}
}
src/core/helpers/hidpi.js
浏览文件 @
22ce471a
...
@@ -36,9 +36,9 @@ const ratioArgs = {
...
@@ -36,9 +36,9 @@ const ratioArgs = {
'
createLinearGradient
'
:
'
all
'
,
'
createLinearGradient
'
:
'
all
'
,
'
setTransform
'
:
[
4
,
5
]
'
setTransform
'
:
[
4
,
5
]
}
}
if
(
pixelRatio
!==
1
)
{
const
proto
=
CanvasRenderingContext2D
.
prototype
const
proto
=
CanvasRenderingContext2D
.
prototype
if
(
pixelRatio
!==
1
)
{
forEach
(
ratioArgs
,
function
(
value
,
key
)
{
forEach
(
ratioArgs
,
function
(
value
,
key
)
{
proto
[
key
]
=
(
function
(
_super
)
{
proto
[
key
]
=
(
function
(
_super
)
{
return
function
()
{
return
function
()
{
...
@@ -129,23 +129,6 @@ if (pixelRatio !== 1) {
...
@@ -129,23 +129,6 @@ if (pixelRatio !== 1) {
}
}
})(
proto
.
strokeText
)
})(
proto
.
strokeText
)
proto
.
drawImageByCanvas
=
(
function
(
_super
)
{
return
function
(
canvas
,
srcx
,
srcy
,
srcw
,
srch
,
desx
,
desy
,
desw
,
desh
,
isScale
)
{
if
(
!
this
.
__hidpi__
)
{
return
_super
.
apply
(
this
,
arguments
)
}
srcx
*=
pixelRatio
srcy
*=
pixelRatio
srcw
*=
pixelRatio
srch
*=
pixelRatio
desx
*=
pixelRatio
desy
*=
pixelRatio
desw
=
isScale
?
desw
*
pixelRatio
:
desw
desh
=
isScale
?
desh
*
pixelRatio
:
desh
_super
.
call
(
this
,
canvas
,
srcx
,
srcy
,
srcw
,
srch
,
desx
,
desy
,
desw
,
desh
)
}
})(
proto
.
drawImage
)
proto
.
drawImage
=
(
function
(
_super
)
{
proto
.
drawImage
=
(
function
(
_super
)
{
return
function
()
{
return
function
()
{
if
(
!
this
.
__hidpi__
)
{
if
(
!
this
.
__hidpi__
)
{
...
@@ -158,6 +141,23 @@ if (pixelRatio !== 1) {
...
@@ -158,6 +141,23 @@ if (pixelRatio !== 1) {
})(
proto
.
drawImage
)
})(
proto
.
drawImage
)
}
}
proto
.
drawImageByCanvas
=
(
function
(
_super
)
{
return
function
(
canvas
,
srcx
,
srcy
,
srcw
,
srch
,
desx
,
desy
,
desw
,
desh
,
isScale
)
{
if
(
!
this
.
__hidpi__
)
{
return
_super
.
apply
(
this
,
arguments
)
}
srcx
*=
pixelRatio
srcy
*=
pixelRatio
srcw
*=
pixelRatio
srch
*=
pixelRatio
desx
*=
pixelRatio
desy
*=
pixelRatio
desw
=
isScale
?
desw
*
pixelRatio
:
desw
desh
=
isScale
?
desh
*
pixelRatio
:
desh
_super
.
call
(
this
,
canvas
,
srcx
,
srcy
,
srcw
,
srch
,
desx
,
desy
,
desw
,
desh
)
}
})(
proto
.
drawImage
)
export
function
wrapper
(
canvas
)
{
export
function
wrapper
(
canvas
)
{
canvas
.
width
=
canvas
.
offsetWidth
*
pixelRatio
canvas
.
width
=
canvas
.
offsetWidth
*
pixelRatio
canvas
.
height
=
canvas
.
offsetHeight
*
pixelRatio
canvas
.
height
=
canvas
.
offsetHeight
*
pixelRatio
...
...
src/core/service/api/context/audio.js
浏览文件 @
22ce471a
...
@@ -9,14 +9,14 @@ const eventNames = [
...
@@ -9,14 +9,14 @@ const eventNames = [
'
pause
'
,
'
pause
'
,
'
stop
'
,
'
stop
'
,
'
ended
'
,
'
ended
'
,
'
time
u
pdate
'
,
'
time
U
pdate
'
,
'
error
'
,
'
error
'
,
'
waiting
'
,
'
waiting
'
,
'
seeking
'
,
'
seeking
'
,
'
seeked
'
'
seeked
'
]
]
const
props
=
[
const
props
=
[
{
{
name
:
'
src
'
,
name
:
'
src
'
,
cache
:
true
cache
:
true
...
@@ -69,7 +69,7 @@ class InnerAudioContext {
...
@@ -69,7 +69,7 @@ class InnerAudioContext {
this
.
_callbacks
=
{}
this
.
_callbacks
=
{}
this
.
_options
=
{}
this
.
_options
=
{}
eventNames
.
forEach
(
name
=>
{
eventNames
.
forEach
(
name
=>
{
this
.
_callbacks
[
name
]
=
[]
this
.
_callbacks
[
name
.
toLowerCase
()
]
=
[]
})
})
props
.
forEach
(
item
=>
{
props
.
forEach
(
item
=>
{
const
name
=
item
.
name
const
name
=
item
.
name
...
@@ -103,11 +103,12 @@ class InnerAudioContext {
...
@@ -103,11 +103,12 @@ class InnerAudioContext {
this
.
_operate
(
'
stop
'
)
this
.
_operate
(
'
stop
'
)
}
}
seek
(
position
)
{
seek
(
position
)
{
this
.
_operate
(
'
play
'
,
{
this
.
_operate
(
'
seek
'
,
{
currentTime
:
position
currentTime
:
position
*
1
e3
})
})
}
}
destroy
()
{
destroy
()
{
clearInterval
(
this
.
__timing
)
invokeMethod
(
'
destroyAudioInstance
'
,
{
invokeMethod
(
'
destroyAudioInstance
'
,
{
audioId
:
this
.
id
audioId
:
this
.
id
})
})
...
@@ -123,6 +124,7 @@ class InnerAudioContext {
...
@@ -123,6 +124,7 @@ class InnerAudioContext {
eventNames
.
forEach
(
item
=>
{
eventNames
.
forEach
(
item
=>
{
const
name
=
item
[
0
].
toUpperCase
()
+
item
.
substr
(
1
)
const
name
=
item
[
0
].
toUpperCase
()
+
item
.
substr
(
1
)
item
=
item
.
toLowerCase
()
InnerAudioContext
.
prototype
[
`on
${
name
}
`
]
=
function
(
callback
)
{
InnerAudioContext
.
prototype
[
`on
${
name
}
`
]
=
function
(
callback
)
{
this
.
_callbacks
[
item
].
push
(
callback
)
this
.
_callbacks
[
item
].
push
(
callback
)
}
}
...
@@ -135,6 +137,17 @@ eventNames.forEach(item => {
...
@@ -135,6 +137,17 @@ eventNames.forEach(item => {
}
}
})
})
function
emit
(
audio
,
state
,
errMsg
,
errCode
)
{
audio
.
_callbacks
[
state
].
forEach
(
callback
=>
{
if
(
typeof
callback
===
'
function
'
)
{
callback
(
state
===
'
error
'
?
{
errMsg
,
errCode
}
:
{})
}
})
}
onMethod
(
'
onAudioStateChange
'
,
({
onMethod
(
'
onAudioStateChange
'
,
({
state
,
state
,
audioId
,
audioId
,
...
@@ -142,14 +155,20 @@ onMethod('onAudioStateChange', ({
...
@@ -142,14 +155,20 @@ onMethod('onAudioStateChange', ({
errCode
errCode
})
=>
{
})
=>
{
const
audio
=
innerAudioContexts
[
audioId
]
const
audio
=
innerAudioContexts
[
audioId
]
audio
&&
audio
.
_callbacks
[
state
].
forEach
(
callback
=>
{
if
(
audio
)
{
if
(
typeof
callback
===
'
function
'
)
{
emit
(
audio
,
state
,
errMsg
,
errCode
)
callback
(
state
===
'
error
'
?
{
if
(
state
===
'
play
'
)
{
errMsg
,
const
oldCurrentTime
=
audio
.
currentTime
errCode
audio
.
__timing
=
setInterval
(()
=>
{
}
:
{})
const
currentTime
=
audio
.
currentTime
if
(
currentTime
!==
oldCurrentTime
)
{
emit
(
audio
,
'
timeupdate
'
)
}
},
200
)
}
else
if
(
state
===
'
pause
'
||
state
===
'
stop
'
||
state
===
'
error
'
)
{
clearInterval
(
audio
.
__timing
)
}
}
}
)
}
})
})
const
innerAudioContexts
=
Object
.
create
(
null
)
const
innerAudioContexts
=
Object
.
create
(
null
)
...
@@ -161,4 +180,4 @@ export function createInnerAudioContext () {
...
@@ -161,4 +180,4 @@ export function createInnerAudioContext () {
const
innerAudioContext
=
new
InnerAudioContext
(
audioId
)
const
innerAudioContext
=
new
InnerAudioContext
(
audioId
)
innerAudioContexts
[
audioId
]
=
innerAudioContext
innerAudioContexts
[
audioId
]
=
innerAudioContext
return
innerAudioContext
return
innerAudioContext
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录