B2B网络软件

标题: 安卓脚本AIWROK软件示例JS函数高级用法 [打印本页]

作者: YYPOST群发软件    时间: 2 小时前
标题: 安卓脚本AIWROK软件示例JS函数高级用法
安卓脚本AIWROK软件示例JS函数高级用法 安卓脚本AIWROK软件示例JS函数高级用法 B2B网络软件

安卓脚本AIWROK软件示例JS函数高级用法 B2B网络软件

  1. // AIWROK 软件 - JavaScript函数综合示例大全
  2. // 作者: AIWROK 开发团队
  3. // 日期: 2024年6月
  4. // 🍎交流QQ群711841924群一,苹果内测群,528816639

  5. /**
  6. * =============================================================================
  7. * JavaScript函数综合示例大全
  8. * =============================================================================
  9. * 基于主脚本中的函数语法说明,展示JavaScript函数的各种高级应用
  10. * 包含:基础函数、闭包、高阶函数、递归、设计模式、异步编程、性能优化、错误处理
  11. *
  12. * 兼容性:Rhino 引擎 (ES5)
  13. * 平台:AIWROK 安卓自动化软件
  14. * =============================================================================
  15. */

  16. // =============================================================================
  17. // 工具函数
  18. // =============================================================================

  19. // 延迟函数(避免与系统sleep冲突)
  20. function delay(ms) {
  21.     var start = new Date().getTime();
  22.     while (new Date().getTime() < start + ms) {
  23.         // 等待
  24.     }
  25. }

  26. // =============================================================================
  27. // 第一部分:基础函数示例
  28. // =============================================================================

  29. // 简单函数定义
  30. function greet(name) {
  31.     return "你好, " + name + "!";
  32. }

  33. // 带默认参数的函数
  34. function greetWithDefault(name) {
  35.     var defaultName = "用户";
  36.     if (name === undefined || name === null) {
  37.         name = defaultName;
  38.     }
  39.     return "你好, " + name + "!";
  40. }

  41. // 多参数函数
  42. function calculateArea(width, height) {
  43.     return width * height;
  44. }

  45. // 演示基础函数
  46. function demoBasicFunctions() {
  47.     console.log("=== 基础函数示例 ===");
  48.    
  49.     var greeting = greet("张三");
  50.     console.log(greeting);
  51.    
  52.     var defaultGreeting = greetWithDefault();
  53.     console.log(defaultGreeting);
  54.    
  55.     var area = calculateArea(5, 10);
  56.     console.log("矩形面积: " + area);
  57. }

  58. // =============================================================================
  59. // 第二部分:返回值与条件返回
  60. // =============================================================================

  61. // 返回单个值
  62. function getMaxValue(arr) {
  63.     if (!arr || arr.length === 0) {
  64.         return null;
  65.     }
  66.    
  67.     var max = arr[0];
  68.     for (var i = 1; i < arr.length; i++) {
  69.         if (arr[i] > max) {
  70.             max = arr[i];
  71.         }
  72.     }
  73.     return max;
  74. }

  75. // 条件返回示例
  76. function divideNumbers(a, b) {
  77.     if (b === 0) {
  78.         return "错误: 除数不能为零";
  79.     }
  80.     return a / b;
  81. }

  82. // 演示返回值函数
  83. function demoReturnValues() {
  84.     console.log("=== 返回值函数示例 ===");
  85.    
  86.     var numbers = [3, 7, 2, 9, 1, 5];
  87.     var maxValue = getMaxValue(numbers);
  88.     console.log("数组最大值: " + maxValue);
  89.    
  90.     var result1 = divideNumbers(10, 2);
  91.     console.log("10 ÷ 2 = " + result1);
  92.    
  93.     var result2 = divideNumbers(10, 0);
  94.     console.log(result2);
  95. }

  96. // =============================================================================
  97. // 第三部分:闭包与私有变量
  98. // =============================================================================

  99. // 创建计数器工厂函数
  100. function createCounter(initialValue) {
  101.     var count = initialValue || 0;
  102.    
  103.     return {
  104.         increment: function() {
  105.             count++;
  106.             return count;
  107.         },
  108.         decrement: function() {
  109.             count--;
  110.             return count;
  111.         },
  112.         getValue: function() {
  113.             return count;
  114.         },
  115.         reset: function() {
  116.             count = initialValue || 0;
  117.             return count;
  118.         }
  119.     };
  120. }

  121. // 演示闭包
  122. function demoClosures() {
  123.     console.log("=== 闭包示例 ===");
  124.    
  125.     var counter1 = createCounter(0);
  126.     var counter2 = createCounter(10);
  127.    
  128.     console.log("计数器1初始值: " + counter1.getValue());
  129.     console.log("计数器2初始值: " + counter2.getValue());
  130.    
  131.     counter1.increment();
  132.     counter1.increment();
  133.     counter2.decrement();
  134.    
  135.     console.log("计数器1当前值: " + counter1.getValue());
  136.     console.log("计数器2当前值: " + counter2.getValue());
  137. }

  138. // =============================================================================
  139. // 第四部分:高阶函数
  140. // =============================================================================

  141. // 高阶函数:接收函数作为参数
  142. function applyOperation(a, b, operation) {
  143.     return operation(a, b);
  144. }

  145. function add(a, b) { return a + b; }
  146. function subtract(a, b) { return a - b; }
  147. function multiply(a, b) { return a * b; }

  148. // 高阶函数:返回函数
  149. function createMultiplier(factor) {
  150.     return function(number) {
  151.         return number * factor;
  152.     };
  153. }

  154. // 演示高阶函数
  155. function demoHigherOrderFunctions() {
  156.     console.log("=== 高阶函数示例 ===");
  157.    
  158.     var sum = applyOperation(5, 3, add);
  159.     console.log("5 + 3 = " + sum);
  160.    
  161.     var product = applyOperation(6, 7, multiply);
  162.     console.log("6 × 7 = " + product);
  163.    
  164.     var double = createMultiplier(2);
  165.     console.log("5 的两倍: " + double(5));
  166. }

  167. // =============================================================================
  168. // 第五部分:递归函数
  169. // =============================================================================

  170. // 计算阶乘
  171. function factorial(n) {
  172.     if (n <= 1) {
  173.         return 1;
  174.     }
  175.     return n * factorial(n - 1);
  176. }

  177. // 斐波那契数列
  178. function fibonacci(n) {
  179.     if (n <= 1) {
  180.         return n;
  181.     }
  182.     return fibonacci(n - 1) + fibonacci(n - 2);
  183. }

  184. // 演示递归函数
  185. function demoRecursion() {
  186.     console.log("=== 递归函数示例 ===");
  187.    
  188.     console.log("5! = " + factorial(5));
  189.     console.log("7! = " + factorial(7));
  190.    
  191.     console.log("斐波那契数列前10项:");
  192.     for (var i = 0; i < 10; i++) {
  193.         console.log("F(" + i + ") = " + fibonacci(i));
  194.     }
  195. }

  196. // =============================================================================
  197. // 第六部分:构造函数与面向对象
  198. // =============================================================================

  199. // 定义学生类
  200. function Student(name, age, grade) {
  201.     this.name = name;
  202.     this.age = age;
  203.     this.grade = grade;
  204.    
  205.     this.getInfo = function() {
  206.         return "姓名: " + this.name + ", 年龄: " + this.age + ", 年级: " + this.grade;
  207.     };
  208.    
  209.     this.isAdult = function() {
  210.         return this.age >= 18;
  211.     };
  212. }

  213. Student.prototype.promote = function() {
  214.     this.grade++;
  215.     return this.grade;
  216. };

  217. // 演示构造函数
  218. function demoConstructors() {
  219.     console.log("=== 构造函数示例 ===");
  220.    
  221.     var student1 = new Student("张三", 16, 10);
  222.     var student2 = new Student("李四", 19, 12);
  223.    
  224.     console.log(student1.getInfo());
  225.     console.log("是否成年: " + student1.isAdult());
  226.    
  227.     student1.promote();
  228.     console.log(student1.name + " 升级到年级: " + student1.grade);
  229. }

  230. // =============================================================================
  231. // 第七部分:回调函数
  232. // =============================================================================

  233. // 模拟异步操作
  234. function simulateAsyncOperation(data, callback) {
  235.     var processedData = data.toUpperCase();
  236.     callback(processedData);
  237. }

  238. // 处理数组的每个元素
  239. function processArray(arr, processor) {
  240.     var results = [];
  241.     for (var i = 0; i < arr.length; i++) {
  242.         results.push(processor(arr[i]));
  243.     }
  244.     return results;
  245. }

  246. // 演示回调函数
  247. function demoCallbacks() {
  248.     console.log("=== 回调函数示例 ===");
  249.    
  250.     simulateAsyncOperation("hello world", function(result) {
  251.         console.log("异步操作结果: " + result);
  252.     });
  253.    
  254.     var numbers = [1, 2, 3, 4, 5];
  255.     var squared = processArray(numbers, function(num) {
  256.         return num * num;
  257.     });
  258.     console.log("平方结果: " + JSON.stringify(squared));
  259. }

  260. // =============================================================================
  261. // 第八部分:单例模式
  262. // =============================================================================

  263. var ConfigManager = (function() {
  264.     var instance;
  265.    
  266.     function ConfigManager() {
  267.         this.config = {};
  268.         
  269.         this.set = function(key, value) {
  270.             this.config[key] = value;
  271.         };
  272.         
  273.         this.get = function(key) {
  274.             return this.config[key];
  275.         };
  276.     }
  277.    
  278.     return {
  279.         getInstance: function() {
  280.             if (!instance) {
  281.                 instance = new ConfigManager();
  282.             }
  283.             return instance;
  284.         }
  285.     };
  286. })();

  287. // 演示单例模式
  288. function demoSingletonPattern() {
  289.     console.log("=== 单例模式示例 ===");
  290.    
  291.     var config1 = ConfigManager.getInstance();
  292.     var config2 = ConfigManager.getInstance();
  293.    
  294.     console.log("两个实例是否相同: " + (config1 === config2));
  295.    
  296.     config1.set("appName", "AIWROK");
  297.     config1.set("version", "2.0");
  298.    
  299.     console.log("应用名称: " + config2.get("appName"));
  300.     console.log("版本号: " + config2.get("version"));
  301. }

  302. // =============================================================================
  303. // 第九部分:工厂模式
  304. // =============================================================================

  305. // 形状基类
  306. function Shape(type) {
  307.     this.type = type;
  308. }

  309. Shape.prototype.draw = function() {
  310.     throw new Error("draw方法必须被重写");
  311. };

  312. // 圆形类
  313. function Circle(radius) {
  314.     Shape.call(this, "circle");
  315.     this.radius = radius;
  316. }

  317. Circle.prototype = Object.create(Shape.prototype);
  318. Circle.prototype.constructor = Circle;
  319. Circle.prototype.draw = function() {
  320.     return "绘制圆形,半径: " + this.radius;
  321. };

  322. // 矩形类
  323. function Rectangle(width, height) {
  324.     Shape.call(this, "rectangle");
  325.     this.width = width;
  326.     this.height = height;
  327. }

  328. Rectangle.prototype = Object.create(Shape.prototype);
  329. Rectangle.prototype.constructor = Rectangle;
  330. Rectangle.prototype.draw = function() {
  331.     return "绘制矩形,宽: " + this.width + ", 高: " + this.height;
  332. };

  333. // 形状工厂
  334. function ShapeFactory() {
  335.     this.createShape = function(type, params) {
  336.         switch (type.toLowerCase()) {
  337.             case "circle":
  338.                 return new Circle(params.radius || 1);
  339.             case "rectangle":
  340.                 return new Rectangle(params.width || 1, params.height || 1);
  341.             default:
  342.                 throw new Error("不支持的形状类型: " + type);
  343.         }
  344.     };
  345. }

  346. // 演示工厂模式
  347. function demoFactoryPattern() {
  348.     console.log("=== 工厂模式示例 ===");
  349.    
  350.     var factory = new ShapeFactory();
  351.    
  352.     var circle = factory.createShape("circle", { radius: 5 });
  353.     var rectangle = factory.createShape("rectangle", { width: 4, height: 6 });
  354.    
  355.     console.log(circle.draw());
  356.     console.log(rectangle.draw());
  357. }

  358. // =============================================================================
  359. // 第十部分:观察者模式
  360. // =============================================================================

  361. function EventEmitter() {
  362.     this.events = {};
  363. }

  364. EventEmitter.prototype.on = function(eventName, listener) {
  365.     if (!this.events[eventName]) {
  366.         this.events[eventName] = [];
  367.     }
  368.     this.events[eventName].push(listener);
  369. };

  370. EventEmitter.prototype.emit = function(eventName) {
  371.     var args = Array.prototype.slice.call(arguments, 1);
  372.    
  373.     if (this.events[eventName]) {
  374.         for (var i = 0; i < this.events[eventName].length; i++) {
  375.             this.events[eventName][i].apply(null, args);
  376.         }
  377.     }
  378. };

  379. // 演示观察者模式
  380. function demoObserverPattern() {
  381.     console.log("=== 观察者模式示例 ===");
  382.    
  383.     var emitter = new EventEmitter();
  384.    
  385.     var listener1 = function(data) {
  386.         console.log("监听器1收到: " + data);
  387.     };
  388.    
  389.     var listener2 = function(data) {
  390.         console.log("监听器2收到: " + data);
  391.     };
  392.    
  393.     emitter.on("data", listener1);
  394.     emitter.on("data", listener2);
  395.    
  396.     console.log("触发data事件:");
  397.     emitter.emit("data", "第一条数据");
  398. }

  399. // =============================================================================
  400. // 第十一部分:Promise模拟
  401. // =============================================================================

  402. function SimplePromise(executor) {
  403.     this.state = "pending";
  404.     this.value = null;
  405.     this.callbacks = [];
  406.    
  407.     var self = this;
  408.    
  409.     function resolve(value) {
  410.         if (self.state === "pending") {
  411.             self.state = "fulfilled";
  412.             self.value = value;
  413.             
  414.             setTimeout(function() {
  415.                 for (var i = 0; i < self.callbacks.length; i++) {
  416.                     self.callbacks[i].onFulfilled(value);
  417.                 }
  418.             }, 0);
  419.         }
  420.     }
  421.    
  422.     function reject(reason) {
  423.         if (self.state === "pending") {
  424.             self.state = "rejected";
  425.             self.value = reason;
  426.             
  427.             setTimeout(function() {
  428.                 for (var i = 0; i < self.callbacks.length; i++) {
  429.                     if (self.callbacks[i].onRejected) {
  430.                         self.callbacks[i].onRejected(reason);
  431.                     }
  432.                 }
  433.             }, 0);
  434.         }
  435.     }
  436.    
  437.     try {
  438.         executor(resolve, reject);
  439.     } catch (e) {
  440.         reject(e);
  441.     }
  442. }

  443. SimplePromise.prototype.then = function(onFulfilled, onRejected) {
  444.     var self = this;
  445.    
  446.     return new SimplePromise(function(resolve, reject) {
  447.         function handleValue(value) {
  448.             try {
  449.                 if (typeof onFulfilled === "function") {
  450.                     var result = onFulfilled(value);
  451.                     resolve(result);
  452.                 } else {
  453.                     resolve(value);
  454.                 }
  455.             } catch (e) {
  456.                 reject(e);
  457.             }
  458.         }
  459.         
  460.         if (self.state === "fulfilled") {
  461.             setTimeout(function() {
  462.                 handleValue(self.value);
  463.             }, 0);
  464.         } else {
  465.             self.callbacks.push({
  466.                 onFulfilled: handleValue,
  467.                 onRejected: onRejected
  468.             });
  469.         }
  470.     });
  471. };

  472. // 演示Promise
  473. function demoPromise() {
  474.     console.log("=== Promise示例 ===");
  475.    
  476.     var promise1 = new SimplePromise(function(resolve, reject) {
  477.         setTimeout(function() {
  478.             resolve("Promise完成");
  479.         }, 100);
  480.     });
  481.    
  482.     promise1.then(function(result) {
  483.         console.log("结果: " + result);
  484.     });
  485. }

  486. // =============================================================================
  487. // 第十二部分:记忆化优化
  488. // =============================================================================

  489. function memoize(func) {
  490.     var cache = {};
  491.    
  492.     return function() {
  493.         var key = JSON.stringify(arguments);
  494.         
  495.         if (cache.hasOwnProperty(key)) {
  496.             return cache[key];
  497.         }
  498.         
  499.         var result = func.apply(this, arguments);
  500.         cache[key] = result;
  501.         return result;
  502.     };
  503. }

  504. // 记忆化斐波那契
  505. var fibonacciMemoized = memoize(function(n) {
  506.     if (n <= 1) return n;
  507.     return fibonacciMemoized(n - 1) + fibonacciMemoized(n - 2);
  508. });

  509. // 演示记忆化
  510. function demoMemoization() {
  511.     console.log("=== 记忆化示例 ===");
  512.    
  513.     var start1 = new Date().getTime();
  514.     var result1 = fibonacciMemoized(30);
  515.     var time1 = new Date().getTime() - start1;
  516.     console.log("记忆化斐波那契(30): " + result1 + ", 耗时: " + time1 + "ms");
  517.    
  518.     var start2 = new Date().getTime();
  519.     var result2 = fibonacciMemoized(30);
  520.     var time2 = new Date().getTime() - start2;
  521.     console.log("再次调用(缓存): " + result2 + ", 耗时: " + time2 + "ms");
  522. }

  523. // =============================================================================
  524. // 第十三部分:节流与防抖
  525. // =============================================================================

  526. // 节流函数
  527. function throttle(func, delay) {
  528.     var lastCall = 0;
  529.    
  530.     return function() {
  531.         var now = new Date().getTime();
  532.         
  533.         if (now - lastCall >= delay) {
  534.             lastCall = now;
  535.             return func.apply(this, arguments);
  536.         }
  537.     };
  538. }

  539. // 防抖函数
  540. function debounce(func, delay) {
  541.     var timeoutId;
  542.    
  543.     return function() {
  544.         var context = this;
  545.         var args = arguments;
  546.         
  547.         clearTimeout(timeoutId);
  548.         timeoutId = setTimeout(function() {
  549.             func.apply(context, args);
  550.         }, delay);
  551.     };
  552. }

  553. // 演示节流
  554. function demoThrottling() {
  555.     console.log("=== 节流示例 ===");
  556.    
  557.     var callCount = 0;
  558.     var throttledFunction = throttle(function() {
  559.         callCount++;
  560.         console.log("函数被调用,总次数: " + callCount);
  561.     }, 1000);
  562.    
  563.     for (var i = 0; i < 5; i++) {
  564.         throttledFunction();
  565.         var start = new Date().getTime();
  566.         while (new Date().getTime() < start + 200) {}
  567.     }
  568.    
  569.     console.log("最终调用次数: " + callCount);
  570. }

  571. // =============================================================================
  572. // 第十四部分:错误处理
  573. // =============================================================================

  574. // 安全除法函数
  575. function safeDivide(a, b) {
  576.     try {
  577.         if (typeof a !== 'number' || typeof b !== 'number') {
  578.             throw new TypeError("参数必须是数字");
  579.         }
  580.         
  581.         if (b === 0) {
  582.             throw new Error("除数不能为零");
  583.         }
  584.         
  585.         return a / b;
  586.     } catch (error) {
  587.         console.log("捕获到错误: " + error.name + " - " + error.message);
  588.         return null;
  589.     }
  590. }

  591. // 自定义错误类
  592. function CustomError(message, code) {
  593.     this.name = "CustomError";
  594.     this.message = message;
  595.     this.code = code;
  596.     this.timestamp = new Date().toISOString();
  597. }

  598. CustomError.prototype = Object.create(Error.prototype);
  599. CustomError.prototype.constructor = CustomError;

  600. // 演示错误处理
  601. function demoErrorHandling() {
  602.     console.log("=== 错误处理示例 ===");
  603.    
  604.     console.log("10 ÷ 2 = " + safeDivide(10, 2));
  605.     console.log("10 ÷ 0 = " + safeDivide(10, 0));
  606.    
  607.     try {
  608.         throw new CustomError("自定义错误消息", "CUSTOM_CODE");
  609.     } catch (error) {
  610.         console.log("捕获自定义错误: " + error.message);
  611.     }
  612. }

  613. // =============================================================================
  614. // 第十五部分:实战应用 - 用户管理
  615. // =============================================================================

  616. function User(id, name, email, age) {
  617.     this.id = id;
  618.     this.name = name;
  619.     this.email = email;
  620.     this.age = age;
  621.    
  622.     this.getInfo = function() {
  623.         return {
  624.             id: this.id,
  625.             name: this.name,
  626.             email: this.email,
  627.             age: this.age
  628.         };
  629.     };
  630.    
  631.     this.isAdult = function() {
  632.         return this.age >= 18;
  633.     };
  634. }

  635. function UserManager() {
  636.     this.users = [];
  637.     this.nextId = 1;
  638.    
  639.     this.addUser = function(name, email, age) {
  640.         var user = new User(this.nextId++, name, email, age);
  641.         this.users.push(user);
  642.         return user;
  643.     };
  644.    
  645.     this.getAdultUsers = function() {
  646.         var adults = [];
  647.         for (var i = 0; i < this.users.length; i++) {
  648.             if (this.users[i].isAdult()) {
  649.                 adults.push(this.users[i]);
  650.             }
  651.         }
  652.         return adults;
  653.     };
  654.    
  655.     this.getStats = function() {
  656.         return {
  657.             totalUsers: this.users.length,
  658.             adultUsers: this.getAdultUsers().length
  659.         };
  660.     };
  661. }

  662. // 演示用户管理
  663. function demoUserManagement() {
  664.     console.log("=== 用户管理示例 ===");
  665.    
  666.     var userManager = new UserManager();
  667.    
  668.     userManager.addUser("张三", "zhangsan@example.com", 25);
  669.     userManager.addUser("李四", "lisi@example.com", 17);
  670.     userManager.addUser("王五", "wangwu@example.com", 30);
  671.    
  672.     var stats = userManager.getStats();
  673.     console.log("用户统计: " + JSON.stringify(stats));
  674. }

  675. // =============================================================================
  676. // 第十六部分:实战应用 - 数据处理器
  677. // =============================================================================

  678. function DataProcessor() {
  679.     this.data = [];
  680.    
  681.     this.addData = function(item) {
  682.         this.data.push(item);
  683.         return this;
  684.     };
  685.    
  686.     this.filter = function(predicate) {
  687.         var filtered = [];
  688.         for (var i = 0; i < this.data.length; i++) {
  689.             if (predicate(this.data[i])) {
  690.                 filtered.push(this.data[i]);
  691.             }
  692.         }
  693.         this.data = filtered;
  694.         return this;
  695.     };
  696.    
  697.     this.map = function(transformer) {
  698.         var transformed = [];
  699.         for (var i = 0; i < this.data.length; i++) {
  700.             transformed.push(transformer(this.data[i]));
  701.         }
  702.         this.data = transformed;
  703.         return this;
  704.     };
  705.    
  706.     this.getResult = function() {
  707.         return this.data;
  708.     };
  709.    
  710.     this.reset = function() {
  711.         this.data = [];
  712.         return this;
  713.     };
  714. }

  715. // 演示数据处理器
  716. function demoDataProcessor() {
  717.     console.log("=== 数据处理器示例 ===");
  718.    
  719.     var processor = new DataProcessor();
  720.    
  721.     processor.addData(1).addData(2).addData(3).addData(4).addData(5).addData(6);
  722.     console.log("原始数据: " + JSON.stringify(processor.getResult()));
  723.    
  724.     processor
  725.         .filter(function(num) { return num % 2 === 0; })
  726.         .map(function(num) { return num * 2; });
  727.    
  728.     console.log("偶数加倍后: " + JSON.stringify(processor.getResult()));
  729. }

  730. // =============================================================================
  731. // 主执行函数
  732. // =============================================================================

  733. function main() {
  734.     console.log("===== JavaScript函数综合示例大全 =====");
  735.     console.log("");
  736.    
  737.     // 基础部分
  738.     demoBasicFunctions();
  739.     delay(2000);
  740.    
  741.     demoReturnValues();
  742.     delay(2000);
  743.    
  744.     demoClosures();
  745.     delay(2000);
  746.    
  747.     demoHigherOrderFunctions();
  748.     delay(2000);
  749.    
  750.     demoRecursion();
  751.     delay(2000);
  752.    
  753.     demoConstructors();
  754.     delay(2000);
  755.    
  756.     demoCallbacks();
  757.     delay(2000);
  758.    
  759.     // 设计模式
  760.     demoSingletonPattern();
  761.     delay(2000);
  762.    
  763.     demoFactoryPattern();
  764.     delay(2000);
  765.    
  766.     demoObserverPattern();
  767.     delay(2000);
  768.    
  769.     // 异步编程
  770.     demoPromise();
  771.     delay(2000);
  772.    
  773.     // 性能优化
  774.     demoMemoization();
  775.     delay(2000);
  776.    
  777.     demoThrottling();
  778.     delay(2000);
  779.    
  780.     // 错误处理
  781.     demoErrorHandling();
  782.     delay(2000);
  783.    
  784.     // 实战应用
  785.     demoUserManagement();
  786.     delay(2000);
  787.    
  788.     demoDataProcessor();
  789.    
  790.     console.log("");
  791.     console.log("===== 所有示例执行完成 =====");
  792. }

  793. // 执行主函数
  794. main();
复制代码












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