Skip to content

Commit 327a5fa

Browse files
committed
feat(wsgw): 主题文字缩放
1 parent 9c7c105 commit 327a5fa

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

Scripts/wsgw.js

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,18 @@ class Widget extends DmYY {
5555
placeholder: '3',
5656
val: 'cacheTime',
5757
});
58+
59+
this.registerAction({
60+
icon: { name: 'character.cursor.ibeam', color: '#EC6240' },
61+
type: 'input',
62+
title: '文字缩放',
63+
desc: '文字缩放比例,值为 0-1',
64+
placeholder: '1',
65+
val: 'scale',
66+
});
67+
5868
this.registerAction('基础设置', this.setWidgetConfig);
5969
}
60-
this.cacheTime = (this.settings.cacheTime || 3) * 3600000;
6170
}
6271

6372
date = new Date();
@@ -67,6 +76,8 @@ class Widget extends DmYY {
6776

6877
init = async () => {
6978
console.log(`当前用户下标:${this.userNum}`);
79+
this.cacheTime = (this.settings.cacheTime || 3) * 3600000;
80+
this.scale = parseFloat(this.settings.scale || '1');
7081
if (
7182
!this.settings.data ||
7283
this.settings.cacheDay + this.cacheTime < this.day
@@ -228,7 +239,11 @@ class Widget extends DmYY {
228239
}
229240

230241
createLeft = async (widget) => {
231-
const fontStyle = { color: new Color('#fff'), size: 20, opacity: 0.8 };
242+
const fontStyle = {
243+
color: new Color('#fff'),
244+
size: 20 * this.scale,
245+
opacity: 0.8,
246+
};
232247
const leftStack = widget.addStack();
233248
leftStack.cornerRadius = 10;
234249
leftStack.layoutVertically();
@@ -255,7 +270,7 @@ class Widget extends DmYY {
255270
if (this.dataSource.left.arrearsOfFees)
256271
fontStyle.color = new Color('#f65755');
257272

258-
fontStyle.size = 20;
273+
fontStyle.size = 20 * this.scale;
259274
this.provideText('¥ ', todayStack, fontStyle);
260275

261276
fontStyle.opacity = 1;
@@ -281,24 +296,28 @@ class Widget extends DmYY {
281296
cellStack.cornerRadius = 10;
282297
cellStack.layoutVertically();
283298

284-
const fontStyle = { color: new Color('#fff'), size: 14, opacity: 0.6 };
299+
const fontStyle = {
300+
color: new Color('#fff'),
301+
size: 14 * this.scale,
302+
opacity: 0.6,
303+
};
285304
this.provideText(data.title, cellStack, fontStyle);
286305

287306
const dataStack = cellStack.addStack();
288307
dataStack.bottomAlignContent();
289308

290-
fontStyle.size = 12;
309+
fontStyle.size = 12 * this.scale;
291310
this.provideText('¥ ', dataStack, fontStyle);
292311

293312
fontStyle.opacity = 1;
294-
fontStyle.size = 20;
313+
fontStyle.size = 20 * this.scale;
295314
this.provideText(` ${data.num.toLocaleString()}`, dataStack, fontStyle);
296315
dataStack.addSpacer();
297316

298317
const dotStack = dataStack.addStack();
299318
this.createDot(dotStack, data.radio > 0 ? '#7EEF8F' : '#ED86A5');
300319

301-
fontStyle.size = 12;
320+
fontStyle.size = 12 * this.scale;
302321
this.provideText(
303322
data.radio > 0 ? ` +${data.radio}%` : ` -${Math.abs(data.radio)}%`,
304323
dataStack,

install.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@
511511
]
512512
},
513513
{
514-
"version": "1.0.1",
514+
"version": "1.0.2",
515515
"description": "网上国网",
516516
"scriptURL": "https://raw.githubusercontent.com/dompling/Scriptable/master/Scripts/wsgw.js",
517517
"thumb": "https://is1-ssl.mzstatic.com/image/thumb/Purple116/v4/83/d8/8a/83d88a92-5a4d-7a2f-118c-80d795e7a9f6/AppIcon-0-0-1x_U007emarketing-0-5-0-0-sRGB-85-220.png/144x144.png",

0 commit comments

Comments
 (0)