Skip to content

Commit 5f36e80

Browse files
committed
Update docs
1 parent ee02e04 commit 5f36e80

File tree

6 files changed

+141
-12
lines changed

6 files changed

+141
-12
lines changed

en/guide/index.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,3 @@ The applications based on this project are neither VPN nor proxy applications. T
6868
- <CheckBox /> Better installation and upgrade experience on macOS and GNU/Linux
6969

7070
- <CheckBox checked /> Rewrite some functions for GUI.for.SingBox
71-
72-
- <CheckBox /> GUI applications for Android™

zh/guide/02-uninstall.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44

55
1、请再次运行程序、取消一些设置
66

7-
在设置里关闭`以管理员身份运行`,关闭`开机时启动`
7+
在设置里关闭`以管理员身份运行`(如果开启过),关闭`开机时启动`(如果开启过)。
8+
9+
> 这一步是为了删除注册表、清除计划任务。
810
911
然后彻底退出程序,包括关闭 core 的运行。
1012

1113
2、 删除目录:`%APPDATA%\[BinaryName.exe]`
1214

1315
BinaryName 是程序的名称。
1416

17+
> 这一步是为了删除 Webview2 运行产生的缓存文件。
18+
1519
3、删除`data`目录(可保留)
1620

1721
data 目录与程序同级,是程序运行时生成的,存放着 core 二进制文件、订阅文件、配置文件、规则集文件、插件文件、计划任务文件。

zh/guide/03-how-it-works.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 运行原理
22

3-
下面从程序的正常使用流程来介绍程序的运行原理
3+
> GUI 维护自己的一套配置文件(保存位置 data/profiles.yaml),是对 core 配置文件的进一步包装。这样做的好处是你不必再理会 core 的 breaking change(破坏性修改),因为 GUI 会处理这一切,包括配置文件的自动升级、以及生成适用于稳定版、测试版的配置
44
55
## 1、快速开始
66

@@ -12,15 +12,13 @@
1212

1313
3. 拉取订阅,更新上一步的订阅信息,读取节点,保存到 `subscribes/ID_xxxxxx.yaml`文件,文件以随机 ID 命名。
1414

15-
4. 如果拉取订阅成功,则提示初始化完成,此时可以启动内核程序,如果拉取订阅失败,则需要手动到`订阅`菜单里更新对应的订阅。
16-
1715
## 2、运行配置
1816

1917
选中一个配置,点击`启动内核`按钮,GUI 会根据当前的配置生成一份 `config.yaml``config.json` 文件,然后调用内核程序运行。如果你创建了多个配置,也可以在`配置`页面,右键某个配置,在更多里选择`使用此配置启动/重启`。排列顺序靠前的会展示在`概览`页,概览页最多展示`4`个配置。
2018

2119
## 3、配置系统代理
2220

23-
默认的设置下,GUI 不会主动的为你设置系统代理,当你点击主页的`系统代理`按钮时,GUI 会从配置中获取 http 代理端口、混合代理端口,并选择一个将其设置为系统代理,混合代理端口总是优先于 http 代理端口。
21+
GUI 的设计理念是不主动修改你系统的任何设置,除非得到你的授权。当你点击主页的`系统代理`按钮时,GUI 会从配置中获取 http 代理端口、混合代理端口,并选择一个将其设置为系统代理,混合代理端口总是优先于 http 代理端口。
2422

2523
## 4、TUN 模式
2624

zh/guide/04-plugins.md

Lines changed: 133 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
- `手动触发`:点击运行按钮时会被触发,GUI 会执行源码中的 `onRun` 方法。
2222

23-
- `更新订阅时`:更新订阅时会被触发,GUI 会执行源码中的 `onSubscribe` 方法,并传递一个参数,其值是节点列表数组。此方法需要返回一个节点列表的数组。
23+
- `更新订阅时`:更新订阅时会被触发,GUI 会执行源码中的 `onSubscribe` 方法,并传递 2 个参数,分别是节点列表数组、订阅元数据。此方法需要返回一个节点列表的数组。
2424

25-
- `生成配置时`:生成配置文件时会被触发,GUI 会执行源码中的 `onGenerate` 方法,并传递一个参数,其值是一个对象,里面包含了 core 的配置,此方法需要将处理后的参数返回,或原样返回。
25+
- `生成配置时`:生成配置文件时会被触发,GUI 会执行源码中的 `onGenerate` 方法,并传递 2 个参数,分别是 core 的配置、配置元数据,此方法需要将处理后的参数返回,或原样返回。
2626

2727
- `启动 APP 时`:启动 APP 时会被触发,GUI 会执行源码中的 `onStartup` 方法,没有传递参数,此方法无需返回任何值。
2828

@@ -216,6 +216,137 @@ const onShutdown = () => {
216216

217217
在上面我们演示了 Plugins.message、Plugins.HttpGet,那么插件对象 Plugins 还有哪些能力呢,你可以在软件界面按下 Ctrl+Shift+F12 打开开发者面板,切换到控制台,输入 Plugins 并回车查看,具体的使用示例可以看源码。
218218

219+
## 高级 API
220+
221+
### 1、添加自定义 UI
222+
223+
现在,你可以使用 `addCustomActions` 方法在 GUI 中添加自定义操作。
224+
225+
方法签名:
226+
227+
```ts
228+
interface CustomActionApi {
229+
h: typeof h;
230+
ref: typeof ref;
231+
}
232+
type CustomActionProps = Recordable;
233+
type CustomActionSlots = Recordable<
234+
| ((api: CustomActionApi) => VNode | string | number | boolean)
235+
| VNode
236+
| string
237+
| number
238+
| boolean
239+
>;
240+
interface CustomAction<P = CustomActionProps, S = CustomActionSlots> {
241+
id?: string;
242+
component: string;
243+
componentProps?: P | ((api: CustomActionApi) => P);
244+
componentSlots?: S | ((api: CustomActionApi) => S);
245+
}
246+
type CustomActionFn = ((api: CustomActionApi) => CustomAction) & {
247+
id?: string;
248+
};
249+
250+
function addCustomActions(
251+
target: string,
252+
actions: CustomAction | CustomAction[] | CustomActionFn | CustomActionFn[]
253+
): () => void;
254+
```
255+
256+
参数说明:
257+
258+
- target: 目标位置,目前可选值为`core_state`,表示添加的概览页的`核心状态`面板中
259+
260+
- actions: 组件列表,通过对象配置或方法返回对象配置
261+
262+
使用示例
263+
264+
```js
265+
const appStore = Plugins.useAppStore();
266+
267+
// 添加单个组件:按钮
268+
appStore.addCustomActions("core_state", {
269+
component: "Button",
270+
componentProps: {
271+
type: "link",
272+
size: "small",
273+
},
274+
componentSlots: {
275+
default: "一个按钮",
276+
},
277+
});
278+
279+
// 添加多个组件:开关、计数器
280+
appStore.addCustomActions("core_state", [
281+
{
282+
component: "Switch",
283+
componentProps: ({ ref }) => {
284+
const checked = ref(false);
285+
return {
286+
modelValue: checked.value,
287+
onChange: (val) => {
288+
checked.value = val;
289+
console.log(val, checked.value);
290+
},
291+
};
292+
},
293+
componentSlots: {
294+
default: "一个开关",
295+
},
296+
},
297+
({ h, ref }) => {
298+
const count = ref(0);
299+
return {
300+
component: "Button",
301+
componentProps: {
302+
type: "link",
303+
size: "small",
304+
onClick: () => (count.value += 1),
305+
},
306+
componentSlots: {
307+
default: () => "+" + count.value,
308+
},
309+
};
310+
},
311+
]);
312+
```
313+
314+
注:`componentProps``componentSlots`以及`actions`数组项可以是对象也可以是方法,方法时需返回`CustomAction`结构的对象。
315+
316+
- 可用的 component 取值:所有 HTML 元素、[组件库](https://github.com/GUI-for-Cores/GUI.for.SingBox/tree/main/frontend/src/components)下的组件。
317+
318+
- 可用的 componentProps 取值:所有的 HTML 属性、[组件库](https://github.com/GUI-for-Cores/GUI.for.SingBox/tree/main/frontend/src/components)中组件支持的属性(Props)
319+
320+
- 可用的 componentSlots 取值:default、[组件库](https://github.com/GUI-for-Cores/GUI.for.SingBox/tree/main/frontend/src/components)中组件支持的插槽(Slots)
321+
322+
- 可用的 CustomActionApi 取值:ref(Vue 中定义响应式变量的 API)、h(Vue 中定义 Vnode 的 API)
323+
324+
### 2、移除自定义 UI
325+
326+
方法签名:
327+
328+
```ts
329+
function removeCustomActions(target: string, id: string | string[]): void;
330+
```
331+
332+
使用示例
333+
334+
```js
335+
const appStore = Plugins.useAppStore();
336+
337+
const remove = appStore.addCustomActions('core_state', {
338+
id: 'first-action'
339+
component: 'xxx',
340+
// ...
341+
})
342+
343+
// 方式1:通过添加时指定的id删除
344+
appStore.removeCustomActions("core_state", 'first-action');
345+
346+
// 方法2:通过添加时返回的删除方法删除
347+
remove()
348+
```
349+
219350
## 更多的示例
220351

221352
```javascript

zh/guide/gfc/how-to-use.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
![](/zh/resources/gfc/207_how_to_use.png)
2424

25-
默认设置下,GUI 不会改变你系统的任何设置,所以你需要手动开启`系统代理`,当然也可以在`设置`里打开`自动配置系统代理`,如果想使用 TUN 模式,则需要打开`以管理员身份运行`TUN 模式和系统代理应该保证只有一个处于开启状态。
25+
默认设置下,GUI 不会改变你系统的任何设置,所以你需要手动开启`系统代理`,当然也可以在`设置`里打开`自动配置系统代理`,如果想使用 TUN 模式,则需要打开`以管理员身份运行`
2626

2727
![](/zh/resources/gfc/208_how_to_use.png)
2828

zh/guide/index.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,3 @@ GUI.for.Cores 项目旨在快速生成 core 的配置文件,并将其参数以
6868
- <CheckBox /> 优化 macOS、 GNU/Linux 下的安装升级体验
6969

7070
- <CheckBox checked /> 重构 GUI.for.SingBox 的部分功能
71-
72-
- <CheckBox /> 开发安卓端的 GUI 系列

0 commit comments

Comments
 (0)