55// 添加require,是为了vscode中可以正确引入包,以获得自动补全等功能
66if ( typeof require === "undefined" ) require = importModule ;
77const { 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// @组件代码开始
1715class 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