1
- import { boolToString , randNumber , toBool } from "./utils" ;
2
- import { Application } from "../application" ;
3
- import { SystemConfig } from "@App/config" ;
1
+ import { boolToString , randNumber , toBool } from "./utils" ;
2
+ import { Application } from "../application" ;
3
+ import { SystemConfig } from "@App/config" ;
4
4
5
5
export interface ConfigItems extends Config {
6
6
SetNamespace ( namespace : string ) : void
@@ -222,7 +222,7 @@ class backendConfig implements Config {
222
222
// 更新配置转为json,存入
223
223
protected updateConfigStorage ( ) {
224
224
let txt = JSON . stringify ( this . cache ) ;
225
- chrome . storage . sync . set ( { "config_storage" : txt } ) ;
225
+ chrome . storage . sync . set ( { "config_storage" : txt } ) ;
226
226
}
227
227
228
228
// 更新缓存
@@ -240,7 +240,7 @@ class backendConfig implements Config {
240
240
}
241
241
} ) ;
242
242
this . updateConfigStorage ( ) ;
243
- resolve ( ) ;
243
+ resolve ( undefined ) ;
244
244
} ) ;
245
245
} ) ;
246
246
}
@@ -263,12 +263,12 @@ class backendConfig implements Config {
263
263
info [ key ] = val ;
264
264
//通知前端和后端
265
265
this . cache [ key ] = val ;
266
- chrome . tabs . query ( { active : true , currentWindow : true } , function ( tabs ) {
267
- chrome . tabs . sendMessage ( tabs [ 0 ] . id , { type : "cxconfig" , key : key , value : val } ) ;
266
+ chrome . tabs . query ( { active : true , currentWindow : true } , function ( tabs ) {
267
+ chrome . tabs . sendMessage ( tabs [ 0 ] . id , { type : "cxconfig" , key : key , value : val } ) ;
268
268
} ) ;
269
- chrome . runtime . sendMessage ( { type : "cxconfig" , key : key , value : val } ) ;
269
+ chrome . runtime . sendMessage ( { type : "cxconfig" , key : key , value : val } ) ;
270
270
this . updateConfigStorage ( ) ;
271
- resolve ( ) ;
271
+ resolve ( undefined ) ;
272
272
} ) ;
273
273
}
274
274
@@ -295,7 +295,7 @@ class frontendGetConfig implements Config {
295
295
296
296
constructor ( ) {
297
297
this . watch = new configWatch ( ) ;
298
- this . cache = ( < any > window ) . configData ;
298
+ this . cache = ( < any > window ) . configData || localStorage ;
299
299
window . addEventListener ( 'message' , ( event ) => {
300
300
if ( event . data . type && event . data . type == "cxconfig" ) {
301
301
Application . App . log . Info ( "配置更新:" + event . data . key + "=" + event . data . value ) ;
@@ -322,7 +322,7 @@ class frontendGetConfig implements Config {
322
322
return ( < any > window ) . GM_setValue ( key , val ) ;
323
323
}
324
324
return Application . App . Client . Send ( {
325
- type : "GM_setValue" , details : { key : key , val : val } ,
325
+ type : "GM_setValue" , details : { key : key , val : val } ,
326
326
} ) ;
327
327
}
328
328
0 commit comments