index.js 562 B

123456789101112131415161718192021
  1. "use strict";
  2. const core_config_defaultConfig = require("./defaultConfig.js");
  3. const mergeConfig = Object.assign({}, core_config_defaultConfig.defaultConfig);
  4. const config = {
  5. // 获取全部配置
  6. all() {
  7. return mergeConfig;
  8. },
  9. // 获取指定配置
  10. get(key, def = void 0) {
  11. if (mergeConfig.hasOwnProperty(key)) {
  12. return mergeConfig[key];
  13. }
  14. console.error(`检测到不存在的配置项: ${key}`);
  15. return def;
  16. },
  17. getResource(imgName) {
  18. return `${mergeConfig.apiUrl}images/${imgName}`;
  19. }
  20. };
  21. exports.config = config;