B2B网络软件

标题: QZ掘金原生UI界面 [打印本页]

作者: YYPOST群发软件    时间: 2 小时前
标题: QZ掘金原生UI界面
QZ掘金原生UI界面
QZ掘金原生UI界面 B2B网络软件


  1. /**
  2. * QZ掘金 - 配置管理界面
  3. *交流QQ群: 711841924 (群一) / 528816639 (安卓内测群)
  4. * 仿照截图界面设计:版本号 + 开始运行按钮 + 操作按钮 + 基础配置
  5. */

  6. var ac = new activity();
  7. ac.loadSXML(`
  8. <ScrollView
  9.     android:layout_width="match_parent"
  10.     android:layout_height="match_parent"
  11.     android:background="#f5f5f5">

  12.     <LinearLayout
  13.         android:layout_width="match_parent"
  14.         android:layout_height="wrap_content"
  15.         android:orientation="vertical"
  16.         android:padding="16dp">

  17.         <!-- 顶部标题栏 -->
  18.         <TextView
  19.             android:layout_width="match_parent"
  20.             android:layout_height="wrap_content"
  21.             android:text="QZ掘金"
  22.             android:textSize="24sp"
  23.             android:textStyle="bold"
  24.             android:textColor="#4A90E2"
  25.             android:gravity="center"
  26.             android:layout_marginBottom="15dp"/>

  27.         <!-- 版本号和开始运行按钮 -->
  28.         <LinearLayout
  29.             android:layout_width="match_parent"
  30.             android:layout_height="wrap_content"
  31.             android:orientation="horizontal"
  32.             android:gravity="center"
  33.             android:layout_marginBottom="15dp">

  34.             <TextView
  35.                 android:id="@+id/tvVersion"
  36.                 android:layout_width="wrap_content"
  37.                 android:layout_height="wrap_content"
  38.                 android:text="版本号: 3.32"
  39.                 android:textSize="16sp"
  40.                 android:textColor="#ffffff"
  41.                 android:background="#9E9E9E"
  42.                 android:padding="10dp"
  43.                 android:layout_marginRight="15dp"/>

  44.             <Button
  45.                 android:id="@+id/btnStart"
  46.                 android:layout_width="80dp"
  47.                 android:layout_height="80dp"
  48.                 android:text="开始\n运行"
  49.                 android:textSize="16sp"
  50.                 android:textColor="#ffffff"
  51.                 android:background="#4CAF50"
  52.                 android:gravity="center"
  53.                 android:padding="5dp"/>
  54.         </LinearLayout>

  55.         <!-- 操作按钮行 -->
  56.         <LinearLayout
  57.             android:layout_width="match_parent"
  58.             android:layout_height="wrap_content"
  59.             android:orientation="horizontal"
  60.             android:layout_marginBottom="20dp">

  61.             <Button
  62.                 android:id="@+id/btnStop"
  63.                 android:layout_width="0dp"
  64.                 android:layout_height="wrap_content"
  65.                 android:layout_weight="1"
  66.                 android:text="停止运行"
  67.                 android:textColor="#ffffff"
  68.                 android:backgroundTint="#F44336"
  69.                 android:layout_marginRight="5dp"
  70.                 android:padding="8dp"/>

  71.             <Button
  72.                 android:id="@+id/btnSave"
  73.                 android:layout_width="0dp"
  74.                 android:layout_height="wrap_content"
  75.                 android:layout_weight="1"
  76.                 android:text="保存配置"
  77.                 android:textColor="#ffffff"
  78.                 android:backgroundTint="#3F51B5"
  79.                 android:layout_marginLeft="5dp"
  80.                 android:layout_marginRight="5dp"
  81.                 android:padding="8dp"/>

  82.             <Button
  83.                 android:id="@+id/btnResetForm"
  84.                 android:layout_width="0dp"
  85.                 android:layout_height="wrap_content"
  86.                 android:layout_weight="1"
  87.                 android:text="重置表单"
  88.                 android:textColor="#ffffff"
  89.                 android:backgroundTint="#FF9800"
  90.                 android:layout_marginLeft="5dp"
  91.                 android:layout_marginRight="5dp"
  92.                 android:padding="8dp"/>

  93.             <Button
  94.                 android:id="@+id/btnResetExecutor"
  95.                 android:layout_width="0dp"
  96.                 android:layout_height="wrap_content"
  97.                 android:layout_weight="1"
  98.                 android:text="重置执行器"
  99.                 android:textColor="#ffffff"
  100.                 android:backgroundTint="#673AB7"
  101.                 android:layout_marginLeft="5dp"
  102.                 android:padding="8dp"/>
  103.         </LinearLayout>

  104.         <!-- 基础配置区域 -->
  105.         <TextView
  106.             android:layout_width="match_parent"
  107.             android:layout_height="wrap_content"
  108.             android:text="基础配置"
  109.             android:textSize="20sp"
  110.             android:textStyle="bold"
  111.             android:textColor="#333333"
  112.             android:layout_marginBottom="15dp"/>

  113.         <!-- 设备名称 -->
  114.         <EditText
  115.             android:id="@+id/etDeviceName"
  116.             android:layout_width="match_parent"
  117.             android:layout_height="wrap_content"
  118.             android:hint="请输入设备名称"
  119.             android:padding="12dp"
  120.             android:backgroundTint="#4CAF50"
  121.             android:layout_marginBottom="5dp"/>

  122.         <TextView
  123.             android:layout_width="match_parent"
  124.             android:layout_height="wrap_content"
  125.             android:text="设备名称,推送消息的时候方便区分设备"
  126.             android:textSize="12sp"
  127.             android:textColor="#999999"
  128.             android:layout_marginBottom="15dp"/>

  129.         <!-- HID硬件类型 -->
  130.         <Button
  131.             android:id="@+id/spinnerHIDType"
  132.             android:layout_width="match_parent"
  133.             android:layout_height="wrap_content"
  134.             android:text="ffChUSB版"
  135.             android:backgroundTint="#E0E0E0"
  136.             android:textColor="#333333"
  137.             android:textSize="16sp"
  138.             android:gravity="left|center_vertical"
  139.             android:padding="12dp"
  140.             android:layout_marginBottom="5dp"/>

  141.         <TextView
  142.             android:layout_width="match_parent"
  143.             android:layout_height="wrap_content"
  144.             android:text="选择HID硬件类型"
  145.             android:textSize="12sp"
  146.             android:textColor="#999999"
  147.             android:layout_marginBottom="15dp"/>

  148.         <!-- UID输入框 -->
  149.         <EditText
  150.             android:id="@+id/etUID"
  151.             android:layout_width="match_parent"
  152.             android:layout_height="wrap_content"
  153.             android:hint="请输入wxPusher的UID"
  154.             android:padding="12dp"
  155.             android:backgroundTint="#4CAF50"
  156.             android:layout_marginBottom="5dp"/>

  157.         <TextView
  158.             android:layout_width="match_parent"
  159.             android:layout_height="wrap_content"
  160.             android:text="wxPusher的UID,用于微信推送消息"
  161.             android:textSize="12sp"
  162.             android:textColor="#999999"
  163.             android:layout_marginBottom="15dp"/>

  164.         <!-- 定时推送时间 -->
  165.         <EditText
  166.             android:id="@+id/etPushTime"
  167.             android:layout_width="match_parent"
  168.             android:layout_height="wrap_content"
  169.             android:hint="例如: 8,12,18"
  170.             android:padding="12dp"
  171.             android:backgroundTint="#4CAF50"
  172.             android:layout_marginBottom="5dp"/>

  173.         <TextView
  174.             android:layout_width="match_parent"
  175.             android:layout_height="wrap_content"
  176.             android:text="每日定时推送时间(小时,隔开)"
  177.             android:textSize="12sp"
  178.             android:textColor="#999999"
  179.             android:layout_marginBottom="15dp"/>

  180.         <!-- 清理后台类型 -->
  181.         <Button
  182.             android:id="@+id/spinnerCleanupType"
  183.             android:layout_width="match_parent"
  184.             android:layout_height="wrap_content"
  185.             android:text="滑动"
  186.             android:backgroundTint="#E0E0E0"
  187.             android:textColor="#333333"
  188.             android:textSize="16sp"
  189.             android:gravity="left|center_vertical"
  190.             android:padding="12dp"
  191.             android:layout_marginBottom="5dp"/>

  192.         <TextView
  193.             android:layout_width="match_parent"
  194.             android:layout_height="wrap_content"
  195.             android:text="清理后台类型"
  196.             android:textSize="12sp"
  197.             android:textColor="#999999"
  198.             android:layout_marginBottom="15dp"/>

  199.         <!-- 左右滑动选项 -->
  200.         <Button
  201.             android:id="@+id/spinnerSlideDirection"
  202.             android:layout_width="match_parent"
  203.             android:layout_height="wrap_content"
  204.             android:text="左右滑动"
  205.             android:backgroundTint="#E0E0E0"
  206.             android:textColor="#333333"
  207.             android:textSize="16sp"
  208.             android:gravity="left|center_vertical"
  209.             android:padding="12dp"
  210.             android:layout_marginBottom="5dp"/>

  211.         <TextView
  212.             android:layout_width="match_parent"
  213.             android:layout_height="wrap_content"
  214.             android:text="滑动方向"
  215.             android:textSize="12sp"
  216.             android:textColor="#999999"
  217.             android:layout_marginBottom="15dp"/>

  218.         <!-- 日志显示区域 -->
  219.         <TextView
  220.             android:layout_width="match_parent"
  221.             android:layout_height="wrap_content"
  222.             android:text="运行日志"
  223.             android:textSize="18sp"
  224.             android:textStyle="bold"
  225.             android:textColor="#333333"
  226.             android:layout_marginTop="10dp"
  227.             android:layout_marginBottom="10dp"/>

  228.         <TextView
  229.             android:id="@+id/tvLog"
  230.             android:layout_width="match_parent"
  231.             android:layout_height="200dp"
  232.             android:text="日志将显示在这里"
  233.             android:textSize="14sp"
  234.             android:textColor="#666666"
  235.             android:padding="10dp"
  236.             android:background="#ffffff"
  237.             android:gravity="left|top"
  238.             android:scrollbars="vertical"/>

  239.     </LinearLayout>

  240. </ScrollView>
  241. `);

  242. // 获取UI组件
  243. var tvVersion = ac.findViewById("tvVersion");
  244. var btnStart = ac.findViewById("btnStart");
  245. var btnStop = ac.findViewById("btnStop");
  246. var btnSave = ac.findViewById("btnSave");
  247. var btnResetForm = ac.findViewById("btnResetForm");
  248. var btnResetExecutor = ac.findViewById("btnResetExecutor");
  249. var etDeviceName = ac.findViewById("etDeviceName");
  250. var spinnerHIDType = ac.findViewById("spinnerHIDType");
  251. var etUID = ac.findViewById("etUID");
  252. var etPushTime = ac.findViewById("etPushTime");
  253. var spinnerCleanupType = ac.findViewById("spinnerCleanupType");
  254. var spinnerSlideDirection = ac.findViewById("spinnerSlideDirection");
  255. var tvLog = ac.findViewById("tvLog");

  256. // Spinner选项数据
  257. var hidTypes = ["ffChUSB版", "标准HID", "蓝牙HID", "WiFi HID"];
  258. var cleanupTypes = ["滑动", "强制停止", "清除数据", "不处理"];
  259. var slideDirections = ["左右滑动", "上下滑动", "随机滑动"];

  260. // Spinner状态对象
  261. var spinnerState = {
  262.     hidIndex: 0,
  263.     cleanupIndex: 0,
  264.     slideIndex: 0
  265. };

  266. // 设置Spinner点击事件
  267. function setupSpinnerClick(spinnerBtn, items, stateKey) {
  268.     spinnerBtn.setOnClickListener(function() {
  269.         try {
  270.             // 在日志区域显示所有选项
  271.             var optionsText = "";
  272.             for (var i = 0; i < items.length; i++) {
  273.                 optionsText += (i + 1) + ". " + items[i] + "\n";
  274.             }
  275.             tvLog.setText("&#128203; 选项列表:\n" + optionsText);
  276.             
  277.             // 获取当前索引并计算新索引
  278.             var currentIndex = spinnerState[stateKey];
  279.             var newIndex = (currentIndex + 1) % items.length;
  280.             
  281.             // 更新状态
  282.             spinnerState[stateKey] = newIndex;
  283.             
  284.             // 更新显示
  285.             spinnerBtn.setText(" " + items[newIndex]);
  286.             tvLog.setText("✅ 已选择: " + items[newIndex]);
  287.             console.log("选择: " + items[newIndex]);
  288.         } catch (e) {
  289.             tvLog.setText(" 选择失败: " + e);
  290.             console.log("选择失败: " + e);
  291.         }
  292.     });
  293. }

  294. setupSpinnerClick(spinnerHIDType, hidTypes, 'hidIndex');
  295. setupSpinnerClick(spinnerCleanupType, cleanupTypes, 'cleanupIndex');
  296. setupSpinnerClick(spinnerSlideDirection, slideDirections, 'slideIndex');

  297. // 加载保存的配置
  298. function loadConfig() {
  299.     try {
  300.         var deviceName = config.getConfig('/sdcard/qz_config.ini', 'device_name', '');
  301.         var hidType = config.getConfig('/sdcard/qz_config.ini', 'hid_type', '0');
  302.         var uid = config.getConfig('/sdcard/qz_config.ini', 'uid', '');
  303.         var pushTime = config.getConfig('/sdcard/qz_config.ini', 'push_time', '');
  304.         var cleanupType = config.getConfig('/sdcard/qz_config.ini', 'cleanup_type', '0');
  305.         var slideDirection = config.getConfig('/sdcard/qz_config.ini', 'slide_direction', '0');
  306.         
  307.         if (deviceName) etDeviceName.setText(deviceName);
  308.         spinnerHIDType.setText(" " + hidTypes[parseInt(hidType) || 0]);
  309.         spinnerState.hidIndex = parseInt(hidType) || 0;
  310.         if (uid) etUID.setText(uid);
  311.         if (pushTime) etPushTime.setText(pushTime);
  312.         spinnerCleanupType.setText(" " + cleanupTypes[parseInt(cleanupType) || 0]);
  313.         spinnerState.cleanupIndex = parseInt(cleanupType) || 0;
  314.         spinnerSlideDirection.setText(" " + slideDirections[parseInt(slideDirection) || 0]);
  315.         spinnerState.slideIndex = parseInt(slideDirection) || 0;
  316.         
  317.         tvLog.setText("✅ 配置加载完成");
  318.         console.log("配置加载完成");
  319.     } catch (e) {
  320.         tvLog.setText("⚠️ 配置加载失败: " + e);
  321.         console.log("配置加载失败: " + e);
  322.     }
  323. }

  324. // 保存配置
  325. function saveConfig() {
  326.     try {
  327.         config.setConfig('/sdcard/qz_config.ini', 'device_name', etDeviceName.getText().toString());
  328.         config.setConfig('/sdcard/qz_config.ini', 'hid_type', spinnerState.hidIndex.toString());
  329.         config.setConfig('/sdcard/qz_config.ini', 'uid', etUID.getText().toString());
  330.         config.setConfig('/sdcard/qz_config.ini', 'push_time', etPushTime.getText().toString());
  331.         config.setConfig('/sdcard/qz_config.ini', 'cleanup_type', spinnerState.cleanupIndex.toString());
  332.         config.setConfig('/sdcard/qz_config.ini', 'slide_direction', spinnerState.slideIndex.toString());
  333.         
  334.         tvLog.setText("✅ 配置保存成功");
  335.         console.log("配置保存成功");
  336.     } catch (e) {
  337.         tvLog.setText("⚠️ 配置保存失败: " + e);
  338.         console.log("配置保存失败: " + e);
  339.     }
  340. }

  341. // 重置表单
  342. function resetForm() {
  343.     etDeviceName.setText("");
  344.     etUID.setText("");
  345.     etPushTime.setText("");
  346.     spinnerHIDType.setText(" " + hidTypes[0]);
  347.     spinnerState.hidIndex = 0;
  348.     spinnerCleanupType.setText(" " + cleanupTypes[0]);
  349.     spinnerState.cleanupIndex = 0;
  350.     spinnerSlideDirection.setText(" " + slideDirections[0]);
  351.     spinnerState.slideIndex = 0;
  352.     tvLog.setText("&#128260; 表单已重置");
  353.     console.log("表单已重置");
  354. }

  355. // 重置执行器
  356. function resetExecutor() {
  357.     tvLog.setText(" 执行器已重置");
  358.     console.log("执行器已重置");
  359. }

  360. // 运行状态控制
  361. var isRunning = false;

  362. // 按钮事件绑定
  363. btnStart.setOnClickListener(function() {
  364.     if (isRunning) {
  365.         tvLog.setText(" 脚本正在运行中,请稍候...");
  366.         console.log("脚本正在运行中");
  367.         return;
  368.     }
  369.    
  370.     // 更新UI状态
  371.     isRunning = true;
  372.     btnStart.setText("⏳ 运行中...");
  373.     btnStart.setBackgroundTintList(android.content.res.ColorStateList.valueOf(
  374.         android.graphics.Color.parseColor("#FF9800")
  375.     ));
  376.     tvLog.setText("▶ 开始运行主脚本...");
  377.     console.log("开始运行主脚本");
  378.    
  379.     try {
  380.         // 直接导入并运行主脚本
  381.         Import("主脚本.js");
  382.         
  383.         // 运行完成后更新状态
  384.         btnStart.setText("开始\n运行");
  385.         btnStart.setBackgroundTintList(android.content.res.ColorStateList.valueOf(
  386.             android.graphics.Color.parseColor("#4CAF50")
  387.         ));
  388.         isRunning = false;
  389.         
  390.         tvLog.setText("✅ 主脚本运行完成");
  391.         console.log("主脚本运行完成");
  392.     } catch (e) {
  393.         btnStart.setText("开始\n运行");
  394.         btnStart.setBackgroundTintList(android.content.res.ColorStateList.valueOf(
  395.             android.graphics.Color.parseColor("#4CAF50")
  396.         ));
  397.         isRunning = false;
  398.         
  399.         tvLog.setText(" 运行失败: " + e);
  400.         console.log("运行失败: " + e);
  401.     }
  402. });

  403. btnStop.setOnClickListener(function() {
  404.     tvLog.setText("⏹️ 已停止运行");
  405.     console.log("停止运行");
  406. });

  407. btnSave.setOnClickListener(function() {
  408.     saveConfig();
  409. });

  410. btnResetForm.setOnClickListener(function() {
  411.     resetForm();
  412. });

  413. btnResetExecutor.setOnClickListener(function() {
  414.     resetExecutor();
  415. });

  416. // 初始化加载配置
  417. loadConfig();

  418. console.log("✅ QZ掘金配置界面已启动");       
复制代码







欢迎光临 B2B网络软件 (http://bbs.niubt.cn/) Powered by Discuz! X3.2