duck-vue-components 0.0.0

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 (123) hide show
  1. package/README.md +29 -0
  2. package/dist/MyButton-C1krVCi6.cjs +36 -0
  3. package/dist/MyButton-C7riFwH6.js +28 -0
  4. package/dist/_plugin-vue_export-helper-DQXgr64F.cjs +13 -0
  5. package/dist/_plugin-vue_export-helper-DbXABBKy.js +8 -0
  6. package/dist/affix-CYU-9qMr.cjs +71 -0
  7. package/dist/affix-D9EM8_Um.js +66 -0
  8. package/dist/button-CGv1WHzT.cjs +132 -0
  9. package/dist/button-tOWSPPxz.js +126 -0
  10. package/dist/chunk-CZWwpsFl.cjs +43 -0
  11. package/dist/chunk-pbuEa-1d.js +13 -0
  12. package/dist/config.cjs +1 -0
  13. package/dist/config.js +1 -0
  14. package/dist/constants/json.cjs +4 -0
  15. package/dist/constants/json.d.cts +2 -0
  16. package/dist/constants/json.d.ts +2 -0
  17. package/dist/constants/json.js +2 -0
  18. package/dist/constants.cjs +14 -0
  19. package/dist/constants.d.cts +3 -0
  20. package/dist/constants.d.ts +3 -0
  21. package/dist/constants.js +3 -0
  22. package/dist/controls/MyButton.cjs +3 -0
  23. package/dist/controls/MyButton.d.cts +2 -0
  24. package/dist/controls/MyButton.d.ts +2 -0
  25. package/dist/controls/MyButton.js +2 -0
  26. package/dist/controls/affix.cjs +8 -0
  27. package/dist/controls/affix.d.cts +2 -0
  28. package/dist/controls/affix.d.ts +2 -0
  29. package/dist/controls/affix.js +2 -0
  30. package/dist/controls/button.cjs +8 -0
  31. package/dist/controls/button.js +2 -0
  32. package/dist/controls.cjs +18 -0
  33. package/dist/controls.d.cts +10 -0
  34. package/dist/controls.d.ts +10 -0
  35. package/dist/controls.js +5 -0
  36. package/dist/dom-CllENWMY.js +346 -0
  37. package/dist/dom-DS4YqkjW.cjs +580 -0
  38. package/dist/index-1ELDRrC5.d.ts +1397 -0
  39. package/dist/index-5JdIJn1m.d.cts +74 -0
  40. package/dist/index-6KzLtJFy.d.cts +157 -0
  41. package/dist/index-BGkTN1DD.d.cts +15 -0
  42. package/dist/index-BHq-BMCP.d.ts +74 -0
  43. package/dist/index-BI-hrf4t.d.ts +332 -0
  44. package/dist/index-BtOBjeH7.d.ts +10 -0
  45. package/dist/index-C-uY4885.d.cts +23 -0
  46. package/dist/index-C5SJLWEN.d.ts +23 -0
  47. package/dist/index-CSvc8L11.d.cts +51 -0
  48. package/dist/index-CeemHBNT.d.ts +51 -0
  49. package/dist/index-CfkAYIKD.d.cts +80 -0
  50. package/dist/index-CiJC-ieW.d.ts +157 -0
  51. package/dist/index-DamAmum6.d.ts +15 -0
  52. package/dist/index-DhOoJCHW.d.cts +1397 -0
  53. package/dist/index-PhthUD7x.d.cts +10 -0
  54. package/dist/index-oDsyZ3t2.d.cts +332 -0
  55. package/dist/index-x9xs2cbA.d.ts +80 -0
  56. package/dist/json-BkkaM20u.cjs +31034 -0
  57. package/dist/json-D-_zTSK6.js +31023 -0
  58. package/dist/locale-DhlAaV1Q.js +597 -0
  59. package/dist/locale-WzzxOobw.cjs +658 -0
  60. package/dist/locale.cjs +12 -0
  61. package/dist/locale.js +2 -0
  62. package/dist/objects-CLXPNOUW.js +134 -0
  63. package/dist/objects-o7u5s_lI.cjs +272 -0
  64. package/dist/packages/config.cjs +10 -0
  65. package/dist/packages/config.d.cts +2 -0
  66. package/dist/packages/config.d.ts +2 -0
  67. package/dist/packages/config.js +5 -0
  68. package/dist/packages/constants/json.cjs +4 -0
  69. package/dist/packages/constants/json.js +2 -0
  70. package/dist/packages/constants.cjs +78 -0
  71. package/dist/packages/constants.js +67 -0
  72. package/dist/packages/controls/MyButton.cjs +3 -0
  73. package/dist/packages/controls/MyButton.js +2 -0
  74. package/dist/packages/controls/affix.cjs +8 -0
  75. package/dist/packages/controls/affix.js +2 -0
  76. package/dist/packages/controls/button.cjs +8 -0
  77. package/dist/packages/controls/button.d.cts +2 -0
  78. package/dist/packages/controls/button.d.ts +2 -0
  79. package/dist/packages/controls/button.js +2 -0
  80. package/dist/packages/controls.cjs +31 -0
  81. package/dist/packages/controls.js +12 -0
  82. package/dist/packages/locale.cjs +12 -0
  83. package/dist/packages/locale.d.cts +39 -0
  84. package/dist/packages/locale.d.ts +39 -0
  85. package/dist/packages/locale.js +2 -0
  86. package/dist/packages/stores.cjs +337 -0
  87. package/dist/packages/stores.js +320 -0
  88. package/dist/packages/utils/dom.cjs +32 -0
  89. package/dist/packages/utils/dom.d.cts +2 -0
  90. package/dist/packages/utils/dom.d.ts +2 -0
  91. package/dist/packages/utils/dom.js +2 -0
  92. package/dist/packages/utils/vue/props.cjs +63 -0
  93. package/dist/packages/utils/vue/props.d.cts +2 -0
  94. package/dist/packages/utils/vue/props.d.ts +2 -0
  95. package/dist/packages/utils/vue/props.js +56 -0
  96. package/dist/packages/utils/vue.cjs +32 -0
  97. package/dist/packages/utils/vue.d.cts +3 -0
  98. package/dist/packages/utils/vue.d.ts +3 -0
  99. package/dist/packages/utils/vue.js +24 -0
  100. package/dist/packages/utils.cjs +190 -0
  101. package/dist/packages/utils.js +6 -0
  102. package/dist/packages.cjs +15 -0
  103. package/dist/packages.d.cts +3 -0
  104. package/dist/packages.d.ts +3 -0
  105. package/dist/packages.js +3 -0
  106. package/dist/stores.cjs +17 -0
  107. package/dist/stores.d.cts +805 -0
  108. package/dist/stores.d.ts +805 -0
  109. package/dist/stores.js +4 -0
  110. package/dist/style.css +15 -0
  111. package/dist/utils/dom.cjs +32 -0
  112. package/dist/utils/dom.js +2 -0
  113. package/dist/utils/vue/props.cjs +7 -0
  114. package/dist/utils/vue/props.js +2 -0
  115. package/dist/utils/vue.cjs +11 -0
  116. package/dist/utils/vue.js +3 -0
  117. package/dist/utils-DlBKdS0t.js +696 -0
  118. package/dist/utils-egS_3P4w.cjs +850 -0
  119. package/dist/utils.cjs +190 -0
  120. package/dist/utils.d.cts +5 -0
  121. package/dist/utils.d.ts +5 -0
  122. package/dist/utils.js +6 -0
  123. package/package.json +184 -0
@@ -0,0 +1,850 @@
1
+ const require_chunk = require("./chunk-CZWwpsFl.cjs");
2
+ const require_dom = require("./dom-DS4YqkjW.cjs");
3
+ require("./objects-o7u5s_lI.cjs");
4
+ require("./packages/utils/vue.cjs");
5
+ const require_locale = require("./locale-WzzxOobw.cjs");
6
+ let vue = require("vue");
7
+ let _vue_shared = require("@vue/shared");
8
+ require("lodash-unified");
9
+ let axios = require("axios");
10
+ axios = require_chunk.__toESM(axios);
11
+ let crypto_js = require("crypto-js");
12
+ crypto_js = require_chunk.__toESM(crypto_js);
13
+ let element_plus = require("element-plus");
14
+ let pinia = require("pinia");
15
+ let xlsx = require("xlsx");
16
+ xlsx = require_chunk.__toESM(xlsx);
17
+ let file_saver = require("file-saver");
18
+ let dayjs = require("dayjs");
19
+ dayjs = require_chunk.__toESM(dayjs);
20
+ //#region src/packages/utils/arrays.ts
21
+ const unique = (arr) => [...new Set(arr)];
22
+ const uniqueBy = (arr, key) => {
23
+ const map = /* @__PURE__ */ new Map();
24
+ return arr.filter((item) => !map.has(item[key]) && map.set(item[key], item));
25
+ };
26
+ const uniqueByFn = (arr, compareFn) => {
27
+ const map = /* @__PURE__ */ new Map();
28
+ return arr.filter((item) => {
29
+ const key = compareFn(item);
30
+ return !map.has(key) && map.set(key, item);
31
+ });
32
+ };
33
+ /** like `_.castArray`, except falsy value returns empty array. */
34
+ const castArray = (arr) => {
35
+ if (!arr && arr !== 0) return [];
36
+ return (0, _vue_shared.isArray)(arr) ? arr : [arr];
37
+ };
38
+ //#endregion
39
+ //#region src/packages/utils/rand.ts
40
+ /**
41
+ * @deprecated Use `useId` `useIdInjection` instead
42
+ * Generate random number in range [0, 1000]
43
+ * Maybe replace with [uuid](https://www.npmjs.com/package/uuid)
44
+ */
45
+ const generateId = () => Math.floor(Math.random() * 1e4);
46
+ /**
47
+ * @deprecated
48
+ * Generating a random int in range (0, max - 1)
49
+ * @param max {number}
50
+ */
51
+ const getRandomInt = (max) => Math.floor(Math.random() * Math.floor(max));
52
+ //#endregion
53
+ //#region src/packages/utils/typescript.ts
54
+ const mutable = (val) => val;
55
+ //#endregion
56
+ //#region src/packages/utils/throttleByRaf.ts
57
+ function throttleByRaf(cb) {
58
+ let timer = 0;
59
+ const throttle = (...args) => {
60
+ if (timer) require_dom.cAF(timer);
61
+ timer = require_dom.rAF(() => {
62
+ cb(...args);
63
+ timer = 0;
64
+ });
65
+ };
66
+ throttle.cancel = () => {
67
+ require_dom.cAF(timer);
68
+ timer = 0;
69
+ };
70
+ return throttle;
71
+ }
72
+ //#endregion
73
+ //#region src/packages/utils/http.ts
74
+ /**
75
+ * HTTP 请求类 - 单例模式实现
76
+ */
77
+ var Http = class Http {
78
+ static {
79
+ this.domainInstances = /* @__PURE__ */ new Map();
80
+ }
81
+ /**
82
+ * 私有构造函数,防止外部直接实例化
83
+ */
84
+ constructor(config = {}) {
85
+ this.plugins = [];
86
+ this.config = {
87
+ init: false,
88
+ baseURL: "",
89
+ timeout: 1e4,
90
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
91
+ repeatPost: false,
92
+ repeatPostTime: 3,
93
+ showError: true,
94
+ autoRelogin: true,
95
+ isDebug: false,
96
+ ...config
97
+ };
98
+ this.axiosInstance = axios.default.create({
99
+ baseURL: this.config.baseURL,
100
+ timeout: this.config.timeout,
101
+ headers: this.config.headers
102
+ });
103
+ this.registerBuiltinPlugins();
104
+ if (this.config.plugins && this.config.plugins.length) this.use(...this.config.plugins);
105
+ this.setupInterceptors();
106
+ }
107
+ /**
108
+ * 获取单例实例
109
+ */
110
+ static getInstance(config) {
111
+ if (!Http.instance || config?.init) Http.instance = new Http(config);
112
+ return Http.instance;
113
+ }
114
+ /**
115
+ * 获取指定域名的实例
116
+ * @param domain 域名
117
+ * @param config 配置
118
+ */
119
+ static getDomainInstance(domain, config = {}) {
120
+ if (!Http.domainInstances.has(domain)) {
121
+ const domainConfig = {
122
+ ...config,
123
+ baseURL: domain
124
+ };
125
+ Http.domainInstances.set(domain, new Http(domainConfig));
126
+ }
127
+ return Http.domainInstances.get(domain);
128
+ }
129
+ /**
130
+ * 创建新的 HTTP 实例(用于特殊需求)
131
+ */
132
+ static createInstance(config = {}) {
133
+ return new Http(config);
134
+ }
135
+ /**
136
+ * 重新配置实例
137
+ */
138
+ reconfigure(config) {
139
+ this.config = {
140
+ ...this.config,
141
+ ...config
142
+ };
143
+ this.axiosInstance = axios.default.create({
144
+ baseURL: this.config.baseURL,
145
+ timeout: this.config.timeout,
146
+ headers: this.config.headers
147
+ });
148
+ this.plugins = [];
149
+ this.registerBuiltinPlugins();
150
+ if (this.config.plugins && this.config.plugins.length) this.use(...this.config.plugins);
151
+ this.setupInterceptors();
152
+ }
153
+ /**
154
+ * 注册内置插件
155
+ */
156
+ registerBuiltinPlugins() {
157
+ if (this.config.responseHandler) this.use(this.createResponseHandlerPlugin(this.config.responseHandler));
158
+ if (this.config.repeatPost) this.use(this.createRepeatPostPlugin(this.config.repeatPostTime));
159
+ if (this.config.showError) this.use(this.createErrorHandlerPlugin(this.config.errorHandler));
160
+ if (this.config.autoRelogin) this.use(this.createReloginPlugin(this.config.reloginHandler));
161
+ if (this.config.isDebug) this.use(this.createDebugPlugin());
162
+ }
163
+ /**
164
+ * 注册插件
165
+ */
166
+ use(...plugins) {
167
+ plugins.forEach((plugin) => {
168
+ if (!this.plugins.some((p) => p.name === plugin.name)) this.plugins.push(plugin);
169
+ });
170
+ return this;
171
+ }
172
+ /**
173
+ * 设置拦截器
174
+ */
175
+ setupInterceptors() {
176
+ this.axiosInstance.interceptors.request.use(async (config) => {
177
+ if (this.config.defaultParams) config.data = {
178
+ ...Object.entries(this.config.defaultParams).reduce((acc, [key, value]) => {
179
+ acc[key] = typeof value === "function" ? value() : value;
180
+ return acc;
181
+ }, {}),
182
+ ...config.data
183
+ };
184
+ if (this.config.encrypt && this.config.encryptOptions?.encryptFunc) config.data = this.config.encryptOptions.encryptFunc(config.data, this.config.encryptOptions.encryptKey || "");
185
+ let processedConfig = config;
186
+ for (const plugin of this.plugins) if (plugin.onRequest) processedConfig = await plugin.onRequest(processedConfig);
187
+ return processedConfig;
188
+ }, (error) => Promise.reject(error));
189
+ this.axiosInstance.interceptors.response.use(async (response) => {
190
+ if (this.config.encrypt && this.config.encryptOptions?.decryptFunc) response.data = this.config.encryptOptions.decryptFunc(response.data, this.config.encryptOptions.encryptKey || "");
191
+ let processedResponse = response;
192
+ for (const plugin of this.plugins) if (plugin.onResponse) processedResponse = await plugin.onResponse(processedResponse);
193
+ return processedResponse.data;
194
+ }, async (error) => {
195
+ let processedError = error;
196
+ for (const plugin of this.plugins) if (plugin.onError) processedError = await plugin.onError(processedError);
197
+ return Promise.reject(processedError);
198
+ });
199
+ }
200
+ /**
201
+ * 创建防重复提交插件
202
+ */
203
+ createRepeatPostPlugin(time = 3) {
204
+ return {
205
+ name: "repeatPost",
206
+ onRequest: (config) => {
207
+ const url = config.url || "";
208
+ const data = config.data || {};
209
+ if (this.isRepeatPost(url, data, time)) config.cancelToken = new axios.default.CancelToken((cancel) => {
210
+ cancel("重复提交,已取消请求");
211
+ });
212
+ return config;
213
+ }
214
+ };
215
+ }
216
+ /**
217
+ * 创建错误处理插件
218
+ */
219
+ createErrorHandlerPlugin(customHandler) {
220
+ return {
221
+ name: "errorHandler",
222
+ onError: (error) => {
223
+ const message = error.message || "请求失败";
224
+ if (customHandler) customHandler();
225
+ else console.error(`请求错误: ${message}`);
226
+ return error;
227
+ }
228
+ };
229
+ }
230
+ /**
231
+ * 创建重新登录插件
232
+ */
233
+ createReloginPlugin(reloginHandler) {
234
+ return {
235
+ name: "autoRelogin",
236
+ onResponse: async (response) => {
237
+ const data = response.data;
238
+ if (data && data.status === 99) {
239
+ if (reloginHandler) {
240
+ if (await reloginHandler()) {
241
+ const result = await this.axiosInstance(response.config);
242
+ return {
243
+ ...response,
244
+ data: result
245
+ };
246
+ }
247
+ }
248
+ }
249
+ return response;
250
+ }
251
+ };
252
+ }
253
+ /**
254
+ * 创建调试插件
255
+ */
256
+ createDebugPlugin() {
257
+ return {
258
+ name: "debug",
259
+ onRequest: (config) => {
260
+ console.log("请求配置:", config);
261
+ return config;
262
+ },
263
+ onResponse: (response) => {
264
+ console.log("响应数据:", response.data);
265
+ return response;
266
+ },
267
+ onError: (error) => {
268
+ console.error("请求错误:", error);
269
+ return error;
270
+ }
271
+ };
272
+ }
273
+ /**
274
+ * 创建统一响应处理插件
275
+ */
276
+ createResponseHandlerPlugin(config) {
277
+ const { successCodes = [200, 0], reloginCodes = [
278
+ 401,
279
+ 403,
280
+ 99
281
+ ], loginPath = "/login", redirectCodes = {}, customHandlers = {}, reLogin, routerPush, showMessage } = config;
282
+ return {
283
+ name: "responseHandler",
284
+ onResponse: async (response) => {
285
+ const data = response.data;
286
+ const status = data?.status ?? data?.code ?? response.status;
287
+ if (customHandlers[status]) return {
288
+ ...response,
289
+ data: customHandlers[status](data, response)
290
+ };
291
+ if (reloginCodes.includes(status)) {
292
+ const message = data?.message || data?.msg || "登录已过期,请重新登录";
293
+ if (showMessage) showMessage(message, "warning");
294
+ if (reLogin) reLogin();
295
+ else if (routerPush) routerPush(typeof loginPath === "function" ? loginPath() : loginPath);
296
+ return Promise.reject(new Error(message));
297
+ }
298
+ if (redirectCodes[status]) {
299
+ const message = data?.message || data?.msg || "页面跳转中...";
300
+ if (showMessage) showMessage(message, "info");
301
+ if (routerPush) routerPush(redirectCodes[status]);
302
+ }
303
+ if (successCodes.includes(status)) return response;
304
+ const errorMessage = data?.message || data?.msg || "请求失败";
305
+ if (showMessage) showMessage(errorMessage, "error");
306
+ return Promise.reject(new Error(errorMessage));
307
+ },
308
+ onError: (error) => {
309
+ const message = error.message || "网络请求失败";
310
+ if (showMessage) showMessage(message, "error");
311
+ return Promise.reject(error);
312
+ }
313
+ };
314
+ }
315
+ /**
316
+ * 检查是否重复提交
317
+ */
318
+ isRepeatPost(url, data, time) {
319
+ return false;
320
+ }
321
+ /**
322
+ * GET 请求
323
+ * @param url 请求路径
324
+ * @param params 请求参数
325
+ * @param config 请求配置
326
+ * @param domain 可选的域名,如果提供则使用该域名发送请求
327
+ */
328
+ get(url, params = {}, config = {}, domain) {
329
+ if (domain) return Http.getDomainInstance(domain).get(url, params, config);
330
+ return this.axiosInstance.get(url, {
331
+ params,
332
+ ...config
333
+ });
334
+ }
335
+ /**
336
+ * POST 请求
337
+ * @param url 请求路径
338
+ * @param data 请求数据
339
+ * @param config 请求配置
340
+ * @param domain 可选的域名,如果提供则使用该域名发送请求
341
+ */
342
+ post(url, data = {}, config = {}, domain) {
343
+ if (domain) return Http.getDomainInstance(domain).post(url, data, config);
344
+ return this.axiosInstance.post(url, data, config);
345
+ }
346
+ /**
347
+ * PUT 请求
348
+ * @param url 请求路径
349
+ * @param data 请求数据
350
+ * @param config 请求配置
351
+ * @param domain 可选的域名,如果提供则使用该域名发送请求
352
+ */
353
+ put(url, data = {}, config = {}, domain) {
354
+ if (domain) return Http.getDomainInstance(domain).put(url, data, config);
355
+ return this.axiosInstance.put(url, data, config);
356
+ }
357
+ /**
358
+ * DELETE 请求
359
+ * @param url 请求路径
360
+ * @param config 请求配置
361
+ * @param domain 可选的域名,如果提供则使用该域名发送请求
362
+ */
363
+ delete(url, config = {}, domain) {
364
+ if (domain) return Http.getDomainInstance(domain).delete(url, config);
365
+ return this.axiosInstance.delete(url, config);
366
+ }
367
+ /**
368
+ * 直接请求特定域名
369
+ * @param domain 域名
370
+ */
371
+ domain(domain) {
372
+ return Http.getDomainInstance(domain);
373
+ }
374
+ /**
375
+ * 添加请求取消功能
376
+ */
377
+ /**
378
+ * 文件上传请求
379
+ */
380
+ upload(url, file, config = {}, domain) {
381
+ const formData = file instanceof File ? new FormData() : file;
382
+ if (file instanceof File) formData.append("file", file);
383
+ const uploadConfig = {
384
+ headers: { "Content-Type": "multipart/form-data" },
385
+ ...config
386
+ };
387
+ if (domain) return Http.getDomainInstance(domain).post(url, formData, uploadConfig);
388
+ return this.axiosInstance.post(url, formData, uploadConfig);
389
+ }
390
+ /**
391
+ * 文件下载请求
392
+ */
393
+ download(url, params = {}, config = {}, domain) {
394
+ const downloadConfig = {
395
+ responseType: "blob",
396
+ ...config
397
+ };
398
+ if (domain) return Http.getDomainInstance(domain).get(url, params, downloadConfig);
399
+ return this.axiosInstance.get(url, {
400
+ params,
401
+ ...downloadConfig
402
+ });
403
+ }
404
+ };
405
+ const http = new Proxy({}, { get(target, prop) {
406
+ const instance = Http.getInstance();
407
+ const value = instance[prop];
408
+ if (typeof value === "function") return value.bind(instance);
409
+ return value;
410
+ } });
411
+ const initHttp = (HttpConfig) => {
412
+ Http.getInstance(HttpConfig);
413
+ };
414
+ const useHttp = () => http;
415
+ //#endregion
416
+ //#region src/packages/utils/encrypt.ts
417
+ function rwEncode(data, privateKey = {}.env.VITE_PRIVATE_KEY) {
418
+ const dataString = JSON.stringify(data);
419
+ const keyHex = crypto_js.default.enc.Utf8.parse(privateKey);
420
+ const options = {
421
+ mode: crypto_js.default.mode.ECB,
422
+ padding: crypto_js.default.pad.Pkcs7
423
+ };
424
+ const Result = crypto_js.default.DES.encrypt(dataString, keyHex, options);
425
+ return crypto_js.default.enc.Base64.stringify(Result.ciphertext);
426
+ }
427
+ function rwDecode(data, privateKey = {}.env.VITE_PRIVATE_KEY, showError = true) {
428
+ const keyHex = crypto_js.default.enc.Utf8.parse(privateKey);
429
+ const options = {
430
+ mode: crypto_js.default.mode.ECB,
431
+ padding: crypto_js.default.pad.Pkcs7
432
+ };
433
+ try {
434
+ const Result = crypto_js.default.DES.decrypt(data, keyHex, options);
435
+ const ResultString = crypto_js.default.enc.Utf8.stringify(Result);
436
+ return JSON.parse(ResultString);
437
+ } catch {
438
+ if (process?.env?.NODE_ENV != "production" && showError) element_plus.ElMessageBox.alert(data, "返回数据解决出错,原文如下", { dangerouslyUseHTMLString: true });
439
+ if (!showError) return data;
440
+ return false;
441
+ }
442
+ }
443
+ const md5 = (sourceString) => {
444
+ if (typeof sourceString !== "string") sourceString = JSON.stringify(sourceString);
445
+ return crypto_js.default.MD5(sourceString).toString().toUpperCase();
446
+ };
447
+ //#endregion
448
+ //#region src/packages/stores/appConfig.ts
449
+ const useAppConfigStore = (0, pinia.defineStore)("appConfig", {
450
+ state: () => ({
451
+ title: "",
452
+ logo: "",
453
+ bgImg: "",
454
+ showWater: true,
455
+ showChoiceSites: false,
456
+ support: "广州召隆信息技术有限公司",
457
+ coopyRight: "Copyright 2025",
458
+ developerMode: true,
459
+ layout: {
460
+ layout: "ltb",
461
+ userCanChange: false,
462
+ paleTheme: false,
463
+ chalk: "blue"
464
+ },
465
+ login: {
466
+ saveLoginDate: 14,
467
+ checkLoginStatus: 5,
468
+ ShowLoginAuthCode: true
469
+ },
470
+ expires: {
471
+ postTime: 10,
472
+ keyword: 5,
473
+ options: 60
474
+ },
475
+ map: {
476
+ type: "",
477
+ key: ""
478
+ }
479
+ }),
480
+ getters: {},
481
+ actions: {
482
+ async getFromRemote(url) {
483
+ return await http.post(url, {}).then((res) => {
484
+ if (res.status == 0) {
485
+ this.$patch({ ...res.data });
486
+ return true;
487
+ } else return false;
488
+ });
489
+ },
490
+ saveToRemote(url) {
491
+ http.post(url, this.$state).then((res) => {
492
+ if (res.status == 0) return true;
493
+ else return false;
494
+ });
495
+ },
496
+ reset() {
497
+ this.$reset();
498
+ }
499
+ },
500
+ persist: {
501
+ key: "appConfig",
502
+ serializer: {
503
+ serialize: (state) => rwEncode(state),
504
+ deserialize: (data) => rwDecode(data)
505
+ },
506
+ storage: localStorage
507
+ }
508
+ });
509
+ //#endregion
510
+ //#region src/packages/utils/loadConfig.ts
511
+ const loadConfig = async function() {
512
+ return { appconfig: await useAppConfigStore().getFromRemote("") };
513
+ };
514
+ //#endregion
515
+ //#region src/packages/utils/exportExcel.ts
516
+ function exportExcel(structName, data, columns) {
517
+ const excelData = [];
518
+ let newLine = [];
519
+ const exportFields = columns.map((item) => {
520
+ return item[Object.keys(item)[1]];
521
+ });
522
+ exportFields.forEach((field) => {
523
+ newLine.push(require_locale.t(structName + "." + field));
524
+ });
525
+ excelData.push(newLine);
526
+ data.forEach((dataInfo) => {
527
+ newLine = [];
528
+ exportFields.forEach((field) => {
529
+ newLine.push(dataInfo[field]);
530
+ });
531
+ excelData.push(newLine);
532
+ });
533
+ const worksheet = xlsx.utils.aoa_to_sheet(excelData);
534
+ const workbook = xlsx.utils.book_new();
535
+ worksheet["!cols"] = [];
536
+ exportFields.forEach((field) => {
537
+ const columnInfo = columns.find((columnInfo) => columnInfo.name == field);
538
+ let width = 10;
539
+ if (columnInfo != void 0) {
540
+ if (columnInfo.width != void 0) width = parseInt(columnInfo.width.toString());
541
+ }
542
+ const colsInfo = { wpx: width };
543
+ worksheet["!cols"] && worksheet["!cols"].push(colsInfo);
544
+ });
545
+ xlsx.utils.book_append_sheet(workbook, worksheet, "Sheet1");
546
+ const excelBuffer = xlsx.write(workbook, {
547
+ bookType: "xlsx",
548
+ type: "array"
549
+ });
550
+ (0, file_saver.saveAs)(new Blob([excelBuffer], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8" }), require_locale.t(structName + ".TITLE") + "-" + (0, dayjs.default)().format("YYYY-MM-DD") + ".xlsx");
551
+ }
552
+ const exportExcelAll = (url, postData, config) => {
553
+ http.post(url, postData, config).then(async (res) => {
554
+ const blob = new Blob([res]);
555
+ const fileName = config.title;
556
+ if ("download" in document.createElement("a")) {
557
+ const elink = document.createElement("a");
558
+ elink.download = fileName;
559
+ elink.style.display = "none";
560
+ elink.href = URL.createObjectURL(blob);
561
+ document.body.appendChild(elink);
562
+ elink.click();
563
+ URL.revokeObjectURL(elink.href);
564
+ document.body.removeChild(elink);
565
+ } else if (navigator.msSaveBlob) navigator.msSaveBlob(blob, fileName);
566
+ });
567
+ };
568
+ //#endregion
569
+ //#region src/packages/utils/mapUtils.ts
570
+ const x_pi = 3.141592653589793 * 3e3 / 180;
571
+ function gcj02ToBd09(lng, lat) {
572
+ var z = Math.sqrt(lng * lng + lat * lat) + 2e-5 * Math.sin(lat * x_pi);
573
+ var theta = Math.atan2(lat, lng) + 3e-6 * Math.cos(lng * x_pi);
574
+ return [z * Math.cos(theta) + .0065, z * Math.sin(theta) + .006];
575
+ }
576
+ function bd09ToGcj02(bd_lon, bd_lat) {
577
+ var x = bd_lon - .0065;
578
+ var y = bd_lat - .006;
579
+ var z = Math.sqrt(x * x + y * y) - 2e-5 * Math.sin(y * x_pi);
580
+ var theta = Math.atan2(y, x) - 3e-6 * Math.cos(x * x_pi);
581
+ return [z * Math.cos(theta), z * Math.sin(theta)];
582
+ }
583
+ //#endregion
584
+ //#region src/packages/utils/formData.ts
585
+ var PathUtils = class {
586
+ static {
587
+ this.cache = /* @__PURE__ */ new Map();
588
+ }
589
+ static parsePath(path) {
590
+ if (this.cache.has(path)) return this.cache.get(path);
591
+ const keys = path.replace(/\[(\d+)\]/g, ".$1").split(".").filter((key) => key !== "");
592
+ this.cache.set(path, keys);
593
+ return keys;
594
+ }
595
+ static getValue(obj, path) {
596
+ const keys = this.parsePath(path);
597
+ let current = obj;
598
+ for (const key of keys) {
599
+ if (current === null || current === void 0) return;
600
+ current = current[key];
601
+ }
602
+ return current;
603
+ }
604
+ static setValue(obj, path, value) {
605
+ const keys = this.parsePath(path);
606
+ let current = obj;
607
+ for (let i = 0; i < keys.length - 1; i++) {
608
+ const key = keys[i];
609
+ const nextKey = keys[i + 1];
610
+ if (current[key] === null || current[key] === void 0) current[key] = /^\d+$/.test(nextKey) ? [] : {};
611
+ current = current[key];
612
+ }
613
+ current[keys[keys.length - 1]] = value;
614
+ }
615
+ static deleteValue(obj, path) {
616
+ const keys = this.parsePath(path);
617
+ let current = obj;
618
+ for (let i = 0; i < keys.length - 1; i++) {
619
+ if (current === null || current === void 0) return false;
620
+ current = current[keys[i]];
621
+ }
622
+ if (current && keys.length > 0) {
623
+ const lastKey = keys[keys.length - 1];
624
+ if (Array.isArray(current)) current.splice(parseInt(lastKey), 1);
625
+ else delete current[lastKey];
626
+ return true;
627
+ }
628
+ return false;
629
+ }
630
+ static hasValue(obj, path) {
631
+ const keys = this.parsePath(path);
632
+ let current = obj;
633
+ for (const key of keys) {
634
+ if (current === null || current === void 0 || !(key in current)) return false;
635
+ current = current[key];
636
+ }
637
+ return true;
638
+ }
639
+ };
640
+ function createFormData(formId, initialData = {}) {
641
+ const state = (0, vue.isReactive)(initialData) ? { data: initialData } : (0, vue.reactive)({ data: { ...initialData } });
642
+ const context = {
643
+ formId,
644
+ data: state.data,
645
+ setFieldValue: (field, value) => {
646
+ try {
647
+ PathUtils.setValue(state.data, field, value);
648
+ } catch (error) {
649
+ console.error(`[FormData] 设置字段 '${field}' 失败:`, error);
650
+ }
651
+ },
652
+ getFieldValue: (field) => {
653
+ try {
654
+ return PathUtils.getValue(state.data, field);
655
+ } catch (error) {
656
+ console.error(`[FormData] 获取字段 '${field}' 失败:`, error);
657
+ return;
658
+ }
659
+ },
660
+ setFieldsValue: (values) => {
661
+ Object.entries(values).forEach(([field, value]) => {
662
+ context.setFieldValue(field, value);
663
+ });
664
+ },
665
+ getFieldsValue: () => state.data,
666
+ deleteField: (field) => {
667
+ PathUtils.deleteValue(state.data, field);
668
+ },
669
+ hasField: (field) => {
670
+ return PathUtils.hasValue(state.data, field);
671
+ },
672
+ validate: async () => {
673
+ return true;
674
+ }
675
+ };
676
+ return context;
677
+ }
678
+ function useFormField(fieldName) {
679
+ const formContext = (0, vue.inject)(FormDataKey);
680
+ if (!formContext) {
681
+ if (process?.env?.NODE_ENV !== "production") console.warn(`[useFormField] FormData not found for field '${fieldName}'. Make sure this component is used within a RwForm component.`);
682
+ return {
683
+ value: (0, vue.ref)(void 0),
684
+ hasValue: (0, vue.ref)(false),
685
+ deleteField: () => {},
686
+ setField: (value) => {}
687
+ };
688
+ }
689
+ return {
690
+ value: (0, vue.computed)({
691
+ get: () => formContext.getFieldValue(fieldName),
692
+ set: (value) => formContext.setFieldValue(fieldName, value)
693
+ }),
694
+ hasValue: (0, vue.computed)(() => formContext.hasField(fieldName)),
695
+ deleteField: () => formContext.deleteField(fieldName),
696
+ setField: (value) => formContext.setFieldValue(fieldName, value)
697
+ };
698
+ }
699
+ const FormDataKey = Symbol("formData");
700
+ //#endregion
701
+ Object.defineProperty(exports, "FormDataKey", {
702
+ enumerable: true,
703
+ get: function() {
704
+ return FormDataKey;
705
+ }
706
+ });
707
+ Object.defineProperty(exports, "Http", {
708
+ enumerable: true,
709
+ get: function() {
710
+ return Http;
711
+ }
712
+ });
713
+ Object.defineProperty(exports, "PathUtils", {
714
+ enumerable: true,
715
+ get: function() {
716
+ return PathUtils;
717
+ }
718
+ });
719
+ Object.defineProperty(exports, "bd09ToGcj02", {
720
+ enumerable: true,
721
+ get: function() {
722
+ return bd09ToGcj02;
723
+ }
724
+ });
725
+ Object.defineProperty(exports, "castArray", {
726
+ enumerable: true,
727
+ get: function() {
728
+ return castArray;
729
+ }
730
+ });
731
+ Object.defineProperty(exports, "createFormData", {
732
+ enumerable: true,
733
+ get: function() {
734
+ return createFormData;
735
+ }
736
+ });
737
+ Object.defineProperty(exports, "exportExcel", {
738
+ enumerable: true,
739
+ get: function() {
740
+ return exportExcel;
741
+ }
742
+ });
743
+ Object.defineProperty(exports, "exportExcelAll", {
744
+ enumerable: true,
745
+ get: function() {
746
+ return exportExcelAll;
747
+ }
748
+ });
749
+ Object.defineProperty(exports, "gcj02ToBd09", {
750
+ enumerable: true,
751
+ get: function() {
752
+ return gcj02ToBd09;
753
+ }
754
+ });
755
+ Object.defineProperty(exports, "generateId", {
756
+ enumerable: true,
757
+ get: function() {
758
+ return generateId;
759
+ }
760
+ });
761
+ Object.defineProperty(exports, "getRandomInt", {
762
+ enumerable: true,
763
+ get: function() {
764
+ return getRandomInt;
765
+ }
766
+ });
767
+ Object.defineProperty(exports, "http", {
768
+ enumerable: true,
769
+ get: function() {
770
+ return http;
771
+ }
772
+ });
773
+ Object.defineProperty(exports, "initHttp", {
774
+ enumerable: true,
775
+ get: function() {
776
+ return initHttp;
777
+ }
778
+ });
779
+ Object.defineProperty(exports, "loadConfig", {
780
+ enumerable: true,
781
+ get: function() {
782
+ return loadConfig;
783
+ }
784
+ });
785
+ Object.defineProperty(exports, "md5", {
786
+ enumerable: true,
787
+ get: function() {
788
+ return md5;
789
+ }
790
+ });
791
+ Object.defineProperty(exports, "mutable", {
792
+ enumerable: true,
793
+ get: function() {
794
+ return mutable;
795
+ }
796
+ });
797
+ Object.defineProperty(exports, "rwDecode", {
798
+ enumerable: true,
799
+ get: function() {
800
+ return rwDecode;
801
+ }
802
+ });
803
+ Object.defineProperty(exports, "rwEncode", {
804
+ enumerable: true,
805
+ get: function() {
806
+ return rwEncode;
807
+ }
808
+ });
809
+ Object.defineProperty(exports, "throttleByRaf", {
810
+ enumerable: true,
811
+ get: function() {
812
+ return throttleByRaf;
813
+ }
814
+ });
815
+ Object.defineProperty(exports, "unique", {
816
+ enumerable: true,
817
+ get: function() {
818
+ return unique;
819
+ }
820
+ });
821
+ Object.defineProperty(exports, "uniqueBy", {
822
+ enumerable: true,
823
+ get: function() {
824
+ return uniqueBy;
825
+ }
826
+ });
827
+ Object.defineProperty(exports, "uniqueByFn", {
828
+ enumerable: true,
829
+ get: function() {
830
+ return uniqueByFn;
831
+ }
832
+ });
833
+ Object.defineProperty(exports, "useAppConfigStore", {
834
+ enumerable: true,
835
+ get: function() {
836
+ return useAppConfigStore;
837
+ }
838
+ });
839
+ Object.defineProperty(exports, "useFormField", {
840
+ enumerable: true,
841
+ get: function() {
842
+ return useFormField;
843
+ }
844
+ });
845
+ Object.defineProperty(exports, "useHttp", {
846
+ enumerable: true,
847
+ get: function() {
848
+ return useHttp;
849
+ }
850
+ });