From 9426372d0938066d0a0860579f87ec4e43a57047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=8B=A4=E6=B0=91?= Date: Fri, 30 Aug 2024 19:03:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E5=86=99=E7=AD=BE=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BuildProfile.ets | 18 +++++++++++++++--- Index.ets | 1 + README.md | 14 ++++++++++++-- src/main/ets/utils/AlgorithmHelper.ets | 18 ++++++++++++++++++ src/main/ets/utils/ToolsHelper.ets | 1 - 5 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 src/main/ets/utils/AlgorithmHelper.ets diff --git a/BuildProfile.ets b/BuildProfile.ets index f8ad882..dd6e96c 100644 --- a/BuildProfile.ets +++ b/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; } \ No newline at end of file diff --git a/Index.ets b/Index.ets index 5c6ab5c..4e2a3a1 100644 --- a/Index.ets +++ b/Index.ets @@ -2,6 +2,7 @@ * 常用工具 */ export { ToolsHelper } from './src/main/ets/utils/ToolsHelper' +export { AlgorithmHelper } from './src/main/ets/utils/AlgorithmHelper' /** * 存储相关 diff --git a/README.md b/README.md index fe2c4c2..8b8153c 100644 --- a/README.md +++ b/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 diff --git a/src/main/ets/utils/AlgorithmHelper.ets b/src/main/ets/utils/AlgorithmHelper.ets new file mode 100644 index 0000000..52579a9 --- /dev/null +++ b/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); + } +} \ No newline at end of file diff --git a/src/main/ets/utils/ToolsHelper.ets b/src/main/ets/utils/ToolsHelper.ets index de0463b..6541074 100644 --- a/src/main/ets/utils/ToolsHelper.ets +++ b/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';