diff --git a/app/.metadata b/app/.metadata index db0a0fe..9ac8de8 100644 --- a/app/.metadata +++ b/app/.metadata @@ -4,8 +4,8 @@ # This file should be version controlled and should not be manually edited. version: - revision: "6b182d2c7585eba26d4edce0f97630effd256c33" - channel: "stable" + revision: "eb712e92d4c63e8051990ceea01fdcf88a7afd5d" + channel: "[user-branch]" project_type: app @@ -13,14 +13,17 @@ project_type: app migration: platforms: - platform: root - create_revision: 6b182d2c7585eba26d4edce0f97630effd256c33 - base_revision: 6b182d2c7585eba26d4edce0f97630effd256c33 + create_revision: eb712e92d4c63e8051990ceea01fdcf88a7afd5d + base_revision: eb712e92d4c63e8051990ceea01fdcf88a7afd5d - platform: android create_revision: 6b182d2c7585eba26d4edce0f97630effd256c33 base_revision: 6b182d2c7585eba26d4edce0f97630effd256c33 - platform: ios create_revision: 6b182d2c7585eba26d4edce0f97630effd256c33 base_revision: 6b182d2c7585eba26d4edce0f97630effd256c33 + - platform: ohos + create_revision: eb712e92d4c63e8051990ceea01fdcf88a7afd5d + base_revision: eb712e92d4c63e8051990ceea01fdcf88a7afd5d # User provided section diff --git a/app/ohos/.gitignore b/app/ohos/.gitignore new file mode 100644 index 0000000..e326491 --- /dev/null +++ b/app/ohos/.gitignore @@ -0,0 +1,20 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +**/BuildProfile.ets +**/oh-package-lock.json5 +/package.json +/package-lock.json + +**/src/main/resources/rawfile/flutter_assets/ +**/libs/**/libapp.so +**/libs/**/libflutter.so +**/libs/**/libvmservice_snapshot.so diff --git a/app/ohos/AppScope/app.json5 b/app/ohos/AppScope/app.json5 new file mode 100644 index 0000000..bd240b6 --- /dev/null +++ b/app/ohos/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.conti.app", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/app/ohos/AppScope/resources/base/element/string.json b/app/ohos/AppScope/resources/base/element/string.json new file mode 100644 index 0000000..198f1e7 --- /dev/null +++ b/app/ohos/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "app" + } + ] +} diff --git a/app/ohos/AppScope/resources/base/media/app_icon.png b/app/ohos/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000..ce307a8 Binary files /dev/null and b/app/ohos/AppScope/resources/base/media/app_icon.png differ diff --git a/app/ohos/build-profile.json5 b/app/ohos/build-profile.json5 new file mode 100644 index 0000000..1c112b1 --- /dev/null +++ b/app/ohos/build-profile.json5 @@ -0,0 +1,39 @@ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.1.0(18)", + "runtimeOS": "HarmonyOS", + } + ], + "buildModeSet": [ + { + "name": "debug" + }, + { + "name": "profile" + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/app/ohos/entry/.gitignore b/app/ohos/entry/.gitignore new file mode 100644 index 0000000..5254b88 --- /dev/null +++ b/app/ohos/entry/.gitignore @@ -0,0 +1,7 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test +GeneratedPluginRegistrant.ets \ No newline at end of file diff --git a/app/ohos/entry/build-profile.json5 b/app/ohos/entry/build-profile.json5 new file mode 100644 index 0000000..6de31ee --- /dev/null +++ b/app/ohos/entry/build-profile.json5 @@ -0,0 +1,15 @@ + +{ + "apiType": 'stageMode', + "buildOption": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "HarmonyOS" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/app/ohos/entry/hvigorfile.ts b/app/ohos/entry/hvigorfile.ts new file mode 100644 index 0000000..ff3bfe0 --- /dev/null +++ b/app/ohos/entry/hvigorfile.ts @@ -0,0 +1,7 @@ + +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +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/app/ohos/entry/oh-package.json5 b/app/ohos/entry/oh-package.json5 new file mode 100644 index 0000000..854eec2 --- /dev/null +++ b/app/ohos/entry/oh-package.json5 @@ -0,0 +1,11 @@ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {}, +} + diff --git a/app/ohos/entry/src/main/ets/entryability/EntryAbility.ets b/app/ohos/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000..f85a655 --- /dev/null +++ b/app/ohos/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,10 @@ + +import { FlutterAbility, FlutterEngine } from '@ohos/flutter_ohos'; +import { GeneratedPluginRegistrant } from '../plugins/GeneratedPluginRegistrant'; + +export default class EntryAbility extends FlutterAbility { + configureFlutterEngine(flutterEngine: FlutterEngine) { + super.configureFlutterEngine(flutterEngine) + GeneratedPluginRegistrant.registerWith(flutterEngine) + } +} diff --git a/app/ohos/entry/src/main/ets/pages/Index.ets b/app/ohos/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000..7bb6543 --- /dev/null +++ b/app/ohos/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,24 @@ + +import common from '@ohos.app.ability.common'; +import { FlutterPage } from '@ohos/flutter_ohos' + +let storage = LocalStorage.getShared() +const EVENT_BACK_PRESS = 'EVENT_BACK_PRESS' + +@Entry(storage) +@Component +struct Index { + private context = getContext(this) as common.UIAbilityContext + @LocalStorageLink('viewId') viewId: string = ""; + + build() { + Column() { + FlutterPage({ viewId: this.viewId }) + } + } + + onBackPress(): boolean { + this.context.eventHub.emit(EVENT_BACK_PRESS) + return true + } +} \ No newline at end of file diff --git a/app/ohos/entry/src/main/module.json5 b/app/ohos/entry/src/main/module.json5 new file mode 100644 index 0000000..5bd7950 --- /dev/null +++ b/app/ohos/entry/src/main/module.json5 @@ -0,0 +1,40 @@ + +{ + "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:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + {"name" : "ohos.permission.INTERNET"}, + ] + } +} \ No newline at end of file diff --git a/app/ohos/entry/src/main/resources/base/element/color.json b/app/ohos/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000..3c71296 --- /dev/null +++ b/app/ohos/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/app/ohos/entry/src/main/resources/base/element/string.json b/app/ohos/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000..6380355 --- /dev/null +++ b/app/ohos/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "app" + } + ] +} \ No newline at end of file diff --git a/app/ohos/entry/src/main/resources/base/media/icon.png b/app/ohos/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000..ce307a8 Binary files /dev/null and b/app/ohos/entry/src/main/resources/base/media/icon.png differ diff --git a/app/ohos/entry/src/main/resources/base/profile/main_pages.json b/app/ohos/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000..1898d94 --- /dev/null +++ b/app/ohos/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/app/ohos/entry/src/main/resources/en_US/element/string.json b/app/ohos/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000..6380355 --- /dev/null +++ b/app/ohos/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": "app" + } + ] +} \ No newline at end of file diff --git a/app/ohos/entry/src/main/resources/rawfile/buildinfo.json5 b/app/ohos/entry/src/main/resources/rawfile/buildinfo.json5 new file mode 100644 index 0000000..6125c99 --- /dev/null +++ b/app/ohos/entry/src/main/resources/rawfile/buildinfo.json5 @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "enable_impeller", + "value": "true" + } + ] +} \ No newline at end of file diff --git a/app/ohos/entry/src/main/resources/zh_CN/element/string.json b/app/ohos/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000..1839f21 --- /dev/null +++ b/app/ohos/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": "app" + } + ] +} \ No newline at end of file diff --git a/app/ohos/entry/src/ohosTest/ets/test/Ability.test.ets b/app/ohos/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000..8abf7f2 --- /dev/null +++ b/app/ohos/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import hilog from '@ohos.hilog'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +export default function abilityTest() { + describe('ActsAbilityTest', function () { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(function () { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(function () { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(function () { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(function () { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain',0, function () { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc' + let b = 'b' + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b) + expect(a).assertEqual(a) + }) + }) +} \ No newline at end of file diff --git a/app/ohos/entry/src/ohosTest/ets/test/List.test.ets b/app/ohos/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000..d766fe2 --- /dev/null +++ b/app/ohos/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test' + +export default function testsuite() { + abilityTest() +} \ No newline at end of file diff --git a/app/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets b/app/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets new file mode 100644 index 0000000..e3f6e91 --- /dev/null +++ b/app/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets @@ -0,0 +1,48 @@ +import UIAbility from '@ohos.app.ability.UIAbility'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import hilog from '@ohos.hilog'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../test/List.test'; +import window from '@ohos.window'; + +export default class TestAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? ''); + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); + windowStage.loadContent('testability/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() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); + } + + onBackground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); + } +} \ No newline at end of file diff --git a/app/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets b/app/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets new file mode 100644 index 0000000..545843d --- /dev/null +++ b/app/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets @@ -0,0 +1,36 @@ + + +import hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/app/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/app/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000..47fc89b --- /dev/null +++ b/app/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,50 @@ + +import hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName + var debug = abilityDelegatorArguments.parameters['-D'] + if (debug == 'true') + { + cmd += ' -D' + } + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/app/ohos/entry/src/ohosTest/module.json5 b/app/ohos/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000..3b02a75 --- /dev/null +++ b/app/ohos/entry/src/ohosTest/module.json5 @@ -0,0 +1,37 @@ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/app/ohos/entry/src/ohosTest/resources/base/element/color.json b/app/ohos/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000..3c71296 --- /dev/null +++ b/app/ohos/entry/src/ohosTest/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/app/ohos/entry/src/ohosTest/resources/base/element/string.json b/app/ohos/entry/src/ohosTest/resources/base/element/string.json new file mode 100644 index 0000000..65d8fa5 --- /dev/null +++ b/app/ohos/entry/src/ohosTest/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + } + ] +} \ No newline at end of file diff --git a/app/ohos/entry/src/ohosTest/resources/base/media/icon.png b/app/ohos/entry/src/ohosTest/resources/base/media/icon.png new file mode 100644 index 0000000..ce307a8 Binary files /dev/null and b/app/ohos/entry/src/ohosTest/resources/base/media/icon.png differ diff --git a/app/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json b/app/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json new file mode 100644 index 0000000..b7e7343 --- /dev/null +++ b/app/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "testability/pages/Index" + ] +} diff --git a/app/ohos/hvigor/hvigor-config.json5 b/app/ohos/hvigor/hvigor-config.json5 new file mode 100644 index 0000000..ad3ecab --- /dev/null +++ b/app/ohos/hvigor/hvigor-config.json5 @@ -0,0 +1,6 @@ + +{ + "modelVersion": "5.1.0", + "dependencies": { + } +} \ No newline at end of file diff --git a/app/ohos/hvigorconfig.ts b/app/ohos/hvigorconfig.ts new file mode 100644 index 0000000..fc2b208 --- /dev/null +++ b/app/ohos/hvigorconfig.ts @@ -0,0 +1,4 @@ +import path from 'path' +import { injectNativeModules } from 'flutter-hvigor-plugin'; + +injectNativeModules(__dirname, path.dirname(__dirname)) \ No newline at end of file diff --git a/app/ohos/hvigorfile.ts b/app/ohos/hvigorfile.ts new file mode 100644 index 0000000..a64db46 --- /dev/null +++ b/app/ohos/hvigorfile.ts @@ -0,0 +1,8 @@ +import path from 'path' +import { appTasks } from '@ohos/hvigor-ohos-plugin'; +import { flutterHvigorPlugin } from 'flutter-hvigor-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[flutterHvigorPlugin(path.dirname(__dirname))] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/app/ohos/oh-package.json5 b/app/ohos/oh-package.json5 new file mode 100644 index 0000000..c1ef193 --- /dev/null +++ b/app/ohos/oh-package.json5 @@ -0,0 +1,13 @@ +{ + "modelVersion": "5.1.0", + "name": "app", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {}, + "devDependencies": { + "@ohos/hypium": "1.0.6" + } +} diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 69ef8e4..9b28735 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -5,7 +5,7 @@ version: 1.0.0+1 resolution: workspace environment: - sdk: ^3.12.0 + sdk: ^3.11.0 dependencies: core_analytics: ^0.1.0 @@ -23,7 +23,7 @@ dependencies: sdk: flutter flutter_localizations: sdk: flutter - flutter_riverpod: ^3.3.2 + flutter_riverpod: 3.2.1 intl: any native_scan: ^0.1.0 sentry_flutter: ^9.26.0 diff --git a/docs/01-project-structure.md b/docs/01-project-structure.md index 6589b0d..b729f8e 100644 --- a/docs/01-project-structure.md +++ b/docs/01-project-structure.md @@ -81,7 +81,7 @@ conti-app/ | 项 | 版本 | 说明 | |---|---|---| | Flutter | **3.44.9** | 用 [FVM](https://fvm.app/) 锁定,仓库根目录提交 `.fvmrc` | -| Dart | 随 Flutter 3.44.9 附带(3.12.x) | 具体号以 `flutter --version` 实测为准;`environment: sdk: ^3.12.0` 对整个 3.12.x 都成立 | +| Dart | 随 Flutter 3.44.9 附带(3.12.x) | 具体号以 `flutter --version` 实测为准;`environment: sdk: ^3.11.0` 对整个 3.12.x 都成立 | **为什么不跟最新 stable(3.47.0 / Dart 3.13.0,2026-08-12 发布)**:鸿蒙(OpenHarmony)的 Flutter 分支适配落后于官方 stable 一段时间,虽然 OHOS 不在首版范围(见 [07-native-integration.md](./07-native-integration.md) 的「OHOS 后续演进」),但 SDK 基线要为后续接 OHOS 留出兼容窗口,所以刻意停在 3.44.9 而不是追最新。这条约束在决定升级 Flutter 版本时必须重新评估,不要因为"新版本有新特性"就单方面升。 @@ -109,7 +109,7 @@ Melos 7.0 起改用 Dart 官方原生的 **[Pub Workspaces](https://dart.dev/too name: conti_app publish_to: none environment: - sdk: ^3.12.0 + sdk: ^3.11.0 workspace: - app diff --git a/docs/07-native-integration.md b/docs/07-native-integration.md index 8ba96fc..af304c8 100644 --- a/docs/07-native-integration.md +++ b/docs/07-native-integration.md @@ -44,7 +44,7 @@ name: native_scan resolution: workspace environment: - sdk: ^3.12.0 + sdk: ^3.11.0 flutter: '>=3.44.0' flutter: diff --git a/enable-ohos.ps1 b/enable-ohos.ps1 new file mode 100644 index 0000000..93b6b8f --- /dev/null +++ b/enable-ohos.ps1 @@ -0,0 +1,46 @@ +# Enables the OpenHarmony Flutter toolchain for the current PowerShell session. +# This script does not change the system or user PATH permanently. + +$ErrorActionPreference = 'Stop' + +$flutterBin = 'C:\Users\A200477427\Developments\flutter_flutter\bin' +$devecoHome = 'C:\Program Files\Huawei\DevEco Studio' +$devecoSdk = "$devecoHome\sdk" +$ohpmBin = "$devecoHome\tools\ohpm\bin" +$hvigorBin = "$devecoHome\tools\hvigor\bin" + +$requiredDirectories = @($flutterBin, $devecoSdk, $ohpmBin, $hvigorBin) +$missingDirectories = $requiredDirectories | Where-Object { + -not (Test-Path -LiteralPath $_ -PathType Container) +} + +if ($missingDirectories) { + throw "OpenHarmony tool directories were not found:`n$($missingDirectories -join "`n")" +} + +# Set these only for this terminal. This also makes the script work in a terminal +# that was opened before the corresponding Windows environment variables existed. +$env:DEVECO_HOME = $devecoHome +$env:DEVECO_SDK_HOME = $devecoSdk + +# Put the OpenHarmony-specific commands first for this terminal only. Remove +# duplicate entries so repeated execution of this script leaves PATH clean. +$pathDirectories = @($flutterBin, $ohpmBin, $hvigorBin) +$pathEntries = $env:Path -split ';' | Where-Object { + $_ -and $_ -notin $pathDirectories +} +$env:Path = ($pathDirectories + $pathEntries) -join ';' + +$commands = @('flutter', 'ohpm', 'hvigorw') +$unavailableCommands = foreach ($command in $commands) { + if (-not (Get-Command $command -ErrorAction SilentlyContinue)) { + $command + } +} + +if ($unavailableCommands) { + throw "The following commands could not be resolved from PATH: $($unavailableCommands -join ', ')" +} + +Write-Host 'OpenHarmony Flutter environment is enabled for this PowerShell session.' -ForegroundColor Green +Get-Command $commands | Select-Object Name, Source, CommandType | Format-Table -AutoSize diff --git a/packages/core_analytics/pubspec.yaml b/packages/core_analytics/pubspec.yaml index 04e8268..ce6f72a 100644 --- a/packages/core_analytics/pubspec.yaml +++ b/packages/core_analytics/pubspec.yaml @@ -5,13 +5,13 @@ version: 0.1.0 resolution: workspace environment: - sdk: ^3.12.0 + sdk: ^3.11.0 dependencies: core_foundation: ^0.1.0 flutter: sdk: flutter - flutter_riverpod: ^3.3.2 + flutter_riverpod: 3.2.1 dev_dependencies: flutter_lints: ^6.0.0 diff --git a/packages/core_auth/pubspec.yaml b/packages/core_auth/pubspec.yaml index 822d321..00339ed 100644 --- a/packages/core_auth/pubspec.yaml +++ b/packages/core_auth/pubspec.yaml @@ -11,16 +11,18 @@ resolution: workspace # 因此本包里的 token 刷新用的是一个**不带任何拦截器的裸 Dio**。 # --------------------------------------------------------------------------- environment: - sdk: ^3.12.0 + sdk: ^3.11.0 dependencies: core_foundation: ^0.1.0 dio: ^5.11.0 flutter: sdk: flutter - flutter_riverpod: ^3.3.2 + flutter_riverpod: 3.2.1 flutter_secure_storage: ^11.0.0 - riverpod_annotation: ^4.0.3 + # 4.0.3+ 的 generator 引入 analyzer ^12,要求 meta ^1.18; + # Harmony Flutter(Dart 3.11)固定 meta 1.17.0,故保持在兼容组合。 + riverpod_annotation: 4.0.2 dev_dependencies: build_runner: ^2.4.13 @@ -28,4 +30,4 @@ dev_dependencies: flutter_test: sdk: flutter mocktail: ^1.0.5 - riverpod_generator: ^4.0.4 + riverpod_generator: 4.0.3 diff --git a/packages/core_foundation/pubspec.yaml b/packages/core_foundation/pubspec.yaml index 7f1e5ae..ae75a94 100644 --- a/packages/core_foundation/pubspec.yaml +++ b/packages/core_foundation/pubspec.yaml @@ -5,12 +5,12 @@ version: 0.1.0 resolution: workspace environment: - sdk: ^3.12.0 + sdk: ^3.11.0 dependencies: flutter: sdk: flutter - flutter_riverpod: ^3.3.2 + flutter_riverpod: 3.2.1 dev_dependencies: flutter_lints: ^6.0.0 diff --git a/packages/core_logging/pubspec.yaml b/packages/core_logging/pubspec.yaml index 77d8cbc..c60bd1c 100644 --- a/packages/core_logging/pubspec.yaml +++ b/packages/core_logging/pubspec.yaml @@ -5,13 +5,13 @@ version: 0.1.0 resolution: workspace environment: - sdk: ^3.12.0 + sdk: ^3.11.0 dependencies: core_foundation: ^0.1.0 flutter: sdk: flutter - flutter_riverpod: ^3.3.2 + flutter_riverpod: 3.2.1 logger: ^2.7.0 sentry_flutter: ^9.26.0 diff --git a/packages/core_network/pubspec.yaml b/packages/core_network/pubspec.yaml index 53d165e..4594546 100644 --- a/packages/core_network/pubspec.yaml +++ b/packages/core_network/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.1.0 resolution: workspace environment: - sdk: ^3.12.0 + sdk: ^3.11.0 dependencies: core_auth: ^0.1.0 @@ -13,7 +13,7 @@ dependencies: dio: ^5.11.0 flutter: sdk: flutter - flutter_riverpod: ^3.3.2 + flutter_riverpod: 3.2.1 path: ^1.9.1 uuid: ^4.5.1 diff --git a/packages/core_router/pubspec.yaml b/packages/core_router/pubspec.yaml index 2b0a37a..043bb30 100644 --- a/packages/core_router/pubspec.yaml +++ b/packages/core_router/pubspec.yaml @@ -8,14 +8,14 @@ resolution: workspace # 注意:本包**不**依赖任何 feature_*。feature 路由由 app/ 通过 appRoutesProvider 注入, # 详见 lib/src/app_router.dart 顶部注释与 SCAFFOLD-NOTES.md §G。 environment: - sdk: ^3.12.0 + sdk: ^3.11.0 dependencies: core_auth: ^0.1.0 core_foundation: ^0.1.0 flutter: sdk: flutter - flutter_riverpod: ^3.3.2 + flutter_riverpod: 3.2.1 go_router: ^17.5.0 dev_dependencies: diff --git a/packages/core_storage/pubspec.yaml b/packages/core_storage/pubspec.yaml index 130e851..11a1350 100644 --- a/packages/core_storage/pubspec.yaml +++ b/packages/core_storage/pubspec.yaml @@ -12,13 +12,13 @@ resolution: workspace # 连带收益:去掉 drift_dev 后 melos 可以留在 8.x(drift_dev 2.34.0 依赖 # cli_util ^0.4.0,与 melos 8 的 ^0.5.0 互斥)。详见 SCAFFOLD-NOTES.md §A。 environment: - sdk: ^3.12.0 + sdk: ^3.11.0 dependencies: core_foundation: ^0.1.0 flutter: sdk: flutter - flutter_riverpod: ^3.3.2 + flutter_riverpod: 3.2.1 shared_preferences: ^2.5.5 dev_dependencies: diff --git a/packages/core_ui/pubspec.yaml b/packages/core_ui/pubspec.yaml index aaa88ac..d349ee6 100644 --- a/packages/core_ui/pubspec.yaml +++ b/packages/core_ui/pubspec.yaml @@ -5,13 +5,13 @@ version: 0.1.0 resolution: workspace environment: - sdk: ^3.12.0 + sdk: ^3.11.0 dependencies: core_foundation: ^0.1.0 flutter: sdk: flutter - flutter_riverpod: ^3.3.2 + flutter_riverpod: 3.2.1 dev_dependencies: flutter_lints: ^6.0.0 diff --git a/packages/core_webview/pubspec.yaml b/packages/core_webview/pubspec.yaml index 0580b78..57e2c7a 100644 --- a/packages/core_webview/pubspec.yaml +++ b/packages/core_webview/pubspec.yaml @@ -8,14 +8,14 @@ resolution: workspace # 「用 target 换真实 URL」的接口调用**不在本包**——那需要 core_network,不是允许的边。 # 换票由调用方(feature)完成后把 URL 传进来,本包只负责校验和承载。 environment: - sdk: ^3.12.0 + sdk: ^3.11.0 dependencies: core_auth: ^0.1.0 core_foundation: ^0.1.0 flutter: sdk: flutter - flutter_riverpod: ^3.3.2 + flutter_riverpod: 3.2.1 webview_flutter: ^4.14.1 dev_dependencies: diff --git a/packages/feature_auth/pubspec.yaml b/packages/feature_auth/pubspec.yaml index 3e5b252..870e14f 100644 --- a/packages/feature_auth/pubspec.yaml +++ b/packages/feature_auth/pubspec.yaml @@ -8,7 +8,7 @@ resolution: workspace # - 这里不出现任何另一个 feature_*(feature 间禁止互相依赖,见 01) # - 这里不直接出现 go_router(路由类型由 core_router re-export,见 04) environment: - sdk: ^3.12.0 + sdk: ^3.11.0 dependencies: core_auth: ^0.1.0 @@ -18,8 +18,9 @@ dependencies: core_ui: ^0.1.0 flutter: sdk: flutter - flutter_riverpod: ^3.3.2 - riverpod_annotation: ^4.0.3 + flutter_riverpod: 3.2.1 + # 与 riverpod_generator 4.0.3 配套,兼容 Harmony Flutter 固定的 meta 1.17.0。 + riverpod_annotation: 4.0.2 dev_dependencies: build_runner: ^2.4.13 @@ -27,4 +28,4 @@ dev_dependencies: flutter_test: sdk: flutter mocktail: ^1.0.5 - riverpod_generator: ^4.0.4 + riverpod_generator: 4.0.3 diff --git a/packages/feature_home/pubspec.yaml b/packages/feature_home/pubspec.yaml index 8a955f2..667e8e0 100644 --- a/packages/feature_home/pubspec.yaml +++ b/packages/feature_home/pubspec.yaml @@ -9,7 +9,7 @@ resolution: workspace # "需要" 登录信息,但它拿的是 core_auth 的会话状态,不是 feature_auth 的页面 # - 这里不直接出现 go_router(路由类型由 core_router re-export,见 04) environment: - sdk: ^3.12.0 + sdk: ^3.11.0 dependencies: core_analytics: ^0.1.0 @@ -20,8 +20,9 @@ dependencies: core_ui: ^0.1.0 flutter: sdk: flutter - flutter_riverpod: ^3.3.2 - riverpod_annotation: ^4.0.3 + flutter_riverpod: 3.2.1 + # 与 riverpod_generator 4.0.3 配套,兼容 Harmony Flutter 固定的 meta 1.17.0。 + riverpod_annotation: 4.0.2 dev_dependencies: build_runner: ^2.4.13 @@ -29,4 +30,4 @@ dev_dependencies: flutter_test: sdk: flutter mocktail: ^1.0.5 - riverpod_generator: ^4.0.4 + riverpod_generator: 4.0.3 diff --git a/packages/native_scan/example/pubspec.yaml b/packages/native_scan/example/pubspec.yaml index 31c2f72..c8469a2 100644 --- a/packages/native_scan/example/pubspec.yaml +++ b/packages/native_scan/example/pubspec.yaml @@ -4,7 +4,7 @@ publish_to: none resolution: workspace environment: - sdk: ^3.12.0 + sdk: ^3.11.0 dependencies: flutter: diff --git a/packages/native_scan/pubspec.yaml b/packages/native_scan/pubspec.yaml index 6c655c5..1432cfa 100644 --- a/packages/native_scan/pubspec.yaml +++ b/packages/native_scan/pubspec.yaml @@ -10,7 +10,7 @@ resolution: workspace # 因此本包抛的是包内自定义的 NativeScanException,由调用方转成 NativeException。 # --------------------------------------------------------------------------- environment: - sdk: ^3.12.0 + sdk: ^3.11.0 dependencies: flutter: @@ -20,7 +20,9 @@ dev_dependencies: flutter_lints: ^6.0.0 flutter_test: sdk: flutter - pigeon: ^27.3.0 + # 27.x 需要 analyzer >=10,与 Harmony 兼容的 riverpod_generator 4.0.3 + # (analyzer ^9)不能共存;26.3.1 同时兼容 Dart 3.11 与 analyzer 9。 + pigeon: 26.3.1 flutter: plugin: diff --git a/pubspec.lock b/pubspec.lock index ad8f4a4..60029c2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,26 +5,26 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: a49d6cf99e8d8e7a8e93668d09ced0bbdb954d0b4fccc2f5f9241c6b87fad95c + sha256: "5b7468c326d2f8a4f630056404ca0d291ade42918f4a3c6233618e724f39da8e" url: "https://pub.dev" source: hosted - version: "99.0.0" + version: "92.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: "663efa951fb8a45e06f491223a604c93820598f20e6a99c25617a1576065e8b7" + sha256: "70e4b1ef8003c64793a9e268a551a82869a8a96f39deb73dea28084b0e8bf75e" url: "https://pub.dev" source: hosted - version: "12.1.0" + version: "9.0.0" analyzer_buffer: dependency: transitive description: name: analyzer_buffer - sha256: "445b77e2054fa3e8c8a8ef1b5e9e6b23bb8028fffd34b5e60eaef315b7750674" + sha256: ff4bd291778c7417fe53fe24ee0d0a1f1ffe281a2d4ea887e7094f16e36eace7 url: "https://pub.dev" source: hosted - version: "0.3.3" + version: "0.3.0" ansi_styles: dependency: transitive description: @@ -229,10 +229,10 @@ packages: dependency: transitive description: name: dart_style - sha256: a4c1ccfee44c7e75ed80484071a5c142a385345e658fd8bd7c4b5c97e7198f98 + sha256: a9c30492da18ff84efe2422ba2d319a89942d93e58eb0b73d32abe822ef54b7b url: "https://pub.dev" source: hosted - version: "3.1.8" + version: "3.1.3" dio: dependency: transitive description: @@ -316,10 +316,10 @@ packages: dependency: transitive description: name: flutter_riverpod - sha256: "9255e1e3ad6e38906a1b4f8287678f95f378744c5b46b1985588543f3f19046e" + sha256: e2026c72738a925a60db30258ff1f29974e40716749f3c9850aabf34ffc1a14c url: "https://pub.dev" source: hosted - version: "3.3.2" + version: "3.2.1" flutter_secure_storage: dependency: transitive description: @@ -728,10 +728,10 @@ packages: dependency: transitive description: name: pigeon - sha256: f90254ef7b22db026fd8d5fd44718fd60697d50968a144a8bc251e5e95d79e10 + sha256: "7afad261c00755491a69de151009fb41fda003e69205e16ba0c354c352c2de62" url: "https://pub.dev" source: hosted - version: "27.3.0" + version: "26.3.1" platform: dependency: transitive description: @@ -816,34 +816,34 @@ packages: dependency: transitive description: name: riverpod - sha256: "17100416c51db7810c71a7bb2c34d1f881faa0074fd452afb0c4db6f8f126c76" + sha256: "8c22216be8ad3ef2b44af3a329693558c98eca7b8bd4ef495c92db0bba279f83" url: "https://pub.dev" source: hosted - version: "3.3.2" + version: "3.2.1" riverpod_analyzer_utils: dependency: transitive description: name: riverpod_analyzer_utils - sha256: "3e275138862ccc22ed61444a1f9a840f753094c367f28f4123f50289cd204d68" + sha256: e55bc08c084a424e1bbdc303fe8ea75daafe4269b68fd0e0f6f1678413715b66 url: "https://pub.dev" source: hosted - version: "1.0.0-dev.10" + version: "1.0.0-dev.9" riverpod_annotation: dependency: transitive description: name: riverpod_annotation - sha256: "674dbb26e2db3d9253166faf4758c796af14146b8fbcf5e7102bc8a04cd359b8" + sha256: "16471a1260b94e939394d78f1c63a9350936ac4a68c9fbdab40be47268c0b04f" url: "https://pub.dev" source: hosted - version: "4.0.3" + version: "4.0.2" riverpod_generator: dependency: transitive description: name: riverpod_generator - sha256: "54d790c3fee1ae281c448801bfdbfaa9fd961a9d3998494e0fcd9ee32184d7eb" + sha256: "6f9220534d7a353b53c875ea191a84d28cb4e52ac420a66a1bd7318329d977b0" url: "https://pub.dev" source: hosted - version: "4.0.4" + version: "4.0.3" sentry: dependency: transitive description: @@ -880,10 +880,10 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: "0634e64bd719f89c012f392938e173521f535d3ecaf66558fa94a056d22b5cc7" + sha256: e8d4762b1e2e8578fc4d0fd548cebf24afd24f49719c08974df92834565e2c53 url: "https://pub.dev" source: hosted - version: "2.4.27" + version: "2.4.23" shared_preferences_foundation: dependency: transitive description: @@ -1173,10 +1173,10 @@ packages: dependency: transitive description: name: webview_flutter_android - sha256: b98656fa4461f8cc05c48a778b4d4883e60ec63e1778348f363f9bb9a477745d + sha256: ad5182eff9a550925330cb9f0cb038eddfdd5712aba8b77aa0f0400e50f6e688 url: "https://pub.dev" source: hosted - version: "4.14.0" + version: "4.12.0" webview_flutter_platform_interface: dependency: transitive description: @@ -1189,10 +1189,10 @@ packages: dependency: transitive description: name: webview_flutter_wkwebview - sha256: c879dd64b87c452aa84381b244d5469da57ba7e8cca6884c7b1e0d406372c12d + sha256: "82648217f537573e1ca9ae9952d3eacedca6ab5aee69dc84445fc763766dcea2" url: "https://pub.dev" source: hosted - version: "3.26.0" + version: "3.25.1" win32: dependency: transitive description: @@ -1234,5 +1234,5 @@ packages: source: hosted version: "2.2.4" sdks: - dart: ">=3.12.0 <4.0.0" - flutter: ">=3.44.0" + dart: ">=3.11.0 <4.0.0" + flutter: ">=3.38.4" diff --git a/pubspec.yaml b/pubspec.yaml index 82c8394..88e46f2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ name: conti_retail_app publish_to: none environment: - sdk: ^3.12.0 + sdk: ^3.11.0 # --------------------------------------------------------------------------- # 工作区成员。新增包时必须同步加到这里,否则 melos bootstrap 看不到它。