shishuangxi

新增组件

... ... @@ -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
... ...
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
\ No newline at end of file
... ...
export { add } from "./src/main/ets/utils/Calc"
export { HWLocationUtils } from './src/main/ets/location/HWLocationUtils'
\ No newline at end of file
... ...
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": true,
"files": [
"./obfuscation-rules.txt"
]
}
}
},
},
],
"targets": [
{
"name": "default"
}
]
}
\ No newline at end of file
... ...
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. */
}
... ...
# 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
... ...
{
"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
... ...
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
... ...
@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
... ...
export function add(a:number, b:number) {
return a + b;
}
\ No newline at end of file
... ...
{
"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
... ...
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
... ...
{
"string": [
{
"name": "shared_desc",
"value": "description"
}
]
}
\ No newline at end of file
... ...
import localUnitTest from './LocalUnit.test';
export default function testsuite() {
localUnitTest();
}
\ No newline at end of file
... ...
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
... ...
... ... @@ -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"
}
}
... ...
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';
... ...