feat: 支持本地文件

This commit is contained in:
xream 2025-06-01 11:54:32 +08:00
parent e4f646af0c
commit 4aafdaaddb
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
2 changed files with 12 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.19.56",
"version": "2.19.57",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {

View File

@ -174,6 +174,17 @@ async function processFn(
);
throw new Error(`无法加载 ${type}: ${url}`);
}
} else if (url?.startsWith('/')) {
try {
const fs = eval(`require("fs")`);
script = fs.readFileSync(url, 'utf8');
// $.info(`Script loaded: >>>\n ${script}`);
} catch (err) {
$.error(
`Error when reading local script: ${item.args.content}.\n Reason: ${err}`,
);
throw new Error(`无法从该路径读取脚本文件: ${url}`);
}
} else {
// if this is a remote script, download it
try {