From 9c6edbf65d8402b4028ab9c509e4aaead38e9c87 Mon Sep 17 00:00:00 2001 From: zywyl Date: Wed, 16 Oct 2024 16:08:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/ScorePage.ets | 90 +++++++++++++++----------- 1 file changed, 51 insertions(+), 39 deletions(-) diff --git a/entry/src/main/ets/pages/ScorePage.ets b/entry/src/main/ets/pages/ScorePage.ets index cb37541..6eb571d 100644 --- a/entry/src/main/ets/pages/ScorePage.ets +++ b/entry/src/main/ets/pages/ScorePage.ets @@ -44,8 +44,8 @@ export struct ScorePage { AppStorage.get('configSource')!; @State requiredSceneInfo: Array = []; @State recommendSceneInfo: Array = []; - @State title: string = ''; scroller: Scroller = new Scroller(); + private score: string = ''; private acquiredScore: number = 0; private totalScore: number = 0; private tableData: Array> = []; @@ -65,15 +65,8 @@ export struct ScorePage { const sceneOption: Array = AppStore.getInstance().optionRecord; this.requiredSceneInfo = []; this.recommendSceneInfo = []; - const csvTitle = await Promise.all([ - MediaTools.getStringFromResource('scene'), - MediaTools.getStringFromResource('operation'), - MediaTools.getStringFromResource('sub_scene'), - MediaTools.getStringFromResource('recommended_performance'), - MediaTools.getStringFromResource('actual_performance'), - MediaTools.getStringFromResource('optimization_suggestions') - ]); - this.tableData = [csvTitle]; + this.acquiredScore = 0; + this.totalScore = 0; for (let i = 0; i < sceneOption.length; i++) { let currentSceneInfo: AnalyticalInfo = { @@ -96,14 +89,52 @@ export struct ScorePage { this.totalScore += this.configSource![i].highestScore; } } + } + + this.score = Math.floor(this.acquiredScore / this.totalScore * 100) + ''; + } + + configSourceChange() { + this.initData(); + } + + aboutToAppear(): void { + this.initData(); + } + + setImageSource(item: AnalyticalInfo) { + if (item.isDetected && item.isFullScore) { + return $r('app.media.right'); + } else if (!item.isRequired && !item.isDetected) { + return $r('app.media.skip'); + } else { + return $r('app.media.error'); + } + } + + onCancel() { + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.export_cancel') }); + } + async generateTableData() { + const sceneOption: Array = AppStore.getInstance().optionRecord; + const csvTitle = await Promise.all([ + MediaTools.getStringFromResource('scene'), + MediaTools.getStringFromResource('operation'), + MediaTools.getStringFromResource('sub_scene'), + MediaTools.getStringFromResource('recommended_performance'), + MediaTools.getStringFromResource('actual_performance'), + MediaTools.getStringFromResource('optimization_suggestions') + ]); + const connectText = + `${await MediaTools.getStringFromResource('csv_generate_semicolon')}${await MediaTools.getStringFromResource('csv_generate_reference_guide')}`; + + for (let i = 0; i < sceneOption.length; i++) { let temp: Array; const scene: string = this.configSource![i].sceneName; const isDetected = sceneOption[i].isSkiped ? await MediaTools.getStringFromResource('csv_generate_skiped') : await MediaTools.getStringFromResource('csv_generate_completed'); let subScene: string, bestExperience: string, curExperience: string, advise: string; - const connectText = - `${await MediaTools.getStringFromResource('csv_generate_semicolon')}${await MediaTools.getStringFromResource('csv_generate_reference_guide')}`; if (this.configSource![i].steps.length > 1) { for (let j = 0; j < this.configSource![i].steps.length; j++) { @@ -140,36 +171,14 @@ export struct ScorePage { } } - this.title = `${await MediaTools.getStringFromResource('score_congratulations')}${Math.floor(this.acquiredScore / - this.totalScore * 100)}`; - } - - configSourceChange() { - this.initData(); - } - - aboutToAppear(): void { - this.initData(); - } - - setImageSource(item: AnalyticalInfo) { - if (item.isDetected && item.isFullScore) { - return $r('app.media.right'); - } else if (!item.isRequired && !item.isDetected) { - return $r('app.media.skip'); - } else { - return $r('app.media.error'); - } - } - - onCancel() { - this.getUIContext().getPromptAction().showToast({ message: $r('app.string.export_cancel') }); + this.tableData.unshift(csvTitle); } async onConfirm() { let filename = 'test' + new Date().getTime() + '.txt'; this.csvFileUtil = new CsvFileUtil(filename); await this.csvFileUtil.getCsvPath(); + await this.generateTableData(); await this.csvFileUtil.writeDataToCsv(this.tableData); await this.csvFileUtil.exportCsvFile(); await this.csvFileUtil.closeWriteData(); @@ -185,9 +194,12 @@ export struct ScorePage { .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP]); Column() { - Text(this.title) - .fontSize(30) - .fontWeight(700); + Text() { + Span($r('app.string.score_congratulations')); + Span(this.score); + } + .fontSize(30) + .fontWeight(700); } .width('100%') .margin({ -- Gitee From f7ed84e22d799465b564514e22d4753bf6391096 Mon Sep 17 00:00:00 2001 From: zywyl Date: Wed, 16 Oct 2024 16:23:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/ScorePage.ets | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/entry/src/main/ets/pages/ScorePage.ets b/entry/src/main/ets/pages/ScorePage.ets index 6eb571d..d71a233 100644 --- a/entry/src/main/ets/pages/ScorePage.ets +++ b/entry/src/main/ets/pages/ScorePage.ets @@ -90,7 +90,6 @@ export struct ScorePage { } } } - this.score = Math.floor(this.acquiredScore / this.totalScore * 100) + ''; } @@ -118,6 +117,7 @@ export struct ScorePage { async generateTableData() { const sceneOption: Array = AppStore.getInstance().optionRecord; + this.tableData = []; const csvTitle = await Promise.all([ MediaTools.getStringFromResource('scene'), MediaTools.getStringFromResource('operation'), @@ -170,7 +170,6 @@ export struct ScorePage { this.tableData.push(temp); } } - this.tableData.unshift(csvTitle); } -- Gitee