优化类型检测

This commit is contained in:
Harvey committed 2020-05-19 14:23:29 +08:00
1 parent 3e609bb153
commit 9760d6268f
6 files changed
+168 -342

No files matched your search

+1 -1
View File
@@ -132,8 +132,8 @@ export default class Artplayer extends Emitter {
networkMonitor: false,
layers: [],
contextmenu: [],
quality: [],
controls: [],
quality: [],
highlight: [],
plugins: [],
whitelist: [],
+22 -40
View File
@@ -7,6 +7,17 @@ function validElement(value, type, paths) {
);
}
const component = {
html: validElement,
disable: 'boolean|undefined',
name: 'string|undefined',
index: 'number|undefined',
style: 'object|undefined',
click: 'function|undefined',
mounted: 'function|undefined',
tooltip: 'string|undefined',
};
export default {
container: validElement,
url: 'string',
@@ -40,28 +51,18 @@ export default {
networkMonitor: 'boolean',
plugins: ['function'],
whitelist: ['string|function|regexp'],
layers: [
layers: [component],
contextmenu: [component],
controls: [
{
disable: 'boolean|undefined',
name: 'string|undefined',
index: 'number|undefined',
html: validElement,
style: 'object|undefined',
click: 'function|undefined',
mounted: 'function|undefined',
tooltip: 'string|undefined',
},
],
contextmenu: [
{
disable: 'boolean|undefined',
name: 'string|undefined',
index: 'number|undefined',
html: validElement,
style: 'object|undefined',
click: 'function|undefined',
mounted: 'function|undefined',
tooltip: 'string|undefined',
...component,
position: (value, type, paths) => {
const position = ['top', 'left', 'right'];
return errorHandle(
position.includes(value),
`${paths.join('.')} only accept ${position.toString()} as parameters, but got ${type}`,
);
},
},
],
quality: [
@@ -71,25 +72,6 @@ export default {
url: 'string',
},
],
controls: [
{
disable: 'boolean|undefined',
name: 'string|undefined',
index: 'number|undefined',
html: validElement,
style: 'object|undefined',
click: 'function|undefined',
mounted: 'function|undefined',
tooltip: 'string|undefined',
position: (value, type, paths) => {
const position = ['top', 'left', 'right'];
return errorHandle(
position.includes(value),
`${paths.join('.')} only accept ${position.toString()} as parameters`,
);
},
},
],
highlight: [
{
time: 'number',