Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
陈剑华
2024-08-23 10:27:29 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
32f96fa9de4db4356253de6ceb1440d4949fe2b9
32f96fa9
2 parents
5023bc25
e93569ef
Merge remote-tracking branch 'origin/main'
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
9 deletions
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhSingleColumn09.ets
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhSingleRow04.ets
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhSingleColumn09.ets
View file @
32f96fa
...
...
@@ -14,6 +14,7 @@ const TAG = 'Zh_Single_Column-09'
@Entry
@Component
export struct ZhSingleColumn09 {
@State fullyTraversed: boolean = false;
@State private pageModel: PageModel = new PageModel();
@State pageId: string = '';
@State pageName: string = '';
...
...
@@ -24,6 +25,7 @@ export struct ZhSingleColumn09 {
@State loadImg: boolean = false;
@State compIndex: number = 0;
@State currentOperDataListIndex: number = 0; //记录换一换点击次数
@State visitedIndices: Set<number> = new Set<number>();
async aboutToAppear(): Promise<void> {
this.loadImg = await onlyWifiLoadImg();
...
...
@@ -77,12 +79,21 @@ export struct ZhSingleColumn09 {
}
shuffleArray(array: ContentDTO[]) {
for (let i = array.length - 1; i > 0; i--) {
for (let i = array.length - 1; i >
=
0; i--) {
const j = Math.floor(Math.random() * (i + 1));
console.info(`cj2024 shuffleArray i = ${i} array.length = ${array.length}`)
// 记录被选中的索引 j
this.visitedIndices.add(j);
console.info(`cj2024 shuffleArray j = ${j} visitedIndices = ${this.visitedIndices.size}`)
const tempArray = array[i];
array[i] = array[j];
array[j] = tempArray
}
// 检查是否所有元素都被遍历过
this.fullyTraversed = this.visitedIndices.size === array.length;
return array
}
...
...
@@ -182,16 +193,14 @@ export struct ZhSingleColumn09 {
Row() {
Text('换一换')
.fontSize(14)
.fontColor(this.compDTO?.operDataList.length > 8 &&
this.currentOperDataListIndex > 0
? 0xed2800 : 0xB0B0B0)
.fontColor(this.compDTO?.operDataList.length > 8 &&
!this.fullyTraversed
? 0xed2800 : 0xB0B0B0)
.margin({ right: 4 })
Image(this.compDTO?.operDataList.length > 8 ? $r('app.media.icon_refresh') : $r('app.media.ic_refresh'))
.width(14)
.height(14)
}
.onClick(() => {
if (this.currentOperDataListIndex > 0) {
this.currentOperDataListIndex--
} else {
if (this.fullyTraversed) {
return
}
if (this.compDTO?.operDataList.length > 8) {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhSingleRow04.ets
View file @
32f96fa
...
...
@@ -60,8 +60,7 @@ export struct ZhSingleRow04 {
.margin({ bottom: 8 })
.width('100%')
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf')
right: 10
})
// 列表内容
...
...
@@ -74,8 +73,8 @@ export struct ZhSingleRow04 {
}
)
.margin({
right: index === this.compDTO.operDataList.length - 1 ? 26 : 0, left:
index === 0 ? $r('app.float.card_comp_pagePadding_lf') : 0,
right: index === this.compDTO.operDataList.length - 1 ? 26 : 0,
left: index === 0 ? 2 : 0,
top: 6
})
.onClick(() => {
...
...
Please
register
or
login
to post a comment