starter.js 806 B

1234567891011121314151617181920212223242526272829303132
  1. (function(window) {
  2. window.SITE_CONFIG = {
  3. demoEnv:true
  4. }
  5. })(window);
  6. /**
  7. * 对象属性合并,与 Object.assign 语法不同
  8. * @param target
  9. * @param source
  10. * @returns {{}}
  11. */
  12. function configDeepMerge(target, source) {
  13. var merged = {};
  14. for (var each in source) {
  15. if (target.hasOwnProperty(each) && source.hasOwnProperty(each)) {
  16. if (typeof target[each] == "object" && typeof source[each] == "object") {
  17. merged[each] = configDeepMerge(target[each], source[each]);
  18. } else {
  19. merged[each] = source[each];
  20. }
  21. } else if (source.hasOwnProperty(each)) {
  22. merged[each] = source[each];
  23. }
  24. }
  25. for (var each in target) {
  26. if (!(each in source) && target.hasOwnProperty(each)) {
  27. merged[each] = target[each];
  28. }
  29. }
  30. return merged;
  31. }