From 3200998063bf86846c8d8f354bed8536b63b83dd Mon Sep 17 00:00:00 2001 From: Elliot Date: Thu, 28 Mar 2024 21:39:31 +0800 Subject: [PATCH] feat: zh-tw translation (#4) --- .vitepress/config.mjs | 63 +++++++ docs/zh-TW/dev-api.md | 46 +++++ docs/zh-TW/dev-extension.md | 347 ++++++++++++++++++++++++++++++++++++ docs/zh-TW/dev.md | 11 ++ docs/zh-TW/donate.md | 17 ++ docs/zh-TW/index.md | 57 ++++++ docs/zh-TW/install.md | 175 ++++++++++++++++++ 7 files changed, 716 insertions(+) create mode 100644 docs/zh-TW/dev-api.md create mode 100644 docs/zh-TW/dev-extension.md create mode 100644 docs/zh-TW/dev.md create mode 100644 docs/zh-TW/donate.md create mode 100644 docs/zh-TW/index.md create mode 100644 docs/zh-TW/install.md diff --git a/.vitepress/config.mjs b/.vitepress/config.mjs index c90397c..b34ea9e 100644 --- a/.vitepress/config.mjs +++ b/.vitepress/config.mjs @@ -160,6 +160,69 @@ export default defineConfig({ }, }, }, + zh-TW: { + label: "正體中文", + lang: "zh-TW", + title: "Gopeed 文件", + description: "Gopeed 文件網站", + themeConfig: { + socialLinks: [ + { icon: "github", link: "https://github.com/GopeedLab/gopeed" }, + { icon: "discord", link: "https://discord.gg/ZUJqJrwCGB" }, + ], + nav: [ + { + text: "指南", + link: "/zh-tw/index.md", + }, + { + text: "開發", + link: "/zh-tw/dev.md", + }, + { + text: "RESTFul API", + link: "https://docs.gopeed.com/site/openapi/index.html", + }, + { + text: "SDK Reference", + link: "https://docs.gopeed.com/site/reference/index.html", + }, + { + text: "捐贈", + link: "/donate.md", + }, + ], + sidebar: [ + { + text: "指南", + items: [ + { + text: "介紹", + link: "/zh-tw/index.md", + }, + { + text: "安裝", + link: "/zh-tw/install.md", + }, + ], + }, + { + text: "開發", + items: [ + { + text: "API 對接", + link: "/zh-tw/dev-api.md", + }, + { + text: "擴充開發", + link: "/zh-tw/dev-extension.md", + }, + ], + }, + ], + }, + }, + }, themeConfig: { logo: "/images/logo.png", logoLink: "https://gopeed.com", diff --git a/docs/zh-TW/dev-api.md b/docs/zh-TW/dev-api.md new file mode 100644 index 0000000..3ce1bd4 --- /dev/null +++ b/docs/zh-TW/dev-api.md @@ -0,0 +1,46 @@ +# API 對接 + +Gopeed 對外提供了 HTTP API 接口,可以透過 API 進行下載管理。 + +## 啟用介面 + +首先需要設定通訊協定為 TCP,透過**設定 -> 進階 -> 通訊協定**,將通訊協定設定為 TCP,並設定 IP 和端口,如下圖所示: + +![](/images/dev/set-port.png) + +這樣就可以透過`http://127.0.0.1:6666`存取API 了,但是出於安全考慮,建議設定一個令牌,透過**設定-> 進階-> 介面令牌**,設定一個令牌 ,如下圖所示: + +![](/images/dev/set-token.png) + +> 註:以上設定需重新啟動後生效。 + +## 使用 JS SDK + +Gopeed 提供了官方的 js 函式庫,首先需要安裝`@gopeed/rest`函式庫: + +``` +npm install @gopeed/rest +``` + +然後就可以愉快的使用了,範例: + +```js +import { Client } 從 "@gopeed/rest"; + +(async function () { + // 建立客戶端 + const client = new Client(); + // 呼叫API建立任務 + const res = await client.createTask({ + req: { + url: "https://example.com/file.zip", + }, + }); +})(); +``` + +更多使用方法請參考 [文件](https://docs.gopeed.com/site/reference/classes/_gopeed_rest.Client.html)。 + +## 使用 HTTP 請求 + +當然也可以直接透過 HTTP 請求來呼叫 API,具體請參考 [介面文件](https://docs.gopeed.com/site/openapi/index.html)。 \ No newline at end of file diff --git a/docs/zh-TW/dev-extension.md b/docs/zh-TW/dev-extension.md new file mode 100644 index 0000000..3c62acf --- /dev/null +++ b/docs/zh-TW/dev-extension.md @@ -0,0 +1,347 @@ +# 擴充開發 + +Gopeed 支援使用`JavaScript`進行擴展開發,擴展可以增強Gopeed 的功能,例如下載某個網站的視頻,或者下載某個網站的音樂等等,可以通過[官方示例](https://github.com/ GopeedLab/gopeed-extension-samples/blob/main/README_zh-CN.md)快速了解一下。 + +Gopeed 擴充功能是基於`git`來實現去中心化的擴充管理,只要將擴充原始碼託管到遠端git 倉庫中,就可以透過Gopeed 進行安裝和更新,所以無論是`github`、`gitee`、`gitlab`還是 其它git 託管平台,都可以作為擴充的託管倉庫。 + +## 快速開始 + +### 使用鷹架搭建 + +Gopeed 提供了腳手架來幫助你快速創建一個擴展開發項目模版: + +```sh +npx create-gopeed-ext@latest +``` + +在建立過程中,將會看到以下提示: + +```sh +√ Project name (gopeed-extension-demo) ... +√ Choose a template » Webpack + +Success! Created gopeed-extension-demo at D:\code\study\js\gopeed-extension-demo +Inside that directory, you can run several commands: + + git init + Initialize git repository + + npm install + Install dependencies + + npm run dev + Compiles and hot-reloads for development. + + npm run build + Compiles and minifies for production. + +We suggest that you begin by typing: + + cd gopeed-extension-demo + +Happy coding! +``` + +### 手動搭建 + +如果你對`node.js`週邊工具不太熟悉,也可以手動建立一個項目,檔案結構如下: + +```sh +├── index.js +├── manifest.json +``` + +## 本機偵錯 + +在專案搭建好之後,需要進行本地調試,可以將本地的擴充項目安裝到 Gopeed 中進行調試,具體步驟如下: + +1. 開啟 `Gopeed` 開發者模式,在擴充頁面`連續點選 5 次`安裝按鈕,即可開啟開發者模式。 + +![](/images/dev/extension/dev-mode.gif) + +2. 點選按鈕在目錄選擇器中選擇擴充目錄,進行安裝。 + +3. 如果使用腳手架中`webpack`模式,可以透過`npm run dev`啟動自動編譯。 + +4. 建立任務即可看到擴充生效了。 + +![](/images/dev/extension/demo.gif) + +可以看到透過腳手架建立的範例擴展,可以實現使用`https://github.com/hello`連結建立任務時,解析出一個`example/index.html`文件 + +> 註:開發者模式只在桌面平台有效。 + +## 開發解析 + +上一節中,已經能夠創建一個基礎的擴展並進行本地調試了,但是在面紗之下,它究竟是怎麼運作的呢? + +首先我們來看看`manifest.json`文件,這個是擴展的清單文件,它描述了擴展的信息,每個擴展項目根目錄中必須包含一個`manifest.json`文件,本節中的示例文件如下 : + +```json +{ + "name": "gopeed-extention-demo", + "author": "", + "title": "gopeed extention demo title", + "description": "gopeed extention demo description", + "icon": "", + "version": "1.0.0", + "homepage": "", + "repository": { + "url": "" + }, + "scripts": [ + { + "event": "onResolve", + "match": { + "urls": ["*://github.com/*"] + }, + "entry": "dist/index.js" + } + ], + "settings": [] +} +``` + +接下來逐一介紹各個字段的含義: + +- `name`和`author`:Gopeed 中會使用`@`作為擴展的ID,填寫`author`後能確保不容易和別的擴展重名導致被覆蓋安裝,所以強烈建議 填寫`author`欄位。 +- `title`和`description`:擴充的標題和描述。 +- `icon`:擴充圖標,填寫相對路徑,範例:`icon.png`。 +- `version`:擴充版本,使用 semver 規範,擴充更新時是基於此欄位進行比較的,所以請確保版本號是符合規範的。 +- `homepage`:擴充首頁,範例:`https://gopeed.com`。 +- `repository`:擴充所屬git 倉庫位址,Gopeed 擴充依賴`git`來實現去中心化的擴充管理,所以如果你的擴充功能需要被使用者安裝和更新,那麼就必須將擴充原始碼託管到遠端git 倉庫中 ,並配置此字段 + + 範例: + + ```json + { + "url": "https://github.com/gopeed/gopeed-extension-demo" + } + ``` + + 如果一個 git 倉庫中包含多個擴充項目的話,可以透過`directory`屬性指定子目錄,範例: + + ```json + { + "url": "https://github.com/GopeedLab/gopeed-extension-samples", + "directory": "github-contributor-avatars-sample" + } + ``` + + 在 Gopeed 安裝時,需要透過`#`進行分割,即安裝連結為`https://github.com/GopeedLab/gopeed-extension-samples#github-contributor-avatars-sample`。 + +- `scripts`:`敲重點! `這裡是 Gopeed 擴充功能啟動事件的設定。 + + 範例專案中配置的`onResolve`事件會在解析任務時觸發,透過`match.urls`欄位來匹配任務建立的url,如果符合成功,則會執行`entry`欄位指定的腳本文件,在上面的鷹架 在專案範例中,配置了符合`*://github.com/*`,然後執行`dist/index.js`文件,所以當我們輸入一個`https://github.com/hello`連結時被匹配 到,然後觸發了擴充腳本的執行,這裡先不講腳本的內容,後面會詳細介紹。 + + > 符合規則和 chrome 擴充的符合規則一致,可以參考[這裡](https://developer.chrome.com/docs/extensions/mv3/match_patterns/) + +- `settings`:擴充設定項,透過設定聲明可以在 Gopeed 中產生對應的設定介面,提供使用者自訂設置,例如自訂`Cookie`、自訂`User-Agent`等等,範例: + + 範例: + + ```json + [ + { + "name": "ua", + "title": "User-Agent", + "description": "自訂 User-Agent", + "type": "string", + "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + } + ] + ``` + + - `name`:設定項目名稱,必填。 + - `title`:設定項目標題,必填。 + - `description`:設定項描述,可選。 + - `type`:設定項目類型,可選值:`string`、`number`、`boolean`。 + - `value`:設定項目預設值,可選。 + +## 腳本編寫 + +上一節中,我們已經知道如何配置清單,接下來就來介紹下擴充腳本的編寫。 + +### 運行環境 + +Gopeed 擴充腳本引擎是由[goja](https://github.com/dop251/goja)來實現的,它是一個純Go 編寫的JavaScript 解釋器,但是由於goja 只是一個純js 運行時,所以`瀏覽 器`和`node.js`的API 都是不支援的,目前`Gopeed`實作了`XMLHttpRequest`、`fetch`兩個API,意味著你可以透過這兩個API 或基於它們的第三方函式庫來 實作網路請求,例如`axios`、`superagent`等等。 + +另外要注意一點的是,goja 原生支援大部分`es6+`的語法,但是極少數語法是不支援的,例如`async generator`,但是沒關係,透過腳手架創建的專案中已經配置好了`bable` ,你可以愉快的使用最新的es 語法,腳本最終會被編譯成`es5`語法。 + +### 範例腳本解析 + +每當事件觸發時,會執行`entry`欄位指定的腳本文件,範例專案中的腳本文件如下: + +```js +gopeed.events.onResolve((ctx) => { + ctx.res = { + name: "example", + files: [ + { + name: "index.html", + req: { + url: "https://example.com", + }, + }, + ], + }; +}); +``` + +接下來,我們逐一介紹一下腳本的內容: + +- `gopeed.events.onResolve`:這裡是註冊`onResolve`事件,方法裡面就是擴充的具體邏輯了。 +- `ctx`:事件上下文,包含了當前事件的一些信息,在`onResolve`事件中,`ctx`包含了以下字段: + - `req`:請求訊息,包含了資源的 url、headers 等等。 + - `res`:回應訊息,腳本需要將解析出的檔案清單賦值給`ctx.res`,Gopeed 會根據裡面傳回的檔案清單進行下載。 + - `settings`:擴充設定項,包含了使用者自訂的設定項。 + +簡而言之就是需要在`onResolve`回調函數中,根據`ctx.req`裡的請求信息,解析出需要下載的文件列表賦值給`ctx.res`即可,那麼上面的腳本就很好理解 了,就是解析出一個`index.html`檔案和對應的下載位址,然後賦值給`ctx.res`。 + +> 關於`ctx`的詳細說明可以參考[文件](https://docs.gopeed.com/site/reference/interfaces/gopeed.types.OnResovleContext.html)。 + +## 擴充設定 + +為了能讓擴展具有更動態化的能力,Gopeed 提供了一套標準的配置項,透過聲明`settings`屬性,可以在 Gopeed 中產生對應的擴展設定介面,提供使用者自訂設置,例如自訂`Cookie`、自訂`User-Agent`等等,來看看下面的範例: + +```json +{ + "settings": [ + { + "name": "cookie", + "title": "網站 Cookie", + "description": "Cookie 可以透過瀏覽器開發者工具取得", + "type": "string" + }, + { + "name": "quality", + "title": "預設畫質", + "type": "number", + "value": "1080", + "options": [ + { + "label": "1080P", + "value": "1080" + }, + { + "label": "720P", + "value": "720" + }, + { + "label": "480P", + "value": "480" + } + ] + } + ] +} +``` + +這裡宣告了兩個設定項,一個是`cookie`,一個是`quality`,來看看它們的效果: + +![](/images/dev/extension/demo-settings.gif) + +可以看到`cookie`是一個輸入文字框,`quality`是一個下拉框,這裡需要注意的是,`type`字段決定了設定項目的類型,目前支援三種類型: + +- `string` +- `number` +- `boolean` + +如果配置了`options`選項,那麼就會渲染成下拉框供使用者選擇。 + +接著就是在擴充腳本中透過`gopeed.settings`取得設定的值了,範例: + +```js +gopeed.events.onResolve((ctx) => { + // 存取cooke設定項 + console.log(gopeed.settings.cookie); + // 存取quality設定項 + console.log(gopeed.settings.quality); +}); +``` + +## 擴充存儲 + +Gopeed 提供了一套儲存 API,以支援擴展持久化儲存數據,例如`登入token`等等,範例: + +```js +gopeed.events.onResolve((ctx) => { + // Get the token, if it not exists, then login + const token = gopeed.storage.get("token"); + if(!token){ + const token = await login(); + gopeed.storage.set("token",token) + } + + // Then do something with the token + // ... +}); +``` + +> 附註:詳細的 API 可以參考[文件](https://docs.gopeed.com/site/reference/interfaces/gopeed.types.Storage.html)。 + +## 擴充調試 + +在腳本中可以透過`gopeed.logger`物件進行日誌輸出,支援`debug`、`info`、`warn`、`error`三種級別,範例: + +```js +gopeed.logger.debug("debug"); +gopeed.logger.info("info"); +gopeed.logger.warn("warn"); +gopeed.logger.error("error"); +``` + +日誌檔案在 Gopeed 安裝目錄裡的`logs`目錄下,檔案名稱為`extension.log`,可以透過`tail -f extension.log`指令即時查看日誌。 + +> 注意:debug 等級的日誌僅在開發者模式安裝的擴充功能中生效。 + +## 擴充功能發布 + +擴充開發完成後,如果是由鷹架創建的`webpack`工程,需要編譯一下: + +```sh +npm run build +``` + +然後我們要建立一個`遠端倉庫`,例如在`github`上建立了一個`https://github.com/xxx/gopeed-extension-demo`倉庫,然後對應的修改一下`manifest.json`中的 `repository`字段: + +```json +{ + "repository": { + "url": "https://github.com/xxx/gopeed-extension-demo" + } +} +``` + +> 正確的設定`repository`,可以讓擴充功能取得遠端更新的功能,如果擴充屬於 git 倉庫下的子目錄,可以透過`directory`屬性指定子目錄,範例: +> +> ```json +> { +> "repository": { +> "url": "https://github.com/xxx/gopeed-extension-demo", +> "directory": "path" +> } +> } +> ``` + +這裡也要記得配置好擴充的`author`和`name`字段,以降低和其它擴展重名的風險。 + +然後將專案推送到遠端倉庫即可完成發布,為了讓用戶更方便的在`github`檢索Gopeed 擴展,建議專案名字統一以`gopeed-extension-`開頭,例如`gopeed-extension-demo`,並且在 `github`中為專案打上`gopeed-extension`標籤。 + +## 擴充安裝 + +發佈到遠端倉庫之後,就可以在Gopeed 中安裝了,打開擴展頁面,輸入擴展的HTTP 協議的`git clone`地址(可以省略掉後面的`.git`後綴),點擊`安裝`按鈕即可進行 安裝。 + +> 註:如果擴充目錄是子目錄,需要在位址後面加上`#`,再加上子目錄名稱,例如`https://github.com/xxx/gopeed-extension-demo#path`。 + +## 官方範例 + +官方提供了兩個具有代表性的範例擴充提供參考,分別是: + +- [github-contributor-avatars-sample](https://github.com/GopeedLab/gopeed-extension-samples/tree/main/github-contributor-avatars-sample) + + 此擴充功能是依賴`node.js`的項目,適用於複雜需求開發,透過`cheerio`庫解析網頁`DOM`,來取得需要下載的檔案清單。 + +- [github-release-sample](https://github.com/GopeedLab/gopeed-extension-samples/tree/main/github-release-sample) + + 此擴充功能是`純js`項目,無任何依賴,適用於簡單需求開發,透過`fetch`實現網路請求,來取得需要下載的檔案清單。 \ No newline at end of file diff --git a/docs/zh-TW/dev.md b/docs/zh-TW/dev.md new file mode 100644 index 0000000..20529ba --- /dev/null +++ b/docs/zh-TW/dev.md @@ -0,0 +1,11 @@ +# 開發 + +Gopeed 目前提供兩種方式對外進行擴展,一種是透過對接 HTTP API,另一種是透過`JavaScript`腳本開發擴展進行增強。 + +## API 對接 + +請參考 [文檔](dev-api.html) + +## 擴充開發 + +請參考 [文檔](dev-extension.html) \ No newline at end of file diff --git a/docs/zh-TW/donate.md b/docs/zh-TW/donate.md new file mode 100644 index 0000000..d946bb9 --- /dev/null +++ b/docs/zh-TW/donate.md @@ -0,0 +1,17 @@ +## 捐贈 + +🙏 開源不易,如果您覺得 Gopeed 對您有幫助,歡迎以捐款表示支持,您的支持會幫助專案更好的發展,謝謝! + +[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R6IJGN6) + +| 微信 | 支付寶 | PayPal | +| :--------------------------------------------------------------------: | :--------------------------------------------------------------: | :-------------------------------------: | +| wechatpay | alipay | [Click Me](https://paypal.me/monkeyWie) | + +### 加密貨幣 + +- **BTC**: 35jYkPN8bgkh7AWjt3B1VgMQHqtGYcvF6p +- **ETH:** 0x928a7fd2398c941Ac6713704e606Fa414595e3A0 +- **Matic:** 0x928a7fd2398c941Ac6713704e606Fa414595e3A0 +- **BNB:** 0x928a7fd2398c941Ac6713704e606Fa414595e3A0 +- **USDT(ERC20)**: 0x928a7fd2398c941Ac6713704e606Fa414595e3A0 \ No newline at end of file diff --git a/docs/zh-TW/index.md b/docs/zh-TW/index.md new file mode 100644 index 0000000..ea3b524 --- /dev/null +++ b/docs/zh-TW/index.md @@ -0,0 +1,57 @@ +# 介紹 +*主要由Google Translate翻譯,對照[90d43b0](https://github.com/GopeedLab/docs/commit/90d43b0abe0d043e0b55212c430f7aeb7313963f)翻譯
+Gopeed(全名為Go Speed),直譯過來中文名叫做`夠快下載器`(不是狗屁下載器!),是一款由`Golang` + `Flutter` 開發的高速下載器,支援(HTTP、BitTorrent、Magnet )協定下載,並且支援所有平台使用,支援的平台有: + +- [x] **Windows** +- [x] **Macos** +- [x] **Linux** +- [x] **Android** +- [x] **iOS** +- [x] **Web** +- [x] **Docker** +- [x] **命令列** + +## 特性 + +作為一個現代化的下載器,Gopeed 有著非常多的特性,以下是來簡單的介紹一下。 + +### 基本功能 + +- HTTP & HTTPS 多重協程下載 +- Torrent & Magnet 下載 +- 每日自動更新 tracker 列表 +- Seed, DHT, PEX, uTP, Webtorrent, Upnp +- 國際化 +- 暗黑主題 + +### 進階特性 + +除了基礎的下載功能外,還有許多進階特性,讓 Gopeed 可玩性更高。 + +- **對外開放 HTTP 介面** + + 透過 RESTFul API 可以很方便的與 Gopeed 進行交互,例如你可以透過 API 來控制 Gopeed 的下載、暫停、刪除等等。 + +- **去中心化的擴展設計** + + 可以透過`JavaScript`編寫擴充功能來增強 Gopeed 的下載功能,例如下載某個網站的視頻,或下載某個網站的音樂等等。 + +## 為什麼不是...? + +這裡和市面上流行的下載器進行對比,可以很直觀的看到 Gopeed 的優勢。 + +| 功能 | Gopeed | Motrix | IDM | +| ----------- | ------ | --------------- | --------------- | +| HTTP | ✔️ | ✔️ | ✔️ | +| BitTorrent | ✔️ | ✔️ | ❌ | +| Magnet | ✔️ | ✔️ | ❌ | +| 全平台支援 | ✔️ | ❌ (僅限桌面平台) | ❌ (僅 Windows) | +| 免費 | ✔️ | ✔️ | ❌ | +| 開源 | ✔️ | ✔️ | ❌ | +| 非 Electron | ✔️ | ❌ | ✔️ | +| 開放 API | ✔️ | ✔️ | ❌ | +| 擴充支援 | ✔️ | ❌ | ❌ | + +當然 Gopeed 可能也有很多不足的地方,但我們會持續的改進。 + +而且 Gopeed 是開源的,你可以隨時隨地的提出你的想法,或直接貢獻程式碼,讓 Gopeed 變得更好。 \ No newline at end of file diff --git a/docs/zh-TW/install.md b/docs/zh-TW/install.md new file mode 100644 index 0000000..9bc86a6 --- /dev/null +++ b/docs/zh-TW/install.md @@ -0,0 +1,175 @@ +# 安裝 + +1. 前往 [官網](https://gopeed.com) 下載,會根據你的作業系統自動選擇對應的版本進行下載。 +2. 前往 [GitHub](https://github.com/GopeedLab/gopeed/releases) 下載,可以自行選擇對應的版本下載。 + +## Windows + +Windows 分成兩個版本,一個是`安裝包`版本還有一個是`免安裝`版本,大家可以依照自己的喜好進行選擇。 + +> 免安裝版本檔案名稱為:`Gopeed-v1.x.x-windows-amd64-portable.zip` + +## Macos + +Macos 版本提供了`.dmg`文件,雙擊即可安裝,安裝套件支援`intel`和`apple silicon`兩種架構。 + +> 附註:macos 版本執行如果提示損壞,請在終端執行 `xattr -d com.apple.quarantine /Applications/Gopeed.app` 指令 + +## Linux + +- Flatpak + + ```sh + flatpak install flathub com.gopeed.Gopeed + ``` + +- Snap + + ```sh + sudo snap install gopeed + ``` + +除此之外,還提供了`.deb`和`.AppImage`兩種安裝包,可以自行選擇下載安裝。 + +## Android + +Android 版本提供了`.apk`文件,可以直接下載安裝,支援所有的 CPU 架構。 + +## iOS + +目前 iOS 平台只提供了`.ipa`文件,需要自行簽名安裝,建議使用[TrollStore(巨魔商店)](https://github.com/opa334/TrollStore)進行安裝。 + +> 為什麼沒有上架到 App Store? +> +> 因為蘋果的審核機制,不允許 BitTorrent 協定相關 App 上架。 +> +> 為什麼沒有上架到 TestFlight? +> +> 因為沒錢! 專案純為愛發電,如果能得到足夠的贊助,會立刻上架到 TestFlight,所以請多多支持,開源不易,感謝! + +## Web + +如果你需要一個遠端下載服務,那麼可以考慮使用 Web 版本,Gopeed 提供了各個平台的 Web 版本,你可以根據自己的系統和 cpu 架構進行下載。 + +![](/images/guide/install/web.png) + +這裡我以 Windows 平台為例,介紹如何使用 Web 版本,其它平台的使用方式也類似。 + +1. 下載 Web 版本,解壓縮後會得到一個資料夾,將其放到你想要的位置。 +2. 在資料夾根目錄中開啟終端,執行`./gopeed.exe`,如果執行成功會看到下列輸出: + + 『`bash + + _______ ______ .______ _______ _______ _______ + / _____| / __ \ | _ \ | ____|| ____|| \ + | | __ | | | | | |_) | | |__ | |__ | .--. | + | | |_ | | | | | | ___/ | __| | __| | | | | | + | |__| | | `--' | | | | |____ | |____ | '--' | + \______| \______/ | _| |_______||_______||_______/ + + Server start success on http://[::]:9999 + ``` + +3. 開啟瀏覽器,造訪`http://localhost:9999` 即可。 + +### Web 配置 + +Web 版支援命令列參數或設定檔進行配置,命令列參數可以透過`./gopeed.exe -h`查看: + +```sh +$ ./gopeed.exe -h +Usage of C:\Users\liwei\Downloads\gopeed-web-v1.3.13-windows-amd64\gopeed.exe: + -A string + Bind Address (default "0.0.0.0") + -P int + Bind Port (default 9999) + -T string + API token, that can only be used when basic authentication is enabled. + -c string + Config file path (default "./config.json") + -p string + HTTP Basic Auth Password + -u string + HTTP Basic Auth Username (default "gopeed") +``` + +同時也支援透過設定檔進行配置,在根目錄下建立`config.json`文件,內容如下: + +```json +{ + "address": "", // 綁定的IP位址(預設:0.0.0.0) + "port": 0, // 綁定的連接埠(預設:9999) + "username": "", // 服務身分認證使用者名,為空時不啟用身分認證 + "password": "", // 服務認證密碼(預設:gopeed) + "token": "" // HTTP API 令牌,在啟用身分認證的情況下使用 HTTP API 時,必須設定令牌 +} +``` + +> 注意:如果你是在公網 ip 部署,建議啟用身份認證,否則會有安全風險。 + +## Docker + +直接一行指令即可運行: + +```sh +docker run --name gopeed -d -p 9999:9999 liwei2633/gopeed +``` + +掛載下載目錄 + +```sh +docker run --name gopeed -d -p 9999:9999 -v /path/to/download:/root/Downloads liwei2633/gopeed +``` + +掛載資料目錄 + +```sh +docker run --name gopeed -d -p 9999:9999 -v /path/to/download:/root/Downloads -v /path/to/storage:/app/storage liwei2633/gopeed +``` + +如果需要啟用身份認證,可以傳遞命令列參數(參考上一節`Web 設定`): + +```sh +docker run --name gopeed -d -p 9999:9999 -v /path/to/download:/root/Downloads -v /path/to/storage:/app/storage liwei2633/gopeed -u admin -p 123456 +``` + +## 命令列 + +命令列版本需要依賴`Golang`環境,如果你沒有安裝`Golang`環境,可以參考[這裡](https://golang.org/doc/install)進行安裝。 + +安裝命令: + +```sh +go install github.com/GopeedLab/gopeed/cmd/gopeed@latest +``` + +安裝完成就可以使用`gopeed`指令進行下載了,具體使用方法可以透過`gopeed -h`查看: + +```sh +$ gopeed -h +Usage of gopeed: + -C int + Concurrent connections. (default 16) + -D string + Store directory. (default "C:\\Users\\levi") +``` + +### 命令列使用範例 + +下載一個 HTTP 資源: + +```sh +gopeed https://example.com/file.zip +``` + +下載一個種子檔: + +```sh +gopeed D:/Downloads/file.torrent +``` + +下載一個磁力連結: + +```sh +gopeed magnet:?xt=urn:btih:xxxx +``` \ No newline at end of file