后端

index.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * 生产环境
  3. */
  4. ;(function () {
  5. window.SITE_CONFIG = {}
  6. // api请求地址
  7. window.SITE_CONFIG.baseUrl = '//demo.renren.io/renren-fast/'
  8. // 嵌套iframe地址
  9. window.SITE_CONFIG.nestIframeUrl = '//demo.renren.io/renren-fast/'
  10. // 嵌套iframe路由名称列表
  11. window.SITE_CONFIG.nestIframeRouteNameList = ['sql']
  12. // 静态资源文件夹名称
  13. window.SITE_CONFIG.staticFileName = '180309'
  14. // cdn地址
  15. window.SITE_CONFIG.cdnUrl = './' + window.SITE_CONFIG.staticFileName
  16. })();
  17. /**
  18. * 动态加载初始资源
  19. */
  20. ;(function(window, document) {
  21. var resList = {
  22. css: [
  23. window.SITE_CONFIG.cdnUrl + '/static/css/app.css'
  24. ],
  25. js: [
  26. window.SITE_CONFIG.cdnUrl + '/static/js/manifest.js',
  27. window.SITE_CONFIG.cdnUrl + '/static/js/vendor.js',
  28. window.SITE_CONFIG.cdnUrl + '/static/js/app.js'
  29. ]
  30. };
  31. // 样式
  32. (function () {
  33. document.getElementsByTagName('html')[0].style.opacity = 0;
  34. var i = 0;
  35. var _style = null;
  36. var createStyles = function () {
  37. if (i >= resList.css.length) {
  38. document.getElementsByTagName('html')[0].style.opacity = 1;
  39. return;
  40. }
  41. _style = document.createElement('link');
  42. _style.href = resList.css[i];
  43. _style.setAttribute('rel', 'stylesheet');
  44. _style.onload = function () {
  45. i++;
  46. createStyles();
  47. }
  48. document.getElementsByTagName('head')[0].appendChild(_style);
  49. }
  50. createStyles();
  51. })();
  52. // 脚本
  53. var isLoad = false;
  54. document.onreadystatechange = function () {
  55. if (!isLoad && (document.readyState === 'interactive' || document.readyState === 'complete')) {
  56. isLoad = true;
  57. var i = 0;
  58. var _script = null;
  59. var createScripts = function () {
  60. if (i >= resList.js.length) {
  61. return;
  62. }
  63. _script = document.createElement('script');
  64. _script.src = resList.js[i];
  65. _script.onload = function () {
  66. i++;
  67. createScripts();
  68. }
  69. document.getElementsByTagName('body')[0].appendChild(_script);
  70. }
  71. createScripts();
  72. }
  73. };
  74. })(window, document);