refactor: lint format

This commit is contained in:
digua
2026-04-13 21:57:34 +08:00
parent c69dcdffbb
commit 2b3f1fc04f
19 changed files with 547 additions and 517 deletions
+3 -6
View File
@@ -72,12 +72,9 @@ export function registerNlpHandlers(_ctx: IpcContext): void {
return isDictDownloaded(dictId)
})
ipcMain.handle(
'nlp:downloadDict',
async (_event, dictId: string): Promise<{ success: boolean; error?: string }> => {
return downloadDict(dictId)
}
)
ipcMain.handle('nlp:downloadDict', async (_event, dictId: string): Promise<{ success: boolean; error?: string }> => {
return downloadDict(dictId)
})
ipcMain.handle('nlp:deleteDict', async (_event, dictId: string): Promise<{ success: boolean; error?: string }> => {
return deleteDict(dictId)
+8 -2
View File
@@ -108,13 +108,19 @@ export async function downloadDict(
if (buffer.length < MIN_DICT_SIZE) {
const preview = buffer.subarray(0, 200).toString('utf-8')
console.error(`[NLP DictManager] Downloaded file too small (${buffer.length} bytes), preview: ${preview}`)
return { success: false, error: `Downloaded file is invalid (${buffer.length} bytes). The dictionary URL may not be available yet.` }
return {
success: false,
error: `Downloaded file is invalid (${buffer.length} bytes). The dictionary URL may not be available yet.`,
}
}
const head = buffer.subarray(0, 50).toString('utf-8').trim()
if (head.startsWith('<!') || head.startsWith('<html')) {
console.error(`[NLP DictManager] Downloaded file appears to be HTML, not a dict file`)
return { success: false, error: 'Downloaded file is HTML, not a dictionary file. The URL may not be deployed yet.' }
return {
success: false,
error: 'Downloaded file is HTML, not a dictionary file. The URL may not be deployed yet.',
}
}
fs.writeFileSync(tmpPath, buffer)
+10 -1
View File
@@ -385,7 +385,16 @@ export function batchSegmentWithFrequency(
locale: SupportedLocale,
options: BatchSegmentOptions = {}
): BatchSegmentResult {
const { minLength, minCount = 2, topN = 100, posFilterMode, customPosTags, enableStopwords, dictType, excludeWords } = options
const {
minLength,
minCount = 2,
topN = 100,
posFilterMode,
customPosTags,
enableStopwords,
dictType,
excludeWords,
} = options
const wordFrequency = new Map<string, number>()
const excludeSet = excludeWords?.length ? new Set(excludeWords.map((w) => w.toLowerCase())) : null
+1 -3
View File
@@ -226,9 +226,7 @@ export const chatApi = {
/**
* 获取支持的格式列表
*/
getSupportedFormats: (): Promise<
Array<{ id: string; name: string; platform: string; extensions: string[] }>
> => {
getSupportedFormats: (): Promise<Array<{ id: string; name: string; platform: string; extensions: string[] }>> => {
return ipcRenderer.invoke('chat:getSupportedFormats')
},
+3 -1
View File
@@ -110,7 +110,9 @@ export const nlpApi = {
return ipcRenderer.invoke('nlp:getPosTags')
},
getDictList: (): Promise<Array<{ id: string; label: string; locale: string; downloaded: boolean; fileSize?: number }>> => {
getDictList: (): Promise<
Array<{ id: string; label: string; locale: string; downloaded: boolean; fileSize?: number }>
> => {
return ipcRenderer.invoke('nlp:getDictList')
},