WebVersionUtils.java 820 Bytes
package com.polysoft.nafmii.utils;

import com.whaty.nafmii.BuildConfig;

import java.io.File;

public class WebVersionUtils {

    public static String getVersion() {
        return SpUtils.getString(SpUtils.KEY_H5_VERSION, BuildConfig.WEB_VERSION);
    }

    public static void setVersion(String name) {
        SpUtils.putString(SpUtils.KEY_H5_VERSION, name);
    }

    public static File getIndex() {
        return new File(getDistDir(), "index.html");
    }

    public static File getDistDir() {
        return getDistDir(getVersion());
    }

    public static File getDistDir(String version) {
        File verisonDir = new File(FileUtils.getRootDir(), version);
        File dist = new File(verisonDir, "dist");
        if (!dist.exists()) {
            dist.mkdirs();
        }
        return dist;
    }
}