File tree Expand file tree Collapse file tree 4 files changed +19
-5
lines changed Expand file tree Collapse file tree 4 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 1111
1212![ Instructions.gif] ( https://s1.ax1x.com/2020/08/19/dQ8R3t.gif )
1313
14+ ### v1.4.0
15+
16+ - 优化导入数据
17+
1418### v1.3.9
1519
1620- 我的自选基金新增支持s前缀搜索过滤自选基金,如s001071
Original file line number Diff line number Diff line change 11{
22 "name" : " utools-fund" ,
3- "version" : " v1.3.9 " ,
3+ "version" : " v1.4.0 " ,
44 "description" : " 自选基金助手" ,
55 "main" : " main.ts" ,
66 "scripts" : {
2525 "dependencies" : {
2626 "axios" : " ^0.19.2"
2727 }
28- }
28+ }
Original file line number Diff line number Diff line change @@ -5,18 +5,28 @@ const FUND_DB_PRE_FIX = 'fund_';
55
66export default class FundDBHelper {
77 static set ( data : IFundEnt ) {
8- return utools . db . put ( {
8+ const db : DBItem < IFundEnt > = {
99 _id : `${ FUND_DB_PRE_FIX } ${ data . id } ` ,
1010 data,
11- } ) ;
11+ } ;
12+ const existDB = FundDBHelper . get ( data . id ) ;
13+ if ( existDB ) {
14+ db . _rev = existDB . _rev ;
15+ }
16+ return utools . db . put ( db ) ;
1217 }
1318
1419 static setList ( data : IFundEnt [ ] ) {
20+ const existDBList = FundDBHelper . getAll ( ) ;
1521 const dbList = data . map ( x => {
1622 const db : DBItem < IFundEnt > = {
1723 _id : `${ FUND_DB_PRE_FIX } ${ x . id } ` ,
1824 data : x ,
1925 } ;
26+ const existDB = existDBList . find ( d => d . data . id === x . id ) ;
27+ if ( existDB ) {
28+ db . _rev = existDB . _rev ;
29+ }
2030 return db ;
2131 } ) ;
2232 return utools . db . bulkDocs ( dbList ) ;
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ const fundImport: TplFeature = {
1111 enter : async ( action , callbackSetList ) => {
1212 if ( action . type === 'files' ) {
1313 const jsonFile : FilesPayload = action . payload [ 0 ] ;
14- if ( jsonFile . isFile && jsonFile . name === 'fund_data.json' ) {
14+ if ( jsonFile . isFile && jsonFile . name . includes ( 'fund_data.json' ) ) {
1515 const fundJsonStr = readFileSync ( jsonFile . path , { encoding : 'utf-8' } ) ;
1616 const fundData : IFundEnt [ ] = JSON . parse ( fundJsonStr ) ;
1717 FundDBHelper . setList ( fundData ) ;
You can’t perform that action at this time.
0 commit comments