mt-qj-wms-ui/static/config/init.js

83 lines
2.4 KiB
JavaScript
Raw Permalink Normal View History

2021-11-30 21:05:26 +08:00
/*
* @Author: gtz
* @Date: 2021-11-19 10:10:52
2022-07-12 14:19:41 +08:00
* @LastEditors: zwq
* @LastEditTime: 2022-07-12 10:47:39
2021-11-30 21:05:26 +08:00
* @Description: file content
* @FilePath: \mt-qj-wms-ui\static\config\init.js
*/
2021-11-15 08:22:01 +08:00
/**
* 动态加载初始资源
*/
2022-07-12 14:19:41 +08:00
;(function () {
2021-11-15 08:22:01 +08:00
var resList = {
2022-07-12 14:19:41 +08:00
icon: window.SITE_CONFIG.cdnUrl + '/static/img/top.png',
2021-11-15 08:22:01 +08:00
css: [
2022-07-12 14:19:41 +08:00
window.SITE_CONFIG.cdnUrl + '/static/css/app.css'
2021-11-15 08:22:01 +08:00
],
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 () {
2022-07-12 14:19:41 +08:00
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)
2021-11-15 08:22:01 +08:00
})();
// 样式
(function () {
2022-07-12 14:19:41 +08:00
document.getElementsByTagName('html')[0].style.opacity = 0
var i = 0
var _style = null
2021-11-15 08:22:01 +08:00
var createStyles = function () {
if (i >= resList.css.length) {
2022-07-12 14:19:41 +08:00
document.getElementsByTagName('html')[0].style.opacity = 1
return
2021-11-15 08:22:01 +08:00
}
2022-07-12 14:19:41 +08:00
_style = document.createElement('link')
_style.href = resList.css[i]
_style.setAttribute('rel', 'stylesheet')
2021-11-15 08:22:01 +08:00
_style.onload = function () {
2022-07-12 14:19:41 +08:00
i++
createStyles()
2021-11-15 08:22:01 +08:00
}
2022-07-12 14:19:41 +08:00
document.getElementsByTagName('head')[0].appendChild(_style)
2021-11-15 08:22:01 +08:00
}
2022-07-12 14:19:41 +08:00
createStyles()
})()
2021-11-15 08:22:01 +08:00
// 脚本
document.onreadystatechange = function () {
if (document.readyState === 'interactive') {
2022-07-12 14:19:41 +08:00
var i = 0
var _script = null
2021-11-15 08:22:01 +08:00
var createScripts = function () {
if (i >= resList.js.length) {
2022-07-12 14:19:41 +08:00
return
2021-11-15 08:22:01 +08:00
}
2022-07-12 14:19:41 +08:00
_script = document.createElement('script')
_script.src = resList.js[i]
2021-11-15 08:22:01 +08:00
_script.onload = function () {
2022-07-12 14:19:41 +08:00
i++
createScripts()
2021-11-15 08:22:01 +08:00
}
2022-07-12 14:19:41 +08:00
document.getElementsByTagName('body')[0].appendChild(_script)
2021-11-15 08:22:01 +08:00
}
2022-07-12 14:19:41 +08:00
createScripts()
2021-11-15 08:22:01 +08:00
}
2022-07-12 14:19:41 +08:00
}
})()