@@ -11,8 +11,6 @@ import {
1111 showPreviewOptions ,
1212 useStorage ,
1313} from '@app/lib/help'
14- import { Col } from '@app/lib/components'
15- import { WstackProps } from '@app/types/widget'
1614import { FC } from 'react'
1715
1816/**榜单信息*/
@@ -178,7 +176,7 @@ const topList: TopInfo[] = [
178176const { setStorage, getStorage} = useStorage ( 'newsTop-xiaoming' )
179177
180178/**文字颜色*/
181- const textColor = getStorage < string > ( 'textColor' ) || '#222222 '
179+ const textColor = getStorage < string > ( 'textColor' ) || '#000000 '
182180
183181/**透明背景*/
184182const transparentBg : Image | string = getStorage < Image > ( 'transparentBg' ) || '#ffffff'
@@ -211,13 +209,17 @@ const colors = {
211209const Article : FC < { article : ArticleInfo ; sort : number } > = ( { article, sort} ) => {
212210 return (
213211 < >
214- < wspacer length = { 5 } > </ wspacer >
212+ { sort > 1 && < wspacer length = { 8 } > </ wspacer > }
215213 < wstack verticalAlign = "center" href = { article . href } >
216- < wtext maxLine = { 1 } font = { Font . lightSystemFont ( 14 ) } >
217- { sort } 、{ article . title }
214+ < wtext font = { Font . heavySystemFont ( 14 ) } textColor = { textColor } >
215+ { sort }
216+ </ wtext >
217+ < wspacer length = { 8 } > </ wspacer >
218+ < wtext maxLine = { 1 } font = { Font . lightSystemFont ( 14 ) } textColor = { textColor } >
219+ { article . title }
218220 </ wtext >
219221 < wspacer > </ wspacer >
220- < wtext maxLine = { 1 } font = { Font . lightSystemFont ( 12 ) } opacity = { 0.6 } >
222+ < wtext maxLine = { 1 } font = { Font . lightSystemFont ( 12 ) } opacity = { 0.6 } textColor = { textColor } >
221223 { article . hot }
222224 </ wtext >
223225 </ wstack >
@@ -249,21 +251,25 @@ class NewsTop {
249251 const updateInterval = 1 * 60 * 60 * 1000
250252 // 渲染尺寸
251253 const size = config . widgetFamily
254+
252255 return (
253256 < wbox
254257 padding = { [ 0 , 0 , 0 , 0 ] }
255258 updateDate = { new Date ( Date . now ( ) + updateInterval ) }
256259 background = { boxBg . match ( '透明背景' ) ? transparentBg : boxBg }
260+ href = { size === 'small' ? articleList [ 0 ] && articleList [ 0 ] . href : '' }
257261 >
258- < wstack flexDirection = "column" padding = { [ 16 , 16 , 16 , 16 ] } >
262+ < wstack flexDirection = "column" padding = { [ 0 , 16 , 0 , 16 ] } >
263+ < wspacer length = { 16 } > </ wspacer >
259264 { /* 标题和logo */ }
260265 < wstack verticalAlign = "center" >
261- < wimage src = { logo } width = { 14 } height = { 14 } borderRadius = { 4 } > </ wimage >
262- < wspacer length = { 10 } > </ wspacer >
263- < wtext opacity = { 0.7 } font = { Font . boldSystemFont ( 12 ) } >
264- { title }
266+ < wimage src = { logo } width = { 20 } height = { 20 } borderRadius = { 4 } > </ wimage >
267+ < wspacer length = { 8 } > </ wspacer >
268+ < wtext opacity = { 0.7 } font = { Font . boldSystemFont ( 16 ) } textColor = { textColor } >
269+ { title } 排行榜
265270 </ wtext >
266271 </ wstack >
272+ < wspacer length = { 16 } > </ wspacer >
267273 { /* 内容 */ }
268274 { size === 'small' && this . renderSmall ( articleList ) }
269275 { size === 'medium' && this . renderMedium ( articleList ) }
@@ -275,12 +281,27 @@ class NewsTop {
275281
276282 // 渲染小尺寸
277283 renderSmall ( articleList : ArticleInfo [ ] ) {
278- return < wstack flexDirection = "column" > </ wstack >
284+ const article = articleList [ 0 ]
285+ return (
286+ < wstack flexDirection = "column" >
287+ < wtext font = { Font . lightSystemFont ( 14 ) } textColor = { textColor } >
288+ { article . title }
289+ </ wtext >
290+ < wspacer > </ wspacer >
291+ < wstack >
292+ < wspacer > </ wspacer >
293+ < wtext maxLine = { 1 } font = { Font . lightSystemFont ( 12 ) } opacity = { 0.6 } textColor = { textColor } >
294+ { article . hot }
295+ </ wtext >
296+ </ wstack >
297+ < wspacer length = { 16 } > </ wspacer >
298+ </ wstack >
299+ )
279300 }
280301
281302 // 渲染中尺寸
282303 renderMedium ( articleList : ArticleInfo [ ] ) {
283- const _articleList = articleList . slice ( 0 , 5 )
304+ const _articleList = articleList . slice ( 0 , 4 )
284305 return (
285306 < wstack flexDirection = "column" >
286307 { _articleList . map ( ( article , index ) => (
@@ -293,7 +314,7 @@ class NewsTop {
293314
294315 // 渲染大尺寸
295316 renderLarge ( articleList : ArticleInfo [ ] ) {
296- const _articleList = articleList . slice ( 0 , 10 )
317+ const _articleList = articleList . slice ( 0 , 12 )
297318 return (
298319 < wstack flexDirection = "column" >
299320 { _articleList . map ( ( article , index ) => (
@@ -308,17 +329,25 @@ class NewsTop {
308329 async showMenu ( ) {
309330 const selectIndex = await showActionSheet ( {
310331 title : '菜单' ,
311- itemList : [ '设置颜色' , '设置透明背景' , '预览组件' ] ,
332+ itemList : [ '使用其他排行榜' , ' 设置颜色', '设置透明背景' , '预览组件' ] ,
312333 } )
313334 switch ( selectIndex ) {
314335 case 0 :
336+ showModal ( {
337+ title : '使用其他排行榜方法' ,
338+ content : `把小部件添加到桌面后,长按编辑小部件,在 Parameter 栏输入以下任一关键词即可:\n\n${ topList
339+ . map ( top => top . title )
340+ . join ( '、' ) } `,
341+ } )
342+ break
343+ case 1 :
315344 const { texts, cancel} = await showModal ( {
316345 title : '设置全局背景和颜色' ,
317346 content : '如果为空,则还原默认' ,
318347 inputItems : [
319348 {
320349 text : getStorage < string > ( 'boxBg' ) || '' ,
321- placeholder : '这里填全局背景, 可以是颜色、图片链接 ' ,
350+ placeholder : '全局背景: 可以是颜色、图链接 ' ,
322351 } ,
323352 {
324353 text : getStorage < string > ( 'textColor' ) || '' ,
@@ -331,15 +360,15 @@ class NewsTop {
331360 setStorage ( 'textColor' , texts [ 1 ] )
332361 await showNotification ( { title : '设置完成' , sound : 'default' } )
333362 break
334- case 1 :
363+ case 2 :
335364 const img : Image | null = ( await setTransparentBackground ( ) ) || null
336365 if ( img ) {
337366 setStorage ( 'transparentBg' , img )
338367 setStorage ( 'boxBg' , '透明背景' )
339368 await showNotification ( { title : '设置透明背景成功' , sound : 'default' } )
340369 }
341370 break
342- case 2 :
371+ case 3 :
343372 await showPreviewOptions ( this . render . bind ( this ) )
344373 break
345374 }
0 commit comments