Skip to content

Commit

Permalink
feat: import way
Browse files Browse the repository at this point in the history
  • Loading branch information
adproqwq committed Apr 5, 2024
1 parent 8e8c3a6 commit 9f81975
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
14 changes: 11 additions & 3 deletions Template.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ Fork 本仓库的 `main`分支。
```
的李跳跳规则填写进入`ltt.json`,然后运行 github action 里的 `convert`

运行成功后,转换结果会出现在`-2.json`
运行成功后,转换结果会出现在`-1.json`

然后参照[教程](https://ltt2gkd.adproqwq.xyz/tutoril.html)导入GKD,

当然,你也可以使用开源仓库、Github gist的方式导入。

由于hash的不可逆性,部分规则会因无法获取具体的应用信息,而被抛弃,具体抛弃数量可以查看`log.txt`

Expand Down Expand Up @@ -52,7 +56,11 @@ pnpm i
pnpm convert
```

运行成功后,转换结果会出现在`-2.json`
运行成功后,转换结果会出现在`-1.json`

然后参照[教程](https://ltt2gkd.adproqwq.xyz/tutoril.html)导入GKD,

当然,你也可以使用开源仓库、Github gist的方式导入。

由于hash的不可逆性,部分规则会因无法获取具体的应用信息,而被抛弃,具体抛弃数量可以查看`log.txt`

Expand Down Expand Up @@ -96,7 +104,7 @@ pnpm run list

当前收录应用 --APPCOUNT-- 个,其中,添加应用补丁 --PATCHCOUNT-- 个。

注意:其中包含大量 OPPO、小米等 手机品牌和安卓系统的系统应用~~所以只是看起来多~~
注意:其中包含大量各手机品牌和安卓系统的系统应用~~所以只是看起来多~~

## 致谢

Expand Down
12 changes: 4 additions & 8 deletions src/convert.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json5 from 'json5';
import { RawSubscription, RawApp, RawAppGroup, RawAppRule, IArray } from '@gkd-kit/api';
import { Root } from './types';
import { RawApp, RawAppGroup, RawAppRule, IArray } from '@gkd-kit/api';
import { Root, Subscription } from './types';
import { getJsonArrayLength, iArrayToArray, textRuleConvert, boundsRuleConvert } from './method'
import fs from 'node:fs/promises';

Expand All @@ -15,11 +15,7 @@ const convert = async () => {
const originLength = getJsonArrayLength(origin);
let throwCount = 0;

let thisSub: RawSubscription = {
id: -2,
name: '本地订阅',
version: 1,
author: 'gkd',
let thisSub: Subscription = {
globalGroups: [],
categories: [],
apps: [],
Expand Down Expand Up @@ -115,6 +111,6 @@ const convert = async () => {

await fs.writeFile(process.cwd() + '/log.txt', `共识别到应用${originLength}个,已抛弃${throwCount}个未知应用的规则`);

await fs.writeFile(process.cwd() + '/-2.json', JSON.stringify(thisSub));
await fs.writeFile(process.cwd() + '/-1.json', JSON.stringify(thisSub));
};
convert();
12 changes: 10 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
export type Root = RawApp[];
import { RawGlobalGroup ,RawCategory, RawApp } from "@gkd-kit/api";

export type Root = RawAppConfig[];

export type PatchApps = RawPatchApp[];

export type LogApps = LogRawApp[];

export type RawApp = {
export type Subscription = {
globalGroups: RawGlobalGroup[],
categories: RawCategory[],
apps: RawApp[],
};

export type RawAppConfig = {
/**
* 应用包名
*/
Expand Down

0 comments on commit 9f81975

Please sign in to comment.