Skip to content

Commit

Permalink
chore: Add HomePage
Browse files Browse the repository at this point in the history
  • Loading branch information
Pylogmon committed Sep 4, 2023
1 parent 6eb0b8a commit fc85bef
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
### 1. 插件仓库创建

- 以此仓库为模板创建一个新的仓库
- 仓库名为 `pot-app-<插件名>`,例如 `pot-app-lingva`
- 仓库名为 `pot-app-translate-plugin-<插件名>`,例如 `pot-app-translate-plugin-lingva`

### 2. 插件信息配置

编辑 `info.json` 文件,修改以下字段:

- `id`:插件唯一 id,必须以`[plugin]`开头,例如 `[plugin].com.pot-app.lingva`
- `homepage`: 插件主页,填写你的仓库地址即可,例如 `https://github.com/pot-app/pot-app-translate-plugin-template`
- `display`: 插件显示名称,例如 `Lingva`
- `icon`: 插件图标,例如 `lingva.svg`
- `needs`: 插件依赖,一个数组,每个依赖为一个对象,包含以下字段:
Expand Down
1 change: 1 addition & 0 deletions info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"plugin_type": "translate",
"icon": "lingva.svg",
"display": "Lingva",
"homepage": "https://github.com/pot-app/pot-app-translate-plugin-template",
"needs": [{ "key": "requestPath", "display": "请求地址" }],
"language": {
"auto": "auto",
Expand Down
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ pub fn translate(
) -> Result<String, Box<dyn Error>> {
let client = reqwest::blocking::ClientBuilder::new().build()?;

let mut url = needs["requestPath"].clone();
let mut url = match needs.get("requestPath") {
Some(url) => url.to_string(),
None => return Err("requestPath not found".into()),
};

if !url.starts_with("http") {
url = format!("https://{}", url);
}

let plain_text = text.replace("/", "@@");
let encode_text = encode(plain_text.as_str());

Expand Down

0 comments on commit fc85bef

Please sign in to comment.