From 7685f8b27a878b5c4c55391e7849e0413f4d4362 Mon Sep 17 00:00:00 2001 From: ipuppet Date: Sun, 3 Apr 2022 12:35:03 +0800 Subject: [PATCH 1/4] update --- scripts/lib/easy-jsbox.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/lib/easy-jsbox.js b/scripts/lib/easy-jsbox.js index b23e348..7b80f35 100644 --- a/scripts/lib/easy-jsbox.js +++ b/scripts/lib/easy-jsbox.js @@ -608,7 +608,7 @@ class Matrix extends View { this.setEvent("itemSize", (sender, indexPath) => { const info = sender.object(indexPath)?.__title?.info if (info?.title) { - return $size(Math.max(UIKit.windowSize.width, UIKit.windowSize.height), 0) + return $size(Math.max($device.info.screen.width, $device.info.screen.height), 0) } const columns = this.props.columns ?? 2 const spacing = this.props.spacing ?? 15 @@ -2127,7 +2127,7 @@ class Setting extends Controller { // 存储数据 setting = {} // fileStorage - fileStorage = new FileStorage() + fileStorage imagePath // 用来控制 child 类型 viewController = new ViewController() @@ -2147,12 +2147,12 @@ class Setting extends Controller { constructor(args = {}) { super() - this.fileStorage = args.fileStorage ?? this.fileStorage // set 和 get 同时设置才会生效 if (typeof args.set === "function" && typeof args.get === "function") { this.set = args.set this.get = args.get } else { + this.fileStorage = args.fileStorage ?? new FileStorage() this.dataFile = args.dataFile ?? "setting.json" } if (args.structure) { From e2fc4eb5a80537b402eef8de89da51a273653267 Mon Sep 17 00:00:00 2001 From: ipuppet Date: Sun, 3 Apr 2022 14:43:18 +0800 Subject: [PATCH 2/4] Setting use this.fileStorage --- scripts/app.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/app.js b/scripts/app.js index 447aa07..f42b0c9 100644 --- a/scripts/app.js +++ b/scripts/app.js @@ -65,11 +65,13 @@ class AppKernel extends Kernel { constructor() { super() this.query = $context.query - this.setting = new Setting() - this.setting.loadConfig() - this.initSettingMethods() // FileStorage this.fileStorage = fileStorage + // setting + this.setting = new Setting({ fileStorage: this.fileStorage }) + this.setting.loadConfig() + this.initSettingMethods() + // 小组件根目录 this.widgetRootPath = widgetRootPath this.widgetDataPath = widgetDataPath From c3f632f20d0a2f7b10179646c8d842ca37fa26cd Mon Sep 17 00:00:00 2001 From: ipuppet Date: Mon, 4 Apr 2022 17:23:55 +0800 Subject: [PATCH 3/4] update --- scripts/lib/easy-jsbox.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/lib/easy-jsbox.js b/scripts/lib/easy-jsbox.js index 7b80f35..5c73793 100644 --- a/scripts/lib/easy-jsbox.js +++ b/scripts/lib/easy-jsbox.js @@ -1890,6 +1890,7 @@ class Kernel { debug(print) { this.debugMode = true + $app.idleTimerDisabled = true if (typeof print === "function") { this.debugPrint = print } From 990a017095df84f4748d5203fdfef45f762a97de Mon Sep 17 00:00:00 2001 From: ipuppet Date: Tue, 12 Apr 2022 22:42:48 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=20Join=20=E6=97=B6?= =?UTF-8?q?=E9=92=9F=20=E4=BC=98=E5=8C=96=20Join=20=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E9=A1=BA=E5=BA=8F=E5=92=8C=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC=20=E4=BC=98=E5=8C=96=20URL=20scheme=20=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.json | 2 +- scripts/app.js | 14 +++++++------- scripts/ui/home.js | 18 ++++++++---------- scripts/widget/Join/index.js | 8 ++++++-- scripts/widget/Join/setting.js | 4 +++- scripts/widget/TextClock/index.js | 12 ++++++++---- 6 files changed, 33 insertions(+), 25 deletions(-) diff --git a/config.json b/config.json index f7b1863..3ec8cd4 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,7 @@ { "info": { "name": "WAIO", - "version": "1.6.3", + "version": "1.6.4", "author": "ipuppet", "module": false }, diff --git a/scripts/app.js b/scripts/app.js index f42b0c9..83e88cd 100644 --- a/scripts/app.js +++ b/scripts/app.js @@ -64,7 +64,6 @@ function widgetInstance(widget, that) { class AppKernel extends Kernel { constructor() { super() - this.query = $context.query // FileStorage this.fileStorage = fileStorage // setting @@ -78,11 +77,6 @@ class AppKernel extends Kernel { // backup this.backupPath = backupPath this.initComponents() - // 检查是否携带URL scheme - if (this.query["url-scheme"]) { - // 延时500ms后跳转 - setTimeout(() => { $app.openURL(this.query["url-scheme"]) }, 500) - } } initComponents() { @@ -304,6 +298,12 @@ class WidgetKernel extends Kernel { class AppUI { static renderMainUI() { + // 检查是否携带 URL scheme + if ($context.query["url-scheme"]) { + $delay(0, () => { $app.openURL($context.query["url-scheme"]) }) + return + } + const kernel = new AppKernel() const buttons = { home: { @@ -406,7 +406,7 @@ module.exports = { run: () => { if ($app.env === $env.widget) { Widget.render() - } else if ($app.env === $env.app || $app.env === $env.today) { + } else if ($app.env === $env.app) { AppUI.renderMainUI() } else { AppUI.renderUnsupported() diff --git a/scripts/ui/home.js b/scripts/ui/home.js index 061d972..b7ab9b3 100644 --- a/scripts/ui/home.js +++ b/scripts/ui/home.js @@ -9,16 +9,14 @@ class HomeUI { constructor(kernel) { this.kernel = kernel this.viewController = new ViewController() - // 检查是否携带widget参数,携带则打开设置页面 - if (this.kernel.query["widget"]) { - setTimeout(() => { - const widget = this.kernel.widgetInstance(this.kernel.query["widget"]) + // 检查是否携带 widget 参数,携带则打开设置页面 + if ($context.query["widget"]) { + $delay(0.5, () => { + const widget = this.kernel.widgetInstance($context.query["widget"]) if (widget) { widget.custom() - // 清空参数 - this.kernel.query["widget"] = undefined } - }, 500) + }) } } @@ -26,7 +24,7 @@ class HomeUI { const data = this.kernel.getWidgetList() const template = data => { return { - icon: {// 如果不设置image属性,默认为小组件目录下的icon.png + icon: {// 如果不设置 image 属性,默认为小组件目录下的 icon.png image: $image(data.icon[0], data.icon[1]) }, title: { @@ -61,7 +59,7 @@ class HomeUI { src: fromPath, dst: newPath }) - // 更新设置文件中的NAME常量 + // 更新设置文件中的 NAME 常量 let settingjs = $file.read(`${newPath}/setting.js`).string const firstLine = `const NAME = "${from}"` const newFirstLine = `const NAME = "${newName}"` @@ -70,7 +68,7 @@ class HomeUI { data: $data({ string: settingjs }), path: `${newPath}/setting.js` }) - // 更新config.json + // 更新 config.json const config = JSON.parse($file.read(`${newPath}/config.json`).string) if (config.from === undefined) config.from = from config.name = newName diff --git a/scripts/widget/Join/index.js b/scripts/widget/Join/index.js index ba52d4d..5611a6d 100644 --- a/scripts/widget/Join/index.js +++ b/scripts/widget/Join/index.js @@ -27,11 +27,15 @@ class JoinWidget extends Widget { const height = $widget.displaySize.height // 调节宽度并裁剪多余部分 if (!leftView.props.frame) leftView.props.frame = {} - leftView.props.frame["maxWidth"] = width + if (leftView.props.frame["maxWidth"] > width) { + leftView.props.frame["maxWidth"] = width + } leftView.props["clipped"] = true leftView.widgetURL = undefined if (!rightView.props.frame) rightView.props.frame = {} - rightView.props.frame["maxWidth"] = width + if (rightView.props.frame["maxWidth"] > width) { + rightView.props.frame["maxWidth"] = width + } rightView.props["clipped"] = true rightView.widgetURL = undefined return { diff --git a/scripts/widget/Join/setting.js b/scripts/widget/Join/setting.js index de3c56a..8fae7d5 100644 --- a/scripts/widget/Join/setting.js +++ b/scripts/widget/Join/setting.js @@ -12,9 +12,11 @@ class JoinSetting extends BaseSetting { const data = this.kernel.getWidgetList() const result = [] data.forEach(item => { - if (item.name !== NAME) + if (item.name !== NAME && item.name !== "Calendar") result.push(item.name) }) + // "Calendar" 作为默认值,永远排在最前面 + result.unshift("Calendar") return result })() diff --git a/scripts/widget/TextClock/index.js b/scripts/widget/TextClock/index.js index 24b4d2b..6779bba 100644 --- a/scripts/widget/TextClock/index.js +++ b/scripts/widget/TextClock/index.js @@ -12,7 +12,7 @@ class TextClockWidget extends Widget { this.oneDayInMillis = 60 * 60 * 24 * 1000 } - view2x2(ctx) { + view2x2() { return { type: "text", props: { @@ -24,7 +24,7 @@ class TextClockWidget extends Widget { monospaced: true }, frame: { - maxWidth: ctx.displaySize.width - 30 + maxWidth: $widget.displaySize.width - 30 }, lineLimit: 1, minimumScaleFactor: 0.01 @@ -32,13 +32,17 @@ class TextClockWidget extends Widget { } } + joinView() { + return this.view2x2() + } + render() { $widget.setTimeline({ policy: { afterDate: new Date(this.midnight.getTime() + this.oneDayInMillis) }, - render: ctx => { - const view = this.view2x2(ctx) + render: () => { + const view = this.view2x2() this.printTimeConsuming() return view }