B2B网络软件

 找回密码
 立即注册 审核网站号:QQ:896757558
搜索
查看: 1|回复: 0
打印 上一主题 下一主题

AIWROK软件双窗口悬浮日志系统

[复制链接]

1182

主题

1187

帖子

8005

积分

abc

Rank: 9Rank: 9Rank: 9

积分
8005
跳转到指定楼层
楼主
AIWROK软件双窗口悬浮日志系统
AIWROK软件双窗口悬浮日志系统 B2B网络软件

AIWROK软件双窗口悬浮日志系统 B2B网络软件

AIWROK软件双窗口悬浮日志系统 B2B网络软件

  1. /**
  2. * AIWROK 双窗口悬浮日志系统(极简版)
  3. * - 窗口 A:主日志面板(大,左侧),滚动显示
  4. * - 窗口 B:实时统计面板(小,右上),计数/耗时/状态
  5. * 适用:安卓 Rhino ES5 · AIWROK
  6. */

  7. importClass(java.lang.Thread);

  8. // ======================== 基础 ========================
  9. function doSleep(ms) { try { Thread.sleep(ms); } catch (e) {} }

  10. // ======================== 主日志窗口 A ========================
  11. var winA = {
  12.     floatUI: null,
  13.     tvLog: null,
  14.     tvTitle: null,
  15.     lines: [],          // 用数组存所有日志行,setText 时 join 全部输出
  16.     count: 0,
  17.     MAX_LINES: 100,     // 最多保留 100 行,超出裁掉旧的

  18.     init: function() {
  19.         this.floatUI = new floatUI();
  20.         var sw = screen.getScreenWidth();
  21.         var sh = screen.getScreenHeight();
  22.         printl("[屏幕] " + sw + "x" + sh);
  23.         // 窗口 A:宽度 40%,高度 22%,贴顶部 8%
  24.         var w = Math.floor(sw * 0.40);
  25.         var h = Math.floor(sh * 0.22);
  26.         var x = 8;
  27.         var y = Math.floor(sh * 0.08);

  28.         var xml = '<LinearLayout orientation="vertical" w="' + w + '" h="' + h +
  29.                   '" background="#881e293b">' +
  30.                   '  <TextView id="title" text="[ 运行日志 ] 共 0 条" ' +
  31.                   'textColor="#7dd3fc" textSize="13" padding="6" background="#441e40af"/>' +
  32.                   '  <ScrollView w="fill_parent" h="fill_parent">' +
  33.                   '    <TextView id="logBox" w="fill_parent" h="fill_parent" text="" ' +
  34.                   'textColor="#f1f5f9" textSize="11" padding="6"/>' +
  35.                   '  </ScrollView>' +
  36.                   '</LinearLayout>';

  37.         try {
  38.             this.floatUI.loadXML(xml);
  39.             this.floatUI.setPosition(x, y);
  40.             this.tvTitle = this.floatUI.findViewById("title");
  41.             this.tvLog   = this.floatUI.findViewById("logBox");
  42.             printl("[窗口A] OK  pos=(" + x + "," + y + ")  size=" + w + "x" + h);
  43.             return true;
  44.         } catch (e) {
  45.             printl("[窗口A] 失败: " + e);
  46.             return false;
  47.         }
  48.     },

  49.     log: function(msg, color) {
  50.         this.count++;
  51.         var colorHex = color || "#E0E0E0";
  52.         if (msg.length > 240) msg = msg.substring(0, 240) + "...";

  53.         var d = new Date();
  54.         var ts = (d.getHours() < 10 ? "0" : "") + d.getHours() + ":" +
  55.                  (d.getMinutes() < 10 ? "0" : "") + d.getMinutes() + ":" +
  56.                  (d.getSeconds() < 10 ? "0" : "") + d.getSeconds();

  57.         // 前缀标记颜色含义(虽然文本颜色无法区分,但前缀能看懂)
  58.         var prefix = colorHex == "#4ADE80" ? "✓ " :
  59.                      colorHex == "#F87171" ? "✗ " :
  60.                      colorHex == "#FFD166" ? "⚡ " : "• ";

  61.         this.lines.push(ts + "  " + prefix + msg);
  62.         if (this.lines.length > this.MAX_LINES) this.lines.shift();

  63.         try {
  64.             this.tvLog.setText(this.lines.join("\n"));
  65.             this.tvTitle.setText("[ 运行日志 ] 共 " + this.count + " 条");
  66.         } catch (e) {}
  67.     },

  68.     destroy: function() {
  69.         try { if (this.floatUI) { this.floatUI.close(); this.floatUI = null; } } catch (e) {}
  70.     }
  71. };

  72. // ======================== 统计窗口 B ========================
  73. var winB = {
  74.     floatUI: null,
  75.     tvTask: null,
  76.     tvOk: null,
  77.     tvErr: null,
  78.     tvCost: null,
  79.     startTs: 0,
  80.     totalTasks: 0,
  81.     okCount: 0,
  82.     errCount: 0,

  83.     init: function() {
  84.         this.floatUI = new floatUI();
  85.         var sw = screen.getScreenWidth();
  86.         var sh = screen.getScreenHeight();
  87.         // 窗口 B:宽度 25%,高度 10%,和 A 顶部对齐
  88.         var w = Math.floor(sw * 0.25);
  89.         var h = Math.floor(sh * 0.10);
  90.         var x = sw - w - 8;
  91.         var y = Math.floor(sh * 0.08);

  92.         var xml = '<LinearLayout orientation="vertical" w="' + w + '" h="' + h +
  93.                   '" background="#88f8fafc" padding="6">' +
  94.                   '  <TextView text="&#128202; 实时统计" textColor="#0ea5e9" textSize="13" gravity="center"/>' +
  95.                   '  <TextView text="────────────────" w="fill_parent" textColor="#330ea5e9" textSize="8" padding="2"/>' +
  96.                   '  <TextView id="tv_task" text="任务: 0" textColor="#334155" textSize="11"/>' +
  97.                   '  <TextView id="tv_ok"   text="✓ 成功: 0" textColor="#16a34a" textSize="11"/>' +
  98.                   '  <TextView id="tv_err"  text="✗ 失败: 0" textColor="#dc2626" textSize="11"/>' +
  99.                   '  <TextView id="tv_cost" text="⏱ 00:00" textColor="#d97706" textSize="11"/>' +
  100.                   '</LinearLayout>';

  101.         try {
  102.             this.floatUI.loadXML(xml);
  103.             this.floatUI.setPosition(x, y);
  104.             this.tvTask = this.floatUI.findViewById("tv_task");
  105.             this.tvOk   = this.floatUI.findViewById("tv_ok");
  106.             this.tvErr  = this.floatUI.findViewById("tv_err");
  107.             this.tvCost = this.floatUI.findViewById("tv_cost");
  108.             this.startTs = new Date().getTime();
  109.             printl("[窗口B] 统计面板 OK  pos=(" + x + "," + y + ") size=" + w + "x" + h);
  110.             return true;
  111.         } catch (e) {
  112.             printl("[窗口B] 失败: " + e);
  113.             return false;
  114.         }
  115.     },

  116.     update: function(taskName, success) {
  117.         this.totalTasks++;
  118.         if (success) this.okCount++; else this.errCount++;

  119.         var elapsed = new Date().getTime() - this.startTs;
  120.         var mm = Math.floor(elapsed / 60000);
  121.         var ss = Math.floor((elapsed % 60000) / 1000);
  122.         var timeStr = (mm < 10 ? "0" : "") + mm + ":" + (ss < 10 ? "0" : "") + ss;

  123.         try {
  124.             this.tvTask.setText("任务: " + this.totalTasks + " · " + taskName);
  125.             this.tvOk.setText("✓ 成功: " + this.okCount);
  126.             this.tvErr.setText("✗ 失败: " + this.errCount);
  127.             this.tvCost.setText("⏱ " + timeStr);
  128.         } catch (e) {}
  129.     },

  130.     tick: function() {
  131.         var elapsed = new Date().getTime() - this.startTs;
  132.         var mm = Math.floor(elapsed / 60000);
  133.         var ss = Math.floor((elapsed % 60000) / 1000);
  134.         var timeStr = (mm < 10 ? "0" : "") + mm + ":" + (ss < 10 ? "0" : "") + ss;
  135.         try { this.tvCost.setText("⏱ " + timeStr); } catch (e) {}
  136.     },

  137.     destroy: function() {
  138.         try { if (this.floatUI) { this.floatUI.close(); this.floatUI = null; } } catch (e) {}
  139.     }
  140. };

  141. // ======================== 后台计时线程 ========================
  142. var stopTick = false;
  143. new thread().runJsCode(function() {
  144.     while (!stopTick) {
  145.         doSleep(1000);
  146.         if (!stopTick) winB.tick();
  147.     }
  148. }, "计时线程");

  149. // ======================== 演示(录像友好版,约 40 秒) ========================
  150. function runDemo() {
  151.     printl("╔══════════════════════════════════════════════╗");
  152.     printl("║     AIWROK 双窗口悬浮日志系统(录像演示)   ║");
  153.     printl("╚══════════════════════════════════════════════╝");

  154.     // ── 第 1 幕:启动(给观众看清两个窗布局,停 3 秒)──
  155.     winA.init();
  156.     doSleep(500);
  157.     winB.init();
  158.     doSleep(1000);

  159.     winA.log("&#127916; 演示开始,请开始录像...", "#FFD166");
  160.     winB.update("系统启动", true);
  161.     doSleep(2000);

  162.     // ── 第 2 幕:跑任务(间隔 800ms,观众能看清每条)──
  163.     var tasks = [
  164.         ["检测设备权限", true],
  165.         ["连接远程服务器", true],
  166.         ["登录鉴权", true],
  167.         ["拉取配置文件", true],
  168.         ["OCR 图像识别", false],   // 故意失败一个
  169.         ["重试 OCR", true],
  170.         ["解析识别结果", true],
  171.         ["写入本地数据库", true],
  172.         ["上传云端同步", true],
  173.         ["校验数据完整性", false],  // 再失败一个
  174.         ["自动修复", true],
  175.         ["推送通知到手机", true],
  176.         ["生成运行报告", true]
  177.     ];

  178.     winA.log("═══════ 任务开始 ═══════", "#FFD166");
  179.     winB.update("准备就绪", true);
  180.     doSleep(1200);

  181.     for (var i = 0; i < tasks.length; i++) {
  182.         var name = tasks[i][0];
  183.         var success = tasks[i][1];

  184.         if (success) {
  185.             winA.log("✓ [ " + (i + 1) + "/" + tasks.length + " ] " + name, "#4ADE80");
  186.         } else {
  187.             winA.log("✗ [ " + (i + 1) + "/" + tasks.length + " ] " + name + " → 重试中...", "#F87171");
  188.         }
  189.         winB.update(name, success);
  190.         doSleep(800);

  191.         // 失败后自动重试一条,展示 winB 持续更新
  192.         if (!success) {
  193.             winA.log("  ↳ 重试成功 ✓", "#4ADE80");
  194.             winB.update(name + "(重试)", true);
  195.             doSleep(800);
  196.         }
  197.     }

  198.     // ── 第 3 幕:收尾展示结果(停 5 秒,观众能看清统计面板)──
  199.     winA.log("═══════ 任务全部结束 ═══════", "#FFD166");
  200.     winA.log("成功 " + winB.okCount + "  /  失败 " + winB.errCount + "  (失败已自动重试)", "#4ADE80");
  201.     doSleep(5000);

  202.     // ── 第 4 幕:展示日志滚动到最新、计时继续跑(停 3 秒)──
  203.     winA.log("窗口保持开启中... 可以继续录统计面板和计时", "#CCCCCC");
  204.     doSleep(3000);

  205.     printl("");
  206.     printl("╔══════════════════════════════════════════════╗");
  207.     printl("║  演示结束!窗口将在 5 秒后自动关闭         ║");
  208.     printl("║  如需更长时间录制,注释掉最后的 destroy      ║");
  209.     printl("╚══════════════════════════════════════════════╝");

  210.     doSleep(5000);

  211.     stopTick = true;
  212.     winA.destroy();
  213.     winB.destroy();
  214.     printl("&#129529; 双窗口已关闭");
  215. }

  216. runDemo();
复制代码


回复

使用道具 举报

本版积分规则

关闭

QQ|»营销软件综合讨论|»营销软件有问必答|»营销软件教程专区|»营销软件POST脚本分享|»营销软件普通脚本分享|»营销软件软件资讯|»营销软件精品软件|»营销软件更新公告|营销软件|B2B软件|B2B网络软件 ( 京ICP备09078825号 )本网站开发的营销软件是一款新的网络营销软件,这款营销可以去网站软件,博客软件,B2B软件,分类信息网发贴,可以抢沙发,可以到百度文库上传WORD文档,可以到一些是相册网站自动上传图片,这个自动发帖软件自带云蜘蛛,加快收录,有6种对接打码接口,方便,效率高,速度快,而且对拖动的验证码全网第一家独家支持,全部原创技术,独家研发,正版原创带版权软件。选择万能营销软件,就选择了一种赚钱的效率,从没有被超越过,一直在努力研发新技术。放飞梦想,解放双手,来点创意,成就你的梦想,就在万能营销软件开始

map2

GMT+8, 2026-9-25 07:52 , Processed in 0.183835 second(s), 35 queries .

快速回复 返回顶部 返回列表