feat: 仅启用开屏广告

This commit is contained in:
lisonge
2023-12-06 10:17:00 +08:00
parent 5a6df72ad6
commit 303f1f8f38
5 changed files with 9 additions and 36 deletions

View File

@@ -1,6 +1,6 @@
# @gkd-kit/subscription
GKD 默认订阅规则
GKD 默认订阅规则, 默认规则仅启用 `开屏广告` 一类规则, 其它所有规则均需用户手动打开
当前订阅为 APP 自带, 无需手动添加, 当前版本: v--VERSION--
@@ -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
```

File diff suppressed because one or more lines are too long

View File

@@ -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);
}

View File

@@ -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,
@@ -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');

View File

@@ -176,6 +176,8 @@ export type GroupConfig = {
/**
* 控制规则默认情况下是启用还是禁用, 默认启用
*
* 仅对于本仓库的规则而言, 除开屏广告外, 其它规则默认禁用
*/
enable?: boolean;