徐勤民 7 ماه پیش
والد
کامیت
9426372d09
5فایلهای تغییر یافته به همراه46 افزوده شده و 6 حذف شده
  1. 15 3
      BuildProfile.ets
  2. 1 0
      Index.ets
  3. 12 2
      README.md
  4. 18 0
      src/main/ets/utils/AlgorithmHelper.ets
  5. 0 1
      src/main/ets/utils/ToolsHelper.ets

+ 15 - 3
BuildProfile.ets

@@ -1,5 +1,17 @@
+/**
+ * Use these variables when you tailor your ArkTS code. They must be of the const type.
+ */
+export const HAR_VERSION = '1.0.1';
+export const BUILD_MODE_NAME = 'debug';
+export const DEBUG = true;
+export const TARGET_NAME = 'default';
+
+/**
+ * BuildProfile Class is used only for compatibility purposes.
+ */
 export default class BuildProfile { 
-	static readonly HAR_VERSION = '1.0.1';
-	static readonly BUILD_MODE_NAME = 'debug';
-	static readonly DEBUG = true;
+	static readonly HAR_VERSION = HAR_VERSION;
+	static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
+	static readonly DEBUG = DEBUG;
+	static readonly TARGET_NAME = TARGET_NAME;
 }

+ 1 - 0
Index.ets

@@ -2,6 +2,7 @@
  * 常用工具
  */
 export { ToolsHelper } from './src/main/ets/utils/ToolsHelper'
+export { AlgorithmHelper } from './src/main/ets/utils/AlgorithmHelper'
 
 /**
  * 存储相关

+ 12 - 2
README.md

@@ -52,10 +52,20 @@ ToolsHelper.showMessage('Hello Word!')
 
 ```typescript
 import { ValidatorHelper } from '@szyx/sdk_base';
-  ValidatorHelper.isPhone('13800000000')
+ValidatorHelper.isPhone('13800000000')
 ```
 
-### 1.5.[XWebHelper](./src/main/ets/utils/XWebHelper.ets)
+### 1.5.[AlgorithmHelper](./src/main/ets/utils/AlgorithmHelper.ets)
+> 计算相关
+
+#### 1.5.1.验证手机号
+
+```typescript
+import { AlgorithmHelper } from '@szyx/sdk_base';
+AlgorithmHelper.calculateDistance(x1, y1, x2, y2)
+```
+
+### 1.6.[XWebHelper](./src/main/ets/utils/XWebHelper.ets)
 > 打开webview页面
 
 ```typescript

+ 18 - 0
src/main/ets/utils/AlgorithmHelper.ets

@@ -0,0 +1,18 @@
+/**
+ * 计算相关工具类
+ */
+export class AlgorithmHelper {
+  /**
+   * 计算两点间距离
+   * @param x1
+   * @param y1
+   * @param x2
+   * @param y2
+   * @returns
+   */
+  static calculateDistance(x1: number, y1: number, x2: number, y2: number): number {
+    const dx = x2 - x1;
+    const dy = y2 - y1;
+    return Math.sqrt(dx * dx + dy * dy);
+  }
+}

+ 0 - 1
src/main/ets/utils/ToolsHelper.ets

@@ -1,5 +1,4 @@
 import promptAction from '@ohos.promptAction';
-import { Resource } from 'GlobalResource';
 import { BusinessError } from '@kit.BasicServicesKit';
 import { HashMap } from '@kit.ArkTS';