Skip to content

Commit d7b6143

Browse files
committed
feat: improve and more languages
1 parent 7f12b04 commit d7b6143

99 files changed

Lines changed: 9959 additions & 433 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

components/docs/SchemeUriBlock.tsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"use client";
2+
3+
import { CodeBlock } from "fumadocs-ui/components/codeblock";
4+
import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline";
5+
import type { ReactNode } from "react";
6+
7+
interface SchemeUriBlockProps {
8+
uri: string;
9+
/** Tailwind text color class for the URI text, e.g. "text-primary-600 dark:text-primary-400" */
10+
textClassName?: string;
11+
}
12+
13+
export function SchemeUriBlock({ uri, textClassName }: SchemeUriBlockProps) {
14+
const handleOpen = () => {
15+
window.open(uri, "_self");
16+
};
17+
18+
return (
19+
<CodeBlock
20+
allowCopy
21+
Actions={({
22+
className,
23+
children,
24+
}: {
25+
className?: string;
26+
children?: ReactNode;
27+
}) => (
28+
<div className={className}>
29+
<button
30+
onClick={handleOpen}
31+
type="button"
32+
className="inline-flex items-center justify-center rounded-md p-1 text-fd-muted-foreground hover:text-fd-accent-foreground transition-colors cursor-pointer"
33+
title="Open"
34+
>
35+
<ArrowTopRightOnSquareIcon className="size-4" />
36+
</button>
37+
{children}
38+
</div>
39+
)}
40+
>
41+
<pre className="min-w-full w-max px-4 pr-14">
42+
<code className={textClassName}>{uri}</code>
43+
</pre>
44+
</CodeBlock>
45+
);
46+
}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
"use client";
2+
3+
import { useState, useMemo } from "react";
4+
import { SchemeUriBlock } from "./SchemeUriBlock";
5+
6+
type SchemePath = "create" | "extension";
7+
8+
interface CreateParams {
9+
req: {
10+
url: string;
11+
};
12+
}
13+
14+
interface ExtensionParams {
15+
url: string;
16+
devMode: boolean;
17+
}
18+
19+
export function SchemeUriBuilder() {
20+
const [path, setPath] = useState<SchemePath>("create");
21+
const [createUrl, setCreateUrl] = useState("https://example.com/file.zip");
22+
const [extUrl, setExtUrl] = useState(
23+
"https://github.com/user/gopeed-extension-example",
24+
);
25+
const [extDevMode, setExtDevMode] = useState(false);
26+
27+
const generatedUri = useMemo(() => {
28+
try {
29+
if (path === "create") {
30+
const params: CreateParams = { req: { url: createUrl } };
31+
const encoded = btoa(JSON.stringify(params));
32+
return `gopeed:///create?params=${encoded}`;
33+
} else {
34+
const params: ExtensionParams = { url: extUrl, devMode: extDevMode };
35+
const encoded = btoa(JSON.stringify(params));
36+
return `gopeed:///extension?params=${encoded}`;
37+
}
38+
} catch {
39+
return "";
40+
}
41+
}, [path, createUrl, extUrl, extDevMode]);
42+
43+
const paramJson = useMemo(() => {
44+
if (path === "create") {
45+
return JSON.stringify({ req: { url: createUrl } }, null, 2);
46+
}
47+
return JSON.stringify({ url: extUrl, devMode: extDevMode }, null, 2);
48+
}, [path, createUrl, extUrl, extDevMode]);
49+
50+
return (
51+
<div className="not-prose my-6 rounded-xl border border-fd-border bg-fd-card overflow-hidden">
52+
{/* Path selector */}
53+
<div className="flex border-b border-fd-border">
54+
{(["create", "extension"] as const).map((p) => (
55+
<button
56+
key={p}
57+
onClick={() => setPath(p)}
58+
className={`flex-1 px-4 py-3 text-sm font-medium transition-colors cursor-pointer ${
59+
path === p
60+
? "bg-primary-500/10 text-primary-600 dark:text-primary-400 border-b-2 border-primary-500"
61+
: "text-fd-muted-foreground hover:text-fd-foreground"
62+
}`}
63+
>
64+
/{p}
65+
</button>
66+
))}
67+
</div>
68+
69+
{/* Form */}
70+
<div className="p-4 space-y-3">
71+
{path === "create" ? (
72+
<div>
73+
<label className="block text-sm font-medium text-fd-foreground mb-1">
74+
下载链接
75+
</label>
76+
<input
77+
type="text"
78+
value={createUrl}
79+
onChange={(e) => setCreateUrl(e.target.value)}
80+
className="w-full px-3 py-2 rounded-lg border border-fd-border bg-fd-secondary text-sm text-fd-foreground focus:outline-none focus:ring-2 focus:ring-primary-500/30 focus:border-primary-500"
81+
placeholder="https://example.com/file.zip"
82+
/>
83+
</div>
84+
) : (
85+
<>
86+
<div>
87+
<label className="block text-sm font-medium text-fd-foreground mb-1">
88+
扩展地址
89+
</label>
90+
<input
91+
type="text"
92+
value={extUrl}
93+
onChange={(e) => setExtUrl(e.target.value)}
94+
className="w-full px-3 py-2 rounded-lg border border-fd-border bg-fd-secondary text-sm text-fd-foreground focus:outline-none focus:ring-2 focus:ring-primary-500/30 focus:border-primary-500"
95+
placeholder="https://github.com/user/gopeed-extension-example"
96+
/>
97+
</div>
98+
<div className="flex items-center gap-2">
99+
<input
100+
type="checkbox"
101+
id="devMode"
102+
checked={extDevMode}
103+
onChange={(e) => setExtDevMode(e.target.checked)}
104+
className="rounded border-fd-border text-primary-500 focus:ring-primary-500/30"
105+
/>
106+
<label htmlFor="devMode" className="text-sm text-fd-foreground">
107+
开发模式
108+
</label>
109+
</div>
110+
</>
111+
)}
112+
</div>
113+
114+
{/* Params preview */}
115+
<div className="px-4 pb-3">
116+
<label className="block text-xs font-medium text-fd-muted-foreground mb-1">
117+
params 解码内容
118+
</label>
119+
<pre className="text-xs bg-fd-secondary rounded-lg p-3 overflow-x-auto text-fd-muted-foreground">
120+
{paramJson}
121+
</pre>
122+
</div>
123+
124+
{/* Generated URI */}
125+
<div className="px-4 pb-4">
126+
<label className="block text-xs font-medium text-fd-muted-foreground mb-1">
127+
生成的 URI
128+
</label>
129+
<div className="[&_figure]:my-0">
130+
<SchemeUriBlock uri={generatedUri} />
131+
</div>
132+
</div>
133+
</div>
134+
);
135+
}

components/home/SeoFaq.tsx

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"use client";
2+
3+
import { ChevronDownIcon } from "@heroicons/react/24/outline";
4+
import { useState } from "react";
15
import type { Locale } from "@/lib/i18n";
26
import { getVisibleFaqEntries } from "@/lib/keyword-pages";
37

@@ -9,10 +13,22 @@ const sectionTitle: Record<Locale, string> = {
913
en: "Download Manager FAQ",
1014
zh: "下载器常见问题",
1115
"zh-TW": "下載器常見問題",
16+
ja: "ダウンロードマネージャー FAQ",
17+
ko: "다운로드 매니저 FAQ",
18+
es: "Preguntas frecuentes sobre el gestor de descargas",
19+
pt: "Perguntas frequentes sobre o gerenciador de downloads",
20+
fr: "FAQ du gestionnaire de téléchargement",
21+
de: "Download-Manager FAQ",
22+
ru: "Часто задаваемые вопросы о менеджере загрузок",
1223
};
1324

1425
export function SeoFaq({ locale }: SeoFaqProps) {
1526
const entries = getVisibleFaqEntries(locale);
27+
const [openIndex, setOpenIndex] = useState<number | null>(null);
28+
29+
const toggle = (index: number) => {
30+
setOpenIndex(openIndex === index ? null : index);
31+
};
1632

1733
return (
1834
<section
@@ -25,20 +41,44 @@ export function SeoFaq({ locale }: SeoFaqProps) {
2541
{sectionTitle[locale]}
2642
</h2>
2743

28-
<div className="space-y-4">
29-
{entries.map((entry) => (
30-
<div
31-
key={entry.question}
32-
className="rounded-2xl border border-gray-200/70 dark:border-gray-800/70 bg-white/90 dark:bg-gray-900/80 p-6"
33-
>
34-
<h3 className="text-lg font-semibold text-gray-900 dark:text-white mb-3">
35-
{entry.question}
36-
</h3>
37-
<p className="text-gray-600 dark:text-gray-400 leading-7">
38-
{entry.answer}
39-
</p>
40-
</div>
41-
))}
44+
<div className="space-y-3">
45+
{entries.map((entry, index) => {
46+
const isOpen = openIndex === index;
47+
return (
48+
<div
49+
key={entry.question}
50+
className="rounded-2xl border border-gray-200/70 dark:border-gray-800/70 bg-white/90 dark:bg-gray-900/80 overflow-hidden"
51+
>
52+
<button
53+
onClick={() => toggle(index)}
54+
className="w-full flex items-center justify-between p-6 text-left cursor-pointer"
55+
aria-expanded={isOpen}
56+
>
57+
<h3 className="text-lg font-semibold text-gray-900 dark:text-white pr-4">
58+
{entry.question}
59+
</h3>
60+
<ChevronDownIcon
61+
className={`h-5 w-5 shrink-0 text-gray-400 dark:text-gray-500 transition-transform duration-200 ${
62+
isOpen ? "rotate-180" : ""
63+
}`}
64+
/>
65+
</button>
66+
<div
67+
className={`grid transition-all duration-200 ease-in-out ${
68+
isOpen
69+
? "grid-rows-[1fr] opacity-100"
70+
: "grid-rows-[0fr] opacity-0"
71+
}`}
72+
>
73+
<div className="overflow-hidden">
74+
<p className="px-6 pb-6 text-gray-600 dark:text-gray-400 leading-7">
75+
{entry.answer}
76+
</p>
77+
</div>
78+
</div>
79+
</div>
80+
);
81+
})}
4282
</div>
4383
</div>
4484
</div>

content/docs/de/dev-api.mdx

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: API-Integration
3+
description: Verwenden Sie die Gopeed HTTP-API und offiziellen SDKs, um Download-Aufgaben zu erstellen und zu verwalten.
4+
---
5+
6+
Gopeed bietet eine HTTP-API-Schnittstelle für die externe Nutzung, die eine Download-Verwaltung über die API ermöglicht.
7+
8+
## API aktivieren
9+
10+
Zunächst müssen Sie das Kommunikationsprotokoll auf TCP einstellen. Gehen Sie zu **Einstellungen -> Erweitert -> Kommunikationsprotokoll** und setzen Sie das Kommunikationsprotokoll auf TCP. Legen Sie dann die IP und den Port fest, wie in der folgenden Abbildung gezeigt:
11+
12+
![](/images/dev/set-port.png)
13+
14+
<Callout type="info">
15+
Sie können einen beliebigen `Port` festlegen, beachten Sie jedoch, dass Sie keine Ports verwenden
16+
sollten, die bereits in Verwendung sind oder vom System reserviert wurden, da dies zu
17+
Zugriffsfehlern führen kann.
18+
</Callout>
19+
20+
Anschließend können Sie über `http://127.0.0.1:9999` auf die API zugreifen. Aus Sicherheitsgründen wird empfohlen, ein Token festzulegen. Gehen Sie zu **Einstellungen -> Erweitert -> API-Token** und setzen Sie ein Token, wie in der folgenden Abbildung gezeigt:
21+
22+
![](/images/dev/set-token.png)
23+
24+
> Hinweis: Die obigen Einstellungen werden nach einem Neustart wirksam.
25+
26+
## JS SDK verwenden
27+
28+
Gopeed bietet eine offizielle JS-Bibliothek, die zunächst mit `npm install @gopeed/rest` installiert werden muss:
29+
30+
```
31+
npm install @gopeed/rest
32+
```
33+
34+
Danach können Sie sie verwenden, zum Beispiel:
35+
36+
```js
37+
import { Client } from "@gopeed/rest";
38+
39+
(async function () {
40+
// Client erstellen
41+
const client = new Client();
42+
// Aufgabe erstellen
43+
const res = await client.createTask({
44+
req: {
45+
url: "https://example.com/file.zip",
46+
},
47+
});
48+
})();
49+
```
50+
51+
Weitere Verwendungsbeispiele, Quellcode und Paketaktualisierungen finden Sie im [offiziellen Gopeed JS-Repository](https://github.com/GopeedLab/gopeed-js).
52+
53+
## Python SDK verwenden
54+
55+
Ein Python SDK, bereitgestellt vom Community-Mitglied [@tick97115115](https://github.com/tick97115115).
56+
57+
```bash
58+
pip install gospeed_api
59+
```
60+
61+
- Github:https://github.com/tick97115115/gospeed_api
62+
- Beispiel:https://github.com/tick97115115/gospeed_api/blob/main/tests/test_index.py
63+
64+
## HTTP API verwenden
65+
66+
Natürlich können Sie die API auch direkt über HTTP-Anfragen aufrufen. Details finden Sie in der [API-Dokumentation](/docs/openapi).

0 commit comments

Comments
 (0)