你是一个资深全栈工程师,你的任务是帮我生成运行在 JSBox 中的 Node.js + Web 应用项目。
JSBox 是一个可以用来运行 JavaScript 脚本的 iOS 应用,它包含一个定制化的 Node 环境。
请严格遵守:
| const idManager = require("../utils/id"); | |
| class BaseView { | |
| constructor() { | |
| this.id = idManager.newId; | |
| } | |
| get definition() { | |
| return this._defineView(); | |
| } |
| class Canvas { | |
| constructor(options) { | |
| this.baseInterval = 1 / 60; | |
| Object.assign(this, options); | |
| this.draw = (view, ctx) => { | |
| ctx.strokeColor = this.tintColor; | |
| const radius = Math.min(view.frame.width, view.frame.height); | |
| ctx.setLineWidth(20); | |
| ctx.setLineCap(1); | |
| ctx.setLineJoin(1); |
| class Canvas { | |
| constructor(options) { | |
| this.baseInterval = 1 / 60; | |
| Object.assign(this, options); | |
| this.draw = (view, ctx) => { | |
| ctx.strokeColor = this.tintColor; | |
| const radius = Math.min(view.frame.width, view.frame.height); | |
| ctx.setLineWidth(20); | |
| ctx.setLineCap(1); | |
| ctx.setLineJoin(1); |
| const TIPS = | |
| "如果在请注意对于黑、白、灰、深灰、浅灰等单色,hexCode仅前两位有效,比如#80FF00其实是灰色,#00FF00其实是黑色。\n由于颜色可以动态变化比较复杂,不对此进行修改。"; | |
| $app.theme = "auto"; | |
| const semanticColors = [ | |
| { | |
| name: "tintColor", | |
| description: "主题色" | |
| }, |
| // When called without arguments, return the center of the rectangle. When a Point is passed as an argument, the rectangle’s x and y values are adjusted, so that the new center of the rectangle is p. | |
| function center(rect, point) { | |
| const { x, y, width: w, height: h } = rect; | |
| if (!point) return $point(x + w / 2, y + h / 2); | |
| const { x: px, y: py } = point; | |
| rect.x = px - w / 2; | |
| rect.y = py - h / 2; | |
| return point; | |
| } |
| class Canvas { | |
| constructor(options) { | |
| this.baseInterval = 1 / 60; | |
| Object.assign(this, options); | |
| this.draw = (view, ctx) => { | |
| ctx.fillColor = this.tintColor; | |
| const radius = Math.min(view.frame.width, view.frame.height); | |
| ctx.setLineWidth(1); | |
| ctx.setLineCap(0); | |
| ctx.setLineJoin(1); |
| function download(params) { | |
| params = params || {}; | |
| params.handlers = params.handlers || {}; | |
| const url = params.url; | |
| const method = params.method || "GET"; | |
| const timeout = params.timeout || 60; | |
| const header = params.header || {}; | |
| const body = params.body; | |
| const callback = params.handler; |
| $objc("NSBundle").$bundleWithPath("/System/Library/PrivateFrameworks/BatteryCenter.framework").$load(); | |
| let deviceController = $objc("BCBatteryDeviceController").$sharedInstance(); | |
| let devices = deviceController.$connectedDevices(); | |
| for (var idx=0; idx<devices.$count(); ++idx) { | |
| let device = devices.$objectAtIndex(idx); | |
| console.log(`name: ${device.$name().rawValue()}`); | |
| console.log(`percentCharge: ${device.$percentCharge()}%`); | |
| console.log(`charging: ${device.$isCharging()}`); |
| const htmlColors = { | |
| //Pink Colors | |
| "Pink": "#FFC0CB", | |
| "LightPink": "#FFB6C1", | |
| "HotPink": "#FF69B4", | |
| "DeepPink": "#FF1493", | |
| "PaleVioletRed": "#DB7093", | |
| "MediumVioletRed": "#C71585", | |
| //Purple Colors | |
| "Lavender": "#E6E6FA", |