From fe143d0a43e18253774afb4bb06cb104a1106449 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sun, 15 Jun 2025 18:18:48 +0800 Subject: [PATCH] Chore: update public --- Build/build-public.ts | 45 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/Build/build-public.ts b/Build/build-public.ts index 62edf604..29789a38 100644 --- a/Build/build-public.ts +++ b/Build/build-public.ts @@ -16,6 +16,25 @@ import { compareAndWriteFile } from './lib/create-file'; const mockDir = path.join(ROOT_DIR, 'Mock'); const modulesDir = path.join(ROOT_DIR, 'Modules'); +const priorityOrder: Record<'default' | string & {}, number> = { + LICENSE: 0, + domainset: 10, + non_ip: 20, + ip: 30, + List: 40, + Surge: 50, + Clash: 60, + 'sing-box': 70, + Surfboard: 80, + LegacyClashPremium: 81, + Modules: 90, + Script: 100, + Mock: 110, + Assets: 120, + Internal: 130, + default: Number.MAX_VALUE +}; + async function copyDirContents(srcDir: string, destDir: string, promises: Array> = []): Promise>> { for await (const entry of await fsp.opendir(srcDir)) { const src = path.join(srcDir, entry.name); @@ -62,12 +81,8 @@ export const buildPublic = task(require.main === module, __filename)(async (span ' cache-control: public, max-age=240, stale-while-revalidate=60, stale-if-error=15', 'https://:project.pages.dev/*', ' X-Robots-Tag: noindex', - '/Modules/*', - ' content-type: text/plain; charset=utf-8', - '/List/*', - ' content-type: text/plain; charset=utf-8', - '/Internal/*', - ' content-type: text/plain; charset=utf-8' + ...Object.keys(priorityOrder) + .map((name) => `/${name}/*\n content-type: text/plain; charset=utf-8\n X-Robots-Tag: noindex`) ], path.join(PUBLIC_DIR, '_headers') ), @@ -95,22 +110,6 @@ export const buildPublic = task(require.main === module, __filename)(async (span return writeFile(path.join(PUBLIC_DIR, 'index.html'), html); }); -const priorityOrder: Record<'default' | string & {}, number> = { - domainset: 1, - non_ip: 2, - ip: 3, - List: 10, - Surge: 11, - Clash: 12, - 'sing-box': 13, - Modules: 20, - Script: 30, - Mock: 40, - Assets: 50, - Internal: 60, - LICENSE: 70, - default: Number.MAX_VALUE -}; const prioritySorter = (a: TreeType, b: TreeType) => ((priorityOrder[a.name] || priorityOrder.default) - (priorityOrder[b.name] || priorityOrder.default)) || fastStringCompare(a.name, b.name); function treeHtml(tree: TreeTypeArray) { @@ -125,7 +124,7 @@ function treeHtml(tree: TreeTypeArray) {
    ${treeHtml(entry.children)}
`; - } else if (/* entry.type === 'file' && */ entry.name !== 'index.html') { + } else if (/* entry.type === 'file' && */ !entry.name.endsWith('.html') && !entry.name.startsWith('_')) { result += html`
  • ${entry.name}
  • `; } }