tisfeng / Easydict

一个简洁优雅的词典翻译 macOS App。开箱即用,支持离线 OCR 识别,支持有道词典,🍎 苹果系统词典,🍎 苹果系统翻译,OpenAI,Gemini,DeepL,Google,Bing,腾讯,百度,阿里,小牛,彩云和火山翻译。A concise and elegant Dictionary and Translator macOS App for looking up words and translating text.
GNU General Public License v3.0
6.38k stars 324 forks source link

perf: throttle the stream completion to update UI #548

Closed tisfeng closed 1 month ago

tisfeng commented 1 month ago

Fix https://github.com/tisfeng/Easydict/issues/541

When I designed this app, I didn't realize that there would be a stream service like OpenAI behind it, and its frequent refreshing of the TableView would lead to high CUP usage and even UI lagging, so I added a Throttler to limit the frequency of refreshing.

While this approach doesn't fundamentally solve the problem, it can greatly alleviate it.

Before we rewrote the query window using SwiftUI, this would be a temporary solution.