gxxc-util 1.0.17 → 1.0.19
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/cjs/index.js +3 -0
- package/dist/cjs/modules/file.js +36 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/modules/file.js +34 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/modules/file.d.ts +16 -1
- package/dist/umd/index.js +5 -5
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -30,6 +30,9 @@ exports.demo = demo.demo;
|
|
|
30
30
|
exports.file_calculate_md5 = file.file_calculate_md5;
|
|
31
31
|
exports.file_load = file.file_load;
|
|
32
32
|
exports.file_open = file.file_open;
|
|
33
|
+
exports.file_url_is_image = file.file_url_is_image;
|
|
34
|
+
exports.file_url_is_video = file.file_url_is_video;
|
|
35
|
+
exports.file_url_is_video_H264 = file.file_url_is_video_H264;
|
|
33
36
|
exports.num_expand = number.num_expand;
|
|
34
37
|
exports.num_expand_100 = number.num_expand_100;
|
|
35
38
|
exports.num_reduce_100 = number.num_reduce_100;
|
package/dist/cjs/modules/file.js
CHANGED
|
@@ -67,7 +67,43 @@ const file_load = (props) => {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* 判断是否为图片地址
|
|
72
|
+
* @param url 文件路径或网络地址
|
|
73
|
+
*/
|
|
74
|
+
const file_url_is_image = (url) => {
|
|
75
|
+
if (!url)
|
|
76
|
+
return false;
|
|
77
|
+
// 匹配图片后缀,支持带查询参数的 URL (如: .jpg?token=123)
|
|
78
|
+
const imageRegex = /\.(jpg|jpeg|png|gif|bmp|webp|avif|svg)(\?.*)?$/i;
|
|
79
|
+
return imageRegex.test(url);
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* 判断是否为视频地址
|
|
83
|
+
* @param url 文件路径或网络地址
|
|
84
|
+
*/
|
|
85
|
+
const file_url_is_video = (url) => {
|
|
86
|
+
if (!url)
|
|
87
|
+
return false;
|
|
88
|
+
// 匹配图片后缀,支持带查询参数的 URL (如: .jpg?token=123)
|
|
89
|
+
const imageRegex = /\.(mp4|mov|wmv|flv|avi|webm)(\?.*)?$/i;
|
|
90
|
+
return imageRegex.test(url);
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* 判断是视频地址是否为 H.264 编码 这个编码 阿里云可以通过video/snapshot截帧
|
|
94
|
+
* @param url 文件路径或网络地址
|
|
95
|
+
*/
|
|
96
|
+
const file_url_is_video_H264 = (url) => {
|
|
97
|
+
if (!url)
|
|
98
|
+
return false;
|
|
99
|
+
// 匹配图片后缀,支持带查询参数的 URL (如: .jpg?token=123)
|
|
100
|
+
const imageRegex = /\.(mp4|mov|flv)(\?.*)?$/i;
|
|
101
|
+
return imageRegex.test(url);
|
|
102
|
+
};
|
|
70
103
|
|
|
71
104
|
exports.file_calculate_md5 = file_calculate_md5;
|
|
72
105
|
exports.file_load = file_load;
|
|
73
106
|
exports.file_open = file_open;
|
|
107
|
+
exports.file_url_is_image = file_url_is_image;
|
|
108
|
+
exports.file_url_is_video = file_url_is_video;
|
|
109
|
+
exports.file_url_is_video_H264 = file_url_is_video_H264;
|
package/dist/esm/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { author_passwordCheck, author_router_add, author_router_filter, author_r
|
|
|
2
2
|
export { city_code_query_text, city_code_text, city_options, city_two_code_text } from './modules/cityOptions.js';
|
|
3
3
|
export { get_multiple_color, hex_to_rgb, reduce_opacity, rgb_to_hex, theme_change } from './modules/color.js';
|
|
4
4
|
export { demo } from './modules/demo.js';
|
|
5
|
-
export { file_calculate_md5, file_load, file_open } from './modules/file.js';
|
|
5
|
+
export { file_calculate_md5, file_load, file_open, file_url_is_image, file_url_is_video, file_url_is_video_H264 } from './modules/file.js';
|
|
6
6
|
export { num_expand, num_expand_100, num_reduce_100, num_text, num_unit } from './modules/number.js';
|
|
7
7
|
export { getOptionConfig, getUrlConfig, sys_detectBrowser, sys_print, tem_compare_version, tem_get_tableHeader, timejs, video_preview, win_dynamic_fontSize } from './modules/other.js';
|
|
8
8
|
export { val_address, val_amount, val_beforeAfter_space, val_email, val_idcard, val_landline, val_number, val_phone, val_space, val_three_percent, val_two_percent } from './modules/validation.js';
|
package/dist/esm/modules/file.js
CHANGED
|
@@ -65,5 +65,38 @@ const file_load = (props) => {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* 判断是否为图片地址
|
|
70
|
+
* @param url 文件路径或网络地址
|
|
71
|
+
*/
|
|
72
|
+
const file_url_is_image = (url) => {
|
|
73
|
+
if (!url)
|
|
74
|
+
return false;
|
|
75
|
+
// 匹配图片后缀,支持带查询参数的 URL (如: .jpg?token=123)
|
|
76
|
+
const imageRegex = /\.(jpg|jpeg|png|gif|bmp|webp|avif|svg)(\?.*)?$/i;
|
|
77
|
+
return imageRegex.test(url);
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* 判断是否为视频地址
|
|
81
|
+
* @param url 文件路径或网络地址
|
|
82
|
+
*/
|
|
83
|
+
const file_url_is_video = (url) => {
|
|
84
|
+
if (!url)
|
|
85
|
+
return false;
|
|
86
|
+
// 匹配图片后缀,支持带查询参数的 URL (如: .jpg?token=123)
|
|
87
|
+
const imageRegex = /\.(mp4|mov|wmv|flv|avi|webm)(\?.*)?$/i;
|
|
88
|
+
return imageRegex.test(url);
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* 判断是视频地址是否为 H.264 编码 这个编码 阿里云可以通过video/snapshot截帧
|
|
92
|
+
* @param url 文件路径或网络地址
|
|
93
|
+
*/
|
|
94
|
+
const file_url_is_video_H264 = (url) => {
|
|
95
|
+
if (!url)
|
|
96
|
+
return false;
|
|
97
|
+
// 匹配图片后缀,支持带查询参数的 URL (如: .jpg?token=123)
|
|
98
|
+
const imageRegex = /\.(mp4|mov|flv)(\?.*)?$/i;
|
|
99
|
+
return imageRegex.test(url);
|
|
100
|
+
};
|
|
68
101
|
|
|
69
|
-
export { file_calculate_md5, file_load, file_open };
|
|
102
|
+
export { file_calculate_md5, file_load, file_open, file_url_is_image, file_url_is_video, file_url_is_video_H264 };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { author_passwordCheck, author_router_add, author_router_filter, author_r
|
|
|
2
2
|
export { city_code_query_text, city_code_text, city_options, city_two_code_text } from './modules/cityOptions.js';
|
|
3
3
|
export { get_multiple_color, hex_to_rgb, reduce_opacity, rgb_to_hex, theme_change } from './modules/color.js';
|
|
4
4
|
export { demo } from './modules/demo.js';
|
|
5
|
-
export { file_calculate_md5, file_load, file_open } from './modules/file.js';
|
|
5
|
+
export { file_calculate_md5, file_load, file_open, file_url_is_image, file_url_is_video, file_url_is_video_H264 } from './modules/file.js';
|
|
6
6
|
export { num_expand, num_expand_100, num_reduce_100, num_text, num_unit } from './modules/number.js';
|
|
7
7
|
export { getOptionConfig, getUrlConfig, sys_detectBrowser, sys_print, tem_compare_version, tem_get_tableHeader, timejs, video_preview, win_dynamic_fontSize } from './modules/other.js';
|
|
8
8
|
export { val_address, val_amount, val_beforeAfter_space, val_email, val_idcard, val_landline, val_number, val_phone, val_space, val_three_percent, val_two_percent } from './modules/validation.js';
|
|
@@ -21,5 +21,20 @@ declare const file_open: (props: IProps) => void;
|
|
|
21
21
|
* @param {string=} name 可选参数,传入的文件的文件名。如果不提供,默认使用URL中的文件名
|
|
22
22
|
*/
|
|
23
23
|
declare const file_load: (props: IProps) => Promise<void> | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* 判断是否为图片地址
|
|
26
|
+
* @param url 文件路径或网络地址
|
|
27
|
+
*/
|
|
28
|
+
declare const file_url_is_image: (url: string | undefined | null) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* 判断是否为视频地址
|
|
31
|
+
* @param url 文件路径或网络地址
|
|
32
|
+
*/
|
|
33
|
+
declare const file_url_is_video: (url: string | undefined | null) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 判断是视频地址是否为 H.264 编码 这个编码 阿里云可以通过video/snapshot截帧
|
|
36
|
+
* @param url 文件路径或网络地址
|
|
37
|
+
*/
|
|
38
|
+
declare const file_url_is_video_H264: (url: string | undefined | null) => boolean;
|
|
24
39
|
|
|
25
|
-
export { file_calculate_md5, file_load, file_open };
|
|
40
|
+
export { file_calculate_md5, file_load, file_open, file_url_is_image, file_url_is_video, file_url_is_video_H264 };
|