index.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * 开发环境
  3. */
  4. ;(function () {
  5. window.SITE_CONFIG = {}
  6. // api接口请求地址
  7. window.SITE_CONFIG['baseUrl'] = 'http://console.edu.oh-os.com/api';
  8. // cdn地址 = 域名 + 版本号
  9. window.SITE_CONFIG['domain'] = './'; // 域名
  10. window.SITE_CONFIG['version'] = ''; // 版本号(年月日时分)
  11. window.SITE_CONFIG['cdnUrl'] = window.SITE_CONFIG.domain + window.SITE_CONFIG.version;
  12. })()
  13. /**
  14. * 动态加载初始资源
  15. */
  16. ;(function () {
  17. var resList = {
  18. icon: window.SITE_CONFIG.cdnUrl + '/static/img/favicon.ico',
  19. css: [
  20. window.SITE_CONFIG.cdnUrl + '/static/css/app.css'
  21. ],
  22. js: [
  23. // 插件, 放置业务之前加载, 以免业务需求依赖插件时, 还未加载出错
  24. // 插件 - echarts
  25. window.SITE_CONFIG.cdnUrl + '/static/plugins/echarts-3.8.5/echarts.common.min.js',
  26. // 插件 - ueditor
  27. window.SITE_CONFIG.cdnUrl + '/static/plugins/ueditor-1.4.3.3/ueditor.config.js',
  28. window.SITE_CONFIG.cdnUrl + '/static/plugins/ueditor-1.4.3.3/ueditor.all.min.js',
  29. window.SITE_CONFIG.cdnUrl + '/static/plugins/ueditor-1.4.3.3/lang/zh-cn/zh-cn.js',
  30. window.SITE_CONFIG.cdnUrl + '/static/plugins/ueditor-1.4.3.3/kityformula-plugin/addKityFormulaDialog.js',
  31. window.SITE_CONFIG.cdnUrl + '/static/plugins/ueditor-1.4.3.3/kityformula-plugin/defaultFilterFix.js',
  32. window.SITE_CONFIG.cdnUrl + '/static/plugins/ueditor-1.4.3.3/kityformula-plugin/getKfContent.js',
  33. // 业务
  34. window.SITE_CONFIG.cdnUrl + '/static/js/manifest.js',
  35. window.SITE_CONFIG.cdnUrl + '/static/js/vendor.js',
  36. window.SITE_CONFIG.cdnUrl + '/static/js/app.js'
  37. ]
  38. };
  39. // 图标
  40. (function () {
  41. var _icon = document.createElement('link')
  42. _icon.setAttribute('rel', 'shortcut icon')
  43. _icon.setAttribute('type', 'image/x-icon')
  44. _icon.setAttribute('href', resList.icon)
  45. document.getElementsByTagName('head')[0].appendChild(_icon)
  46. })();
  47. // 样式
  48. (function () {
  49. document.getElementsByTagName('html')[0].style.opacity = 0
  50. var i = 0
  51. var _style = null
  52. var createStyles = function () {
  53. if (i >= resList.css.length) {
  54. document.getElementsByTagName('html')[0].style.opacity = 1
  55. return
  56. }
  57. _style = document.createElement('link')
  58. _style.href = resList.css[i]
  59. _style.setAttribute('rel', 'stylesheet')
  60. _style.onload = function () {
  61. i++
  62. createStyles()
  63. }
  64. document.getElementsByTagName('head')[0].appendChild(_style)
  65. }
  66. createStyles()
  67. })()
  68. // 脚本
  69. document.onreadystatechange = function () {
  70. if (document.readyState === 'interactive') {
  71. var i = 0
  72. var _script = null
  73. var createScripts = function () {
  74. if (i >= resList.js.length) {
  75. return
  76. }
  77. _script = document.createElement('script')
  78. _script.src = resList.js[i]
  79. _script.onload = function () {
  80. i++
  81. createScripts()
  82. }
  83. document.getElementsByTagName('body')[0].appendChild(_script)
  84. }
  85. createScripts()
  86. }
  87. }
  88. })()