Listary 插件开发教程,自己摸索出来的

作者已经全职加入一家初创公司了,没有时间维护 Listary 了,不过 Listary 确实是一个好软件,这里预祝作者早日实现财富自由,我最近摸索了一下 Listary 的插件开发方式:

CSDN 见:https://blog.csdn.net/hezhongla0811/article/details/110189562
github 见:https://github.com/378978764/listary-plugin-example

正文见:

开发思路

原作者貌似已经弃坑(加入了一家 AI 初创公司,遂 Listary 已经一年多没人维护了),确实比 Wox 方便些,因此反编译一下看看当年作者写的插件半成品如何使用。

反编译

经过反编译后,发现 Listary 使用 Javascript 开发的插件一共有下面四个选项可以配置:

得到字段

发现可以返回一个数组,数组里面的对象内容为:

{
	title: 标题,
	subtitle: 副标题,
	execution: 要执行的动作,是一个数组
}
  • 1
  • 2
  • 3
  • 4
  • 5

这个 execution 目前只发现了一个,打开网页用的:

[
	{
		type: 'OpenUrl',
		url: 'http://baidu.com'
	}
]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

例子

可以直接去 github 下载成品:

https://github.com/378978764/listary-plugin-example
  • 1

流程

有了上述的开发思路,开发流程如下:

clone 项目到插件文件夹下

插件文件夹为:%AppData%\Listary\UserProfile\Extensions

cd %AppData%\Listary\UserProfile\Extensions
git clone https://github.com/378978764/listary-plugin-example.git
  • 1
  • 2

重启 Listary

关闭 Listary 并重新打开后,就会发现使用 yd 关键词可以呼出有道查词(抓包得来的一个未公开接口,不需要key,慎用)。

结果

在这里插入图片描述

项目解释

index.js 中的 search 函数就是整个插件的入口,然后返回一个符合上述条件的 result 字段数组即可。


一个最为简单的例子为:

const axios = require("axios")

async function search(query) {
  return [
    {
      title: "标题",
      subtitle: "副标题",
    },
    {
      title: "点击这里可以打开百度",
      subtitle: "副标题",
      execution: [
        {
          type: "OpenUrl",
          url: "http://baidu.com",
        },
      ],
    },
  ]
}
module.exports = {
  search: search,
}
2 Likes

请问能不能类似这个提供一个支持有道翻译key的独立插件版https://github.com/whklhh/youdao-dic-plugin-for-listary6beta
多谢了

非常非常感谢,还有网友大神有如此能力作深度开发。
希望继续完善。我会继续关注你的。

按照你这个操作但是返回永远是“No search results” 是咋回事啊

这么优秀的工具,可惜 了。开发了70%。