mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 00:31:20 -08:00
格式化
This commit is contained in:
1 parent
0454f785be
commit
203ad0d3a0
75 files changed
+3120
-2904
No files matched your search
@@ -1,31 +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 key ? 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;
|
||||
constructor(art) {
|
||||
this.art = art;
|
||||
this.storageName = 'artplayer_settings';
|
||||
sleep().then(() => {
|
||||
this.initVolume();
|
||||
});
|
||||
}
|
||||
|
||||
get(key) {
|
||||
const storage = JSON.parse(localStorage.getItem(this.storageName)) || {};
|
||||
return key ? 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