编辑代码

图形化显示数组
//函数2:图形化显示数组
func displayArrayGraph() {
    let myView1 = self.view.viewWithTag(2001) as! UIImageView
    let myView2 = self.view.viewWithTag(2002) as! UIImageView
    myView1.backgroundColor = .darkGray
    myView2.backgroundColor = .darkGray

    let h = myView1.frame.size.height
    let w = myView1.frame.size.width

    let padding : CGFloat = 5
    let margin : CGFloat = 10

    //计算每个格子的高度和宽度
    let grid_w = (w - margin * 2 - padding * CGFloat(cols-1)) / CGFloat(cols)
    let grid_h = (h - margin * 2 - padding * CGFloat(rows-1)) / CGFloat(rows)

    for i in 0..<rows {
        for j in 0..<cols {
            let x = margin + CGFloat(j) * (grid_w + padding)
            let y = margin + CGFloat(i) * (grid_h + padding)
            let rect = CGFloat(x: x, y:y, width: grid_w, height: grid_h)
            //在上面的ImageView中显示
            let fileName1 = iv1[i*cols+j]
            let img1 = UIImage(named: fileName1)
            let imgView1 = UIImageView(frame: rect)
            imgView1.image = img1
            imgView1.backgroundColor = .yellow
            myView1.addSubview(imgView1)
            //在下面的ImageView中显示
            let fileName2 = iv2[i*cols+j]
            let img2 = UIImage(named: fileName2)
            let imgView2 = UIImageView(frame: rect)
            imgView2.image = img2
            imgView2.backgroundColor = .yellow
            myView2.addSubview(imgView2)
        }
    }
}
淘宝满减
package com.lyd.wx.uitls;
import java.math.BigDecimal;
import java.util.Scanner;

/**
 * @description: TODO
 * @author haiyang
 * @date 2023/5/11 22:15
 * @version 1.0
 *
 * 满减系数 30(n-1)
 *
 * 1 0-299       0
 * 2 300-599     30
 * 3 600-899     60
 * 4 900-1199    90
 */
public class Price {

    private static final int DEF_DIV_SCALE = 2;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        double superValue = 300;
        int fijo = 30;
        double progress = 299;
        System.out.println("请输入成本价格:");
        double cost = sc.nextInt();

        System.out.println("请输入你想售卖的价格:");
        double sellingPrice = sc.nextInt();

        //优惠券
        double coupon = 0.0;
        //区间最大值 = 成本价 + 299
        double intervalMax = sellingPrice + superValue;
        //系数区间 向下取整
        double na = Math.floor(intervalMax / superValue);
        int ya = new Double(na).intValue();

        //系数区间 向上取整
        double nb = Math.ceil(intervalMax / superValue);
        int yb = new Double(nb).intValue();
//        // 当前满减优惠金额 30(n-1)
//        double full = fijo * (na - 1);
//        //满减区间最小值
//        double fullMin =  full * 10;
//        System.out.println("当前满减区间["+fullMin+","+add(fullMin,progress)+"]"+"当前满减优惠最大金额: "+ full);
//        System.out.println("当前产品定价: "+ sellingPrice);
//
//        //当前优惠券最大设置值
//        coupon = sub(sub(sellingPrice,full),cost);
//        System.out.println("当前优惠券最大设置值: "+ coupon);
//
//
//        System.out.println("--------------------------递增区间-----------------------------");
//        double fullIncrement = fijo * (nb - 1);
//        //满减区间最小值
//        double fullIncrementMin =  fullIncrement * 10;
//        System.out.println("递增满减区间["+fullIncrementMin+","+add(fullIncrementMin,progress)+"]"+"当前满减优惠最大金额: "+ fullIncrement);
//        System.out.println("当前产品定价: "+ sellingPrice);
//
//        //当前优惠券最大设置值
//        double couponIncrement = sub(sub(sellingPrice,fullIncrement),cost);
//        System.out.println("当前优惠券最大设置值: "+ couponIncrement);

        for (int i = 1; i < 20; i++) {
            double full = fijo * (i - 1);
            //满减区间最小值
            double priceMin =  full * 10;
            System.out.println("当前产品定价: "+ sellingPrice);

            //当前优惠券最大设置值

            if (full != 0){
                double fullMax = div(sellingPrice,priceMin,2) * full;
                System.out.println("当前满减区间["+priceMin+","+add(priceMin,progress)+"]"+"当前满减优惠最大金额: "+ fullMax);

                coupon = sub(sub(sellingPrice,fullMax),cost);
                System.out.println("当前优惠券最大设置值: "+ coupon);
                System.out.println();
            }else {
                System.out.println("当前满减区间["+priceMin+","+add(priceMin,progress)+"]"+"当前满减优惠最大金额: "+ full);
                coupon = sub(sub(sellingPrice,full),cost);
                System.out.println("当前优惠券最大设置值: "+ coupon);
                System.out.println();
            }
        }
    }

    /**
     * @Description 两个Double数相乘
     *
     * @param d1
     * @param d2
     * @return Double
     */
    public static Double mul(Double d1,Double d2){
        BigDecimal b1 = new BigDecimal(d1.toString());
        BigDecimal b2 = new BigDecimal(d2.toString());
        return b1.multiply(b2).doubleValue();
    }

    /**
     * @Description 两个Double数相除
     *
     * @param d1
     * @param d2
     * @return Double
     */
    public static Double div(Double d1,Double d2){
        BigDecimal b1 = new BigDecimal(d1.toString());
        BigDecimal b2 = new BigDecimal(d2.toString());
        return b1.divide(b2,DEF_DIV_SCALE,BigDecimal.ROUND_HALF_UP).doubleValue();
    }

    /**
     * @Description 两个Double数相除,并保留scale位小数
     *
     * @param d1
     * @param d2
     * @param scale
     * @return Double
     */
    public static Double div(Double d1,Double d2,int scale){
        if(scale<0){
            throw new IllegalArgumentException(
                    "The scale must be a positive integer or zero");
        }
        BigDecimal b1 = new BigDecimal(d1.toString());
        BigDecimal b2 = new BigDecimal(d2.toString());
        return b1.divide(b2,scale,BigDecimal.ROUND_HALF_UP).doubleValue();
    }

    public static double sub(double v1,double v2){
         BigDecimal b1 = new BigDecimal(Double.toString(v1));
         BigDecimal b2 = new BigDecimal(Double.toString(v2));
         return b1.subtract(b2).doubleValue();
    }

    public static double add(double v1,double v2){
        BigDecimal b1 = new BigDecimal(Double.toString(v1));
        BigDecimal b2 = new BigDecimal(Double.toString(v2));
        return b1.add(b2).doubleValue();
    }
}

//函数 3:图形化显示程序,支持 Button
     func displayArrayGraphButton () {
          let myViewlgelf.vlew.yiewwithTag(2001) as! UIImagevien
          1et ByVie2=Be1f.view.viewithTag(2002) as! UIImageViem
          myViewl.backgroundColor = .darkGray
          myView2.backgroundColor = .darkGray
          //支持View可以进行交互等操作
         myView1.isUserInteractionEnabled = true
         myView2.isUserInteractionEnabled = true

         let h = myViewl.frame.size.height
         let w=myViewl.frame.size.width

         let padding : CGFloat = 5
         let margin : CGFloat = 10

         //计算每个格子的高度和宽度
          let grid_w = (w- margin *2 - paodding*OGEloat (co1s-1))/ CGFloat (cols)
          let grid_h = (h - margin*2 - padding*CGFloat (rows-1))/ CGFLoat (rows)

         for i in 0..<rows {
         for j in 0..<cols {
         let x = margin + CGFloat(j) * (grid_w + padding)
         let y = margin + CGFloat(i) * (grid h + padding)
         let rect = CGRect(x: x, y:y, width: grid_w, height: grid_h)
         // 在上面的 ImageView中显示
         let fileNamel = iv1 [i*cols+j]
         let imgl = UIImage(named: fileName1)
         let btnl = UIButton(frame: rect)
         btnl.setImage(imgl, for: .normal)
         tnl.backgroundColor= .yellow
         //Button的tag设定为4000及以上
         btnl.tag= i*cols+j + 4000
         btnl.addTarget(self,action: #selector(buttonCheck(_:))for:,.touchUpInside)
         myViewl.addSubview(btnl)
         //在下面的 ImageView 中显示
         let fileName2 = iv2[1*cols+j]
         let img2 UIImage (named:fileName2)
         let btn2= UIButton(frame: rect)
         btn2.setImage(img2, for:.normal)
         btn2.backgroundColor =·yellow
         //Button的tag设定为5000及以上
         btn2.tag = i*cols+j + 5000
         btn2.addTarget(self, action: #selector(buttonCheck(_:)),for: ,touchipinside)
         myView2.addSubview(btn2)
         }
         }
     }

3.Button事件的响应函数
当不同点的Button被单击后,首先根据其tag的数值,来分析是上面还是下面aton.其具体位置,包括行号和列号。
这个函数比较特殊,其前面有@objc标志,含是按照Objective C的调用规范。
函数4的功能是显示当前被单击的那个Button的行号列号。
//函数4:不同点的Button 被单击后调用
   objc func buttonCheck(_ sender : UIButton)(
   let tipsLabel = self.view.viewWithTag(1001) as! UILabel
   let tag = sender.tag
   if tag >= 5000 
        let row = Int ((tag - 5000)/ cols)
        let col = tag - 5000 - cols * row
        print("Bottom(\(row),\(col))")
        tipsLabel.text= "Bottom(\(row),\(col)) "
}
    else if tag >= 4000(
        let row = Int ((tag - 4000)/ cols)
       let col = tag - 4000 - cols * row
       print("Top(\(row),\(col))")
       tipsLabel.text="Top(\(row),\(col))"
}
    else {
     print("Button.tag=\(sender.tag)")
     tipsLabel.text ="Button.tag=\(sender.tag)"
    }
 }

4.相同于扰项函数
这个就是函数4,用于随机的生成干扰项。同时把这些位置记录在conds数组中,另
个保存有小图片的数组images。
//函数五:生成平抗项的随机位置和随机内容
    func distractorCreate(mount:Int){
    for _ in 0..<mount {
     let col = Int (arc4random()) % cols
     let row = Int (arc4random()) % rows

     cords.append((row,col))
     /从 images 提供的字符中选择一个
     let index = Int(arc4random()) images.count
     //影响1v1和1v2这两个图形
     1v1[cols*row + col = images[index]
     1v2[cols*row + col] = images[index]
    }
}
5. 新增数据定义
干找项函数需要新增两个数组,因此需要修改数据定义部分内容,增加两个数组cords 和images。
//数据定义开始--
//定义行数和列数
let rows = 8
let cols = 8
//定义上下两个图形数组
var ivl : Array<String>= []
var iv2 :Array<String>=
//定义上下相同的干扰项数组
var cords : Array<(Int,Int)> []
//干扰项和不同项只能是小图形
let images:Array<String>=["bird","bee", "flower", "mogu"]
/ / 数据定义结束 --

//函数六:生成不同项的随机位置和随机内容
func differenceCreate(mount:Int){
    for _ in 0..<mount {
        let col = Int(arc4random()) % cols
        let row = Int(arc4random()) % rows

        errorCords.append((row,col))
        //从images提供的字符中选择一个
        let indx = Int(arc4random()) % images.count
        //选择上面图形 还是下面图形
        let which = Int(arc4tandom()) % 2
        //影响iv1和iv2这两个图形
        if which == 0 {
            iv1[cols*row + col] = images[index]
        }
        else {
             iv2[cols*row + col] = images[index] 
        }
    }
}
//函数七:不同点的Button被单击后调用,支持音效
@objc func buttonCheckMusic(_ sender : UIButton) {
    let tispsLabel = self.view.viewWithTag(1001) as! UILabel
    var tag = sender.tar
    if tag >= 5000 {
        tag -= 5000
    }
    else if tag >= 4000 {
        tag -= 4000
    }
    let row = Int (tag / cols)
    let col = tag  - cols * row
    let result = errorCords.filter {
        $0 == (row,col)
    }
    if result.count >=1 {
        let path = Bundle.main.path(forResource:"birdsound",ofType:"m4a")
        let ur1 = URL(fileURLWithPath: path!)
        soundPlayer=try? AVAudioPlayer(contentsOf: ur1)
        soundPlayer.play()
        tipsLabel.text = "不同找到: (\(row),\(col))"
    }
    else {
        let path = Bundle.main.path(forResource: "error", ofType:"m4a")
        let ur1 = URL(fileURLWithPath: path!)
        soundPlayer=try? AVAudioPlayer(contentsOf: UR1)
        soundPlayer.play()
        tipsLabel.text = "找错啦: (\(row),\(col))"
    }
}


4.实现音效功能
btnl.addTarget(self, action: #selector(buttonCheckMusic(_:)),for: .touchUpInside)
btn2.addTarget(self, action: #selector(buttonCheckMusic(_:)),for: .touchUpInside)

4.2.4计时功能
//游戏是否结束标记
var GameOver = flase
//游戏开始时间戳
var beginTimestamp : Int = 0
//游戏限定时间,单位:秒
let GamePeriod = 20
//游戏本次花费时间,单位:秒
var TimeCost = 0

//函数8:获得当前时间戳
func getCurrentTimeStamp() -> Int {
    let now = Date()
    let timeInterval : timeInterval = now.timeIntervalSince1970
    return Int(timeInterval)
}

//函数9:定时器倒计时函数,显示当前消耗时间和倒计时
func timeElapse() {
    Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) {
        (timer) in
        let timestamp = self.getCurrentTimeStamp()
        let pastPeriod = timestamp - self.neginTimestamp
        let countDown = self.GamePeriod - pastPeriod
        self.TimeCost = pastPeriod
        if countDown <= 0 || self.GameOver {
            self.GameOver = true
            let tipsLabel = self.view.viewWithTag(1001) as! UILabel
            tipsLabel.text = "游戏结束,共消耗时间\(self.TimeCost)秒"
            timer.invalidate()
        }
        let tipsLabel = self.view.viewWithTag(1002) as! UILabel
        DispatchQueue.main.async {
            tipsLabel.text = "您消耗\(pastPeriod)秒,倒计时\(countDown)秒"
        }
        
    }
}
3.修改Button函数支持计时
//函数10:不同点的Button被单机后调用,支持音效,计时,游戏结束
@objc func buttonCheckMusicTimer(_sender : UIButton){
    if GameOver {return}
    let tipsLabel=self.view.viewWithTag(1001) as! UILabel
    var tag=sender.tag
    if tag >= 5000 {
        tag -=5000
    }
    else if tsg >= 4000 {
        tag -=4000
    }
    let row = Int (tag / cols)
    let col - tag  - cols * row
    let result = errorCords.filter {
        $0 == (row,col)
    }
    let reserved = errorCords.filter {
        $0 != (row,col)
    }
    errorCords = reserved

    if result.count >= 1 {
        sender.backgroundColor = .reservedlet path = Bundle.main.path(forResource: "birdsound", ofType: "m4a")
        let ur1 = URL(fileURLWithPath:path!)
        soundPlayer=try? AVAudioPlayer(contentsOf: ur1)
        soundPlayer.play()
        tipsLabel.text = "不同找到:(\(row),\(col)),还剩\(errorCords.count)个"
        if errorCords.count <= 0 {
            GameOver = true
            tipsLabel.text = "任务完成,共花费时间\(self.TimeCost) 秒"
        }
    }
    else {
        sender.backgroundColor = .brown
        let path = Bunble.main.path(forResource: "error", ofType:"m4a")
        let ur1 = URL(fileURLWithPath: path!)
        soundPlayer=try? AVAudioPlayer(contentsOF: ur1)
        soundPlayer.play()
        tispLabel.text = "找错了: (\(row),\(col))"
    }
}
4.功能实现
//实现功效
btnl.addTarget(self, action: #selector(buttonCheckMusic(_:)),for: .touchUpInside)
btn2.addTarget(self, action: #selector(buttonCheckMusic(_:)),for: .touchUpInside)

//游戏结束标志
GameOver = flase
//获取游戏开始时间并保存
beginTimestamp=getCurrentTimeStamp
//倒计时
timeInterval()
//数组初始化
initGame()
distractorCreate(mount: 5)
differenceCreate(mount: 3)
displayArrayGraphButton()
4.2.5游戏提示
//函数11:图形化显示程序,支持Button,支持提示功能
func displayArrayGraphBottonTops() {
        let myView1 = self.view.viewWithTag(2001) as! UIImageView
        let myView2 = self.view.viewWithTag(2002) as! UIImageView
        myView1.backgroundColor = .darkGray
        myView2.backgroundColor = .darkGray
        //支持View可以进行交互等操作
        myView1.isUserInteractionEnabled = true
        myView2.isUserInteractionEnabled = true

        let h = myView1.frame.size.height
        let w = myView2.framesize.width

        let padding : CGFloat = 5
        let margin : CGFloat = 10

        //计算每个格子的高度和宽度
        let grid_w = (w-margin * 2 - padding * CGFloat(cols-1)) / CGFloat(cols)
        let grid_h = (h-margin * 2 - padding * CGFloat(cols-1)) / CGFloat(cols)

        for i in 0..<rows {
            for j in 0..<cols {
            let x = margin + CGFloat(j) * (grid_w + padding)
            let y = margin + CGFloat(i) * (grid_h + padding)
            let rect = CGFloat(x: x,y:y ,width:grid_w,height:grid_h)
            
            //在上面的ImageView中显示
            let fileName1 = iv1[i*cols+j]
            let tag1 =i*cols+j + 5000
            addButton(view.myView1,rect: ret, fileName: fileName1,tag: tag1)

            //在下面的ImageView中显示
            let fileName2 = iv1[i*cols+j]
            let tag2 =i*cols+j + 5000
            addButton(view.myView2,rect: ret, fileName: fileName2,tag: tag2)

            }
       
        }

//函数12:View上面添加Button的函数,提示功能,用于减少代码数量
    func addButton(view:UIView,rect:CGRect,fileName:String,tag:Int) {
        let img = UIImage(named: fileName)
        let bth = UIButton(frame: rect)
    bth.setImage(img, for: .normal)

    var mytag = tag
    if mytag >= 5000 {
        mytag -= 5000
    }
    eles if mytag >= 4000 {
        mytag -= 4000
    }
    let row = Int (mytag / cols)
    let col = mytag - cols * row

    let result = errorCords.filter {
        $0 == (row,col)
    }

    if result.count >= 1 && TipsFlag {
        btn.backgroundColor = .blue
    }
    eles {
        btn.backgroundColor = .yellow
    }
    btn.tag = tag
    btn.addTarget(self, action:: #selector(buttonCheckMusicTimer(_:)),for: .touchUpInside)
    view.addSubview(btn)
}
@IBAction func onBegin(_ sender : UIButton){
    //游戏结束标志
    GameOver = false
    //获取游戏开始时间并保存
    beginTimestamp = getCurrenTimeStamp()
    //倒计时
    timeElapse()
    //数组初始化
    initGame()
    distractorCreate(mount: 5)
    differenceCreate(mount: 3)
    displarArrayGraphButtonTips()
}
新增函数13,修改函数12和函数11
removeAllreAllSubViews(view:myView1)
removeAllreAllSubViews(view:myView2)

//函数12:View上面添加Button的函数,提示功能,用于减少代码数量
func addButton(view:UIView,rect:CGRect,fileName:String,tag:Int) {
    let img = UIImage(named: fileName)
    let bth = UIButton(frame: rect)
    bth.setImage(img, for: .normal)

    var mytag = tag
    if mytag >= 5000 {
        mytag -= 5000
    }
    else if mytag >= 4000 {
        mytag -= 4000
    }
    let row = Int (mytag / cols)
    let col = mytag - cols * row

    let result = errorCords.filter {
        $0 == (row,col)
    }

    if result.count >= 1 && TipsFlag {
        btn.backgroundColor = .blue
        btn.tag = tag1btn.addTarget(self,action: #selector(buttonCheckMusicTimer(_:)),for: touchUpInside)
        view.addSubview(btn)
    }

    let result1 = cords.filter {
        $0 == (row,col)
    }
    if resultl.count >= 1 {
        btn.tag = tag
        btn.addTarget(self, action: #selector(buttonCheckMusicTimer(_:)),for: .touchUpInside)
        view.addSubview(btn)
    }
}

//函数13:移除所有子控件
func removeAllSubviews(view:UIView) {
    if view.subviews.count>0 {
        view.subviews.forEach({$0.removeFromSuperview()})
    }
}

@IBAction func onTips(_ sender : UIButton) {
    TipsFlag = !TipsFlag
    displayArrayGraphButtonTisp()
}

@IBAction Func onBegin(_ sends : UIButton) {
    //游戏结束标志
    GameOver = false
    //获取游戏开始时间并保存
    beginTimestamp = getCurrenTimeStamp()
    //倒计时
    timeElapse()
    //数组初始化
    initGame()
    distractorCreate(mount: 10)
    differenceCreate(mount: 8)
    displarArrayGraphButtonTips()
}

@IBAction Func onNext(_ sends : UIButton) {
    GameOver = true
    TipsFlag = falas
    let myView1 = self.view.viewWithTag(2001) as! UIImageView
    let myView2 = self.view.viewWithTag(2002) as! UIImageView
    CurrentBackground += 1
    if CurrentBackground > 4 {
        CurrentBackground = 1
    }
    let image = UIImage(named: "back0\(CurrentBackground)")!
    myView1.image = image
    myView2.image = image
    removeAllSubViews(view: myView1)
    removeAllSubViews(view: myView2)
}
4.3.2登录界面的实现
//
//ContentView.swift
//LoginSwiftUI
//
//Created by Zhifeng Chen on 2020/8/1.
//Copyright ⓒ 2020 zhifeng Chen. All rights reserved.
//
import SwiftUI

struct ContentView : View {

    @State var userName : String = ""
    @State var passWord : String = ""

    var body: some View {
        VStack {
            Text("欢迎使用找不同")
            .font(.title)
            .padding()
            Divider()
            .background(Color(.brown))
            Image(systemName:"person")
            .resizable()
            .frame(width: 150, height: 150)
            .cornerRadius(50)

            VStack {
                TextField("请输入用户名", text: $userName)
                .padding()
                .padding(.leading,10)
                .background(Color(.lightGray))
                .cornerRadius(15)
                TextField("请输入密码", text: $passWord)
                .padding()
                .padding(.leading,10)
                .background(Color(.lightGray))
                .cornerRadius(15)
            }
            .padding()
            Button(action: {
                print("被点击了...")
            }, label: {Text("登录")}) 
            .padding()
            Spacer()   
            
        }
    }
}
struct ContentView_Previews : PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

//
//ContentView.swift
//LoginSwiftUI
//
//Created by Zhifeng Chen on 2020/8/1.
//Copyright ⓒ 2020 zhifeng Chen. All rights reserved.
//
import SwiftUI

let lightGrayColor = Color(red: 239.0/255.0, green: 243.0/255.0, blue: 244.0/255.0, opacity: 1.0)
struct ContentView : View {
    //保存输入的用户名
    @State var userName : String = ""
    //保存输入的密码
    @State var passWord : String = ""
    //是否需要弹出Alert窗口
    @State private var alertFlag : Bool = false
    //弹出窗口里面的具体内容
    @State private var alertMsg : String = ""
    var  body: some View {
        VStack {
            Text("欢迎使用找不同")
            .font(.title) //字体大小为标题
            .padding() //四周间隔
            Divider()
            .background(Color(.brown)) //背景色为brown
            Image("back02") //图片back02.png
            .resizable() //允许改变图像尺寸
            .frame(width: 150, height: 150) //尺寸改为150*150
            .cornerRadius(150) //圆角半径50
            VStack {
                TextField("请输入用户名", text: $userName)
                .padding() //四周默认间隔
                .padding(.leading,10) //前方间隔10
                .background(lightGrayColor) //背景色
                .cornerRadius(15) //圆角半径15
                TextField("请输入密码", text: $passWord)
                .padding() //四周默认间隔
                .padding(.leading,10) //前方间隔10
                .background(lightGrayColor) //背景色
                .cornerRadius(15) //圆角半径15
            }
            .padding() //四周默认间隔
            Button(action: {
                if self.userName == "Zfchen" && self.passWord == "123" {
                    self.alertFlag = true
                    self.alertMsg = "登录成功"
                }
                else {
                    self.alertFlag = true
                    self.alertMsg = "登录失败"
                }
            }, label: {
                Text("登录")
                .font(.headline)
                .foregroundColor(.white)
                .frame(width: 220, height: 60)
                .background(Color.green)
                .cornerRadius(15.0)
            })
            .padding()
            Spacer()
        }
        .alert(isPresented: $alertFlag) { () -> Alert in
        Alert(title: Text("登录提示"), message: Text(self.alertMsg), dismissButton: .default(Text("确定")))
        }
    }
}
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}