zmdms-utils 0.0.42 → 0.0.44
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/es/common.d.ts +5 -1
- package/dist/es/common.js +18 -1
- package/dist/es/qiankunUtils.d.ts +5 -1
- package/dist/es/qiankunUtils.js +22 -1
- package/dist/es/water.d.ts +1 -1
- package/dist/es/water.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/src/common.ts +20 -0
- package/src/index.ts +2 -1
- package/src/qiankunUtils.ts +19 -0
- package/src/water.ts +1 -1
package/dist/es/common.d.ts
CHANGED
|
@@ -73,5 +73,9 @@ declare function parseJoin(params?: any): any;
|
|
|
73
73
|
* @returns
|
|
74
74
|
*/
|
|
75
75
|
declare function isChinese(char?: string): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* 往地址后面追加参数
|
|
78
|
+
*/
|
|
79
|
+
declare function appendQueryParamsToUrl(url: string, params: any): string;
|
|
76
80
|
|
|
77
|
-
export { addThousedSeparator, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isChinese, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString };
|
|
81
|
+
export { addThousedSeparator, appendQueryParamsToUrl, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isChinese, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString };
|
package/dist/es/common.js
CHANGED
|
@@ -253,5 +253,22 @@ function isChinese(char) {
|
|
|
253
253
|
}
|
|
254
254
|
return isChineseValidate.regex.test(char);
|
|
255
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* 往地址后面追加参数
|
|
258
|
+
*/
|
|
259
|
+
function appendQueryParamsToUrl(url, params) {
|
|
260
|
+
// 检查 URL 中是否已经有查询字符串
|
|
261
|
+
var hasQuery = url.indexOf("?") !== -1;
|
|
262
|
+
var newUrl = url;
|
|
263
|
+
// 遍历参数并追加到 URL
|
|
264
|
+
Object.keys(params).forEach(function (key, index) {
|
|
265
|
+
// 对于第一个参数,如果 URL 已经有查询字符串,则追加 '&'
|
|
266
|
+
// 如果没有,则追加 '?'
|
|
267
|
+
var prefix = hasQuery || index > 0 ? "&" : "?";
|
|
268
|
+
newUrl +=
|
|
269
|
+
prefix + encodeURIComponent(key) + "=" + encodeURIComponent(params[key]);
|
|
270
|
+
});
|
|
271
|
+
return newUrl;
|
|
272
|
+
}
|
|
256
273
|
|
|
257
|
-
export { addThousedSeparator, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isChinese, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString };
|
|
274
|
+
export { addThousedSeparator, appendQueryParamsToUrl, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isChinese, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString };
|
package/dist/es/qiankunUtils.js
CHANGED
|
@@ -7,5 +7,26 @@
|
|
|
7
7
|
function isQiankun() {
|
|
8
8
|
return window.__POWERED_BY_QIANKUN__;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* @description 取微应用地址
|
|
12
|
+
*/
|
|
13
|
+
function getMicroUrl(appKey, apps) {
|
|
14
|
+
var _a;
|
|
15
|
+
if (apps === void 0) { apps = []; }
|
|
16
|
+
var result = (_a = apps === null || apps === void 0 ? void 0 : apps.find) === null || _a === void 0 ? void 0 : _a.call(apps, function (app) { return (app === null || app === void 0 ? void 0 : app.appCode) === appKey; });
|
|
17
|
+
if (result && result.appUrl) {
|
|
18
|
+
try {
|
|
19
|
+
return result.appUrl.endsWith("/")
|
|
20
|
+
? result.appUrl.slice(result.appUrl.length - 1)
|
|
21
|
+
: result.appUrl;
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
console.log("未取到对应的微应用地址!");
|
|
25
|
+
return "";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
console.log("未取到对应的微应用地址!");
|
|
29
|
+
return "";
|
|
30
|
+
}
|
|
10
31
|
|
|
11
|
-
export { isQiankun };
|
|
32
|
+
export { getMicroUrl, isQiankun };
|
package/dist/es/water.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ declare function mergeWaterConfig(waterConfig?: IWaterConfig): {
|
|
|
26
26
|
};
|
|
27
27
|
image: string | undefined;
|
|
28
28
|
};
|
|
29
|
-
declare function getDefaultContent(): string[] | "
|
|
29
|
+
declare function getDefaultContent(): string[] | "浙江交通集团";
|
|
30
30
|
interface IWaterConfig {
|
|
31
31
|
width?: number;
|
|
32
32
|
height?: number;
|
package/dist/es/water.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { initMicroApp } from './es/microAppCreator.js';
|
|
2
|
-
export { isQiankun } from './es/qiankunUtils.js';
|
|
2
|
+
export { getMicroUrl, isQiankun } from './es/qiankunUtils.js';
|
|
3
3
|
export { initGlobalError, initMainApp } from './es/mainApp.js';
|
|
4
4
|
export { getToken, parseToken, removeToken, setToken } from './es/auth.js';
|
|
5
5
|
export { AxiosRequest, IOptions, IOtherOptions } from './es/request.js';
|
|
6
6
|
export { getBaseUrl } from './es/baseUrl.js';
|
|
7
7
|
export { Crypto, md5 } from './es/crypto.js';
|
|
8
|
-
export { addThousedSeparator, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isChinese, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString } from './es/common.js';
|
|
8
|
+
export { addThousedSeparator, appendQueryParamsToUrl, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isChinese, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString } from './es/common.js';
|
|
9
9
|
export { divide, exactRound, formatUnit, minus, plus, times } from './es/math.js';
|
|
10
10
|
export { validatePassword } from './es/passwordValidate.js';
|
|
11
11
|
export { emailValidate, idCardValidate, isChineseValidate, morePhoneValidate, phoneValidate, strLenValidate } from './es/validate.js';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { initMicroApp } from './es/microAppCreator.js';
|
|
2
|
-
export { isQiankun } from './es/qiankunUtils.js';
|
|
2
|
+
export { getMicroUrl, isQiankun } from './es/qiankunUtils.js';
|
|
3
3
|
export { initGlobalError, initMainApp } from './es/mainApp.js';
|
|
4
4
|
export { getToken, parseToken, removeToken, setToken } from './es/auth.js';
|
|
5
5
|
export { AxiosRequest } from './es/request.js';
|
|
6
6
|
export { getBaseUrl } from './es/baseUrl.js';
|
|
7
7
|
export { Crypto, md5 } from './es/crypto.js';
|
|
8
|
-
export { addThousedSeparator, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isChinese, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString } from './es/common.js';
|
|
8
|
+
export { addThousedSeparator, appendQueryParamsToUrl, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isChinese, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString } from './es/common.js';
|
|
9
9
|
export { divide, exactRound, formatUnit, minus, plus, times } from './es/math.js';
|
|
10
10
|
export { validatePassword } from './es/passwordValidate.js';
|
|
11
11
|
export { emailValidate, idCardValidate, isChineseValidate, morePhoneValidate, phoneValidate, strLenValidate } from './es/validate.js';
|
package/package.json
CHANGED
package/src/common.ts
CHANGED
|
@@ -263,3 +263,23 @@ export function isChinese(char?: string) {
|
|
|
263
263
|
}
|
|
264
264
|
return isChineseValidate.regex.test(char);
|
|
265
265
|
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* 往地址后面追加参数
|
|
269
|
+
*/
|
|
270
|
+
export function appendQueryParamsToUrl(url: string, params: any) {
|
|
271
|
+
// 检查 URL 中是否已经有查询字符串
|
|
272
|
+
const hasQuery = url.indexOf("?") !== -1;
|
|
273
|
+
let newUrl = url;
|
|
274
|
+
|
|
275
|
+
// 遍历参数并追加到 URL
|
|
276
|
+
Object.keys(params).forEach((key, index) => {
|
|
277
|
+
// 对于第一个参数,如果 URL 已经有查询字符串,则追加 '&'
|
|
278
|
+
// 如果没有,则追加 '?'
|
|
279
|
+
const prefix = hasQuery || index > 0 ? "&" : "?";
|
|
280
|
+
newUrl +=
|
|
281
|
+
prefix + encodeURIComponent(key) + "=" + encodeURIComponent(params[key]);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
return newUrl;
|
|
285
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { initMicroApp } from "./microAppCreator";
|
|
2
|
-
export { isQiankun } from "./qiankunUtils";
|
|
2
|
+
export { isQiankun, getMicroUrl } from "./qiankunUtils";
|
|
3
3
|
export { initMainApp, initGlobalError } from "./mainApp";
|
|
4
4
|
export { getToken, setToken, removeToken, parseToken } from "./auth";
|
|
5
5
|
export { AxiosRequest, type IOtherOptions, type IOptions } from "./request";
|
|
@@ -10,6 +10,7 @@ export {
|
|
|
10
10
|
emitter,
|
|
11
11
|
addThousedSeparator,
|
|
12
12
|
parseQueryParams,
|
|
13
|
+
appendQueryParamsToUrl,
|
|
13
14
|
unescapeString,
|
|
14
15
|
copyToClipboard,
|
|
15
16
|
getFileExtension,
|
package/src/qiankunUtils.ts
CHANGED
|
@@ -8,3 +8,22 @@
|
|
|
8
8
|
export function isQiankun() {
|
|
9
9
|
return (window as any).__POWERED_BY_QIANKUN__;
|
|
10
10
|
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @description 取微应用地址
|
|
14
|
+
*/
|
|
15
|
+
export function getMicroUrl(appKey: string, apps: any = []) {
|
|
16
|
+
const result = apps?.find?.((app: any) => app?.appCode === appKey);
|
|
17
|
+
if (result && result.appUrl) {
|
|
18
|
+
try {
|
|
19
|
+
return result.appUrl.endsWith("/")
|
|
20
|
+
? result.appUrl.slice(result.appUrl.length - 1)
|
|
21
|
+
: result.appUrl;
|
|
22
|
+
} catch (err) {
|
|
23
|
+
console.log("未取到对应的微应用地址!");
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
console.log("未取到对应的微应用地址!");
|
|
28
|
+
return "";
|
|
29
|
+
}
|