bluestar-util 1.0.3
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/dist/blue-star/util/src/common/control.d.ts +7 -0
- package/dist/blue-star/util/src/data/binaryProcessor.d.ts +7 -0
- package/dist/blue-star/util/src/data/color.d.ts +13 -0
- package/dist/blue-star/util/src/data/createValueMap.d.ts +9 -0
- package/dist/blue-star/util/src/data/hash.d.ts +1 -0
- package/dist/blue-star/util/src/data/isNullOrUndefined.d.ts +4 -0
- package/dist/blue-star/util/src/data/linerInsert.d.ts +23 -0
- package/dist/blue-star/util/src/data/weg.d.ts +31 -0
- package/dist/blue-star/util/src/http/RequestInstance.d.ts +142 -0
- package/dist/blue-star/util/src/http/http.d.ts +60 -0
- package/dist/blue-star/util/src/http/httpOriginCache/WorkerRequestInstance.d.ts +48 -0
- package/dist/blue-star/util/src/http/httpOriginCache/httpOriginCache.worker.d.ts +1 -0
- package/dist/blue-star/util/src/http/httpOriginCache/opfs.d.ts +5 -0
- package/dist/blue-star/util/src/http/queryStringParser.d.ts +1 -0
- package/dist/blue-star/util/src/http/useApi.d.ts +67 -0
- package/dist/blue-star/util/src/index.d.ts +15 -0
- package/dist/blue-star/util/src/lang/lang.d.ts +42 -0
- package/dist/blue-star/util/src/setting/baseSetting.d.ts +3 -0
- package/dist/blue-star/util/src/setting/globalSetting.d.ts +13 -0
- package/dist/blue-star/util/src/time/delay.d.ts +1 -0
- package/dist/blue-star/util/src/vue/component.d.ts +4 -0
- package/dist/blue-star/util/src/vue/createState.d.ts +7 -0
- package/dist/blue-star/util/src/vue/requestInterceptor.d.ts +30 -0
- package/dist/blue-star/util/src/vue/vueUse.d.ts +18 -0
- package/dist/blue-star/util/src/webGL/color.d.ts +7 -0
- package/dist/blue-star/util/src/webGL/vec.d.ts +26 -0
- package/dist/blue-star/util/src/webGL/webglTool.d.ts +62 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +935 -0
- package/dist/style.css +1 -0
- package/dist/types/types.d.ts +9 -0
- package/package.json +11 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,935 @@
|
|
|
1
|
+
var Xe = Object.defineProperty;
|
|
2
|
+
var Ge = (t, e, n) => e in t ? Xe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var b = (t, e, n) => Ge(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { reactive as Q, unref as We, openBlock as Se, createElementBlock as ke, createElementVNode as R, withDirectives as ne, vModelText as se, createCommentVNode as Ve, getCurrentInstance as Le, onBeforeUnmount as K, onMounted as O } from "vue";
|
|
5
|
+
const ve = (t, e) => {
|
|
6
|
+
const n = t.__vccOpts || t;
|
|
7
|
+
for (const [s, r] of e)
|
|
8
|
+
n[s] = r;
|
|
9
|
+
return n;
|
|
10
|
+
}, Ie = {
|
|
11
|
+
key: 0,
|
|
12
|
+
class: "local-dev-ip-setter"
|
|
13
|
+
}, Ne = { class: "setter-item" }, xe = { class: "setter-item" }, Ue = {
|
|
14
|
+
__name: "local-dev-ip-setter",
|
|
15
|
+
emits: ["visible"],
|
|
16
|
+
setup(t, { emit: e }) {
|
|
17
|
+
const n = process.env.NODE_ENV, s = e, r = Q({
|
|
18
|
+
ip: localStorage.getItem("DEVIP") ?? "",
|
|
19
|
+
port: localStorage.getItem("DEVPORT") ?? ""
|
|
20
|
+
});
|
|
21
|
+
function a() {
|
|
22
|
+
confirm("保存后的IP端口设置将在下次打开浏览器生效,请确认。") && (localStorage.setItem("DEVIP", r.ip), localStorage.setItem("DEVPORT", r.port), window.location.reload());
|
|
23
|
+
}
|
|
24
|
+
function o() {
|
|
25
|
+
s("visible", !1);
|
|
26
|
+
}
|
|
27
|
+
return (h, i) => We(n) === "development" ? (Se(), ke("div", Ie, [
|
|
28
|
+
R("div", null, [
|
|
29
|
+
i[4] || (i[4] = R("div", { class: "setter-title" }, "本地IP端口设置", -1)),
|
|
30
|
+
R("div", Ne, [
|
|
31
|
+
i[2] || (i[2] = R("label", { for: "devip" }, "请输入ip", -1)),
|
|
32
|
+
ne(R("input", {
|
|
33
|
+
class: "setter-input",
|
|
34
|
+
type: "text",
|
|
35
|
+
"onUpdate:modelValue": i[0] || (i[0] = (d) => r.ip = d),
|
|
36
|
+
placeholder: "例如: 127.0.0.1",
|
|
37
|
+
id: "devip"
|
|
38
|
+
}, null, 512), [
|
|
39
|
+
[se, r.ip]
|
|
40
|
+
])
|
|
41
|
+
]),
|
|
42
|
+
R("div", xe, [
|
|
43
|
+
i[3] || (i[3] = R("label", { for: "devport" }, "请输入port", -1)),
|
|
44
|
+
ne(R("input", {
|
|
45
|
+
class: "setter-input",
|
|
46
|
+
type: "text",
|
|
47
|
+
"onUpdate:modelValue": i[1] || (i[1] = (d) => r.port = d),
|
|
48
|
+
placeholder: "数值",
|
|
49
|
+
id: "devport"
|
|
50
|
+
}, null, 512), [
|
|
51
|
+
[se, r.port]
|
|
52
|
+
])
|
|
53
|
+
]),
|
|
54
|
+
R("div", null, [
|
|
55
|
+
R("button", {
|
|
56
|
+
class: "save-button",
|
|
57
|
+
onClick: a
|
|
58
|
+
}, "保存")
|
|
59
|
+
]),
|
|
60
|
+
R("div", {
|
|
61
|
+
class: "close-button",
|
|
62
|
+
onClick: o
|
|
63
|
+
}, "×")
|
|
64
|
+
])
|
|
65
|
+
])) : Ve("", !0);
|
|
66
|
+
}
|
|
67
|
+
}, Je = /* @__PURE__ */ ve(Ue, [["__scopeId", "data-v-aa74a9b4"]]), _e = Je;
|
|
68
|
+
function $e(t = 1e3, e = 10) {
|
|
69
|
+
const n = Le();
|
|
70
|
+
return function() {
|
|
71
|
+
const s = 1e3 / e, r = t / s;
|
|
72
|
+
return new Promise((a) => {
|
|
73
|
+
if (n) {
|
|
74
|
+
if (n.isUnmounted)
|
|
75
|
+
return;
|
|
76
|
+
if (n.isMounted)
|
|
77
|
+
a();
|
|
78
|
+
else {
|
|
79
|
+
let o = 0, h = setTimeout(() => {
|
|
80
|
+
n.isMounted ? (a(), clearTimeout(h)) : (o++, o > r && clearTimeout(h));
|
|
81
|
+
}, s);
|
|
82
|
+
}
|
|
83
|
+
} else
|
|
84
|
+
console.error("无效的拦截器: 拦截器必须定义在vue组件的setup函数中!"), a();
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function ce(t) {
|
|
89
|
+
return new Promise((e) => setTimeout(e, t));
|
|
90
|
+
}
|
|
91
|
+
const he = "dmFyIEI9T2JqZWN0LmRlZmluZVByb3BlcnR5O3ZhciBrPShnLHUsdyk9PnUgaW4gZz9CKGcsdSx7ZW51bWVyYWJsZTohMCxjb25maWd1cmFibGU6ITAsd3JpdGFibGU6ITAsdmFsdWU6d30pOmdbdV09dzt2YXIgZj0oZyx1LHcpPT5rKGcsdHlwZW9mIHUhPSJzeW1ib2wiP3UrIiI6dSx3KTsoZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7ZnVuY3Rpb24gZyh0KXtyZXR1cm4gdCBpbnN0YW5jZW9mIEZvcm1EYXRhP3Q6dD9KU09OLnN0cmluZ2lmeSh0KTpudWxsfWNvbnN0IHU9e2FzeW5jIGFsZXJ0KHQpe3JldHVybiIifSxhc3luYyB3YXJuaW5nKHQpe3JldHVybiIifSxhc3luYyBjb25maXJtKHQpe3JldHVybiIifSxhc3luYyBlcnJvcih0KXtyZXR1cm4iIn0sYXN5bmMgc3VjY2Vzcyh0KXtyZXR1cm4iIn19O2NsYXNzIHd7Y29uc3RydWN0b3IoZSl7Zih0aGlzLCJyZXF1ZXN0SW50ZXJjZXB0ZXJMaXN0IixbXSk7Zih0aGlzLCJoZWFkZXJzIix7fSk7Zih0aGlzLCJiYXNlVVJMIiwiIik7Zih0aGlzLCJVUkxTIixbXSk7Zih0aGlzLCJtb2NrUG9ydCIsMzc3NzgpO2YodGhpcywiTWVzc2FnZUJveCIsdSk7Zih0aGlzLCJ0b2tlbiIsIiIpO2YodGhpcywiZ2V0dGluZ1JlcXVlc3R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nNsaWNlKDQsNCthKSxzPW5ldyBUZXh0RGVjb2RlcigpLmRlY29kZShyKSxuPUpTT04ucGFyc2UocyksaT1lLmJ1ZmZlci5zbGljZSg0K2EpO3JldHVybntoZWFkZXJzOm4sYnVmZmVyOml9fX0pKCk7Cg==", Fe = (t) => Uint8Array.from(atob(t), (e) => e.charCodeAt(0)), re = typeof self < "u" && self.Blob && new Blob([Fe(he)], { type: "text/javascript;charset=utf-8" });
|
|
92
|
+
function Ce(t) {
|
|
93
|
+
let e;
|
|
94
|
+
try {
|
|
95
|
+
if (e = re && (self.URL || self.webkitURL).createObjectURL(re), !e) throw "";
|
|
96
|
+
const n = new Worker(e, {
|
|
97
|
+
name: t == null ? void 0 : t.name
|
|
98
|
+
});
|
|
99
|
+
return n.addEventListener("error", () => {
|
|
100
|
+
(self.URL || self.webkitURL).revokeObjectURL(e);
|
|
101
|
+
}), n;
|
|
102
|
+
} catch {
|
|
103
|
+
return new Worker(
|
|
104
|
+
"data:text/javascript;base64," + he,
|
|
105
|
+
{
|
|
106
|
+
name: t == null ? void 0 : t.name
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
} finally {
|
|
110
|
+
e && (self.URL || self.webkitURL).revokeObjectURL(e);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const oe = {
|
|
114
|
+
uint8: Uint8Array,
|
|
115
|
+
// float16: Float16Array,
|
|
116
|
+
float32: Float32Array,
|
|
117
|
+
int8: Int8Array,
|
|
118
|
+
int16: Int16Array,
|
|
119
|
+
int32: Int32Array
|
|
120
|
+
};
|
|
121
|
+
function ue(t) {
|
|
122
|
+
const e = new TextDecoder("utf-8");
|
|
123
|
+
if (!t || t.byteLength < 3)
|
|
124
|
+
throw console.error("Weg解析错误: 数据长度过小"), new Error("数据异常");
|
|
125
|
+
const n = new DataView(t);
|
|
126
|
+
if (n.getUint8(0) === 123 && n.getUint8(1) === 34 && n.getUint8(t.byteLength - 1) === 125) {
|
|
127
|
+
const p = e.decode(t), Z = JSON.parse(p);
|
|
128
|
+
throw console.error("Weg解析错误: " + Z.msg), new Error(Z.msg);
|
|
129
|
+
}
|
|
130
|
+
const s = n.getInt32(0, !0);
|
|
131
|
+
if (s < 0)
|
|
132
|
+
throw console.error("Weg文件格式错误: weg内JSON长度不存在"), new Error("数据异常");
|
|
133
|
+
if (s + 4 > t.byteLength)
|
|
134
|
+
throw console.error("Weg文件格式错误: 数据长度错误,请检查响应数据"), new Error("数据异常");
|
|
135
|
+
const r = t.slice(4, s + 4), a = e.decode(r).trim();
|
|
136
|
+
if (a[0] !== "{" && a[a.length - 1] !== "}")
|
|
137
|
+
throw console.error(`Weg文件格式错误: 数据内json错误或该文件并非weg文件
|
|
138
|
+
`), new Error("数据异常");
|
|
139
|
+
const o = JSON.parse(a), h = t.slice(4 + s);
|
|
140
|
+
if (o.width === void 0 || o.height === void 0)
|
|
141
|
+
throw console.error(`Weg文件格式错误: 数据内json错误,width,height 字段不存在。
|
|
142
|
+
` + a), new Error("数据异常");
|
|
143
|
+
o.dtype === void 0 && (o.dtype = "float32");
|
|
144
|
+
const i = o.width * o.height, d = o.dtype.split(":"), l = d[0], u = d[1] ?? "R";
|
|
145
|
+
if (o.dtype = l, o.pixelFormat = u, !o.dtype || oe[o.dtype] === void 0)
|
|
146
|
+
throw console.error("Weg文件格式错误: 数据内json错误,该数据类型不支持"), new Error("数据异常");
|
|
147
|
+
let c = oe[o.dtype], m = i * c.BYTES_PER_ELEMENT * u.length;
|
|
148
|
+
if (m > 0) {
|
|
149
|
+
const p = h.byteLength / m;
|
|
150
|
+
if (p === 1)
|
|
151
|
+
o.data = new c(h);
|
|
152
|
+
else if (p === 2)
|
|
153
|
+
o.data = new c(h, 0, i), o.directionData = new c(h, m, i);
|
|
154
|
+
else
|
|
155
|
+
throw console.error(`Weg文件格式错误: 数据内json错误,data 字段长度错误。
|
|
156
|
+
` + JSON.stringify(o)), new Error("数据异常");
|
|
157
|
+
return o;
|
|
158
|
+
} else
|
|
159
|
+
throw console.error("Weg文件格式错误: 数据内json错误,data 字段长度错误。baseInfo.width * baseInfo.height * 4 = " + m), new Error("数据异常");
|
|
160
|
+
}
|
|
161
|
+
async function et(t) {
|
|
162
|
+
const e = new Blob([t]), n = new DecompressionStream("gzip"), s = e.stream().pipeThrough(n);
|
|
163
|
+
return t = await (await new Response(s).blob()).arrayBuffer(), ue(t);
|
|
164
|
+
}
|
|
165
|
+
const y = [];
|
|
166
|
+
for (let t = 0; t < 256; ++t)
|
|
167
|
+
y.push((t + 256).toString(16).slice(1));
|
|
168
|
+
function Te(t, e = 0) {
|
|
169
|
+
return (y[t[e + 0]] + y[t[e + 1]] + y[t[e + 2]] + y[t[e + 3]] + "-" + y[t[e + 4]] + y[t[e + 5]] + "-" + y[t[e + 6]] + y[t[e + 7]] + "-" + y[t[e + 8]] + y[t[e + 9]] + "-" + y[t[e + 10]] + y[t[e + 11]] + y[t[e + 12]] + y[t[e + 13]] + y[t[e + 14]] + y[t[e + 15]]).toLowerCase();
|
|
170
|
+
}
|
|
171
|
+
let D;
|
|
172
|
+
const Me = new Uint8Array(16);
|
|
173
|
+
function Pe() {
|
|
174
|
+
if (!D) {
|
|
175
|
+
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
176
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
177
|
+
D = crypto.getRandomValues.bind(crypto);
|
|
178
|
+
}
|
|
179
|
+
return D(Me);
|
|
180
|
+
}
|
|
181
|
+
const ze = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ae = { randomUUID: ze };
|
|
182
|
+
function Ke(t, e, n) {
|
|
183
|
+
var r;
|
|
184
|
+
t = t || {};
|
|
185
|
+
const s = t.random ?? ((r = t.rng) == null ? void 0 : r.call(t)) ?? Pe();
|
|
186
|
+
if (s.length < 16)
|
|
187
|
+
throw new Error("Random bytes length must be >= 16");
|
|
188
|
+
return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, Te(s);
|
|
189
|
+
}
|
|
190
|
+
function M(t, e, n) {
|
|
191
|
+
return ae.randomUUID && !e && !t ? ae.randomUUID() : Ke(t);
|
|
192
|
+
}
|
|
193
|
+
function ie(t) {
|
|
194
|
+
return t instanceof FormData ? t : t ? JSON.stringify(t) : null;
|
|
195
|
+
}
|
|
196
|
+
const Ee = {
|
|
197
|
+
async alert(t) {
|
|
198
|
+
return "";
|
|
199
|
+
},
|
|
200
|
+
async warning(t) {
|
|
201
|
+
return "";
|
|
202
|
+
},
|
|
203
|
+
async confirm(t) {
|
|
204
|
+
return "";
|
|
205
|
+
},
|
|
206
|
+
async error(t) {
|
|
207
|
+
return "";
|
|
208
|
+
},
|
|
209
|
+
async success(t) {
|
|
210
|
+
return "";
|
|
211
|
+
}
|
|
212
|
+
}, X = class X {
|
|
213
|
+
constructor(e) {
|
|
214
|
+
b(this, "requestIntercepterList", []);
|
|
215
|
+
b(this, "headers", {});
|
|
216
|
+
b(this, "baseURL", "");
|
|
217
|
+
b(this, "URLS", []);
|
|
218
|
+
b(this, "mockPort", 37778);
|
|
219
|
+
// mock server端口
|
|
220
|
+
b(this, "MessageBox", Ee);
|
|
221
|
+
b(this, "worker");
|
|
222
|
+
b(this, "token", "");
|
|
223
|
+
b(this, "workerRequestList", []);
|
|
224
|
+
b(this, "requestAlert", !1);
|
|
225
|
+
b(this, "evn", "production");
|
|
226
|
+
b(this, "mockMode", !1);
|
|
227
|
+
b(this, "sourceBasePath");
|
|
228
|
+
typeof e == "string" ? this.baseURL = e : e instanceof Array && (this.baseURL = e[0], this.URLS = e), this.worker = new Ce(), this.worker.onmessage = this.receiveWorkerResponse.bind(this), this.worker.postMessage({
|
|
229
|
+
type: "init",
|
|
230
|
+
URLS: this.URLS,
|
|
231
|
+
mockPort: this.mockPort,
|
|
232
|
+
evn: this.evn
|
|
233
|
+
});
|
|
234
|
+
let n = location.pathname;
|
|
235
|
+
(n.endsWith(".html") || n.endsWith(".htm")) && (n = n.substring(0, n.lastIndexOf("/") + 1)), this.sourceBasePath = n.replace(/\/$/g, "");
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* @param mode 模式 入参是"mock"时启用mock资源
|
|
239
|
+
*/
|
|
240
|
+
setMockMode(e) {
|
|
241
|
+
this.mockMode = e === "mock";
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* 获取缓存历史
|
|
245
|
+
* */
|
|
246
|
+
getCacheHistory() {
|
|
247
|
+
return X.supportCache ? new Promise((e, n) => {
|
|
248
|
+
const s = M();
|
|
249
|
+
this.workerRequestList.push({
|
|
250
|
+
// @ts-ignore
|
|
251
|
+
workerRequestData: { hashCode: s },
|
|
252
|
+
// @ts-ignore
|
|
253
|
+
resolve: e,
|
|
254
|
+
reject: n
|
|
255
|
+
}), this.worker.postMessage({
|
|
256
|
+
type: "cacheHistory",
|
|
257
|
+
hashCode: s
|
|
258
|
+
});
|
|
259
|
+
}) : (console.warn("当前浏览器不支持缓存功能"), Promise.resolve([]));
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* 删除缓存历史
|
|
263
|
+
* */
|
|
264
|
+
removeCache(e) {
|
|
265
|
+
return X.supportCache ? !e || e.length === 0 ? Promise.resolve(!1) : new Promise((n, s) => {
|
|
266
|
+
const r = M();
|
|
267
|
+
this.workerRequestList.push({
|
|
268
|
+
// @ts-ignore
|
|
269
|
+
workerRequestData: { hashCode: r },
|
|
270
|
+
// @ts-ignore
|
|
271
|
+
resolve: n,
|
|
272
|
+
reject: s
|
|
273
|
+
}), this.worker.postMessage({
|
|
274
|
+
type: "removeCache",
|
|
275
|
+
hashCode: r,
|
|
276
|
+
history: e
|
|
277
|
+
});
|
|
278
|
+
}) : (console.warn("当前浏览器不支持缓存功能"), Promise.resolve(!1));
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* 清空缓存
|
|
282
|
+
* */
|
|
283
|
+
clearCache() {
|
|
284
|
+
return X.supportCache ? new Promise((e, n) => {
|
|
285
|
+
const s = M();
|
|
286
|
+
this.workerRequestList.push({
|
|
287
|
+
// @ts-ignore
|
|
288
|
+
workerRequestData: { hashCode: s },
|
|
289
|
+
// @ts-ignore
|
|
290
|
+
resolve: e,
|
|
291
|
+
reject: n
|
|
292
|
+
}), this.worker.postMessage({
|
|
293
|
+
type: "clearCache",
|
|
294
|
+
hashCode: s
|
|
295
|
+
});
|
|
296
|
+
}) : (console.warn("当前浏览器不支持缓存功能"), Promise.resolve(!1));
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* 设置基础URL
|
|
300
|
+
* @param baseURL 基础URL
|
|
301
|
+
*/
|
|
302
|
+
setBaseURL(e) {
|
|
303
|
+
typeof e == "string" ? this.baseURL = e : e instanceof Array && (this.baseURL = e[0], this.URLS = e), this.worker.postMessage({
|
|
304
|
+
type: "init",
|
|
305
|
+
URLS: this.baseURL,
|
|
306
|
+
mockPort: this.mockPort,
|
|
307
|
+
evn: this.evn
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* 设置环境
|
|
312
|
+
* @param evn 环境,请配置 process.env.NODE_ENV
|
|
313
|
+
*/
|
|
314
|
+
setEnvironment(e) {
|
|
315
|
+
this.evn = e, this.worker.postMessage({
|
|
316
|
+
type: "init",
|
|
317
|
+
URLS: this.baseURL,
|
|
318
|
+
mockPort: this.mockPort,
|
|
319
|
+
evn: this.evn
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* 设置mock服务器端口
|
|
324
|
+
* @deprecated 已废弃,请使用mockSource如有特殊情况,可本地使用mock server
|
|
325
|
+
* @param mockPort mock端口
|
|
326
|
+
*/
|
|
327
|
+
setMockPort(e) {
|
|
328
|
+
this.mockPort = e, this.worker.postMessage({
|
|
329
|
+
type: "init",
|
|
330
|
+
URLS: this.baseURL,
|
|
331
|
+
mockPort: this.mockPort,
|
|
332
|
+
evn: this.evn
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* 设置请求拦截器
|
|
337
|
+
* @param requestInterceptor 请求拦截器
|
|
338
|
+
*/
|
|
339
|
+
setRequestInterceptor(e) {
|
|
340
|
+
this.requestIntercepterList.push(e);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* @hidden
|
|
344
|
+
* */
|
|
345
|
+
receiveWorkerResponse(e) {
|
|
346
|
+
for (let n = 0; n < this.workerRequestList.length; n++) {
|
|
347
|
+
const s = this.workerRequestList[n];
|
|
348
|
+
if (s.workerRequestData.hashCode === e.data.hashCode) {
|
|
349
|
+
e.data.type === "response" ? (s.resolve(e.data), this.workerRequestList.splice(n, 1)) : e.data.type === "error" ? (s.reject(e.data.error), this.workerRequestList.splice(n, 1)) : e.data.type === "cancel" ? (s.reject(new Error("cancel")), this.workerRequestList.splice(n, 1)) : e.data.type === "processing" && s.workerRequestData.config.readableStreamCallback ? s.workerRequestData.config.readableStreamCallback(e.data.receivedLength, e.data.totalLength, e.data.currentLength) : e.data.type === "cacheHistory" ? (s.resolve(e.data.history), this.workerRequestList.splice(n, 1)) : e.data.type === "removeCache" ? (s.resolve(e.data.status), this.workerRequestList.splice(n, 1)) : e.data.type === "clearCache" && (s.resolve(e.data.status), this.workerRequestList.splice(n, 1));
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* @hidden
|
|
356
|
+
* */
|
|
357
|
+
createReadableStream(e, n) {
|
|
358
|
+
const s = e.clone();
|
|
359
|
+
if (!s.body) return;
|
|
360
|
+
const r = s.body.getReader(), a = e.headers.get("content-length"), o = a ? parseInt(a) : 0;
|
|
361
|
+
new ReadableStream({
|
|
362
|
+
start(h) {
|
|
363
|
+
let i = 0;
|
|
364
|
+
const d = async () => {
|
|
365
|
+
const { done: l, value: u } = await r.read();
|
|
366
|
+
if (l) {
|
|
367
|
+
h.close();
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
i += u.length, n(i, o, u.length), h.enqueue(u), d();
|
|
371
|
+
};
|
|
372
|
+
d();
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* @hidden
|
|
378
|
+
* */
|
|
379
|
+
listenWorker(e) {
|
|
380
|
+
return new Promise((n, s) => {
|
|
381
|
+
this.workerRequestList.push({
|
|
382
|
+
workerRequestData: e,
|
|
383
|
+
resolve: n,
|
|
384
|
+
reject: s
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* @hidden
|
|
390
|
+
* */
|
|
391
|
+
async workerRequest(e, n, s, r) {
|
|
392
|
+
const { headers: a, responseType: o, cancelToken: h, mock: i = !1, URLindex: d = 0, readableStreamCallback: l, cacheName: u } = r, c = {
|
|
393
|
+
type: "request",
|
|
394
|
+
method: s,
|
|
395
|
+
url: e,
|
|
396
|
+
data: n,
|
|
397
|
+
config: {
|
|
398
|
+
headers: a,
|
|
399
|
+
responseType: o,
|
|
400
|
+
mock: i,
|
|
401
|
+
URLindex: d
|
|
402
|
+
// enableReadableStreamCallback: readableStreamCallback !== undefined,
|
|
403
|
+
},
|
|
404
|
+
hashCode: ""
|
|
405
|
+
}, m = u ?? M();
|
|
406
|
+
c.hashCode = m;
|
|
407
|
+
const p = this.listenWorker(c);
|
|
408
|
+
return this.worker.postMessage(c), c.config.readableStreamCallback = l, await p;
|
|
409
|
+
}
|
|
410
|
+
async post(e, n, s) {
|
|
411
|
+
const { headers: r, responseType: a, cancelToken: o, mock: h = !1, URLindex: i = 0, readableStreamCallback: d } = s;
|
|
412
|
+
if (this.mockMode && s.mockSource)
|
|
413
|
+
return await this.fetchMockSource(s);
|
|
414
|
+
if (X.supportCache && s.cacheName) {
|
|
415
|
+
const l = await this.workerRequest(e, n, "post", s), u = new Headers();
|
|
416
|
+
for (const p in l.headersObj)
|
|
417
|
+
u.append(p, l.headersObj[p]);
|
|
418
|
+
const c = new Response(l.arrayBuffer, {
|
|
419
|
+
status: 200,
|
|
420
|
+
headers: l.headersObj
|
|
421
|
+
}), m = await this.handleResponse(c, a);
|
|
422
|
+
return m || new Promise(() => {
|
|
423
|
+
});
|
|
424
|
+
} else {
|
|
425
|
+
const l = this.getFullURL(e, h, i), u = {
|
|
426
|
+
headers: {
|
|
427
|
+
...this.headers,
|
|
428
|
+
...r
|
|
429
|
+
},
|
|
430
|
+
url: l
|
|
431
|
+
};
|
|
432
|
+
n instanceof FormData || (u.headers["Content-Type"] = "application/json"), this.requestIntercepterList.forEach((m) => m(u));
|
|
433
|
+
const c = await fetch(u.url, {
|
|
434
|
+
method: "POST",
|
|
435
|
+
headers: u.headers,
|
|
436
|
+
body: ie(n),
|
|
437
|
+
signal: o ? o.controller.signal : void 0
|
|
438
|
+
}).then((m) => (d && m.body && this.createReadableStream(m, d), this.handleResponse(m, a))).catch((m) => {
|
|
439
|
+
throw m;
|
|
440
|
+
});
|
|
441
|
+
return c || new Promise(() => {
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
async put(e, n, { headers: s, responseType: r, mock: a, URLindex: o, cancelToken: h, readableStreamCallback: i }) {
|
|
446
|
+
const d = this.getFullURL(e, a, o), l = {
|
|
447
|
+
headers: {
|
|
448
|
+
...this.headers,
|
|
449
|
+
...s
|
|
450
|
+
},
|
|
451
|
+
url: d
|
|
452
|
+
};
|
|
453
|
+
n instanceof FormData || (l.headers["Content-Type"] = "application/json"), this.requestIntercepterList.forEach((c) => c(l));
|
|
454
|
+
const u = await fetch(l.url, {
|
|
455
|
+
method: "POST",
|
|
456
|
+
headers: l.headers,
|
|
457
|
+
body: ie(n),
|
|
458
|
+
signal: h ? h.controller.signal : void 0
|
|
459
|
+
}).then((c) => (i && c.body && this.createReadableStream(c, i), this.handleResponse(c, r))).catch((c) => {
|
|
460
|
+
throw c;
|
|
461
|
+
});
|
|
462
|
+
return u || new Promise(() => {
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
async get(e, n) {
|
|
466
|
+
const { headers: s, responseType: r, cancelToken: a, mock: o = !1, URLindex: h = 0, readableStreamCallback: i } = n;
|
|
467
|
+
if (this.mockMode && n.mockSource)
|
|
468
|
+
return await this.fetchMockSource(n);
|
|
469
|
+
if (X.supportCache && n.cacheName)
|
|
470
|
+
return await this.workerRequest(e, {}, "get", n);
|
|
471
|
+
{
|
|
472
|
+
const d = this.getFullURL(e, o, h), l = {
|
|
473
|
+
headers: {
|
|
474
|
+
...this.headers,
|
|
475
|
+
...s
|
|
476
|
+
},
|
|
477
|
+
url: d
|
|
478
|
+
};
|
|
479
|
+
this.requestIntercepterList.forEach((c) => c(l));
|
|
480
|
+
let u = await fetch(l.url, {
|
|
481
|
+
method: "GET",
|
|
482
|
+
headers: l.headers,
|
|
483
|
+
signal: a ? a.controller.signal : void 0
|
|
484
|
+
}).then((c) => (i && c.body && this.createReadableStream(c, i), this.handleResponse(c, r))).catch((c) => {
|
|
485
|
+
throw c;
|
|
486
|
+
});
|
|
487
|
+
return u || new Promise(() => {
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* @hidden
|
|
493
|
+
* */
|
|
494
|
+
getFullURL(e, n = !1, s = 0) {
|
|
495
|
+
const r = s > 0 ? this.URLS[s] : this.baseURL, a = r.startsWith("https") ? "https" : "http";
|
|
496
|
+
return (n && this.evn === "development" ? `${a}://localhost:${this.mockPort}` : r) + e;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* @hidden
|
|
500
|
+
* */
|
|
501
|
+
async handleResponse(e, n = "json") {
|
|
502
|
+
if (e && e.status === 200)
|
|
503
|
+
if (n === "blob") {
|
|
504
|
+
const s = await e.blob();
|
|
505
|
+
let r = "", a = e.headers.get("content-disposition") ?? e.headers.get("Content-Disposition");
|
|
506
|
+
if (a) {
|
|
507
|
+
let o = a.split("filename=")[1];
|
|
508
|
+
o && (r = o);
|
|
509
|
+
}
|
|
510
|
+
return {
|
|
511
|
+
blob: s,
|
|
512
|
+
header: e.headers,
|
|
513
|
+
fileName: r
|
|
514
|
+
};
|
|
515
|
+
} else return n === "arrayBuffer" ? await e.arrayBuffer() : n === "weg" ? {
|
|
516
|
+
code: 200,
|
|
517
|
+
msg: "解析weg成功",
|
|
518
|
+
data: ue(await e.arrayBuffer())
|
|
519
|
+
} : n === "text" ? await e.text() : await e.json();
|
|
520
|
+
else {
|
|
521
|
+
if (e.status === 500)
|
|
522
|
+
this.MessageBox.alert("服务器错误");
|
|
523
|
+
else {
|
|
524
|
+
if (e.status === 204)
|
|
525
|
+
return null;
|
|
526
|
+
e.status === 401 ? this.MessageBox.alert("无权限访问服务器接口") : e.status === 404 ? this.MessageBox.alert("无效请求") : e.status === 402 && this.requestAlert === !1 ? (this.requestAlert = !0, this.MessageBox.alert("登录过期,请重新登录")) : this.MessageBox.alert("未知错误");
|
|
527
|
+
}
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* @hidden
|
|
533
|
+
* */
|
|
534
|
+
async fetchMockSource(e) {
|
|
535
|
+
const { responseType: n, mockSource: s, readableStreamCallback: r } = e, a = await fetch(this.sourceBasePath + s).then((o) => (r && o.body && this.createReadableStream(o, r), this.handleResponse(o, n))).catch((o) => {
|
|
536
|
+
throw o;
|
|
537
|
+
});
|
|
538
|
+
return await ce(e.responseType === "weg" ? 2e3 : 500), a || new Promise(() => {
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
b(X, "instance", new X()), b(X, "supportCache", !!navigator.storage);
|
|
543
|
+
let G = X;
|
|
544
|
+
class de {
|
|
545
|
+
constructor(e) {
|
|
546
|
+
b(this, "controller", new AbortController());
|
|
547
|
+
e(this);
|
|
548
|
+
}
|
|
549
|
+
clear() {
|
|
550
|
+
this.controller.abort();
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
let N;
|
|
554
|
+
function Be(t) {
|
|
555
|
+
G.instance.MessageBox.error({
|
|
556
|
+
title: "错误",
|
|
557
|
+
message: t.msg ? t.msg : "请求错误"
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
const le = {
|
|
561
|
+
handleResponse(t, e, n = Be, s) {
|
|
562
|
+
return s ? e(t) : t.code === 200 ? e(t.data) : t.code == 402 ? (G.instance.MessageBox.alert("登录已过期,请重新登录", "提示", () => {
|
|
563
|
+
window.present.router.push({ name: "login" });
|
|
564
|
+
}), new Promise(() => {
|
|
565
|
+
})) : t.code == 403 ? (G.instance.MessageBox.error({
|
|
566
|
+
message: "无权限访问该功能,请联系管理员"
|
|
567
|
+
}), new Promise(() => {
|
|
568
|
+
})) : t.code == 401 ? (G.instance.MessageBox.alert("登录已过期,请重新登录", "提示", () => {
|
|
569
|
+
window.present.router.push({ name: "login" });
|
|
570
|
+
}), new Promise(() => {
|
|
571
|
+
})) : t.code == 601 ? (G.instance.MessageBox.warning({
|
|
572
|
+
message: t.msg
|
|
573
|
+
}), new Promise(() => {
|
|
574
|
+
})) : n(t) ?? new Promise(() => {
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
async function tt({ api: t, data: e, success: n = (i) => i, fail: s, final: r, noCheckRes: a = !1, wait: o = 0, readableStreamCallback: h }) {
|
|
579
|
+
let i = (/* @__PURE__ */ new Date()).getTime();
|
|
580
|
+
const d = await t(e, h).catch((l) => {
|
|
581
|
+
if (!N) {
|
|
582
|
+
let u;
|
|
583
|
+
return s ? u = s(l) : G.instance.MessageBox.error({
|
|
584
|
+
title: "错误",
|
|
585
|
+
message: je(l.message)
|
|
586
|
+
}), N && (clearTimeout(N), N = null), N = setTimeout(() => N = null, 3e3), r && setTimeout(r, 500), u;
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
if (le.handleResponse || d || a) {
|
|
590
|
+
if (o) {
|
|
591
|
+
let l = o - ((/* @__PURE__ */ new Date()).getTime() - i);
|
|
592
|
+
l > 0 && await ce(l);
|
|
593
|
+
}
|
|
594
|
+
return r && setTimeout(r, 500), le.handleResponse(d, n, s, a);
|
|
595
|
+
} else
|
|
596
|
+
return r && setTimeout(r, 500), new Promise(() => {
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
function je(t) {
|
|
600
|
+
let e = t;
|
|
601
|
+
return t.match(/failed/ig) ? e = "链接服务器失败" : t.match(/time/ig) && t.match(/out/ig) && (e = "请求超时"), e;
|
|
602
|
+
}
|
|
603
|
+
function q(t, e = "") {
|
|
604
|
+
let n = "";
|
|
605
|
+
for (let s in t) {
|
|
606
|
+
const r = t[s];
|
|
607
|
+
e && (s = `[${s}]`), typeof r == "number" || typeof r == "string" ? n += `${e}${s}=${r}&` : typeof r == "object" && (n += q(r, e + s));
|
|
608
|
+
}
|
|
609
|
+
return e || (n = n.replace(/&$/, ""), n = n.length > 0 ? "?" + n : n), n;
|
|
610
|
+
}
|
|
611
|
+
let F = [];
|
|
612
|
+
const A = {
|
|
613
|
+
push(t) {
|
|
614
|
+
F.length > 150 && F.shift(), F.push(t);
|
|
615
|
+
},
|
|
616
|
+
clear() {
|
|
617
|
+
F.forEach((t) => t.clear()), F = [];
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
function nt(t, e = {}, n) {
|
|
621
|
+
n = me(n);
|
|
622
|
+
let s = e.headers ? e.headers : {}, r = De(e), a = e.query ? q(e.query) : "";
|
|
623
|
+
return G.instance.post(t + a, r, {
|
|
624
|
+
headers: s,
|
|
625
|
+
cancelToken: new de((o) => A.push(o)),
|
|
626
|
+
...n
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
function st(t, e = {}, n) {
|
|
630
|
+
n = me(n);
|
|
631
|
+
let s = e.headers ? e.headers : {}, r = e.query ? q(e.query) : "";
|
|
632
|
+
return G.instance.get(t + r, {
|
|
633
|
+
headers: s,
|
|
634
|
+
cancelToken: new de((a) => A.push(a)),
|
|
635
|
+
...n
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
function me(t) {
|
|
639
|
+
return {
|
|
640
|
+
mockSource: (t == null ? void 0 : t.mockSource) ?? void 0,
|
|
641
|
+
URLindex: (t == null ? void 0 : t.URLindex) ?? 0,
|
|
642
|
+
responseType: (t == null ? void 0 : t.responseType) ?? "json",
|
|
643
|
+
cacheName: (t == null ? void 0 : t.cacheName) ?? ""
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
function rt() {
|
|
647
|
+
A.clear();
|
|
648
|
+
}
|
|
649
|
+
function De(t) {
|
|
650
|
+
let { formData: e, params: n } = t;
|
|
651
|
+
if (e) {
|
|
652
|
+
const s = new FormData();
|
|
653
|
+
for (const r in e)
|
|
654
|
+
Object.hasOwnProperty.call(e, r) && (e[r] instanceof Array ? e[r].forEach((a) => {
|
|
655
|
+
s.append(r, a);
|
|
656
|
+
}) : s.append(r, e[r]));
|
|
657
|
+
return s;
|
|
658
|
+
} else return n || {};
|
|
659
|
+
}
|
|
660
|
+
function ot(t) {
|
|
661
|
+
const e = Q(t), n = JSON.stringify(t);
|
|
662
|
+
return {
|
|
663
|
+
state: e,
|
|
664
|
+
resetState() {
|
|
665
|
+
const s = JSON.parse(n);
|
|
666
|
+
for (const r in s)
|
|
667
|
+
e[r] = s[r];
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
const z = /* @__PURE__ */ new Map(), C = [];
|
|
672
|
+
let x = location.pathname;
|
|
673
|
+
(x.endsWith(".html") || x.endsWith(".htm")) && (x = x.substring(0, x.lastIndexOf("/") + 1));
|
|
674
|
+
const pe = x.replace(/\/$/g, ""), g = {
|
|
675
|
+
lang: "en",
|
|
676
|
+
// frontBaseURL: '',
|
|
677
|
+
terminal: "WEB",
|
|
678
|
+
buildBaseURL: "/lang",
|
|
679
|
+
pending: !1,
|
|
680
|
+
requestCache: [],
|
|
681
|
+
env: "development",
|
|
682
|
+
setEnvironment(t) {
|
|
683
|
+
this.env = t;
|
|
684
|
+
},
|
|
685
|
+
setLang(t) {
|
|
686
|
+
this.lang = t, this.changeLang();
|
|
687
|
+
},
|
|
688
|
+
async changeLang() {
|
|
689
|
+
if (this.env === "development")
|
|
690
|
+
for (const { path: t, langTextRef: e, onloadCallback: n } of C)
|
|
691
|
+
Ze(t).then((s) => {
|
|
692
|
+
for (const r in s)
|
|
693
|
+
e[r] = s[r];
|
|
694
|
+
n && n(e);
|
|
695
|
+
});
|
|
696
|
+
else {
|
|
697
|
+
let t = z.get(this.lang);
|
|
698
|
+
t || (t = await ye()), t = z.get(this.lang);
|
|
699
|
+
for (const { path: e, langTextRef: n, onloadCallback: s } of C) {
|
|
700
|
+
const r = this.getFullPath(e), a = t.find((o) => o.path === r);
|
|
701
|
+
if (a) {
|
|
702
|
+
for (const o in a.lang)
|
|
703
|
+
n[o] = a.lang[o];
|
|
704
|
+
s && s(n);
|
|
705
|
+
} else
|
|
706
|
+
throw new Error("语言包内容不存在");
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
},
|
|
710
|
+
setBuildBaseURL(t) {
|
|
711
|
+
this.buildBaseURL = t;
|
|
712
|
+
},
|
|
713
|
+
getFullPath(t) {
|
|
714
|
+
return "src" + t + "/lang/" + this.lang + ".lang.json";
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
function at(t, e, n) {
|
|
718
|
+
const s = Q(e);
|
|
719
|
+
g.env === "development" ? Ze(t).then((a) => {
|
|
720
|
+
for (const o in a)
|
|
721
|
+
s[o] = a[o];
|
|
722
|
+
n && n(s);
|
|
723
|
+
}) : be(t, s, n);
|
|
724
|
+
const r = {
|
|
725
|
+
path: t,
|
|
726
|
+
langTextRef: s,
|
|
727
|
+
onloadCallback: n
|
|
728
|
+
};
|
|
729
|
+
return C.push(r), K(() => {
|
|
730
|
+
const a = C.findIndex((o) => o === r);
|
|
731
|
+
a >= 0 && C.splice(a, 1);
|
|
732
|
+
}), s;
|
|
733
|
+
}
|
|
734
|
+
function be(t, e, n) {
|
|
735
|
+
const s = g.getFullPath(t);
|
|
736
|
+
let r = z.get(g.lang);
|
|
737
|
+
if (r) {
|
|
738
|
+
const a = r.find((o) => o.path === s);
|
|
739
|
+
if (a) {
|
|
740
|
+
const o = a.lang;
|
|
741
|
+
for (const h in o)
|
|
742
|
+
e[h] = o[h];
|
|
743
|
+
n && n(e);
|
|
744
|
+
}
|
|
745
|
+
} else
|
|
746
|
+
g.requestCache.push({ path: t, langTextRef: e, onloadCallback: n }), g.pending || ye().then((a) => {
|
|
747
|
+
g.requestCache.forEach(
|
|
748
|
+
({ path: o, langTextRef: h, onloadCallback: i }) => be(o, h, i)
|
|
749
|
+
), g.requestCache = [];
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
async function ye() {
|
|
753
|
+
g.pending = !0;
|
|
754
|
+
let t = pe + g.buildBaseURL + "/" + g.lang + ".langAll.json";
|
|
755
|
+
const n = await (await fetch(t)).json().catch((r) => {
|
|
756
|
+
throw new Error("获取语言包内容错误:" + t);
|
|
757
|
+
});
|
|
758
|
+
if (!n) throw new Error("语言包服务不存在");
|
|
759
|
+
const s = g.terminal === "WEB" ? n : n.data;
|
|
760
|
+
if (!s) throw new Error("语言包内容不存在");
|
|
761
|
+
return z.set(g.lang, s), g.pending = !1, s;
|
|
762
|
+
}
|
|
763
|
+
async function Ze(t) {
|
|
764
|
+
let e = g.env === "development" ? "/src" : "/lang", n = pe + e + t + "/lang/" + g.lang + ".lang.json";
|
|
765
|
+
return await (await fetch(n)).json().catch((a) => {
|
|
766
|
+
throw new Error("获取组件文本路径错误:" + n);
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
function it() {
|
|
770
|
+
Object.defineProperty(Array.prototype, "findName", {
|
|
771
|
+
value: () => {
|
|
772
|
+
},
|
|
773
|
+
writable: !0,
|
|
774
|
+
enumerable: !1
|
|
775
|
+
}), Object.defineProperty(Array.prototype, "findKey", {
|
|
776
|
+
value: () => {
|
|
777
|
+
},
|
|
778
|
+
writable: !0,
|
|
779
|
+
enumerable: !1
|
|
780
|
+
}), Array.prototype.findName = function(t) {
|
|
781
|
+
return this.find((e) => e.name === t);
|
|
782
|
+
}, Array.prototype.findKey = function(t, e) {
|
|
783
|
+
return this.find((n) => n[t] === e);
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
const He = document.getElementsByTagName("html")[0], w = {
|
|
787
|
+
size: 16,
|
|
788
|
+
width: window.innerWidth,
|
|
789
|
+
height: window.innerHeight,
|
|
790
|
+
isFullScreen: !1,
|
|
791
|
+
isInit: !1
|
|
792
|
+
};
|
|
793
|
+
function H() {
|
|
794
|
+
w.isFullScreen ? w.size = 16 / w.height * window.innerHeight : w.size = 16 / w.width * window.innerWidth, He.style.cssText = `font-size:${w.size}px`;
|
|
795
|
+
}
|
|
796
|
+
function lt(t = 1920, e = 1080, n = !0) {
|
|
797
|
+
w.width = t, w.height = e, w.isFullScreen = n, H(), w.isInit || (window.addEventListener("resize", H), w.isInit = !0);
|
|
798
|
+
}
|
|
799
|
+
function ct(t) {
|
|
800
|
+
w.isFullScreen = t, H();
|
|
801
|
+
}
|
|
802
|
+
function ht(t) {
|
|
803
|
+
return t / 16 * w.size;
|
|
804
|
+
}
|
|
805
|
+
function ut(t) {
|
|
806
|
+
if (!t.callback || !t.element || !t.event) throw new Error("useEvent: callback, element, event are required");
|
|
807
|
+
O(() => {
|
|
808
|
+
t.element.addEventListener(t.event, t.callback);
|
|
809
|
+
}), K(() => {
|
|
810
|
+
t.element.removeEventListener(t.event, t.callback);
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
function dt(t) {
|
|
814
|
+
if (!t.callback || !t.time) throw new Error("useInterval: callback and time are required");
|
|
815
|
+
return O(() => {
|
|
816
|
+
t.timer = setInterval(t.callback, t.time);
|
|
817
|
+
}), K(() => {
|
|
818
|
+
t.timer && clearInterval(t.timer);
|
|
819
|
+
}), t;
|
|
820
|
+
}
|
|
821
|
+
function mt(t, e, n = "modelValue") {
|
|
822
|
+
if (t[n] === void 0) throw new Error(`useModel: props.${n} can not be undefined.`);
|
|
823
|
+
return new Proxy(t, {
|
|
824
|
+
get(s, r) {
|
|
825
|
+
return s[n][r];
|
|
826
|
+
},
|
|
827
|
+
set(s, r, a) {
|
|
828
|
+
const o = JSON.parse(JSON.stringify(s[n]));
|
|
829
|
+
return o[r] = a, e("update:" + n, o), !0;
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
class pt {
|
|
834
|
+
constructor() {
|
|
835
|
+
b(this, "container", {});
|
|
836
|
+
}
|
|
837
|
+
on(e, n) {
|
|
838
|
+
this.container[e] || (this.container[e] = []), this.container[e].push(n);
|
|
839
|
+
}
|
|
840
|
+
emit(e, ...n) {
|
|
841
|
+
this.container.hasOwnProperty(e) && this.container[e].forEach((s) => {
|
|
842
|
+
s(...n);
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
remove(e, n) {
|
|
846
|
+
if (this.container[e] && this.container[e] instanceof Array) {
|
|
847
|
+
let s = this.container[e].findIndex((r) => r == n);
|
|
848
|
+
s >= 0 && this.container[e].splice(s, 1), this.container[e].length === 0 && delete this.container[e];
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
listen(e, n) {
|
|
852
|
+
const s = this;
|
|
853
|
+
O(() => {
|
|
854
|
+
s.on(e, n);
|
|
855
|
+
}), K(() => {
|
|
856
|
+
s.remove(e, n);
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
emitKeys(e) {
|
|
860
|
+
e.forEach((n) => {
|
|
861
|
+
this.emit(n);
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
function bt(t, e, n, s = !1) {
|
|
866
|
+
return t.directionData ? Qe(t, e, n, s) : Oe(t, e, n, s);
|
|
867
|
+
}
|
|
868
|
+
function Qe(t, e, n, s) {
|
|
869
|
+
const { west: r, east: a, south: o, north: h, width: i } = t, d = (a - r) / (i - 1), l = t.data, u = l.length / i, c = (h - o) / (u - 1);
|
|
870
|
+
if (e < r || e > a || n < o || n > h)
|
|
871
|
+
return { value: NaN };
|
|
872
|
+
const m = (e - r) / d, p = (h - n) / c, Z = Math.floor(m), f = Math.floor(p), Y = i * f + Z;
|
|
873
|
+
if (!s) {
|
|
874
|
+
let T = Math.abs(m - Z) < Math.abs(Z + 1 - m) ? 0 : 1, I = Math.abs(p - f) < Math.abs(f + 1 - p) ? 0 : 1;
|
|
875
|
+
return { value: l[Y + I * i + T] };
|
|
876
|
+
}
|
|
877
|
+
const W = m - Z, L = p - f, S = l[Y], k = Z + 1 < i ? l[Y + 1] : S, V = f + 1 < u ? l[Y + i] : S, U = Z + 1 < i && f + 1 < u ? l[Y + i + 1] : Z + 1 < i ? k : f + 1 < u ? V : S, J = S + (k - S) * W, v = V + (U - V) * W;
|
|
878
|
+
return { value: J + (v - J) * L };
|
|
879
|
+
}
|
|
880
|
+
function P(t, e) {
|
|
881
|
+
const n = e * Math.PI / 180;
|
|
882
|
+
return {
|
|
883
|
+
u: t * Math.sin(n),
|
|
884
|
+
// 东向分量(正东为正)
|
|
885
|
+
v: t * Math.cos(n)
|
|
886
|
+
// 北向分量(正北为正)
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
function Oe(t, e, n, s) {
|
|
890
|
+
const { west: r, east: a, south: o, north: h, width: i, data: d, directionData: l } = t;
|
|
891
|
+
if (!l)
|
|
892
|
+
throw new Error("weg数据中不包含矢量数据");
|
|
893
|
+
const u = (a - r) / (i - 1), c = d.length / i, m = (h - o) / (c - 1);
|
|
894
|
+
if (e < r || e > a || n < o || n > h)
|
|
895
|
+
return { value: NaN, direction: NaN };
|
|
896
|
+
const p = (e - r) / u, Z = (h - n) / m, f = Math.floor(p), Y = Math.floor(Z), W = i * Y + f;
|
|
897
|
+
if (!s) {
|
|
898
|
+
let Ye = Math.abs(p - f) < Math.abs(f + 1 - p) ? 0 : 1, Re = Math.abs(Z - Y) < Math.abs(Y + 1 - Z) ? 0 : 1;
|
|
899
|
+
const te = W + Re * i + Ye;
|
|
900
|
+
return {
|
|
901
|
+
value: d[te],
|
|
902
|
+
direction: l[te]
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
const L = p - f, S = Z - Y, k = W, V = f + 1 < i ? W + 1 : k, U = Y + 1 < c ? W + i : k, J = f + 1 < i && Y + 1 < c ? W + i + 1 : f + 1 < i ? V : U, v = P(d[k], l[k]), T = P(d[V], l[V]), I = P(d[U], l[U]), _ = P(d[J], l[J]), $ = v.u + (T.u - v.u) * L, fe = I.u + (_.u - I.u) * L, E = $ + (fe - $) * S, ee = v.v + (T.v - v.v) * L, ge = I.v + (_.v - I.v) * L, B = ee + (ge - ee) * S, we = Math.sqrt(E * E + B * B);
|
|
906
|
+
let j = Math.atan2(E, B) * 180 / Math.PI;
|
|
907
|
+
return j = (j + 360) % 360, { value: we, direction: j };
|
|
908
|
+
}
|
|
909
|
+
function yt(t) {
|
|
910
|
+
return t == null;
|
|
911
|
+
}
|
|
912
|
+
export {
|
|
913
|
+
pt as EventListenControl,
|
|
914
|
+
_e as LocalDevIpSetter,
|
|
915
|
+
G as RequestInstance,
|
|
916
|
+
rt as cancelRequest,
|
|
917
|
+
ct as changeFullScreenLayout,
|
|
918
|
+
$e as createRequestInterceptor,
|
|
919
|
+
ot as createState,
|
|
920
|
+
et as decodeWegGzipFile,
|
|
921
|
+
at as defineLang,
|
|
922
|
+
it as extendsArray,
|
|
923
|
+
ht as fontSize,
|
|
924
|
+
st as get,
|
|
925
|
+
lt as initResponsiveLayout,
|
|
926
|
+
yt as isNullOrUndefined,
|
|
927
|
+
g as langSetting,
|
|
928
|
+
bt as pickFromWeg,
|
|
929
|
+
nt as post,
|
|
930
|
+
ue as processBinaryFile,
|
|
931
|
+
tt as useApi,
|
|
932
|
+
ut as useEvent,
|
|
933
|
+
dt as useInterval,
|
|
934
|
+
mt as useModel
|
|
935
|
+
};
|