77
88import BaseDatabase from "./common/base-database"
99import { REMAIN_WORD_PREFIX } from "./common/constant"
10+ import { BrowserMigratable } from './types'
1011
1112const KEY = REMAIN_WORD_PREFIX + 'CATE'
1213
@@ -38,7 +39,9 @@ function migrate(exist: Items, toMigrate: any) {
3839 *
3940 * @since 3.0.0
4041 */
41- class SiteCateDatabase extends BaseDatabase {
42+ class SiteCateDatabase extends BaseDatabase implements BrowserMigratable < '__cate__' > {
43+ namespace : '__cate__' = '__cate__'
44+
4245 private async getItems ( ) : Promise < Items > {
4346 return await this . storage . getOne < Items > ( KEY ) || { }
4447 }
@@ -86,14 +89,6 @@ class SiteCateDatabase extends BaseDatabase {
8689 await this . saveItems ( items )
8790 }
8891
89- async importData ( data : any ) : Promise < void > {
90- let toImport = data [ KEY ] as Items
91- // Not import
92- if ( typeof toImport !== 'object' ) return
93- const exists : Items = await this . getItems ( )
94- migrate ( exists , toImport )
95- this . setByKey ( KEY , exists )
96- }
9792
9893 async delete ( id : number ) : Promise < void > {
9994 const items = await this . getItems ( )
@@ -102,6 +97,20 @@ class SiteCateDatabase extends BaseDatabase {
10297 delete items [ id ]
10398 await this . saveItems ( items )
10499 }
100+
101+ async importData ( data : unknown ) : Promise < void > {
102+ // let toImport = data[KEY] as Items
103+ // // Not import
104+ // if (typeof toImport !== 'object') return
105+ // const exists: Items = await this.getItems()
106+ // migrate(exists, toImport)
107+ // this.setByKey(KEY, exists)
108+ throw new Error ( 'Method not implemented.' )
109+ }
110+
111+ exportData ( ) : Promise < timer . site . Cate [ ] > {
112+ throw new Error ( 'Method not implemented.' )
113+ }
105114}
106115
107116const siteCateDatabase = new SiteCateDatabase ( )
0 commit comments