# Mdict开源

**URL:** <https://forum.freemdict.com/t/topic/41957>\
**Category:** 软件经验交流展望\
**Tags:** mdict\
**Created:** [2025 年10 月 29 日 15:02 UTC](https://forum.freemdict.com/t/topic/41957 "2025-10-29T15:02:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

作者： ![Yacht](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/y/aca169/32.png) [@Yacht](https://forum.freemdict.com/u/Yacht)\
发布日期： [2025 年10 月 29 日 15:02 UTC](https://forum.freemdict.com/t/topic/41957/1 "2025-10-29T15:02:53Z")

</div>

Mdict作者在公众号里发文开源了本软件

> **[GitHub - raymanzhang/mdict: The MDict App](https://github.com/raymanzhang/mdict)**
>
> The MDict App

这个是经过rust重写的版本，目前仅支持pc

忘了贴上作者公众号原文的链接了，现已补上：  
[https://mp.weixin.qq.com/s/QEgatU1pVrGqLUC53aGcLw](https://mp.weixin.qq.com/s/QEgatU1pVrGqLUC53aGcLw)

---

<div class="post-metadata">

作者： ![mixivivo](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/m/8491ac/32.png) [@mixivivo](https://forum.freemdict.com/u/mixivivo)\
发布日期： [2025 年10 月 29 日 15:55 UTC](https://forum.freemdict.com/t/topic/41957/2 "2025-10-29T15:55:03Z")

</div>

祝贺。开源之后，最起码索引和排序之谜就能解开了。

---

<div class="post-metadata">

作者： ![amob](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/amob/32/14630_2.png) [@amob](https://forum.freemdict.com/u/amob)\
发布日期： [2025 年10 月 29 日 16:01 UTC](https://forum.freemdict.com/t/topic/41957/3 "2025-10-29T16:01:12Z")

</div>

Mdict终于开源，功德一件。更有实用价值的可能是其他相关的工具，而不是尚为雏形的rust版软件。基于这些源代码，我想很多东西都能得到改善。

[raymanzhang/mdx\_util: A command line tools for handling mdx related jobs.](https://github.com/raymanzhang/mdx_util)  
[raymanzhang/mdx: A rust library for encode/decode mdx format file](https://github.com/raymanzhang/mdx)

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2025 年10 月 29 日 16:01 UTC](https://forum.freemdict.com/t/topic/41957/4 "2025-10-29T16:01:17Z")

</div>

关键代码在这里，怪不得有声调的字母会导致整个词典索引排序出错。[sort\_key.rs#L69](https://github.com/raymanzhang/mdx/blob/main/src/utils/sort_key.rs#L69)

原作者处理的结果是 Á → Á，另外函数里对 GBK 和 BIG5 的处理感觉也有问题。

```auto
ch = ch - b'A' + b'a';

```

社区开源的打包工具，处理的结果是 Á → á，使用 `locale.strxfrm` 也会导致排序混乱，标点处理可能也有差异，没有细看。[writer.py#L129](https://github.com/liuyug/mdict-utils/blob/master/mdict_utils/writer.py#L129)

```auto
key1 = item1['key'].lower()

```

原作者在处理 GBK/BIG5 编码的词典排序时会出错：

```auto
GBK: [B0, A1] // “啊” 的 GBK 编码
Sort key: [B0, A1, A1] // 多了一个编码出来

```

> **[Rust Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=56b03ca9e038144586a8dbf13c74d094)**
>
> A browser interface to the Rust compiler to experiment with the language

下个结论：

第三方词典软件如果不使用自己的索引，在查询有声调字母的单词时，100% 出错，因为软件这边没法同时兼容社区和原作者这两个打包工具生成的词典。

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2025 年10 月 29 日 17:42 UTC](https://forum.freemdict.com/t/topic/41957/5 "2025-10-29T17:42:00Z")

</div>

#142 下面这段代码也是错误的，直接删掉就好了。

比如 `abc!` 和 `abc`，原作者的排序是 `abc` \> `abc!`，mdict-utils 是 `abc!` \> `abc`：

```auto
# reverse
if len(key1) > len(key2):
    return -1
elif len(key1) < len(key2):
    return 1

```

---

<div class="post-metadata">

作者： ![endnote](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/e/9de0a6/32.png) [@endnote](https://forum.freemdict.com/u/endnote)\
发布日期： [2025 年10 月 29 日 18:41 UTC](https://forum.freemdict.com/t/topic/41957/6 "2025-10-29T18:41:20Z")

</div>

开源是好事。Mdict的优势是占用资源小。

希望把老旧的浏览器开发框架更新一下，以支持新的HTML和CSS特性

---

<div class="post-metadata">

作者： ![jdiary](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/j/ad7895/32.png) [@jdiary](https://forum.freemdict.com/u/jdiary)\
发布日期： [2025 年10 月 29 日 19:13 UTC](https://forum.freemdict.com/t/topic/41957/7 "2025-10-29T19:13:21Z")

</div>

因为Rust相关技术能力实在不够，所以我纯属筹热闹的同时给这个帖子也加点热度。这下可以期待有更多的词典软件能够支持mdd甚至多个mdd了。因为想找到能用mdd的词典软件，我也试了好几个软件了，有的（以mdict-query为代表）会额外生成sqlite数据库文件，算是自建“索引”的一类了。可是这样的话，既让mdx和mdd本身作为只读数据库失去了意义，又让文件夹里面多了重复的数据文件。期待有更多可以支持mdd的软件，也让 [支持 mdd 的词典软件有哪些？](https://forum.freemdict.com/t/topic/41934) 这个问题的答案变得充实一些。感觉技术难度还是在怎么不“解压”mdd的同时又快速为HTML里面的引用返回数据，比如一个词条里面有5张图片（常见的不同发音的多个发音图标，解释释义里面的图示），软件能快速全部显示出来。（这里不得不服GoldenDict是真厉害，但是似乎是自建索引 - 我的猜想，这很合理，毕竟是支持多种词典格式的，自建索引统一处理。）

---

<div class="post-metadata">

作者： ![ad困困](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/a/87869e/32.png) [@ad困困](https://forum.freemdict.com/u/ad%E5%9B%B0%E5%9B%B0)\
发布日期： [2025 年10 月 30 日 01:48 UTC](https://forum.freemdict.com/t/topic/41957/8 "2025-10-30T01:48:00Z")

</div>

Releases上没有下载程序，看来是个源代码需要自己编译，我等菜鸡不会。等后续完善了再说吧

---

<div class="post-metadata">

作者： ![hua](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/hua/32/11090_2.png) [@hua](https://forum.freemdict.com/u/hua)\
发布日期： [2025 年10 月 30 日 03:03 UTC](https://forum.freemdict.com/t/topic/41957/9 "2025-10-30T03:03:39Z")

</div>

Interesting 好像作者也玩 PVE 😀

我曾有很多想法做一款新的词典软件，不过一直未曾开始，现在看来囿于精力就让这个烂在肚子里吧。

---

<div class="post-metadata">

作者： ![hua](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/hua/32/11090_2.png) [@hua](https://forum.freemdict.com/u/hua)\
发布日期： [2025 年10 月 30 日 03:06 UTC](https://forum.freemdict.com/t/topic/41957/10 "2025-10-30T03:06:59Z")

</div>



---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2025 年10 月 30 日 03:13 UTC](https://forum.freemdict.com/t/topic/41957/11 "2025-10-30T03:13:19Z")

</div>

新版本截图：

 ![截屏2025-10-30 11.12.47](https://forumcdn.freemdict.com/uploads/default/original/3X/0/e/0ec4724be52ccfab9fbca1dd9c830d1114a5f98c.png)

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2025 年10 月 30 日 03:26 UTC](https://forum.freemdict.com/t/topic/41957/12 "2025-10-30T03:26:11Z")

</div>

新版本集成了全文搜索引擎，类似 GoldenDict-NG 的实现，但是需要重写分词器的部分，因为这个引擎是用于日志搜索的，和通用搜索引擎不一样，没有考虑中文和日文需要分词的情况。

---

<div class="post-metadata">

作者： ![atauzki](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/atauzki/32/1365_2.png) [@atauzki](https://forum.freemdict.com/u/atauzki)\
发布日期： [2025 年10 月 30 日 04:35 UTC](https://forum.freemdict.com/t/topic/41957/13 "2025-10-30T04:35:11Z")

</div>

这个版本用的tauri调用的是系统的webview框架，至少windows上是基于edge的不用担心web兼容性问题，linux的webkitgtk兼容性问题应该也不大，但是稳定性不咋地

---

<div class="post-metadata">

作者： ![Yacht](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/y/aca169/32.png) [@Yacht](https://forum.freemdict.com/u/Yacht)\
发布日期： [2025 年10 月 30 日 04:57 UTC](https://forum.freemdict.com/t/topic/41957/14 "2025-10-30T04:57:17Z")

</div>

webview下应该理论上是能打开目前所有mdx而不会出现原来旧mdict各种js问题的，目前参与项目的还不多，还要经过大量测试看看。

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2025 年10 月 30 日 05:01 UTC](https://forum.freemdict.com/t/topic/41957/15 "2025-10-30T05:01:16Z")

</div>

linux 的 webview 问题非常多多多多。。。

---

<div class="post-metadata">

作者： ![Yacht](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/y/aca169/32.png) [@Yacht](https://forum.freemdict.com/u/Yacht)\
发布日期： [2025 年10 月 30 日 05:03 UTC](https://forum.freemdict.com/t/topic/41957/16 "2025-10-30T05:03:01Z")

</div>

> [@last\_idol](#):
>
> linux 的 webview 问题

linux系统不知道怎么搞的，这内核级别的东西一堆bug。  
就拿ubuntu来说20.04版本后的lts性能还会倒退的也是一绝。

---

<div class="post-metadata">

作者： ![atauzki](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/atauzki/32/1365_2.png) [@atauzki](https://forum.freemdict.com/u/atauzki)\
发布日期： [2025 年10 月 30 日 05:09 UTC](https://forum.freemdict.com/t/topic/41957/17 "2025-10-30T05:09:37Z")

</div>

移植苹果的玩意还是gtk负责的，拿脚想bug都不少……

---

<div class="post-metadata">

作者： ![endnote](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/e/9de0a6/32.png) [@endnote](https://forum.freemdict.com/u/endnote)\
发布日期： [2025 年10 月 30 日 05:16 UTC](https://forum.freemdict.com/t/topic/41957/18 "2025-10-30T05:16:27Z")

</div>

> [@last\_idol](#):
>
> 但是需要重写分词器的部分

承借Mdict开源的东风，建议群策群力把其他开源MDX编译和MDX解读程序的最佳实践纳进来，形成实际的MDX标准（估计没有人愿意花时间去搞大厚本的MDX规格手册）。

不管怎么说，Mdict高效小巧，目前代码量不算大，改进扩充的难度比GoldenDict小，大牛们还可以借此练手Rust技能

---

<div class="post-metadata">

作者： ![amob](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/amob/32/14630_2.png) [@amob](https://forum.freemdict.com/u/amob)\
发布日期： [2025 年10 月 30 日 05:36 UTC](https://forum.freemdict.com/t/topic/41957/19 "2025-10-30T05:36:03Z")

</div>

Mdict给了个好思路，重建索引（目前只有Goldendict这么做），strip key、排序、重音字母等问题应该都能得到解决：

 ![image](https://forumcdn.freemdict.com/uploads/default/original/3X/3/5/35de283c6c108e09adeaa8ac2a8e09e4aaf8e15f.png)

---

<div class="post-metadata">

作者： ![winn](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/w/9dc877/32.png) [@winn](https://forum.freemdict.com/u/winn)\
发布日期： [2025 年10 月 30 日 05:39 UTC](https://forum.freemdict.com/t/topic/41957/20 "2025-10-30T05:39:58Z")

</div>

我希望有个正则查词的功能，这实现起来应该不难。很多时候想查个记忆模糊的词，如果有正则选择就方便了。

[下一页](https://forum.freemdict.com/t/topic/41957.md?page=2)
