mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-19 03:11:20 -08:00
Refactor artplayerPluginLibass to use ES6 syntax
This commit is contained in:
1 parent
4360c1e695
commit
b2bffa8079
4 files changed
+11
-113
No files matched your search
@@ -1,25 +1,8 @@
|
||||
import LibassAdapter from './adapter'
|
||||
|
||||
function checkVersion(art) {
|
||||
const {
|
||||
version,
|
||||
utils: { errorHandle },
|
||||
} = art.constructor
|
||||
const arr = version.split('.').map(Number)
|
||||
const major = arr[0]
|
||||
const minor = arr[1] / 100
|
||||
errorHandle(
|
||||
major + minor >= 5,
|
||||
`Artplayer.js@${version} is not compatible the artplayerPluginLibass@${artplayerPluginLibass.version}. Please update it to version Artplayer.js@5.x.x`,
|
||||
)
|
||||
}
|
||||
import LibassAdapter from './adapter';
|
||||
|
||||
export default function artplayerPluginLibass(option) {
|
||||
return (art) => {
|
||||
checkVersion(art)
|
||||
|
||||
let adapter = new LibassAdapter(art, option)
|
||||
|
||||
const adapter = new LibassAdapter(art, option);
|
||||
return {
|
||||
name: 'artplayerPluginLibass',
|
||||
libass: adapter.libass,
|
||||
@@ -29,14 +12,10 @@ export default function artplayerPluginLibass(option) {
|
||||
show: adapter.show.bind(adapter),
|
||||
hide: adapter.hide.bind(adapter),
|
||||
destroy: adapter.destroy.bind(adapter),
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
artplayerPluginLibass.env = process.env.NODE_ENV
|
||||
artplayerPluginLibass.version = process.env.APP_VER
|
||||
artplayerPluginLibass.build = process.env.BUILD_DATE
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window['artplayerPluginLibass'] = artplayerPluginLibass
|
||||
window['artplayerPluginLibass'] = artplayerPluginLibass;
|
||||
}
|
||||
Reference in new issue
Block a user