feat: 自动更新默认 User-Agent

This commit is contained in:
xream committed 2026-04-10 15:01:50 +08:00
1 parent bdd5635abc
commit 78c7b62b84
4 files changed
+34 -3

No files matched your search

+31
View File
@@ -27,6 +27,37 @@ jobs:
run: |
npm install -g pnpm
cd backend && pnpm i --no-frozen-lockfile
- name: Sync latest mihomo version
run: |
MIHOMO_VERSION="$(curl -fsSL https://github.com/MetaCubeX/mihomo/releases/latest/download/version.txt | tr -d '\r\n')"
test -n "$MIHOMO_VERSION"
echo "Using mihomo version: $MIHOMO_VERSION"
cd backend
MIHOMO_VERSION="$MIHOMO_VERSION" node <<'NODE'
const fs = require('fs');
const files = ['src/utils/download.js', 'src/utils/flow.js'];
const version = process.env.MIHOMO_VERSION;
let replacements = 0;
for (const file of files) {
const source = fs.readFileSync(file, 'utf8');
const next = source.replace(/clash\.meta\/[^"']+/g, () => {
replacements += 1;
return `clash.meta/${version}`;
});
if (next !== source) {
fs.writeFileSync(file, next);
}
}
if (replacements === 0) {
throw new Error('No clash.meta version strings were updated.');
}
console.log(`Updated ${replacements} clash.meta version string(s).`);
NODE
- name: Test
run: |
cd backend