Browse Source

初始化

XUYangWei 3 months ago
parent
commit
371d2fd724
39 changed files with 1416 additions and 50 deletions
  1. 1 1
      AppScope/app.json5
  2. 5 5
      build-profile.json5
  3. 1 1
      commons/basic/src/main/ets/components/generalComp/YTHeader.ets
  4. 41 1
      commons/basic/src/main/ets/models/index.ets
  5. 4 0
      commons/basic/src/main/ets/utils/YTRouter.ets
  6. BIN
      commons/basic/src/main/resources/base/media/back.png
  7. BIN
      commons/basic/src/main/resources/base/media/backimgNumber.png
  8. BIN
      commons/basic/src/main/resources/base/media/banner.png
  9. BIN
      commons/basic/src/main/resources/base/media/big.png
  10. BIN
      commons/basic/src/main/resources/base/media/coin.png
  11. BIN
      commons/basic/src/main/resources/base/media/coinback.png
  12. BIN
      commons/basic/src/main/resources/base/media/coinbefore.png
  13. BIN
      commons/basic/src/main/resources/base/media/dice.png
  14. BIN
      commons/basic/src/main/resources/base/media/eat.png
  15. BIN
      commons/basic/src/main/resources/base/media/number.png
  16. BIN
      commons/basic/src/main/resources/base/media/rannum.png
  17. BIN
      commons/basic/src/main/resources/base/media/shai_1.png
  18. BIN
      commons/basic/src/main/resources/base/media/shai_2.png
  19. BIN
      commons/basic/src/main/resources/base/media/shai_3.png
  20. BIN
      commons/basic/src/main/resources/base/media/shai_4.png
  21. BIN
      commons/basic/src/main/resources/base/media/shai_5.png
  22. BIN
      commons/basic/src/main/resources/base/media/shai_6.png
  23. BIN
      commons/basic/src/main/resources/rawfile/beizi.mp4
  24. 0 5
      features/feature/Index.ets
  25. 80 0
      features/feature/src/main/ets/utils/Sector.ets
  26. 317 0
      features/feature/src/main/ets/view/BigWheelView.ets
  27. 22 0
      features/feature/src/main/ets/view/EatWhatView.ets
  28. 67 1
      features/feature/src/main/ets/view/MainView.ets
  29. 317 0
      features/feature/src/main/ets/view/RanNumberView.ets
  30. 340 0
      features/feature/src/main/ets/view/RollDiceView.ets
  31. 0 6
      features/feature/src/main/ets/view/SecondView.ets
  32. 0 6
      features/feature/src/main/ets/view/ThirdView.ets
  33. 187 0
      features/feature/src/main/ets/view/TossCoinView.ets
  34. 25 1
      features/feature/src/main/resources/base/profile/router_map.json
  35. 9 23
      products/entry/src/main/ets/pages/Index.ets
  36. BIN
      products/entry/src/main/resources/base/media/homes.png
  37. BIN
      products/entry/src/main/resources/base/media/homeuns.png
  38. BIN
      products/entry/src/main/resources/base/media/mys.png
  39. BIN
      products/entry/src/main/resources/base/media/myuns.png

+ 1 - 1
AppScope/app.json5

@@ -1,6 +1,6 @@
 {
   "app": {
-    "bundleName": "com.ytpm.ltlab",
+    "bundleName": "com.ytpm.ytxjd",
     "vendor": "example",
     "versionCode": 1000000,
     "versionName": "1.0.0",

+ 5 - 5
build-profile.json5

@@ -4,13 +4,13 @@
       {
         "name": "default",
         "material": {
-          "certpath": "sign/调试证书.cer",
+          "storeFile": "sign/basic.p12",
+          "storePassword": "000000187CD06458091FA47389D48BC101B8367DE23AB9D60937F522FB6EFC874B3CCBF3CF140A50",
           "keyAlias": "yt112233",
-          "keyPassword": "00000018AA1DF792B5966FE644806FA1B800469145FF0EE3857ECE33FD36FAEE0CC52F9710C5CD18",
-          "profile": "D:/恋爱宝证书文件/聊天恋爱宝调试证书.p7b",
+          "keyPassword": "0000001804DB1A9D8153633E7AA037AEC254E68493CF286BE33E6F821CB8F46AB67E1EB65367D447",
           "signAlg": "SHA256withECDSA",
-          "storeFile": "sign/basic.p12",
-          "storePassword": "00000018885669D97A30E6B9EAD10C9194794FC76A11200ED5E34C1C9C3BA8B4DFCC4090FD92F540"
+          "profile": "C:/Users/EDY/Downloads/樱桃小决定调试Debug.p7b",
+          "certpath": "sign/调试证书.cer"
         }
       }
     ],

+ 1 - 1
commons/basic/src/main/ets/components/generalComp/YTHeader.ets

@@ -9,7 +9,7 @@ export struct YTHeader {
   @StorageProp(YTAvoid.SAFE_TOP_KEY) safeTop: number = 0
   backArrow: boolean = true
   title: string = ''
-  bgc: ResourceColor = Color.White
+  bgc: ResourceColor = Color.Transparent
   click = () => {
     yTRouter.routerBack()
   }

+ 41 - 1
commons/basic/src/main/ets/models/index.ets

@@ -51,4 +51,44 @@ export type ResultCallBack<T> = (res?: T, err?: Error) => void
 /**
  * @description 断点字符串类型
  */
-export type BreakPointString = 'xs' | 'sm' | 'md' | 'lg'
+export type BreakPointString = 'xs' | 'sm' | 'md' | 'lg'
+
+
+export interface  DecisionItem{
+  title:string,
+  message:string,
+  icon:string | ResourceStr,
+  pageName:string
+}
+export const decisionItemList:DecisionItem[]=[
+  {
+    title:"抛硬币",
+    message:"选正反",
+    icon:$r('app.media.coin'),
+    pageName: "TossCoinView"
+  },
+  {
+    title:"掷筛子",
+    message:"摇一摇",
+    icon:$r('app.media.dice'),
+    pageName: "RollDiceView"
+  },
+  {
+    title:"吃什么",
+    message:"h",
+    icon:$r('app.media.eat'),
+    pageName: "EatWhatView"
+  },
+  {
+    title:"大转盘",
+    message:"搏一搏",
+    icon:$r('app.media.big'),
+    pageName: "BigWheelView"
+  },
+  {
+    title:"随机数",
+    message:"数字",
+    icon:$r('app.media.rannum'),
+    pageName: "RanNumberView"
+  }
+]

+ 4 - 0
commons/basic/src/main/ets/utils/YTRouter.ets

@@ -14,6 +14,10 @@ export class YTRouter extends NavPathStack {
     return YTRouter.instance
   }
 
+router2DecisionPage(name:string){
+    YTRouter.getInstance().pushPathByName(name,'')
+  }
+
   router2SettingPage() {
     yTRouter.pushPathByName('SettingPage', '')
   }

BIN
commons/basic/src/main/resources/base/media/back.png


BIN
commons/basic/src/main/resources/base/media/backimgNumber.png


BIN
commons/basic/src/main/resources/base/media/banner.png


BIN
commons/basic/src/main/resources/base/media/big.png


BIN
commons/basic/src/main/resources/base/media/coin.png


BIN
commons/basic/src/main/resources/base/media/coinback.png


BIN
commons/basic/src/main/resources/base/media/coinbefore.png


BIN
commons/basic/src/main/resources/base/media/dice.png


BIN
commons/basic/src/main/resources/base/media/eat.png


BIN
commons/basic/src/main/resources/base/media/number.png


BIN
commons/basic/src/main/resources/base/media/rannum.png


BIN
commons/basic/src/main/resources/base/media/shai_1.png


BIN
commons/basic/src/main/resources/base/media/shai_2.png


BIN
commons/basic/src/main/resources/base/media/shai_3.png


BIN
commons/basic/src/main/resources/base/media/shai_4.png


BIN
commons/basic/src/main/resources/base/media/shai_5.png


BIN
commons/basic/src/main/resources/base/media/shai_6.png


BIN
commons/basic/src/main/resources/rawfile/beizi.mp4


+ 0 - 5
features/feature/Index.ets

@@ -1,8 +1,3 @@
 export { MainView } from './src/main/ets/view/MainView';
-
-export { SecondView } from './src/main/ets/view/SecondView';
-
-export { ThirdView } from './src/main/ets/view/ThirdView';
-
 export { add } from './src/main/ets/utils/Calc';
 

+ 80 - 0
features/feature/src/main/ets/utils/Sector.ets

@@ -0,0 +1,80 @@
+// 定义扇形组件
+@Component
+export struct Sector {
+  @Prop radius: number; // 扇形的半径
+  @Prop angle: number; // 扇形的角度
+  @Prop color: string; // 扇形的颜色
+
+  // 创建扇形路径的函数
+  createSectorPath(radius: number, angle: number): string {
+    const centerX = radius / 2; // 计算扇形中心的X坐标
+    const centerY = radius / 2; // 计算扇形中心的Y坐标
+    const startX = centerX; // 扇形起始点的X坐标
+    const startY = centerY - radius; // 扇形起始点的Y坐标
+    const halfAngle = angle / 4; // 计算半个角度
+
+    // 计算扇形结束点1的坐标
+    const endX1 = centerX + radius * Math.cos((halfAngle * Math.PI) / 180);
+    const endY1 = centerY - radius * Math.sin((halfAngle * Math.PI) / 180);
+
+    // 计算扇形结束点2的坐标
+    const endX2 = centerX + radius * Math.cos((-halfAngle * Math.PI) / 180);
+    const endY2 = centerY - radius * Math.sin((-halfAngle * Math.PI) / 180);
+
+    // 判断是否为大弧
+    const largeArcFlag = angle / 2 > 180 ? 1 : 0;
+    const sweepFlag = 1; // 设置弧线方向为顺时针
+
+    // 生成SVG路径命令
+    const pathCommands =
+      `M${startX} ${startY} A${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${endX1} ${endY1} L${centerX} ${centerY} L${endX2} ${endY2} A${radius} ${radius} 0 ${largeArcFlag} ${1 -
+        sweepFlag} ${startX} ${startY} Z`;
+    return pathCommands; // 返回路径命令
+  }
+
+  // 构建扇形组件
+  build() {
+    Stack() {
+      // 创建第一个扇形路径
+      Path()
+        .width(`${this.radius}px`) // 设置宽度为半径
+        .height(`${this.radius}px`) // 设置高度为半径
+        .commands(this.createSectorPath(this.radius, this.angle)) // 设置路径命令
+        .fillOpacity(1) // 设置填充透明度
+        .fill(this.color) // 设置填充颜色
+        .strokeWidth(0) // 设置边框宽度为0
+        .rotate({ angle: this.angle / 4 - 90 }); // 旋转扇形
+
+      // 创建第二个扇形路径
+      Path()
+        .width(`${this.radius}px`) // 设置宽度为半径
+        .height(`${this.radius}px`) // 设置高度为半径
+        .commands(this.createSectorPath(this.radius, this.angle)) // 设置路径命令
+        .fillOpacity(1) // 设置填充透明度
+        .fill(this.color) // 设置填充颜色
+        .strokeWidth(0) // 设置边框宽度为0
+        .rotate({ angle: 180 - (this.angle / 4 - 90) }); // 旋转扇形
+    }
+  }
+}
+
+// 定义单元格类
+@ObservedV2
+export class Cell {
+  @Trace id:number=0
+  @Trace angle: number = 0; // 扇形的角度
+  @Trace title: string; // 当前格子的标题
+  @Trace color: string; // 背景颜色
+  @Trace rotate: number = 0; // 在转盘要旋转的角度
+  angleStart: number = 0; // 轮盘所在区间的起始
+  angleEnd: number = 0; // 轮盘所在区间的结束
+  proportion: number = 0; // 所占比例
+
+  // 构造函数
+  constructor(id:number,proportion: number, title: string, color: string) {
+    this.proportion = proportion; // 设置比例
+    this.title = title; // 设置标题
+    this.color = color; // 设置颜色
+    this.id=id
+  }
+}

+ 317 - 0
features/feature/src/main/ets/view/BigWheelView.ets

@@ -0,0 +1,317 @@
+import { YTAvoid, YTHeader } from 'basic'
+import { Cell, Sector } from '../utils/Sector';
+import { CounterComponent, CounterType } from '@kit.ArkUI';
+
+
+@Builder
+function BigWheelViewBuilder(){
+  NavDestination(){
+    BigWheelView()
+  }.title("大转盘")
+  .hideTitleBar(true)
+}
+
+@Component
+struct BigWheelView{
+  @StorageProp(YTAvoid.SAFE_TOP_KEY) safeBottom: number = 0
+
+  @State cells: Cell[] = []; // 存储单元格的数组
+  @State wheelWidth: number = 600; // 转盘的宽度
+  @State currentAngle: number = 0; // 当前转盘的角度
+  @State selectedName: string = ""; // 选中的名称
+  @State isRepeat:boolean=false
+  @Watch('xxx')
+  @State selected:Cell[]=[]
+  @State UnSelected:Cell[]=[]
+  @State randomAngle:number=0
+  isAnimating: boolean = false; // 动画状态
+  colorIndex: number = 0; // 颜色索引
+  spinDuration:number=5000
+
+  colorPalette: string[] = [ // 颜色调色板
+    "#26c2ff",
+    "#978efe",
+    "#c389fe",
+    "#ff85bd",
+    "#ff7051",
+    "#fea800",
+    "#ffcf18",
+    "#a9c92a",
+    "#fea800",
+    "#ffcf18",
+    "#a9c92a"
+  ];
+  xxx(){
+    //每次选中的数组有变化,那就要重新过滤
+    this.UnSelected = this.cells.filter(item =>
+    !this.selected.some(selected => selected.id === item.id));
+    // promptAction.showToast({
+    //   message:JSON.stringify(this.UnSelected)
+    // })
+    //要把选的变成灰色
+    // this.cells.map((item)=>{
+    //
+    // })
+
+  }
+
+  // 组件即将出现时调用
+  aboutToAppear(): void {
+    // 初始化单元格
+    this.cells.push(new Cell(1,1, "转盘1", this.colorPalette[this.colorIndex++ % this.colorPalette.length]));
+    this.cells.push(new Cell(2,2, "转盘2", this.colorPalette[this.colorIndex++ % this.colorPalette.length]));
+    this.cells.push(new Cell(3,1, "转盘3", this.colorPalette[this.colorIndex++ % this.colorPalette.length]));
+    this.cells.push(new Cell(4,4, "转盘4", this.colorPalette[this.colorIndex++ % this.colorPalette.length]));
+    this.UnSelected=this.cells
+
+    this.calculateAngles(); // 计算角度
+  }
+
+  // 计算每个单元格的角度
+  private calculateAngles() {
+    // 根据比例计算总比例
+    const totalProportion = this.cells.reduce((sum, cell) => sum + cell.proportion, 0);
+    this.cells.forEach(cell => {
+      cell.angle = (cell.proportion * 360) / totalProportion; // 计算每个单元格的角度
+    });
+
+    let cumulativeAngle = 0; // 累计角度
+    this.cells.forEach(cell => {
+      cell.angleStart = cumulativeAngle; // 设置起始角度
+      cumulativeAngle += cell.angle; // 更新累计角度
+      cell.angleEnd = cumulativeAngle; // 设置结束角度
+      cell.rotate = cumulativeAngle - (cell.angle / 2); // 计算旋转角度
+    });
+  }
+
+  private calculateNoSelectedAngles(){
+    //在这里计算
+
+    if(this.UnSelected.length!=0) {
+      //随机选取一个没有选中的角度范围扇形
+      const currangle=this.currentAngle%360
+      const randomIndex = Math.floor(Math.random() * this.UnSelected.length) as number
+      const ranNumStart = 360-this.UnSelected[randomIndex].angleEnd
+      const ranNumEnd = 360-this.UnSelected[randomIndex].angleStart
+      this.randomAngle =Math.floor(Math.random() * (ranNumEnd - ranNumStart) + ranNumStart)-currangle
+    }
+    // else{
+    //   this.randomAngle=Math.floor(Math.random()*360)
+    // }
+  }
+
+
+  build() {
+    Column() {
+      YTHeader({ title: '大转盘' })
+
+      Row() {
+        Text('转盘').fontSize(20).fontColor("#0b0e15"); // 显示转盘标题
+      }.width('100%').height(44).justifyContent(FlexAlign.Center); // 设置行的宽度和高度
+
+      // 显示当前状态
+      Text(this.isAnimating ? '旋转中' : `${this.selectedName}`).fontSize(20).fontColor("#0b0e15").height(40);
+
+      Stack() {
+        Stack() {
+          // 遍历每个单元格并绘制扇形
+          ForEach(this.cells, (cell: Cell) => {
+            Stack() {
+              Sector({ radius: lpx2px(this.wheelWidth) / 2, angle: cell.angle, color: cell.color }); // 创建扇形
+              Text(cell.title).fontColor(Color.White).margin({ bottom: `${this.wheelWidth / 1.4}lpx` }); // 显示单元格标题
+            }.width('100%').height('100%').rotate({ angle: cell.rotate }); // 设置宽度和高度,并旋转
+          });
+        }
+        .borderRadius('50%') // 设置圆角
+        .backgroundColor(Color.Gray) // 设置背景颜色
+        .width(`${this.wheelWidth}lpx`) // 设置转盘宽度
+        .height(`${this.wheelWidth}lpx`) // 设置转盘高度
+        .rotate({ angle: this.currentAngle }); // 旋转转盘
+
+        // 创建指针
+        Polygon({ width: 20, height: 10 })
+          .points([[0, 0], [10, -20], [20, 0]]) // 设置指针的点
+          .fill("#d72b0b") // 设置指针颜色
+          .height(20) // 设置指针高度
+          .margin({ bottom: '140lpx' }); // 设置指针底部边距
+
+        // 创建开始按钮
+        Button('开始')
+          .fontColor("#c53a2c") // 设置按钮字体颜色
+          .borderWidth(10) // 设置按钮边框宽度
+          .borderColor("#dd2218") // 设置按钮边框颜色
+          .backgroundColor("#fde427") // 设置按钮背景颜色
+          .width('200lpx') // 设置按钮宽度
+          .height('200lpx') // 设置按钮高度
+          .borderRadius('50%') // 设置按钮为圆形
+          .clickEffect({ level: ClickEffectLevel.LIGHT }) // 设置点击效果
+          .onClick(() => { // 点击按钮时的回调函数
+            if (this.isAnimating) { // 如果正在动画中,返回
+              return;
+            }
+            if(this.selected.length==this.cells.length){
+              return
+            }
+            //如果都已经被选了,则不能再转了
+            this.calculateNoSelectedAngles()
+            this.selectedName = ""; // 清空选中的名称
+            this.isAnimating = true; // 设置动画状态为正在动画
+            animateTo({ // 开始动画
+              duration: this.spinDuration, // 动画持续时间为5000毫秒
+              curve: Curve.EaseInOut, // 动画曲线为缓入缓出
+              onFinish: () => { // 动画完成后的回调
+                this.currentAngle %= 360; // 保持当前角度在0到360之间
+                for (const cell of this.cells) { // 遍历每个单元格
+                  // 检查当前角度是否在单元格的角度范围内
+                  if (360 - this.currentAngle >= cell.angleStart && 360 - this.currentAngle <= cell.angleEnd) {
+                    this.selected.push(cell)
+                    //这里需要下次点击的时候
+                    cell.color='#202020'
+                    this.selectedName = cell.title; // 设置选中的名称为当前单元格的标题
+                    break; // 找到后退出循环
+                  }
+                }
+                this.isAnimating = false; // 设置动画状态为未动画
+              },
+            }, () => { // 动画进行中的回调
+              //在这里判断
+              // this.randomAngle=Math.floor(Math.random()*360)
+              // this.currentAngle += (360 * this.spinDuration/1000 + Math.floor(Math.random() * 360)); // 更新当前角度,增加随机旋转
+              //在这里算已经选过的,不能在指了
+
+              // this.currentAngle += (360 * this.spinDuration/1000 + Math.floor(Math.random() * 360)); // 更新当前角度,增加随机旋转
+
+              // promptAction.showToast({
+              //   message:this.randomAngle.toString()
+              // })
+              this.currentAngle += (360 * this.spinDuration/1000)+this.randomAngle
+
+
+
+            });
+          });
+      }
+
+      // 创建滚动区域
+      Scroll() {
+        Column() {
+          // 遍历每个单元格,创建输入框和计数器
+          ForEach(this.cells, (item: Cell, index: number) => {
+            Row() {
+              // 创建文本输入框,显示单元格标题
+              TextInput({ text: item.title })
+                .layoutWeight(1) // 设置输入框占据剩余空间
+                .onChange((value) => { // 输入框内容变化时的回调
+                  item.title = value; // 更新单元格标题
+                });
+              // 创建计数器组件
+              CounterComponent({
+                options: {
+                  type: CounterType.COMPACT, // 设置计数器类型为紧凑型
+                  numberOptions: {
+                    label: `当前占比`, // 设置计数器标签
+                    value: item.proportion, // 设置计数器初始值
+                    min: 1, // 设置最小值
+                    max: 100, // 设置最大值
+                    step: 1, // 设置步长
+                    onChange: (value: number) => { // 计数器值变化时的回调
+                      item.proportion = value; // 更新单元格的比例
+                      this.calculateAngles(); // 重新计算角度
+                    }
+                  }
+                }
+              });
+              // 创建删除按钮
+              Button('删除').onClick(() => {
+                this.cells.splice(index, 1); // 从单元格数组中删除当前单元格
+                this.calculateAngles(); // 重新计算角度
+              });
+            }.width('100%').justifyContent(FlexAlign.SpaceBetween) // 设置行的宽度和内容对齐方式
+            .padding({ left: 40, right: 40 }); // 设置左右内边距
+          });
+        }.layoutWeight(1); // 设置滚动区域占据剩余空间
+      }.layoutWeight(1) // 设置滚动区域占据剩余空间
+      .margin({ top: 20, bottom: 20 }) // 设置上下外边距
+      .align(Alignment.Top); // 设置对齐方式为顶部对齐
+
+      Row(){
+        ForEach([2,3,4,5,6],(item:number,index)=>{
+          Text((item).toString()).width(20).fontColor(Color.Red).onClick(()=>{
+            //如果当前内容
+            // if(this.cells.length>(item+1)){
+            //
+            //
+            // }
+            this.cells=[]
+            for(let i=0;i<item;i++){
+              this.cells.push(new Cell(i+1,1, "转盘"+(i+1), this.colorPalette[i]));
+            }
+            this.calculateAngles(); // 重新计算角度
+
+
+          })
+        })
+      }
+
+      Text('旋转秒数').fontColor(Color.Black)
+      CounterComponent({
+        options: {
+          type: CounterType.COMPACT, // 设置计数器类型为紧凑型
+          numberOptions: {
+            value: this.spinDuration/1000, // 设置计数器初始值 5
+            min: 1, // 设置最小值
+            max: 100, // 设置最大值
+            step: 1, // 设置步长
+            onChange: (value: number) => { // 计数器值变化时的回调
+              this.spinDuration = value*1000;
+              // this.calculateAngles(); // 重新计算角度
+            }
+          }
+        }
+      }).backgroundColor(Color.White)
+
+
+      Row(){
+        Column(){
+          //是否允许结果重复
+          Button('是否允许结果重复').onClick(()=>{
+            this.isRepeat=!this.isRepeat
+          })
+          Text(this.isRepeat+"")
+        }
+
+        Column(){
+          Button('xxx').onClick(()=>{
+            //
+            // router.pushUrl({
+            //   url:"/pages/Test2ge".slice(1)
+            // })
+          })
+
+          Button('xxxxx').onClick(()=>{
+            // router.pushUrl({
+            //   url:"/pages/Index".slice(1)
+            // })
+          })
+        }
+      }
+
+
+
+
+
+      // 创建添加新内容按钮
+      Button('添加新内容').onClick(() => {
+        // 向单元格数组中添加新单元格
+        // this.cells.push(new Cell(1, "新内容", this.colorPalette[this.colorIndex++ % this.colorPalette.length]));
+        this.calculateAngles(); // 重新计算角度
+      }).margin({ top: 20, bottom: 20 }); // 设置按钮的上下外边距
+
+
+
+
+
+    }.padding({ bottom: this.safeBottom })
+    .justifyContent(FlexAlign.Center)
+  }
+}

+ 22 - 0
features/feature/src/main/ets/view/EatWhatView.ets

@@ -0,0 +1,22 @@
+import { YTAvoid, YTHeader } from 'basic'
+
+@Builder
+function EatWhatViewBuilder(){
+  NavDestination(){
+    EatWhatView()
+  }.title("吃什么")
+  .hideTitleBar(true)
+}
+
+@Component
+struct EatWhatView{
+  @StorageProp(YTAvoid.SAFE_TOP_KEY) safeBottom: number = 0
+  build() {
+    Column() {
+      YTHeader({ title: '吃什么' })
+
+    }.padding({ bottom: this.safeBottom })
+    .height('100%')
+    .backgroundColor(Color.White)
+  }
+}

+ 67 - 1
features/feature/src/main/ets/view/MainView.ets

@@ -1,6 +1,72 @@
+import { DecisionItem, decisionItemList, YTAvoid, yTRouter } from "basic"
+
+
 @Component
 export struct MainView {
+  @StorageProp(YTAvoid.SAFE_TOP_KEY)
+  top:number=0
   build() {
-    Text('1')
+    Column(){
+      Row(){
+        Text('樱桃决定').fontSize(18)
+          .fontWeight(700)
+          .fontColor(Color.Black)
+      }.width('100%')
+      .justifyContent(FlexAlign.Center)
+      .height(44 + this.top)
+      .padding({ top: this.top,left:18,right:9 }) //27 padding18
+
+
+      Column(){
+
+        // Text('我是首页的swiper组件')
+        Image($r('[basic].media.banner')).width('100%').height(170).objectFit(ImageFit.Fill)
+
+      }.width('100%')
+      .height(170)
+      // .margin({left:20,right:20})
+      // .backgroundColor(Color.Green)
+
+
+      Column() {
+        List({ space: 10 }) {
+          ForEach(decisionItemList, (item: DecisionItem, index) => {
+            ListItem() {
+              Row() {
+                Text(item.title).fontSize(30)
+
+              }
+              .width('95%')
+              .height(100)
+              .borderRadius(20)
+              .backgroundImage(item.icon)
+              .backgroundImageSize({ width: '100%', height: 100 })
+              // .backgroundColor(Color.Red)
+              .justifyContent(FlexAlign.Center)
+              .onClick(() => {
+                yTRouter.router2DecisionPage(item.pageName)
+              })
+            }
+          })
+
+        }.margin({top:10})
+        .alignListItem(ListItemAlign.Center)
+        .scrollBar(BarState.Off)
+
+      }
+      .offset({y:-20})
+      .layoutWeight(1)
+      .padding({left:10,right:10})
+      .borderRadius({topLeft:20,topRight:20})
+      .backgroundColor(Color.White)
+
+
+
+
+
+    }.width('100%')
+    .height('100%')
+    .backgroundImage($r('[basic].media.back'))
+    .backgroundImageSize({width:'100%',height:'100%'})
   }
 }

+ 317 - 0
features/feature/src/main/ets/view/RanNumberView.ets

@@ -0,0 +1,317 @@
+import { it } from '@ohos/hypium';
+import { IBestToast, YTAvoid, YTButton, YTHeader } from 'basic'
+import { LengthMetrics, promptAction } from '@kit.ArkUI';
+
+@Builder
+function RanNumberViewBuilder(){
+  NavDestination(){
+    RanNumberView()
+  }.title("随机数")
+  .hideTitleBar(true)
+}
+@Component
+struct RanNumberView{
+  @StorageProp(YTAvoid.SAFE_TOP_KEY) safeBottom: number = 0
+
+  // 存储生成的随机数字符串
+  @State private generatedNumbers: string = '';
+  // 应用的主题色
+  @State private primaryColor: string = '#fea024';
+  // 文本的颜色
+  @State private fontColor: string = "#2e2e2e";
+  // 输入框是否获取焦点的状态变量
+  @State private isFocusStart: boolean = false;
+  @State private isFocusEnd: boolean = false;
+  @State private isFocusCount: boolean = false;
+  // 是否允许生成的随机数重复
+  @State private isUnique: boolean = true;
+  // 随机数生成的起始值
+  @State private startValue: number = 0;
+  // 随机数生成的结束值
+  @State private endValue: number = 0;
+  // 要生成的随机数个数
+  @State private countValue: number = 0;
+  @State private randomNumberArr:number[]=[]
+
+
+  /**
+   * todo:bug:
+   * 改变值,会引起UI刷新
+   */
+  // 生成随机数的方法
+  private generateRandomNumbers(): void {
+
+    const startValue = this.startValue; // 获取当前设定的起始值
+    const endValue = this.endValue; // 获取当前设定的结束值
+    const countValue = this.countValue; // 获取当前设定的生成个数
+    const range: number = endValue - startValue + 1; // 计算生成范围
+
+
+    // 用于存储生成的随机数
+    const generatedNumbers = new Set<number>(); // 使用Set来自动去重
+    const tempArray: number[] = []; // 临时数组,用于辅助生成不重复的随机数
+
+    // 如果不允许重复,则使用去重算法生成随机数
+    if (!this.isUnique) {
+      // 如果请求的随机数数量超过了范围内的总数,则显示错误提示
+      if (countValue > range) {
+        this.getUIContext().showAlertDialog({
+          title: '错误提示',
+          message: `请求的随机数数量超过了范围内的总数`,
+          confirm: {
+            defaultFocus: true,
+            value: '我知道了',
+            fontColor: Color.White,
+            backgroundColor: this.primaryColor,
+            action: () => {} // 点击确认后的回调
+          },
+          onWillDismiss: () => {}, // 对话框即将关闭时的回调
+          alignment: DialogAlignment.Center, // 对话框的对齐方式
+        });
+        return;
+      }
+
+      for (let i = 0; i < countValue; i++) {
+        let randomIndex = Math.floor(Math.random() * (range - i)); // 在剩余范围内选择一个随机索引
+        let randomNum = 0;
+        if (tempArray[randomIndex] !== undefined) { // 如果索引位置已有值,则使用该值
+          randomNum = tempArray[randomIndex];
+        } else {
+          randomNum = startValue + randomIndex; // 否则计算新的随机数
+        }
+        generatedNumbers.add(randomNum); // 添加到Set中,自动去重
+        if (tempArray[range - 1 - i] === undefined) { // 更新末尾元素的位置
+          tempArray[range - 1 - i] = startValue + range - 1 - i;
+        }
+        tempArray[randomIndex] = tempArray[range - 1 - i]; // 将末尾元素移到随机位置
+      }
+      // 将生成的随机数转换成JSON格式的字符串
+      this.generatedNumbers = JSON.stringify(Array.from(generatedNumbers));
+    } else {
+      // 如果允许重复,则直接生成随机数
+      for (let i = 0; i < this.countValue; i++) {
+        let randomNumber = this.startValue + Math.floor(Math.random() * (this.endValue - this.startValue));
+        tempArray.push(randomNumber);
+      }
+      // 将生成的随机数转换成JSON格式的字符串
+      this.generatedNumbers = JSON.stringify(tempArray);
+    }
+
+    //最终将生成的字符串转化为数组
+    this.randomNumberArr=JSON.parse(this.generatedNumbers)
+    // this.flexChangeValue=this.countValue
+
+
+  }
+  // // 将生成的随机数复制到剪贴板的方法
+  // private copyToClipboard(text: string): void {
+  //   const pasteboardData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, text); // 创建剪贴板数据
+  //   const systemPasteboard = pasteboard.getSystemPasteboard(); // 获取系统剪贴板
+  //   systemPasteboard.setData(pasteboardData); // 设置剪贴板数据
+  //   // 显示复制成功的提示信息
+  //   promptAction.showToast({ message: '已复制' });
+  // }
+
+
+
+  build() {
+    Column() {
+      YTHeader({ title: '随机数' })
+      //声音
+      Row(){
+        Image($r('app.media.app_icon')).width(24)
+      }.width('100%')
+      .justifyContent(FlexAlign.Start)
+      .padding({left:30})
+
+      Column() {
+
+        Flex({ wrap: FlexWrap.Wrap, justifyContent: FlexAlign.SpaceBetween }) {
+          ForEach(this.randomNumberArr, (item: number, index: number) => {
+            Column() {
+              Text(item.toString()).width(30)
+
+            }
+            .width(this.countValue > 3 ? 70 : 95)
+            .height(this.countValue > 3 ? 60 : 85)
+            .justifyContent(FlexAlign.Center)
+            .alignItems(HorizontalAlign.Center)
+            .margin({ bottom: 20 })
+            .backgroundImage($r('[basic].media.number'))
+            .backgroundImageSize({ width: "100%", height: '100%' })
+
+          })
+
+
+        }.padding({ left: 30, right: 30 })
+      }.width('100%')
+      .height(300)
+
+      // 输入随机数范围的两个值
+      Column({space:20}) {
+        Row() {
+          Text('取值范围:').margin({right:30})
+          TextInput() // 输入框,显示占位符
+            .width(60)
+            .height(60)
+            .type(InputType.Number) // 设置输入类型为数字
+            .placeholderColor(this.isFocusStart ? this.primaryColor : Color.Gray) // 设置占位符颜色
+            .fontColor(this.isFocusStart ? this.primaryColor : this.fontColor) // 设置文本颜色
+            .borderColor(this.isFocusStart ? this.primaryColor : Color.Gray) // 设置边框颜色
+            .borderWidth(1) // 设置边框宽度
+            .borderRadius(10) // 设置圆角半径
+            .backgroundColor(Color.White) // 设置背景颜色
+            .showUnderline(false) // 不显示下划线
+            .onBlur(() => this.isFocusStart = false) // 输入框失去焦点时的处理
+            .onFocus(() => this.isFocusStart = true) // 输入框获得焦点时的处理
+            .onChange((value: string) => {
+              if(Number(value)>100){
+                IBestToast.show({
+                  message:'生成范围只能是100以内'
+                })
+                return
+              }
+              if(Number(value)<=0){
+                IBestToast.show({
+                  message:'生成范围只能是100以内'
+                })
+                return
+              }
+
+
+              this.startValue = Number(value)
+
+            }); // 输入值变化时的处理
+
+          // 分隔符
+          // Line().width(10) // 设置分隔符宽度
+          Text().width(30).height(1).fontColor(Color.Gray)
+          TextInput() // 输入框,显示占位符
+            .width(60)
+            .height(60)
+            .type(InputType.Number) // 设置输入类型为数字
+            .placeholderColor(this.isFocusEnd ? this.primaryColor : Color.Gray) // 设置占位符颜色
+            .fontColor(this.isFocusEnd ? this.primaryColor : this.fontColor) // 设置文本颜色
+            .borderColor(this.isFocusEnd ? this.primaryColor : Color.Gray) // 设置边框颜色
+            .borderWidth(1) // 设置边框宽度
+            .borderRadius(10) // 设置圆角半径
+            .backgroundColor(Color.White) // 设置背景颜色
+            .showUnderline(false) // 不显示下划线
+            .onBlur(() => this.isFocusEnd = false) // 输入框失去焦点时的处理
+            .onFocus(() => this.isFocusEnd = true) // 输入框获得焦点时的处理
+            .onChange((value: string) =>{
+              if(Number(value)>100){
+                IBestToast.show({
+                  message:'生成范围只能是100以内'
+                })
+                return
+              }
+              if(Number(value)<=0){
+                IBestToast.show({
+                  message:'生成范围只能是100以内'
+                })
+                return
+              }
+              this.endValue = Number(value)
+            }); // 输入值变化时的处理
+        }.width('100%').margin({top:10})
+
+        Row() {
+          Text('生成个数:').margin({right:30})
+          TextInput({ placeholder: ''}) // 输入框,显示占位符
+            .width(60)
+            .height(60)
+            .type(InputType.Number) // 设置输入类型为数字
+            .placeholderColor(this.isFocusCount ? this.primaryColor : Color.Gray) // 设置占位符颜色
+            .fontColor(this.isFocusCount ? this.primaryColor : this.fontColor) // 设置文本颜色
+            .borderColor(Color.Orange) // 设置边框颜色
+            .borderWidth(1) // 设置边框宽度
+            .borderRadius(10) // 设置圆角半径
+            .backgroundColor(Color.White) // 设置背景颜色
+            .showUnderline(false) // 不显示下划线
+            .onBlur(() => this.isFocusCount = false) // 输入框失去焦点时的处理
+            .onFocus(() => this.isFocusCount = true) // 输入框获得焦点时的处理
+            .onChange((value: string) =>{
+              if(Number(value)>10){
+                IBestToast.show({
+                  message:'只能生成10个数'
+                })
+                return
+              }
+              if(Number(value)<0){
+                IBestToast.show({
+                  message:'不能是负数'
+                })
+                return
+              }
+
+
+            this.countValue = Number(value)
+
+            }); // 输入值变化时的处理
+        }.width('100%')
+      }.width(330)
+      .height(170)
+      .padding({left:30,top:10})
+      .borderRadius(20)
+      .backgroundColor('#e0f8ff')
+      .justifyContent(FlexAlign.Start)
+
+      Text('生成范围为100以内,最多生成10个数')
+
+
+      Button('数字是否可以重复').onClick(()=>{
+        this.isUnique=!this.isUnique
+      })
+      Text(JSON.stringify(this.isUnique))
+
+      YTButton({
+        bgc:'#fd54e3',
+        btHeight:54,
+        btBorderRadius:20,
+        btWidth:300,
+        btFontColor:Color.White,
+        btFontSize:20,
+        click:()=>{
+
+          this.generateRandomNumbers()
+        },
+        btContent:'随机数生成'
+
+      })
+
+    }.padding({ bottom: this.safeBottom })
+    .height('100%')
+    .backgroundColor(Color.White)
+    .backgroundImage($r('[basic].media.backimgNumber'))
+    .backgroundImageSize({width:'100%',height:"100%"})
+  }
+}
+/**
+ *  Row() {
+ Text('数字是否可重复')
+ .fontWeight(400) // 设置字体粗细为400
+ .fontSize(16) // 设置字体大小为16
+ .fontColor(this.fontColor) // 设置文本颜色
+ .layoutWeight(1); // 设置布局权重为1
+
+ Toggle({ type: ToggleType.Checkbox, isOn: this.isUnique }) // 切换按钮
+ .width('100lpx') // 设置宽度
+ .height('50lpx') // 设置高度
+ .borderColor(Color.Gray) // 设置边框颜色
+ .selectedColor(this.primaryColor) // 设置选中时的颜色
+ .onChange((isOn: boolean) => this.isUnique = isOn) // 切换状态变化时的处理
+ .align(Alignment.End); // 设置对齐方式为右对齐
+ }
+ .margin({
+ top: `${this.baseSpacing}lpx`, // 上边距
+ })
+ .width('100%') // 设置宽度为100%
+ .padding({
+ left: `${this.baseSpacing}lpx`, // 左内边距
+ right: `${this.baseSpacing}lpx`, // 右内边距
+ top: `${this.baseSpacing / 3}lpx`, // 上内边距
+ })
+ .hitTestBehavior(HitTestMode.Block) // 设置点击测试行为
+ .onClick(() => this.isUnique = !this.isUnique); // 点击时切换状态
+ */

+ 340 - 0
features/feature/src/main/ets/view/RollDiceView.ets

@@ -0,0 +1,340 @@
+import { YTAvoid, YTHeader } from 'basic'
+import { promptAction, PromptAction } from '@kit.ArkUI'
+
+@Builder
+function RollDiceViewBuilder(){
+  NavDestination(){
+    RollDiceView()
+  }.title("掷筛子")
+  .hideTitleBar(true)
+}
+
+@Component
+struct RollDiceView {
+  @StorageProp(YTAvoid.SAFE_TOP_KEY) safeBottom: number = 0
+  images: ImageFrameInfo[] = Array.from<string>({ length: 6 }).map<ImageFrameInfo>((v: string, index: number) => {
+    return {
+      src: $r(`[basic].media.shai_${index+1}`),
+    }
+  })
+
+
+  @State currentIndex:number=0
+  controller: VideoController = new VideoController();
+
+
+  //几颗筛子
+  @State
+  number:number=1
+
+  randomNumber():number{
+   return Math.floor(Math.random()*6)
+  }
+  //筛子结果
+  @State
+  RollDiceList:number[]=[]
+
+  build() {
+    Column() {
+      YTHeader({ title: '掷筛子' })
+
+      Column(){
+
+        // Column(){
+        //   Video({
+        //     src:$rawfile('[basic].beizi.mp4'),
+        //     controller:this.controller
+        //   })
+        //     .width(300)
+        //     .height(600)
+        //     .objectFit(ImageFit.TOP_START)
+        //     .controls(false)
+        //
+        // }.width('100%')
+        // .height(500)
+        //
+        //
+        //
+        //
+        //
+        //
+        // Row(){
+        //   Button('开始播放').onClick(()=>{
+        //     this.controller.start()
+        //   })
+        //   Button('停止播放').onClick(()=>{
+        //     this.controller.stop()
+        //   })
+        //   // Button('开始播放').onClick(()=>{
+        //   //   this.controller.start()
+        //   // })
+        //
+        //
+        // }.width('100%')
+        // .height('100%')
+
+        //随机选取图片
+       Button('xxx').onClick(()=>{
+         this.RollDiceList=[]
+         this.number=(Math.floor(Math.random()*6)+1)
+
+         for(let i=0;i<this.number;i++){
+          this.RollDiceList.push(this.randomNumber())
+         }
+
+
+         promptAction.showToast({
+           message:this.number.toString()+"----"+JSON.stringify(this.RollDiceList)
+         })
+       })
+        Column() {
+          if (this.number==1) {
+            Column() {
+              Image($r(`[basic].media.shai_${this.RollDiceList[0]+1}`)).width(200).height(200)
+            }
+          }else if (this.number==2){
+            Column(){
+              Row(){
+                Image($r(`[basic].media.shai_${this.RollDiceList[0]+1}`)).width(100).height(100)
+              }.width('100%')
+              .justifyContent(FlexAlign.Start)
+
+              Row(){
+                Image($r(`[basic].media.shai_${this.RollDiceList[1]+1}`)).width(100).height(100)
+              }.width('100%')
+              .justifyContent(FlexAlign.End)
+            }
+          }else if(this.number==3){
+            Column(){
+              Row(){
+                Image($r(`[basic].media.shai_${this.RollDiceList[0]+1}`)).width(100).height(100)
+              }.width('100%')
+              .justifyContent(FlexAlign.Center)
+
+              Row(){
+                Image($r(`[basic].media.shai_${this.RollDiceList[1]+1}`)).width(100).height(100)
+                Image($r(`[basic].media.shai_${this.RollDiceList[2]+1}`)).width(100).height(100)
+              }.width('100%')
+              .justifyContent(FlexAlign.End)
+            }
+          }else if(this.number==4){
+            Column(){
+              Row(){
+                Image($r(`[basic].media.shai_${this.RollDiceList[0]+1}`)).width(100).height(100)
+                Image($r(`[basic].media.shai_${this.RollDiceList[1]+1}`)).width(100).height(100)
+              }.width('100%')
+              .justifyContent(FlexAlign.Center)
+
+              Row(){
+                Image($r(`[basic].media.shai_${this.RollDiceList[2]+1}`)).width(100).height(100)
+                Image($r(`[basic].media.shai_${this.RollDiceList[3]+1}`)).width(100).height(100)
+              }.width('100%')
+              .justifyContent(FlexAlign.End)
+            }
+          }else if(this.number==5){
+            Column(){
+              Row(){
+                Image($r(`[basic].media.shai_${this.RollDiceList[0]+1}`)).width(60).height(60)
+                Image($r(`[basic].media.shai_${this.RollDiceList[1]+1}`)).width(60).height(60)
+              }.width('100%')
+              .justifyContent(FlexAlign.Center)
+
+              Row(){
+                Image($r(`[basic].media.shai_${this.RollDiceList[2]+1}`)).width(60).height(60)
+                Image($r(`[basic].media.shai_${this.RollDiceList[3]+1}`)).width(60).height(60)
+                Image($r(`[basic].media.shai_${this.RollDiceList[4]+1}`)).width(60).height(60)
+              }.width('100%')
+              .justifyContent(FlexAlign.End)
+            }
+          }else if(this.number==6){
+            Column(){
+              Row(){
+                Image($r(`[basic].media.shai_${this.RollDiceList[0]+1}`)).width(60).height(60)
+                Image($r(`[basic].media.shai_${this.RollDiceList[1]+1}`)).width(60).height(60)
+                Image($r(`[basic].media.shai_${this.RollDiceList[2]+1}`)).width(60).height(60)
+
+              }.width('100%')
+              .justifyContent(FlexAlign.Center)
+
+              Row(){
+                Image($r(`[basic].media.shai_${this.RollDiceList[3]+1}`)).width(60).height(60)
+                Image($r(`[basic].media.shai_${this.RollDiceList[4]+1}`)).width(60).height(60)
+                Image($r(`[basic].media.shai_${this.RollDiceList[5]+1}`)).width(60).height(60)
+              }.width('100%')
+              .justifyContent(FlexAlign.End)
+            }
+          }
+        }.width('100%')
+        .height(300)
+
+
+
+
+
+
+        // Column() {
+        // //   if (this.currentIndex == 0) {
+        // //     Image($r('[basic].media.one_1'))
+        // //   } else if (this.currentIndex == 1) {
+        // //     Image($r('[basic].media.one_2'))
+        // //   } else if (this.currentIndex == 2) {
+        // //     Image($r('[basic].media.one_3'))
+        // //   } else if (this.currentIndex == 3) {
+        // //     Image($r('[basic].media.one_4'))
+        // //   } else if (this.currentIndex == 4) {
+        // //     Image($r('[basic].media.one_5'))
+        // //   } else if (this.currentIndex == 5) {
+        // //     Image($r('[basic].media.one_6'))
+        // //   }
+        // // }.width(100)
+        // // .height(100)
+        //
+        //   if (this.currentIndex == 0) {
+        //     Row({space:10}){
+        //       Image($r('[basic].media.one_1')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //     }
+        //
+        //   } else if (this.currentIndex == 1) {
+        //     Row({space:10}){
+        //       Image($r('[basic].media.one_1')).width(50)
+        //       Image($r('[basic].media.one_3')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //     }
+        //   } else if (this.currentIndex == 2) {
+        //     Row({space:10}){
+        //       Image($r('[basic].media.one_1')).width(50)
+        //       Image($r('[basic].media.one_4')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //     }
+        //   } else if (this.currentIndex == 3) {
+        //     Row({space:10}){
+        //       Image($r('[basic].media.one_1')).width(50)
+        //       Image($r('[basic].media.one_5')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //     }
+        //   } else if (this.currentIndex == 4) {
+        //     Row({space:10}){
+        //       Image($r('[basic].media.one_1')).width(50)
+        //       Image($r('[basic].media.one_6')).width(50)
+        //       Image($r('[basic].media.one_1')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //     }
+        //   } else if (this.currentIndex == 5) {
+        //     Row({space:10}){
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_6')).width(50)
+        //       Image($r('[basic].media.one_1')).width(50)
+        //     }
+        //   }
+        //   else if (this.currentIndex == 6) {
+        //     Row({space:10}){
+        //       Image($r('[basic].media.one_1')).width(50)
+        //       Image($r('[basic].media.one_3')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //     }
+        //   }
+        //   else if (this.currentIndex == 7) {
+        //     Row({space:10}){
+        //       Image($r('[basic].media.one_1')).width(50)
+        //       Image($r('[basic].media.one_4')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //     }
+        //   }
+        //   else if (this.currentIndex == 8) {
+        //     Row({space:10}){
+        //       Image($r('[basic].media.one_1')).width(50)
+        //       Image($r('[basic].media.one_5')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //     }
+        //   }
+        //   else if (this.currentIndex == 9) {
+        //     Row({space:10}){
+        //       Image($r('[basic].media.one_1')).width(50)
+        //       Image($r('[basic].media.one_6')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //     }
+        //   }
+        //   else if (this.currentIndex == 10) {
+        //     Row({space:10}){
+        //       Image($r('[basic].media.one_3')).width(50)
+        //       Image($r('[basic].media.one_3')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //     }
+        //   }
+        //   else if (this.currentIndex == 11) {
+        //     Row({space:10}){
+        //       Image($r('[basic].media.one_3')).width(50)
+        //       Image($r('[basic].media.one_4')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //       Image($r('[basic].media.one_2')).width(50)
+        //     }
+        //   }
+        // }.width('100%')
+        // .height(100)
+
+
+
+
+
+      }.width('100%')
+      .height(500)
+      .justifyContent(FlexAlign.Center)
+
+      // ImageAnimator()
+      //   .animatorFancy() // 抽取公共属性
+      //   .images(this.images) // 动画数组
+      //   .duration(this.images.length * 100)// 持续
+      //   .state(this.state)// 动画状态
+      //   .iterations(-1) // 播放次数
+      // //
+      // // Button('x').onClick(()=>{
+      // //   this.currentIndex=Math.floor(Math.random()*6) as number
+      // // })
+      // Button('xx').onClick(()=>{
+      //   this.currentIndex=Math.floor(Math.random()*12) as number
+      // })
+      //
+      // // 按钮控制区域
+      // Row({ space: 20 }) {
+      //   Button('启动').onClick(() => {
+      //     this.state = AnimationStatus.Running
+      //   })
+      //   Button('暂停').onClick(() => {
+      //     this.state = AnimationStatus.Paused
+      //   })
+      //   Button('停止').onClick(() => {
+      //     this.state = AnimationStatus.Stopped
+      //   })
+      // }
+
+
+
+
+    }.padding({ bottom: this.safeBottom })
+    .height('100%')
+    .backgroundColor(Color.White)
+  }
+
+  @Styles
+  animatorFancy() {
+    .width(300)
+    .aspectRatio(2)
+    .padding(10)
+    .borderRadius(10)
+  }
+}

+ 0 - 6
features/feature/src/main/ets/view/SecondView.ets

@@ -1,6 +0,0 @@
-@Component
-export struct SecondView {
-  build() {
-    Text('2')
-  }
-}

+ 0 - 6
features/feature/src/main/ets/view/ThirdView.ets

@@ -1,6 +0,0 @@
-@Component
-export struct ThirdView {
-  build() {
-    Text('3')
-  }
-}

+ 187 - 0
features/feature/src/main/ets/view/TossCoinView.ets

@@ -0,0 +1,187 @@
+import { YTAvoid, YTHeader } from 'basic'
+
+@Builder
+function TossCoinViewBuilder(){
+  NavDestination(){
+    TossCoinView()
+  }.title("抛硬币")
+  .hideTitleBar(true)
+}
+
+@Component
+struct TossCoinView{
+  @StorageProp(YTAvoid.SAFE_TOP_KEY) safeBottom: number = 0
+  @State cellWidth: number = 50 // 单元格宽度
+  @State headsCount: number = 0 // 正面朝上的次数
+  @State tailsCount: number = 0 // 反面朝上的次数
+  @State rotationAngle: number = 40 // 旋转角度
+  @State verticalOffset: number = 0 // 纵向位移
+  @State isAnimRun: boolean = false // 动画是否正在执行
+
+
+  // 判断当前是否显示正面
+  isHeadsFaceUp() {
+    let normalizedAngle = this.rotationAngle % 360; // 规范化角度
+    // 判断角度范围,确定是否显示地鼠面
+    if (normalizedAngle >= 0 && normalizedAngle < 90 || normalizedAngle >= 270 && normalizedAngle <= 360) {
+      return true; // 显示地鼠面
+    }
+    return false; // 显示反面
+  }
+
+  build() {
+    Column() {
+      YTHeader({ title: '抛硬币' })
+
+      // Column(){
+      //   // Text('xxx').onClick(()=>{
+      //   //   router.back()
+      //   // })
+      // }
+      // 页面标题
+      Text('抛硬币')
+        .height(50)// 高度设置为50
+        .width('100%')// 宽度设置为100%
+        .textAlign(TextAlign.Center)// 文本居中对齐
+        .fontColor("#fefefe")// 字体颜色
+        .fontSize(20); // 字体大小
+
+      // 显示地鼠和计数
+      Row({ space: 20 }) {
+        Stack() {
+         Image($r('[basic].media.coinbefore')).width(20).height(20).borderRadius(10)
+
+        }
+        .borderRadius('50%') // 设置圆角
+        .width(20) // 设置宽度
+        .height(20) // 设置高度
+        .linearGradient({
+          // 设置线性渐变背景
+          direction: GradientDirection.LeftBottom,
+          colors: [['#ebcf2f', 0.0], ['#fef888', 0.5], ['#ebcf2f', 1.0]]
+        });
+
+        // 显示反面朝上的次数
+        Text(`${this.tailsCount}`)
+          .fontSize(20)
+          .fontColor(Color.Black);
+
+        Stack() {
+          // 显示100
+          Image($r('[basic].media.coinback')).width(20).height(20).borderRadius(10)
+        }
+        .borderRadius('50%') // 设置圆角
+        .width(20) // 设置宽度
+        .height(20) // 设置高度
+        .linearGradient({
+          // 设置线性渐变背景
+          direction: GradientDirection.LeftBottom,
+          colors: [['#ebcf2f', 0.0], ['#fef888', 0.5], ['#ebcf2f', 1.0]]
+        });
+
+        // 显示正面朝上的次数
+        Text(`${this.headsCount}`)
+          .fontSize(20)
+          .fontColor(Color.Black);
+
+      }.width('100%').justifyContent(FlexAlign.Center); // 设置宽度和内容居中对齐
+
+      Stack() {
+        Stack() {
+          // 创建放大版地鼠组件
+          // Hamster({ cellWidth: this.cellWidth * 3 })
+          //   .visibility(this.isHeadsFaceUp() ? Visibility.Visible : Visibility.Hidden); // 根据状态显示或隐藏
+
+          Image($r('[basic].media.coinbefore')).width('100%').visibility(this.isHeadsFaceUp() ? Visibility.Visible : Visibility.Hidden)
+
+          // 显示100
+          Image($r('[basic].media.coinback'))
+            .width('100%')
+            .visibility(!this.isHeadsFaceUp() ? Visibility.Visible : Visibility.Hidden)// 根据状态显示或隐藏
+            .rotate({
+              // 旋转180度
+              x: 1,
+              y: 0,
+              z: 0,
+              angle: 180
+            });
+        }
+        .borderRadius('50%') // 设置圆角
+        .width(100) // 设置宽度
+        .height(100) // 设置高度
+        .shadow({
+          radius:5,
+          color:"#f8cd46",
+          offsetY:this.isHeadsFaceUp() ?15:-15
+        })
+        // .linearGradient({
+        //   // 设置线性渐变背景
+        //   direction: GradientDirection.LeftBottom,
+        //   colors: [['#ebcf2f', 0.0], ['#fef888', 0.5], ['#ebcf2f', 1.0]]
+        // })
+        .rotate({
+          // 根据当前角度旋转
+          x: 1,
+          y: 0,
+          z: 0,
+          // angle:30
+          angle: this.rotationAngle
+        })
+        .translate({ x: 0, y: this.verticalOffset }) // 设置纵向位移
+        .onClick(() => { // 点击事件处理
+
+          if (this.isAnimRun) {
+            return;
+          }
+          this.isAnimRun = true
+
+          let maxAnimationSteps = 2 * (10 + Math.floor(Math.random() * 10)); // 计算最大动画次数
+          let totalAnimationDuration = 1500; // 动画总时长 2000
+
+          // 第一次动画,向上抛出
+          animateToImmediately({
+            duration: totalAnimationDuration / 2, // 动画时长为总时长的一半
+            onFinish: () => { // 动画完成后的回调
+              // 第二次动画,向下落
+              animateToImmediately({
+                duration: totalAnimationDuration / 2,
+                onFinish: () => {
+                  this.rotationAngle = this.rotationAngle % 360; // 确保角度在0到360之间
+                  // 判断当前显示的面
+                  if (this.isHeadsFaceUp()) { // 如果是地鼠面
+                    this.tailsCount++; // 反面朝上的次数加1
+                  } else { // 如果是反面
+                    this.headsCount++; // 正面朝上的次数加1
+                  }
+                  this.isAnimRun = false
+                }
+              }, () => {
+                this.verticalOffset = 0; // 重置纵向位移
+              });
+            }
+          }, () => {
+            // 设置纵向位移,模拟抛硬币的效果
+            this.verticalOffset = -100 * (1 + Math.floor(Math.random() * 5)); // 随机设置向上的位移
+          });
+
+          // 循环动画,增加旋转效果
+          for (let i = 0; i < maxAnimationSteps; i++) {
+            animateToImmediately({
+              delay: i * totalAnimationDuration / maxAnimationSteps, // 设置每次动画的延迟
+              duration: 100, // 每次动画的持续时间
+              onFinish: () => {
+                // 动画完成后的回调
+              }
+            }, () => {
+              this.rotationAngle += 90; // 每次增加90度旋转
+            });
+          }
+        });
+      }.width('100%').layoutWeight(1).align(Alignment.Bottom).padding({ bottom: 80 }); // 设置组件的宽度、权重、对齐方式和底部内边距
+
+
+    }.padding({ bottom: this.safeBottom })
+    .height('100%')
+    .backgroundColor(Color.White)
+  }
+}

+ 25 - 1
features/feature/src/main/resources/base/profile/router_map.json

@@ -1,5 +1,29 @@
 {
   "routerMap": [
-
+    {
+      "name": "TossCoinView",
+      "pageSourceFile": "src/main/ets/view/TossCoinView.ets",
+      "buildFunction": "TossCoinViewBuilder"
+    },
+    {
+      "name": "RollDiceView",
+      "pageSourceFile": "src/main/ets/view/RollDiceView.ets",
+      "buildFunction": "RollDiceViewBuilder"
+    },
+    {
+      "name": "RanNumberView",
+      "pageSourceFile": "src/main/ets/view/RanNumberView.ets",
+      "buildFunction": "RanNumberViewBuilder"
+    },
+    {
+      "name": "EatWhatView",
+      "pageSourceFile": "src/main/ets/view/EatWhatView.ets",
+      "buildFunction": "EatWhatViewBuilder"
+    },
+    {
+      "name": "BigWheelView",
+      "pageSourceFile": "src/main/ets/view/BigWheelView.ets",
+      "buildFunction": "BigWheelViewBuilder"
+    }
   ]
 }

+ 9 - 23
products/entry/src/main/ets/pages/Index.ets

@@ -1,33 +1,23 @@
-import { BasicType, YTAvoid, yTRouter, yTToast } from 'basic';
+import { BasicType, YTAvoid, yTRouter, yTToast} from 'basic';
 import { Mine } from 'user/src/main/ets/views/Mine';
-import { MainView, SecondView, ThirdView } from 'feature';
+import { MainView} from 'feature';
 
 @Entry
 @Component
 struct Index {
   @State currentIndex: number = 0
-  @StorageProp(YTAvoid.SAFE_BOTTOM_KEY) bottom: number = 0
+  @StorageProp(YTAvoid.SAFE_TOP_KEY) bottom: number = 0
   //tabs展示内容
   contentList: BasicType<undefined>[] = [
     {
-      text: '日历',
-      src: $r('app.media.app_icon'),
-      acSrc: $r('app.media.app_icon')
-    },
-    {
-      text: '黄历',
-      src: $r('app.media.app_icon'),
-      acSrc: $r('app.media.app_icon')
-    },
-    {
-      text: '卡片',
-      src: $r('app.media.app_icon'),
-      acSrc: $r('app.media.app_icon')
+      text: '工具',
+      src: $r('app.media.homeuns'),
+      acSrc: $r('app.media.homes')
     },
     {
       text: '我的',
-      src: $r('app.media.app_icon'),
-      acSrc: $r('app.media.app_icon')
+      src: $r('app.media.myuns'),
+      acSrc: $r('app.media.mys')
     }
   ]
   tabsController: TabsController = new TabsController()
@@ -37,8 +27,8 @@ struct Index {
       context: this.getUIContext(),
       options: { alignment: DialogAlignment.Center, maskColor: '#80000000' }
     })
+    yTRouter.router2LoginPage()
   }
-
   build() {
     Navigation(yTRouter) {
       Column() {
@@ -48,10 +38,6 @@ struct Index {
               if (index == 0) {
                 //放对应组件
                 MainView()
-              } else if (index == 1) {
-                SecondView()
-              } else if (index == 2) {
-                ThirdView()
               } else {
                 Mine()
               }

BIN
products/entry/src/main/resources/base/media/homes.png


BIN
products/entry/src/main/resources/base/media/homeuns.png


BIN
products/entry/src/main/resources/base/media/mys.png


BIN
products/entry/src/main/resources/base/media/myuns.png