管理员

刷新换图
没有文字

最后由 O了吗 编辑
管理员
"ui";
path = "/sdcard/Download/img1/";
var url = "https://api.tujian.ml/suiji/api.php";
files.createWithDirs(path);
ui.statusBarColor("#ff000000")
ui.layout(
    <vertical>
        <frame>
            <img  id="h1"  margin="-140,0,0,0" />
            <text id="tips" text="" margin="130,250" w="150" h="30" textColor="black"/>
            <text id="catchtext" text="" margin="0,0,0,0" textColor="black"/>
            <button id="last" margin="90,0,0,0" w="200" h="200" text="上一张" style="Widget.AppCompat.Button.Borderless"/>
            <button id="next" margin="90,50,0,450" w="200" h="200" text="下一张" style="Widget.AppCompat.Button.Borderless"/>
            <button id="download_more" margin="40,0,0,570" w="80" h="50" text="下载多张" style="Widget.AppCompat.Button.Borderless"/>
            <button id="download" margin="0,0,0,590" w="60" h="50" text="下载" style="Widget.AppCompat.Button.Borderless" />
        </frame>
        <text text="请使用横屏浏览" textSize="20sp" textColor="black" margin="100"/>
    </vertical>
);
var img = [];
var n = 8;  //预加载数量
var top = 0;
ui.tips.setText("初始化中,请稍后");
//开始加载图片
threads.start(function () {
    let i = 0;
    while (true) {
        if (i - top < n) {
            img[i] = images.load(url);
            if (i == 0) {
                top++;
                ui.run(function () {
                    ui.tips.setText("");
                    ui.h1.setSource(img[i]);
                });
            }
            i++;
            ui.run(function () {
                ui.tips.setText("");
            });
        }
        else {
            sleep(500);
        }
    }
});

ui.next.click(() => {
    if (top < img.length) {
        ui.next.setText("");
        ui.last.setText("");
        ui.tips.setText("");
        ui.catchtext.setText("");
        ui.h1.setSource(img[top++]);
    }
    else {
        ui.tips.setText("努力加载中");
    }
});

ui.last.click(() => {
    if (top > 1) {
        --top;
        ui.tips.setText("");
        ui.catchtext.setText("");
        ui.h1.setSource(img[top - 1]);
    }
});
ui.download.click(() => {
    a = threads.start(function () {
        ui.catchtext.setText("请稍等...");
        images.save(img[top - 1], path + new Date().toTimeString().substr(0, 8) + " " + random() + ".png");
        ui.catchtext.setText("已保存到" + path);
    });
});

ui.download_more.click(() => {
    threads.start(function () {
        n = dialogs.input("下载几张?", "10");
        if(n != null){
            for (i = 1; i <= n; i++) {
                ui.catchtext.setText("已下载 " + (i - 1) / n * 100 + "%");
                img1 = images.load(url);
                name = new Date().toTimeString().substr(0, 8) + " " + random() + ".png";
                images.save(img1, path + name);
            }
            ui.catchtext.setText("全部已下载到" + path);
        }
    });
});


管理员

我的是auto4.0.0 beta

  • 6
    帖子
  • 437
    浏览

与 Auto.js 的连接断开,我们正在尝试重连,请耐心等待