|
|
资讯缩略图:
资讯发布日期:2026-06-08
资讯发布简介:QZ掘金原生UI界面
资讯关键词:QZ掘金原生UI界面
资讯所属分类:IT资讯 SEO资讯
联系:
① 本信息收集于网络,如有不对的地方欢迎联系我纠正! ② 本信息免费收录,不存在价格的问题! ③ 如果您的网站也想这样出现在这里,请您加好友情链接,我当天会审核通过!
④友情链接关键字:软件网站分类目录 网址:http://www.postbbs.com/
资讯详细描述
 | |  |  | QZ掘金原生UI界面
- /**
- * QZ掘金 - 配置管理界面
- *交流QQ群: 711841924 (群一) / 528816639 (安卓内测群)
- * 仿照截图界面设计:版本号 + 开始运行按钮 + 操作按钮 + 基础配置
- */
- var ac = new activity();
- ac.loadSXML(`
- <ScrollView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="#f5f5f5">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:padding="16dp">
- <!-- 顶部标题栏 -->
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="QZ掘金"
- android:textSize="24sp"
- android:textStyle="bold"
- android:textColor="#4A90E2"
- android:gravity="center"
- android:layout_marginBottom="15dp"/>
- <!-- 版本号和开始运行按钮 -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:gravity="center"
- android:layout_marginBottom="15dp">
- <TextView
- android:id="@+id/tvVersion"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="版本号: 3.32"
- android:textSize="16sp"
- android:textColor="#ffffff"
- android:background="#9E9E9E"
- android:padding="10dp"
- android:layout_marginRight="15dp"/>
- <Button
- android:id="@+id/btnStart"
- android:layout_width="80dp"
- android:layout_height="80dp"
- android:text="开始\n运行"
- android:textSize="16sp"
- android:textColor="#ffffff"
- android:background="#4CAF50"
- android:gravity="center"
- android:padding="5dp"/>
- </LinearLayout>
- <!-- 操作按钮行 -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:layout_marginBottom="20dp">
- <Button
- android:id="@+id/btnStop"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="停止运行"
- android:textColor="#ffffff"
- android:backgroundTint="#F44336"
- android:layout_marginRight="5dp"
- android:padding="8dp"/>
- <Button
- android:id="@+id/btnSave"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="保存配置"
- android:textColor="#ffffff"
- android:backgroundTint="#3F51B5"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp"
- android:padding="8dp"/>
- <Button
- android:id="@+id/btnResetForm"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="重置表单"
- android:textColor="#ffffff"
- android:backgroundTint="#FF9800"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp"
- android:padding="8dp"/>
- <Button
- android:id="@+id/btnResetExecutor"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="重置执行器"
- android:textColor="#ffffff"
- android:backgroundTint="#673AB7"
- android:layout_marginLeft="5dp"
- android:padding="8dp"/>
- </LinearLayout>
- <!-- 基础配置区域 -->
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="基础配置"
- android:textSize="20sp"
- android:textStyle="bold"
- android:textColor="#333333"
- android:layout_marginBottom="15dp"/>
- <!-- 设备名称 -->
- <EditText
- android:id="@+id/etDeviceName"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="请输入设备名称"
- android:padding="12dp"
- android:backgroundTint="#4CAF50"
- android:layout_marginBottom="5dp"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="设备名称,推送消息的时候方便区分设备"
- android:textSize="12sp"
- android:textColor="#999999"
- android:layout_marginBottom="15dp"/>
- <!-- HID硬件类型 -->
- <Button
- android:id="@+id/spinnerHIDType"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="ffChUSB版"
- android:backgroundTint="#E0E0E0"
- android:textColor="#333333"
- android:textSize="16sp"
- android:gravity="left|center_vertical"
- android:padding="12dp"
- android:layout_marginBottom="5dp"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="选择HID硬件类型"
- android:textSize="12sp"
- android:textColor="#999999"
- android:layout_marginBottom="15dp"/>
- <!-- UID输入框 -->
- <EditText
- android:id="@+id/etUID"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="请输入wxPusher的UID"
- android:padding="12dp"
- android:backgroundTint="#4CAF50"
- android:layout_marginBottom="5dp"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="wxPusher的UID,用于微信推送消息"
- android:textSize="12sp"
- android:textColor="#999999"
- android:layout_marginBottom="15dp"/>
- <!-- 定时推送时间 -->
- <EditText
- android:id="@+id/etPushTime"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="例如: 8,12,18"
- android:padding="12dp"
- android:backgroundTint="#4CAF50"
- android:layout_marginBottom="5dp"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="每日定时推送时间(小时,隔开)"
- android:textSize="12sp"
- android:textColor="#999999"
- android:layout_marginBottom="15dp"/>
- <!-- 清理后台类型 -->
- <Button
- android:id="@+id/spinnerCleanupType"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="滑动"
- android:backgroundTint="#E0E0E0"
- android:textColor="#333333"
- android:textSize="16sp"
- android:gravity="left|center_vertical"
- android:padding="12dp"
- android:layout_marginBottom="5dp"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="清理后台类型"
- android:textSize="12sp"
- android:textColor="#999999"
- android:layout_marginBottom="15dp"/>
- <!-- 左右滑动选项 -->
- <Button
- android:id="@+id/spinnerSlideDirection"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="左右滑动"
- android:backgroundTint="#E0E0E0"
- android:textColor="#333333"
- android:textSize="16sp"
- android:gravity="left|center_vertical"
- android:padding="12dp"
- android:layout_marginBottom="5dp"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="滑动方向"
- android:textSize="12sp"
- android:textColor="#999999"
- android:layout_marginBottom="15dp"/>
- <!-- 日志显示区域 -->
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="运行日志"
- android:textSize="18sp"
- android:textStyle="bold"
- android:textColor="#333333"
- android:layout_marginTop="10dp"
- android:layout_marginBottom="10dp"/>
- <TextView
- android:id="@+id/tvLog"
- android:layout_width="match_parent"
- android:layout_height="200dp"
- android:text="日志将显示在这里"
- android:textSize="14sp"
- android:textColor="#666666"
- android:padding="10dp"
- android:background="#ffffff"
- android:gravity="left|top"
- android:scrollbars="vertical"/>
- </LinearLayout>
- </ScrollView>
- `);
- // 获取UI组件
- var tvVersion = ac.findViewById("tvVersion");
- var btnStart = ac.findViewById("btnStart");
- var btnStop = ac.findViewById("btnStop");
- var btnSave = ac.findViewById("btnSave");
- var btnResetForm = ac.findViewById("btnResetForm");
- var btnResetExecutor = ac.findViewById("btnResetExecutor");
- var etDeviceName = ac.findViewById("etDeviceName");
- var spinnerHIDType = ac.findViewById("spinnerHIDType");
- var etUID = ac.findViewById("etUID");
- var etPushTime = ac.findViewById("etPushTime");
- var spinnerCleanupType = ac.findViewById("spinnerCleanupType");
- var spinnerSlideDirection = ac.findViewById("spinnerSlideDirection");
- var tvLog = ac.findViewById("tvLog");
- // Spinner选项数据
- var hidTypes = ["ffChUSB版", "标准HID", "蓝牙HID", "WiFi HID"];
- var cleanupTypes = ["滑动", "强制停止", "清除数据", "不处理"];
- var slideDirections = ["左右滑动", "上下滑动", "随机滑动"];
- // Spinner状态对象
- var spinnerState = {
- hidIndex: 0,
- cleanupIndex: 0,
- slideIndex: 0
- };
- // 设置Spinner点击事件
- function setupSpinnerClick(spinnerBtn, items, stateKey) {
- spinnerBtn.setOnClickListener(function() {
- try {
- // 在日志区域显示所有选项
- var optionsText = "";
- for (var i = 0; i < items.length; i++) {
- optionsText += (i + 1) + ". " + items[i] + "\n";
- }
- tvLog.setText("📋 选项列表:\n" + optionsText);
-
- // 获取当前索引并计算新索引
- var currentIndex = spinnerState[stateKey];
- var newIndex = (currentIndex + 1) % items.length;
-
- // 更新状态
- spinnerState[stateKey] = newIndex;
-
- // 更新显示
- spinnerBtn.setText(" " + items[newIndex]);
- tvLog.setText("✅ 已选择: " + items[newIndex]);
- console.log("选择: " + items[newIndex]);
- } catch (e) {
- tvLog.setText(" 选择失败: " + e);
- console.log("选择失败: " + e);
- }
- });
- }
- setupSpinnerClick(spinnerHIDType, hidTypes, 'hidIndex');
- setupSpinnerClick(spinnerCleanupType, cleanupTypes, 'cleanupIndex');
- setupSpinnerClick(spinnerSlideDirection, slideDirections, 'slideIndex');
- // 加载保存的配置
- function loadConfig() {
- try {
- var deviceName = config.getConfig('/sdcard/qz_config.ini', 'device_name', '');
- var hidType = config.getConfig('/sdcard/qz_config.ini', 'hid_type', '0');
- var uid = config.getConfig('/sdcard/qz_config.ini', 'uid', '');
- var pushTime = config.getConfig('/sdcard/qz_config.ini', 'push_time', '');
- var cleanupType = config.getConfig('/sdcard/qz_config.ini', 'cleanup_type', '0');
- var slideDirection = config.getConfig('/sdcard/qz_config.ini', 'slide_direction', '0');
-
- if (deviceName) etDeviceName.setText(deviceName);
- spinnerHIDType.setText(" " + hidTypes[parseInt(hidType) || 0]);
- spinnerState.hidIndex = parseInt(hidType) || 0;
- if (uid) etUID.setText(uid);
- if (pushTime) etPushTime.setText(pushTime);
- spinnerCleanupType.setText(" " + cleanupTypes[parseInt(cleanupType) || 0]);
- spinnerState.cleanupIndex = parseInt(cleanupType) || 0;
- spinnerSlideDirection.setText(" " + slideDirections[parseInt(slideDirection) || 0]);
- spinnerState.slideIndex = parseInt(slideDirection) || 0;
-
- tvLog.setText("✅ 配置加载完成");
- console.log("配置加载完成");
- } catch (e) {
- tvLog.setText("⚠️ 配置加载失败: " + e);
- console.log("配置加载失败: " + e);
- }
- }
- // 保存配置
- function saveConfig() {
- try {
- config.setConfig('/sdcard/qz_config.ini', 'device_name', etDeviceName.getText().toString());
- config.setConfig('/sdcard/qz_config.ini', 'hid_type', spinnerState.hidIndex.toString());
- config.setConfig('/sdcard/qz_config.ini', 'uid', etUID.getText().toString());
- config.setConfig('/sdcard/qz_config.ini', 'push_time', etPushTime.getText().toString());
- config.setConfig('/sdcard/qz_config.ini', 'cleanup_type', spinnerState.cleanupIndex.toString());
- config.setConfig('/sdcard/qz_config.ini', 'slide_direction', spinnerState.slideIndex.toString());
-
- tvLog.setText("✅ 配置保存成功");
- console.log("配置保存成功");
- } catch (e) {
- tvLog.setText("⚠️ 配置保存失败: " + e);
- console.log("配置保存失败: " + e);
- }
- }
- // 重置表单
- function resetForm() {
- etDeviceName.setText("");
- etUID.setText("");
- etPushTime.setText("");
- spinnerHIDType.setText(" " + hidTypes[0]);
- spinnerState.hidIndex = 0;
- spinnerCleanupType.setText(" " + cleanupTypes[0]);
- spinnerState.cleanupIndex = 0;
- spinnerSlideDirection.setText(" " + slideDirections[0]);
- spinnerState.slideIndex = 0;
- tvLog.setText("🔄 表单已重置");
- console.log("表单已重置");
- }
- // 重置执行器
- function resetExecutor() {
- tvLog.setText(" 执行器已重置");
- console.log("执行器已重置");
- }
- // 运行状态控制
- var isRunning = false;
- // 按钮事件绑定
- btnStart.setOnClickListener(function() {
- if (isRunning) {
- tvLog.setText(" 脚本正在运行中,请稍候...");
- console.log("脚本正在运行中");
- return;
- }
-
- // 更新UI状态
- isRunning = true;
- btnStart.setText("⏳ 运行中...");
- btnStart.setBackgroundTintList(android.content.res.ColorStateList.valueOf(
- android.graphics.Color.parseColor("#FF9800")
- ));
- tvLog.setText("▶ 开始运行主脚本...");
- console.log("开始运行主脚本");
-
- try {
- // 直接导入并运行主脚本
- Import("主脚本.js");
-
- // 运行完成后更新状态
- btnStart.setText("开始\n运行");
- btnStart.setBackgroundTintList(android.content.res.ColorStateList.valueOf(
- android.graphics.Color.parseColor("#4CAF50")
- ));
- isRunning = false;
-
- tvLog.setText("✅ 主脚本运行完成");
- console.log("主脚本运行完成");
- } catch (e) {
- btnStart.setText("开始\n运行");
- btnStart.setBackgroundTintList(android.content.res.ColorStateList.valueOf(
- android.graphics.Color.parseColor("#4CAF50")
- ));
- isRunning = false;
-
- tvLog.setText(" 运行失败: " + e);
- console.log("运行失败: " + e);
- }
- });
- btnStop.setOnClickListener(function() {
- tvLog.setText("⏹️ 已停止运行");
- console.log("停止运行");
- });
- btnSave.setOnClickListener(function() {
- saveConfig();
- });
- btnResetForm.setOnClickListener(function() {
- resetForm();
- });
- btnResetExecutor.setOnClickListener(function() {
- resetExecutor();
- });
- // 初始化加载配置
- loadConfig();
- console.log("✅ QZ掘金配置界面已启动");
复制代码
| |  | |  |
|
unto安卓脚本auto方法完整示例nextnocontent
|