mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-24 14:41:20 -08:00
压缩
This commit is contained in:
1 parent
bb92f3dc3d
commit
6a9863ad99
4 files changed
+14
-32
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { errorHandle, has } from '../utils';
|
||||
import { errorHandle, has, def } from '../utils';
|
||||
import subtitleOffset from './subtitleOffset';
|
||||
import localVideo from './localVideo';
|
||||
import localSubtitle from './localSubtitle';
|
||||
@@ -40,19 +40,9 @@ export default class Plugins {
|
||||
add(plugin) {
|
||||
this.id += 1;
|
||||
const result = plugin.call(this, this.art);
|
||||
let pluginName = '';
|
||||
if (result && result.name) {
|
||||
pluginName = result.name;
|
||||
} else if (plugin.name) {
|
||||
pluginName = plugin.name;
|
||||
} else {
|
||||
pluginName = `plugin${this.id}`;
|
||||
}
|
||||
errorHandle(
|
||||
!has(this, pluginName),
|
||||
`Cannot add a plugin that already has the same name: ${pluginName}`,
|
||||
);
|
||||
Object.defineProperty(this, pluginName, {
|
||||
const pluginName = (result && result.name) || plugin.name || `plugin${this.id}`;
|
||||
errorHandle(!has(this, pluginName), `Cannot add a plugin that already has the same name: ${pluginName}`);
|
||||
def(this, pluginName, {
|
||||
value: result,
|
||||
});
|
||||
this.art.emit('plugin:add', plugin);
|
||||
|
||||
Reference in new issue
Block a user