 | |  |  | IOS苹果 脚本View的完整功能实例
- // 🍎交流QQ群711841924群一,苹果内测群,528816639
- // 📱IOSView综合应用示例 - 智能助手控制台
- // 基于AIWROK开发平台,展示IOSView的完整功能
- printl("=== 智能助手控制台启动中 ===");
- // 创建主TabView
- var mainTab = new TabView();
- // 设置Tab标题
- var tabTitles = ["控制中心", "任务管理", "数据监控", "系统设置"];
- mainTab.setTitles(tabTitles);
- // 显示TabView
- mainTab.show(() => {
- printl("✅ 智能助手控制台已加载");
-
- // 添加各个Tab页面的内容
- mainTab.addView(0, createControlCenter());
- mainTab.addView(1, createTaskManager());
- mainTab.addView(2, createDataMonitor());
- mainTab.addView(3, createSystemSettings());
-
- printl("✅ 所有页面初始化完成");
- });
- printl("✅ 智能助手控制台启动成功");
- // ====================== 第一页:控制中心 ======================
- function createControlCenter() {
- var v = new Vertical();
- v.setBackgroundColor(245, 247, 250);
- v.setSpacing(15);
-
- // 页面标题
- var header = new Horizontal();
- header.setAlignment("center");
-
- var title = new Label();
- title.setText("⚡ 智能控制中心");
- title.setTextColor(41, 128, 185);
- title.setFontSize(22);
- header.addView(title);
-
- v.addView(header);
-
- // 分隔线
- var divider = new Label();
- divider.setHeight(2);
- divider.setBackgroundColor(200, 200, 200);
- v.addView(divider);
-
- // 快捷操作区域
- var quickActions = new Vertical();
- quickActions.setBackgroundColor(255, 255, 255);
-
- var quickTitle = new Label();
- quickTitle.setText("快捷操作");
- quickTitle.setTextColor(80, 80, 80);
- quickTitle.setFontSize(16);
- quickActions.addView(quickTitle);
-
- // 按钮网格
- var buttonGrid = new Horizontal();
- buttonGrid.setSpacing(10);
-
- var btn1 = createQuickButton("🚀 启动", 46, 204, 113, () => {
- printl("🚀 启动按钮被点击");
- showToast("正在启动服务...");
- });
- buttonGrid.addView(btn1);
-
- var btn2 = createQuickButton("⏸️ 暂停", 241, 196, 15, () => {
- printl("⏸️ 暂停按钮被点击");
- showToast("服务已暂停");
- });
- buttonGrid.addView(btn2);
-
- var btn3 = createQuickButton("🔄 重启", 52, 152, 219, () => {
- printl("🔄 重启按钮被点击");
- showToast("正在重启服务...");
- });
- buttonGrid.addView(btn3);
-
- var btn4 = createQuickButton("⏹️ 停止", 231, 76, 60, () => {
- printl("⏹️ 停止按钮被点击");
- showToast("服务已停止");
- });
- buttonGrid.addView(btn4);
-
- quickActions.addView(buttonGrid);
- v.addView(quickActions);
-
- // 功能开关区域
- var featureSwitches = new Vertical();
- featureSwitches.setBackgroundColor(255, 255, 255);
-
- var switchTitle = new Label();
- switchTitle.setText("功能开关");
- switchTitle.setTextColor(80, 80, 80);
- switchTitle.setFontSize(16);
- featureSwitches.addView(switchTitle);
-
- var switch1 = new CheckBox();
- switch1.setText("启用自动化脚本");
- switch1.setID("auto_script");
- switch1.setDefultSelect();
- featureSwitches.addView(switch1);
-
- var switch2 = new CheckBox();
- switch2.setText("启用日志记录");
- switch2.setID("log_record");
- switch2.setDefultSelect();
- featureSwitches.addView(switch2);
-
- var switch3 = new CheckBox();
- switch3.setText("启用通知提醒");
- switch3.setID("notification");
- featureSwitches.addView(switch3);
-
- var switch4 = new CheckBox();
- switch4.setText("启用定时任务");
- switch4.setID("scheduled_task");
- featureSwitches.addView(switch4);
-
- v.addView(featureSwitches);
-
- // 执行按钮
- var executeBtn = new Button();
- executeBtn.setText("执行选中操作");
- executeBtn.setColor(41, 128, 185);
- executeBtn.setTextColor(255, 255, 255);
- executeBtn.setHeight(45);
- executeBtn.onClick(() => {
- var autoScript = switch1.isSelect();
- var logRecord = switch2.isSelect();
- var notification = switch3.isSelect();
- var scheduledTask = switch4.isSelect();
-
- printl("执行配置:");
- printl(" 自动化脚本: " + autoScript);
- printl(" 日志记录: " + logRecord);
- printl(" 通知提醒: " + notification);
- printl(" 定时任务: " + scheduledTask);
-
- showToast("配置已应用");
- });
- v.addView(executeBtn);
-
- // 返回按钮
- var backBtn = new Button();
- backBtn.setText("返回");
- backBtn.setColor(149, 165, 166);
- backBtn.setTextColor(255, 255, 255);
- backBtn.setHeight(40);
- backBtn.onClick(() => {
- printl("返回按钮被点击");
- mainTab.dismiss();
- });
- v.addView(backBtn);
-
- return v;
- }
- // ====================== 第二页:任务管理 ======================
- function createTaskManager() {
- var v = new Vertical();
- v.setBackgroundColor(245, 247, 250);
- v.setSpacing(15);
-
- // 页面标题
- var header = new Horizontal();
- header.setAlignment("center");
-
- var title = new Label();
- title.setText("📋 任务管理中心");
- title.setTextColor(41, 128, 185);
- title.setFontSize(22);
- header.addView(title);
-
- v.addView(header);
-
- // 分隔线
- var divider = new Label();
- divider.setHeight(2);
- divider.setBackgroundColor(200, 200, 200);
- v.addView(divider);
-
- // 任务输入区域
- var inputContainer = new Horizontal();
- inputContainer.setAlignment("center_vertical");
-
- var inputLabel = new Label();
- inputLabel.setText("新任务:");
- inputLabel.setWidth(70);
- inputContainer.addView(inputLabel);
-
- var taskInput = new Input();
- taskInput.setWidth(200);
- taskInput.setID("task_input");
- taskInput.setDefultText("输入任务名称...");
- inputContainer.addView(taskInput);
-
- v.addView(inputContainer);
-
- // 优先级选择
- var priorityContainer = new Horizontal();
- priorityContainer.setAlignment("center_vertical");
-
- var priorityLabel = new Label();
- priorityLabel.setText("优先级:");
- priorityLabel.setWidth(70);
- priorityContainer.addView(priorityLabel);
-
- var priorityGroup = new RadioButtonGroup();
- priorityGroup.setID("task_priority");
- priorityGroup.setDefultSelect("中");
-
- var highPriority = new RadioButton();
- highPriority.setText("高");
- highPriority.setGroup(priorityGroup);
-
- var mediumPriority = new RadioButton();
- mediumPriority.setText("中");
- mediumPriority.setGroup(priorityGroup);
-
- var lowPriority = new RadioButton();
- lowPriority.setText("低");
- lowPriority.setGroup(priorityGroup);
-
- priorityContainer.addView(highPriority);
- priorityContainer.addView(mediumPriority);
- priorityContainer.addView(lowPriority);
-
- v.addView(priorityContainer);
-
- // 添加任务按钮
- var addBtn = new Button();
- addBtn.setText("➕ 添加任务");
- addBtn.setColor(46, 204, 113);
- addBtn.setTextColor(255, 255, 255);
- addBtn.setHeight(40);
- addBtn.onClick(() => {
- var taskName = taskInput.getText();
- var selectedRadio = priorityGroup.currentSelectedRadio();
- var priority = selectedRadio ? selectedRadio.getText() : "";
-
- if (taskName && taskName.length > 0) {
- printl("添加任务: " + taskName + ", 优先级: " + priority);
- showToast("任务已添加: " + taskName);
- taskInput.setText("");
- } else {
- showToast("请输入任务名称");
- }
- });
- v.addView(addBtn);
-
- // 任务列表
- var taskList = new Vertical();
- taskList.setBackgroundColor(255, 255, 255);
-
- var listTitle = new Label();
- listTitle.setText("任务列表");
- listTitle.setTextColor(80, 80, 80);
- listTitle.setFontSize(16);
- taskList.addView(listTitle);
-
- // 添加示例任务
- addTaskItem(taskList, "执行自动化脚本", "高");
- addTaskItem(taskList, "检查系统状态", "中");
- addTaskItem(taskList, "清理缓存数据", "低");
- addTaskItem(taskList, "更新配置文件", "中");
- addTaskItem(taskList, "生成日志报告", "低");
-
- v.addView(taskList);
-
- // 批量操作按钮
- var batchContainer = new Horizontal();
- batchContainer.setSpacing(10);
-
- var completeAllBtn = new Button();
- completeAllBtn.setText("全部完成");
- completeAllBtn.setColor(46, 204, 113);
- completeAllBtn.setTextColor(255, 255, 255);
- completeAllBtn.setWidth(100);
- completeAllBtn.setHeight(40);
- completeAllBtn.onClick(() => {
- printl("所有任务标记为完成");
- showToast("所有任务已完成");
- });
- batchContainer.addView(completeAllBtn);
-
- var clearCompletedBtn = new Button();
- clearCompletedBtn.setText("清除已完成");
- clearCompletedBtn.setColor(241, 196, 15);
- clearCompletedBtn.setTextColor(50, 50, 50);
- clearCompletedBtn.setWidth(120);
- clearCompletedBtn.setHeight(40);
- clearCompletedBtn.onClick(() => {
- printl("清除已完成任务");
- showToast("已完成任务已清除");
- });
- batchContainer.addView(clearCompletedBtn);
-
- v.addView(batchContainer);
-
- // 返回按钮
- var backBtn = new Button();
- backBtn.setText("返回");
- backBtn.setColor(149, 165, 166);
- backBtn.setTextColor(255, 255, 255);
- backBtn.setHeight(40);
- backBtn.onClick(() => {
- printl("返回按钮被点击");
- mainTab.dismiss();
- });
- v.addView(backBtn);
-
- return v;
- }
- // ====================== 第三页:数据监控 ======================
- function createDataMonitor() {
- var v = new Vertical();
- v.setBackgroundColor(245, 247, 250);
- v.setSpacing(15);
-
- // 页面标题
- var header = new Horizontal();
- header.setAlignment("center");
-
- var title = new Label();
- title.setText("📊 数据监控中心");
- title.setTextColor(41, 128, 185);
- title.setFontSize(22);
- header.addView(title);
-
- v.addView(header);
-
- // 分隔线
- var divider = new Label();
- divider.setHeight(2);
- divider.setBackgroundColor(200, 200, 200);
- v.addView(divider);
-
- // 实时数据统计
- var statsContainer = new Vertical();
- statsContainer.setBackgroundColor(255, 255, 255);
-
- var statsTitle = new Label();
- statsTitle.setText("实时数据");
- statsTitle.setTextColor(80, 80, 80);
- statsTitle.setFontSize(16);
- statsContainer.addView(statsTitle);
-
- // 数据项
- addStatItem(statsContainer, "运行时间", "2小时35分钟", 52, 152, 219);
- addStatItem(statsContainer, "执行任务数", "128", 46, 204, 113);
- addStatItem(statsContainer, "成功率", "98.5%", 155, 89, 182);
- addStatItem(statsContainer, "内存使用", "256MB", 241, 196, 15);
- addStatItem(statsContainer, "CPU占用", "12%", 231, 76, 60);
-
- v.addView(statsContainer);
-
- // 分类统计
- var categoryContainer = new Vertical();
- categoryContainer.setBackgroundColor(255, 255, 255);
-
- var categoryTitle = new Label();
- categoryTitle.setText("分类统计");
- categoryTitle.setTextColor(80, 80, 80);
- categoryTitle.setFontSize(16);
- categoryContainer.addView(categoryTitle);
-
- addStatItem(categoryContainer, "自动化任务", "45", 52, 152, 219);
- addStatItem(categoryContainer, "数据处理", "32", 46, 204, 113);
- addStatItem(categoryContainer, "网络请求", "28", 155, 89, 182);
- addStatItem(categoryContainer, "文件操作", "23", 241, 196, 15);
-
- v.addView(categoryContainer);
-
- // 刷新按钮
- var refreshBtn = new Button();
- refreshBtn.setText("🔄 刷新数据");
- refreshBtn.setColor(52, 152, 219);
- refreshBtn.setTextColor(255, 255, 255);
- refreshBtn.setHeight(45);
- refreshBtn.onClick(() => {
- printl("数据已刷新");
- showToast("数据已更新");
- });
- v.addView(refreshBtn);
-
- // 导出按钮
- var exportBtn = new Button();
- exportBtn.setText("📥 导出报告");
- exportBtn.setColor(155, 89, 182);
- exportBtn.setTextColor(255, 255, 255);
- exportBtn.setHeight(45);
- exportBtn.onClick(() => {
- printl("导出数据报告");
- showToast("报告已导出");
- });
- v.addView(exportBtn);
-
- // 返回按钮
- var backBtn = new Button();
- backBtn.setText("返回");
- backBtn.setColor(149, 165, 166);
- backBtn.setTextColor(255, 255, 255);
- backBtn.setHeight(40);
- backBtn.onClick(() => {
- printl("返回按钮被点击");
- mainTab.dismiss();
- });
- v.addView(backBtn);
-
- return v;
- }
- // ====================== 第四页:系统设置 ======================
- function createSystemSettings() {
- var v = new Vertical();
- v.setBackgroundColor(245, 247, 250);
- v.setSpacing(15);
-
- // 页面标题
- var header = new Horizontal();
- header.setAlignment("center");
-
- var title = new Label();
- title.setText("⚙️ 系统设置");
- title.setTextColor(41, 128, 185);
- title.setFontSize(22);
- header.addView(title);
-
- v.addView(header);
-
- // 分隔线
- var divider = new Label();
- divider.setHeight(2);
- divider.setBackgroundColor(200, 200, 200);
- v.addView(divider);
-
- // 基本设置
- var basicSettings = new Vertical();
- basicSettings.setBackgroundColor(255, 255, 255);
-
- var basicTitle = new Label();
- basicTitle.setText("基本设置");
- basicTitle.setTextColor(80, 80, 80);
- basicTitle.setFontSize(16);
- basicSettings.addView(basicTitle);
-
- var autoSaveCheck = new CheckBox();
- autoSaveCheck.setText("自动保存配置");
- autoSaveCheck.setID("auto_save");
- autoSaveCheck.setDefultSelect();
- basicSettings.addView(autoSaveCheck);
-
- var autoStartCheck = new CheckBox();
- autoStartCheck.setText("开机自动启动");
- autoStartCheck.setID("auto_start");
- basicSettings.addView(autoStartCheck);
-
- var debugModeCheck = new CheckBox();
- debugModeCheck.setText("调试模式");
- debugModeCheck.setID("debug_mode");
- basicSettings.addView(debugModeCheck);
-
- v.addView(basicSettings);
-
- // 通知设置
- var notificationSettings = new Vertical();
- notificationSettings.setBackgroundColor(255, 255, 255);
-
- var notifTitle = new Label();
- notifTitle.setText("通知设置");
- notifTitle.setTextColor(80, 80, 80);
- notifTitle.setFontSize(16);
- notificationSettings.addView(notifTitle);
-
- var soundCheck = new CheckBox();
- soundCheck.setText("启用声音提示");
- soundCheck.setID("sound_enable");
- soundCheck.setDefultSelect();
- notificationSettings.addView(soundCheck);
-
- var vibrationCheck = new CheckBox();
- vibrationCheck.setText("启用震动反馈");
- vibrationCheck.setID("vibration_enable");
- vibrationCheck.setDefultSelect();
- notificationSettings.addView(vibrationCheck);
-
- var popupCheck = new CheckBox();
- popupCheck.setText("显示弹窗通知");
- popupCheck.setID("popup_enable");
- popupCheck.setDefultSelect();
- notificationSettings.addView(popupCheck);
-
- v.addView(notificationSettings);
-
- // 主题设置
- var themeContainer = new Horizontal();
- themeContainer.setAlignment("center");
- themeContainer.setSpacing(15);
-
- var themeLabel = new Label();
- themeLabel.setText("主题颜色:");
- themeLabel.setTextColor(80, 80, 80);
- themeContainer.addView(themeLabel);
-
- var lightThemeBtn = new Button();
- lightThemeBtn.setText("浅色");
- lightThemeBtn.setColor(255, 255, 255);
- lightThemeBtn.setTextColor(50, 50, 50);
- lightThemeBtn.setWidth(80);
- lightThemeBtn.setHeight(40);
- lightThemeBtn.onClick(() => {
- printl("切换到浅色主题");
- showToast("已切换到浅色主题");
- });
- themeContainer.addView(lightThemeBtn);
-
- var darkThemeBtn = new Button();
- darkThemeBtn.setText("深色");
- darkThemeBtn.setColor(50, 50, 50);
- darkThemeBtn.setTextColor(255, 255, 255);
- darkThemeBtn.setWidth(80);
- darkThemeBtn.setHeight(40);
- darkThemeBtn.onClick(() => {
- printl("切换到深色主题");
- showToast("已切换到深色主题");
- });
- themeContainer.addView(darkThemeBtn);
-
- v.addView(themeContainer);
-
- // 数据管理
- var dataContainer = new Vertical();
-
- var backupBtn = new Button();
- backupBtn.setText("💾 备份数据");
- backupBtn.setColor(52, 152, 219);
- backupBtn.setTextColor(255, 255, 255);
- backupBtn.setHeight(40);
- backupBtn.onClick(() => {
- printl("备份数据中...");
- showToast("数据备份中...");
- });
- dataContainer.addView(backupBtn);
-
- var restoreBtn = new Button();
- restoreBtn.setText("📂 恢复数据");
- restoreBtn.setColor(155, 89, 182);
- restoreBtn.setTextColor(255, 255, 255);
- restoreBtn.setHeight(40);
- restoreBtn.onClick(() => {
- printl("恢复数据中...");
- showToast("数据恢复中...");
- });
- dataContainer.addView(restoreBtn);
-
- var clearDataBtn = new Button();
- clearDataBtn.setText("🗑️ 清除数据");
- clearDataBtn.setColor(231, 76, 60);
- clearDataBtn.setTextColor(255, 255, 255);
- clearDataBtn.setHeight(40);
- clearDataBtn.onClick(() => {
- printl("清除所有数据");
- showToast("数据已清除");
- });
- dataContainer.addView(clearDataBtn);
-
- v.addView(dataContainer);
-
- // 保存设置按钮
- var saveBtn = new Button();
- saveBtn.setText("💾 保存设置");
- saveBtn.setColor(46, 204, 113);
- saveBtn.setTextColor(255, 255, 255);
- saveBtn.setHeight(45);
- saveBtn.onClick(() => {
- printl("设置已保存");
- showToast("设置已保存");
- });
- v.addView(saveBtn);
-
- // 返回按钮
- var backBtn = new Button();
- backBtn.setText("返回");
- backBtn.setColor(149, 165, 166);
- backBtn.setTextColor(255, 255, 255);
- backBtn.setHeight(40);
- backBtn.onClick(() => {
- printl("返回按钮被点击");
- mainTab.dismiss();
- });
- v.addView(backBtn);
-
- // 关于信息
- var aboutLabel = new Label();
- aboutLabel.setText("智能助手控制台 v1.0\n基于AIWROK开发平台");
- aboutLabel.setTextColor(120, 120, 120);
- aboutLabel.setFontSize(12);
- aboutLabel.setTextAlignment("center");
- v.addView(aboutLabel);
-
- return v;
- }
- // ====================== 辅助函数 ======================
- // 创建快捷按钮
- function createQuickButton(text, r, g, b, onClick) {
- var btn = new Button();
- btn.setText(text);
- btn.setColor(r, g, b);
- btn.setTextColor(255, 255, 255);
- btn.setWidth(80);
- btn.setHeight(50);
- btn.onClick(onClick);
- return btn;
- }
- // 添加任务项
- function addTaskItem(container, taskName, priority) {
- var item = new Horizontal();
- item.setAlignment("center_vertical");
-
- var checkBox = new CheckBox();
- checkBox.setText(taskName);
- checkBox.setWidth(180);
- item.addView(checkBox);
-
- var priorityLabel = new Label();
- priorityLabel.setText(priority);
- priorityLabel.setWidth(50);
-
- if (priority === "高") {
- priorityLabel.setTextColor(231, 76, 60);
- } else if (priority === "中") {
- priorityLabel.setTextColor(241, 196, 15);
- } else {
- priorityLabel.setTextColor(46, 204, 113);
- }
-
- item.addView(priorityLabel);
-
- var deleteBtn = new Button();
- deleteBtn.setText("删除");
- deleteBtn.setColor(231, 76, 60);
- deleteBtn.setTextColor(255, 255, 255);
- deleteBtn.setWidth(60);
- deleteBtn.setHeight(30);
- deleteBtn.onClick(() => {
- printl("删除任务: " + taskName);
- showToast("任务已删除");
- });
- item.addView(deleteBtn);
-
- container.addView(item);
- }
- // 添加统计项
- function addStatItem(container, label, value, r, g, b) {
- var item = new Horizontal();
- item.setAlignment("space_between");
- item.setSpacing(10);
-
- var labelView = new Label();
- labelView.setText(label);
- labelView.setTextColor(80, 80, 80);
- labelView.setWidth(120);
- item.addView(labelView);
-
- var valueView = new Label();
- valueView.setText(value);
- valueView.setTextColor(r, g, b);
- valueView.setTextAlignment("right");
- item.addView(valueView);
-
- container.addView(item);
- }
- // 显示提示信息
- function showToast(message) {
- printl("提示: " + message);
- }
- // 日志输出函数
- function printl(message) {
- console.log("[智能助手] " + message);
- }
复制代码
| |  | |  |
|