@yysports/tools 0.1.9 → 0.1.11

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.
@@ -221,7 +221,7 @@ var Track = /*#__PURE__*/function () {
221
221
  });
222
222
  case 5:
223
223
  // 如果对接了权限中心,取权限中心的用户信息
224
- if (this.authCenterUserProfile.email) {
224
+ if (this.authCenterUserProfile.userName) {
225
225
  this.setUserProfile({
226
226
  userId: this.authCenterUserProfile.userName,
227
227
  userName: this.authCenterUserProfile.nickName
@@ -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
  };
@@ -175,7 +175,7 @@ var Track = class {
175
175
  menuNameMap,
176
176
  routes
177
177
  });
178
- if (this.authCenterUserProfile.email) {
178
+ if (this.authCenterUserProfile.userName) {
179
179
  this.setUserProfile({
180
180
  userId: this.authCenterUserProfile.userName,
181
181
  userName: this.authCenterUserProfile.nickName
@@ -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.11",
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.8.4",
68
+ "@commitlint/cli": "^19.6.1",
69
+ "@commitlint/config-conventional": "^19.6.0",
70
70
  "@types/pako": "^2.0.3",
71
- "@types/react": "^18.3.3",
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",
80
- "prettier": "^3.3.3",
71
+ "@types/react": "^18.3.18",
72
+ "@types/react-dom": "^18.3.5",
73
+ "@umijs/lint": "^4.4.4",
74
+ "antd": "^5.23.2",
75
+ "dumi": "^2.4.17",
76
+ "eslint": "^9.18.0",
77
+ "father": "^4.5.2",
78
+ "husky": "^9.1.7",
79
+ "lint-staged": "^15.4.1",
80
+ "prettier": "^3.4.2",
81
81
  "prettier-plugin-organize-imports": "^3.2.4",
82
- "prettier-plugin-packagejson": "^2.5.1",
82
+ "prettier-plugin-packagejson": "^2.5.8",
83
83
  "react": "^18.3.1",
84
84
  "react-dom": "^18.3.1",
85
- "stylelint": "^16.8.1"
85
+ "stylelint": "^16.13.2"
86
86
  },
87
87
  "publishConfig": {
88
88
  "access": "public"