初版,确立了鸿蒙版程序的基本框架。
这个提交包含在:
12
.gitignore
vendored
普通文件
12
.gitignore
vendored
普通文件
@ -0,0 +1,12 @@
|
|||||||
|
/node_modules
|
||||||
|
/oh_modules
|
||||||
|
/local.properties
|
||||||
|
/.idea
|
||||||
|
**/build
|
||||||
|
/.hvigor
|
||||||
|
.cxx
|
||||||
|
/.clangd
|
||||||
|
/.clang-format
|
||||||
|
/.clang-tidy
|
||||||
|
**/.test
|
||||||
|
/.appanalyzer
|
||||||
10
AppScope/app.json5
普通文件
10
AppScope/app.json5
普通文件
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"app": {
|
||||||
|
"bundleName": "io.github.lanshuye123.zeroone",
|
||||||
|
"vendor": "example",
|
||||||
|
"versionCode": 1000000,
|
||||||
|
"versionName": "1.0.0",
|
||||||
|
"icon": "$media:layered_image",
|
||||||
|
"label": "$string:app_name_cn"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"string": [
|
||||||
|
{
|
||||||
|
"name": "app_name",
|
||||||
|
"value": "ZeroOne"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "app_name_cn",
|
||||||
|
"value": "凌依"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
二进制文件未显示。
|
之后 宽度: | 高度: | 大小: 46 KiB |
二进制文件未显示。
|
之后 宽度: | 高度: | 大小: 865 KiB |
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"layered-image":
|
||||||
|
{
|
||||||
|
"background" : "$media:background",
|
||||||
|
"foreground" : "$media:foreground"
|
||||||
|
}
|
||||||
|
}
|
||||||
56
build-profile.json5
普通文件
56
build-profile.json5
普通文件
@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"app": {
|
||||||
|
"signingConfigs": [
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"type": "HarmonyOS",
|
||||||
|
"material": {
|
||||||
|
"certpath": "C:\\Users\\lansh\\.ohos\\config\\default_ZeroOne_zwrHiIUUBrKBsz9KOzw2rWlQY8yS3a15TciGqrbfftM=.cer",
|
||||||
|
"keyAlias": "debugKey",
|
||||||
|
"keyPassword": "0000001BFDBC96CD74E1ADEC1826678C7D98AAE8B9F8435B053D6A83681A017B1143851850C2D98247E27E",
|
||||||
|
"profile": "C:\\Users\\lansh\\.ohos\\config\\default_ZeroOne_zwrHiIUUBrKBsz9KOzw2rWlQY8yS3a15TciGqrbfftM=.p7b",
|
||||||
|
"signAlg": "SHA256withECDSA",
|
||||||
|
"storeFile": "C:\\Users\\lansh\\.ohos\\config\\default_ZeroOne_zwrHiIUUBrKBsz9KOzw2rWlQY8yS3a15TciGqrbfftM=.p12",
|
||||||
|
"storePassword": "0000001B05E4D8E09E85FF5E2282FDF221F6BCE3C72B8A5178D43613D8ADF81D2CC29C0D9DE08987D1F06E"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"products": [
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"signingConfig": "default",
|
||||||
|
"targetSdkVersion": "6.0.0(20)",
|
||||||
|
"compatibleSdkVersion": "5.0.1(13)",
|
||||||
|
"runtimeOS": "HarmonyOS",
|
||||||
|
"buildOption": {
|
||||||
|
"strictMode": {
|
||||||
|
"caseSensitiveCheck": true,
|
||||||
|
"useNormalizedOHMUrl": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"buildModeSet": [
|
||||||
|
{
|
||||||
|
"name": "debug",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"modules": [
|
||||||
|
{
|
||||||
|
"name": "entry",
|
||||||
|
"srcPath": "./entry",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"applyToProducts": [
|
||||||
|
"default"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
32
code-linter.json5
普通文件
32
code-linter.json5
普通文件
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"**/*.ets"
|
||||||
|
],
|
||||||
|
"ignore": [
|
||||||
|
"**/src/ohosTest/**/*",
|
||||||
|
"**/src/test/**/*",
|
||||||
|
"**/src/mock/**/*",
|
||||||
|
"**/node_modules/**/*",
|
||||||
|
"**/oh_modules/**/*",
|
||||||
|
"**/build/**/*",
|
||||||
|
"**/.preview/**/*"
|
||||||
|
],
|
||||||
|
"ruleSet": [
|
||||||
|
"plugin:@performance/recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"@security/no-unsafe-aes": "error",
|
||||||
|
"@security/no-unsafe-hash": "error",
|
||||||
|
"@security/no-unsafe-mac": "warn",
|
||||||
|
"@security/no-unsafe-dh": "error",
|
||||||
|
"@security/no-unsafe-dsa": "error",
|
||||||
|
"@security/no-unsafe-ecdsa": "error",
|
||||||
|
"@security/no-unsafe-rsa-encrypt": "error",
|
||||||
|
"@security/no-unsafe-rsa-sign": "error",
|
||||||
|
"@security/no-unsafe-rsa-key": "error",
|
||||||
|
"@security/no-unsafe-dsa-key": "error",
|
||||||
|
"@security/no-unsafe-dh-key": "error",
|
||||||
|
"@security/no-unsafe-3des": "error"
|
||||||
|
}
|
||||||
|
}
|
||||||
6
entry/.gitignore
vendored
普通文件
6
entry/.gitignore
vendored
普通文件
@ -0,0 +1,6 @@
|
|||||||
|
/node_modules
|
||||||
|
/oh_modules
|
||||||
|
/.preview
|
||||||
|
/build
|
||||||
|
/.cxx
|
||||||
|
/.test
|
||||||
44
entry/build-profile.json5
普通文件
44
entry/build-profile.json5
普通文件
@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"apiType": "stageMode",
|
||||||
|
"buildOption": {
|
||||||
|
"resOptions": {
|
||||||
|
"copyCodeResource": {
|
||||||
|
"enable": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"externalNativeOptions": {
|
||||||
|
"path": "./src/main/cpp/CMakeLists.txt",
|
||||||
|
"arguments": "",
|
||||||
|
"cppFlags": "",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"buildOptionSet": [
|
||||||
|
{
|
||||||
|
"name": "release",
|
||||||
|
"arkOptions": {
|
||||||
|
"obfuscation": {
|
||||||
|
"ruleOptions": {
|
||||||
|
"enable": false,
|
||||||
|
"files": [
|
||||||
|
"./obfuscation-rules.txt"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nativeLib": {
|
||||||
|
"debugSymbol": {
|
||||||
|
"strip": true,
|
||||||
|
"exclude": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"name": "default"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ohosTest",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
6
entry/hvigorfile.ts
普通文件
6
entry/hvigorfile.ts
普通文件
@ -0,0 +1,6 @@
|
|||||||
|
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
||||||
|
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
|
||||||
|
}
|
||||||
23
entry/obfuscation-rules.txt
普通文件
23
entry/obfuscation-rules.txt
普通文件
@ -0,0 +1,23 @@
|
|||||||
|
# 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://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
-enable-property-obfuscation
|
||||||
|
-enable-toplevel-obfuscation
|
||||||
|
-enable-filename-obfuscation
|
||||||
|
-enable-export-obfuscation
|
||||||
19
entry/oh-package-lock.json5
普通文件
19
entry/oh-package-lock.json5
普通文件
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"meta": {
|
||||||
|
"stableOrder": true,
|
||||||
|
"enableUnifiedLockfile": false
|
||||||
|
},
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
||||||
|
"specifiers": {
|
||||||
|
"libentry.so@src/main/cpp/types/libentry": "libentry.so@src/main/cpp/types/libentry"
|
||||||
|
},
|
||||||
|
"packages": {
|
||||||
|
"libentry.so@src/main/cpp/types/libentry": {
|
||||||
|
"name": "libentry.so",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "",
|
||||||
|
"registryType": "local"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
entry/oh-package.json5
普通文件
11
entry/oh-package.json5
普通文件
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "entry",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Please describe the basic information.",
|
||||||
|
"main": "",
|
||||||
|
"author": "",
|
||||||
|
"license": "",
|
||||||
|
"dependencies": {
|
||||||
|
"libentry.so": "file:./src/main/cpp/types/libentry"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
# the minimum version of CMake.
|
||||||
|
cmake_minimum_required(VERSION 3.5.0)
|
||||||
|
project(ZeroOne)
|
||||||
|
|
||||||
|
set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
if(DEFINED PACKAGE_FIND_FILE)
|
||||||
|
include(${PACKAGE_FIND_FILE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include_directories(${NATIVERENDER_ROOT_PATH}
|
||||||
|
${NATIVERENDER_ROOT_PATH}/include)
|
||||||
|
|
||||||
|
add_library(entry SHARED napi_init.cpp)
|
||||||
|
target_link_libraries(entry PUBLIC libace_napi.z.so)
|
||||||
53
entry/src/main/cpp/napi_init.cpp
普通文件
53
entry/src/main/cpp/napi_init.cpp
普通文件
@ -0,0 +1,53 @@
|
|||||||
|
#include "napi/native_api.h"
|
||||||
|
#include "dlfcn.h"
|
||||||
|
static napi_value Add(napi_env env, napi_callback_info info)
|
||||||
|
{
|
||||||
|
size_t argc = 2;
|
||||||
|
napi_value args[2] = {nullptr};
|
||||||
|
|
||||||
|
napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
|
||||||
|
|
||||||
|
napi_valuetype valuetype0;
|
||||||
|
napi_typeof(env, args[0], &valuetype0);
|
||||||
|
|
||||||
|
napi_valuetype valuetype1;
|
||||||
|
napi_typeof(env, args[1], &valuetype1);
|
||||||
|
|
||||||
|
double value0;
|
||||||
|
napi_get_value_double(env, args[0], &value0);
|
||||||
|
|
||||||
|
double value1;
|
||||||
|
napi_get_value_double(env, args[1], &value1);
|
||||||
|
|
||||||
|
napi_value sum;
|
||||||
|
napi_create_double(env, value0 + value1, &sum);
|
||||||
|
|
||||||
|
return sum;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
EXTERN_C_START
|
||||||
|
static napi_value Init(napi_env env, napi_value exports)
|
||||||
|
{
|
||||||
|
napi_property_descriptor desc[] = {
|
||||||
|
{ "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr }
|
||||||
|
};
|
||||||
|
napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
|
||||||
|
return exports;
|
||||||
|
}
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
static napi_module demoModule = {
|
||||||
|
.nm_version = 1,
|
||||||
|
.nm_flags = 0,
|
||||||
|
.nm_filename = nullptr,
|
||||||
|
.nm_register_func = Init,
|
||||||
|
.nm_modname = "entry",
|
||||||
|
.nm_priv = ((void*)0),
|
||||||
|
.reserved = { 0 },
|
||||||
|
};
|
||||||
|
|
||||||
|
extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
|
||||||
|
{
|
||||||
|
napi_module_register(&demoModule);
|
||||||
|
}
|
||||||
1
entry/src/main/cpp/types/libentry/index.d.ts
vendored
普通文件
1
entry/src/main/cpp/types/libentry/index.d.ts
vendored
普通文件
@ -0,0 +1 @@
|
|||||||
|
export const add: (a: number, b: number) => number;
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "libentry.so",
|
||||||
|
"types": "./index.d.ts",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Please describe the basic information."
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
import { calendarMgr } from './entryability/EntryAbility';
|
||||||
|
|
||||||
|
import hilog from '@ohos.hilog';
|
||||||
|
import { calendarManager } from '@kit.CalendarKit';
|
||||||
|
|
||||||
|
let ev:calendarManager.Event = {
|
||||||
|
type: calendarManager.EventType.NORMAL,
|
||||||
|
title: "测试",
|
||||||
|
startTime: Date.now(),
|
||||||
|
endTime: Date.now() + 1000*60
|
||||||
|
}
|
||||||
|
|
||||||
|
let ZOCalendarAccount: calendarManager.CalendarAccount = {
|
||||||
|
name: '落云日程',
|
||||||
|
type: calendarManager.CalendarType.LOCAL,
|
||||||
|
displayName: "凌依助手-落云日程表"
|
||||||
|
}
|
||||||
|
calendarMgr?.createCalendar(ZOCalendarAccount).catch(() => {
|
||||||
|
// TODO: Implement error handling.
|
||||||
|
}).then(()=>{
|
||||||
|
calendarMgr?.getCalendar(ZOCalendarAccount).then((ca)=>{
|
||||||
|
ca.setConfig({
|
||||||
|
color: '#5DA5E9'
|
||||||
|
})
|
||||||
|
ca.addEvent(ev)
|
||||||
|
}).catch(() => {
|
||||||
|
|
||||||
|
})
|
||||||
|
})
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
export interface UserInfo{
|
||||||
|
uid:Number,
|
||||||
|
username: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultUserInfo:UserInfo = {
|
||||||
|
uid:927980270,
|
||||||
|
username:"岚椿桦"
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getUserInfo = (()=>{
|
||||||
|
return defaultUserInfo;
|
||||||
|
})
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
@Component
|
||||||
|
struct CalendarItem {
|
||||||
|
private name:string = "Test"
|
||||||
|
build() {
|
||||||
|
Row(){
|
||||||
|
Text(this.name)
|
||||||
|
}.backgroundColor('#8863FF').width('100%').border({
|
||||||
|
width:1
|
||||||
|
}).borderRadius(5).borderColor('##63A7FF').margin(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entry
|
||||||
|
@Component
|
||||||
|
struct CalendarCardCard {
|
||||||
|
readonly displayPriorityOne = 1;
|
||||||
|
readonly displayPriorityTwo = 2;
|
||||||
|
readonly flexGrowValue = 1;
|
||||||
|
readonly fullPercent = '100%';
|
||||||
|
readonly imageHeight = '58%';
|
||||||
|
readonly actionType = 'router';
|
||||||
|
readonly abilityName = 'ShareAbility';
|
||||||
|
readonly message = 'add detail';
|
||||||
|
readonly layoutWeightValue = 1;
|
||||||
|
readonly maxLinesValue = 1;
|
||||||
|
|
||||||
|
build() {
|
||||||
|
Stack({ alignContent: Alignment.TopStart }) {
|
||||||
|
Stack({ alignContent: Alignment.BottomStart }) {}
|
||||||
|
Flex({ direction: FlexDirection.Column }) {
|
||||||
|
Flex({ direction: FlexDirection.Row }) {
|
||||||
|
Column(){
|
||||||
|
CalendarItem({"name":"1"})
|
||||||
|
CalendarItem({"name":"2"})
|
||||||
|
CalendarItem({"name":"3"})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.backgroundColor($r('sys.color.comp_background_primary'))
|
||||||
|
.displayPriority(this.displayPriorityTwo)
|
||||||
|
.flexGrow(this.flexGrowValue)
|
||||||
|
.height($r('app.float.info_column_height'))
|
||||||
|
.padding($r('app.float.info_column_padding'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.onClick(() => {
|
||||||
|
postCardAction(this, {
|
||||||
|
action: this.actionType,
|
||||||
|
abilityName: this.abilityName,
|
||||||
|
params: {
|
||||||
|
message: this.message
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
import { abilityAccessCtrl, AbilityConstant, ConfigurationConstant,
|
||||||
|
PermissionRequestResult,
|
||||||
|
Permissions,
|
||||||
|
UIAbility, Want } from '@kit.AbilityKit';
|
||||||
|
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||||
|
import common from '@ohos.app.ability.common';
|
||||||
|
import calendarManager from '@ohos.calendarManager';
|
||||||
|
import { BusinessError } from '@kit.BasicServicesKit';
|
||||||
|
import { window } from '@kit.ArkUI';
|
||||||
|
|
||||||
|
export let calendarMgr: calendarManager.CalendarManager | null = null;
|
||||||
|
export let mContext: common.UIAbilityContext | null = null;
|
||||||
|
|
||||||
|
const DOMAIN = 0x0000;
|
||||||
|
|
||||||
|
export default class EntryAbility extends UIAbility {
|
||||||
|
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
||||||
|
try {
|
||||||
|
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
|
||||||
|
} catch (err) {
|
||||||
|
hilog.error(DOMAIN, 'testTag', 'Failed to set colorMode. Cause: %{public}s', JSON.stringify(err));
|
||||||
|
}
|
||||||
|
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
|
||||||
|
}
|
||||||
|
|
||||||
|
onDestroy(): void {
|
||||||
|
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
|
||||||
|
}
|
||||||
|
|
||||||
|
onWindowStageCreate(windowStage: window.WindowStage): void {
|
||||||
|
// Main window is created, set main page for this ability
|
||||||
|
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
||||||
|
|
||||||
|
windowStage.loadContent('pages/Index', (err) => {
|
||||||
|
if (err.code) {
|
||||||
|
hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
|
||||||
|
});
|
||||||
|
mContext = this.context;
|
||||||
|
const permissions: Permissions[] = ['ohos.permission.READ_CALENDAR', 'ohos.permission.WRITE_CALENDAR'];
|
||||||
|
let atManager = abilityAccessCtrl.createAtManager();
|
||||||
|
atManager.requestPermissionsFromUser(mContext, permissions).then((result: PermissionRequestResult) => {
|
||||||
|
console.info(`get Permission success, result: ${JSON.stringify(result)}`);
|
||||||
|
calendarMgr = calendarManager.getCalendarManager(mContext);
|
||||||
|
}).catch((error: BusinessError) => {
|
||||||
|
console.error(`get Permission error, error. Code: ${error.code}, message: ${error.message}`);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onWindowStageDestroy(): void {
|
||||||
|
// Main window is destroyed, release UI related resources
|
||||||
|
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
|
||||||
|
}
|
||||||
|
|
||||||
|
onForeground(): void {
|
||||||
|
// Ability has brought to foreground
|
||||||
|
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');
|
||||||
|
}
|
||||||
|
|
||||||
|
onBackground(): void {
|
||||||
|
// Ability has back to background
|
||||||
|
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||||
|
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
|
||||||
|
|
||||||
|
const DOMAIN = 0x0000;
|
||||||
|
|
||||||
|
export default class EntryBackupAbility extends BackupExtensionAbility {
|
||||||
|
async onBackup() {
|
||||||
|
hilog.info(DOMAIN, 'testTag', 'onBackup ok');
|
||||||
|
await Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
async onRestore(bundleVersion: BundleVersion) {
|
||||||
|
hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
|
||||||
|
await Promise.resolve();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
import { formBindingData, FormExtensionAbility, formInfo } from '@kit.FormKit';
|
||||||
|
import { Want } from '@kit.AbilityKit';
|
||||||
|
|
||||||
|
export default class EntryCalendarCardAbility extends FormExtensionAbility {
|
||||||
|
onAddForm(want: Want) {
|
||||||
|
// Called to return a FormBindingData object.
|
||||||
|
const formData = '';
|
||||||
|
return formBindingData.createFormBindingData(formData);
|
||||||
|
}
|
||||||
|
|
||||||
|
onCastToNormalForm(formId: string) {
|
||||||
|
// Called when the form provider is notified that a temporary form is successfully
|
||||||
|
// converted to a normal form.
|
||||||
|
}
|
||||||
|
|
||||||
|
onUpdateForm(formId: string) {
|
||||||
|
// Called to notify the form provider to update a specified form.
|
||||||
|
}
|
||||||
|
|
||||||
|
onFormEvent(formId: string, message: string) {
|
||||||
|
// Called when a specified message event defined by the form provider is triggered.
|
||||||
|
}
|
||||||
|
|
||||||
|
onRemoveForm(formId: string) {
|
||||||
|
// Called to notify the form provider that a specified form has been destroyed.
|
||||||
|
}
|
||||||
|
|
||||||
|
onAcquireFormState(want: Want) {
|
||||||
|
// Called to return a {@link FormState} object.
|
||||||
|
return formInfo.FormState.READY;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,88 @@
|
|||||||
|
import {getUserInfo} from './../UserInfoHelper'
|
||||||
|
|
||||||
|
import { textToSpeech } from '@kit.CoreSpeechKit';
|
||||||
|
import { BusinessError } from '@kit.BasicServicesKit';
|
||||||
|
|
||||||
|
let ttsEngine: textToSpeech.TextToSpeechEngine;
|
||||||
|
|
||||||
|
// 设置创建引擎参数
|
||||||
|
let extraParam: Record<string, Object> = {"style": 'interaction-broadcast', "locate": 'CN', "name": 'EngineName'};
|
||||||
|
let initParamsInfo: textToSpeech.CreateEngineParams = {
|
||||||
|
language: 'zh-CN',
|
||||||
|
person: 0,
|
||||||
|
online: 1,
|
||||||
|
extraParams: extraParam
|
||||||
|
};
|
||||||
|
|
||||||
|
// 调用createEngine方法
|
||||||
|
textToSpeech.createEngine(initParamsInfo, (err: BusinessError, textToSpeechEngine: textToSpeech.TextToSpeechEngine) => {
|
||||||
|
if (!err) {
|
||||||
|
console.info('Succeeded in creating engine');
|
||||||
|
// 接收创建引擎的实例
|
||||||
|
ttsEngine = textToSpeechEngine;
|
||||||
|
// 设置回调
|
||||||
|
ttsEngine.setListener(speakListener);
|
||||||
|
// 调用播报方法
|
||||||
|
// 开发者可以通过修改speakParams主动设置播报策略
|
||||||
|
} else {
|
||||||
|
console.error(`Failed to create engine. Code: ${err.code}, message: ${err.message}.`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 设置speak的回调信息
|
||||||
|
let speakListener: textToSpeech.SpeakListener = {
|
||||||
|
// 开始播报回调
|
||||||
|
onStart(requestId: string, response: textToSpeech.StartResponse) {
|
||||||
|
console.info(`onStart, requestId: ${requestId} response: ${JSON.stringify(response)}`);
|
||||||
|
},
|
||||||
|
// 合成完成及播报完成回调
|
||||||
|
onComplete(requestId: string, response: textToSpeech.CompleteResponse) {
|
||||||
|
console.info(`onComplete, requestId: ${requestId} response: ${JSON.stringify(response)}`);
|
||||||
|
},
|
||||||
|
// 停止播报回调
|
||||||
|
onStop(requestId: string, response: textToSpeech.StopResponse) {
|
||||||
|
console.info(`onStop, requestId: ${requestId} response: ${JSON.stringify(response)}`);
|
||||||
|
},
|
||||||
|
// 返回音频流
|
||||||
|
onData(requestId: string, audio: ArrayBuffer, response: textToSpeech.SynthesisResponse) {
|
||||||
|
console.info(`onData, requestId: ${requestId} sequence: ${JSON.stringify(response)} audio: ${JSON.stringify(audio)}`);
|
||||||
|
},
|
||||||
|
// 错误回调
|
||||||
|
onError(requestId: string, errorCode: number, errorMessage: string) {
|
||||||
|
console.error(`onError, requestId: ${requestId} errorCode: ${errorCode} errorMessage: ${errorMessage}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let originalText: string = 'Hello HarmonyOS';
|
||||||
|
// 设置播报相关参数
|
||||||
|
let speakParams: textToSpeech.SpeakParams = {
|
||||||
|
requestId: Date(), // requestId在同一实例内仅能用一次,请勿重复设置
|
||||||
|
extraParams: extraParam
|
||||||
|
};
|
||||||
|
|
||||||
|
let userinfo = getUserInfo()
|
||||||
|
let SpeechPageA = new NavPathInfo('SpeechPage',null)
|
||||||
|
let NVS = new NavPathStack()
|
||||||
|
NVS.pushPath(SpeechPageA)
|
||||||
|
@Entry
|
||||||
|
@Component
|
||||||
|
struct Index {
|
||||||
|
@State message: string = 'Hello World';
|
||||||
|
@State errmsg: string = "你说得对,但是原神是一款由米哈游独立自主研发的开放世界冒险游戏。故事发生在提瓦特大陆,在这里,你将扮演旅行者的形象。"
|
||||||
|
build() {
|
||||||
|
Column(){
|
||||||
|
Row(){
|
||||||
|
Image(`https://q.qlogo.cn/headimg_dl?dst_uin=${userinfo.uid}&spec=640&img_type=jpg`).width(30).borderRadius(10)
|
||||||
|
Text(userinfo.username).fontSize(24)
|
||||||
|
}.width('100%').padding(15)
|
||||||
|
Divider()
|
||||||
|
Text(this.errmsg)
|
||||||
|
Button('114514').onClick((ev)=>{
|
||||||
|
try {
|
||||||
|
ttsEngine.speak(this.errmsg, speakParams);
|
||||||
|
} catch (error) {
|
||||||
|
this.errmsg = error
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
@Entry
|
||||||
|
@Component
|
||||||
|
struct MES{
|
||||||
|
build() {
|
||||||
|
Text("MEShare")
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
|
||||||
|
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||||
|
import { window } from '@kit.ArkUI';
|
||||||
|
import { systemShare } from '@kit.ShareKit';
|
||||||
|
import { BusinessError } from '@kit.BasicServicesKit';
|
||||||
|
|
||||||
|
const DOMAIN = 0x0000;
|
||||||
|
|
||||||
|
export default class ShareAbility extends UIAbility {
|
||||||
|
handleParam(want: Want) {
|
||||||
|
systemShare.getSharedData(want)
|
||||||
|
.then(( data) => {
|
||||||
|
const records = data.getRecords();
|
||||||
|
records.forEach((record: systemShare.SharedRecord) => {
|
||||||
|
// 处理单条分享数据(如文件FD)
|
||||||
|
console.log('Want FD')
|
||||||
|
console.log(record.title)
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((err: BusinessError) => {
|
||||||
|
console.error('接收分享失败:', err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
||||||
|
this.handleParam(want)
|
||||||
|
}
|
||||||
|
|
||||||
|
onDestroy(): void {
|
||||||
|
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
|
||||||
|
}
|
||||||
|
|
||||||
|
onWindowStageCreate(windowStage: window.WindowStage): void {
|
||||||
|
// Main window is created, set main page for this ability
|
||||||
|
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
||||||
|
|
||||||
|
windowStage.loadContent('pages/MEShare/MES', (err) => {
|
||||||
|
if (err.code) {
|
||||||
|
hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onWindowStageDestroy(): void {
|
||||||
|
// Main window is destroyed, release UI related resources
|
||||||
|
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
|
||||||
|
}
|
||||||
|
|
||||||
|
onForeground(): void {
|
||||||
|
// Ability has brought to foreground
|
||||||
|
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');
|
||||||
|
}
|
||||||
|
|
||||||
|
onBackground(): void {
|
||||||
|
// Ability has back to background
|
||||||
|
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');
|
||||||
|
}
|
||||||
|
}
|
||||||
109
entry/src/main/module.json5
普通文件
109
entry/src/main/module.json5
普通文件
@ -0,0 +1,109 @@
|
|||||||
|
{
|
||||||
|
"module": {
|
||||||
|
"name": "entry",
|
||||||
|
"type": "entry",
|
||||||
|
"description": "$string:module_desc",
|
||||||
|
"mainElement": "EntryAbility",
|
||||||
|
"deviceTypes": [
|
||||||
|
"phone"
|
||||||
|
],
|
||||||
|
"deliveryWithInstall": true,
|
||||||
|
"installationFree": false,
|
||||||
|
"pages": "$profile:main_pages",
|
||||||
|
"requestPermissions": [
|
||||||
|
{
|
||||||
|
"name": "ohos.permission.READ_CALENDAR",
|
||||||
|
"reason": "$string:read_calendar_permission",
|
||||||
|
"usedScene": {
|
||||||
|
"when": "always"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ohos.permission.WRITE_CALENDAR",
|
||||||
|
"reason": "$string:read_calendar_permission",
|
||||||
|
"usedScene": {
|
||||||
|
"when": "always"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ohos.permission.INTERNET",
|
||||||
|
"reason": "$string:network_connecting"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ohos.permission.kernel.ALLOW_EXECUTABLE_FORT_MEMORY",
|
||||||
|
"reason": "$string:JIT"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"abilities": [
|
||||||
|
{
|
||||||
|
"name": "EntryAbility",
|
||||||
|
"srcEntry": "./ets/entryability/EntryAbility.ets",
|
||||||
|
"description": "$string:EntryAbility_desc",
|
||||||
|
"icon": "$media:layered_image",
|
||||||
|
"label": "$string:EA_label_zhcn",
|
||||||
|
"startWindowIcon": "$media:foreground",
|
||||||
|
"startWindowBackground": "$color:start_window_background",
|
||||||
|
"exported": true,
|
||||||
|
"skills": [
|
||||||
|
{
|
||||||
|
"entities": [
|
||||||
|
"entity.system.home"
|
||||||
|
],
|
||||||
|
"actions": [
|
||||||
|
"ohos.want.action.home"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ShareAbility",
|
||||||
|
"srcEntry": "./ets/shareability/ShareAbility.ets",
|
||||||
|
"description": "$string:ShareAbility_desc",
|
||||||
|
"icon": "$media:layered_image",
|
||||||
|
"label": "$string:ShareAbility_label",
|
||||||
|
"startWindowIcon": "$media:startIcon",
|
||||||
|
"startWindowBackground": "$color:start_window_background",
|
||||||
|
"exported": true,
|
||||||
|
"skills": [{
|
||||||
|
"actions": ["ohos.want.action.sendData"],
|
||||||
|
"uris": [{
|
||||||
|
"utd": "general.entity",
|
||||||
|
"scheme": 'file',
|
||||||
|
"maxFileSupported": 1
|
||||||
|
},{
|
||||||
|
"scheme": "file",
|
||||||
|
"utd": "general.text",
|
||||||
|
"maxFileSupported": 1
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"extensionAbilities": [
|
||||||
|
{
|
||||||
|
"name": "EntryBackupAbility",
|
||||||
|
"srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
|
||||||
|
"type": "backup",
|
||||||
|
"exported": false,
|
||||||
|
"metadata": [
|
||||||
|
{
|
||||||
|
"name": "ohos.extension.backup",
|
||||||
|
"resource": "$profile:backup_config"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "EntryCalendarCardAbility",
|
||||||
|
"srcEntry": "./ets/entrycalendarcardability/EntryCalendarCardAbility.ets",
|
||||||
|
"label": "$string:EntryCalendarCardAbility_label",
|
||||||
|
"description": "$string:EntryCalendarCardAbility_desc",
|
||||||
|
"type": "form",
|
||||||
|
"metadata": [
|
||||||
|
{
|
||||||
|
"name": "ohos.extension.form",
|
||||||
|
"resource": "$profile:form_config"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"color": [
|
||||||
|
{
|
||||||
|
"name": "start_window_background",
|
||||||
|
"value": "#FFFFFF"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "information_title_font",
|
||||||
|
"value": "#E6000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "title_font",
|
||||||
|
"value": "#E5FFFFFF"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "item_text_font",
|
||||||
|
"value": "#99000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "image_info_background",
|
||||||
|
"value": "#FFFFFF"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"float": [
|
||||||
|
{
|
||||||
|
"name": "page_text_font_size",
|
||||||
|
"value": "50fp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "card_title_font_size",
|
||||||
|
"value": "14fp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "item_font_size",
|
||||||
|
"value": "12fp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "maximum_padding",
|
||||||
|
"value": "12vp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "item_margin_top",
|
||||||
|
"value": "2vp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "image_margin_bottom",
|
||||||
|
"value": "8vp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "info_column_padding",
|
||||||
|
"value": "12vp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "info_column_width",
|
||||||
|
"value": "106vp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "info_column_height",
|
||||||
|
"value": "112vp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "image_border_radius",
|
||||||
|
"value": "8vp"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,64 @@
|
|||||||
|
{
|
||||||
|
"string": [
|
||||||
|
{
|
||||||
|
"name": "module_desc",
|
||||||
|
"value": "本模块是凌依助手的首选启动模块。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "EntryAbility_desc",
|
||||||
|
"value": "凌依助手是星谐落云全过程人工智能辅助体系的前端组成部分。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "EntryAbility_label",
|
||||||
|
"value": "Zero One"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "EA_label_zhcn",
|
||||||
|
"value": "凌依"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "read_calendar_permission",
|
||||||
|
"value": "读写日历的权限,用以同步日程。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "EntryCalendarCardAbility_desc",
|
||||||
|
"value": "form_description"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "EntryCalendarCardAbility_label",
|
||||||
|
"value": "落云日程表"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "CalendarCard_desc",
|
||||||
|
"value": "凌依助手-落云日程表"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "CalendarCard_display_name",
|
||||||
|
"value": "落云日程表卡片"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "card_title",
|
||||||
|
"value": "标题"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "introduction",
|
||||||
|
"value": "描述"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_connecting",
|
||||||
|
"value": "通过网络下载资源、完成请求等。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "JIT",
|
||||||
|
"value": "在程序运行过程中动态更新代码。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ShareAbility_desc",
|
||||||
|
"value": "芸链分享是星谐智能的一个基础多端分享能力。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ShareAbility_label",
|
||||||
|
"value": "芸链分享"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
二进制文件未显示。
|
之后 宽度: | 高度: | 大小: 90 KiB |
二进制文件未显示。
|
之后 宽度: | 高度: | 大小: 8.6 KiB |
二进制文件未显示。
|
之后 宽度: | 高度: | 大小: 5.7 KiB |
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"layered-image":
|
||||||
|
{
|
||||||
|
"background" : "$media:background",
|
||||||
|
"foreground" : "$media:foreground"
|
||||||
|
}
|
||||||
|
}
|
||||||
二进制文件未显示。
|
之后 宽度: | 高度: | 大小: 20 KiB |
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"allowToBackupRestore": true
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"forms": [
|
||||||
|
{
|
||||||
|
"name": "CalendarCard",
|
||||||
|
"displayName": "$string:CalendarCard_display_name",
|
||||||
|
"description": "$string:CalendarCard_desc",
|
||||||
|
"src": "./ets/calendarcard/pages/CalendarCardCard.ets",
|
||||||
|
"uiSyntax": "arkts",
|
||||||
|
"window": {
|
||||||
|
"designWidth": 720,
|
||||||
|
"autoDesignWidth": true
|
||||||
|
},
|
||||||
|
"colorMode": "auto",
|
||||||
|
"isDynamic": true,
|
||||||
|
"isDefault": true,
|
||||||
|
"updateEnabled": false,
|
||||||
|
"scheduledUpdateTime": "10:30",
|
||||||
|
"updateDuration": 1,
|
||||||
|
"defaultDimension": "4*4",
|
||||||
|
"supportDimensions": [
|
||||||
|
"4*4"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"src": [
|
||||||
|
"pages/Index",
|
||||||
|
"pages/SpeechPage",
|
||||||
|
"pages/MEShare/MES"
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"color": [
|
||||||
|
{
|
||||||
|
"name": "start_window_background",
|
||||||
|
"value": "#000000"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||||
|
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
|
||||||
|
|
||||||
|
export default function abilityTest() {
|
||||||
|
describe('ActsAbilityTest', () => {
|
||||||
|
// 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.
|
||||||
|
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
|
||||||
|
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);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
import abilityTest from './Ability.test';
|
||||||
|
|
||||||
|
export default function testsuite() {
|
||||||
|
abilityTest();
|
||||||
|
}
|
||||||
11
entry/src/ohosTest/module.json5
普通文件
11
entry/src/ohosTest/module.json5
普通文件
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"module": {
|
||||||
|
"name": "entry_test",
|
||||||
|
"type": "feature",
|
||||||
|
"deviceTypes": [
|
||||||
|
"phone"
|
||||||
|
],
|
||||||
|
"deliveryWithInstall": true,
|
||||||
|
"installationFree": false
|
||||||
|
}
|
||||||
|
}
|
||||||
5
entry/src/test/List.test.ets
普通文件
5
entry/src/test/List.test.ets
普通文件
@ -0,0 +1,5 @@
|
|||||||
|
import localUnitTest from './LocalUnit.test';
|
||||||
|
|
||||||
|
export default function testsuite() {
|
||||||
|
localUnitTest();
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
23
hvigor/hvigor-config.json5
普通文件
23
hvigor/hvigor-config.json5
普通文件
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"modelVersion": "6.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
},
|
||||||
|
"execution": {
|
||||||
|
// "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | "ultrafine" | false ]. Default: "normal" */
|
||||||
|
// "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
|
||||||
|
// "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
|
||||||
|
// "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
|
||||||
|
// "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
|
||||||
|
// "optimizationStrategy": "memory" /* Define the optimization strategy. Value: [ "memory" | "performance" ]. Default: "memory" */
|
||||||
|
},
|
||||||
|
"logging": {
|
||||||
|
// "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
|
||||||
|
},
|
||||||
|
"debugging": {
|
||||||
|
// "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
|
||||||
|
},
|
||||||
|
"nodeOptions": {
|
||||||
|
// "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
|
||||||
|
// "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
|
||||||
|
}
|
||||||
|
}
|
||||||
6
hvigorfile.ts
普通文件
6
hvigorfile.ts
普通文件
@ -0,0 +1,6 @@
|
|||||||
|
import { appTasks } from '@ohos/hvigor-ohos-plugin';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
||||||
|
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
|
||||||
|
}
|
||||||
28
oh-package-lock.json5
普通文件
28
oh-package-lock.json5
普通文件
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"meta": {
|
||||||
|
"stableOrder": true,
|
||||||
|
"enableUnifiedLockfile": false
|
||||||
|
},
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
||||||
|
"specifiers": {
|
||||||
|
"@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0",
|
||||||
|
"@ohos/hypium@1.0.24": "@ohos/hypium@1.0.24"
|
||||||
|
},
|
||||||
|
"packages": {
|
||||||
|
"@ohos/hamock@1.0.0": {
|
||||||
|
"name": "",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==",
|
||||||
|
"resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har",
|
||||||
|
"registryType": "ohpm"
|
||||||
|
},
|
||||||
|
"@ohos/hypium@1.0.24": {
|
||||||
|
"name": "",
|
||||||
|
"version": "1.0.24",
|
||||||
|
"integrity": "sha512-3dCqc+BAR5LqEGG2Vtzi8O3r7ci/3fYU+FWjwvUobbfko7DUnXGOccaror0yYuUhJfXzFK0aZNMGSnXaTwEnbw==",
|
||||||
|
"resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.24.har",
|
||||||
|
"registryType": "ohpm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
oh-package.json5
普通文件
10
oh-package.json5
普通文件
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"modelVersion": "6.0.0",
|
||||||
|
"description": "Please describe the basic information.",
|
||||||
|
"dependencies": {
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@ohos/hypium": "1.0.24",
|
||||||
|
"@ohos/hamock": "1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
在新工单中引用
屏蔽一个用户