@showlotus/open-scriptable 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/count-down.js +1 -1
- package/dist/hello-world.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,10 @@ const code = await new Request(url).loadString();
|
|
|
14
14
|
eval(code);
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
<
|
|
17
|
+
<div>
|
|
18
|
+
<img src="./res/hello-world/light.png" alt="light" width="300">
|
|
19
|
+
<img src="./res/hello-world/dark.jpeg" alt="dark" width="300">
|
|
20
|
+
</div>
|
|
18
21
|
|
|
19
22
|
## 组件列表
|
|
20
23
|
|
package/dist/count-down.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let t;t=config.runsInWidget
|
|
1
|
+
!function(){let t;t=config.runsInWidget?config.widgetFamily||"small":"medium";const e={small:3,medium:3,large:7}[t],n=new ListWidget;n.backgroundColor=Color.dynamic(new Color("#FFFFFF"),new Color("#1c1c1c")),n.spacing=8;const o=Object.entries(function(t,e=""){try{return __GLOBAL_CONFIG__[t]}catch(n){return e}}("days",{})||{}).map(([t,e])=>({name:t,date:e})).sort((t,e)=>t.date>e.date?1:-1).filter(t=>{const[e,n,o]=t.date.split("-").map(Number),a=new Date;return e>a.getFullYear()||e===a.getFullYear()&&(n>a.getMonth()+1||n===a.getMonth()+1&&o>=a.getDate())}).slice(0,e);if(o.length<e)for(let a=o.length;a<e;a++)o.push({name:"",date:"",isEmpty:!0});o.forEach((e,a)=>{const l=n.addStack();l.layoutHorizontally();const r=l.addStack();r.layoutVertically(),r.spacing=1;const c=r.addStack();c.layoutHorizontally(),c.spacing=2;const i=c.addText(e.name);i.font=Font.mediumRoundedSystemFont(14),i.textColor=Color.dynamic(new Color("#000000"),new Color("#FFFFFF"));const d=r.addStack();d.layoutHorizontally(),d.spacing=2;const s=e.isEmpty?null:function(t){try{const[e,n,o]=t.split("-").map(Number);return new Date(e,n-1,o)}catch(e){return null}}(e.date),g=d.addText(e.isEmpty?" ":function(e){const n=["周日","周一","周二","周三","周四","周五","周六"][e.getDay()],o=(e.getMonth()+1).toString().padStart(2,"0"),a=e.getDate().toString().padStart(2,"0");return`${e.getFullYear()}/${o}/${a}${"small"===t?"":`, ${n}`}`}(s));g.font=Font.regularRoundedSystemFont(10),g.textColor=Color.dynamic(new Color("#979797"),new Color("#8e8e8e")),l.addSpacer();const m=l.addStack();m.layoutHorizontally(),m.bottomAlignContent(),m.spacing=2;const u=e.isEmpty?" ":function(t){const e=new Date;e.setHours(0,0,0,0);const n=t.getTime()-e.getTime();return Math.floor(n/864e5)}(s),y=m.addStack();y.spacing=2,y.topAlignContent();const F=y.addText(u.toString());F.font=Font.mediumRoundedSystemFont(24),F.textColor=Color.dynamic(new Color("#000000"),new Color("#FFFFFF")),F.rightAlignText();const p=m.addStack();if(p.setPadding(0,0,4,0),!e.isEmpty){const t=p.addText("天");t.font=Font.boldRoundedSystemFont(10),t.textColor=Color.dynamic(new Color("#979797"),new Color("#8e8e8e")),t.rightAlignText()}if(a<o.length-1){const e=n.addStack();e.layoutHorizontally(),e.centerAlignContent();const o="small"===t?126:305,a=1,l=new DrawContext;l.size=new Size(o,a),l.opaque=!1,l.respectScreenScale=!0,l.setFillColor(Color.dynamic(new Color("#E5E5E5"),new Color("#333333")));const r=new Path;r.addRoundedRect(new Rect(0,0,o,a),a/2,a/2),l.addPath(r),l.fillPath();e.addImage(l.getImage()).centerAlignImage()}}),config.runsInWidget?Script.setWidget(n):config.runsInApp&&("small"===t?n.presentSmall():"medium"===t?n.presentMedium():"large"===t&&n.presentLarge()),Script.complete()}();
|
package/dist/hello-world.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let
|
|
1
|
+
!function(){let o;o=config.runsInWidget&&config.widgetFamily||"small";const n=new ListWidget;n.backgroundColor=Color.dynamic(new Color("#FFFFFF"),new Color("#1c1c1c"));const e=n.addText(`Hello, ${function(o,n=""){try{return __GLOBAL_CONFIG__[o]}catch(e){return n}}("name","World")}`);e.textColor=Color.dynamic(new Color("#000000"),new Color("#FFFFFF")),e.font=Font.boldSystemFont(16),e.centerAlignText(),console.log("config:"),console.log(JSON.stringify(config,null,2)),config.runsInWidget?Script.setWidget(n):"small"===o?n.presentSmall():"medium"===o?n.presentMedium():"large"===o&&n.presentLarge(),Script.complete()}();
|