diff --git a/Data/StringCipherETS/AppScope/app.json5 b/Data/StringCipherETS/AppScope/app.json5 index 516d3cdeedff119268bd08b17ec93b2d017e9081..0ce57ac091b31cb4e1c63c81131b7605400434a5 100644 --- a/Data/StringCipherETS/AppScope/app.json5 +++ b/Data/StringCipherETS/AppScope/app.json5 @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.huawei.cookbook", + "bundleName": "com.example.stringcipherets", "vendor": "example", "versionCode": 1000000, "versionName": "1.0.0", diff --git a/Data/StringCipherETS/hvigorfile.js b/Data/StringCipherETS/entry/hvigorfile.ts similarity index 63% rename from Data/StringCipherETS/hvigorfile.js rename to Data/StringCipherETS/entry/hvigorfile.ts index 5f2735e3deeaf655828407544bbed9365c258278..80e4ec5b81689f238c34614b167a0b9e9c83e8d9 100644 --- a/Data/StringCipherETS/hvigorfile.js +++ b/Data/StringCipherETS/entry/hvigorfile.ts @@ -1,2 +1,2 @@ // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').appTasks \ No newline at end of file +export { hapTasks } from '@ohos/hvigor-ohos-plugin'; diff --git a/Data/StringCipherETS/entry/package.json b/Data/StringCipherETS/entry/package.json index c4e988f30f2ec9e3430a4d0c8f05e89fabbc2659..29732ffea047ab4e9d897d4cc7092f5e7fe3493f 100644 --- a/Data/StringCipherETS/entry/package.json +++ b/Data/StringCipherETS/entry/package.json @@ -1,13 +1,14 @@ { + "license": "ISC", + "devDependencies": {}, "name": "entry", - "version": "1.0.0", "ohos": { "org": "huawei", - "buildTool": "hvigor", - "directoryLevel": "module" + "directoryLevel": "module", + "buildTool": "hvigor" }, "description": "example description", "repository": {}, - "license": "ISC", + "version": "1.0.0", "dependencies": {} } diff --git a/Data/StringCipherETS/entry/src/main/ets/Application/AbilityStage.ts b/Data/StringCipherETS/entry/src/main/ets/Application/AbilityStage.ts deleted file mode 100644 index 32dfe93ccff0375201857794de902cec4d239442..0000000000000000000000000000000000000000 --- a/Data/StringCipherETS/entry/src/main/ets/Application/AbilityStage.ts +++ /dev/null @@ -1,7 +0,0 @@ -import AbilityStage from "@ohos.application.AbilityStage" - -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("[Demo] MyAbilityStage onCreate") - } -} \ No newline at end of file diff --git a/Data/StringCipherETS/entry/src/main/ets/Model/RdbModel.ts b/Data/StringCipherETS/entry/src/main/ets/Model/RdbModel.ts index 9da9c5ca3e23a74b56bb631e38acbcefaf8de314..cd3a02d56a8bbc08c7cfc2813f7da9c161707954 100644 --- a/Data/StringCipherETS/entry/src/main/ets/Model/RdbModel.ts +++ b/Data/StringCipherETS/entry/src/main/ets/Model/RdbModel.ts @@ -13,8 +13,8 @@ * limitations under the License. */ -import dataRdb from '@ohos.data.rdb' -import prompt from '@ohos.prompt' +import relationalStore from '@ohos.data.relationalStore' +import prompt from '@ohos.promptAction' export class RdbModel { private rdbStore: any = null @@ -22,7 +22,10 @@ export class RdbModel { private tableName: string = '' private sqlCreateTable: string = '' private columns: Array = [] - private STORE_CONFIG = { name: 'user.db', encryptKey: null } + private STORE_CONFIG = { + name: 'user.db', + securityLevel: relationalStore.SecurityLevel.S1 + } constructor(tableName: string, sqlCreateTable: string, columns: Array) { this.tableName = tableName @@ -35,7 +38,7 @@ export class RdbModel { if (this.rdbStore != null) { return this.rdbStore.executeSql(this.sqlCreateTable); } - let getPromiseRdb = dataRdb.getRdbStore(globalThis.context, this.STORE_CONFIG, 1); + let getPromiseRdb = relationalStore.getRdbStore(globalThis.context, this.STORE_CONFIG); await getPromiseRdb.then(async (rdbStore) => { this.rdbStore = rdbStore; this.promiseExecSql = rdbStore.executeSql(this.sqlCreateTable); @@ -56,7 +59,7 @@ export class RdbModel { // 更新数据 updateData(user) { const valueBucket = JSON.parse(JSON.stringify(user)); - let predicates = new dataRdb.RdbPredicates(this.tableName); + let predicates = new relationalStore.RdbPredicates(this.tableName); predicates.equalTo('id', user.id); this.rdbStore.update(valueBucket, predicates, function (err, ret) { prompt.showToast({ message: 'updated row done:' + ret }); @@ -65,7 +68,7 @@ export class RdbModel { // 删除数据 deleteById(user) { - let predicates = new dataRdb.RdbPredicates(this.tableName); + let predicates = new relationalStore.RdbPredicates(this.tableName); predicates.equalTo('id', user.id); this.rdbStore.delete(predicates, function (err, rows) { prompt.showToast({ message: 'delete user' + rows }); diff --git a/Data/StringCipherETS/entry/src/main/ets/Model/UserTableApi.ts b/Data/StringCipherETS/entry/src/main/ets/Model/UserTableApi.ts index 5f9a30307373dda28da958585c4b4d398d93557b..43e8de41b9b612c64f9c2884808103e2631822de 100644 --- a/Data/StringCipherETS/entry/src/main/ets/Model/UserTableApi.ts +++ b/Data/StringCipherETS/entry/src/main/ets/Model/UserTableApi.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import dataRdb from '@ohos.data.rdb' +import relationalStore from '@ohos.data.relationalStore' import { User } from '../model/User' import { RdbModel } from '../model/RdbModel' @@ -42,7 +42,7 @@ export class UserTableApi { async queryUserByUsername(username) { let resultList; await this.userTable.getRdbStore().then(async () => { - let predicates = new dataRdb.RdbPredicates(TABLE_NAME); + let predicates = new relationalStore.RdbPredicates(TABLE_NAME); predicates.equalTo('username', username); let ret = await this.userTable.query(predicates); resultList = getListFromResultSet(ret); diff --git a/Data/StringCipherETS/entry/src/main/ets/MainAbility/MainAbility.ts b/Data/StringCipherETS/entry/src/main/ets/entryability/EntryAbility.ts similarity index 33% rename from Data/StringCipherETS/entry/src/main/ets/MainAbility/MainAbility.ts rename to Data/StringCipherETS/entry/src/main/ets/entryability/EntryAbility.ts index d626981f290c62eab271a0a7e20eed99d672c445..caec0a78e6ea0f4ece76d5bcaa3c5f25692f920c 100644 --- a/Data/StringCipherETS/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/Data/StringCipherETS/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,41 +1,42 @@ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; -export default class MainAbility extends Ability { +export default class EntryAbility extends UIAbility { onCreate(want, launchParam) { - console.log("[Demo] MainAbility onCreate") - globalThis.abilityWant = want; + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); globalThis.context = this.context; } onDestroy() { - console.log("[Demo] MainAbility onDestroy") + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); } - onWindowStageCreate(windowStage) { + onWindowStageCreate(windowStage: window.WindowStage) { // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent("pages/index", (err, data) => { + windowStage.loadContent('pages/index', (err, data) => { if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; } - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); }); } onWindowStageDestroy() { // Main window is destroyed, release UI related resources - console.log("[Demo] MainAbility onWindowStageDestroy") + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); } onForeground() { // Ability has brought to foreground - console.log("[Demo] MainAbility onForeground") + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); } onBackground() { // Ability has back to background - console.log("[Demo] MainAbility onBackground") + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); } -}; +} diff --git a/Data/StringCipherETS/entry/src/main/ets/pages/index.ets b/Data/StringCipherETS/entry/src/main/ets/pages/index.ets index be5cbb5b858582335811fcbd61495170277ddb2d..f1d3fbc1b3a704c1ead166447f5dde79cdaee2a1 100644 --- a/Data/StringCipherETS/entry/src/main/ets/pages/index.ets +++ b/Data/StringCipherETS/entry/src/main/ets/pages/index.ets @@ -14,7 +14,7 @@ */ // @ts-nocheck -import prompt from '@ohos.prompt'; +import prompt from '@ohos.promptAction'; import router from '@ohos.router'; import cipher from '@system.cipher'; import { User } from '../model/User'; @@ -77,8 +77,8 @@ struct Index { .margin({ top: '3%' }) .textAlign(TextAlign.Center) .onClick(() => { - router.push({ - uri: 'pages/register' + router.pushUrl({ + url: 'pages/register' }); }); } @@ -181,8 +181,8 @@ struct Index { let user = this.userList[0]; if (this.decryptPassword == this.password) { // 跳转到登录成功页面 - router.push({ - uri: 'pages/welcome', + router.pushUrl({ + url: 'pages/welcome', params: { 'nickname': user.nickname } }); } else { diff --git a/Data/StringCipherETS/entry/src/main/ets/pages/inputItem.ets b/Data/StringCipherETS/entry/src/main/ets/pages/inputItem.ets index 70daf0aedc28eddd8b8797a26440a8acb1d77318..4f6edc855f73f2f24ea68ee0a679f4c94f02dbfb 100644 --- a/Data/StringCipherETS/entry/src/main/ets/pages/inputItem.ets +++ b/Data/StringCipherETS/entry/src/main/ets/pages/inputItem.ets @@ -26,10 +26,10 @@ export struct InputItem { TextInput({ placeholder: this.placeholderName }) .type(this.typeFlag ? InputType.Password : InputType.Normal) .placeholderColor(Color.Gray) - .fontSize(30) + .fontSize(20) .caretColor(Color.Gray) .width('60%') - .height('55%') + .height('60%') .maxLength(14) .margin({ left: '8%' }) .onChange((value) => { diff --git a/Data/StringCipherETS/entry/src/main/ets/pages/register.ets b/Data/StringCipherETS/entry/src/main/ets/pages/register.ets index 5966f91c75bdad92a2caf48605358417cbf8bc93..39002e22f2583e27fc5a9a0684bbb09f6c40373e 100644 --- a/Data/StringCipherETS/entry/src/main/ets/pages/register.ets +++ b/Data/StringCipherETS/entry/src/main/ets/pages/register.ets @@ -14,7 +14,7 @@ */ // @ts-nocheck -import prompt from '@ohos.prompt'; +import prompt from '@ohos.promptAction'; import router from '@ohos.router'; import cipher from '@system.cipher'; import { User } from '../model/User'; @@ -208,8 +208,8 @@ struct Register { bottom: '40%' }); // 注册成功之后,跳转到登录页面 - router.push({ - uri: 'pages/index' + router.pushUrl({ + url: 'pages/index' }); } } \ No newline at end of file diff --git a/Data/StringCipherETS/entry/src/main/ets/pages/welcome.ets b/Data/StringCipherETS/entry/src/main/ets/pages/welcome.ets index 71722221430992a2d12e0d5f45322ccfd6b48bfc..45f73ebff1a882a1a906b2a678910e1d85b9e084 100644 --- a/Data/StringCipherETS/entry/src/main/ets/pages/welcome.ets +++ b/Data/StringCipherETS/entry/src/main/ets/pages/welcome.ets @@ -18,7 +18,7 @@ import router from '@ohos.router'; @Entry @Component struct Welcome { - @State nickname: string = router.getParams().nickname.toString() + @State nickname: string = router.getParams()['nickname'].toString() @State message: string = '登录成功' build() { diff --git a/Data/StringCipherETS/entry/src/main/module.json5 b/Data/StringCipherETS/entry/src/main/module.json5 index d5a10a3bcd49f48392e52ea49a3401ebf165b1b5..684b172c94cc3483466ca52296eb9c6e03e4f44c 100644 --- a/Data/StringCipherETS/entry/src/main/module.json5 +++ b/Data/StringCipherETS/entry/src/main/module.json5 @@ -2,26 +2,30 @@ "module": { "name": "entry", "type": "entry", - "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:entry_desc", - "mainElement": "MainAbility", + "description": "$string:module_desc", + "mainElement": "EntryAbility", "deviceTypes": [ "default", "tablet" ], + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "true" + } + ], "deliveryWithInstall": true, "installationFree": false, "pages": "$profile:main_pages", - "uiSyntax": "ets", "abilities": [ { - "name": "MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:MainAbility_desc", + "name": "EntryAbility", + "srcEntrance": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", "icon": "$media:icon", - "label": "$string:MainAbility_label", + "label": "$string:EntryAbility_label", "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:white", + "startWindowBackground": "$color:start_window_background", "visible": true, "skills": [ { diff --git a/Data/StringCipherETS/entry/src/main/resources/base/element/color.json b/Data/StringCipherETS/entry/src/main/resources/base/element/color.json index 1bbc9aa9617e97c45440e1d3d66afc1154837012..3c712962da3c2751c2b9ddb53559afcbd2b54a02 100644 --- a/Data/StringCipherETS/entry/src/main/resources/base/element/color.json +++ b/Data/StringCipherETS/entry/src/main/resources/base/element/color.json @@ -1,7 +1,7 @@ { "color": [ { - "name": "white", + "name": "start_window_background", "value": "#FFFFFF" } ] diff --git a/Data/StringCipherETS/entry/src/main/resources/base/element/string.json b/Data/StringCipherETS/entry/src/main/resources/base/element/string.json index 490210a3908f47722dc942d49dacc98b97669a5f..48b7c4d725c5414b7a391bcc0dc7bd986bb87761 100644 --- a/Data/StringCipherETS/entry/src/main/resources/base/element/string.json +++ b/Data/StringCipherETS/entry/src/main/resources/base/element/string.json @@ -1,16 +1,16 @@ { "string": [ { - "name": "entry_desc", - "value": "description" + "name": "module_desc", + "value": "module description" }, { - "name": "MainAbility_desc", + "name": "EntryAbility_desc", "value": "description" }, { - "name": "MainAbility_label", - "value": "label" + "name": "EntryAbility_label", + "value": "StringCipher" } ] } \ No newline at end of file diff --git a/Data/StringCipherETS/entry/src/main/resources/en_US/element/string.json b/Data/StringCipherETS/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..48b7c4d725c5414b7a391bcc0dc7bd986bb87761 --- /dev/null +++ b/Data/StringCipherETS/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "StringCipher" + } + ] +} \ No newline at end of file diff --git a/Data/StringCipherETS/entry/src/main/resources/zh_CN/element/string.json b/Data/StringCipherETS/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..8139358f8d49b54ee71c530fa5a7724b6f5f28b5 --- /dev/null +++ b/Data/StringCipherETS/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "字符串加解密" + } + ] +} \ No newline at end of file diff --git a/Data/StringCipherETS/entry/hvigorfile.js b/Data/StringCipherETS/hvigorfile.ts similarity index 63% rename from Data/StringCipherETS/entry/hvigorfile.js rename to Data/StringCipherETS/hvigorfile.ts index d7720ee6a7aad5c617d1fd2f6fc8c87067bfa32c..6478186902c0c1ad7c966a929c7d6b7d8ae7a9f3 100644 --- a/Data/StringCipherETS/entry/hvigorfile.js +++ b/Data/StringCipherETS/hvigorfile.ts @@ -1,2 +1,2 @@ // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks +export { appTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/Data/StringCipherETS/package.json b/Data/StringCipherETS/package.json index d18a1e72920ca576d334caae318bb6e4b81ab91e..63d664f8f0e1842e3d99b2f56353fceeeb8737de 100644 --- a/Data/StringCipherETS/package.json +++ b/Data/StringCipherETS/package.json @@ -1,17 +1,18 @@ { - "name": "stringcipher", - "version": "1.0.0", + "license": "ISC", + "devDependencies": {}, + "name": "stringcipherets", "ohos": { "org": "huawei", - "buildTool": "hvigor", - "directoryLevel": "project" + "directoryLevel": "project", + "buildTool": "hvigor" }, "description": "example description", "repository": {}, - "license": "ISC", + "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.1", - "@ohos/hvigor": "1.1.6", - "@ohos/hvigor-ohos-plugin": "1.1.6" + "@ohos/hypium": "1.0.5", + "@ohos/hvigor-ohos-plugin": "1.4.0", + "@ohos/hvigor": "1.4.0" } }