index.js 3.1 KB

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