Xxxu
2020-07-03 1ac6ef52a03f25f9def9f6a2594d2a8196aa77f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
 * 动态加载初始资源
 */
(function () {
  var resList = {
    icon: window.SITE_CONFIG.cdnUrl + '/static/img/x.png',
    css: [
      window.SITE_CONFIG.cdnUrl + '/static/css/app.css'
    ],
    js: [
      // 插件, 放置业务之前加载, 以免业务需求依赖插件时, 还未加载出错
      // 插件 - echarts
      window.SITE_CONFIG.cdnUrl + '/static/plugins/echarts-3.8.5/echarts.common.min.js',
      // 插件 - ueditor
      window.SITE_CONFIG.cdnUrl + '/static/plugins/ueditor-1.4.3.3/ueditor.config.js',
      window.SITE_CONFIG.cdnUrl + '/static/plugins/ueditor-1.4.3.3/ueditor.all.min.js',
      window.SITE_CONFIG.cdnUrl + '/static/plugins/ueditor-1.4.3.3/lang/zh-cn/zh-cn.js',
      // 业务
      window.SITE_CONFIG.cdnUrl + '/static/js/manifest.js',
      window.SITE_CONFIG.cdnUrl + '/static/js/vendor.js',
      window.SITE_CONFIG.cdnUrl + '/static/js/app.js'
    ]
  };
 
  // 图标
  (function () {
    var _icon = document.createElement('link')
    _icon.setAttribute('rel', 'shortcut icon')
    _icon.setAttribute('type', 'image/x-icon')
    _icon.setAttribute('href', resList.icon)
    document.getElementsByTagName('head')[0].appendChild(_icon)
  })();
 
  // 样式
  (function () {
    document.getElementsByTagName('html')[0].style.opacity = 0
    var i = 0
    var _style = null
    var createStyles = function () {
      if (i >= resList.css.length) {
        document.getElementsByTagName('html')[0].style.opacity = 1
        return
      }
      _style = document.createElement('link')
      _style.href = resList.css[i]
      _style.setAttribute('rel', 'stylesheet')
      _style.onload = function () {
        i++
        createStyles()
      }
      document.getElementsByTagName('head')[0].appendChild(_style)
    }
    createStyles()
  })()
 
  // 脚本
  document.onreadystatechange = function () {
    if (document.readyState === 'interactive') {
      var i = 0
      var _script = null
      var createScripts = function () {
        if (i >= resList.js.length) {
          return
        }
        _script = document.createElement('script')
        _script.src = resList.js[i]
        _script.onload = function () {
          i++
          createScripts()
        }
        document.getElementsByTagName('body')[0].appendChild(_script)
      }
      createScripts()
    }
  }
})()