mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-12 02:35:42 +00:00
Initial commit
This commit is contained in:
19
assets/js/hooks/localStorageSetting.ts
Normal file
19
assets/js/hooks/localStorageSetting.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export default {
|
||||
key(): string {
|
||||
return this.el.dataset.key;
|
||||
},
|
||||
|
||||
getItem(key: string) {
|
||||
return localStorage.getItem(key);
|
||||
},
|
||||
|
||||
setItem(key: string, value: string) {
|
||||
return localStorage.setItem(key, value);
|
||||
},
|
||||
|
||||
mounted() {
|
||||
const key = this.key();
|
||||
this.pushEvent(`ls_restore_${key}`, { value: this.getItem(key) });
|
||||
this.handleEvent(`ls_update_${key}`, ({ value }) => this.setItem(key, value));
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user