diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ed37cd10289419f1da2ff5ee67ec2c3ec477e1be --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.databaseupgrade", + "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..334e464d91262625a08ed65f71b2573e701c0a0e --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "DataBaseUpgrade" + } + ] +} diff --git a/AppScope/resources/base/media/app_icon.png b/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..cd45accb1dfd2fd0da16c732c72faa6e46b26521 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 f3d72cb43127683ba38a2f498d2f706b6380d8bc..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# DataBaseUpgrade - -#### 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 f6811801d1ba9b34833a96af7760d6ac58a5e9de..84743b22fb0be95c964fc2d142b95bd353026f5e 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,69 @@ -# DataBaseUpgrade +# 数据库升级 -#### 介绍 -{**以下是 Gitee 平台说明,您可以替换此简介** -Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} +### 介绍 -#### 软件架构 -软件架构说明 +本示例展示了对关系型数据库的操作,包括对数据库的常规增删改查操作以及对数据库事务的操作。 +本实例参考关系型数据库。 -#### 安装教程 -1. xxxx -2. xxxx -3. xxxx +### 效果预览 +![image](screenshots/device/DataBaseUpgrade.gif) -#### 使用说明 +使用说明 -1. xxxx -2. xxxx -3. xxxx +1、使用下拉选择框的方式提供几个可添加的字段名,然后提示用户输入对应的字段值。 -#### 参与贡献 +2、点击版本更新后,会拉取正在更新的进度条弹窗,当进度条100%前点击叉号取消,会事务性回滚导致下方用户信息不更新。 -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request +3、点击版本更新后,会拉取正在更新的进度条弹窗,当进度条达到100%后,会事务性提交并刷新下方用户信息并刷新备份数据库。 +4、点击版本回退按钮,会查询备份数据库并恢复。 -#### 特技 +5、版本回退的背景是在数据库在执行出问题时,可以回退到上一个版本,所以版本回退仅能回退一个版本,但在有新的版本更新之后,即可进行新的回退。 -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/) + +### 工程目录 +``` +├──entry/src/main/ets/ +│ ├──common +│ │ ├──constants +│ │ │ └──CommonConstants.ets // 常量类 +│ │ └──utils +│ │ ├──CommonUtils.ets // 文字弹窗实现类 +│ │ ├──DBUtils.ets // 数据库操作类 +│ │ └──Logger.ets // 日志打印类 +│ ├──entryability +│ │ └──EntryAbility.ets // 程序入口类 +│ ├──pages +│ │ └──Index.ets // 主页面 +│ ├──view +│ │ └──ProgressDialog.ets // 进度条弹窗实现类 +│ └──viewmodel +│ └──userInfo.ets // 用户信息类 +└──entry/src/main/resources // 应用静态资源目录 +``` +### 具体实现 + +* 本示例的主要功能都基于关系型数据库。 +* 添加字段值的操作主要基于executeSql。 +* 关于数据库事务性的操作主要参考commit和rollback +* 版本回退的实现主要利用对数据库的备份与恢复,在版本更新时,备份数据库,在版本回退时,恢复数据库。 + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:华为手机。 + +2. HarmonyOS系统:HarmonyOS NEXT Developer Beta1及以上。 + +3. DevEco Studio版本:DevEco Studio NEXT Developer Beta1及以上。 + +4. HarmonyOS SDK版本:HarmonyOS NEXT Developer Beta1 SDK及以上。 \ No newline at end of file diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d8c1dc53c229c6a7adab02944d312b78b87f8b3e --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,34 @@ +{ + "app": { + "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/.gitignore b/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..197e83c1b9504b12a3837e0189185479662cad4b --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + "arkOptions": { + // "apPath": "./modules.ap" /* Profile used for profile-guided optimization (PGO), a compiler optimization technique to improve app runtime performance. */ + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "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/oh-package.json5 b/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..225946cb11a2c405c8dc81eea89c22f923556638 --- /dev/null +++ b/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/entry/src/main/ets/common/constants/CommonConstants.ets b/entry/src/main/ets/common/constants/CommonConstants.ets new file mode 100644 index 0000000000000000000000000000000000000000..341c1c97090ac319717f8d0b2f8c9719c267ac13 --- /dev/null +++ b/entry/src/main/ets/common/constants/CommonConstants.ets @@ -0,0 +1,89 @@ +/* + * 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. + */ + +/** + * Common constants for all features. + */ +export class CommonConstants { + /** + * SQL statement for creating a user table. + */ + static readonly SQL_CREATE_USER_TABLE: string = 'CREATE TABLE IF NOT EXISTS user_info (id INTEGER PRIMARY KEY AUTOINCREMENT)'; + /** + * SQL statement for initializing user tables. + */ + static readonly SQL_INIT_USER_TABLE: string = 'insert into user_info values(1)'; + /** + * SQL statement for querying user tables. + */ + static readonly SQL_QUERY_USER_TABLE: string = 'SELECT * FROM user_info WHERE id = 1'; + /** + * String that fail to be updated. + */ + static readonly UPDATE_FAILED: string = '更新失败'; + /** + * String that Rollback failed. + */ + static readonly ROLLBACK_FAILED: string = '回退失败'; + /** + * String that Rollback success. + */ + static readonly ROLLBACK_SUCCESS: string = '回退成功'; + /** + * String that update success. + */ + static readonly UPDATE_SUCCESS: string = '更新成功'; + /** + * String that updating. + */ + static readonly UPDATING: string = '正在更新'; + /** + * String that empty. + */ + static readonly EMPTY_STRING: string = ''; + /** + * Maximum value of the progress bar. + */ + static readonly PROGRESS_MAX: number = 100; + /** + * Progress bar step. + */ + static readonly PROGRESS_STEP: number = 20; + /** + * String that 100%. + */ + static readonly PERCENT_WIDTH: string = '100%'; + /** + * String that 90%. + */ + static readonly PERCENT_NINETY_WIDTH: string = '90%'; + /** + * Number for 100. + */ + static readonly NUMBER_100: number = 100; + /** + * Number for 400. + */ + static readonly NUMBER_400: number = 400; + /** + * Number for 500. + */ + static readonly NUMBER_500: number = 500; + /** + * String for init name. + */ + static readonly INIT_NAME: string = 'developer1'; +} + diff --git a/entry/src/main/ets/common/utils/CommonUtils.ets b/entry/src/main/ets/common/utils/CommonUtils.ets new file mode 100644 index 0000000000000000000000000000000000000000..17385c4fd951e21a027175bb86dc373a653e2ad9 --- /dev/null +++ b/entry/src/main/ets/common/utils/CommonUtils.ets @@ -0,0 +1,29 @@ +/* + * 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 { promptAction } from '@kit.ArkUI'; + +export class CommonUtils { + showToast(message: string) { + promptAction.showToast({ + message: message, + duration: 1000 + }); + } +} + +let commonUtils = new CommonUtils(); + +export default commonUtils as CommonUtils; \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/DBUtils.ets b/entry/src/main/ets/common/utils/DBUtils.ets new file mode 100644 index 0000000000000000000000000000000000000000..a4892c01ae32e99ca3b22e90755979e9afd701bb --- /dev/null +++ b/entry/src/main/ets/common/utils/DBUtils.ets @@ -0,0 +1,207 @@ +/* + * 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 { relationalStore } from '@kit.ArkData'; +import { BusinessError } from "@kit.BasicServicesKit"; +import { User } from '../../viewmodel/UserInfo'; +import { CommonConstants } from '../constants/CommonConstants'; +import Logger from './Logger'; + +let store: relationalStore.RdbStore | undefined = undefined; +let context = getContext(this); +const STORE_CONFIG: relationalStore.StoreConfig = { + name: "RdbTest.db", + securityLevel: relationalStore.SecurityLevel.S1 +}; +const COLUMN_TYPE_MAP = [ + ['username', 'varchar(30)'], + ['account', 'varchar(30)'], + ['nickname', 'varchar(30)'], + ['age', 'varchar(30)'] +]; + +export class DBUtils { + /** + * Creating a User Table. + */ + createDB() { + relationalStore.getRdbStore(context, STORE_CONFIG, (err: BusinessError, rdbStore: relationalStore.RdbStore) => { + store = rdbStore; + if (store !== undefined) { + (store as relationalStore.RdbStore).executeSql(CommonConstants.SQL_CREATE_USER_TABLE, (err) => { + if (err) { + Logger.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`); + return; + } + Logger.info('create table done.'); + this.insertData(); + }) + } + }) + } + + /** + * Initializing User Table Data. + */ + insertData() { + if (store !== undefined) { + (store as relationalStore.RdbStore).executeSql(CommonConstants.SQL_INIT_USER_TABLE).then(() => { + Logger.info('insert data table done.'); + }).catch((err: BusinessError) => { + Logger.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`); + }) + } + } + + /** + * Querying User Table Information. + */ + async queryData(flags: number[]): Promise { + let res: User = new User(); + if (store !== undefined) { + (store as relationalStore.RdbStore).querySql(CommonConstants.SQL_QUERY_USER_TABLE, (err, resultSet) => { + if (err) { + Logger.error(`Query failed, code is ${err.code},message is ${err.message}`); + return; + } + Logger.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); + while (resultSet.goToNextRow()) { + let id = resultSet.getString(resultSet.getColumnIndex("id")); + res.setId(id); + let name = ''; + let account = '' + let nickname = ''; + let age = ''; + try { + if (flags[0] > 0) { + name = resultSet.getString(resultSet.getColumnIndex(COLUMN_TYPE_MAP[0][0])); + res.setName(name); + } + if (flags[1] > 0) { + account = resultSet.getString(resultSet.getColumnIndex(COLUMN_TYPE_MAP[1][0])); + res.setAccount(account); + } + if (flags[2] > 0) { + nickname = resultSet.getString(resultSet.getColumnIndex(COLUMN_TYPE_MAP[2][0])); + res.setNickName(nickname); + } + if (flags[3] > 0) { + age = resultSet.getString(resultSet.getColumnIndex(COLUMN_TYPE_MAP[3][0])); + res.setAge(age); + } + } catch (error) { + Logger.error(`ExecuteSql failed, code is ${error.code},message is ${error.message}`); + resultSet.close(); + return res; + } + resultSet.close(); + return res; + } + resultSet.close(); + return res; + }) + } + return res; + } + + /** + * Modifying the User Table Information. + */ + updateData(index: number, content: string) { + if (store !== undefined) { + (store as relationalStore.RdbStore).executeSql("update user_info set " + + COLUMN_TYPE_MAP[index][0] + " = '" + content + "' where id = 1") + .then(() => { + Logger.info('update data done.'); + }) + .catch((err: BusinessError) => { + Logger.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`); + }) + } + } + + /** + * Used for database transactional rollback. + */ + rollback() { + if (store !== undefined) { + store.rollBack(); + } + } + + /** + * Used to commit database transactions. + */ + commit() { + if (store !== undefined) { + store.commit(); + } + } + + /** + * Modifying the User Table Structure. + */ + async updateTable(index: number, content: string) { + let updateTableSql = "alter table user_info add column " + + COLUMN_TYPE_MAP[index][0] + " " + COLUMN_TYPE_MAP[index][1]; + if (store !== undefined) { + store.beginTransaction(); + (store as relationalStore.RdbStore).executeSql(updateTableSql, (err) => { + if (err) { + Logger.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`); + return; + } + Logger.info('update table done.'); + this.updateData(index, content); + }) + } + } + + /** + * Modifying the User Table Information. + */ + async backup(callback: () => void) { + if (store !== undefined) { + (store as relationalStore.RdbStore).backup('dbBackup.db', (err) => { + if (err) { + Logger.error(`Failed to backup data. Code:${err.code},message:${err.message}`); + return; + } + Logger.info('Succeeded in backuping data.'); + callback(); + }) + } + } + + /** + * Modifying the User Table Information. + */ + async restore(callback: () => void) { + if (store !== undefined) { + (store as relationalStore.RdbStore).restore('dbBackup.db', (err) => { + if (err) { + Logger.error(`Failed to restore data. Code:${err.code},message:${err.message}`); + return; + } + Logger.info('Succeeded in restoring data.'); + callback(); + }) + } + } +} + +let dbUtils = new DBUtils(); + +export default dbUtils as DBUtils; \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/Logger.ets b/entry/src/main/ets/common/utils/Logger.ets new file mode 100644 index 0000000000000000000000000000000000000000..0b312714d7102541c07ba27420ccd3967e6472e1 --- /dev/null +++ b/entry/src/main/ets/common/utils/Logger.ets @@ -0,0 +1,55 @@ +/* + * 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'; + +const LOGGER_PREFIX: string = 'DataBaseUpgrade'; + +class Logger { + private domain: number; + private prefix: string; + // format Indicates the log format string. + private format: string = '%{public}s, %{public}s'; + + /** + * constructor. + * + * @param prefix Identifies the log tag. + * @param domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF + * @param args Indicates the log parameters. + */ + constructor(prefix: string = '', domain: number = 0xFF00) { + this.prefix = prefix; + this.domain = domain; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + +export default new Logger(LOGGER_PREFIX, 0xFF02); \ 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..8bd1dd3bfc74906b9c7d9d2b22d2b67fc3de24ec --- /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 { UIAbility } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(): 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, data) => { + 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. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + 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/pages/Index.ets b/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..76808b5685cf5e7b967ac0dea6514ce58e1f2b3d --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,263 @@ +/* + * 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 { CommonConstants } from '../common/constants/CommonConstants'; +import CommonUtils from '../common/utils/CommonUtils'; +import dbUtils from '../common/utils/DBUtils'; +import { User } from '../viewmodel/UserInfo'; +import { ProgressDialog } from '../view/ProgressDialog'; + + +@Entry +@Component +struct Index { + @State index: number = 0; + @State content: string = ''; + @State res: User | undefined = undefined; + @State versionInfo: string[] = []; + @State versionNumber: number = 0; + @State flags: number[] = [0, 0, 0, 0]; + // Set the initial value of the progress bar to 0. + @State @Watch('onUpdated') progressValue: number = 0; + // Check whether to cancel the update. + @State isCanceled: boolean = false; + // Check whether the update is successful. + @State isSucceed: boolean = false; + // Check whether the loading dynamic effect is displayed. + @State isShowLoading: boolean = false; + @State isUpdate: boolean = false; + versionUpdateInfo: string[] = []; + subscript: number = 2; + dialogController: CustomDialogController = new CustomDialogController({ + builder: ProgressDialog({ + progressValue: this.progressValue, + isCanceled: this.isCanceled, + isSucceed: this.isSucceed, + isShowLoading: this.isShowLoading, + index: this.index, + content: this.content, + res: this.res, + versionNumber: this.versionNumber, + flags: this.flags, + isUpdate: this.isUpdate + }), + }); + + onUpdated() { + if (this.isCanceled) { + this.dialogController.close(); + } + if (this.progressValue == CommonConstants.PROGRESS_MAX) { + this.isSucceed = true; + } + } + + aboutToAppear() { + dbUtils.createDB(); + } + + build() { + Column() { + Column() { + Text($r('app.string.Sequence_diagram')) + .width($r('app.float.default_312')) + .height($r('app.float.default_32')) + .fontSize($r('app.float.default_font_24')) + .fontWeight(CommonConstants.NUMBER_500) + .margin({ + top: $r('app.float.default_12'), + bottom: $r('app.float.default_12'), + left: $r('app.float.default_12'), + right: $r('app.float.default_24') + }) + } + .width($r('app.float.default_360')) + .height($r('app.float.default_56')) + + Row() { + Text($r('app.string.input_field')) + .fontWeight(CommonConstants.NUMBER_500) + .fontSize($r('app.float.default_font_16')) + Select([ + { value: $r('app.string.username') }, + { value: $r('app.string.account') }, + { value: $r('app.string.nickname') }, + { value: $r('app.string.age') } + ]) + .backgroundColor($r('app.color.start_window_background')) + .selected(0) + .font({ weight: CommonConstants.NUMBER_500, size: $r('app.float.default_font_16') }) + .value($r('app.string.username')) + .onSelect((index: number) => { + this.index = index; + }) + } + .justifyContent(FlexAlign.SpaceBetween) + .width($r('app.float.default_312')) + .height($r('app.float.default_48')) + + Column() { + Column() { + Text($r('app.string.field_value')) + .textAlign(TextAlign.Center) + .fontSize($r('app.float.default_font_16')) + .fontWeight(CommonConstants.NUMBER_500) + } + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Start) + .width($r('app.float.default_312')) + .height($r('app.float.default_48')) + + TextInput({ placeholder: CommonConstants.INIT_NAME }) + .enableKeyboardOnFocus(false) + .backgroundColor($r('app.color.input_background')) + .borderRadius(0) + .width($r('app.float.default_312')) + .height($r('app.float.default_48')) + .onChange((value: string) => { + this.content = value; + }) + Row() { + Button($r('app.string.version_update')) + .margin({ right: $r('app.float.default_12') }) + .fontSize($r('app.float.default_font_16')) + .fontWeight(CommonConstants.NUMBER_500) + .width($r('app.float.default_150')) + .height($r('app.float.default_40')) + .onClick(() => { + this.isCanceled = false; + this.dialogController.open(); + }) + Button($r('app.string.version_rollback')) + .backgroundColor($r('app.color.rollback_background')) + .opacity(!this.isUpdate ? 0.5 : 1) + .fontColor($r('app.color.font_color')) + .fontSize($r('app.float.default_font_16')) + .fontWeight(CommonConstants.NUMBER_500) + .width($r('app.float.default_150')) + .height($r('app.float.default_40')) + .onClick(async () => { + if (!this.isUpdate) { + CommonUtils.showToast(CommonConstants.ROLLBACK_FAILED); + } else { + dbUtils.restore(() => { + dbUtils.queryData(this.flags).then((value: User) => { + this.res = value; + CommonUtils.showToast(CommonConstants.ROLLBACK_SUCCESS); + }) + }); + this.isUpdate = false; + this.flags[this.index]--; + } + }) + } + .width($r('app.float.default_312')) + .height($r('app.float.default_40')) + .justifyContent(FlexAlign.Start) + .margin({ top: $r('app.float.default_24') }) + } + .borderRadius($r('app.float.default_16')) + .backgroundColor($r('app.color.input_background')) + .width($r('app.float.default_336')) + .height($r('app.float.default_176')) + + Column() { + Column() { + Text($r('app.string.user_info')) + .width($r('app.float.default_288')) + .height($r('app.float.default_56')) + .fontWeight(CommonConstants.NUMBER_500) + .fontSize($r('app.float.default_font_20')) + } + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Start) + .width($r('app.float.default_312')) + .height($r('app.float.default_56')) + + Row() { + if (this.flags[0] > 0) { + Text($r('app.string.username')) + .fontSize($r('app.float.default_font_16')) + .fontWeight(CommonConstants.NUMBER_500) + .textAlign(TextAlign.Center) + Text(this.res?.name) + .textAlign(TextAlign.Center) + .fontSize($r('app.float.default_font_14')) + .fontWeight(CommonConstants.NUMBER_400) + } + } + .justifyContent(FlexAlign.SpaceBetween) + .width($r('app.float.default_312')) + .height(this.flags[0] > 0 ? $r('app.float.default_48') : $r('app.float.default_0')) + + Row() { + if (this.flags[1] > 0) { + Text($r('app.string.account')) + .fontSize($r('app.float.default_font_16')) + .fontWeight(CommonConstants.NUMBER_500) + .textAlign(TextAlign.Center) + Text(this.res?.account) + .textAlign(TextAlign.Center) + .fontSize($r('app.float.default_font_14')) + .fontWeight(CommonConstants.NUMBER_400) + } + } + .justifyContent(FlexAlign.SpaceBetween) + .width($r('app.float.default_312')) + .height(this.flags[1] > 0 ? $r('app.float.default_48') : $r('app.float.default_0')) + + Row() { + if (this.flags[2] > 0) { + Text($r('app.string.nickname')) + .fontSize($r('app.float.default_font_16')) + .fontWeight(CommonConstants.NUMBER_500) + .textAlign(TextAlign.Center) + Text(this.res?.nickname) + .textAlign(TextAlign.Center) + .fontSize($r('app.float.default_font_14')) + .fontWeight(CommonConstants.NUMBER_400) + } + } + .justifyContent(FlexAlign.SpaceBetween) + .width($r('app.float.default_312')) + .height(this.flags[2] > 0 ? $r('app.float.default_48') : $r('app.float.default_0')) + + Row() { + if (this.flags[3] > 0) { + Text($r('app.string.age')) + .fontSize($r('app.float.default_font_16')) + .fontWeight(CommonConstants.NUMBER_500) + .textAlign(TextAlign.Center) + Text(this.res?.age) + .textAlign(TextAlign.Center) + .fontSize($r('app.float.default_14')) + .fontWeight(CommonConstants.NUMBER_400) + } + } + .justifyContent(FlexAlign.SpaceBetween) + .width($r('app.float.default_312')) + .height(this.flags[3] > 0 ? $r('app.float.default_48') : $r('app.float.default_0')) + } + .borderRadius($r('app.float.default_16')) + .margin({ top: $r('app.float.default_12') }) + .backgroundColor($r('app.color.input_background')) + .width($r('app.float.default_336')) + .height($r('app.float.default_256')) + } + .width(CommonConstants.PERCENT_WIDTH) + .height(CommonConstants.PERCENT_WIDTH) + .backgroundColor($r('app.color.start_window_background')) + } +} diff --git a/entry/src/main/ets/view/ProgressDialog.ets b/entry/src/main/ets/view/ProgressDialog.ets new file mode 100644 index 0000000000000000000000000000000000000000..88a17a6bbab5f1368027b4f467d432b3f1e9ae49 --- /dev/null +++ b/entry/src/main/ets/view/ProgressDialog.ets @@ -0,0 +1,116 @@ +/* + * 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 { CommonConstants } from '../common/constants/CommonConstants'; +import CommonUtils from '../common/utils/CommonUtils'; +import dbUtils from '../common/utils/DBUtils'; +import { User } from '../viewmodel/UserInfo'; + +@CustomDialog +export struct ProgressDialog { + @Link index: number; + @Link content: string; + @Link progressValue: number; + @Link isCanceled: boolean; + @Link versionNumber: number; + @Link res: User; + @Link isSucceed: boolean; + @Link isShowLoading: boolean; + @Link flags: number[]; + @Link isUpdate: boolean; + controller: CustomDialogController; + private intervalId: number = 0; + + aboutToAppear() { + this.isShowLoading = true; + if (!this.flags[this.index]) { + dbUtils.backup(() => { + dbUtils.updateTable(this.index, this.content); + }); + } else { + dbUtils.backup(() => { + dbUtils.updateData(this.index, this.content); + }); + } + this.intervalId = setInterval(() => { + if (this.progressValue < CommonConstants.PROGRESS_MAX) { + this.progressValue += CommonConstants.PROGRESS_STEP; + } else { + this.isSucceed = true; + this.controller.close(); + } + }, CommonConstants.NUMBER_500) + } + + async aboutToDisappear() { + if (this.isCanceled) { + CommonUtils.showToast(CommonConstants.UPDATE_FAILED); + dbUtils.rollback(); + } else if (this.isSucceed) { + CommonUtils.showToast(CommonConstants.UPDATE_SUCCESS); + this.isUpdate = true; + this.versionNumber++; + dbUtils.commit(); + setTimeout(() => { + dbUtils.queryData(this.flags).then((value: User) => { + this.flags[this.index]++; + this.res = value; + }); + }, CommonConstants.NUMBER_100) + } + this.isShowLoading = false; + this.progressValue = 0; + clearInterval(this.intervalId); + } + + build() { + Column() { + Column() { + Row() { + Text(CommonConstants.UPDATING) + .fontSize($r('app.float.default_font_14')) + .fontWeight(CommonConstants.NUMBER_400) + Text(this.progressValue + '%') + .fontSize($r('app.float.default_font_14')) + .fontWeight(CommonConstants.NUMBER_400) + } + .margin({ top: $r('app.float.default_29') }) + .width(CommonConstants.PERCENT_NINETY_WIDTH) + .justifyContent(FlexAlign.SpaceBetween) + + Row() { + Progress({ value: 0, total: CommonConstants.PROGRESS_MAX, type: ProgressType.Linear }) + .value(this.progressValue) + .width($r('app.float.default_268')) + .height($r('app.float.default_24')) + .margin({ right: $r('app.float.default_12') }) + Image($r('app.media.ic_public_close_filled')) + .width($r('app.float.default_24')) + .height($r('app.float.default_24')) + .onClick(() => { + this.isCanceled = true; + clearInterval(this.intervalId); + this.controller.close(); + }) + } + .justifyContent(FlexAlign.SpaceBetween) + } + .width($r('app.float.default_304')) + .height($r('app.float.default_56')) + } + .width($r('app.float.default_336')) + .height($r('app.float.default_88')) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/viewmodel/UserInfo.ets b/entry/src/main/ets/viewmodel/UserInfo.ets new file mode 100644 index 0000000000000000000000000000000000000000..4b66e98ff7e5c7b28858e20386e175159f588086 --- /dev/null +++ b/entry/src/main/ets/viewmodel/UserInfo.ets @@ -0,0 +1,44 @@ +/* + * 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 { CommonConstants } from '../common/constants/CommonConstants'; + +export class User { + public id: string = CommonConstants.EMPTY_STRING; + public name: string = CommonConstants.EMPTY_STRING; + public account: string = CommonConstants.EMPTY_STRING; + public nickname: string = CommonConstants.EMPTY_STRING; + public age: string = CommonConstants.EMPTY_STRING; + + public setId(id: string): void { + this.id = id; + } + + public setName(name: string): void { + this.name = name; + } + + public setNickName(nickname: string): void { + this.nickname = nickname; + } + + public setAge(age: string): void { + this.age = age; + } + + public setAccount(account: string): void { + this.account = account; + } +} \ 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..6c07d9d8839ac9716809c6e06c21805d52c138fe --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,38 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ 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..7feb0bcd492ea7fa0d2eef3bb2c5ead924d7c308 --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,23 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#F1F3F5" + }, + { + "name": "input_background", + "value": "#FFFFFF" + }, + { + "name": "rollback_background", + "value": "#0D000000" + }, + { + "name": "font_color", + "value": "#0A59F7" + } + + + + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/dimen.json b/entry/src/main/resources/base/element/dimen.json new file mode 100644 index 0000000000000000000000000000000000000000..cd1964923b670c2ea17d5f8fd9124d6f6b50ff34 --- /dev/null +++ b/entry/src/main/resources/base/element/dimen.json @@ -0,0 +1,176 @@ +{ + "float": [ + { + "name": "default_22", + "value": "22vp" + }, + { + "name": "default_24", + "value": "24vp" + }, + { + "name": "default_294", + "value": "294vp" + }, + { + "name": "default_312", + "value": "312vp" + }, + { + "name": "default_40", + "value": "40vp" + }, + { + "name": "default_16", + "value": "16vp" + }, + { + "name": "default_13", + "value": "13vp" + }, + { + "name": "default_336", + "value": "336vp" + }, + { + "name": "default_8", + "value": "8vp" + }, + { + "name": "default_139", + "value": "139vp" + }, + { + "name": "default_20", + "value": "20vp" + }, + { + "name": "default_100", + "value": "100vp" + }, + { + "name": "default_48", + "value": "48vp" + }, + { + "name": "default_147", + "value": "147vp" + }, + { + "name": "default_10", + "value": "10vp" + }, + { + "name": "default_223", + "value": "223vp" + }, + { + "name": "default_302", + "value": "302vp" + }, + { + "name": "default_213", + "value": "213vp" + }, + { + "name": "default_120", + "value": "120vp" + }, + { + "name": "default_251", + "value": "251vp" + }, + { + "name": "default_41", + "value": "41vp" + }, + { + "name": "default_30", + "value": "30vp" + }, + { + "name": "default_7", + "value": "7vp" + }, + { + "name": "default_360", + "value": "360vp" + }, + { + "name": "default_56", + "value": "56vp" + }, + { + "name": "default_680", + "value": "680vp" + }, + { + "name": "default_200", + "value": "200vp" + }, + { + "name": "default_12", + "value": "12vp" + }, + { + "name": "default_32", + "value": "32vp" + }, + { + "name": "default_150", + "value": "150vp" + }, + { + "name": "default_176", + "value": "176vp" + }, + { + "name": "default_288", + "value": "288vp" + }, + { + "name": "default_14", + "value": "14vp" + }, + { + "name": "default_256", + "value": "256vp" + }, + { + "name": "default_29", + "value": "29vp" + }, + { + "name": "default_268", + "value": "268vp" + }, + { + "name": "default_304", + "value": "304vp" + }, + { + "name": "default_88", + "value": "88vp" + }, + { + "name": "default_0", + "value": "0vp" + }, + { + "name": "default_font_16", + "value": "16fp" + }, + { + "name": "default_font_14", + "value": "14fp" + }, + { + "name": "default_font_24", + "value": "24fp" + }, + { + "name": "default_font_20", + "value": "20fp" + } + ] +} \ 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..1162b88f4013de3adaa69ae55daf9417e87b164f --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,68 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "DataBaseUpgrade" + }, + { + "name": "Update_failed", + "value": "Update failed." + }, + { + "name": "Sequence_diagram", + "value": "sequence diagram" + }, + { + "name": "input_field", + "value": "Please select the name of the field you want to add." + }, + { + "name": "field_value", + "value": "field value" + }, + { + "name": "username", + "value": "username" + }, + { + "name": "account", + "value": "account" + }, + { + "name": "nickname", + "value": "nickname" + }, + { + "name": "age", + "value": "age" + }, + { + "name": "version_update", + "value": "version update" + }, + { + "name": "version_rollback", + "value": "version rollback" + }, + { + "name": "rollback_failed", + "value": "rollback failed" + }, + { + "name": "rollback_success", + "value": "rollback success" + }, + { + "name": "user_info", + "value": "User information display" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_close_filled.svg b/entry/src/main/resources/base/media/ic_public_close_filled.svg new file mode 100644 index 0000000000000000000000000000000000000000..5f46a4f38abd1a9ea20e74ea2bd06bc90ca8d2f9 --- /dev/null +++ b/entry/src/main/resources/base/media/ic_public_close_filled.svg @@ -0,0 +1,16 @@ + + + Public/ic_public_close_filled + + + + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..cd45accb1dfd2fd0da16c732c72faa6e46b26521 Binary files /dev/null and b/entry/src/main/resources/base/media/icon.png differ 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..366f76459ffd4494ec40d0ddd5c59385b9c5da11 Binary files /dev/null and b/entry/src/main/resources/base/media/startIcon.png differ 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..ddb963fa57a8515ffe0400576fc84c8acad3e28f --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,67 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "DataBaseUpgrade" + }, + { + "name": "Update_failed", + "value": "Update failed." + }, + { + "name": "Sequence_diagram", + "value": "sequence diagram" + }, + { + "name": "input_field", + "value": "Please select the name of the field you want to add." + }, + { + "name": "field_value", + "value": "field value" + }, + { + "name": "username", + "value": "username" + }, + { + "name": "account", + "value": "account" + }, + { + "name": "nickname", + "value": "nickname" + },{ + "name": "age", + "value": "age" + }, + { + "name": "version_update", + "value": "version update" + }, + { + "name": "version_rollback", + "value": "version rollback" + }, + { + "name": "rollback_failed", + "value": "rollback failed" + }, + { + "name": "rollback_success", + "value": "rollback success" + }, + { + "name": "user_info", + "value": "User information display" + } + ] +} \ 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..929239d38419c9b0c4b498003dd96a7862aab00d --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,68 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "数据库升级" + }, + { + "name": "Update_failed", + "value": "更新失败" + }, + { + "name": "Sequence_diagram", + "value": "顺序图" + }, + { + "name": "input_field", + "value": "请选择你要添加的字段名" + }, + { + "name": "field_value", + "value": "字段值" + }, + { + "name": "username", + "value": "用户名" + }, + { + "name": "account", + "value": "账号" + }, + { + "name": "nickname", + "value": "昵称" + }, + { + "name": "age", + "value": "年龄" + }, + { + "name": "version_update", + "value": "版本更新" + }, + { + "name": "version_rollback", + "value": "版本回退" + }, + { + "name": "rollback_failed", + "value": "回退失败" + }, + { + "name": "rollback_success", + "value": "回退成功" + }, + { + "name": "user_info", + "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..73bfab4e997c8d4aea53b22fdd7f10112b30987f --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,17 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "daemon": true, /* Enable daemon compilation. Default: true */ + // "incremental": true, /* Enable incremental compilation. Default: true */ + // "parallel": true, /* Enable parallel compilation. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Default: false */ + } +} \ No newline at end of file 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..e849b8e7154d4e7d30d823ec078b4b9ea403d80a --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,13 @@ +{ + "modelVersion": "5.0.0", + "license": "ISC", + "devDependencies": { + "@ohos/hypium": "1.0.15" + }, + "author": "", + "name": "databaseupgrade", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} \ No newline at end of file diff --git a/screenshots/device/DataBaseUpgrade.gif b/screenshots/device/DataBaseUpgrade.gif new file mode 100644 index 0000000000000000000000000000000000000000..78fe013b79b5f6f94765e18f0fcab4ce2f66c235 Binary files /dev/null and b/screenshots/device/DataBaseUpgrade.gif differ