优化整体结构

This commit is contained in:
Harvey Zack committed 2019-04-30 13:06:24 +08:00
1 parent 9f9cb0e036
commit 487e865017
34 files changed
+505 -427

No files matched your search

+7 -3
View File
@@ -1,7 +1,7 @@
export default class Storage {
constructor(art) {
this.art = art;
this.storageName = 'artplayer_settings';
this.name = 'artplayer_settings';
this.init();
}
@@ -14,7 +14,7 @@ export default class Storage {
}
get(key) {
const storage = JSON.parse(localStorage.getItem(this.storageName)) || {};
const storage = JSON.parse(window.localStorage.getItem(this.name)) || {};
return key ? storage[key] : {};
}
@@ -22,6 +22,10 @@ export default class Storage {
const storage = Object.assign({}, this.get(), {
[key]: value,
});
localStorage.setItem(this.storageName, JSON.stringify(storage));
window.localStorage.setItem(this.name, JSON.stringify(storage));
}
clean() {
window.localStorage.removeItem(this.name);
}
}