import { CookieService } from '@delon/util/browser' ; import { ITokenModel } from '../token/interface' ; import { IStore } from './interface' ; /**
 * `cookie` storage
 *
 * ```ts
 * // global-config.module.ts
 * { provide: DA_STORE_TOKEN, useClass: CookieStorageStore, deps: [CookieService] }
 * ```
 */ export class CookieStorageStore implements IStore { constructor ( private srv ) { } get ( key ) { return JSON . parse ( this . srv . get ( key ) || '{}' ) || { } ; } set ( key , value ) { this . srv . put ( key , value != null ? JSON . stringify ( value ) : '{}' ) ; return true ; } remove ( key ) { this . srv . remove ( key ) ; } }