qy-renren-qt/static/config/init.js

83 lines
2.4 KiB
JavaScript
Raw Permalink Normal View History

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