refactor: 用LocalStorageService代理localStorage

This commit is contained in:
禾几海
2021-03-16 20:38:42 +08:00
parent a2e80e6fdd
commit 2ba3d4ca1b
5 changed files with 36 additions and 18 deletions

View File

@@ -39,6 +39,18 @@ export class LocalStorageService {
return this.getToken() != null;
}
setItem(key: string, value: any) {
localStorage.setItem(key, JSON.stringify(value));
}
getItem(key: string) {
return localStorage.getItem(key);
}
removeItem(key: string) {
localStorage.removeItem(key);
}
// setUser(user: User) {
// // TODO: 简单加个密
// localStorage.setItem('t', new Date().valueOf().toString());