@yysports/tools 0.1.9 → 0.1.10

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.
@@ -8,3 +8,11 @@ export declare const compressImg: (file: Blob, config?: number | compressAccurat
8
8
  * @returns
9
9
  */
10
10
  export declare const checkFileType: (file: File, accept: string) => boolean;
11
+ /**
12
+ * 获取图片分辨率
13
+ * @param file File 图片文件对象
14
+ */
15
+ export declare const getImageResolution: (file: File) => Promise<{
16
+ width: number;
17
+ height: number;
18
+ }>;
@@ -28,4 +28,21 @@ export var checkFileType = function checkFileType(file, accept) {
28
28
  return acceptList.includes(fileType);
29
29
  }
30
30
  return true;
31
+ };
32
+
33
+ /**
34
+ * 获取图片分辨率
35
+ * @param file File 图片文件对象
36
+ */
37
+ export var getImageResolution = function getImageResolution(file) {
38
+ return new Promise(function (resolve) {
39
+ var img = new Image();
40
+ img.src = URL.createObjectURL(file);
41
+ img.onload = function () {
42
+ resolve({
43
+ width: img.width,
44
+ height: img.height
45
+ });
46
+ };
47
+ });
31
48
  };
@@ -8,3 +8,11 @@ export declare const compressImg: (file: Blob, config?: number | compressAccurat
8
8
  * @returns
9
9
  */
10
10
  export declare const checkFileType: (file: File, accept: string) => boolean;
11
+ /**
12
+ * 获取图片分辨率
13
+ * @param file File 图片文件对象
14
+ */
15
+ export declare const getImageResolution: (file: File) => Promise<{
16
+ width: number;
17
+ height: number;
18
+ }>;
package/lib/Utils/file.js CHANGED
@@ -21,7 +21,8 @@ var file_exports = {};
21
21
  __export(file_exports, {
22
22
  checkFileType: () => checkFileType,
23
23
  compressImg: () => compressImg,
24
- downloadFile: () => downloadFile
24
+ downloadFile: () => downloadFile,
25
+ getImageResolution: () => getImageResolution
25
26
  });
26
27
  module.exports = __toCommonJS(file_exports);
27
28
  var import_image_conversion = require("image-conversion");
@@ -42,9 +43,19 @@ var checkFileType = (file, accept) => {
42
43
  }
43
44
  return true;
44
45
  };
46
+ var getImageResolution = (file) => {
47
+ return new Promise((resolve) => {
48
+ const img = new Image();
49
+ img.src = URL.createObjectURL(file);
50
+ img.onload = () => {
51
+ resolve({ width: img.width, height: img.height });
52
+ };
53
+ });
54
+ };
45
55
  // Annotate the CommonJS export names for ESM import in node:
46
56
  0 && (module.exports = {
47
57
  checkFileType,
48
58
  compressImg,
49
- downloadFile
59
+ downloadFile,
60
+ getImageResolution
50
61
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yysports/tools",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "常用工具函数库",
5
5
  "homepage": "https://git.pousheng.com/sport-service-department/pousheng-guard/yysports_tools#readme",
6
6
  "bugs": {
@@ -64,25 +64,25 @@
64
64
  "pako": "^2.1.0"
65
65
  },
66
66
  "devDependencies": {
67
- "@ant-design/pro-components": "^2.7.14",
68
- "@commitlint/cli": "^19.3.0",
69
- "@commitlint/config-conventional": "^19.2.2",
67
+ "@ant-design/pro-components": "^2.7.16",
68
+ "@commitlint/cli": "^19.4.1",
69
+ "@commitlint/config-conventional": "^19.4.1",
70
70
  "@types/pako": "^2.0.3",
71
- "@types/react": "^18.3.3",
71
+ "@types/react": "^18.3.5",
72
72
  "@types/react-dom": "^18.3.0",
73
- "@umijs/lint": "^4.3.11",
74
- "antd": "^5.19.4",
75
- "dumi": "^2.4.7",
76
- "eslint": "^9.8.0",
77
- "father": "^4.4.6",
78
- "husky": "^9.1.4",
79
- "lint-staged": "^15.2.7",
73
+ "@umijs/lint": "^4.3.20",
74
+ "antd": "^5.20.6",
75
+ "dumi": "^2.4.10",
76
+ "eslint": "^9.10.0",
77
+ "father": "^4.5.0",
78
+ "husky": "^9.1.5",
79
+ "lint-staged": "^15.2.10",
80
80
  "prettier": "^3.3.3",
81
81
  "prettier-plugin-organize-imports": "^3.2.4",
82
- "prettier-plugin-packagejson": "^2.5.1",
82
+ "prettier-plugin-packagejson": "^2.5.2",
83
83
  "react": "^18.3.1",
84
84
  "react-dom": "^18.3.1",
85
- "stylelint": "^16.8.1"
85
+ "stylelint": "^16.9.0"
86
86
  },
87
87
  "publishConfig": {
88
88
  "access": "public"