mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-29 11:11:20 -08:00
分离事件中心
This commit is contained in:
1 parent
b5694fea89
commit
1d40d1c46b
31 files changed
+728
-403
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { sleep } from './utils';
|
||||
|
||||
export default class Storage {
|
||||
constructor(art) {
|
||||
this.art = art;
|
||||
this.storageName = 'artplayer_settings';
|
||||
sleep().then(() => {
|
||||
this.initVolume();
|
||||
});
|
||||
}
|
||||
|
||||
get(key) {
|
||||
const storage = JSON.parse(localStorage.getItem(this.storageName));
|
||||
return storage[key];
|
||||
}
|
||||
|
||||
set(key, value) {
|
||||
const storage = Object.assign({}, this.get() || {}, {
|
||||
[key]: value
|
||||
});
|
||||
localStorage.setItem(this.storageName, JSON.stringify(storage));
|
||||
}
|
||||
|
||||
initVolume() {
|
||||
const { player } = this.art;
|
||||
const volume = this.get('volume');
|
||||
if (volume) {
|
||||
player.volume = volume;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user