Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 19, 2025

Implements vocabulary notebook functionality: user-initiated favorites and automatic query history, both accessible via Settings tabs.

Architecture

Data Layer

  • QueryRecord: Codable model storing query text, language pair, and timestamp
  • FavoritesManager / HistoryManager: Singleton managers with UserDefaults persistence via Defaults library
  • History capped at 1,000 entries, deduplicated on insert

UI Components

  • FavoritesTab / HistoryTab: SwiftUI list views with swipe-to-delete and bulk clear
  • Click-to-requery: triggers EZWindowManager.showMainWindowIfNeeded()startQueryText()
  • Favorite button in titlebar: star icon (filled/outline) next to pin button

Integration Points

  • History tracking: injected into EZBaseQueryViewController.queryAllSerives: after query execution
  • Favorite toggle: EZTitlebar observes NSNotification.serviceHasUpdated to refresh button state
  • Exposed queryModel as readonly property on EZBaseQueryViewController for titlebar access

Example Usage

// Auto-tracking in query flow
- (void)queryAllSerives:(EZQueryModel *)queryModel {
    // ... existing query logic ...
    [HistoryManager.shared addHistoryWithQueryText:queryModel.queryText
                                      fromLanguage:queryModel.queryFromLanguage
                                        toLanguage:queryModel.queryTargetLanguage];
}

// Toggle favorite from titlebar
- (void)toggleFavorite {
    BOOL isFavorited = [FavoritesManager.shared isFavoritedWithQueryText:queryText];
    if (isFavorited) {
        [FavoritesManager.shared removeFavoriteWithId:record.id];
    } else {
        [FavoritesManager.shared addFavoriteWithQueryText:queryText ...];
    }
}

Localized for en, zh-Hans, zh-Hant. All new files added to Xcode project configuration.

Original prompt

This section details on the original issue you should resolve

<issue_title>🚀 功能建议:建议新增类似生词本的功能</issue_title>
<issue_description>### 请先确认以下事项

  • 已仔细阅读了 README
  • issues 页面搜索过,未发现类似功能建议
  • Easydict 已升级到最新版本

功能描述

在查词界面上加一个收藏按钮,类似有道词典;可以在统一的地方查看生词详情列表;

使用场景(可选)

No response

实现方案(可选)

No response</issue_description>

<agent_instructions>请根据 issue 内容,使用 swift 实现查询文本的收藏夹和历史记录功能。
在设置页面添加收藏夹和历史记录 tab

每次执行查询词操作时,我们都会记录该词,即历史记录列表。
如果用户点击右上角的“新建收藏”按钮,我们会将该词添加到收藏列表中。</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@tisfeng 可以,感谢反馈,稍后会添加这个功能的。 @tisfeng 收到,记下了。 @tisfeng 暂时没有,要等设置页重构 https://github.com//issues/227#issuecomment-1849027631 完成后,再来看这个。 @tisfeng Currently, the new settings page is almost completed, and some related features can be done.

We can add a favorites button in the top right corner, and add a favorites and history Tab to the settings.

If you are interested in this feature, you can try to push this issue, PR is always welcome 🤗</comment_new>
<comment_new>@tisfeng
For now, we can start by only supporting the Favorite/History feature, and Eudic can be put into another issue.

Favorite and History are very similar, we can use a simple way to do it, only record the information of the query word, such as word, queryFromLanguage, timestamp, etc., and don't record the result of the query for the time being.

Each time we perform a query word action, we record the word, which is the History list.
If the user clicks on the New Favorite button in the upper right corner, we add the word to the Favorite list.</comment_new>
<comment_new>@tisfeng
I previously added Realm package, you can use it to store favorite words.

Of course, if you have other better solutions, that's fine too.</comment_new>
<comment_new>@tisfeng
单词本:手动添加才会记录。
历史记录:每个查询都会被记录。

@yam-liu 你好,请问有在做这个功能吗</comment_new>
<comment_new>@tisfeng
我也在使用 eudic,对于支持 eudic,将收藏的单词同步到 eudic 这部分没问题。

但考虑到不是所有用户都使用欧路词典,所以 Easydict 本身还是应该实现一个自己的单词记录模块(单词本和历史记录),将单词本同步到 eudic 可以是一个额外功能。</comment_new>
<comment_new>@tisfeng
最近计划使用 SwiftUI 重写查询窗口 #551 ,考虑到 SwiftUI 可能会改动许多数据存储结构,因此单词本功能需要等重写完成后。</comment_new>
<comment_new>@tisfeng

单词本什么时候上呢,需不需要帮忙

需要的,非常需要,如果会一些 Swift,可以来帮忙。

最近我在尝试重写 AppleService 服务 #921 ,其他开发者在冬眠,顾不上这里。

我之前曾想用 Swift 重写 EZQueryService 和 EZQueryModel,但后面发现牵扯太多了。

如果想要做这个功能,可以单独写一个有关单词记录的数据存储模块,不用太顾及当前的代码,这样会更方便快捷。</comment_new>
<comment_new>@tisfeng
我最近工作比较忙,其他开发者也没有活跃,没有空来处理 🥺</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits November 19, 2025 16:26
Co-authored-by: tisfeng <25194972+tisfeng@users.noreply.github.com>
Co-authored-by: tisfeng <25194972+tisfeng@users.noreply.github.com>
Co-authored-by: tisfeng <25194972+tisfeng@users.noreply.github.com>
Co-authored-by: tisfeng <25194972+tisfeng@users.noreply.github.com>
Copilot AI changed the title [WIP] Add favorites and history functionality to query interface Add favorites and history tracking with Settings UI Nov 19, 2025
Copilot AI requested a review from tisfeng November 19, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 功能建议:建议新增类似生词本的功能

2 participants