mirror of
https://github.com/AIsouler/GKD_subscription.git
synced 2025-12-20 16:54:43 +08:00
feat: 规则分类+全局规则组
This commit is contained in:
@@ -2,13 +2,15 @@ import path from 'node:path';
|
||||
import url from 'node:url';
|
||||
import picocolors from 'picocolors';
|
||||
import { walk } from './file';
|
||||
import type { AppConfig, AppConfigMudule, SubscriptionConfig } from './types';
|
||||
import type { RawApp, RawSubscription } from './types';
|
||||
import _ from 'lodash';
|
||||
import { pinyin } from 'pinyin-pro';
|
||||
import globalGroups from './globalGroups';
|
||||
import categories from './categories';
|
||||
|
||||
const apps: AppConfig[] = [];
|
||||
const apps: RawApp[] = [];
|
||||
for await (const tsFp of walk(process.cwd() + '/src/apps')) {
|
||||
const mod: AppConfigMudule = await import(url.pathToFileURL(tsFp).href);
|
||||
const mod: { default: RawApp } = await import(url.pathToFileURL(tsFp).href);
|
||||
const appConfig = mod.default;
|
||||
if (path.basename(tsFp, '.ts') != appConfig.id) {
|
||||
throw new Error(
|
||||
@@ -27,16 +29,23 @@ for await (const tsFp of walk(process.cwd() + '/src/apps')) {
|
||||
apps.push(appConfig);
|
||||
}
|
||||
|
||||
const subsConfig: SubscriptionConfig = {
|
||||
const subsConfig: RawSubscription = {
|
||||
id: 0,
|
||||
version: 0,
|
||||
name: '默认订阅',
|
||||
author: 'lisonge',
|
||||
supportUri: 'https://github.com/gkd-kit/subscription',
|
||||
checkUpdateUrl:
|
||||
'https://registry.npmmirror.com/@gkd-kit/subscription/latest/files/dist/gkd.version.json',
|
||||
globalGroups,
|
||||
categories,
|
||||
apps: _.sortBy(apps, (a) => {
|
||||
const pyName = pinyin(a.name, { separator: '', toneType: 'none' });
|
||||
if (pyName === a.name) return a.name;
|
||||
const showName = a.name || a.id;
|
||||
const pyName = pinyin(showName, {
|
||||
separator: '',
|
||||
toneType: 'none',
|
||||
});
|
||||
if (pyName === showName) return showName;
|
||||
return '\uFFFF' + pyName; // 让带拼音的全排在后面
|
||||
}),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user