diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..baf7d2210e46934a28d76baa153c1cd6534416b7 --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.kvstore", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c43fe751de7039692a3fd1cbc09909a21fff65af --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "KVStore" + } + ] +} diff --git a/AppScope/resources/base/media/app_icon.png b/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/AppScope/resources/base/media/app_icon.png differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..338e5b0bc22082e0ffcc7121c2ed3897a3ddccb0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,78 @@ + Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +Apache License, Version 2.0 +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: +1.You must give any other recipients of the Work or Derivative Works a copy of this License; and +2.You must cause any modified files to carry prominent notices stating that You changed the files; and +3.You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +4.If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 76e0bf7e6f10a5814673d2a1b0bbcaafdfc00463..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# KVStore - -#### Description -{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md index 77477523fa3004adf4737ca71f3c6e1af4d9d759..1bbf8ec0f903956a7032876706026f161db97522 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,66 @@ -# KVStore +## 键值型数据库读写 -#### 介绍 -{**以下是 Gitee 平台说明,您可以替换此简介** -Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} +### 介绍 -#### 软件架构 -软件架构说明 +本示例主要使用@ohos.data.distributedKVStore接口,实现了键值型数据库的访问及增删改查功能。 +### 效果预览 -#### 安装教程 +| 首页 | 详情页 | 新增页 | +|-------------------------------------|-----------------------------------------|----------------------------------| +| ![](screenshots/devices/create.png) | ![](screenshots/devices/read_write.png) | ![](screenshots/devices/new.png) | -1. xxxx -2. xxxx -3. xxxx -#### 使用说明 +使用说明: -1. xxxx -2. xxxx -3. xxxx +1. 选择数据等级及是否加密数据后,点击“创建”按钮,进入详情页; +2. 点击“新增”,弹出新增半模态,可以自定义新增类型、键、值; +3. 点击“提交”,数据库增加一条数据(相同键名只能存在一条),点击右上X键或者蒙层区域,退出半模态,数据不更新; +4. 数据库每条数据可编辑,可删除,点击“删除”,数据库删除该条数据; +5. 点击“编辑”,弹出编辑半模态,可修改数据的类型和值,不允许修改键名; +6. 点击“提交”,数据库该条数据信息更新。 -#### 参与贡献 +### 工程目录 -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request +``` +├──entry/src/main/ets // 代码区 +│ ├──constants +│ │ └──utils +│ │ └──KVStore.ets // 键值数据库相关操作 +│ ├──entryability +│ │ └──EntryAbility.ets +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets +│ ├──pages +│ │ ├──Index.ets // 首页 +│ │ └──ReadWritePage.ets // 读写页 +│ └──viewmodel +│ └──KVStoreType.ets // 数据库信息类 +└──entry/src/main/resources // 应用资源目录 +``` +### 具体实现 -#### 特技 +1. 使用createKVManager()接口,创建一个KVManager对象实例,用于管理数据库对象。(实现代码:[](entry/src/main/ets/common/utils/KVStore.ets)) +2. 使用getKVStore()接口,指定options和storeId,创建并得到SingleKVStore类型的KVStore数据库。(实现代码:[](entry/src/main/ets/common/utils/KVStore.ets)) +3. 使用put()接口,添加指定类型的键值对到数据库。(实现代码:[](entry/src/main/ets/common/utils/KVStore.ets)) +4. 使用getEntries()接口,获取所有键值。(实现代码:[](entry/src/main/ets/common/utils/KVStore.ets)) +5. 使用delete()接口,从数据库中删除指定键值的数据。(实现代码:[](entry/src/main/ets/common/utils/KVStore.ets)) -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:华为手机。 + +2. HarmonyOS系统:HarmonyOS 5.0.0 Developer Release及以上。 + +3. DevEco Studio版本:DevEco Studio 5.0.0 Developer Release及以上。 + +4. HarmonyOS SDK版本:HarmonyOS 5.0.0 Developer Release SDK及以上。 diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c033ce4278fb0641d84107c3c134047ac487368e --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,35 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/entry/hvigorfile.ts b/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/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. */ +} diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/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 \ No newline at end of file diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/entry/src/main/ets/common/utils/KVStore.ets b/entry/src/main/ets/common/utils/KVStore.ets new file mode 100644 index 0000000000000000000000000000000000000000..42e25aafece38eff88563fb201bb9a4d4a37ddc0 --- /dev/null +++ b/entry/src/main/ets/common/utils/KVStore.ets @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { distributedKVStore } from '@kit.ArkData'; +import { bundleManager } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { KVStoreType } from '../../viewmodel/KVStoreType'; + +export default class KVStore { + private kvManager: distributedKVStore.KVManager | undefined = undefined; + private context = getContext(this); + private kvStore: distributedKVStore.SingleKVStore | undefined = undefined; + private bundleName: string = ''; + + constructor(encrypt: boolean, securityLevel: distributedKVStore.SecurityLevel) { + let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; + bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => { + this.bundleName = data.name; + const kvManagerConfig: distributedKVStore.KVManagerConfig = { + context: this.context, + bundleName: this.bundleName + }; + this.kvManager = distributedKVStore.createKVManager(kvManagerConfig); + const options: distributedKVStore.Options = { + createIfMissing: true, + backup: false, + autoSync: false, + kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION, + encrypt: encrypt, + securityLevel: securityLevel + }; + this.kvManager.getKVStore(`${securityLevel}${JSON.stringify(encrypt)}`, options, + (err, store: distributedKVStore.SingleKVStore) => { + if (err) { + hilog.error(0x0000, 'KVStore', `Failed to get KVStore: Code:${err.code},message:${err.message}`); + return; + } + hilog.info(0x0000, 'KVStore', 'Succeeded in getting KVStore.'); + this.kvStore = store; + }); + }) + } + + async put(key: string, value: Uint8Array | string | number | boolean) { + this.kvStore!.put(key, value, (err) => { + if (err !== undefined) { + hilog.error(0x0000, 'KVStore', `Failed to put data. Code:${err.code},message:${err.message}`); + return; + } + hilog.info(0x0000, 'KVStore', 'Succeeded in putting data.'); + }); + } + + delete(key: string) { + this.kvStore!.delete(key, (err) => { + if (err !== undefined) { + hilog.error(0x0000, 'KVStore', `Failed to delete data. Code:${err.code},message:${err.message}`); + return; + } + hilog.info(0x0000, 'KVStore', 'Succeeded in deleting data.'); + }); + } + + async getAll(): Promise { + let allKVStore: KVStoreType[] = []; + await this.kvStore!.getEntries('^').then((entries: distributedKVStore.Entry[]) => { + let i = 0; + for (i; i < entries.length; i++) { + let type: string = typeof entries[i].value.value; + if (type === 'object') { + type = 'Uint8Array'; + } + let kvStoreType = new KVStoreType(entries[i].key, entries[i].value.value, type); + allKVStore.push(kvStoreType); + } + }); + hilog.info(0x0000, 'KVStore', `kvStoreType: ${JSON.stringify(allKVStore)}`); + return allKVStore; + } +} \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..217744d8eb6d893e1138cd660209ce4d0441ac4f --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..6b744d7eaa66e51e79fc4e0896e251292ee767c5 --- /dev/null +++ b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8854973de23b08887f157a1d1fb0f44d7ebc4283 --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { distributedKVStore } from '@kit.ArkData'; +import KVStore from '../common/utils/KVStore'; +import { KVStoreType } from '../viewmodel/KVStoreType'; +import { ReadWrite } from './ReadWritePage'; + +@Entry +@Component +struct Index { + @Provide('pageInfos') pageInfos: NavPathStack = new NavPathStack(); + @State text: string = 'S1'; + @State index: number = 0; + @State securityLevel: distributedKVStore.SecurityLevel = distributedKVStore.SecurityLevel.S1; + @StorageLink('encrypted') encrypted: boolean = false; + @StorageLink('kvStore') kvStore: KVStore | undefined = undefined; + @StorageLink('kvStoreAll') kvStoreAll: KVStoreType[] = []; + + @Builder + pageMap(name: string) { + if(name === 'readWritePage'){ + ReadWrite() + } + } + + build() { + Navigation(this.pageInfos) { + Column() { + Column() { + Row() { + Text($r('app.string.select')) + .fontSize(14) + .fontWeight(FontWeight.Regular) + .fontColor($r('sys.color.mask_secondary')) + .lineHeight(20) + .margin({ + top: 28, + bottom: 12 + }) + Row() { + Checkbox({ name: 'encrypt', group: 'checkboxGroup' }) + .select(false) + .height(20) + .width(20) + .selectedColor('#0A59F7') + .shape(CheckBoxShape.CIRCLE) + .onChange((value: boolean) => { + this.encrypted = value; + }) + Text($r('app.string.encrypt')) + .fontSize(14) + .fontWeight(FontWeight.Regular) + .fontColor($r('sys.color.mask_secondary')) + .lineHeight(20) + .margin({ left: 8 }) + } + .height('100%') + .margin({ + top: 28, + bottom: 12 + }) + } + .height(60) + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + .margin({ + top: 8, + bottom: 12 + }) + + Select([{ value: 'S1' }, + { value: 'S2' }, + { value: 'S3' }, + { value: 'S4' }]) + .selected(this.index) + .value(this.text) + .font({ + size: 16, + weight: 500 + }) + .fontColor($r('sys.color.font_primary')) + .selectedOptionFont({ + size: 16, + weight: 500 + }) + .optionFont({ + size: 16, + weight: 500 + }) + .space(8) + .width('100%') + .arrowPosition(ArrowPosition.END) + .menuAlign(MenuAlignType.START, { dx: 0, dy: 0 }) + .optionWidth(200) + .optionHeight(300) + .onSelect((index: number, text?: string) => { + this.index = index; + if (text) { + this.text = text; + if (text === 'S1') { + this.securityLevel = distributedKVStore.SecurityLevel.S1; + } else if (text === 'S2') { + this.securityLevel = distributedKVStore.SecurityLevel.S2; + } else if (text === 'S3') { + this.securityLevel = distributedKVStore.SecurityLevel.S3; + } else if (text === 'S4') { + this.securityLevel = distributedKVStore.SecurityLevel.S4; + } + } + }) + } + + Button($r('app.string.create')) + .width('100%') + .height('40vp') + .fontSize('16fp') + .backgroundColor('#0A59F7') + .fontWeight(FontWeight.Medium) + .onClick(async () => { + this.kvStoreAll = []; + this.kvStore = undefined; + this.kvStore = new KVStore(this.encrypted, this.securityLevel); + setTimeout(() => { + this.pageInfos.pushPath(new NavPathInfo('readWritePage', [])); + }, 200) + }) + } + .justifyContent(FlexAlign.SpaceBetween) + .height('100%') + .width('100%') + .padding({ + left: 16, + right: 16, + bottom: 16 + }) + } + .title($r('app.string.title')) + .width('100%') + .height('100%') + .hideToolBar(true) + .navDestination(this.pageMap) + .backgroundColor('#F1F3F5') + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/ReadWritePage.ets b/entry/src/main/ets/pages/ReadWritePage.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a8a014fd48ca7294009d3dc4a7c39d8b06e56d8 --- /dev/null +++ b/entry/src/main/ets/pages/ReadWritePage.ets @@ -0,0 +1,423 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { buffer, util } from '@kit.ArkTS'; +import KVStore from '../common/utils/KVStore'; +import { KVStoreType } from '../viewmodel/KVStoreType'; + +@Extend(Text) +function tableStyle() { + .maxLines(1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .fontSize(14) + .fontWeight(400) + .fontColor('#e6000000') + .lineHeight(20) + .textAlign(TextAlign.Center) +} + +@Extend(Text) +function tableHeaderStyle() { + .fontSize(18) + .fontWeight(700) + .fontColor($r('sys.color.mask_secondary')) + .height(37) + .textAlign(TextAlign.Center) +} + +@Component +export struct ReadWrite { + @StorageLink('isInsetShow') isInsetShow: boolean = false; + @StorageLink('isEditShow') isEditShow: boolean = false; + @StorageLink('editData') editData: KVStoreType | undefined = undefined; + @StorageLink('kvStoreAll') kvStoreAll: KVStoreType[] = []; + @StorageLink('kvStore') kvStore: KVStore | undefined = undefined; + @State text: string = 'number'; + @State index: number = 0; + private inputKey: string = ''; + private inputValue: Uint8Array | string | number | boolean = ''; + + @Builder + menuBuilder(kvStore: KVStoreType) { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Column() { + Row() { + SymbolGlyph($r('sys.symbol.square_and_pencil_fill')) + .fontSize(24) + .margin({ right: 8 }) + Text($r('app.string.edit')) + .fontSize(16) + .fontWeight(500) + .lineHeight(21) + .fontColor('#e6000000') + } + .width('100%') + .height(30) + .justifyContent(FlexAlign.Start) + .align(Alignment.Center) + .onClick(() => { + this.isEditShow = true; + this.editData = kvStore; + if (kvStore.type === 'Uint8Array') { + let uint8Array: Uint8Array = this.editData.value as Uint8Array; + let textDecoderOptions: util.TextDecoderOptions = { + fatal: false, + ignoreBOM: true + }; + let decodeToStringOptions: util.DecodeToStringOptions = { + stream: false + }; + let textDecoder = util.TextDecoder.create('utf-8', textDecoderOptions); + let retStr = textDecoder.decodeToString(uint8Array, decodeToStringOptions); + this.editData.value = retStr.slice(1, -1); + } + this.text = this.editData.type; + switch (this.editData.type) { + case 'number': + this.index = 0; + break; + case 'string': + this.index = 1; + break; + case 'boolean': + this.index = 2; + break; + case 'Uint8Array': + this.index = 3; + break; + default: + break; + } + }) + + Divider() + .height(10) + .width('100%') + .color('#0d000000') + + Row() { + SymbolGlyph($r('sys.symbol.trash_fill')) + .fontSize(24) + .margin({ right: 8 }) + Text($r('app.string.delete')) + .fontSize(16) + .fontWeight(500) + .lineHeight(21) + .fontColor('#e6000000') + } + .width('100%') + .height(30) + .justifyContent(FlexAlign.Start) + .align(Alignment.Center) + .onClick(async () => { + this.kvStore?.delete(kvStore.key) + setTimeout(async () => { + await this.kvStore?.getAll().then((data: KVStoreType[]) => { + this.kvStoreAll = data; + }); + }, 200) + }) + } + .padding({ + top: 4, + bottom: 4, + left: 16, + right: 16 + }) + .height(80) + } + .width(224) + } + + @Builder + insertBindSheet(editData?: KVStoreType | undefined) { + Column() { + Text(editData ? $r('app.string.edit_type') : $r('app.string.new_type')) + .width('100%') + .fontSize(16) + .fontWeight(500) + .lineHeight(37) + .padding({ + left: 16, + right: 16 + }) + + Select([{ value: 'number' }, + { value: 'string' }, + { value: 'boolean' }, + { value: 'Uint8Array' }]) + .selected(this.index) + .value(this.text) + .font({ + size: 16, + weight: 500 + }) + .fontColor($r('sys.color.font_primary')) + .selectedOptionFont({ + size: 16, + weight: 500 + }) + .optionFont({ + size: 16, + weight: 500 + }) + .space(8) + .width('100%') + .arrowPosition(ArrowPosition.END) + .menuAlign(MenuAlignType.START, { dx: 0, dy: 0 }) + .optionWidth(200) + .optionHeight(300) + .onSelect((index: number, text?: string) => { + this.index = index; + if (text) { + this.text = text; + } + }) + + Text($r('app.string.table_header_key')) + .width('100%') + .fontSize(16) + .fontWeight(500) + .lineHeight(37) + .padding({ + left: 16, + right: 16 + }) + TextInput({ placeholder: editData?.key }) + .width('100%') + .enabled(editData ? false : true) + .onChange((value) => { + this.inputKey = value; + }) + + Text($r('app.string.table_header_value')) + .width('100%') + .fontSize(16) + .fontWeight(500) + .lineHeight(37) + .padding({ + left: 16, + right: 16 + }) + if (this.text === 'number') { + TextInput({ placeholder: '', text: editData ? editData.value.toString() : '' }) + .type(InputType.Number) + .width('100%') + .onChange((value: string) => { + this.inputValue = value; + }) + } else if (this.text === 'boolean') { + Column() { + Row() { + Radio({ value: 'true', group: 'radioGroup' }) + .checked(editData && editData.value === true ? true : false) + .height(20) + .width(20) + .onChange((isChecked: boolean) => { + if (isChecked) { + this.inputValue = true; + } + }) + Text('true') + .fontSize(16) + .margin({ right: 50 }) + } + .width('100%') + .padding({ left: 12 }) + .justifyContent(FlexAlign.Start) + + Row() { + Radio({ value: 'false', group: 'radioGroup' }) + .checked(editData && editData.value === false ? true : false) + .height(20) + .width(20) + .onChange((isChecked: boolean) => { + if (isChecked) { + this.inputValue = false; + } + }) + Text('false') + .fontSize(16) + } + .width('100%') + .padding({ left: 12 }) + .justifyContent(FlexAlign.Start) + } + .width('100%') + } else { + TextInput({ placeholder: '', text: editData ? editData.value.toString() : '' }) + .width('100%') + .onChange((value) => { + this.inputValue = value; + }) + } + + Button($r('app.string.submit')) + .width('100%') + .height(40) + .margin({ + top: 16, + bottom: 16 + }) + .fontSize(16) + .backgroundColor('#0A59F7') + .fontWeight(FontWeight.Medium) + .onClick(async () => { + let newArray: Uint8Array | undefined = undefined; + if (this.text === 'number') { + this.inputValue = Number(this.inputValue); + } else if (this.text === 'Uint8Array') { + newArray = new Uint8Array(buffer.from(JSON.stringify(this.inputValue), 'utf-8').buffer); + } + await this.kvStore?.put(editData ? editData.key : this.inputKey, newArray ? newArray : this.inputValue); + setTimeout(async () => { + await this.kvStore?.getAll().then((data) => { + this.kvStoreAll = data; + }); + this.isInsetShow = false; + this.isEditShow = false; + this.editData = undefined; + }, 200); + }) + } + .height('100%') + .justifyContent(FlexAlign.SpaceBetween) + .padding({ + left: 16, + right: 16, + bottom: 16 + }) + .borderRadius(10) + } + + async aboutToAppear() { + await this.kvStore?.getAll().then((data) => { + this.kvStoreAll = data; + }); + } + + build() { + NavDestination() { + Column() { + Scroll() { + Column() { + Row() { + Text($r('app.string.table_header_key')) + .width(50) + .tableHeaderStyle() + Text($r('app.string.table_header_value')) + .width(80) + .tableHeaderStyle() + Text($r('app.string.table_header_type')) + .width(76) + .tableHeaderStyle() + Text($r('app.string.table_header_operate')) + .width(40) + .tableHeaderStyle() + } + .padding({ right: 11 }) + .width('100%') + .height(44) + .justifyContent(FlexAlign.SpaceBetween) + + Divider() + .padding({ + left: 11, + right: 11 + }) + .width('100%') + .color('#0d000000') + + Column() { + ForEach(this.kvStoreAll, (kvStore: KVStoreType) => { + Row() { + Text(kvStore.key) + .width(50) + .tableStyle() + Text(kvStore.value.toString()) + .width(80) + .tableStyle() + Text(kvStore.type) + .width(76) + .tableStyle() + SymbolGlyph($r('sys.symbol.dot_grid_1x2')) + .fontSize(20) + .fontColor(['#99000000']) + .bindMenu(this.menuBuilder(kvStore)) + .width(40) + .height(20) + } + .margin({ + top: 8, + bottom: 12 + }) + .width('100%') + .height(20) + .justifyContent(FlexAlign.SpaceBetween) + }, (kvStore: KVStoreType) => JSON.stringify(kvStore)) + } + .width('100%') + .bindSheet(this.isEditShow, this.insertBindSheet(this.editData), { + height: 440, + title: { title: $r('app.string.edit_title') }, + onDisappear: async () => { + if (this.text === 'Uint8Array') { + let newArray = new Uint8Array(buffer.from(JSON.stringify(this.inputValue), 'utf-8').buffer); + this.editData!.value = newArray; + } + this.isEditShow = false; + this.editData = undefined; + } + }) + } + .padding(12) + .width('100%') + .borderRadius(12) + .backgroundColor(Color.White) + } + .borderRadius(12) + .align(Alignment.TopStart) + .scrollBar(BarState.Auto) + .height('90%') + + Column() { + Button($r('app.string.new')) + .width('100%') + .onClick(() => { + this.isInsetShow = true; + this.text = 'number'; + this.index = 0; + }) + .bindSheet(this.isInsetShow, this.insertBindSheet(), { + height: 440, + title: { title: $r('app.string.new_title') }, + onDisappear: () => { + this.isInsetShow = false; + } + }) + } + .width('100%') + } + .padding(16) + .width('100%') + .height('100%') + .justifyContent(FlexAlign.SpaceBetween) + } + .width('100%') + .height('100%') + .title(getContext(this).resourceManager.getStringSync($r('app.string.destination_title'))) + .backgroundColor('#F1F3F5') + } +} \ No newline at end of file diff --git a/entry/src/main/ets/viewmodel/KVStoreType.ets b/entry/src/main/ets/viewmodel/KVStoreType.ets new file mode 100644 index 0000000000000000000000000000000000000000..33fdf5533f87f1fd71d5865c663d7bf16d51968d --- /dev/null +++ b/entry/src/main/ets/viewmodel/KVStoreType.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class KVStoreType { + public key: string; + public value: Uint8Array | string | number | boolean; + public type: string; + + constructor(key: string, value: Uint8Array | string | number | boolean, type: string) { + this.key = key; + this.value = value; + this.type = type; + } +} \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ad219d733f6afa5ea07f85f580208b08cc3b9041 --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,50 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..acd4663f178d703da68c568772678cb4888a5f6a --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,84 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "KVStore" + }, + { + "name": "table_header_key", + "value": "Key" + }, + { + "name": "table_header_value", + "value": "Value" + }, + { + "name": "table_header_type", + "value": "Type" + }, + { + "name": "table_header_operate", + "value": "Operate" + }, + { + "name": "title", + "value": "Create a key value database" + }, + { + "name": "select", + "value": "Select security level" + }, + { + "name": "encrypt", + "value": "Encrypt" + }, + { + "name": "create", + "value": "Create" + }, + { + "name": "destination_title", + "value": "Database details" + }, + { + "name": "edit", + "value": "Edit" + }, + { + "name": "delete", + "value": "Delete" + }, + { + "name": "edit_title", + "value": "Edit project" + }, + { + "name": "new_title", + "value": "New project" + }, + { + "name": "edit_type", + "value": "Edit Type" + }, + { + "name": "new_type", + "value": "New Type" + }, + { + "name": "submit", + "value": "Submit" + }, + { + "name": "new", + "value": "New" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/background.png b/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/entry/src/main/resources/base/media/background.png differ diff --git a/entry/src/main/resources/base/media/foreground.png b/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/entry/src/main/resources/base/media/foreground.png differ diff --git a/entry/src/main/resources/base/media/layered_image.json b/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/startIcon.png b/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/entry/src/main/resources/base/media/startIcon.png differ diff --git a/entry/src/main/resources/base/profile/backup_config.json b/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..acd4663f178d703da68c568772678cb4888a5f6a --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,84 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "KVStore" + }, + { + "name": "table_header_key", + "value": "Key" + }, + { + "name": "table_header_value", + "value": "Value" + }, + { + "name": "table_header_type", + "value": "Type" + }, + { + "name": "table_header_operate", + "value": "Operate" + }, + { + "name": "title", + "value": "Create a key value database" + }, + { + "name": "select", + "value": "Select security level" + }, + { + "name": "encrypt", + "value": "Encrypt" + }, + { + "name": "create", + "value": "Create" + }, + { + "name": "destination_title", + "value": "Database details" + }, + { + "name": "edit", + "value": "Edit" + }, + { + "name": "delete", + "value": "Delete" + }, + { + "name": "edit_title", + "value": "Edit project" + }, + { + "name": "new_title", + "value": "New project" + }, + { + "name": "edit_type", + "value": "Edit Type" + }, + { + "name": "new_type", + "value": "New Type" + }, + { + "name": "submit", + "value": "Submit" + }, + { + "name": "new", + "value": "New" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..51d997c6dea560bc6cd60e0caabd185e1ae2b135 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,84 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "KVStore" + }, + { + "name": "table_header_key", + "value": "键" + }, + { + "name": "table_header_value", + "value": "值" + }, + { + "name": "table_header_type", + "value": "类型" + }, + { + "name": "table_header_operate", + "value": "操作" + }, + { + "name": "title", + "value": "创建键值型数据库" + }, + { + "name": "select", + "value": "选择数据等级" + }, + { + "name": "encrypt", + "value": "加密数据" + }, + { + "name": "create", + "value": "创建" + }, + { + "name": "destination_title", + "value": "数据库详情" + }, + { + "name": "edit", + "value": "编辑" + }, + { + "name": "delete", + "value": "删除" + }, + { + "name": "edit_title", + "value": "编辑项目" + }, + { + "name": "new_title", + "value": "新增项目" + }, + { + "name": "edit_type", + "value": "编辑类型" + }, + { + "name": "new_type", + "value": "新增类型" + }, + { + "name": "submit", + "value": "提交" + }, + { + "name": "new", + "value": "新增" + } + ] +} \ No newline at end of file diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..06b2783670a348f95533b352c1ceda909a842bbc --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | 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 */ + }, + "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*/ + } +} diff --git a/hvigorfile.ts b/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/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. */ +} diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8bf916d4a165e0466c65bc49f58ab2e3c27e8931 --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,8 @@ +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + } +} diff --git a/screenshots/devices/create.png b/screenshots/devices/create.png new file mode 100644 index 0000000000000000000000000000000000000000..042c58195a0bc569d66d648cf05ea54ddcae77fb Binary files /dev/null and b/screenshots/devices/create.png differ diff --git a/screenshots/devices/new.png b/screenshots/devices/new.png new file mode 100644 index 0000000000000000000000000000000000000000..7131b8c0e825b5fd5432fd7661ad129863da7634 Binary files /dev/null and b/screenshots/devices/new.png differ diff --git a/screenshots/devices/read_write.png b/screenshots/devices/read_write.png new file mode 100644 index 0000000000000000000000000000000000000000..634956f2c48da848911391bb19325fda54b159d0 Binary files /dev/null and b/screenshots/devices/read_write.png differ