 | |  |  | 现代深色UI设计风格
- // 🎯 智能个人助手 - 全新UI界面设计
- // 🍎腾711841924,腾528816639
- // 特色功能: 任务管理、快捷操作、数据监控、个性化设置
- printl("=== 智能个人助手启动 ===");
- var tab = new TabView();
- tab.setTitles(["首页", "任务", "工具", "数据"]);
- tab.show(function() {
- printl("智能个人助手界面加载完成");
-
- // ====================== 第一页:智能首页 ======================
- var homePage = createHomePage();
- tab.addView(0, homePage);
-
- // ====================== 第二页:任务管理 ======================
- var taskPage = createTaskPage();
- tab.addView(1, taskPage);
-
- // ====================== 第三页:快捷工具 ======================
- var toolPage = createToolPage();
- tab.addView(2, toolPage);
-
- // ====================== 第四页:数据监控 ======================
- var dataPage = createDataPage();
- tab.addView(3, dataPage);
-
- printl("所有页面初始化完成");
- });
- // ====================== 创建智能首页 ======================
- function createHomePage() {
- var page = new Vertical();
- page.setSpacing(12);
- page.setBackgroundColor(248, 250, 252);
-
- // 顶部欢迎卡片
- var welcomeCard = new Vertical();
- welcomeCard.setBackgroundColor(255, 255, 255);
- welcomeCard.setContainerSize(380, 140);
-
- var timeLabel = new Label();
- var now = new Date();
- var hour = now.getHours();
- var greeting = "";
- if (hour < 6) greeting = "夜深了";
- else if (hour < 9) greeting = "早上好";
- else if (hour < 12) greeting = "上午好";
- else if (hour < 14) greeting = "中午好";
- else if (hour < 18) greeting = "下午好";
- else greeting = "晚上好";
-
- timeLabel.setText(greeting + "!\n" + (now.getMonth() + 1) + "月" + now.getDate() + "日");
- timeLabel.setTextColor(50, 50, 50);
- timeLabel.setFontSize(22);
- timeLabel.setTextAlignment("center");
- welcomeCard.addView(timeLabel);
-
- var quoteLabel = new Label();
- quoteLabel.setText("✨ 每一天都是新的开始");
- quoteLabel.setTextColor(120, 120, 120);
- quoteLabel.setFontSize(13);
- quoteLabel.setTextAlignment("center");
- welcomeCard.addView(quoteLabel);
-
- page.addView(welcomeCard);
-
- // 快速统计区域
- var statsRow = new Horizontal();
- statsRow.setSpacing(10);
-
- var statItems = [
- {icon: "📋", label: "待办", value: "5", color: [66, 133, 244]},
- {icon: "✅", label: "完成", value: "12", color: [52, 168, 83]},
- {icon: "⏰", label: "提醒", value: "3", color: [251, 188, 5]}
- ];
-
- // 统计卡片添加点击交互
- for (var i = 0; i < statItems.length; i++) {
- var statCard = createStatCard(statItems[i]);
- // 为统计卡片添加点击按钮
- var clickBtn = new Button();
- clickBtn.setText("查看");
- clickBtn.setColor(statItems[i].color[0], statItems[i].color[1], statItems[i].color[2]);
- clickBtn.setTextColor(255, 255, 255);
- clickBtn.setWidth(115);
- clickBtn.setHeight(25);
- clickBtn.onClick(function() {
- printl("查看" + statItems[i].label + "详情");
- showToast(statItems[i].label + "详细数据");
- });
- statsRow.addView(statCard);
- }
-
- page.addView(statsRow);
-
- // 常用功能区
- var sectionTitle = new Label();
- sectionTitle.setText("常用功能");
- sectionTitle.setTextColor(80, 80, 80);
- sectionTitle.setFontSize(16);
- page.addView(sectionTitle);
-
- var quickActions = new Vertical();
- quickActions.setBackgroundColor(255, 255, 255);
- quickActions.setSpacing(8);
-
- var actions = [
- {icon: "📝", text: "新建笔记", color: [66, 133, 244]},
- {icon: "📅", text: "添加日程", color: [52, 168, 83]},
- {icon: "🔔", text: "设置提醒", color: [251, 188, 5]},
- {icon: "📊", text: "查看报告", color: [156, 39, 176]},
- {icon: "🏠", text: "返回桌面", color: [244, 67, 54]}
- ];
-
- for (var i = 0; i < actions.length; i++) {
- var actionBtn = createActionButton(actions[i]);
- quickActions.addView(actionBtn);
- }
-
- page.addView(quickActions);
-
- return page;
- }
- // 创建统计卡片
- function createStatCard(item) {
- var card = new Vertical();
- card.setAlignment("center");
- card.setBackgroundColor(255, 255, 255);
- card.setContainerSize(115, 90);
-
- var iconLabel = new Label();
- iconLabel.setText(item.icon);
- iconLabel.setFontSize(28);
- card.addView(iconLabel);
-
- var valueLabel = new Label();
- valueLabel.setText(item.value);
- valueLabel.setTextColor(item.color[0], item.color[1], item.color[2]);
- valueLabel.setFontSize(20);
- card.addView(valueLabel);
-
- var label = new Label();
- label.setText(item.label);
- label.setTextColor(150, 150, 150);
- label.setFontSize(12);
- card.addView(label);
-
- return card;
- }
- // 创建操作按钮
- function createActionButton(item) {
- var btn = new Button();
- btn.setText(item.icon + " " + item.text);
- btn.setColor(item.color[0], item.color[1], item.color[2]);
- btn.setTextColor(255, 255, 255);
- btn.setHeight(50);
- btn.onClick(function() {
- printl("点击: " + item.text);
-
- // 如果是"新建笔记"按钮,执行主脚本的功能
- if (item.text === "新建笔记") {
- try {
- showToast("正在启动主脚本...");
- printl("=== 开始执行主脚本功能 ===");
-
- // 使用 Import() 函数导入并运行主脚本.js
- printl("尝试导入主脚本.js...");
- Import("主脚本.js");
- toast.show("已导入主脚本.js");
- printl("✓ 主脚本已导入");
-
- } catch(e) {
- printl("导入主脚本失败: " + e.message);
- showToast("导入失败: " + e.message);
- }
- }
- // 如果是"返回桌面"按钮,直接返回桌面
- else if (item.text === "返回桌面") {
- showToast("正在返回桌面...");
- try {
- hid.home();
- printl("已按下Home键返回桌面");
- } catch(e) {
- printl("返回桌面失败: " + e.message);
- showToast("返回失败: " + e.message);
- }
- } else {
- showToast(item.text + " 功能开发中");
- }
- });
- return btn;
- }
- // ====================== 创建任务管理页 ======================
- function createTaskPage() {
- var page = new Vertical();
- page.setSpacing(15);
- page.setBackgroundColor(248, 250, 252);
-
- // 标题栏
- var header = new Horizontal();
- header.setBackgroundColor(255, 255, 255);
-
- var titleLabel = new Label();
- titleLabel.setText("📋 任务管理");
- titleLabel.setTextColor(50, 50, 50);
- titleLabel.setFontSize(20);
- header.addView(titleLabel);
-
- page.addView(header);
-
- // 任务分类标签
- var categoryRow = new Horizontal();
- categoryRow.setSpacing(10);
-
- var categories = ["全部", "进行中", "已完成", "已延期"];
- for (var i = 0; i < categories.length; i++) {
- var catBtn = new Button();
- catBtn.setText(categories[i]);
- catBtn.setColor(i === 0 ? 66 : 200, i === 0 ? 133 : 200, i === 0 ? 244 : 200);
- catBtn.setTextColor(255, 255, 255);
- catBtn.setWidth(80);
- catBtn.setHeight(35);
- catBtn.onClick(function() {
- printl("筛选任务: " + this.getText());
- showToast("已筛选: " + this.getText());
- });
- categoryRow.addView(catBtn);
- }
-
- page.addView(categoryRow);
-
- // 任务列表
- var taskList = new Vertical();
- taskList.setSpacing(10);
-
- var tasks = [
- {title: "完成项目文档", priority: "高", status: "进行中", time: "今天 18:00"},
- {title: "回复客户邮件", priority: "中", status: "待处理", time: "明天 10:00"},
- {title: "整理会议纪要", priority: "低", status: "已完成", time: "昨天"}
- ];
-
- for (var i = 0; i < tasks.length; i++) {
- var taskCard = createTaskCard(tasks[i]);
- taskList.addView(taskCard);
- }
-
- page.addView(taskList);
-
- // 添加任务按钮
- var addBtn = new Button();
- addBtn.setText("+ 新建任务");
- addBtn.setColor(66, 133, 244);
- addBtn.setTextColor(255, 255, 255);
- addBtn.setHeight(50);
- addBtn.onClick(function() {
- printl("新建任务");
- showToast("新建任务功能");
- });
- page.addView(addBtn);
-
- return page;
- }
- // 创建任务卡片
- function createTaskCard(task) {
- var card = new Vertical();
- card.setBackgroundColor(255, 255, 255);
-
- // 添加点击事件
- card.onClick = function() {
- printl("查看任务: " + task.title);
- showToast("任务: " + task.title);
- };
-
- var titleRow = new Horizontal();
-
- var priorityColor = task.priority === "高" ? [244, 67, 54] :
- task.priority === "中" ? [255, 152, 0] : [76, 175, 80];
-
- var priorityBadge = new Label();
- priorityBadge.setText(task.priority);
- priorityBadge.setTextColor(priorityColor[0], priorityColor[1], priorityColor[2]);
- priorityBadge.setFontSize(12);
- priorityBadge.setBackgroundColor(priorityColor[0], priorityColor[1], priorityColor[2]);
- titleRow.addView(priorityBadge);
-
- var space = new Label();
- space.setWidth(10);
- titleRow.addView(space);
-
- var titleLabel = new Label();
- titleLabel.setText(task.title);
- titleLabel.setTextColor(50, 50, 50);
- titleLabel.setFontSize(15);
- titleRow.addView(titleLabel);
-
- card.addView(titleRow);
-
- var infoRow = new Horizontal();
-
- var statusLabel = new Label();
- statusLabel.setText(task.status);
- statusLabel.setTextColor(120, 120, 120);
- statusLabel.setFontSize(12);
- infoRow.addView(statusLabel);
-
- var timeLabel = new Label();
- timeLabel.setText("⏰ " + task.time);
- timeLabel.setTextColor(150, 150, 150);
- timeLabel.setFontSize(12);
- infoRow.addView(timeLabel);
-
- card.addView(infoRow);
-
- return card;
- }
- // ====================== 创建快捷工具页 ======================
- function createToolPage() {
- var page = new Vertical();
- page.setSpacing(15);
- page.setBackgroundColor(248, 250, 252);
-
- // 标题
- var header = new Horizontal();
- header.setBackgroundColor(255, 255, 255);
-
- var titleLabel = new Label();
- titleLabel.setText("🛠️ 快捷工具");
- titleLabel.setTextColor(50, 50, 50);
- titleLabel.setFontSize(20);
- header.addView(titleLabel);
-
- page.addView(header);
-
- // 工具网格
- var toolsGrid = new Vertical();
- toolsGrid.setSpacing(15);
-
- var toolRows = [
- [
- {icon: "🧮", name: "计算器", color: [66, 133, 244]},
- {icon: "📏", name: "单位转换", color: [52, 168, 83]},
- {icon: "💱", name: "汇率", color: [251, 188, 5]}
- ],
- [
- {icon: "📝", name: "记事本", color: [156, 39, 176]},
- {icon: "🔍", name: "搜索", color: [233, 30, 99]},
- {icon: "📷", name: "扫码", color: [0, 150, 136]}
- ],
- [
- {icon: "🌐", name: "翻译", color: [33, 150, 243]},
- {icon: "📅", name: "日历", color: [255, 87, 34]},
- {icon: "⏱️", name: "计时器", color: [121, 85, 72]}
- ]
- ];
-
- for (var i = 0; i < toolRows.length; i++) {
- var row = new Horizontal();
- row.setSpacing(10);
-
- for (var j = 0; j < toolRows[i].length; j++) {
- var toolBtn = createToolButton(toolRows[i][j]);
- row.addView(toolBtn);
- }
-
- toolsGrid.addView(row);
- }
-
- page.addView(toolsGrid);
-
- return page;
- }
- // 创建工具按钮
- function createToolButton(tool) {
- var btn = new Button();
- btn.setText(tool.icon + "\n" + tool.name);
- btn.setColor(tool.color[0], tool.color[1], tool.color[2]);
- btn.setTextColor(255, 255, 255);
- btn.setWidth(115);
- btn.setHeight(100);
- btn.onClick(function() {
- printl("打开工具: " + tool.name);
- showToast(tool.name + " 工具");
- });
- return btn;
- }
- // ====================== 创建数据监控页 ======================
- function createDataPage() {
- var page = new Vertical();
- page.setSpacing(15);
- page.setBackgroundColor(248, 250, 252);
-
- // 标题
- var header = new Horizontal();
- header.setBackgroundColor(255, 255, 255);
-
- var titleLabel = new Label();
- titleLabel.setText("📊 数据监控");
- titleLabel.setTextColor(50, 50, 50);
- titleLabel.setFontSize(20);
- header.addView(titleLabel);
-
- page.addView(header);
-
- // 数据概览卡片
- var overviewCard = new Vertical();
- overviewCard.setBackgroundColor(255, 255, 255);
-
- var overviewTitle = new Label();
- overviewTitle.setText("本周概览");
- overviewTitle.setTextColor(80, 80, 80);
- overviewTitle.setFontSize(16);
- overviewCard.addView(overviewTitle);
-
- var dataItems = [
- {label: "完成任务", value: "28", unit: "个", color: [66, 133, 244]},
- {label: "工作时长", value: "35.5", unit: "小时", color: [52, 168, 83]},
- {label: "效率评分", value: "92", unit: "分", color: [251, 188, 5]}
- ];
-
- // 数据项添加点击交互
- for (var i = 0; i < dataItems.length; i++) {
- var dataRow = new Horizontal();
- var itemData = dataItems[i]; // 保存当前数据到局部变量,避免闭包问题
-
- var label = new Label();
- label.setText(itemData.label);
- label.setTextColor(100, 100, 100);
- label.setFontSize(14);
- dataRow.addView(label);
-
- var valueLabel = new Label();
- valueLabel.setText(itemData.value + itemData.unit);
- valueLabel.setTextColor(itemData.color[0], itemData.color[1], itemData.color[2]);
- valueLabel.setFontSize(18);
- dataRow.addView(valueLabel);
-
- // 为每个数据行添加点击按钮
- var clickBtn = new Button();
- clickBtn.setText("详情");
- clickBtn.setColor(itemData.color[0], itemData.color[1], itemData.color[2]);
- clickBtn.setTextColor(255, 255, 255);
- clickBtn.setWidth(60);
- clickBtn.setHeight(30);
- clickBtn.onClick(function() {
- printl("查看" + itemData.label + "详情");
- showToast(itemData.label + "详细信息");
- });
- dataRow.addView(clickBtn);
-
- overviewCard.addView(dataRow);
- }
-
- page.addView(overviewCard);
-
- // 趋势图表占位
- var chartCard = new Vertical();
- chartCard.setBackgroundColor(255, 255, 255);
- chartCard.setContainerSize(380, 200);
-
- var chartTitle = new Label();
- chartTitle.setText("任务完成趋势");
- chartTitle.setTextColor(80, 80, 80);
- chartTitle.setFontSize(16);
- chartCard.addView(chartTitle);
-
- var chartPlaceholder = new Label();
- chartPlaceholder.setText("📈 图表区域\n(数据可视化)");
- chartPlaceholder.setTextColor(180, 180, 180);
- chartPlaceholder.setFontSize(14);
- chartPlaceholder.setTextAlignment("center");
- chartCard.addView(chartPlaceholder);
-
- page.addView(chartCard);
-
- return page;
- }
- // ====================== 账号配置函数 ======================
- function openAccountConfig() {
- printl("打开账号配置界面");
-
- // 获取当前配置的账号密码
- var currentAccount = config.getConfig("panda_account") || "";
- var currentPassword = config.getConfig("panda_password") || "";
-
- printl("当前账号: " + currentAccount);
- printl("当前密码: " + currentPassword);
-
- // 显示配置提示
- toast.show("账号配置说明:\n\n请在脚本中运行以下代码设置账号密码:\n\nconfig.setConfig('panda_account', '您的账号')\nconfig.setConfig('panda_password', '您的密码')\n\n或者直接在'新建笔记'按钮使用时自动提示配置");
-
- // 如果有配置,显示当前值
- if (currentAccount != "" && currentPassword != "") {
- toast.show("当前已配置:\n账号: " + currentAccount + "\n密码: " + currentPassword);
- }
- }
- // Toast提示函数
- function showToast(message) {
- printl("[提示] " + message);
- // 在手机上显示吐司弹窗
- try {
- toast.show(message); // 直接使用全局toast对象
- } catch(e) {
- printl("Toast显示失败: " + e.message);
- }
- }
- printl("智能个人助手已启动");
复制代码
| |  | |  |
|