@impui/imp 1.0.16-beta.0 → 1.0.16

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.
Files changed (71) hide show
  1. package/dist/axios/index.es.js +1 -143
  2. package/dist/config/index.es.js +1 -127
  3. package/dist/core/index.es.js +1 -34
  4. package/dist/gotool/go2/index.es.js +1 -510
  5. package/dist/gotool/index/index.es.js +1 -164
  6. package/dist/imph5/index.es.js +1 -324
  7. package/dist/index.es.js +1 -49
  8. package/dist/login/index.es.js +1 -711
  9. package/dist/node_modules/axios/index/index.es.js +1 -38
  10. package/dist/node_modules/axios/lib/adapters/adapters/index.es.js +1 -71
  11. package/dist/node_modules/axios/lib/adapters/fetch/index.es.js +1 -219
  12. package/dist/node_modules/axios/lib/adapters/xhr/index.es.js +1 -141
  13. package/dist/node_modules/axios/lib/axios/index.es.js +1 -50
  14. package/dist/node_modules/axios/lib/cancel/CancelToken/index.es.js +1 -99
  15. package/dist/node_modules/axios/lib/cancel/CanceledError/index.es.js +1 -12
  16. package/dist/node_modules/axios/lib/cancel/isCancel/index.es.js +1 -6
  17. package/dist/node_modules/axios/lib/core/Axios/index.es.js +1 -180
  18. package/dist/node_modules/axios/lib/core/AxiosError/index.es.js +1 -80
  19. package/dist/node_modules/axios/lib/core/AxiosHeaders/index.es.js +1 -231
  20. package/dist/node_modules/axios/lib/core/InterceptorManager/index.es.js +1 -65
  21. package/dist/node_modules/axios/lib/core/buildFullPath/index.es.js +1 -12
  22. package/dist/node_modules/axios/lib/core/dispatchRequest/index.es.js +1 -52
  23. package/dist/node_modules/axios/lib/core/mergeConfig/index.es.js +1 -83
  24. package/dist/node_modules/axios/lib/core/settle/index.es.js +1 -18
  25. package/dist/node_modules/axios/lib/core/transformData/index.es.js +1 -17
  26. package/dist/node_modules/axios/lib/defaults/index/index.es.js +1 -116
  27. package/dist/node_modules/axios/lib/defaults/transitional/index.es.js +1 -8
  28. package/dist/node_modules/axios/lib/env/data/index.es.js +1 -4
  29. package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams/index.es.js +1 -34
  30. package/dist/node_modules/axios/lib/helpers/HttpStatusCode/index.es.js +1 -77
  31. package/dist/node_modules/axios/lib/helpers/bind/index.es.js +1 -8
  32. package/dist/node_modules/axios/lib/helpers/buildURL/index.es.js +1 -34
  33. package/dist/node_modules/axios/lib/helpers/combineURLs/index.es.js +1 -6
  34. package/dist/node_modules/axios/lib/helpers/composeSignals/index.es.js +1 -39
  35. package/dist/node_modules/axios/lib/helpers/cookies/index.es.js +1 -49
  36. package/dist/node_modules/axios/lib/helpers/formDataToJSON/index.es.js +1 -54
  37. package/dist/node_modules/axios/lib/helpers/isAbsoluteURL/index.es.js +1 -6
  38. package/dist/node_modules/axios/lib/helpers/isAxiosError/index.es.js +1 -7
  39. package/dist/node_modules/axios/lib/helpers/isURLSameOrigin/index.es.js +1 -11
  40. package/dist/node_modules/axios/lib/helpers/null/index.es.js +1 -4
  41. package/dist/node_modules/axios/lib/helpers/parseHeaders/index.es.js +1 -47
  42. package/dist/node_modules/axios/lib/helpers/parseProtocol/index.es.js +1 -7
  43. package/dist/node_modules/axios/lib/helpers/progressEventReducer/index.es.js +1 -41
  44. package/dist/node_modules/axios/lib/helpers/resolveConfig/index.es.js +1 -46
  45. package/dist/node_modules/axios/lib/helpers/speedometer/index.es.js +1 -36
  46. package/dist/node_modules/axios/lib/helpers/spread/index.es.js +1 -8
  47. package/dist/node_modules/axios/lib/helpers/throttle/index.es.js +1 -35
  48. package/dist/node_modules/axios/lib/helpers/toFormData/index.es.js +1 -117
  49. package/dist/node_modules/axios/lib/helpers/toURLEncodedForm/index.es.js +1 -18
  50. package/dist/node_modules/axios/lib/helpers/trackStream/index.es.js +1 -80
  51. package/dist/node_modules/axios/lib/helpers/validator/index.es.js +1 -67
  52. package/dist/node_modules/axios/lib/platform/browser/classes/Blob/index.es.js +1 -4
  53. package/dist/node_modules/axios/lib/platform/browser/classes/FormData/index.es.js +1 -4
  54. package/dist/node_modules/axios/lib/platform/browser/classes/URLSearchParams/index.es.js +1 -5
  55. package/dist/node_modules/axios/lib/platform/browser/index/index.es.js +1 -15
  56. package/dist/node_modules/axios/lib/platform/common/utils/index.es.js +1 -15
  57. package/dist/node_modules/axios/lib/platform/index/index.es.js +1 -9
  58. package/dist/node_modules/axios/lib/utils/index.es.js +1 -387
  59. package/dist/packages/com/dist/cache/index.es/index.es.js +1 -145
  60. package/dist/packages/com/dist/core/index.es/index.es.js +1 -154
  61. package/dist/packages/com/dist/data/index.es/index.es.js +1 -26
  62. package/dist/packages/com/dist/date/index.es/index.es.js +2 -194
  63. package/dist/packages/com/dist/log/index.es/index.es.js +1 -110
  64. package/dist/packages/com/dist/message/index.es/index.es.js +1 -90
  65. package/dist/packages/com/dist/req/index.es/index.es.js +1 -35
  66. package/dist/packages/com/dist/str/index.es/index.es.js +1 -25
  67. package/dist/packages/com/dist/typetool/index.es/index.es.js +1 -53
  68. package/dist/packages/com/dist/url/index.es/index.es.js +1 -238
  69. package/dist/restool/index/index.es.js +1 -266
  70. package/dist/restool/index.css/index.es.js +1 -4
  71. package/package.json +5 -1
@@ -1,238 +1 @@
1
- import { isString, isArray, isObject } from "../../typetool/index.es/index.es.js";
2
- let pageDomain = null;
3
- let path = {};
4
- function jsonto(param, url2) {
5
- url2 = url2 ? url2 : "?";
6
- if (!param) return url2;
7
- for (var key in param) {
8
- url2 = addPar(key, param[key], url2);
9
- }
10
- return url2;
11
- }
12
- function formto(data) {
13
- if (!data) return "";
14
- var str = "";
15
- for (var key in data) {
16
- str += key + "=" + data[key] + "&";
17
- }
18
- str = str.trimEnd("&");
19
- return str;
20
- }
21
- function toData(str) {
22
- if (!str) return null;
23
- let arr = str.split(",");
24
- var data = {};
25
- for (var i = 0; i < arr.length; i++) {
26
- let item = arr[i].split("=");
27
- data[item[0]] = item[1] || null;
28
- }
29
- return data;
30
- }
31
- function getDomainFromStr(url2) {
32
- if (!url2) {
33
- return "";
34
- }
35
- var index = url2.indexOf("://");
36
- index = index >= 0 ? index + 3 : 0;
37
- return url2.substr(index).split("/")[0];
38
- }
39
- function getDomain() {
40
- let key = "mh_" + Math.random();
41
- let keyR = new RegExp("(^|;)\\s*" + key + "=12345");
42
- let expiredTime = /* @__PURE__ */ new Date(0);
43
- let domain = document.domain;
44
- let domainList = domain.split(".");
45
- let port = !location.port || location.port === 80 || location.port === 443 ? "" : ":" + location.port;
46
- let urlItems = [];
47
- urlItems.unshift(domainList.pop());
48
- while (domainList.length) {
49
- urlItems.unshift(domainList.pop());
50
- let mainHost = urlItems.join(".");
51
- let cookie = key + "=12345;domain=." + mainHost;
52
- document.cookie = cookie;
53
- if (keyR.test(document.cookie)) {
54
- document.cookie = cookie + ";expires=" + expiredTime;
55
- return mainHost + port;
56
- }
57
- }
58
- return document.domain + port;
59
- }
60
- function getDomainJson(islocal) {
61
- if (pageDomain) return pageDomain;
62
- let key = "mh_" + Math.random();
63
- let keyR = new RegExp("(^|;)\\s*" + key + "=12345");
64
- let expiredTime = /* @__PURE__ */ new Date(0);
65
- let domain = document.domain;
66
- let domainList = domain.split(".");
67
- let port = !location.port || location.port === 80 || location.port === 443 ? "" : ":" + location.port;
68
- let urlItems = [];
69
- urlItems.unshift(domainList.pop());
70
- while (domainList.length) {
71
- urlItems.unshift(domainList.pop());
72
- let mainHost = urlItems.join(".");
73
- pageDomain = {
74
- main: mainHost,
75
- port,
76
- mainhost: mainHost + port,
77
- name: mainHost.split(".")[0],
78
- protocol: location.protocol
79
- };
80
- if (!islocal) {
81
- let cookie = key + "=12345;domain=." + mainHost;
82
- document.cookie = cookie;
83
- if (keyR.test(document.cookie)) {
84
- document.cookie = cookie + ";expires=" + expiredTime;
85
- pageDomain = {
86
- main: mainHost,
87
- port,
88
- mainhost: mainHost + port,
89
- name: mainHost.split(".")[0],
90
- protocol: location.protocol
91
- };
92
- return pageDomain;
93
- }
94
- } else {
95
- return pageDomain;
96
- }
97
- }
98
- if (!pageDomain) {
99
- let mainHost = "localhost";
100
- return {
101
- main: mainHost,
102
- port,
103
- mainhost: mainHost + port,
104
- name: mainHost,
105
- protocol: location.protocol
106
- };
107
- }
108
- }
109
- function getParsTo(names, prefix, c_url) {
110
- if (c_url) {
111
- const parindex = url.indexOf("?");
112
- if (parindex === -1) {
113
- return "";
114
- }
115
- c_url = c_url.substr(parindex + 1);
116
- } else {
117
- c_url = window.location.search.substr(1);
118
- }
119
- if (!c_url) {
120
- return "";
121
- }
122
- prefix = prefix === "" ? "" : prefix || "?";
123
- let str = "";
124
- let arr = c_url.split("&");
125
- names = isString(names) ? names.split(",") : names;
126
- for (var i = 0; i < arr.length; i++) {
127
- let keyOrValue = arr[i].split("=");
128
- if (keyOrValue[1] && names.indexOf(keyOrValue[0]) >= 0) {
129
- str += (str === "" ? prefix : "&") + keyOrValue[0] + "=" + keyOrValue[1];
130
- }
131
- }
132
- return str;
133
- }
134
- function getPar(name, c_url) {
135
- c_url = c_url || window.location.search.substr(1);
136
- if (!c_url) {
137
- var index = window.location.hash.indexOf("?");
138
- c_url = index >= 0 ? window.location.hash.substr(index + 1) : "";
139
- }
140
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
141
- var r = c_url.match(reg);
142
- if (r !== null)
143
- return r[2];
144
- return null;
145
- }
146
- function addPar(name, value, c_url) {
147
- if (value === null || value === void 0) return c_url;
148
- var url2 = c_url || window.location.href;
149
- url2 = delPar(name, url2);
150
- var prefix = url2 === "?" ? "" : url2.indexOf("?") >= 0 ? "&" : "?";
151
- return url2 + prefix + name + "=" + escape(value);
152
- }
153
- function addPars(data, c_url) {
154
- if (!data) return c_url;
155
- var url2 = c_url || window.location.href;
156
- var prefix = url2 === "?" ? "" : url2.indexOf("?") >= 0 ? "&" : "?";
157
- var index = 0;
158
- url2 = delPar(data, url2);
159
- for (var key in data) {
160
- if (data[key] || data[key] === 0) {
161
- prefix = index === 0 ? prefix : "&";
162
- url2 = url2 + prefix + key + "=" + escape(data[key]);
163
- index++;
164
- }
165
- }
166
- return url2;
167
- }
168
- function delPar(delNames, c_url) {
169
- var url2 = c_url || window.location.href;
170
- var str = "", parindex = url2.indexOf("?");
171
- if (parindex === -1) {
172
- return url2;
173
- }
174
- str = url2.substr(parindex + 1);
175
- if (!str) {
176
- return url2;
177
- }
178
- let arr = str.split("&");
179
- let returnurl = "";
180
- delNames = isString(delNames) ? delNames.split(",") : delNames;
181
- for (var i = 0; i < arr.length; i++) {
182
- let keyOrValue = arr[i].split("=");
183
- let name = keyOrValue[0];
184
- if (name && (isArray(delNames) && delNames.indexOf(name) === -1) || isObject(delNames) && delNames[name] === void 0) {
185
- returnurl = returnurl + name + "=" + keyOrValue[1] + "&";
186
- }
187
- }
188
- return url2.substr(0, parindex) + "?" + returnurl.substr(0, returnurl.length - 1);
189
- }
190
- function delParsUpUrl(delNames, title) {
191
- const historyUrl = delPar(delNames);
192
- history.replaceState(null, title, historyUrl);
193
- }
194
- function currentPath() {
195
- if (!path.currentPath) {
196
- path.currentPath = location.pathname.substring(0, location.pathname.lastIndexOf("/") + 1);
197
- }
198
- return path.currentPath;
199
- }
200
- function domainCurrentPath() {
201
- if (!path.domainCurrentPath) {
202
- path.domainCurrentPath = location.href.substring(0, location.href.lastIndexOf("/") + 1);
203
- }
204
- return path.domainCurrentPath;
205
- }
206
- const urltool = {
207
- jsonto,
208
- formto,
209
- toData,
210
- getDomainFromStr,
211
- getDomain,
212
- getDomainJson,
213
- getParsTo,
214
- getPar,
215
- addPar,
216
- addPars,
217
- delPar,
218
- delParsUpUrl,
219
- currentPath,
220
- domainCurrentPath
221
- };
222
- export {
223
- addPar,
224
- addPars,
225
- currentPath,
226
- delPar,
227
- delParsUpUrl,
228
- domainCurrentPath,
229
- formto,
230
- getDomain,
231
- getDomainFromStr,
232
- getDomainJson,
233
- getPar,
234
- getParsTo,
235
- jsonto,
236
- toData,
237
- urltool
238
- };
1
+ import{isString as t,isArray as n,isObject as o}from"../../typetool/index.es/index.es.js";let r=null,e={};function i(t,n){if(n=n||"?",!t)return n;for(var o in t)n=p(o,t[o],n);return n}function a(t){if(!t)return"";var n="";for(var o in t)n+=o+"="+t[o]+"&";return n.trimEnd("&")}function s(t){if(!t)return null;let n=t.split(",");for(var o={},r=0;r<n.length;r++){let t=n[r].split("=");o[t[0]]=t[1]||null}return o}function l(t){if(!t)return"";var n=t.indexOf("://");return n=n>=0?n+3:0,t.substr(n).split("/")[0]}function u(){let t="mh_"+Math.random(),n=new RegExp("(^|;)\\s*"+t+"=12345"),o=/* @__PURE__ */new Date(0),r=document.domain.split("."),e=location.port&&80!==location.port&&443!==location.port?":"+location.port:"",i=[];for(i.unshift(r.pop());r.length;){i.unshift(r.pop());let a=i.join("."),s=t+"=12345;domain=."+a;if(document.cookie=s,n.test(document.cookie))return document.cookie=s+";expires="+o,a+e}return document.domain+e}function c(t){if(r)return r;let n="mh_"+Math.random(),o=new RegExp("(^|;)\\s*"+n+"=12345"),e=/* @__PURE__ */new Date(0),i=document.domain.split("."),a=location.port&&80!==location.port&&443!==location.port?":"+location.port:"",s=[];for(s.unshift(i.pop());i.length;){s.unshift(i.pop());let l=s.join(".");if(r={main:l,port:a,mainhost:l+a,name:l.split(".")[0],protocol:location.protocol},t)return r;{let t=n+"=12345;domain=."+l;if(document.cookie=t,o.test(document.cookie))return document.cookie=t+";expires="+e,r={main:l,port:a,mainhost:l+a,name:l.split(".")[0],protocol:location.protocol},r}}if(!r){let t="localhost";return{main:t,port:a,mainhost:t+a,name:t,protocol:location.protocol}}}function f(n,o,r){if(r){const t=url.indexOf("?");if(-1===t)return"";r=r.substr(t+1)}else r=window.location.search.substr(1);if(!r)return"";o=""===o?"":o||"?";let e="",i=r.split("&");n=t(n)?n.split(","):n;for(var a=0;a<i.length;a++){let t=i[a].split("=");t[1]&&n.indexOf(t[0])>=0&&(e+=(""===e?o:"&")+t[0]+"="+t[1])}return e}function d(t,n){if(!(n=n||window.location.search.substr(1))){var o=window.location.hash.indexOf("?");n=o>=0?window.location.hash.substr(o+1):""}var r=new RegExp("(^|&)"+t+"=([^&]*)(&|$)","i"),e=n.match(r);return null!==e?e[2]:null}function p(t,n,o){if(null==n)return o;var r=o||window.location.href,e="?"===(r=h(t,r))?"":r.indexOf("?")>=0?"&":"?";return r+e+t+"="+escape(n)}function m(t,n){if(!t)return n;var o=n||window.location.href,r="?"===o?"":o.indexOf("?")>=0?"&":"?",e=0;for(var i in o=h(t,o),t)(t[i]||0===t[i])&&(o=o+(r=0===e?r:"&")+i+"="+escape(t[i]),e++);return o}function h(r,e){var i=e||window.location.href,a="",s=i.indexOf("?");if(-1===s)return i;if(!(a=i.substr(s+1)))return i;let l=a.split("&"),u="";r=t(r)?r.split(","):r;for(var c=0;c<l.length;c++){let t=l[c].split("="),e=t[0];(e&&n(r)&&-1===r.indexOf(e)||o(r)&&void 0===r[e])&&(u=u+e+"="+t[1]+"&")}return i.substr(0,s)+"?"+u.substr(0,u.length-1)}function g(t,n){const o=h(t);history.replaceState(null,n,o)}function P(){return e.currentPath||(e.currentPath=location.pathname.substring(0,location.pathname.lastIndexOf("/")+1)),e.currentPath}function w(){return e.domainCurrentPath||(e.domainCurrentPath=location.href.substring(0,location.href.lastIndexOf("/")+1)),e.domainCurrentPath}const x={jsonto:i,formto:a,toData:s,getDomainFromStr:l,getDomain:u,getDomainJson:c,getParsTo:f,getPar:d,addPar:p,addPars:m,delPar:h,delParsUpUrl:g,currentPath:P,domainCurrentPath:w};export{p as addPar,m as addPars,P as currentPath,h as delPar,g as delParsUpUrl,w as domainCurrentPath,a as formto,u as getDomain,l as getDomainFromStr,c as getDomainJson,d as getPar,f as getParsTo,i as jsonto,s as toData,x as urltool};
@@ -1,266 +1 @@
1
- import { isString, isObject, isArray } from "@impui/com/typetool";
2
- import { injectCSS } from "@impui/com/style";
3
- import cssText from "../index.css/index.es.js";
4
- import { getConfig } from "../../config/index.es.js";
5
- injectCSS(cssText, "imp-restool");
6
- const zipCache = {};
7
- class Restool {
8
- constructor() {
9
- this._config = null;
10
- this.initPromise = this.init();
11
- }
12
- /**
13
- * 初始化配置
14
- */
15
- async init() {
16
- if (!this._config) {
17
- this._config = await getConfig();
18
- }
19
- return this;
20
- }
21
- /**
22
- * 确保配置已加载
23
- */
24
- async ensureConfig() {
25
- if (!this._config) {
26
- await this.initPromise;
27
- }
28
- return this;
29
- }
30
- /**
31
- * 默认常用资源
32
- */
33
- get statics() {
34
- if (!this._config) return { nohead: "" };
35
- return {
36
- nohead: `${this._config.sr}/live/webSkins_site/${this._config.sitetype}/images/nohead.jpg`
37
- };
38
- }
39
- /**
40
- * 获取资源url地址
41
- * @param {string|number} type 资源类型(枚举key或值)
42
- * @param {string|number} name 资源id或名称
43
- * @param {string} verKey 版本key
44
- * @returns {string} 资源URL
45
- */
46
- getSrc(type, name, verKey) {
47
- if (!this._config) return "";
48
- let typeInt = type;
49
- if (isNaN(parseInt(type))) {
50
- typeInt = this._config.paths.typeEnums[type];
51
- }
52
- if (isString(type) && ["emblem", "bubble", "head", "cardskin"].indexOf(type.toLowerCase()) >= 0 && (isObject(name) || isArray(name))) {
53
- name = this.titlesTool.getTitlexIdFromType(name, type);
54
- if (name === 0) {
55
- return "";
56
- }
57
- }
58
- if (typeInt !== 4 && name != 0 && !name) return "";
59
- typeInt = parseInt(typeInt);
60
- const resObj = this._config.paths.types[`t_${typeInt}`];
61
- const path = resObj.pc_path || resObj.path;
62
- const suffix = resObj.pc_suffix || resObj.suffix;
63
- let ver = this._config.js_version;
64
- if (verKey) {
65
- const codeVer = impui.getCodeVer();
66
- ver = codeVer[verKey] || this._config.js_version;
67
- }
68
- if (name || name === 0) {
69
- return `${path}${name}${suffix}?d=${ver}`;
70
- } else {
71
- return `${path}?d=${ver}`;
72
- }
73
- }
74
- /**
75
- * 获取表情图片
76
- * @param {string} path 表情子目录
77
- * @param {string} v 表情名
78
- * @param {boolean} isSmall 是否小图
79
- * @returns {string} 表情URL
80
- */
81
- getEmotSrc(path, v, isSmall = false) {
82
- if (isSmall) {
83
- return this.getSrc("emot", `${path}/${v}_s`);
84
- }
85
- return this.getSrc("emot", `${path}/${v}`);
86
- }
87
- /**
88
- * 获取用户等级图标
89
- * @param {number|string} level 用户等级
90
- * @returns {string} 等级图标URL
91
- */
92
- getUserLevelSrc(level) {
93
- return this.getSrc("user", level);
94
- }
95
- /**
96
- * 获取主播等级图标
97
- * @param {number|string} level 主播等级
98
- * @returns {string} 主播等级图标URL
99
- */
100
- getAnchorLevelSrc(level) {
101
- return this.getSrc("host", level);
102
- }
103
- /**
104
- * 获取气泡zip包地址
105
- * @param {number} bubbleId 气泡ID
106
- * @returns {string} zip包URL
107
- */
108
- getBubbleZipSrc(bubbleId) {
109
- return this.getSrc("bubble_zip", bubbleId);
110
- }
111
- /**
112
- * 获取粉丝团等级图标HTML
113
- * @param {number} level 粉丝团等级
114
- * @param {string} name 粉丝团名称
115
- * @returns {string} HTML字符串
116
- */
117
- getFanclubLevelHtml(level, name) {
118
- return `<span class="fanclubgrage" style="background-image:url(${this.getSrc("fans_grade", level)})">${name}</span>`;
119
- }
120
- /**
121
- * 获取气泡图片映射
122
- * @param {number} bubbleId 气泡ID
123
- * @param {Function} filterFn 过滤函数
124
- * @returns {Promise<Object>} 图片映射
125
- */
126
- async getBubbleImageMap(bubbleId, filterFn) {
127
- const zipUrl = this.getBubbleZipSrc(bubbleId);
128
- return await this.getZipUrlMap(zipUrl, filterFn);
129
- }
130
- /**
131
- * 获取接口图片地址
132
- * @param {string} src 图片地址
133
- * @returns {string} 完整URL
134
- */
135
- getSrImgSrc(src) {
136
- if (!src) return "";
137
- if (src.startsWith("http")) return src;
138
- return `${this._config.sr}${src.startsWith("/") ? src : "/" + src}`;
139
- }
140
- /**
141
- * 获取压缩包文件映射
142
- * @param {string} zipurl zip包URL
143
- * @param {Function} filterFn 过滤函数
144
- * @returns {Promise<Object>} 文件映射
145
- */
146
- async getZipUrlMap(zipurl, filterFn) {
147
- await this.ensureConfig();
148
- const { jszip } = await impui.loadAsync(["jszip"]);
149
- const zip = new jszip();
150
- try {
151
- let zipFile;
152
- if (zipCache[zipurl]) {
153
- zipFile = zipCache[zipurl];
154
- } else {
155
- const zipRes = await fetch(zipurl);
156
- const zipData = await zipRes.arrayBuffer();
157
- zipFile = await zip.loadAsync(zipData);
158
- zipCache[zipurl] = zipFile;
159
- }
160
- filterFn = filterFn || (() => true);
161
- const blobMap = {};
162
- const blobPromises = [];
163
- zipFile.forEach(async (relativePath, zipEntry) => {
164
- if (filterFn(relativePath, zipEntry)) {
165
- const blobPromise = zipEntry.async("blob").then((fileBlob) => {
166
- const url = URL.createObjectURL(fileBlob);
167
- return { key: relativePath, url };
168
- });
169
- blobPromises.push(blobPromise);
170
- }
171
- });
172
- const files = await Promise.all(blobPromises);
173
- files.forEach((item) => {
174
- blobMap[item.key] = item.url;
175
- });
176
- return blobMap;
177
- } catch (e) {
178
- console.error("获取压缩包失败:", e);
179
- return null;
180
- }
181
- }
182
- /**
183
- * titleEx工具类
184
- */
185
- get titlesTool() {
186
- return {
187
- /**
188
- * 转换titleEx格式
189
- */
190
- converTitlesex: (titex) => {
191
- if (!titex) return {};
192
- if (isObject(titex)) return titex;
193
- if (isString(titex)) return JSON.parse(titex);
194
- const ret = {};
195
- if (isArray(titex)) {
196
- titex.forEach((item) => {
197
- ret[item.titleid] = item;
198
- });
199
- }
200
- return ret;
201
- },
202
- /**
203
- * 根据类型获取titleEx ID数组
204
- */
205
- getTitlesexFromType: (titex, type) => {
206
- const converted = this.titlesTool.converTitlesex(titex);
207
- const titles = [];
208
- for (const key in converted) {
209
- const item = converted[key];
210
- if (item.type === type) {
211
- titles.push(parseInt(key));
212
- }
213
- }
214
- return titles;
215
- },
216
- /**
217
- * 根据类型获取titleEx ID
218
- */
219
- getTitlexIdFromType: (titex, type) => {
220
- const converted = this.titlesTool.converTitlesex(titex);
221
- let ret = 0;
222
- let currentTime = Number.MAX_VALUE;
223
- const typeLower = type.toLowerCase();
224
- for (const key in converted) {
225
- const item = converted[key];
226
- const tempType = item.type.toLowerCase();
227
- if (tempType === typeLower) {
228
- if (typeLower !== "bubble") {
229
- return parseInt(key);
230
- }
231
- const endTime = parseInt(item.endtime);
232
- if (endTime < currentTime) {
233
- ret = parseInt(key);
234
- currentTime = endTime;
235
- }
236
- }
237
- }
238
- return ret;
239
- },
240
- /**
241
- * 获取头像框图片地址
242
- */
243
- getHeadBorderSrc: (borderid) => {
244
- return this.getSrc(7, borderid);
245
- },
246
- /**
247
- * 获取头像框HTML
248
- */
249
- getHeadBorderImg: (borderid) => {
250
- return `<div class="border_img"><img src="${this.titlesTool.getHeadBorderSrc(borderid)}" /></div>`;
251
- },
252
- /**
253
- * 获取头像框
254
- */
255
- getHeadBorder: (box, borderid) => {
256
- box.addClass("headBorder");
257
- box.append(this.titlesTool.getHeadBorderImg(borderid));
258
- return box;
259
- }
260
- };
261
- }
262
- }
263
- const restool = new Restool();
264
- export {
265
- restool
266
- };
1
+ import{isString as t,isObject as e,isArray as r}from"@impui/com/typetool";import{injectCSS as i}from"@impui/com/style";import s from"../index.css/index.es.js";import{getConfig as n}from"../../config/index.es.js";i(s,"imp-restool");const o={};const c=new class{constructor(){this._config=null,this.initPromise=this.init()}async init(){return this._config||(this._config=await n()),this}async ensureConfig(){return this._config||await this.initPromise,this}get statics(){return this._config?{nohead:`${this._config.sr}/live/webSkins_site/${this._config.sitetype}/images/nohead.jpg`}:{nohead:""}}getSrc(i,s,n){if(!this._config)return"";let o=i;if(isNaN(parseInt(i))&&(o=this._config.paths.typeEnums[i]),t(i)&&["emblem","bubble","head","cardskin"].indexOf(i.toLowerCase())>=0&&(e(s)||r(s))&&0===(s=this.titlesTool.getTitlexIdFromType(s,i)))return"";if(4!==o&&0!=s&&!s)return"";o=parseInt(o);const c=this._config.paths.types[`t_${o}`],a=c.pc_path||c.path,l=c.pc_suffix||c.suffix;let g=this._config.js_version;if(n){g=impui.getCodeVer()[n]||this._config.js_version}return s||0===s?`${a}${s}${l}?d=${g}`:`${a}?d=${g}`}getEmotSrc(t,e,r=!1){return r?this.getSrc("emot",`${t}/${e}_s`):this.getSrc("emot",`${t}/${e}`)}getUserLevelSrc(t){return this.getSrc("user",t)}getAnchorLevelSrc(t){return this.getSrc("host",t)}getBubbleZipSrc(t){return this.getSrc("bubble_zip",t)}getFanclubLevelHtml(t,e){return`<span class="fanclubgrage" style="background-image:url(${this.getSrc("fans_grade",t)})">${e}</span>`}async getBubbleImageMap(t,e){const r=this.getBubbleZipSrc(t);return await this.getZipUrlMap(r,e)}getSrImgSrc(t){return t?t.startsWith("http")?t:`${this._config.sr}${t.startsWith("/")?t:"/"+t}`:""}async getZipUrlMap(t,e){await this.ensureConfig();const{jszip:r}=await impui.loadAsync(["jszip"]),i=new r;try{let r;if(o[t])r=o[t];else{const e=await fetch(t),s=await e.arrayBuffer();r=await i.loadAsync(s),o[t]=r}e=e||(()=>!0);const s={},n=[];r.forEach(async(t,r)=>{if(e(t,r)){const e=r.async("blob").then(e=>{const r=URL.createObjectURL(e);return{key:t,url:r}});n.push(e)}});return(await Promise.all(n)).forEach(t=>{s[t.key]=t.url}),s}catch(s){return console.error("获取压缩包失败:",s),null}}get titlesTool(){return{converTitlesex:i=>{if(!i)return{};if(e(i))return i;if(t(i))return JSON.parse(i);const s={};return r(i)&&i.forEach(t=>{s[t.titleid]=t}),s},getTitlesexFromType:(t,e)=>{const r=this.titlesTool.converTitlesex(t),i=[];for(const s in r){r[s].type===e&&i.push(parseInt(s))}return i},getTitlexIdFromType:(t,e)=>{const r=this.titlesTool.converTitlesex(t);let i=0,s=Number.MAX_VALUE;const n=e.toLowerCase();for(const o in r){const t=r[o];if(t.type.toLowerCase()===n){if("bubble"!==n)return parseInt(o);const e=parseInt(t.endtime);e<s&&(i=parseInt(o),s=e)}}return i},getHeadBorderSrc:t=>this.getSrc(7,t),getHeadBorderImg:t=>`<div class="border_img"><img src="${this.titlesTool.getHeadBorderSrc(t)}" /></div>`,getHeadBorder:(t,e)=>(t.addClass("headBorder"),t.append(this.titlesTool.getHeadBorderImg(e)),t)}}};export{c as restool};
@@ -1,4 +1 @@
1
- const cssText = "\r\n\r\n\r\n/*粉丝团等级*/\r\n.fanclubgrage{background-repeat:no-repeat;background-size:100%;height:22px !important;aspect-ratio: 77 / 22;display:inline-block;color:#fff;text-indent:32px;line-height:23px !important;font-size: 12px;}\r\n\r\n\r\n";
2
- export {
3
- cssText as default
4
- };
1
+ const n="\r\n\r\n\r\n/*粉丝团等级*/\r\n.fanclubgrage{background-repeat:no-repeat;background-size:100%;height:22px !important;aspect-ratio: 77 / 22;display:inline-block;color:#fff;text-indent:32px;line-height:23px !important;font-size: 12px;}\r\n\r\n\r\n";export{n as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@impui/imp",
3
- "version": "1.0.16-beta.0",
3
+ "version": "1.0.16",
4
4
  "description": "此库主要是公司相关的特殊处理,只用于公司专有项目,无法用于其他项目",
5
5
  "main": "dist/index.es.js",
6
6
  "files": [
@@ -25,5 +25,9 @@
25
25
  "type": "commonjs",
26
26
  "devDependencies": {
27
27
  "axios": "^1.13.2"
28
+ },
29
+ "dependencies": {
30
+ "@impui/com": "^1.1.3-beta.7",
31
+ "axios": "^1.13.2"
28
32
  }
29
33
  }