Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
shishuangxi
2024-04-23 09:45:57 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7e6b4d1e6b750939763b6f172a3a39e798f9e3ef
7e6b4d1e
1 parent
4d6497b1
新增组件
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
226 additions
and
17 deletions
sight_harmony/commons/wdKit/Index.ets
sight_harmony/features/wdHwAbility/.gitignore
sight_harmony/features/wdHwAbility/Index.ets
sight_harmony/features/wdHwAbility/build-profile.json5
sight_harmony/features/wdHwAbility/hvigorfile.ts
sight_harmony/features/wdHwAbility/obfuscation-rules.txt
sight_harmony/features/wdHwAbility/oh-package.json5
sight_harmony/commons/wdKit/src/main/ets/utils/HWLocationUtils.ets → sight_harmony/features/wdHwAbility/src/main/ets/location/HWLocationUtils.ets
sight_harmony/features/wdHwAbility/src/main/ets/pages/Index.ets
sight_harmony/features/wdHwAbility/src/main/ets/utils/Calc.ets
sight_harmony/features/wdHwAbility/src/main/module.json5
sight_harmony/features/wdHwAbility/src/main/resources/base/element/color.json
sight_harmony/features/wdHwAbility/src/main/resources/base/element/string.json
sight_harmony/features/wdHwAbility/src/main/resources/base/profile/main_pages.json
sight_harmony/features/wdHwAbility/src/test/List.test.ets
sight_harmony/features/wdHwAbility/src/test/LocalUnit.test.ets
sight_harmony/products/phone/oh-package.json5
sight_harmony/products/phone/src/main/ets/pages/MainPage.ets
sight_harmony/commons/wdKit/Index.ets
View file @
7e6b4d1
...
...
@@ -43,5 +43,3 @@ export { ErrorToastUtils } from './src/main/ets/utils/ErrorToastUtils'
export { EmitterUtils } from './src/main/ets/utils/EmitterUtils'
export { EmitterEventId } from './src/main/ets/utils/EmitterEventId'
export { HWLocationUtils } from './src/main/ets/utils/HWLocationUtils'
\ No newline at end of file
...
...
sight_harmony/features/wdHwAbility/.gitignore
0 → 100644
View file @
7e6b4d1
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
\ No newline at end of file
...
...
sight_harmony/features/wdHwAbility/Index.ets
0 → 100644
View file @
7e6b4d1
export { add } from "./src/main/ets/utils/Calc"
export { HWLocationUtils } from './src/main/ets/location/HWLocationUtils'
\ No newline at end of file
...
...
sight_harmony/features/wdHwAbility/build-profile.json5
0 → 100644
View file @
7e6b4d1
{
"apiType"
:
"stageMode"
,
"buildOption"
:
{
},
"buildOptionSet"
:
[
{
"name"
:
"release"
,
"arkOptions"
:
{
"obfuscation"
:
{
"ruleOptions"
:
{
"enable"
:
true
,
"files"
:
[
"./obfuscation-rules.txt"
]
}
}
},
}
,
],
"targets"
:
[
{
"name"
:
"default"
}
]
}
\ No newline at end of file
...
...
sight_harmony/features/wdHwAbility/hvigorfile.ts
0 → 100644
View file @
7e6b4d1
import
{
hspTasks
}
from
'@ohos/hvigor-ohos-plugin'
;
export
default
{
system
:
hspTasks
,
/* Built-in plugin of Hvigor. It cannot be modified. */
plugins
:[]
/* Custom plugin to extend the functionality of Hvigor. */
}
...
...
sight_harmony/features/wdHwAbility/obfuscation-rules.txt
0 → 100644
View file @
7e6b4d1
# Define project specific obfuscation rules here.
# You can include the obfuscation configuration files in the current module's build-profile.json5.
#
# For more details, see
# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
# Obfuscation options:
# -disable-obfuscation: disable all obfuscations
# -enable-property-obfuscation: obfuscate the property names
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
# -compact: remove unnecessary blank spaces and all line feeds
# -remove-log: remove all console.* statements
# -print-namecache: print the name cache that contains the mapping from the old names to new names
# -apply-namecache: reuse the given cache file
# Keep options:
# -keep-property-name: specifies property names that you want to keep
# -keep-global-name: specifies names that you want to keep in the global scope
\ No newline at end of file
...
...
sight_harmony/features/wdHwAbility/oh-package.json5
0 → 100644
View file @
7e6b4d1
{
"name"
:
"wdhwability"
,
"version"
:
"1.0.0"
,
"description"
:
"Please describe the basic information."
,
"main"
:
"Index.ets"
,
"author"
:
""
,
"license"
:
"Apache-2.0"
,
"packageType"
:
"InterfaceHar"
,
"dependencies"
:
{
}
}
\ No newline at end of file
...
...
sight_harmony/
commons/wdKit/src/main/ets/utils
/HWLocationUtils.ets → sight_harmony/
features/wdHwAbility/src/main/ets/location
/HWLocationUtils.ets
View file @
7e6b4d1
import { Logger } from './Logger';
import { PermissionUtils } from './PermissionUtils';
import { Logger } from '../../../../../../commons/wdKit/src/main/ets/utils/Logger';
import { PermissionUtils } from '../../../../../../commons/wdKit/src/main/ets/utils/PermissionUtils';
import { abilityAccessCtrl, bundleManager, Permissions } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { geoLocationManager } from '@kit.LocationKit';
import { SPHelper } from './SPHelper';
import { SPHelper } from '../../../../../../commons/wdKit/src/main/ets/utils/SPHelper';
import { ResourcesUtils } from '../../../../../../commons/wdKit/src/main/ets/utils/ResourcesUtils';
/**
* 系统定位服务实现
...
...
@@ -101,23 +102,18 @@ export class HWLocationUtils {
"longitude": longitude,
"maxItems": 2
};
geoLocationManager.getAddressesFromLocation(requestInfo, (error, data) => {
geoLocationManager.getAddressesFromLocation(requestInfo,
async
(error, data) => {
if (error) {
Logger.debug('location :' + JSON.stringify(error))
}
if (data) {
Logger.debug('location :' + JSON.stringify(data))
if (data[0] && data[0].countryName) {
if (data[0].descriptionsSize && data[0].descriptions) {
let code = data[0].descriptions[1]
let cityCode = code.substring(0, 6)
if (data[0] && data[0].administrativeArea && data[0].subAdministrativeArea) {
let cityName = data[0].subAdministrativeArea;
if (cityName) {
let code = await HWLocationUtils.getCityCode(data[0].administrativeArea, data[0].subAdministrativeArea)
if (code) {
SPHelper.default.save(HWLocationUtils.LOCATION_CITY_NAME, cityName)
}
if (cityCode) {
SPHelper.default.save(HWLocationUtils.LOCATION_CITY_NAME, cityCode)
}
SPHelper.default.save(HWLocationUtils.LOCATION_CITY_CODE, code)
}
}
}
...
...
@@ -135,4 +131,55 @@ export class HWLocationUtils {
})
})
}
private static async getCityCode(administrativeArea: string, cityName: string) {
let bean = await ResourcesUtils.getResourcesJson<ResponseDTO<Array<LocalData>>>(getContext(), 'areaList_data.json');
if (bean) {
if (bean.code == 0 && bean.data) {
for (let i = 0; i < bean.data.length; i++) {
if (bean.data[i].label == administrativeArea) {
for (let j = 0; j < bean.data[i].children.length; j++) {
if (bean.data[i].children[j].label == cityName) {
Logger.debug("huaw" + bean.data[i].children[j].code)
return bean.data[i].children[j].code
}
}
}
}
}
}
return ''
}
}
interface ResponseDTO<T> {
success: boolean;
// 服务请求响应值/微服务响应状态码”
code: number;
// 服务请求响应说明
message: string;
// 响应结果
data?: T;
totalCount?: number;
// 请求响应时间戳(unix格式)
timestamp?: number;
}
interface LocalData {
"code": string,
"id": string,
"label": string,
"children": Array<ChildrenData>
}
interface ChildrenData {
"code": string,
"id": string,
"label": string,
}
\ No newline at end of file
...
...
sight_harmony/features/wdHwAbility/src/main/ets/pages/Index.ets
0 → 100644
View file @
7e6b4d1
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdHwAbility/src/main/ets/utils/Calc.ets
0 → 100644
View file @
7e6b4d1
export function add(a:number, b:number) {
return a + b;
}
\ No newline at end of file
...
...
sight_harmony/features/wdHwAbility/src/main/module.json5
0 → 100644
View file @
7e6b4d1
{
"module"
:
{
"name"
:
"wdHwAbility"
,
"type"
:
"shared"
,
"description"
:
"$string:shared_desc"
,
"deviceTypes"
:
[
"phone"
,
"tablet"
,
"2in1"
],
"deliveryWithInstall"
:
true
,
"pages"
:
"$profile:main_pages"
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdHwAbility/src/main/resources/base/element/color.json
0 → 100644
View file @
7e6b4d1
{
"color"
:
[
{
"name"
:
"white"
,
"value"
:
"#FFFFFF"
}
]
}
\ No newline at end of file
...
...
sight_harmony/features/wdHwAbility/src/main/resources/base/element/string.json
0 → 100644
View file @
7e6b4d1
{
"string"
:
[
{
"name"
:
"shared_desc"
,
"value"
:
"description"
}
]
}
\ No newline at end of file
...
...
sight_harmony/features/wdHwAbility/src/main/resources/base/profile/main_pages.json
0 → 100644
View file @
7e6b4d1
{
"src"
:
[
"pages/Index"
]
}
...
...
sight_harmony/features/wdHwAbility/src/test/List.test.ets
0 → 100644
View file @
7e6b4d1
import localUnitTest from './LocalUnit.test';
export default function testsuite() {
localUnitTest();
}
\ No newline at end of file
...
...
sight_harmony/features/wdHwAbility/src/test/LocalUnit.test.ets
0 → 100644
View file @
7e6b4d1
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function localUnitTest() {
describe('localUnitTest',() => {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(() => {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
});
beforeEach(() => {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
});
afterEach(() => {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
});
afterAll(() => {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
});
it('assertContain', 0, () => {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
let a = 'abc';
let b = 'b';
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
expect(a).assertContain(b);
expect(a).assertEqual(a);
});
});
}
\ No newline at end of file
...
...
sight_harmony/products/phone/oh-package.json5
View file @
7e6b4d1
...
...
@@ -14,6 +14,7 @@
"wdBean"
:
"file:../../features/wdBean"
,
"wdDetailPlayShortVideo"
:
"file:../../features/wdDetailPlayShortVideo"
,
"wdRouter"
:
"file:../../commons/wdRouter"
,
"wdNetwork"
:
"file:../../commons/wdNetwork"
"wdNetwork"
:
"file:../../commons/wdNetwork"
,
"wdHwAbility"
:
"file:../../features/wdHwAbility"
}
}
...
...
sight_harmony/products/phone/src/main/ets/pages/MainPage.ets
View file @
7e6b4d1
import { BottomNavigationComponent, LogoutViewModel} from 'wdComponent';
import { BreakpointConstants } from 'wdConstant';
import { BreakpointSystem, EmitterEventId, EmitterUtils,
HWLocationUtils,
Logger } from 'wdKit';
import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger } from 'wdKit';
import router from '@ohos.router';
import { promptAction } from '@kit.ArkUI';
import { HWLocationUtils } from 'wdHwAbility/Index';
const TAG = 'MainPage';
...
...
Please
register
or
login
to post a comment