mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-03-01 08:10:25 +00:00
Refactor bypass defaults and crash handling
Set bypass defaults to disabled and simplify loading: napcat.json default bypass flags changed to false and code now reads bypass options without merging a prior "all enabled" default. Removed the progressive bypass-disable logic and related environment variable usage, and added a log when Napi2NativeLoader enables bypasses. Web UI/backend adjustments: default NapCat config is now generated from the AJV schema; the bypass settings UI defaults to false, adds an o3HookMode toggle, and submits o3HookMode as 0/1. UX fixes: extension tabs made horizontally scrollable with fixed tab sizing, and plugin uninstall flow updated to a single confirmation dialog with an optional checkbox to remove plugin config. Overall changes aim to use safer defaults, simplify crash/restart behavior, and improve configuration and UI clarity.
This commit is contained in:
@@ -47,28 +47,23 @@ export async function NCoreInitFramework (
|
||||
const napi2nativeLoader = new Napi2NativeLoader({ logger }); // 初始化 Napi2NativeLoader 用于后续使用
|
||||
//console.log('[NapCat] [Napi2NativeLoader]', napi2nativeLoader.nativeExports.enableAllBypasses?.());
|
||||
if (process.env['NAPCAT_DISABLE_BYPASS'] !== '1') {
|
||||
// 读取 napcat.json 配置
|
||||
let bypassOptions: BypassOptions = {
|
||||
hook: false,
|
||||
window: false,
|
||||
module: false,
|
||||
process: false,
|
||||
container: false,
|
||||
js: false,
|
||||
};
|
||||
let bypassOptions: BypassOptions = {};
|
||||
try {
|
||||
const configFile = path.join(pathWrapper.configPath, 'napcat.json');
|
||||
if (fs.existsSync(configFile)) {
|
||||
const content = fs.readFileSync(configFile, 'utf-8');
|
||||
const config = json5.parse(content);
|
||||
if (config.bypass && typeof config.bypass === 'object') {
|
||||
bypassOptions = { ...bypassOptions, ...config.bypass };
|
||||
bypassOptions = { ...config.bypass };
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logger.logWarn('[NapCat] 读取 napcat.json bypass 配置失败,已全部禁用:', e);
|
||||
}
|
||||
const bypassEnabled = napi2nativeLoader.nativeExports.enableAllBypasses?.(bypassOptions);
|
||||
if (bypassEnabled) {
|
||||
logger.log('[NapCat] Napi2NativeLoader: 已启用Bypass');
|
||||
}
|
||||
logger.log('[NapCat] Napi2NativeLoader: Framework模式Bypass配置:', bypassOptions);
|
||||
} else {
|
||||
logger.log('[NapCat] Napi2NativeLoader: Bypass已通过环境变量禁用');
|
||||
|
||||
Reference in New Issue
Block a user