Skip to content

Commit aa4b514

Browse files
committed
fix: broken links
Signed-off-by: 82Flex <82flex@gmail.com>
1 parent 10239c1 commit aa4b514

5 files changed

Lines changed: 37 additions & 16 deletions

File tree

docusaurus.config.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,34 @@ import type * as Preset from '@docusaurus/preset-classic';
44

55
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
66
function getSiteTagline() {
7-
switch(process.env.DOCUSAURUS_CURRENT_LOCALE) {
7+
switch (process.env.DOCUSAURUS_CURRENT_LOCALE) {
88
case "zh-Hans": return "强大而灵活的 iOS 自动化工具 —— 经典传承,始于 2015 年。";
99
default: return "Powerful and flexible automation tool for iOS since 2015.";
1010
}
1111
}
1212

13-
function getEditUrl(type: 'docs' | 'blog' | 'pages') {
14-
switch(process.env.DOCUSAURUS_CURRENT_LOCALE) {
15-
case "zh-Hans": return `https://github.com/OwnGoalStudio/XXTouchElite/tree/main/i18n/zh-Hans/docusaurus-plugin-content-${type}/`;
16-
default: return "https://github.com/OwnGoalStudio/XXTouchElite/tree/main/";
13+
function getEditUrl(params: {versionDocsDirPath: string, docPath: string, permalink: string, locale: string}) {
14+
const rootPath = "https://github.com/OwnGoalStudio/XXTouchElite/tree/main";
15+
if (params.locale == "en") {
16+
return `${rootPath}/${params.versionDocsDirPath}/${params.docPath}`;
1717
}
18+
return `${rootPath}/i18n/${params.locale}/docusaurus-plugin-content-docs/current/${params.docPath}`;
19+
}
20+
21+
function getBlogEditUrl(params: {blogDirPath: string, blogPath: string, permalink: string, locale: string}) {
22+
const rootPath = "https://github.com/OwnGoalStudio/XXTouchElite/tree/main";
23+
if (params.locale == "en") {
24+
return `${rootPath}/${params.blogDirPath}/${params.blogPath}`;
25+
}
26+
return `${rootPath}/i18n/${params.locale}/docusaurus-plugin-content-blog/${params.blogPath}`;
27+
}
28+
29+
function getPagesEditUrl(params: {pagesDirPath: string, pagesPath: string, permalink: string, locale: string}) {
30+
const rootPath = "https://github.com/OwnGoalStudio/XXTouchElite/tree/main";
31+
if (params.locale == "en") {
32+
return `${rootPath}/${params.pagesDirPath}/${params.pagesPath}`;
33+
}
34+
return `${rootPath}/i18n/${params.locale}/docusaurus-plugin-content-pages/${params.pagesPath}`;
1835
}
1936

2037
const config: Config = {
@@ -60,7 +77,7 @@ const config: Config = {
6077
showLastUpdateTime: true,
6178
// Please change this to your repo.
6279
// Remove this to remove the "edit this page" links.
63-
editUrl: getEditUrl('docs'),
80+
editUrl: getEditUrl,
6481
},
6582
blog: {
6683
showReadingTime: true,
@@ -71,12 +88,16 @@ const config: Config = {
7188
},
7289
// Please change this to your repo.
7390
// Remove this to remove the "edit this page" links.
74-
editUrl: getEditUrl('blog'),
91+
editUrl: getBlogEditUrl,
7592
// Useful options to enforce blogging best practices
7693
onInlineTags: 'ignore',
7794
onInlineAuthors: 'warn',
7895
onUntruncatedBlogPosts: 'warn',
7996
},
97+
pages: {
98+
showLastUpdateTime: true,
99+
editUrl: getPagesEditUrl,
100+
},
80101
theme: {
81102
customCss: './src/css/custom.css',
82103
},

i18n/zh-Hans/docusaurus-plugin-content-docs/current/lua-manual/appendix/command-line-tools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ remote-access.lua [on|off]
191191

192192
#### 说明
193193

194-
效果等同于 [打开远程访问](../../tutorial/ready-to-develop.md#enable-remote-access)
194+
效果等同于 [打开远程访问](../../tutorial/ready-to-develop.md#启用远程访问)
195195

196196
#### 示例
197197

i18n/zh-Hans/docusaurus-plugin-content-docs/current/lua-manual/appendix/process-scheduling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ notify_post(通知名称)
248248
#### 参数及返回值
249249

250250
- 通知名称 *文本型*
251-
- `ch.xxtou.notification.remote-access.on`[打开远程访问](../../tutorial/ready-to-develop.md#enable-remote-access)
251+
- `ch.xxtou.notification.remote-access.on`[打开远程访问](../../tutorial/ready-to-develop.md#启用远程访问)
252252
- `ch.xxtou.notification.remote-access.off`:关闭远程访问
253253
- `ch.xxtou.notification.restart`:立即结束脚本,并重启 XXTouch Elite 守护进程
254254
- `ch.xxtou.notification.boom`:立即结束脚本,并卸载 XXTouch Elite

i18n/zh-Hans/docusaurus-plugin-content-docs/current/lua-manual/screen.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ end
351351
使用相似度模式查找(模式匹配),获取区域中第一个完全匹配的多点颜色结构(模式)的位置。
352352

353353
:::note 不会吧,不会吧
354-
不会有人[手写这个匹配表](../tutorial/make-some-notes.md#find-new-note-button)吧?
354+
不会有人[手写这个匹配表](../tutorial/make-some-notes.md#找到-新建笔记-按钮)吧?
355355
:::
356356

357357
#### 示例

i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorial/make-some-notes.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ sidebar_position: 5
1616

1717
## 打开 “备忘录”
1818

19-
我们需要做的第一件事是打开 “备忘录” 应用。为此,我们将使用 [`app.run`](../lua-manual/app.md#run-the-app-apprun) 函数。[`app.run`](../lua-manual/app.md#run-the-app-apprun) 函数接受一个字符串作为参数,该字符串是我们想要打开的应用的包标识符。在我们的例子中,我们想要打开 “备忘录” 应用,因此我们将使用字符串 `"com.apple.mobilenotes"`
19+
我们需要做的第一件事是打开 “备忘录” 应用。为此,我们将使用 [`app.run`](../lua-manual/app.md#运行-app-apprun) 函数。[`app.run`](../lua-manual/app.md#运行-app-apprun) 函数接受一个字符串作为参数,该字符串是我们想要打开的应用的包标识符。在我们的例子中,我们想要打开 “备忘录” 应用,因此我们将使用字符串 `"com.apple.mobilenotes"`
2020

2121
```lua
2222
nLog("Open Notes...")
@@ -35,7 +35,7 @@ app.run("com.apple.mobilenotes")
3535

3636
## 找到 “新建笔记” 按钮
3737

38-
现在我们已经打开了 “备忘录” 应用,我们需要找到 “新建笔记” 按钮。为此,我们将使用 [`screen.find_color`](../lua-manual/screen.md#-multi-point-similarity-mode-color-finding-screenfind_color) 函数。[`screen.find_color`](../lua-manual/screen.md#-multi-point-similarity-mode-color-finding-screenfind_color) 函数接受一个颜色表作为参数,这是我们想要找到的颜色样本的集合。
38+
现在我们已经打开了 “备忘录” 应用,我们需要找到 “新建笔记” 按钮。为此,我们将使用 [`screen.find_color`](../lua-manual/screen.md#-多点相似度模式找色-screenfind_color) 函数。[`screen.find_color`](../lua-manual/screen.md#-多点相似度模式找色-screenfind_color) 函数接受一个颜色表作为参数,这是我们想要找到的颜色样本的集合。
3939

4040
![Make_Notes](./img/Make_Notes.gif)
4141

@@ -66,9 +66,9 @@ touch.tap(x, y)
6666
sys.sleep(2)
6767
```
6868

69-
这里我们向颜色表中添加了 6 个颜色样本。使用 `while ... do` 循环不断搜索按钮,直到找到为止。[`sys.sleep(1)`](../lua-manual/sys.md#-second-level-delay-syssleep) 函数用于在再次搜索之前暂停脚本 1 秒。
69+
这里我们向颜色表中添加了 6 个颜色样本。使用 `while ... do` 循环不断搜索按钮,直到找到为止。[`sys.sleep(1)`](../lua-manual/sys.md#-秒级延迟-syssleep) 函数用于在再次搜索之前暂停脚本 1 秒。
7070

71-
[`screen.find_color`](../lua-manual/screen.md#-multi-point-similarity-mode-color-finding-screenfind_color) 函数返回按钮的坐标(如果找到),或者返回 `nil`(如果未找到)。我们将使用这些坐标与 [`touch.tap`](../lua-manual/touch.md#simulate-a-single-tap-on-the-screen-touchtap) 一起点击按钮。
71+
[`screen.find_color`](../lua-manual/screen.md#-多点相似度模式找色-screenfind_color) 函数返回按钮的坐标(如果找到),或者返回 `nil`(如果未找到)。我们将使用这些坐标与 [`touch.tap`](../lua-manual/touch.md#模拟手指轻触一次屏幕-touchtap) 一起点击按钮。
7272

7373
:::tip
7474
制作颜色样本并不容易。以下是一些实用技巧:
@@ -81,7 +81,7 @@ sys.sleep(2)
8181

8282
## 输入 “Hello, World!”
8383

84-
向 “备忘录” 应用发送文本是最简单的部分。我们可以使用 [`key.send_text`](../lua-manual/key.md#simulate-typing-text-keysend_text) 函数向应用发送文本。[`key.send_text`](../lua-manual/key.md#simulate-typing-text-keysend_text) 函数接受一个字符串作为参数,这是我们想要发送的文本。
84+
向 “备忘录” 应用发送文本是最简单的部分。我们可以使用 [`key.send_text`](../lua-manual/key.md#模拟键入文本-keysend_text) 函数向应用发送文本。[`key.send_text`](../lua-manual/key.md#模拟键入文本-keysend_text) 函数接受一个字符串作为参数,这是我们想要发送的文本。
8585

8686
```lua
8787
nLog("Enter text…")
@@ -94,7 +94,7 @@ key.send_text("Hello, world!")
9494

9595
## 点击 “完成”
9696

97-
最后,我们需要点击 “完成” 按钮以保存笔记。我们可以使用 [`screen.ocr_text`](../lua-manual/screen.md#-screen-optical-character-recognition-screenocr_text) 函数找到 “完成” 按钮,然后使用 [`touch.tap`](../lua-manual/touch.md#simulate-a-single-tap-on-the-screen-touchtap) 点击它。这部分有点棘手,因为文本容易受到字体和大小的影响,因此我们需要使用 OCR(光学字符识别)来找到它。
97+
最后,我们需要点击 “完成” 按钮以保存笔记。我们可以使用 [`screen.ocr_text`](../lua-manual/screen.md#-屏幕光学字符识别-screenocr_text) 函数找到 “完成” 按钮,然后使用 [`touch.tap`](../lua-manual/touch.md#模拟手指轻触一次屏幕-touchtap) 点击它。这部分有点棘手,因为文本容易受到字体和大小的影响,因此我们需要使用 OCR(光学字符识别)来找到它。
9898

9999
**以下是我们的最终脚本:**
100100

0 commit comments

Comments
 (0)