@@ -13,7 +13,6 @@ export class DataStore {
1313
1414 get appDataPath ( ) {
1515 const appDataPath = getAppDataPath ( 'vs-piclist' )
16- console . log ( 'appDataPath' , appDataPath )
1716 fs . ensureDirSync ( appDataPath )
1817 return appDataPath
1918 }
@@ -25,7 +24,6 @@ export class DataStore {
2524 static writeUploadedFileDB ( data : IStringKeyObject [ ] ) {
2625 try {
2726 const originData = DataStore . readUploadedFileDB ( ) || [ ]
28- console . log ( 'data' , data )
2927 const newData = [ ...originData , ...data ]
3028 fs . writeJSONSync ( DataStore . dataStore . conUploadedFileDBPath , newData )
3129 } catch ( error ) {
@@ -43,15 +41,26 @@ export class DataStore {
4341 }
4442 }
4543
46- static searchUploadedFileDB ( url : string ) : IStringKeyObject {
44+ static searchUploadedFileDB ( urls : string [ ] ) : IStringKeyObject [ ] {
4745 const data = DataStore . readUploadedFileDB ( )
48- const res = data . find ( item => item . imgUrl === url || decodeURI ( item . imgUrl ) === url ) || { }
46+ const res = [ ] as IStringKeyObject [ ]
47+ for ( const url of urls ) {
48+ const item = data . find ( item => item . imgUrl === url || decodeURI ( item . imgUrl ) === url )
49+ if ( item ) {
50+ res . push ( item )
51+ }
52+ }
4953 return res
5054 }
5155
52- static removeUploadedFileDBItem ( item : IStringKeyObject ) {
56+ static removeUploadedFileDBItem ( items : IStringKeyObject [ ] ) {
5357 const data = DataStore . readUploadedFileDB ( )
54- const newData = data . filter ( ( i : IStringKeyObject ) => i . id !== item . id )
55- fs . writeJSONSync ( DataStore . dataStore . conUploadedFileDBPath , newData )
58+ for ( const item of items ) {
59+ const index = data . findIndex ( ( i : IStringKeyObject ) => i . id === item . id )
60+ if ( index !== - 1 ) {
61+ data . splice ( index , 1 )
62+ }
63+ }
64+ fs . writeJSONSync ( DataStore . dataStore . conUploadedFileDBPath , data )
5665 }
5766}
0 commit comments