arisu.js 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/dist/arisu.commonjs.min.js +1 -1
- package/dist/arisu.js +507 -190
- package/dist/arisu.min.js +1 -1
- package/dist/arisu.module.min.js +1 -1
- package/dist/arisu.window.min.js +1 -1
- package/package.json +1 -1
- package/src/js/base.js +239 -123
- package/src/js/main.js +11 -4
- package/src/js/utils.js +256 -63
- package/webpack.config.js +15 -15
- package/deprecated/arisu-1.2.js +0 -3307
- package/deprecated/arisu-1.3.js +0 -3718
- package/deprecated/arisu.min.js +0 -1
- package/deprecated/base-2.0.js +0 -948
- package/deprecated/early/base-1.2.js +0 -1090
- package/deprecated/export-method.js +0 -467
- package/deprecated/jquery.module.js +0 -299
- package/deprecated/jquery.template.js +0 -82
- package/deprecated/main-2.0.js +0 -278
- package/deprecated/single-vue.js +0 -47
- package/deprecated/single.js +0 -130
- package/deprecated/utils-1.2.js +0 -2774
package/src/js/utils.js
CHANGED
|
@@ -23,6 +23,7 @@ import b from './base'
|
|
|
23
23
|
10. 弹框搜索面板:new u.PopoverSearch('#ipopover', {
|
|
24
24
|
11. 文字切换动画特效:new u.Flash("#ce-flash", {
|
|
25
25
|
12. 绘制点线背景动画:new u.LineEffect("#canvas-warp", {
|
|
26
|
+
13. JS、CSS页面引入,多次引入只保留一个:const iloader = new u.ILoader();
|
|
26
27
|
|
|
27
28
|
* ======================================================================== */
|
|
28
29
|
/**
|
|
@@ -129,6 +130,7 @@ export class SubmitFlag {
|
|
|
129
130
|
|
|
130
131
|
init(element) {
|
|
131
132
|
let myElems = b(element),
|
|
133
|
+
/** @type {SubmitFlag<>} **/
|
|
132
134
|
data = myElems.data("be.submitflag");
|
|
133
135
|
myElems.data("text", myElems.text()).click((e) => {
|
|
134
136
|
data.request(e.currentTarget);
|
|
@@ -554,13 +556,18 @@ export class BtnEf {
|
|
|
554
556
|
* ======================================================================== */
|
|
555
557
|
export class AeLoader {
|
|
556
558
|
constructor(selector, custom) {
|
|
557
|
-
this.selector =
|
|
558
|
-
|
|
559
|
+
this.selector = '';
|
|
560
|
+
if(b.isObject(selector)) {
|
|
561
|
+
this.options = b.extend( selector, this.options );
|
|
562
|
+
} else {
|
|
563
|
+
if(selector) this.selector = selector;
|
|
564
|
+
this.options = b.extend( custom, this.options )
|
|
565
|
+
}
|
|
559
566
|
b("[data-ae-load]").addClass("ae-load");
|
|
560
567
|
}
|
|
561
568
|
|
|
562
569
|
options = {
|
|
563
|
-
target: '',
|
|
570
|
+
// target: '',
|
|
564
571
|
//默认1秒,修改需要同时也需要修改CSS动画
|
|
565
572
|
time: 1000
|
|
566
573
|
}
|
|
@@ -588,8 +595,8 @@ export class AeLoader {
|
|
|
588
595
|
|
|
589
596
|
b("[data-ae-load]").addClass("ae-load");
|
|
590
597
|
b(target + "[data-ae-load]").each(function(currentTarget) {
|
|
591
|
-
|
|
592
|
-
|
|
598
|
+
const minWidth = b(currentTarget).data("al-mw"),
|
|
599
|
+
minHeight = b(currentTarget).data("al-mh");
|
|
593
600
|
if (minWidth) b(currentTarget).css("min-width", minWidth);
|
|
594
601
|
if (minHeight) b(currentTarget).css("min-height", minHeight);
|
|
595
602
|
|
|
@@ -623,7 +630,7 @@ export class AeLoader {
|
|
|
623
630
|
* 2024年6月29日 10:28:55
|
|
624
631
|
* ========================================================================
|
|
625
632
|
* <pre>
|
|
626
|
-
<div class="be-paging-warp">
|
|
633
|
+
<div id="be-pw" class="be-paging-warp">
|
|
627
634
|
<p></p>
|
|
628
635
|
<nav>
|
|
629
636
|
<ul id="ipagination" class="be-paging"></ul>
|
|
@@ -662,10 +669,10 @@ export class IPagination {
|
|
|
662
669
|
}
|
|
663
670
|
// containerId, totalItems, itemsPerPage, visiblePages = 5
|
|
664
671
|
options = {
|
|
665
|
-
targetWarp: '
|
|
672
|
+
targetWarp: '#be-pw', //不同分页区分
|
|
666
673
|
totalItems: 0, //总条数
|
|
667
674
|
itemsPerPage: 0, //一页几条数据
|
|
668
|
-
visiblePages: 5,
|
|
675
|
+
visiblePages: 5, //多少按钮页可见
|
|
669
676
|
prev: '上一页', //or: <i class="bi bi-chevron-left"></i>
|
|
670
677
|
next: '下一页', //or: <i class="bi bi-chevron-right"></i>
|
|
671
678
|
first: '首页', //or: <i class="bi bi-chevron-double-left"></i>
|
|
@@ -767,7 +774,7 @@ export class IPagination {
|
|
|
767
774
|
</div>
|
|
768
775
|
<div class="be-list-nofound">查询不到相应数据!</div>
|
|
769
776
|
<div class="be-list-page">
|
|
770
|
-
<div class="be-paging-warp">
|
|
777
|
+
<div id="ilist-ip-warp" class="be-paging-warp">
|
|
771
778
|
<p></p>
|
|
772
779
|
<nav>
|
|
773
780
|
<ul id="ipagination" class="be-paging"></ul>
|
|
@@ -944,6 +951,7 @@ export class IList {
|
|
|
944
951
|
template: "#tp-list",
|
|
945
952
|
headerMap: { }, //{ 'Content-Type': 'application/json'}
|
|
946
953
|
cache: 'default',
|
|
954
|
+
ipWarp: '#ilist-ip-warp',
|
|
947
955
|
prev: '上一页', //or: <i class="bi bi-chevron-left"></i>
|
|
948
956
|
next: '下一页', //or: <i class="bi bi-chevron-right"></i>
|
|
949
957
|
first: '首页', //or: <i class="bi bi-chevron-double-left"></i>
|
|
@@ -980,7 +988,8 @@ export class IList {
|
|
|
980
988
|
|
|
981
989
|
// 数据查询
|
|
982
990
|
getData(element, options, param) {
|
|
983
|
-
let target = this
|
|
991
|
+
let target = this,
|
|
992
|
+
myElement = b(element);
|
|
984
993
|
b(".be-list-data-body", element).html("");
|
|
985
994
|
b(".be-list-loading", element).addClass("opacity-100");
|
|
986
995
|
b(".be-list-nofound", element).removeClass("opacity-100");
|
|
@@ -1015,11 +1024,29 @@ export class IList {
|
|
|
1015
1024
|
|
|
1016
1025
|
if (data.total) {
|
|
1017
1026
|
target.page(element, options, param, data.total);//翻页
|
|
1018
|
-
|
|
1027
|
+
|
|
1028
|
+
// 全选/全清
|
|
1019
1029
|
b(".ilist-check-all").checkAll('.ilist-check');
|
|
1020
1030
|
|
|
1021
|
-
|
|
1022
|
-
|
|
1031
|
+
//点击列选择单列/点击列取消选择单列
|
|
1032
|
+
b( "table > tbody tr", element ).click( e => {
|
|
1033
|
+
let target = b( e.target );
|
|
1034
|
+
if (!(target.is( "input" ) || target.is( "i" ) || target.is( "a" ))) {
|
|
1035
|
+
b( ".ilist-check", e.currentTarget ).click();
|
|
1036
|
+
}
|
|
1037
|
+
} )
|
|
1038
|
+
|
|
1039
|
+
// 全选列/全清列
|
|
1040
|
+
// b( ".ilist-check-all", element ).change( e => {
|
|
1041
|
+
// let isChecked = b( e.currentTarget ).is( ":checked" );
|
|
1042
|
+
// if (isChecked)
|
|
1043
|
+
// b( ".ilist-check" ).addClass( "active" ).trigger("change");
|
|
1044
|
+
// else
|
|
1045
|
+
// b( ".ilist-check" ).removeClass( "active" ).trigger("change");
|
|
1046
|
+
// } );
|
|
1047
|
+
|
|
1048
|
+
if (myElement.data("be.ilist.event")) {
|
|
1049
|
+
myElement.data("be.ilist.event", false);
|
|
1023
1050
|
|
|
1024
1051
|
//选择单列/取消选择单列
|
|
1025
1052
|
b( ".ilist-check", element ).change( e => {
|
|
@@ -1030,27 +1057,14 @@ export class IList {
|
|
|
1030
1057
|
b(e.currentTarget).parents("tr").removeClass("active");
|
|
1031
1058
|
} );
|
|
1032
1059
|
|
|
1033
|
-
//全选列/全清列
|
|
1034
|
-
b( ".ilist-check-all", element ).change( e => {
|
|
1035
|
-
let isChecked = b( e.currentTarget ).is( ":checked" );
|
|
1036
|
-
if (isChecked)
|
|
1037
|
-
b( ".ilist-check" ).addClass( "active" ).trigger("change");
|
|
1038
|
-
else
|
|
1039
|
-
b( ".ilist-check" ).removeClass( "active" ).trigger("change");
|
|
1040
|
-
} );
|
|
1041
|
-
|
|
1042
|
-
//点击列选择单列/点击列取消选择单列
|
|
1043
|
-
b( "table > tbody tr", element ).click( e => {
|
|
1044
|
-
let target = b( e.target );
|
|
1045
|
-
if (!(target.is( "input" ) || target.is( "i" ) || target.is( "a" ))) {
|
|
1046
|
-
b( ".ilist-check", e.currentTarget ).click();
|
|
1047
|
-
}
|
|
1048
|
-
} )
|
|
1049
|
-
|
|
1050
1060
|
//排序,<td data-sortname="a.title" data-is-sort="true"
|
|
1051
1061
|
b( "table > thead tr td", element ).click( e => {
|
|
1052
1062
|
const sortname = b( e.currentTarget ).data( "sortname" );
|
|
1053
1063
|
if (sortname) {
|
|
1064
|
+
const reloadParam = myElement.data("be.ilist.param");
|
|
1065
|
+
if (reloadParam) {
|
|
1066
|
+
param = b.extend(reloadParam, param);
|
|
1067
|
+
}
|
|
1054
1068
|
param.sortname = sortname;
|
|
1055
1069
|
if (!b( e.currentTarget ).hasClass( "is-check" ) && param.sortname) {
|
|
1056
1070
|
let sortorder = b( e.currentTarget ).attr( "data-sort-order" );
|
|
@@ -1071,7 +1085,7 @@ export class IList {
|
|
|
1071
1085
|
param.sortorder = "desc";
|
|
1072
1086
|
}
|
|
1073
1087
|
|
|
1074
|
-
|
|
1088
|
+
myElement.data("be.ilist.flag", true );
|
|
1075
1089
|
param.page = "1";
|
|
1076
1090
|
options.isInit = false;
|
|
1077
1091
|
target.getData( element, options, param );
|
|
@@ -1099,8 +1113,9 @@ export class IList {
|
|
|
1099
1113
|
page(element, options, param, total) {
|
|
1100
1114
|
let target = this,
|
|
1101
1115
|
myElement = b(element);
|
|
1102
|
-
if (myElement.data("be.ilist.flag")) {
|
|
1116
|
+
if (myElement.data("be.ilist.flag")) { //每次都重新生成一次分页
|
|
1103
1117
|
new IPagination('#ipagination', {
|
|
1118
|
+
targetWarp: options.ipWarp,
|
|
1104
1119
|
totalItems: total,
|
|
1105
1120
|
itemsPerPage: options.rp,
|
|
1106
1121
|
visiblePages: options.visiblePages,
|
|
@@ -1121,12 +1136,15 @@ export class IList {
|
|
|
1121
1136
|
|
|
1122
1137
|
// 设置参数重新搜索
|
|
1123
1138
|
reload(param) {
|
|
1124
|
-
let
|
|
1125
|
-
|
|
1139
|
+
let myElement = b(this.selector),
|
|
1140
|
+
/** @type {IList<>} **/
|
|
1141
|
+
data = myElement.data("be.ilist"),
|
|
1126
1142
|
newParam = b.extend(param,
|
|
1127
1143
|
{ page: 1, rp: data.options.rp, sortname: data.options.sortname, sortorder: data.options.sortorder });
|
|
1128
1144
|
data.options.isInit = false;
|
|
1129
|
-
|
|
1145
|
+
myElement.data("be.ilist.flag", true);
|
|
1146
|
+
myElement.data("be.ilist.param", newParam);
|
|
1147
|
+
b('table > thead tr td', myElement).attr('data-sort-order', '');
|
|
1130
1148
|
data["getData"](data['selector'], data.options, newParam);
|
|
1131
1149
|
}
|
|
1132
1150
|
}
|
|
@@ -1583,7 +1601,6 @@ export class PopoverSearch {
|
|
|
1583
1601
|
// 获取参数
|
|
1584
1602
|
getParam() {
|
|
1585
1603
|
const params = {};
|
|
1586
|
-
b.l(b(".popover-form-item"))
|
|
1587
1604
|
b(".popover-form-item").each(function(e) {
|
|
1588
1605
|
const myEle = b(e),
|
|
1589
1606
|
name = myEle.attr("name"),
|
|
@@ -1931,38 +1948,52 @@ export class LineEffect {
|
|
|
1931
1948
|
// 监听事件,移动鼠标, 滚动, 改变屏幕大小
|
|
1932
1949
|
addListeners(options, xy, canvas) {
|
|
1933
1950
|
const target = this;
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
}
|
|
1939
|
-
window.addEventListener("scroll", () => {
|
|
1951
|
+
const mousemove = (e) => {
|
|
1952
|
+
target.mouseMove(e, xy);
|
|
1953
|
+
};
|
|
1954
|
+
const scroll = () => {
|
|
1940
1955
|
target.scrollCheck(options);
|
|
1941
|
-
}
|
|
1942
|
-
|
|
1956
|
+
};
|
|
1957
|
+
const resize = () => {
|
|
1943
1958
|
target.resize(options, canvas);
|
|
1944
|
-
}
|
|
1959
|
+
};
|
|
1960
|
+
|
|
1961
|
+
if (document.getElementById(target.options.canvasId)) {
|
|
1962
|
+
if(!('ontouchstart' in window)) {
|
|
1963
|
+
window.addEventListener("mousemove", mousemove);
|
|
1964
|
+
}
|
|
1965
|
+
window.addEventListener("scroll", scroll);
|
|
1966
|
+
window.addEventListener("resize", resize);
|
|
1967
|
+
} else {
|
|
1968
|
+
if(!('ontouchstart' in window)) {
|
|
1969
|
+
window.removeEventListener("mousemove", mousemove);
|
|
1970
|
+
}
|
|
1971
|
+
window.removeEventListener("scroll", scroll);
|
|
1972
|
+
window.removeEventListener("resize", resize);
|
|
1973
|
+
}
|
|
1945
1974
|
}
|
|
1946
1975
|
|
|
1947
1976
|
mouseMove(e, xy) {
|
|
1948
|
-
const canvas = document.getElementById(this.options.canvasId)
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1977
|
+
const canvas = document.getElementById(this.options.canvasId);
|
|
1978
|
+
if (canvas) {
|
|
1979
|
+
const rect = canvas.getBoundingClientRect(),
|
|
1980
|
+
scrollTop = window.pageYOffset || document.documentElement.scrollTop,
|
|
1981
|
+
scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,
|
|
1982
|
+
offsetTop = rect.top + scrollTop,
|
|
1983
|
+
offsetLeft = rect.left + scrollLeft;
|
|
1984
|
+
|
|
1985
|
+
let posx = 0,
|
|
1986
|
+
posy = 0;
|
|
1987
|
+
if (e.pageX || e.pageY) {
|
|
1988
|
+
posx = e.pageX;
|
|
1989
|
+
posy = e.pageY;
|
|
1990
|
+
} else if (e.clientX || e.clientY) {
|
|
1991
|
+
posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
|
|
1992
|
+
posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
|
|
1993
|
+
}
|
|
1994
|
+
xy.x = posx - offsetLeft;
|
|
1995
|
+
xy.y = posy - offsetTop;
|
|
1963
1996
|
}
|
|
1964
|
-
xy.x = posx - offsetLeft;
|
|
1965
|
-
xy.y = posy - offsetTop;
|
|
1966
1997
|
}
|
|
1967
1998
|
|
|
1968
1999
|
scrollCheck(options) {
|
|
@@ -1976,7 +2007,6 @@ export class LineEffect {
|
|
|
1976
2007
|
}
|
|
1977
2008
|
|
|
1978
2009
|
|
|
1979
|
-
|
|
1980
2010
|
/* ========================================================================
|
|
1981
2011
|
* 12. 鼠标上下左右划入监听实现对应动画
|
|
1982
2012
|
* 2022年7月28日 10:50:06
|
|
@@ -2106,6 +2136,169 @@ export class HoverDir {
|
|
|
2106
2136
|
}
|
|
2107
2137
|
|
|
2108
2138
|
|
|
2139
|
+
/* ========================================================================
|
|
2140
|
+
* 13. JS、CSS页面引入,多次引入只保留一个
|
|
2141
|
+
* 2024年9月15日 09:19:37
|
|
2142
|
+
* ========================================================================
|
|
2143
|
+
* <pre>
|
|
2144
|
+
const iloader = new u.ILoader();
|
|
2145
|
+
Promise.all([
|
|
2146
|
+
iloader.loadStyle('https://arisu.cn/te/WEB/css/animate.v4.css'),
|
|
2147
|
+
iloader.loadScript('https://arisu.cn/te/WEB/js/handlebars-v4.0.5.js'),
|
|
2148
|
+
iloader.loadScript('https://arisu.cn/te/WEB/js/imagesloaded.pkgd.min.js'),
|
|
2149
|
+
]).then(() => {
|
|
2150
|
+
console.log('All scripts、style loaded');
|
|
2151
|
+
}).catch(error => {
|
|
2152
|
+
console.error('Error loading scripts、style', error);
|
|
2153
|
+
});
|
|
2154
|
+
* </pre>
|
|
2155
|
+
* ======================================================================== */
|
|
2156
|
+
export class ILoader {
|
|
2157
|
+
constructor(custom) {
|
|
2158
|
+
/** @type {Array<{script: HTMLElement, url: string, isLoaded: boolean}>} **/
|
|
2159
|
+
this.jsLoaded = [];
|
|
2160
|
+
this.cssLoaded = [];
|
|
2161
|
+
this.options = b.extend( custom, this.options );
|
|
2162
|
+
}
|
|
2163
|
+
options = {
|
|
2164
|
+
// 脚本加载失败,重新尝试次数和每次使用时间(毫秒)
|
|
2165
|
+
times: 20,
|
|
2166
|
+
time: 1000
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
/** 定义一个加载并执行外部 JS 文件的函数
|
|
2170
|
+
const iloader = new u.ILoader();
|
|
2171
|
+
Promise.all([
|
|
2172
|
+
iloader.loadScript('https://arisu.cn/te/WEB/js/handlebars-v4.0.5.js'),
|
|
2173
|
+
iloader.loadScript('https://arisu.cn/te/WEB/js/imagesloaded.pkgd.min.js')
|
|
2174
|
+
]).then(() => {
|
|
2175
|
+
console.log('All scripts loaded');
|
|
2176
|
+
}).catch(error => {
|
|
2177
|
+
console.error('Error loading scripts', error);
|
|
2178
|
+
});
|
|
2179
|
+
* @param url
|
|
2180
|
+
* @returns {Promise<unknown>}
|
|
2181
|
+
*/
|
|
2182
|
+
loadScript(url) {
|
|
2183
|
+
const target = this;
|
|
2184
|
+
|
|
2185
|
+
return new Promise((resolve, reject) => {
|
|
2186
|
+
// 检查是否已经加载过该脚本
|
|
2187
|
+
const existingScript = target.jsLoaded.find(script => script.url === url);
|
|
2188
|
+
if (!existingScript) {
|
|
2189
|
+
// 页面上未引入
|
|
2190
|
+
let script = document.createElement('script'),
|
|
2191
|
+
isOnload = false,
|
|
2192
|
+
count = 0;
|
|
2193
|
+
|
|
2194
|
+
target.jsLoaded = [...target.jsLoaded, { script: script, url: url, isLoaded: false, count: 0 }];
|
|
2195
|
+
|
|
2196
|
+
script.src = url;
|
|
2197
|
+
// script.async = 'true';
|
|
2198
|
+
script.onload = () => {
|
|
2199
|
+
target.jsLoaded = target.jsLoaded.map(item =>
|
|
2200
|
+
item.url === url ? { ...item, isLoaded: true } : item
|
|
2201
|
+
);
|
|
2202
|
+
isOnload = true;
|
|
2203
|
+
resolve(script);
|
|
2204
|
+
};
|
|
2205
|
+
script.onerror = () => {
|
|
2206
|
+
target.jsLoaded = target.jsLoaded.filter(item => item.url !== url);
|
|
2207
|
+
reject(new Error('Script load error for ' + url));
|
|
2208
|
+
}
|
|
2209
|
+
document.body.append(script);
|
|
2210
|
+
const intervalId = setInterval(() => {
|
|
2211
|
+
if (isOnload) {
|
|
2212
|
+
// b.l('载入成功!: ', url)
|
|
2213
|
+
clearInterval(intervalId);
|
|
2214
|
+
return;
|
|
2215
|
+
} else {
|
|
2216
|
+
if (count > target.options.times) {
|
|
2217
|
+
// console.log('载入失败!: ', url)
|
|
2218
|
+
if (script.parentNode === document.body) document.body.removeChild(script);
|
|
2219
|
+
clearInterval(intervalId);
|
|
2220
|
+
return;
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
count++;
|
|
2224
|
+
}, 100);
|
|
2225
|
+
} else {
|
|
2226
|
+
// 页面上已经引入,但是还未调用
|
|
2227
|
+
let count = 0, scriptItem;
|
|
2228
|
+
const intervalId = setInterval(() => {
|
|
2229
|
+
scriptItem = target.jsLoaded.find(item => item.url === url);
|
|
2230
|
+
b.l('尝试加载中: ', url, count)
|
|
2231
|
+
try {
|
|
2232
|
+
if (!scriptItem.isLoaded && count > target.options.times) {
|
|
2233
|
+
// b.l('删除了URL: ', scriptItem.url);
|
|
2234
|
+
target.jsLoaded = target.jsLoaded.filter(item => item.url !== url);
|
|
2235
|
+
if (scriptItem.script.parentNode === document.body) document.body.removeChild(scriptItem.script);
|
|
2236
|
+
clearInterval(intervalId);
|
|
2237
|
+
return;
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
if (scriptItem.isLoaded) {
|
|
2241
|
+
// b.l('载入成功 ');
|
|
2242
|
+
clearInterval(intervalId);
|
|
2243
|
+
resolve();
|
|
2244
|
+
return;
|
|
2245
|
+
}
|
|
2246
|
+
count++;
|
|
2247
|
+
} catch(e) { console.error(e) }
|
|
2248
|
+
}, target.options.time);
|
|
2249
|
+
}
|
|
2250
|
+
})
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
/** 定义一个加载并执行外部 JS 文件的函数
|
|
2254
|
+
Promise.all([
|
|
2255
|
+
loadScript('https://arisu.cn/te/WEB/css/buttons-plus.css'),
|
|
2256
|
+
loadStyle('https://arisu.cn/te/WEB/css/animate.v4.css')
|
|
2257
|
+
]).then(() => {
|
|
2258
|
+
console.log('All scripts/style loaded');
|
|
2259
|
+
}).catch(error => {
|
|
2260
|
+
console.error('Error loading', error);
|
|
2261
|
+
});
|
|
2262
|
+
* @param href 样式地址
|
|
2263
|
+
* @returns {Promise<unknown>}
|
|
2264
|
+
*/
|
|
2265
|
+
loadStyle(href) {
|
|
2266
|
+
const target = this;
|
|
2267
|
+
return new Promise((resolve, reject) => {
|
|
2268
|
+
// 检查是否已经加载了CSS文件
|
|
2269
|
+
const links = document.getElementsByTagName("link");
|
|
2270
|
+
for (let i = 0; i < links.length; i++) {
|
|
2271
|
+
if (links[i].getAttribute("href") === href) {
|
|
2272
|
+
resolve();
|
|
2273
|
+
return true;
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2277
|
+
let style = document.createElement('link');
|
|
2278
|
+
style.href = href;
|
|
2279
|
+
style.rel = 'stylesheet';
|
|
2280
|
+
style.type = 'text/css';
|
|
2281
|
+
style.onload = () => resolve(style);
|
|
2282
|
+
style.onerror = () => reject(new Error('Style load error for ' + href));
|
|
2283
|
+
document.head.append(style);
|
|
2284
|
+
target.cssLoaded.push(style);
|
|
2285
|
+
});
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
// 删除所有引入脚本、样式
|
|
2289
|
+
destroy() {
|
|
2290
|
+
this.jsLoaded.forEach((item)=>{
|
|
2291
|
+
if (item.script && item.script.parentNode === document.body) document.body.removeChild(item.script);
|
|
2292
|
+
})
|
|
2293
|
+
this.cssLoaded.forEach((item)=>{
|
|
2294
|
+
if (item.parentNode === document.head) document.head.removeChild(item);
|
|
2295
|
+
})
|
|
2296
|
+
this.jsLoaded = [];
|
|
2297
|
+
this.cssLoaded = [];
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
|
|
2109
2302
|
|
|
2110
2303
|
export { b };
|
|
2111
2304
|
export default b;
|
package/webpack.config.js
CHANGED
|
@@ -74,18 +74,18 @@ module.exports = {
|
|
|
74
74
|
entry: './src/js/main.js',
|
|
75
75
|
mode: 'production',
|
|
76
76
|
// 打包方式三
|
|
77
|
-
experiments: {
|
|
78
|
-
|
|
79
|
-
},
|
|
77
|
+
// experiments: {
|
|
78
|
+
// outputModule: true
|
|
79
|
+
// },
|
|
80
80
|
output: {
|
|
81
81
|
path: path.resolve( __dirname, base ),
|
|
82
82
|
// clean: true,
|
|
83
83
|
// 打包方式一
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
filename: 'arisu.window.min.js',
|
|
85
|
+
library: {
|
|
86
|
+
name: 'arisu',
|
|
87
|
+
type: 'window'
|
|
88
|
+
},
|
|
89
89
|
// 打包方式二
|
|
90
90
|
// filename: 'arisu.commonjs.min.js',
|
|
91
91
|
// library: {
|
|
@@ -93,25 +93,25 @@ module.exports = {
|
|
|
93
93
|
// type: 'commonjs'
|
|
94
94
|
// }
|
|
95
95
|
// 打包方式三
|
|
96
|
-
filename: 'arisu.module.min.js',
|
|
97
|
-
library: {
|
|
98
|
-
|
|
99
|
-
}
|
|
96
|
+
// filename: 'arisu.module.min.js',
|
|
97
|
+
// library: {
|
|
98
|
+
// type: 'module'
|
|
99
|
+
// }
|
|
100
100
|
// 取消压缩
|
|
101
101
|
// optimization: {
|
|
102
102
|
// minimize: false
|
|
103
103
|
// }
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
**/
|
|
107
107
|
|
|
108
108
|
// 打包方式四
|
|
109
109
|
module.exports = {
|
|
110
110
|
entry: './src/js/main.js',
|
|
111
111
|
mode: 'production',
|
|
112
112
|
output: {
|
|
113
|
-
|
|
114
|
-
// path: path.resolve( __dirname, "
|
|
113
|
+
path: path.resolve( __dirname, base ),//dist目录,供上线发布
|
|
114
|
+
// path: path.resolve( __dirname, "D:/develop/nodejs/node_modules/arisu/dist" ),//生成在本地测试目录,需要管理员权限打开cmd,同全局安装
|
|
115
115
|
// filename: 'arisu.min.js',
|
|
116
116
|
filename: 'arisu.js',
|
|
117
117
|
library: {
|