mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-04-25 22:29:47 +08:00
fix(js): 修复模块被导入时副作用代码被重复执行 (#3070)
This commit is contained in:
@@ -32,7 +32,8 @@ namespace BetterGenshinImpact.Core.Script
|
||||
{
|
||||
string content = await File.ReadAllTextAsync(targetPath);
|
||||
string processedCode = RewriteScriptCode(content, targetPath);
|
||||
return new StringDocument(new DocumentInfo(targetPath) { Category = ModuleCategory.Standard }, processedCode);
|
||||
var documentInfo = new DocumentInfo(new Uri(targetPath)) { Category = ModuleCategory.Standard };
|
||||
return new StringDocument(documentInfo, processedCode);
|
||||
}
|
||||
|
||||
return await Default.LoadDocumentAsync(settings, sourceInfo, specifier, category, contextCallback);
|
||||
|
||||
@@ -122,7 +122,8 @@ public class ScriptProject
|
||||
string mainScriptPath = Path.Combine(ProjectPath, Manifest.Main);
|
||||
string runtimeCode = loader.RewriteScriptCode(code, mainScriptPath);
|
||||
|
||||
var evaluation = engine.Evaluate(new DocumentInfo(mainScriptPath) { Category = ModuleCategory.Standard }, runtimeCode);
|
||||
var documentInfo = new DocumentInfo(new Uri(mainScriptPath)) { Category = ModuleCategory.Standard };
|
||||
var evaluation = engine.Evaluate(documentInfo, runtimeCode);
|
||||
if (evaluation is Task task) await task;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user