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:26:10 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
e93569eff34aa7ee65c182ca058bd708de5e4338
e93569ef
2 parents
bed85016
5227a1bf
Merge branch 'main' of
http://192.168.1.42/developOne/harmonyPool
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhSingleColumn09.ets
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhSingleColumn09.ets
View file @
e93569e
...
...
@@ -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) {
...
...
Please
register
or
login
to post a comment