vscode中读取json文件settings.json

读取文件的内容:
在这里插入图片描述

读取文件的方法:

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";
    }

猜你喜欢

转载自blog.csdn.net/qq_23350817/article/details/83587580
今日推荐