@mingto/tools 1.0.686 → 1.0.687
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/file/{get-file-query.d.ts → get-file-path-query.d.ts} +2 -2
- package/dist/file/index.d.ts +2 -2
- package/dist/index.js +60 -16
- package/dist/string/get-url-not-query.d.ts +8 -0
- package/dist/string/get-url-query.d.ts +8 -0
- package/dist/string/index.d.ts +4 -1
- package/dist/string/update-url-query.d.ts +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,7 +75,7 @@ tools.getLocale()
|
|
|
75
75
|
| `getFileIcon` | 获取文件图标 |
|
|
76
76
|
| `getFileName` | 获取文件名 |
|
|
77
77
|
| `getFilePathNotQuery` | 获取去除 query 的文件路径 |
|
|
78
|
-
| `
|
|
78
|
+
| `getFilePathQuery` | 获取文件路径 query |
|
|
79
79
|
| `getFileSuffix` | 获取文件后缀 |
|
|
80
80
|
| `getFileSuffixIcon` | 获取文件后缀图标 |
|
|
81
81
|
| `getFileTitle` | 获取文件标题 |
|
package/dist/file/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { CompressFileSuffixEnum, DocumentFileSuffixEnum, FileSuffixEnum, ImageFi
|
|
|
4
4
|
import { default as getFileIcon } from './get-file-icon';
|
|
5
5
|
import { default as getFileName } from './get-file-name';
|
|
6
6
|
import { default as getFilePathNotQuery } from './get-file-path-not-query';
|
|
7
|
-
import { default as
|
|
7
|
+
import { default as getFilePathQuery } from './get-file-path-query';
|
|
8
8
|
import { default as getFileSuffix } from './get-file-suffix';
|
|
9
9
|
import { default as getFileSuffixIcon } from './get-file-suffix-icon';
|
|
10
10
|
import { default as getFileTitle } from './get-file-title';
|
|
@@ -20,4 +20,4 @@ import { default as singleDownloadFile } from './single-download-file';
|
|
|
20
20
|
import { default as singleDownloadFileBase64 } from './single-download-file-base64';
|
|
21
21
|
import { default as updateFilePathQuery } from './update-file-path-query';
|
|
22
22
|
export type { CompressFileSuffix, DocumentFileSuffix, FileSuffix, ImageFileSuffix, MarkdownFileSuffix, MusicFileSuffix, PptFileSuffix, VideoFileSuffix, };
|
|
23
|
-
export { batchDownloadFile, CompressFileSuffixEnum, DocumentFileSuffixEnum, FileSuffixEnum, getFileIcon, getFileName, getFilePathNotQuery,
|
|
23
|
+
export { batchDownloadFile, CompressFileSuffixEnum, DocumentFileSuffixEnum, FileSuffixEnum, getFileIcon, getFileName, getFilePathNotQuery, getFilePathQuery, getFileSuffix, getFileSuffixIcon, getFileTitle, ImageFileSuffixEnum, isCompressFilePath, isDocumentFilePath, isFilePath, isImageFilePath, isMarkdownFilePath, isMusicFilePath, isPptFilePath, isVideoFilePath, MarkdownFileSuffixEnum, MusicFileSuffixEnum, PptFileSuffixEnum, singleDownloadFile, singleDownloadFileBase64, updateFilePathQuery, VideoFileSuffixEnum, };
|
package/dist/index.js
CHANGED
|
@@ -15979,21 +15979,17 @@ function chunkString(str) {
|
|
|
15979
15979
|
return chunks;
|
|
15980
15980
|
}
|
|
15981
15981
|
//#endregion
|
|
15982
|
-
//#region src/string/
|
|
15983
|
-
init__rollupPluginBabelHelpers();
|
|
15982
|
+
//#region src/string/get-url-not-query.ts
|
|
15984
15983
|
/**
|
|
15985
|
-
*
|
|
15986
|
-
* 该函数会遍历对象的键值对,将每个键和值进行 URL 编码,然后以 "key=value" 的形式拼接成字符串,并用 "&" 符号连接。
|
|
15987
|
-
*
|
|
15988
|
-
* @param obj - 需要转换的对象,对象的键为字符串,值为任意类型。
|
|
15989
|
-
* @returns 转换后的 URL 查询字符串。
|
|
15984
|
+
* 获取 URL 中不包含查询参数的主体部分。
|
|
15990
15985
|
*
|
|
15986
|
+
* @param url URL。
|
|
15987
|
+
* @returns 不包含查询参数的 URL 主体。
|
|
15991
15988
|
*/
|
|
15992
|
-
function
|
|
15993
|
-
|
|
15994
|
-
|
|
15995
|
-
|
|
15996
|
-
}).join("&");
|
|
15989
|
+
function getUrlNotQuery(url) {
|
|
15990
|
+
var _matchResult$;
|
|
15991
|
+
var matchResult = url.match(/^([^?]*)/);
|
|
15992
|
+
return (_matchResult$ = matchResult === null || matchResult === void 0 ? void 0 : matchResult[1]) !== null && _matchResult$ !== void 0 ? _matchResult$ : url;
|
|
15997
15993
|
}
|
|
15998
15994
|
//#endregion
|
|
15999
15995
|
//#region src/string/query-string-to-object.ts
|
|
@@ -16014,6 +16010,54 @@ function queryStringToObject(queryString) {
|
|
|
16014
16010
|
}, {});
|
|
16015
16011
|
}
|
|
16016
16012
|
//#endregion
|
|
16013
|
+
//#region src/string/get-url-query.ts
|
|
16014
|
+
/**
|
|
16015
|
+
* 获取 URL 中的查询参数。
|
|
16016
|
+
*
|
|
16017
|
+
* @param url URL。
|
|
16018
|
+
* @returns 查询参数对象。
|
|
16019
|
+
*/
|
|
16020
|
+
function getUrlQuery(url) {
|
|
16021
|
+
var _matchResult$;
|
|
16022
|
+
var matchResult = url.match(/\?(.*)/);
|
|
16023
|
+
return queryStringToObject((_matchResult$ = matchResult === null || matchResult === void 0 ? void 0 : matchResult[1]) !== null && _matchResult$ !== void 0 ? _matchResult$ : "");
|
|
16024
|
+
}
|
|
16025
|
+
//#endregion
|
|
16026
|
+
//#region src/string/object-to-query-string.ts
|
|
16027
|
+
init__rollupPluginBabelHelpers();
|
|
16028
|
+
/**
|
|
16029
|
+
* 将对象转换为 URL 查询字符串。
|
|
16030
|
+
* 该函数会遍历对象的键值对,将每个键和值进行 URL 编码,然后以 "key=value" 的形式拼接成字符串,并用 "&" 符号连接。
|
|
16031
|
+
*
|
|
16032
|
+
* @param obj - 需要转换的对象,对象的键为字符串,值为任意类型。
|
|
16033
|
+
* @returns 转换后的 URL 查询字符串。
|
|
16034
|
+
*
|
|
16035
|
+
*/
|
|
16036
|
+
function objectToQueryString(obj) {
|
|
16037
|
+
return Object.entries(obj).map(function(_ref) {
|
|
16038
|
+
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
16039
|
+
return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
|
|
16040
|
+
}).join("&");
|
|
16041
|
+
}
|
|
16042
|
+
//#endregion
|
|
16043
|
+
//#region src/string/update-url-query.ts
|
|
16044
|
+
init__rollupPluginBabelHelpers();
|
|
16045
|
+
/**
|
|
16046
|
+
* 更新 URL 的查询参数。
|
|
16047
|
+
*
|
|
16048
|
+
* @param url 完整 URL。
|
|
16049
|
+
* @param objectQuery 查询参数对象。
|
|
16050
|
+
* @param isAppend 是否合并原有查询参数,默认 `true` 表示合并;`false` 则仅使用新传入的参数。
|
|
16051
|
+
* @returns 更新后的 URL。
|
|
16052
|
+
*/
|
|
16053
|
+
function updateUrlQuery(url, objectQuery) {
|
|
16054
|
+
var isAppend = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
16055
|
+
var urlPath = getUrlNotQuery(url);
|
|
16056
|
+
var urlQuery = getUrlQuery(url);
|
|
16057
|
+
var queryString = objectToQueryString(isAppend ? _objectSpread2(_objectSpread2({}, urlQuery), objectQuery) : objectQuery);
|
|
16058
|
+
return checkEmpty(queryString) ? urlPath : "".concat(urlPath, "?").concat(queryString);
|
|
16059
|
+
}
|
|
16060
|
+
//#endregion
|
|
16017
16061
|
//#region src/file/get-file-path-not-query.ts
|
|
16018
16062
|
/**
|
|
16019
16063
|
* 获取文件路径(不包含查询参数)。
|
|
@@ -16027,14 +16071,14 @@ function getFilePathNotQuery(filePath) {
|
|
|
16027
16071
|
return (_matchResult$ = matchResult === null || matchResult === void 0 ? void 0 : matchResult[1]) !== null && _matchResult$ !== void 0 ? _matchResult$ : "";
|
|
16028
16072
|
}
|
|
16029
16073
|
//#endregion
|
|
16030
|
-
//#region src/file/get-file-query.ts
|
|
16074
|
+
//#region src/file/get-file-path-query.ts
|
|
16031
16075
|
/**
|
|
16032
16076
|
* 获取 URL 中的查询参数。
|
|
16033
16077
|
*
|
|
16034
16078
|
* @param filePath 文件路径。
|
|
16035
16079
|
* @returns 查询参数对象。
|
|
16036
16080
|
*/
|
|
16037
|
-
function
|
|
16081
|
+
function getFilePathQuery(filePath) {
|
|
16038
16082
|
var _matchResult$;
|
|
16039
16083
|
var matchResult = filePath.match(filePathRegex);
|
|
16040
16084
|
return queryStringToObject((_matchResult$ = matchResult === null || matchResult === void 0 ? void 0 : matchResult[6]) !== null && _matchResult$ !== void 0 ? _matchResult$ : "");
|
|
@@ -16052,7 +16096,7 @@ function updateFilePathQuery(filePath, objectQuery) {
|
|
|
16052
16096
|
var isAppend = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
16053
16097
|
var filePathNotQuery = getFilePathNotQuery(filePath);
|
|
16054
16098
|
var queryString = "";
|
|
16055
|
-
if (isAppend) queryString = objectToQueryString(_objectSpread2(_objectSpread2({},
|
|
16099
|
+
if (isAppend) queryString = objectToQueryString(_objectSpread2(_objectSpread2({}, getFilePathQuery(filePath)), objectQuery));
|
|
16056
16100
|
else queryString = objectToQueryString(objectQuery);
|
|
16057
16101
|
return checkEmpty(queryString) ? filePathNotQuery : "".concat(filePathNotQuery, "?").concat(queryString);
|
|
16058
16102
|
}
|
|
@@ -19793,4 +19837,4 @@ var src_default = {
|
|
|
19793
19837
|
}
|
|
19794
19838
|
};
|
|
19795
19839
|
//#endregion
|
|
19796
|
-
export { CompressFileSuffixEnum, DEFAULT_USER_AVATAR, DocumentFileSuffixEnum, FileSuffixEnum, ImageFileSuffixEnum, MarkdownFileSuffixEnum, MusicFileSuffixEnum, PptFileSuffixEnum, VideoFileSuffixEnum, add, batchDownloadFile, beParsedAsNumber, calcAspectRatio, canBeParsedAsNumber, checkArrayEmpty, checkEmpty, checkEmptyNotZero, checkObjectEmpty, chunkArray, chunkString, closeWorker, copyText, createAudioPermission, createWebSocket, createWorker, debounce, deepFreeze, src_default as default, divide, getAbsoluteUrl, getBrowserFingerprint, getDecimalPlaces, getFileIcon, getFileName, getFilePathNotQuery,
|
|
19840
|
+
export { CompressFileSuffixEnum, DEFAULT_USER_AVATAR, DocumentFileSuffixEnum, FileSuffixEnum, ImageFileSuffixEnum, MarkdownFileSuffixEnum, MusicFileSuffixEnum, PptFileSuffixEnum, VideoFileSuffixEnum, add, batchDownloadFile, beParsedAsNumber, calcAspectRatio, canBeParsedAsNumber, checkArrayEmpty, checkEmpty, checkEmptyNotZero, checkObjectEmpty, chunkArray, chunkString, closeWorker, copyText, createAudioPermission, createWebSocket, createWorker, debounce, deepFreeze, src_default as default, divide, getAbsoluteUrl, getBrowserFingerprint, getDecimalPlaces, getFileIcon, getFileName, getFilePathNotQuery, getFilePathQuery, getFileSuffix, getFileSuffixIcon, getFileTitle, getUrlNotQuery, getUrlQuery, getUuid, isAndroid, isArray, isBoolean, isCompressFilePath, isDocumentFilePath, isFilePath, isFunction, isImageFilePath, isIos, isMarkdownFilePath, isMobile, isMusicFilePath, isNullOrUndefined, isNumber, isObject, isPc, isPptFilePath, isString, isUndefined, isValidBase64, isValidUrl, isVideoFilePath, isWebSocketSupported, multiply, objectToQueryString, pickObject, queryStringToObject, singleDownloadFile, downloadBase64File as singleDownloadFileBase64, subtract, throttle, timeDelay, updateFilePathQuery, updateUrlQuery, useTheme };
|
package/dist/string/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { default as chunkString } from './chunk-string';
|
|
2
|
+
import { default as getUrlNotQuery } from './get-url-not-query';
|
|
3
|
+
import { default as getUrlQuery } from './get-url-query';
|
|
2
4
|
import { default as objectToQueryString } from './object-to-query-string';
|
|
3
5
|
import { default as queryStringToObject } from './query-string-to-object';
|
|
4
|
-
|
|
6
|
+
import { default as updateUrlQuery } from './update-url-query';
|
|
7
|
+
export { chunkString, getUrlNotQuery, getUrlQuery, objectToQueryString, queryStringToObject, updateUrlQuery };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 更新 URL 的查询参数。
|
|
3
|
+
*
|
|
4
|
+
* @param url 完整 URL。
|
|
5
|
+
* @param objectQuery 查询参数对象。
|
|
6
|
+
* @param isAppend 是否合并原有查询参数,默认 `true` 表示合并;`false` 则仅使用新传入的参数。
|
|
7
|
+
* @returns 更新后的 URL。
|
|
8
|
+
*/
|
|
9
|
+
declare function updateUrlQuery(url: string, objectQuery: Record<string, string>, isAppend?: boolean): string;
|
|
10
|
+
export default updateUrlQuery;
|