File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' openapi-ts-request ' : patch
3+ ---
4+
5+ fix: fix bug #644
Original file line number Diff line number Diff line change @@ -326,9 +326,23 @@ export async function translateChineseModuleNodeToEnglish(
326326 } ) ;
327327 } ) ;
328328 resolve ( translateMap ) ;
329+
330+ // 在写入前再次读取缓存,合并多个任务的翻译结果
331+ const existingContent = readFileSafelySync (
332+ process . cwd ( ) + '/openapi-ts-request.cache.json'
333+ ) ;
334+ let existingCache : Record < string , string > = { } ;
335+
336+ if ( existingContent !== null && isJSONString ( existingContent ) ) {
337+ existingCache = JSON . parse ( existingContent ) as Record < string , string > ;
338+ }
339+
340+ // 合并现有缓存和新的翻译结果(新结果优先)
341+ const mergedCache = { ...existingCache , ...translateMap } ;
342+
329343 void writeFileAsync (
330344 process . cwd ( ) + '/openapi-ts-request.cache.json' ,
331- JSON . stringify ( translateMap , null , 2 )
345+ JSON . stringify ( mergedCache , null , 2 )
332346 ) ;
333347 } )
334348 . catch ( ( ) => {
You can’t perform that action at this time.
0 commit comments