public interface IAppRuntimeFilter { // APP端专用策略属性, 可判定Vue-Store上所有支持的属性及子属性 // AppConfigNode.content中任何数组属性或者数组子属性及后代属性,都支持implement该接口 // 后台可以将此属性赋值到配置内容的相应属性,让前端自行筛选(这样可以减少API输出差异); // 也可以自行筛选将最终结果返回给不同用户(这样可以减少传输量),推荐前者。 public string[] satisfyStoreGetters; public bool satisfyAny; } /// 可以定制具体的配置文件类 public class AppConfigNode { // 对应APP配置模块中要替换的配置结点Key public string key; // 配置内容,任意内容 public T content; } /// 也可以模糊处理 public class AppConfigNode: AppConfigNode { } /// 此接口用来生成最终配置文件 public interface IAppConfigProvider { List get(); // 获取正常开启的配置项 Dictionary output(); // 最终输出结果 } /// Table - top entry public class AppConfigStrategy { public string key; // 要替换的app config key public string desc; // 配置说明,方便UI展示示意 // 控制策略 public bool disabled; // 禁用,总开关 public string minVersion; // 最低启用版本,不填不限 public string maxVersion; // 最高启用版本,不填不限 public string[] osTypes; // 操作系统,不填不限 public string[] roles; // 角色,不填不限 public string[] periods; // 学阶,不填不限 // 自定义策略 public string[] customStrategies; // 可能需要更复杂的判定逻辑,比如要取某些业务表才能决定 } /// Table - config dynamic content public class AppConfigContent { public string scope; // parent key public EnumScopeType scopeType; // type builder public string itemKey; // map to AppConfigContentItem.key, 没有则直接作用于scope public string alias; // 别名,用于填充配置时使用,没有则使用itemKey,用于适配同名属性 public string value; // single、multiple时可能要保存选择结果 public string customValueFormatter; // 装配配置时的自定义格式转换器 } /// Table - content value shared item pool public class AppConfigContentItem { public string key; public string desc; // 配置说明,方便UI展示示意 public string options; // 配置选项,供于前端选择 public string customOptionsLoader; // 自定义选科加载类,解决固定配置无法完成的部分 public EnumAppConfigOptionType enumOptionType; // 选项使用类型 } public enum EnumScopeType { none = 0, obj = 1, array = 2 } public enum EnumAppConfigOptionType { copy = 0, // 直接复制选项值,不需要用户选择 single = 1, // 需要用户选择,单选 multiple = 2, // 需要用户选择,多选 } public class AppConfigCustomStrategyContext { public List strategies; public ConfigCustomStrategy current; } /// 此接口主要用来决策要不要启用某个key的配置替换 public interface IAppConfigCustomStrategy { bool satisfy(AppConfigCustomStrategyContext context) } public class CustomOptionsLoaderContext: AppConfigCustomStrategyContext { public AppConfigContentItem Item; } /// 此接口用来加载配置值的动态选项 public interface ICustomOptionsLoader { void load(CustomOptionsLoaderContext context) } public class CustomValueFormatterContext: AppConfigCustomStrategyContext { public AppConfigContent content; } /// 此接口用来做配置值的输出转换 public interface ICustomValueFormatter { void format(CustomValueFormatterContext context) }