已合并
代码优化 #3
sfchu创建于 7月10日
代码优化 #3
已合并
共 12 个文件变更+274-174
| @@ -62,10 +62,10 @@ | |||
| 62 | │ │ └──WidthBreakpointType.ets // 断点宽度类型工具类 | 62 | │ │ └──WidthBreakpointType.ets // 断点宽度类型工具类 |
| 63 | │ ├──view | 63 | │ ├──view |
| 64 | │ │ ├──AddPicView.ets // 添加图片组件 | 64 | │ │ ├──AddPicView.ets // 添加图片组件 |
| 65 | -│ │ ├──MigrateDataWantParamView.ets // want.param迁移页面 | ||
| 66 | │ │ ├──MigrateDataDistributedBaseView.ets // 分布式对象基础数据迁移页面 | 65 | │ │ ├──MigrateDataDistributedBaseView.ets // 分布式对象基础数据迁移页面 |
| 67 | │ │ ├──MigrateDataDistributedMonoFileView.ets // 分布式对象单文件迁移页面 | 66 | │ │ ├──MigrateDataDistributedMonoFileView.ets // 分布式对象单文件迁移页面 |
| 68 | -│ │ └──MigrateDataDistributedMultiFileView.ets // 分布式对象多文件迁移页面 | 67 | +│ │ ├──MigrateDataDistributedMultiFileView.ets // 分布式对象多文件迁移页面 |
| 68 | +│ │ └──MigrateDataWantParamView.ets // want.param迁移页面 | ||
| 69 | │ └──viewModel | 69 | │ └──viewModel |
| 70 | │ └──AddPicViewModel.ets // 图片添加与处理业务逻辑 | 70 | │ └──AddPicViewModel.ets // 图片添加与处理业务逻辑 |
| 71 | └──entry/src/main/resources // 应用资源目录 | 71 | └──entry/src/main/resources // 应用资源目录 |
| @@ -81,7 +81,7 @@ | |||
| 81 | 81 | ||
| 82 | ## 约束与限制 | 82 | ## 约束与限制 |
| 83 | 83 | ||
| 84 | -1. 本示例仅支持标准系统上运行,支持设备:直板机。 | 84 | +1. 本示例仅支持标准系统上运行,支持设备:直板机、双折叠、阔折叠、三折叠、平板、PC/2in1。 |
| 85 | 85 | ||
| 86 | 2. HarmonyOS系统:HarmonyOS 6.1.0 Release及以上。 | 86 | 2. HarmonyOS系统:HarmonyOS 6.1.0 Release及以上。 |
| 87 | 87 | ||
| @@ -34,4 +34,8 @@ export default class CommonConstants { | |||
| 34 | ]; | 34 | ]; |
| 35 | public static readonly FULL_PERCENT: string = '100%'; | 35 | public static readonly FULL_PERCENT: string = '100%'; |
| 36 | public static readonly IMAGE_WIDTH_HEIGHT: number = 113; | 36 | public static readonly IMAGE_WIDTH_HEIGHT: number = 113; |
| 37 | + public static readonly TEXT_INPUT_HEIGHT: number = 40; | ||
| 38 | + public static readonly DEBOUNCE_DELAY: number = 300; | ||
| 39 | + public static readonly PAGE_PADDING_HORIZONTAL: number = 16; | ||
| 40 | + public static readonly SECTION_MARGIN_TOP: number = 12; | ||
| 37 | } | 41 | } |
| @@ -28,6 +28,7 @@ const FORMAT = '%{public}s'; | |||
| 28 | // [Start WantParamSource] | 28 | // [Start WantParamSource] |
| 29 | // [Start WantParamFace] | 29 | // [Start WantParamFace] |
| 30 | // [Start DistributedBaseContinue] | 30 | // [Start DistributedBaseContinue] |
| 31 | +// [Start DistributedBaseRecover] | ||
| 31 | export default class EntryAbility extends UIAbility { | 32 | export default class EntryAbility extends UIAbility { |
| 32 | // [StartExclude WantParamSource] | 33 | // [StartExclude WantParamSource] |
| 33 | private distributedObject: distributedDataObject.DataObject | undefined = undefined; | 34 | private distributedObject: distributedDataObject.DataObject | undefined = undefined; |
| @@ -47,10 +48,12 @@ export default class EntryAbility extends UIAbility { | |||
| 47 | 48 | ||
| 48 | appContinuity(want: Want, launchParam: AbilityConstant.LaunchParam) { | 49 | appContinuity(want: Want, launchParam: AbilityConstant.LaunchParam) { |
| 49 | if (launchParam.launchReason === AbilityConstant.LaunchReason.CONTINUATION) { | 50 | if (launchParam.launchReason === AbilityConstant.LaunchReason.CONTINUATION) { |
| 51 | + // [StartExclude DistributedBaseRecover] | ||
| 50 | if (want.parameters !== undefined) { | 52 | if (want.parameters !== undefined) { |
| 51 | // Use want.param to migrate the simple data page data | 53 | // Use want.param to migrate the simple data page data |
| 52 | AppStorage.setOrCreate('wantBasicData', want.parameters.wantBasicData); | 54 | AppStorage.setOrCreate('wantBasicData', want.parameters.wantBasicData); |
| 53 | } | 55 | } |
| 56 | + // [EndExclude DistributedBaseRecover] | ||
| 54 | // [StartExclude WantParamFace] | 57 | // [StartExclude WantParamFace] |
| 55 | let mailInfo: ContinuationData = new ContinuationData(undefined, undefined, undefined, undefined, undefined, | 58 | let mailInfo: ContinuationData = new ContinuationData(undefined, undefined, undefined, undefined, undefined, |
| 56 | undefined, undefined, undefined, undefined, undefined); | 59 | undefined, undefined, undefined, undefined, undefined); |
| @@ -64,29 +67,35 @@ export default class EntryAbility extends UIAbility { | |||
| 64 | return; | 67 | return; |
| 65 | } | 68 | } |
| 66 | // Use the distributed object migration to transfer the basic page data | 69 | // Use the distributed object migration to transfer the basic page data |
| 67 | - AppStorage.setOrCreate('basicDataStr', this.distributedObject['basicDataStr']); | 70 | + AppStorage.setOrCreate('basicDataStr', this.distributedObject['basicDataStr'] ?? ''); |
| 68 | - AppStorage.setOrCreate('basicDataNum', this.distributedObject['basicDataNum']); | 71 | + AppStorage.setOrCreate('basicDataNum', this.distributedObject['basicDataNum'] ?? undefined); |
| 69 | - AppStorage.setOrCreate('distributedData', this.distributedObject['distributedData']); | 72 | + AppStorage.setOrCreate('distributedData', this.distributedObject['distributedData'] ?? undefined); |
| 73 | + // [StartExclude DistributedBaseRecover] | ||
| 70 | // Migrate page data using distributed object single-file migration | 74 | // Migrate page data using distributed object single-file migration |
| 71 | - AppStorage.setOrCreate('monoFileStr', this.distributedObject['monoFileStr']); | 75 | + AppStorage.setOrCreate('monoFileStr', this.distributedObject['monoFileStr'] ?? ''); |
| 72 | - AppStorage.setOrCreate('monoFileNum', this.distributedObject['monoFileNum']); | 76 | + AppStorage.setOrCreate('monoFileNum', this.distributedObject['monoFileNum'] ?? undefined); |
| 73 | - AppStorage.setOrCreate('attachment', this.distributedObject['attachment']); | 77 | + AppStorage.setOrCreate('attachment', this.distributedObject['attachment'] ?? []); |
| 74 | - let attachment = this.distributedObject['attachment'] as commonType.Assets; | 78 | + if (this.distributedObject['attachment'] as commonType.Assets !== undefined) { |
| 75 | - for (const attachments of attachment) { | 79 | + let attachment = this.distributedObject['attachment'] as commonType.Assets; |
| 76 | - this.distributedFileUtil.fileCopy(attachments, true); | 80 | + for (const attachments of attachment) { |
| 81 | + this.distributedFileUtil.fileCopy(attachments, true); | ||
| 82 | + } | ||
| 77 | } | 83 | } |
| 78 | - AppStorage.setOrCreate<ImageInfo>('imageUri', this.distributedFileUtil.imageUri); | 84 | + AppStorage.setOrCreate<ImageInfo>('imageUri', this.distributedFileUtil.imageUri ?? undefined); |
| 79 | // Use the distributed object multi-file migration page data function | 85 | // Use the distributed object multi-file migration page data function |
| 80 | - AppStorage.setOrCreate('multiFileStr', this.distributedObject['multiFileStr']); | 86 | + AppStorage.setOrCreate('multiFileStr', this.distributedObject['multiFileStr'] ?? ''); |
| 81 | - AppStorage.setOrCreate('multiFileNum', this.distributedObject['multiFileNum']); | 87 | + AppStorage.setOrCreate('multiFileNum', this.distributedObject['multiFileNum'] ?? undefined); |
| 82 | - AppStorage.setOrCreate('attachments', this.distributedObject['attachments']); | 88 | + AppStorage.setOrCreate('attachments', this.distributedObject['attachments'] ?? []); |
| 83 | - let attachments = this.distributedObject['attachments'] as commonType.Assets; | 89 | + if (this.distributedObject['attachments'] as commonType.Assets !== undefined) { |
| 84 | - for (const attachment of attachments) { | 90 | + let attachments = this.distributedObject['attachments'] as commonType.Assets; |
| 85 | - this.distributedFileUtil.fileCopy(attachment); | 91 | + for (const attachment of attachments) { |
| 92 | + this.distributedFileUtil.fileCopy(attachment); | ||
| 93 | + } | ||
| 86 | } | 94 | } |
| 87 | - AppStorage.setOrCreate<Array<ImageInfo>>('imageUriArray', this.distributedFileUtil.imageUriArray); | 95 | + AppStorage.setOrCreate<Array<ImageInfo>>('imageUriArray', this.distributedFileUtil.imageUriArray ?? []); |
| 88 | // The name of the page routing for migration | 96 | // The name of the page routing for migration |
| 89 | - AppStorage.setOrCreate('curPageInfos', this.distributedObject['curPageInfos']); | 97 | + // [EndExclude DistributedBaseRecover] |
| 98 | + AppStorage.setOrCreate('curPageInfos', this.distributedObject['curPageInfos'] ?? undefined); | ||
| 90 | } | 99 | } |
| 91 | }); | 100 | }); |
| 92 | } catch (err) { | 101 | } catch (err) { |
| @@ -105,9 +114,11 @@ export default class EntryAbility extends UIAbility { | |||
| 105 | } | 114 | } |
| 106 | } | 115 | } |
| 107 | } | 116 | } |
| 117 | + | ||
| 108 | // [EndExclude DistributedBaseContinue] | 118 | // [EndExclude DistributedBaseContinue] |
| 109 | // [EndExclude WantParamSource] | 119 | // [EndExclude WantParamSource] |
| 110 | // [StartExclude WantParamFace] | 120 | // [StartExclude WantParamFace] |
| 121 | + // [StartExclude DistributedBaseRecover] | ||
| 111 | async onContinue(wantParam: Record<string, Object | undefined>): Promise<AbilityConstant.OnContinueResult> { | 122 | async onContinue(wantParam: Record<string, Object | undefined>): Promise<AbilityConstant.OnContinueResult> { |
| 112 | // [StartExclude WantParamSource] | 123 | // [StartExclude WantParamSource] |
| 113 | if (!this.distributedFileUtil) { | 124 | if (!this.distributedFileUtil) { |
| @@ -122,36 +133,51 @@ export default class EntryAbility extends UIAbility { | |||
| 122 | let sessionId: string = distributedDataObject.genSessionId(); | 133 | let sessionId: string = distributedDataObject.genSessionId(); |
| 123 | wantParam.distributedSessionId = sessionId; | 134 | wantParam.distributedSessionId = sessionId; |
| 124 | // [StartExclude DistributedBaseContinue] | 135 | // [StartExclude DistributedBaseContinue] |
| 136 | + // [Start UniFileDistributedFile] | ||
| 125 | let imageUri: ImageInfo | undefined = AppStorage.get<ImageInfo>('imageUri'); | 137 | let imageUri: ImageInfo | undefined = AppStorage.get<ImageInfo>('imageUri'); |
| 138 | + let asset: commonType.Assets | undefined; | ||
| 126 | if (imageUri !== undefined) { | 139 | if (imageUri !== undefined) { |
| 127 | this.distributedFileUtil.pixelMapToBuffer(imageUri); | 140 | this.distributedFileUtil.pixelMapToBuffer(imageUri); |
| 141 | + asset = this.distributedFileUtil.buildAssetsFromImageInfo(imageUri); | ||
| 128 | } | 142 | } |
| 129 | - let asset = this.distributedFileUtil.buildAssetsFromImageInfo(imageUri); | 143 | + // [StartExclude UniFileDistributedFile] |
| 144 | + // [Start MultiFileDistributedFile] | ||
| 130 | let imageUriArray: Array<ImageInfo> | undefined = AppStorage.get<Array<ImageInfo>>('imageUriArray'); | 145 | let imageUriArray: Array<ImageInfo> | undefined = AppStorage.get<Array<ImageInfo>>('imageUriArray'); |
| 131 | - if (imageUriArray !== undefined ) { | 146 | + |
| 147 | + let assets: commonType.Assets | undefined; | ||
| 148 | + if (imageUriArray !== undefined) { | ||
| 132 | imageUriArray.forEach((item: ImageInfo) => { | 149 | imageUriArray.forEach((item: ImageInfo) => { |
| 133 | this.distributedFileUtil?.pixelMapToBuffer(item); | 150 | this.distributedFileUtil?.pixelMapToBuffer(item); |
| 134 | }); | 151 | }); |
| 152 | + assets = this.distributedFileUtil.buildAssetsFromImageArray(AppStorage.get<Array<ImageInfo>>('imageUriArray')); | ||
| 135 | } | 153 | } |
| 136 | - let assets = | 154 | + |
| 137 | - this.distributedFileUtil.buildAssetsFromImageArray(AppStorage.get<Array<ImageInfo>>('imageUriArray')); | 155 | + // [EndExclude UniFileDistributedFile] |
| 138 | // [EndExclude DistributedBaseContinue] | 156 | // [EndExclude DistributedBaseContinue] |
| 139 | let contentInfo: ContinuationData = new ContinuationData( | 157 | let contentInfo: ContinuationData = new ContinuationData( |
| 140 | - AppStorage.get('basicDataStr'), | 158 | + // [StartExclude UniFileDistributedFile] |
| 141 | - AppStorage.get('basicDataNum'), | 159 | + // [StartExclude MultiFileDistributedFile] |
| 142 | - AppStorage.get('distributedData'), | 160 | + AppStorage.get('basicDataStr') ?? '', |
| 161 | + AppStorage.get('basicDataNum') ?? undefined, | ||
| 162 | + AppStorage.get('distributedData') ?? undefined, | ||
| 163 | + // [EndExclude UniFileDistributedFile] | ||
| 143 | // [StartExclude DistributedBaseContinue] | 164 | // [StartExclude DistributedBaseContinue] |
| 144 | - AppStorage.get('monoFileStr'), | 165 | + AppStorage.get('monoFileStr') ?? '', |
| 145 | - AppStorage.get('monoFileNum'), | 166 | + AppStorage.get('monoFileNum') ?? undefined, |
| 146 | asset, | 167 | asset, |
| 147 | - AppStorage.get('multiFileStr'), | 168 | + // [EndExclude MultiFileDistributedFile] |
| 148 | - AppStorage.get('multiFileNum'), | 169 | + // [StartExclude UniFileDistributedFile] |
| 170 | + AppStorage.get('multiFileStr') ?? '', | ||
| 171 | + AppStorage.get('multiFileNum') ?? undefined, | ||
| 149 | assets, | 172 | assets, |
| 173 | + // [EndExclude UniFileDistributedFile] | ||
| 150 | // [EndExclude DistributedBaseContinue] | 174 | // [EndExclude DistributedBaseContinue] |
| 151 | (AppStorage.get('pageInfos') as NavPathStack).getAllPathName()[0] | 175 | (AppStorage.get('pageInfos') as NavPathStack).getAllPathName()[0] |
| 152 | ); | 176 | ); |
| 153 | let source = contentInfo.flatAssets(); | 177 | let source = contentInfo.flatAssets(); |
| 154 | this.distributedObject = distributedDataObject.create(this.context, source); | 178 | this.distributedObject = distributedDataObject.create(this.context, source); |
| 179 | + // [End UniFileDistributedFile] | ||
| 180 | + // [End MultiFileDistributedFile] | ||
| 155 | this.distributedObject.setSessionId(sessionId).catch((err: BusinessError) => { | 181 | this.distributedObject.setSessionId(sessionId).catch((err: BusinessError) => { |
| 156 | hilog.info(DOMAIN, TAG, FORMAT, `SetSessionId failed. Cause code: ${err.code}`); | 182 | hilog.info(DOMAIN, TAG, FORMAT, `SetSessionId failed. Cause code: ${err.code}`); |
| 157 | }); | 183 | }); |
| @@ -195,10 +221,12 @@ export default class EntryAbility extends UIAbility { | |||
| 195 | // Ability has back to background | 221 | // Ability has back to background |
| 196 | hilog.info(DOMAIN, TAG, FORMAT, `Ability onBackground`); | 222 | hilog.info(DOMAIN, TAG, FORMAT, `Ability onBackground`); |
| 197 | } | 223 | } |
| 224 | + // [EndExclude DistributedBaseRecover] | ||
| 198 | // [EndExclude DistributedBaseContinue] | 225 | // [EndExclude DistributedBaseContinue] |
| 199 | // [EndExclude WantParamFace] | 226 | // [EndExclude WantParamFace] |
| 200 | // [EndExclude WantParamSource] | 227 | // [EndExclude WantParamSource] |
| 201 | } | 228 | } |
| 229 | +// [End DistributedBaseRecover] | ||
| 202 | // [End DistributedBaseContinue] | 230 | // [End DistributedBaseContinue] |
| 203 | // [End WantParamFace] | 231 | // [End WantParamFace] |
| 204 | // [End WantParamSource] | 232 | // [End WantParamSource] |
| @@ -24,8 +24,10 @@ export interface ImageInfo { | |||
| 24 | imagePixelMap: PixelMap; | 24 | imagePixelMap: PixelMap; |
| 25 | imageName: string; | 25 | imageName: string; |
| 26 | } | 26 | } |
| 27 | +// [Start DistributedMultiFile] | ||
| 27 | // [Start DistributedBaseData] | 28 | // [Start DistributedBaseData] |
| 28 | export class ContinuationData { | 29 | export class ContinuationData { |
| 30 | + // [StartExclude DistributedMultiFile] | ||
| 29 | public basicDataStr: string | undefined; | 31 | public basicDataStr: string | undefined; |
| 30 | public basicDataNum: number | undefined; | 32 | public basicDataNum: number | undefined; |
| 31 | public distributedData: DistributedData | undefined; | 33 | public distributedData: DistributedData | undefined; |
| @@ -33,12 +35,14 @@ export class ContinuationData { | |||
| 33 | public monoFileStr: string | undefined; | 35 | public monoFileStr: string | undefined; |
| 34 | public monoFileNum: number | undefined; | 36 | public monoFileNum: number | undefined; |
| 35 | public attachment: commonType.Assets | undefined; | 37 | public attachment: commonType.Assets | undefined; |
| 38 | + // [EndExclude DistributedMultiFile] | ||
| 36 | public multiFileStr: string | undefined; | 39 | public multiFileStr: string | undefined; |
| 37 | public multiFileNum: number | undefined; | 40 | public multiFileNum: number | undefined; |
| 38 | public attachments: commonType.Assets | undefined; | 41 | public attachments: commonType.Assets | undefined; |
| 39 | public curPageInfos: string | undefined; | 42 | public curPageInfos: string | undefined; |
| 40 | // [EndExclude DistributedBaseData] | 43 | // [EndExclude DistributedBaseData] |
| 41 | constructor( | 44 | constructor( |
| 45 | + // [StartExclude DistributedMultiFile] | ||
| 42 | basicDataStr: string | undefined, | 46 | basicDataStr: string | undefined, |
| 43 | basicDataNum: number | undefined, | 47 | basicDataNum: number | undefined, |
| 44 | distributedData: DistributedData | undefined, | 48 | distributedData: DistributedData | undefined, |
| @@ -46,12 +50,14 @@ export class ContinuationData { | |||
| 46 | monoFileStr: string | undefined, | 50 | monoFileStr: string | undefined, |
| 47 | monoFileNum: number | undefined, | 51 | monoFileNum: number | undefined, |
| 48 | attachment: commonType.Assets | undefined, | 52 | attachment: commonType.Assets | undefined, |
| 53 | + // [EndExclude DistributedMultiFile] | ||
| 49 | multiFileStr: string | undefined, | 54 | multiFileStr: string | undefined, |
| 50 | multiFileNum: number | undefined, | 55 | multiFileNum: number | undefined, |
| 51 | attachments: commonType.Assets | undefined, | 56 | attachments: commonType.Assets | undefined, |
| 52 | curPageInfos: string | undefined | 57 | curPageInfos: string | undefined |
| 53 | // [EndExclude DistributedBaseData] | 58 | // [EndExclude DistributedBaseData] |
| 54 | ) { | 59 | ) { |
| 60 | + // [StartExclude DistributedMultiFile] | ||
| 55 | this.basicDataStr = basicDataStr; | 61 | this.basicDataStr = basicDataStr; |
| 56 | this.basicDataNum = basicDataNum; | 62 | this.basicDataNum = basicDataNum; |
| 57 | this.distributedData = distributedData; | 63 | this.distributedData = distributedData; |
| @@ -59,6 +65,7 @@ export class ContinuationData { | |||
| 59 | this.monoFileStr = monoFileStr; | 65 | this.monoFileStr = monoFileStr; |
| 60 | this.monoFileNum = monoFileNum; | 66 | this.monoFileNum = monoFileNum; |
| 61 | this.attachment = attachment; | 67 | this.attachment = attachment; |
| 68 | + // [EndExclude DistributedMultiFile] | ||
| 62 | this.multiFileStr = multiFileStr; | 69 | this.multiFileStr = multiFileStr; |
| 63 | this.multiFileNum = multiFileNum; | 70 | this.multiFileNum = multiFileNum; |
| 64 | this.attachments = attachments; | 71 | this.attachments = attachments; |
| @@ -79,4 +86,5 @@ export class ContinuationData { | |||
| 79 | } | 86 | } |
| 80 | // [EndExclude DistributedBaseData] | 87 | // [EndExclude DistributedBaseData] |
| 81 | } | 88 | } |
| 89 | +// [End DistributedMultiFile] | ||
| 82 | // [End DistributedBaseData] | 90 | // [End DistributedBaseData] |
| @@ -33,7 +33,7 @@ export class DistributedFileUtil { | |||
| 33 | constructor(context: common.UIAbilityContext) { | 33 | constructor(context: common.UIAbilityContext) { |
| 34 | this.context = context; | 34 | this.context = context; |
| 35 | } | 35 | } |
| 36 | - | 36 | + // [Start CreateAsset] |
| 37 | getAssetInfo(append: ImageInfo): commonType.Asset | undefined { | 37 | getAssetInfo(append: ImageInfo): commonType.Asset | undefined { |
| 38 | let filePath = this.context.distributedFilesDir + '/' + append.imageName; | 38 | let filePath = this.context.distributedFilesDir + '/' + append.imageName; |
| 39 | let attachment: commonType.Asset; | 39 | let attachment: commonType.Asset; |
| @@ -55,6 +55,7 @@ export class DistributedFileUtil { | |||
| 55 | return undefined; | 55 | return undefined; |
| 56 | } | 56 | } |
| 57 | } | 57 | } |
| 58 | + // [End CreateAsset] | ||
| 58 | 59 | ||
| 59 | fileCopy(attachment: commonType.Asset, isUniFile?: boolean): void { | 60 | fileCopy(attachment: commonType.Asset, isUniFile?: boolean): void { |
| 60 | if (!canIUse('SystemCapability.DistributedDataManager.CommonType')) { | 61 | if (!canIUse('SystemCapability.DistributedDataManager.CommonType')) { |
| @@ -157,7 +158,7 @@ export class DistributedFileUtil { | |||
| 157 | hilog.error(DOMAIN, TAG, FORMAT, `PackToData failed. Cause code: ${err.code}`); | 158 | hilog.error(DOMAIN, TAG, FORMAT, `PackToData failed. Cause code: ${err.code}`); |
| 158 | }); | 159 | }); |
| 159 | } | 160 | } |
| 160 | - | 161 | + // [Start WriteDistributedFile] |
| 161 | writeDistributedFile(buf: ArrayBuffer, displayName: string): void { | 162 | writeDistributedFile(buf: ArrayBuffer, displayName: string): void { |
| 162 | let distributedDir: string = this.context.distributedFilesDir; | 163 | let distributedDir: string = this.context.distributedFilesDir; |
| 163 | let fileName: string = '/' + displayName; | 164 | let fileName: string = '/' + displayName; |
| @@ -180,4 +181,5 @@ export class DistributedFileUtil { | |||
| 180 | } | 181 | } |
| 181 | } | 182 | } |
| 182 | } | 183 | } |
| 184 | + // [End WriteDistributedFile] | ||
| 183 | } | 185 | } |
| @@ -26,7 +26,7 @@ const FORMAT = '%{public}s'; | |||
| 26 | 26 | ||
| 27 | @Component | 27 | @Component |
| 28 | export struct AddPicView { | 28 | export struct AddPicView { |
| 29 | - @StorageLink('imageUri') imageUri: ImageInfo | null = null; | 29 | + @StorageLink('imageUri') imageUri: ImageInfo | undefined = undefined; |
| 30 | @StorageLink('imageUriArray') imageUriArray: Array<ImageInfo> = []; | 30 | @StorageLink('imageUriArray') imageUriArray: Array<ImageInfo> = []; |
| 31 | @StorageLink('currentBreakpoint') currentBreakpoint: string = 'sm'; | 31 | @StorageLink('currentBreakpoint') currentBreakpoint: string = 'sm'; |
| 32 | @Link isSingleImage: boolean; | 32 | @Link isSingleImage: boolean; |
| @@ -108,7 +108,7 @@ export struct AddPicView { | |||
| 108 | SymbolGlyph($r('sys.symbol.plus')) | 108 | SymbolGlyph($r('sys.symbol.plus')) |
| 109 | .fontSize(26) | 109 | .fontSize(26) |
| 110 | .fontColor([$r('sys.color.font_primary')]) | 110 | .fontColor([$r('sys.color.font_primary')]) |
| 111 | - Text(this.viewModel.getButtonText(this.isSingleImage, this.imageUri !== null, this.imageUriArray.length)) | 111 | + Text(this.viewModel.getButtonText(this.isSingleImage, this.imageUriArray.length)) |
| 112 | .fontSize(12) | 112 | .fontSize(12) |
| 113 | .fontColor($r('app.color.text_font_gray')) | 113 | .fontColor($r('app.color.text_font_gray')) |
| 114 | .margin({ top: 8 }) | 114 | .margin({ top: 8 }) |
| @@ -26,61 +26,65 @@ export function migrateDataDistributedBaseViewBuilder() { | |||
| 26 | export struct MigrateDataDistributedBaseView { | 26 | export struct MigrateDataDistributedBaseView { |
| 27 | @StorageLink('basicDataStr') basicDataStr: string = ''; | 27 | @StorageLink('basicDataStr') basicDataStr: string = ''; |
| 28 | @StorageLink('basicDataNum') basicDataNum: number | null = null; | 28 | @StorageLink('basicDataNum') basicDataNum: number | null = null; |
| 29 | - @StorageLink('distributedData') distributedData: DistributedData = { str: '', num: null }; | 29 | + @StorageLink('distributedData') distributedDataProp: DistributedData | undefined = undefined; |
| 30 | - private debounceDelay: number = 300; | 30 | + @State distributedData: DistributedData = { str: '', num: null }; |
| 31 | + @State distributedDataStr: string = ''; | ||
| 32 | + @State distributedDataNum: number | null = null; | ||
| 33 | + | ||
| 34 | + aboutToAppear(): void { | ||
| 35 | + if (this.distributedDataProp) { | ||
| 36 | + this.distributedData = this.distributedDataProp; | ||
| 37 | + this.distributedDataStr = this.distributedData.str ?? ''; | ||
| 38 | + this.distributedDataNum = this.distributedData.num ?? null; | ||
| 39 | + } else { | ||
| 40 | + this.distributedData = { str: '', num: null }; | ||
| 41 | + this.distributedDataStr = ''; | ||
| 42 | + this.distributedDataNum = null; | ||
| 43 | + } | ||
| 44 | + } | ||
| 31 | 45 | ||
| 32 | build() { | 46 | build() { |
| 33 | NavDestination() { | 47 | NavDestination() { |
| 34 | - Column({ space: 12 }) { | 48 | + Column({ space: CommonConstants.SECTION_MARGIN_TOP }) { |
| 35 | - Text($r('app.string.basic_data')) | 49 | + this.SectionTitle($r('app.string.basic_data')) |
| 36 | - .alignSelf(ItemAlign.Start) | 50 | + this.TextInputField(this.basicDataStr, $r('app.string.input_text_data_to_migrate'), (value: string) => { |
| 37 | - .fontWeight(FontWeight.Medium) | 51 | + DebounceUtil.debounce('basicDataStr', () => { |
| 38 | - .margin({ top: 12 }) | 52 | + this.basicDataStr = value; |
| 39 | - TextInput({ text: this.basicDataStr, placeholder: $r('app.string.input_text_data_to_migrate') }) | 53 | + AppStorage.setOrCreate('basicDataStr', value); |
| 40 | - .width(CommonConstants.FULL_PERCENT) | 54 | + }, CommonConstants.DEBOUNCE_DELAY); |
| 41 | - .height(40) | 55 | + }) |
| 42 | - .onChange(((value: string) => { | 56 | + this.NumberInputField(this.basicDataNum, $r('app.string.input_number_data_to_migrate'), (value: string) => { |
| 43 | - DebounceUtil.debounce('basicDataStr', () => { | 57 | + DebounceUtil.debounce('basicDataNum', () => { |
| 44 | - this.basicDataStr = value; | 58 | + const num = Number(value); |
| 45 | - }, this.debounceDelay); | 59 | + const result = value && !isNaN(num) ? num : null; |
| 46 | - })) | 60 | + this.basicDataNum = result; |
| 47 | - TextInput({ text: `${this.basicDataNum}`, placeholder: $r('app.string.input_number_data_to_migrate') }) | 61 | + AppStorage.setOrCreate('basicDataNum', result); |
| 48 | - .type(InputType.Number) | 62 | + }, CommonConstants.DEBOUNCE_DELAY); |
| 49 | - .width(CommonConstants.FULL_PERCENT) | 63 | + }) |
| 50 | - .height(40) | 64 | + |
| 51 | - .onChange(((value: string) => { | 65 | + this.SectionTitle($r('app.string.data_object')) |
| 52 | - DebounceUtil.debounce('basicDataNum', () => { | 66 | + this.TextInputField(this.distributedDataStr, $r('app.string.input_text_data_to_migrate'), (value: string) => { |
| 53 | - const num = Number(value); | 67 | + DebounceUtil.debounce('distributedDataStr', () => { |
| 54 | - this.basicDataNum = value && !isNaN(num) ? num : null; | 68 | + this.distributedDataStr = value; |
| 55 | - }, this.debounceDelay); | 69 | + this.distributedData.str = value; |
| 56 | - })) | 70 | + AppStorage.setOrCreate('distributedData', this.distributedData); |
| 57 | - Text($r('app.string.data_object')) | 71 | + }, CommonConstants.DEBOUNCE_DELAY); |
| 58 | - .alignSelf(ItemAlign.Start) | 72 | + }) |
| 59 | - .fontWeight(FontWeight.Medium) | 73 | + this.NumberInputField(this.distributedDataNum, $r('app.string.input_number_data_to_migrate'), |
| 60 | - .margin({ top: 12 }) | 74 | + (value: string) => { |
| 61 | - TextInput({ text: this.distributedData.str, placeholder: $r('app.string.input_text_data_to_migrate') }) | ||
| 62 | - .width(CommonConstants.FULL_PERCENT) | ||
| 63 | - .height(40) | ||
| 64 | - .onChange(((value: string) => { | ||
| 65 | - DebounceUtil.debounce('distributedDataStr', () => { | ||
| 66 | - this.distributedData.str = value; | ||
| 67 | - }, this.debounceDelay); | ||
| 68 | - })) | ||
| 69 | - TextInput({ text: `${this.distributedData.num}`, placeholder: $r('app.string.input_number_data_to_migrate') }) | ||
| 70 | - .type(InputType.Number) | ||
| 71 | - .width(CommonConstants.FULL_PERCENT) | ||
| 72 | - .height(40) | ||
| 73 | - .onChange(((value: string) => { | ||
| 74 | DebounceUtil.debounce('distributedDataNum', () => { | 75 | DebounceUtil.debounce('distributedDataNum', () => { |
| 75 | const num = Number(value); | 76 | const num = Number(value); |
| 76 | - this.distributedData.num = value && !isNaN(num) ? num : null; | 77 | + const result = value && !isNaN(num) ? num : null; |
| 77 | - }, this.debounceDelay); | 78 | + this.distributedDataNum = result; |
| 78 | - })) | 79 | + this.distributedData.num = result; |
| 80 | + AppStorage.setOrCreate('distributedData', this.distributedData); | ||
| 81 | + }, CommonConstants.DEBOUNCE_DELAY); | ||
| 82 | + }) | ||
| 79 | } | 83 | } |
| 80 | .width(CommonConstants.FULL_PERCENT) | 84 | .width(CommonConstants.FULL_PERCENT) |
| 81 | .padding({ | 85 | .padding({ |
| 82 | - left: 16, | 86 | + left: CommonConstants.PAGE_PADDING_HORIZONTAL, |
| 83 | - right: 16 | 87 | + right: CommonConstants.PAGE_PADDING_HORIZONTAL |
| 84 | }) | 88 | }) |
| 85 | } | 89 | } |
| 86 | .title($r('app.string.migrate_data_distributed_base')) | 90 | .title($r('app.string.migrate_data_distributed_base')) |
| @@ -88,4 +92,29 @@ export struct MigrateDataDistributedBaseView { | |||
| 88 | .height(CommonConstants.FULL_PERCENT) | 92 | .height(CommonConstants.FULL_PERCENT) |
| 89 | .backgroundColor($r('app.color.page_background')) | 93 | .backgroundColor($r('app.color.page_background')) |
| 90 | } | 94 | } |
| 95 | + | ||
| 96 | + @Builder | ||
| 97 | + SectionTitle(title: Resource) { | ||
| 98 | + Text(title) | ||
| 99 | + .alignSelf(ItemAlign.Start) | ||
| 100 | + .fontWeight(FontWeight.Medium) | ||
| 101 | + .margin({ top: CommonConstants.SECTION_MARGIN_TOP }) | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + @Builder | ||
| 105 | + TextInputField(value: string, placeholder: Resource, onChange: (value: string) => void) { | ||
| 106 | + TextInput({ text: value, placeholder: placeholder }) | ||
| 107 | + .width(CommonConstants.FULL_PERCENT) | ||
| 108 | + .height(CommonConstants.TEXT_INPUT_HEIGHT) | ||
| 109 | + .onChange(onChange) | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + @Builder | ||
| 113 | + NumberInputField(value: number | null, placeholder: Resource, onChange: (value: string) => void) { | ||
| 114 | + TextInput({ text: `${value}`, placeholder: placeholder }) | ||
| 115 | + .type(InputType.Number) | ||
| 116 | + .width(CommonConstants.FULL_PERCENT) | ||
| 117 | + .height(CommonConstants.TEXT_INPUT_HEIGHT) | ||
| 118 | + .onChange(onChange) | ||
| 119 | + } | ||
| 91 | } | 120 | } |
| @@ -24,45 +24,36 @@ export function migrateDataDistributedMonoFileViewBuilder() { | |||
| 24 | 24 | ||
| 25 | @Component | 25 | @Component |
| 26 | export struct MigrateDataDistributedMonoFileView { | 26 | export struct MigrateDataDistributedMonoFileView { |
| 27 | - @State isSingleImage: boolean = true; | ||
| 28 | @StorageLink('monoFileStr') monoFileStr: string = ''; | 27 | @StorageLink('monoFileStr') monoFileStr: string = ''; |
| 29 | @StorageLink('monoFileNum') monoFileNum: number | null = null; | 28 | @StorageLink('monoFileNum') monoFileNum: number | null = null; |
| 30 | - private debounceDelay: number = 300; | 29 | + @State isSingleImage: boolean = true; |
| 31 | 30 | ||
| 32 | build() { | 31 | build() { |
| 33 | NavDestination() { | 32 | NavDestination() { |
| 34 | - Column({ space: 12 }) { | 33 | + Column({ space: CommonConstants.SECTION_MARGIN_TOP }) { |
| 35 | - Text($r('app.string.basic_data')) | 34 | + this.SectionTitle($r('app.string.basic_data')) |
| 36 | - .alignSelf(ItemAlign.Start) | 35 | + this.TextInputField(this.monoFileStr, $r('app.string.input_text_data_to_migrate'), (value: string) => { |
| 37 | - .fontWeight(FontWeight.Medium) | 36 | + DebounceUtil.debounce('monoFileStr', () => { |
| 38 | - .margin({ top: 12 }) | 37 | + this.monoFileStr = value; |
| 39 | - TextInput({ text: this.monoFileStr, placeholder: $r('app.string.input_text_data_to_migrate') }) | 38 | + AppStorage.setOrCreate('monoFileStr', value); |
| 40 | - .width(CommonConstants.FULL_PERCENT) | 39 | + }, CommonConstants.DEBOUNCE_DELAY); |
| 41 | - .height(40) | 40 | + }) |
| 42 | - .onChange(((value: string) => { | 41 | + this.NumberInputField(this.monoFileNum, $r('app.string.input_number_data_to_migrate'), (value: string) => { |
| 43 | - DebounceUtil.debounce('monoFileStr', () => { | 42 | + DebounceUtil.debounce('monoFileNum', () => { |
| 44 | - this.monoFileStr = value; | 43 | + const num = Number(value); |
| 45 | - }, this.debounceDelay); | 44 | + const result = value && !isNaN(num) ? num : null; |
| 46 | - })) | 45 | + this.monoFileNum = result; |
| 47 | - TextInput({ text: `${this.monoFileNum}`, placeholder: $r('app.string.input_number_data_to_migrate') }) | 46 | + AppStorage.setOrCreate('monoFileNum', result); |
| 48 | - .type(InputType.Number) | 47 | + }, CommonConstants.DEBOUNCE_DELAY); |
| 49 | - .width(CommonConstants.FULL_PERCENT) | 48 | + }) |
| 50 | - .height(40) | 49 | + |
| 51 | - .onChange(((value: string) => { | 50 | + this.SectionTitle($r('app.string.image_file')) |
| 52 | - DebounceUtil.debounce('monoFileNum', () => { | ||
| 53 | - const num = Number(value); | ||
| 54 | - this.monoFileNum = value && !isNaN(num) ? num : null; | ||
| 55 | - }, this.debounceDelay); | ||
| 56 | - })) | ||
| 57 | - Text($r('app.string.image_file')) | ||
| 58 | - .alignSelf(ItemAlign.Start) | ||
| 59 | - .fontWeight(FontWeight.Medium) | ||
| 60 | AddPicView({ isSingleImage: this.isSingleImage }) | 51 | AddPicView({ isSingleImage: this.isSingleImage }) |
| 61 | } | 52 | } |
| 62 | .width(CommonConstants.FULL_PERCENT) | 53 | .width(CommonConstants.FULL_PERCENT) |
| 63 | .padding({ | 54 | .padding({ |
| 64 | - left: 16, | 55 | + left: CommonConstants.PAGE_PADDING_HORIZONTAL, |
| 65 | - right: 16 | 56 | + right: CommonConstants.PAGE_PADDING_HORIZONTAL |
| 66 | }) | 57 | }) |
| 67 | } | 58 | } |
| 68 | .title($r('app.string.migrate_data_distributed_mono_file')) | 59 | .title($r('app.string.migrate_data_distributed_mono_file')) |
| @@ -70,4 +61,29 @@ export struct MigrateDataDistributedMonoFileView { | |||
| 70 | .height(CommonConstants.FULL_PERCENT) | 61 | .height(CommonConstants.FULL_PERCENT) |
| 71 | .backgroundColor($r('app.color.page_background')) | 62 | .backgroundColor($r('app.color.page_background')) |
| 72 | } | 63 | } |
| 64 | + | ||
| 65 | + @Builder | ||
| 66 | + SectionTitle(title: Resource) { | ||
| 67 | + Text(title) | ||
| 68 | + .alignSelf(ItemAlign.Start) | ||
| 69 | + .fontWeight(FontWeight.Medium) | ||
| 70 | + .margin({ top: CommonConstants.SECTION_MARGIN_TOP }) | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + @Builder | ||
| 74 | + TextInputField(value: string, placeholder: Resource, onChange: (value: string) => void) { | ||
| 75 | + TextInput({ text: value, placeholder: placeholder }) | ||
| 76 | + .width(CommonConstants.FULL_PERCENT) | ||
| 77 | + .height(CommonConstants.TEXT_INPUT_HEIGHT) | ||
| 78 | + .onChange(onChange) | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + @Builder | ||
| 82 | + NumberInputField(value: number | null, placeholder: Resource, onChange: (value: string) => void) { | ||
| 83 | + TextInput({ text: `${value}`, placeholder: placeholder }) | ||
| 84 | + .type(InputType.Number) | ||
| 85 | + .width(CommonConstants.FULL_PERCENT) | ||
| 86 | + .height(CommonConstants.TEXT_INPUT_HEIGHT) | ||
| 87 | + .onChange(onChange) | ||
| 88 | + } | ||
| 73 | } | 89 | } |
| @@ -24,45 +24,34 @@ export function migrateDataDistributedMultiFileViewBuilder() { | |||
| 24 | 24 | ||
| 25 | @Component | 25 | @Component |
| 26 | export struct MigrateDataDistributedMultiFileView { | 26 | export struct MigrateDataDistributedMultiFileView { |
| 27 | - @State isSingleImage: boolean = false; | ||
| 28 | @StorageLink('multiFileStr') multiFileStr: string = ''; | 27 | @StorageLink('multiFileStr') multiFileStr: string = ''; |
| 29 | @StorageLink('multiFileNum') multiFileNum: number | null = null; | 28 | @StorageLink('multiFileNum') multiFileNum: number | null = null; |
| 30 | - private debounceDelay: number = 300; | 29 | + @State isSingleImage: boolean = false; |
| 31 | 30 | ||
| 32 | build() { | 31 | build() { |
| 33 | NavDestination() { | 32 | NavDestination() { |
| 34 | - Column({ space: 12 }) { | 33 | + Column({ space: CommonConstants.SECTION_MARGIN_TOP }) { |
| 35 | - Text($r('app.string.basic_data')) | 34 | + this.SectionTitle($r('app.string.basic_data')) |
| 36 | - .alignSelf(ItemAlign.Start) | 35 | + this.TextInputField(this.multiFileStr, $r('app.string.input_text_data_to_migrate'), (value: string) => { |
| 37 | - .fontWeight(FontWeight.Medium) | 36 | + DebounceUtil.debounce('multiFileStr', () => { |
| 38 | - .margin({ top: 12 }) | 37 | + this.multiFileStr = value; |
| 39 | - TextInput({ text: this.multiFileStr, placeholder: $r('app.string.input_text_data_to_migrate') }) | 38 | + }, CommonConstants.DEBOUNCE_DELAY); |
| 40 | - .width(CommonConstants.FULL_PERCENT) | 39 | + }) |
| 41 | - .height(40) | 40 | + this.NumberInputField(this.multiFileNum, $r('app.string.input_number_data_to_migrate'), (value: string) => { |
| 42 | - .onChange(((value: string) => { | 41 | + DebounceUtil.debounce('multiFileNum', () => { |
| 43 | - DebounceUtil.debounce('multiFileStr', () => { | 42 | + const num = Number(value); |
| 44 | - this.multiFileStr = value; | 43 | + const result = value && !isNaN(num) ? num : null; |
| 45 | - }, this.debounceDelay); | 44 | + this.multiFileNum = result; |
| 46 | - })) | 45 | + }, CommonConstants.DEBOUNCE_DELAY); |
| 47 | - TextInput({ text: `${this.multiFileNum}`, placeholder: $r('app.string.input_number_data_to_migrate') }) | 46 | + }) |
| 48 | - .type(InputType.Number) | 47 | + |
| 49 | - .width(CommonConstants.FULL_PERCENT) | 48 | + this.SectionTitle($r('app.string.image_file')) |
| 50 | - .height(40) | ||
| 51 | - .onChange(((value: string) => { | ||
| 52 | - DebounceUtil.debounce('multiFileNum', () => { | ||
| 53 | - const num = Number(value); | ||
| 54 | - this.multiFileNum = value && !isNaN(num) ? num : null; | ||
| 55 | - }, this.debounceDelay); | ||
| 56 | - })) | ||
| 57 | - Text($r('app.string.image_file')) | ||
| 58 | - .alignSelf(ItemAlign.Start) | ||
| 59 | - .fontWeight(FontWeight.Medium) | ||
| 60 | AddPicView({ isSingleImage: this.isSingleImage }) | 49 | AddPicView({ isSingleImage: this.isSingleImage }) |
| 61 | } | 50 | } |
| 62 | .width(CommonConstants.FULL_PERCENT) | 51 | .width(CommonConstants.FULL_PERCENT) |
| 63 | .padding({ | 52 | .padding({ |
| 64 | - left: 16, | 53 | + left: CommonConstants.PAGE_PADDING_HORIZONTAL, |
| 65 | - right: 16 | 54 | + right: CommonConstants.PAGE_PADDING_HORIZONTAL |
| 66 | }) | 55 | }) |
| 67 | } | 56 | } |
| 68 | .title($r('app.string.migrate_data_distributed_multi_file')) | 57 | .title($r('app.string.migrate_data_distributed_multi_file')) |
| @@ -70,4 +59,29 @@ export struct MigrateDataDistributedMultiFileView { | |||
| 70 | .height(CommonConstants.FULL_PERCENT) | 59 | .height(CommonConstants.FULL_PERCENT) |
| 71 | .backgroundColor($r('app.color.page_background')) | 60 | .backgroundColor($r('app.color.page_background')) |
| 72 | } | 61 | } |
| 62 | + | ||
| 63 | + @Builder | ||
| 64 | + SectionTitle(title: Resource) { | ||
| 65 | + Text(title) | ||
| 66 | + .alignSelf(ItemAlign.Start) | ||
| 67 | + .fontWeight(FontWeight.Medium) | ||
| 68 | + .margin({ top: CommonConstants.SECTION_MARGIN_TOP }) | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + @Builder | ||
| 72 | + TextInputField(value: string, placeholder: Resource, onChange: (value: string) => void) { | ||
| 73 | + TextInput({ text: value, placeholder: placeholder }) | ||
| 74 | + .width(CommonConstants.FULL_PERCENT) | ||
| 75 | + .height(CommonConstants.TEXT_INPUT_HEIGHT) | ||
| 76 | + .onChange(onChange) | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @Builder | ||
| 80 | + NumberInputField(value: number | null, placeholder: Resource, onChange: (value: string) => void) { | ||
| 81 | + TextInput({ text: `${value}`, placeholder: placeholder }) | ||
| 82 | + .type(InputType.Number) | ||
| 83 | + .width(CommonConstants.FULL_PERCENT) | ||
| 84 | + .height(CommonConstants.TEXT_INPUT_HEIGHT) | ||
| 85 | + .onChange(onChange) | ||
| 86 | + } | ||
| 73 | } | 87 | } |
| @@ -23,28 +23,21 @@ export function migrateDataWantParamViewBuilder() { | |||
| 23 | @Component | 23 | @Component |
| 24 | export struct MigrateDataWantParamView { | 24 | export struct MigrateDataWantParamView { |
| 25 | @StorageLink('wantBasicData') wantBasicData: string = ''; | 25 | @StorageLink('wantBasicData') wantBasicData: string = ''; |
| 26 | - private debounceDelay: number = 300; | ||
| 27 | 26 | ||
| 28 | build() { | 27 | build() { |
| 29 | NavDestination() { | 28 | NavDestination() { |
| 30 | - Column({ space: 12 }) { | 29 | + Column({ space: CommonConstants.SECTION_MARGIN_TOP }) { |
| 31 | - Text($r('app.string.basic_data')) | 30 | + this.SectionTitle($r('app.string.basic_data')) |
| 32 | - .alignSelf(ItemAlign.Start) | 31 | + this.TextInputField(this.wantBasicData, $r('app.string.input_data_to_migrate'), (value: string) => { |
| 33 | - .fontWeight(FontWeight.Medium) | 32 | + DebounceUtil.debounce('wantBasicData', () => { |
| 34 | - .margin({ top: 12 }) | 33 | + this.wantBasicData = value; |
| 35 | - TextInput({ text: this.wantBasicData, placeholder: $r('app.string.input_data_to_migrate') }) | 34 | + }, CommonConstants.DEBOUNCE_DELAY); |
| 36 | - .width(CommonConstants.FULL_PERCENT) | 35 | + }) |
| 37 | - .height(40) | ||
| 38 | - .onChange(((value: string) => { | ||
| 39 | - DebounceUtil.debounce('wantBasicData', () => { | ||
| 40 | - this.wantBasicData = value; | ||
| 41 | - }, this.debounceDelay); | ||
| 42 | - })) | ||
| 43 | } | 36 | } |
| 44 | .width(CommonConstants.FULL_PERCENT) | 37 | .width(CommonConstants.FULL_PERCENT) |
| 45 | .padding({ | 38 | .padding({ |
| 46 | - left: 16, | 39 | + left: CommonConstants.PAGE_PADDING_HORIZONTAL, |
| 47 | - right: 16 | 40 | + right: CommonConstants.PAGE_PADDING_HORIZONTAL |
| 48 | }) | 41 | }) |
| 49 | } | 42 | } |
| 50 | .title($r('app.string.migrate_data_want_param')) | 43 | .title($r('app.string.migrate_data_want_param')) |
| @@ -52,4 +45,20 @@ export struct MigrateDataWantParamView { | |||
| 52 | .height(CommonConstants.FULL_PERCENT) | 45 | .height(CommonConstants.FULL_PERCENT) |
| 53 | .backgroundColor($r('app.color.page_background')) | 46 | .backgroundColor($r('app.color.page_background')) |
| 54 | } | 47 | } |
| 48 | + | ||
| 49 | + @Builder | ||
| 50 | + SectionTitle(title: Resource) { | ||
| 51 | + Text(title) | ||
| 52 | + .alignSelf(ItemAlign.Start) | ||
| 53 | + .fontWeight(FontWeight.Medium) | ||
| 54 | + .margin({ top: CommonConstants.SECTION_MARGIN_TOP }) | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @Builder | ||
| 58 | + TextInputField(value: string, placeholder: Resource, onChange: (value: string) => void) { | ||
| 59 | + TextInput({ text: value, placeholder: placeholder }) | ||
| 60 | + .width(CommonConstants.FULL_PERCENT) | ||
| 61 | + .height(CommonConstants.TEXT_INPUT_HEIGHT) | ||
| 62 | + .onChange(onChange) | ||
| 63 | + } | ||
| 55 | } | 64 | } |
| @@ -43,13 +43,9 @@ export class AddPicViewModel { | |||
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | - canAddMoreImages(isSingleImage: boolean): boolean { | 46 | + getButtonText(isSingleImage: boolean, imageCount: number): Resource { |
| 47 | - return this.imageUriArray.length < (isSingleImage ? 1 : MAX_IMAGE_COUNT); | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - getButtonText(isSingleImage: boolean, hasImage: boolean, imageCount: number): Resource { | ||
| 51 | if (isSingleImage) { | 47 | if (isSingleImage) { |
| 52 | - return hasImage ? $r('app.string.image_add') : $r('app.string.add_high_img'); | 48 | + return $r('app.string.add_high_img'); |
| 53 | } | 49 | } |
| 54 | if (imageCount === 0) { | 50 | if (imageCount === 0) { |
| 55 | return $r('app.string.add_high_img'); | 51 | return $r('app.string.add_high_img'); |
| @@ -61,18 +57,10 @@ export class AddPicViewModel { | |||
| 61 | } | 57 | } |
| 62 | 58 | ||
| 63 | selectImage(isSingleImage: boolean): void { | 59 | selectImage(isSingleImage: boolean): void { |
| 64 | - if (!this.canAddMoreImages(isSingleImage)) { | ||
| 65 | - this.showToast($r('app.string.add_picture_prompt')); | ||
| 66 | - return; | ||
| 67 | - } | ||
| 68 | fileSelect(isSingleImage).then((uri: Array<ResourceStr>) => { | 60 | fileSelect(isSingleImage).then((uri: Array<ResourceStr>) => { |
| 69 | if (!uri || uri.length === 0) { | 61 | if (!uri || uri.length === 0) { |
| 70 | return; | 62 | return; |
| 71 | } | 63 | } |
| 72 | - if ((this.imageUriArray.length + uri.length) > (isSingleImage ? 1 : 9)) { | ||
| 73 | - uri.length = (isSingleImage ? 1 : 9) - this.imageUriArray.length; | ||
| 74 | - this.showToast($r('app.string.add_picture_prompt')); | ||
| 75 | - } | ||
| 76 | uri.forEach((item: ResourceStr) => { | 64 | uri.forEach((item: ResourceStr) => { |
| 77 | this.getThumbnail(item as string, isSingleImage); | 65 | this.getThumbnail(item as string, isSingleImage); |
| 78 | }); | 66 | }); |
| @@ -5,7 +5,9 @@ | |||
| 5 | "description": "$string:module_desc", | 5 | "description": "$string:module_desc", |
| 6 | "mainElement": "EntryAbility", | 6 | "mainElement": "EntryAbility", |
| 7 | "deviceTypes": [ | 7 | "deviceTypes": [ |
| 8 | - "phone" | 8 | + "phone", |
| 9 | + "tablet", | ||
| 10 | + "2in1" | ||
| 9 | ], | 11 | ], |
| 10 | "deliveryWithInstall": true, | 12 | "deliveryWithInstall": true, |
| 11 | "installationFree": false, | 13 | "installationFree": false, |
和readme机型不匹配