Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
feat: 仅启用开屏广告
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Dec 6, 2023
1 parent 5a6df72 commit 303f1f8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 36 deletions.
12 changes: 1 addition & 11 deletions Template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @gkd-kit/subscription

GKD 默认订阅规则
GKD 默认订阅规则, 默认规则仅启用 `开屏广告` 一类规则, 其它所有规则均需用户手动打开

当前订阅为 APP 自带, 无需手动添加, 当前版本: v--VERSION--

Expand All @@ -13,13 +13,3 @@ GKD 默认订阅规则
## 感谢以下开发者的贡献

![img](https://contrib.rocks/image?repo=gkd-kit/subscription&_v=--VERSION--)

## 其它

本仓库额外构建了一个仅启用 开屏广告 规则的订阅

你可以将默认订阅删除后, 添加此订阅, 订阅链接如下

```txt
https://registry.npmmirror.com/@gkd-kit/subscription/latest/files/dist/gkd.openad.json
```
1 change: 0 additions & 1 deletion dist/gkd.openad.json

This file was deleted.

5 changes: 5 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ for await (const tsFp of walk(process.cwd() + '/src/apps')) {
)} `,
);
}
appConfig.groups?.forEach((g) => {
if (!g.name.startsWith('开屏广告')) {
g.enable = false;
}
});
apps.push(appConfig);
}

Expand Down
25 changes: 1 addition & 24 deletions src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,6 @@ export const writeConfig = async (config: SubscriptionConfig) => {
const buffer = Buffer.from(orderdStringify5(newConfig, sortKeys), 'utf-8');
await fs.writeFile(gkdFp, buffer);

// update gkd.openad.json
const onlyOpenAdConfig = _.cloneDeep(newConfig);
onlyOpenAdConfig.apps.forEach((a) => {
a.groups?.forEach((g) => {
g.enable = g.name.startsWith('开屏广告');
});
});
await fs.writeFile(
process.cwd() + '/dist/gkd.openad.json',
orderdStringify(onlyOpenAdConfig, sortKeys),
'utf-8',
);

// update gkd.version.json
await fs.writeFile(
versionFp,
Expand Down Expand Up @@ -439,17 +426,7 @@ export const updateReadMeMd = async (
newConfig.apps
.map((app) => {
const groups = app.groups || [];
const diabledSize = _.sumBy(groups, (g) =>
g.enable === false ? 1 : 0,
);

return `| ${app.name} | [${app.id}](/docs/${app.id}.md) | ${
diabledSize
? `${groups.length}/${
groups.length - diabledSize
}启用/${diabledSize}禁用`
: groups.length
} |`;
return `| ${app.name} | [${app.id}](/docs/${app.id}.md) | ${groups.length} |`;
})
.join('\n');
const mdTemplate = await fs.readFile(process.cwd() + '/Template.md', 'utf-8');
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ export type GroupConfig = {

/**
* 控制规则默认情况下是启用还是禁用, 默认启用
*
* 仅对于本仓库的规则而言, 除开屏广告外, 其它规则默认禁用
*/
enable?: boolean;

Expand Down

0 comments on commit 303f1f8

Please sign in to comment.