读取文件的内容:
读取主题颜色“workbench.colorTheme”并适配主题的方法:
var settingsPath = process.env.AppData + "\\Code\\User\\settings.json"; var allConfigJson = JSON.parse(fs.readFileSync(settingsPath).toString()); if (allConfigJson["workbench.colorTheme"] != undefined) { themeColor = allConfigJson["workbench.colorTheme"].toString().trim(); if (themeColor.indexOf("Light") != -1) { MyDTSInfoWebview.htmlFilePath = "\\media\\ui\\myDTSInfoLight.html"; } else if (themeColor.indexOf("Dark") != -1) { MyDTSInfoWebview.htmlFilePath = "\\media\\ui\\myDTSInfo.html"; }