// 配置管理类
class ConfigManager {
    static getConfig(key, defaultValue = null) {
        const value = localStorage.getItem(key);
        if (value === null) return defaultValue;
        try {
            return JSON.parse(value);
        } catch {
            return value;
        }
    }

    static setConfig(key, value) {
        try {
            localStorage.setItem(key, JSON.stringify(value));
        } catch {
            localStorage.setItem(key, value);
        }
    }

    static getBoolConfig(key, defaultValue = false) {
        const value = this.getConfig(key);
        return value === null ? defaultValue : value === 'true' || value === true;
    }

    static setBoolConfig(key, value) {
        this.setConfig(key, Boolean(value));
    }

    // Beta功能管理
    static getBetaFeature(featureName, defaultValue = false) {
        const betaFeatures = this.getConfig('betaFeatures', {});
        return betaFeatures[featureName] !== undefined ? betaFeatures[featureName] : defaultValue;
    }

    static setBetaFeature(featureName, enabled) {
        const betaFeatures = this.getConfig('betaFeatures', {});
        betaFeatures[featureName] = enabled;
        this.setConfig('betaFeatures', betaFeatures);
        return enabled;
    }

    static toggleBetaFeature(featureName) {
        const current = this.getBetaFeature(featureName, false);
        return this.setBetaFeature(featureName, !current);
    }

    // 获取所有Beta功能状态
    static getAllBetaFeatures() {
        return this.getConfig('betaFeatures', {});
    }

    // Beta功能描述
    static getBetaFeatureInfo(featureName) {
        const betaFeaturesInfo = {
            dynamicIsland: {
                name: '灵动岛',
                description: '小米风格的搜索栏+公告栏集成设计',
                version: '0.1.0',
                stable: false,
                category: '界面'
            }
            // 可以添加更多Beta功能
        };
        return betaFeaturesInfo[featureName] || { name: featureName, description: '未知功能' };
    }
}
