Skip to content

Commit 8235f04

Browse files
author
dompling
committed
update
1 parent edb1d0b commit 8235f04

File tree

2 files changed

+39
-14
lines changed

2 files changed

+39
-14
lines changed

Scripts/DmYY.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2074,8 +2074,8 @@ const Runing = async (Widget, default_args = "", isDebug = true, extra) => {
20742074
const menuConfig = [
20752075
...(preview ? [{ title: "预览组件", menu: preview }] : []),
20762076
...(lockView.length ? [{ title: "锁屏组件", menu: lockView }] : []),
2077-
{ title: "组件配置", menu: actions },
20782077
...M["_menuActions"],
2078+
{ title: "组件配置", menu: actions },
20792079
];
20802080
await M.renderAppView(menuConfig, true);
20812081
}

Scripts/birthday.js

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
// 添加require,是为了vscode中可以正确引入包,以获得自动补全等功能
66
if (typeof require === "undefined") require = importModule;
77
const { DmYY, Runing } = require("./DmYY");
8-
const mainTextSize = 13; // 倒数、农历、生日文字大小
9-
const now = new Date();
10-
const today = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`;
8+
let mainTextSize = 13; // 倒数、农历、生日文字大小
119

12-
const widthMode = Device.model() === "iPad" ? 110 : 400; // 中号组件图片尺寸
10+
let widthMode = 110; // 中号组件图片尺寸
1311

14-
const heightMode = Device.model() === "iPad" ? 100 : 380; // 中号组件图片尺寸
12+
let heightMode = 100; // 中号组件图片尺寸
1513

1614
// @组件代码开始
1715
class Widget extends DmYY {
@@ -23,11 +21,35 @@ class Widget extends DmYY {
2321

2422
if (config.runsInApp) {
2523
this.registerAction({
26-
icon: { name: "person.badge.plus", color: "#52c41a" },
27-
type: "img",
28-
title: "头像",
29-
name: "avatar",
30-
val: this.cacheImage,
24+
title: "头像设置",
25+
menu: [
26+
{
27+
icon: { name: "person.badge.plus", color: "#52c41a" },
28+
type: "img",
29+
title: "头像",
30+
name: "avatar",
31+
val: this.cacheImage,
32+
},
33+
{
34+
icon: { name: "arrow.left.and.right", color: "#13c2c2" },
35+
type: "input",
36+
title: "头像宽度",
37+
name: "avatarWidth",
38+
},
39+
{
40+
icon: { name: "arrow.up.and.down", color: "#1890ff" },
41+
type: "input",
42+
title: "头像高度",
43+
name: "avatarHeight",
44+
},
45+
],
46+
});
47+
48+
this.registerAction({
49+
icon: { name: "a.square", color: "#eb2f96" },
50+
type: "input",
51+
title: "主文字大小",
52+
name: "mainTextSize",
3153
});
3254

3355
this.registerAction({
@@ -281,6 +303,10 @@ class Widget extends DmYY {
281303
};
282304

283305
init = async () => {
306+
widthMode = this.settings.avatarWidth || widthMode;
307+
heightMode = this.settings.avatarHeight || heightMode;
308+
mainTextSize = this.settings.mainTextSize || mainTextSize;
309+
284310
await this.FILE_MGR.fileExistsExtra(this.LEFT_IMG_KEY);
285311
this.defaultData = {
286312
username: this.settings.nickname || "", // 姓名
@@ -301,12 +327,11 @@ class Widget extends DmYY {
301327
nongli,
302328
isLeapMonth,
303329
};
304-
330+
305331
if (this.settings.ajax) {
306332
this.ajax(opt).then((res) => {
307333
this.settings.ajax = res;
308334
this.saveSettings(false);
309-
310335
});
311336
} else {
312337
this.settings.ajax = await this.ajax(opt);
@@ -337,7 +362,7 @@ class Widget extends DmYY {
337362
.replace("年", "-")
338363
.replace("月", "-")
339364
.replace("日", "");
340-
365+
341366
const tmpBirth = this.getAge(this.defaultData.time);
342367
let ageYear = tmpBirth.year > 0 ? `${tmpBirth.year}岁` : "";
343368
let ageMonth = tmpBirth.month > 0 ? `${tmpBirth.month}月` : "";

0 commit comments

Comments
 (0)