@@ -5,18 +5,18 @@ document.addEventListener('DOMContentLoaded', function() {
55 initialView : 'dayGridMonth' ,
66 validRange : function ( nowDate ) {
77 let endDate = new Date ( ) ;
8- endDate . setDate ( endDate . getDate ( ) + 6 ) ;
8+ endDate . setDate ( endDate . getDate ( ) + 7 ) ;
99 return {
1010 start : '2025-09-01' ,
1111 end : endDate
12- } ; // 可预览未来6天的事件
12+ } ; // 可预览未来7天的事件
1313 } ,
1414 headerToolbar : {
1515 left : 'prev,next today' ,
1616 center : 'title' ,
1717 right : 'dayGridMonth'
1818 } ,
19- events : './data/schedule .json' , // 加载 WP JSON 数据
19+ events : './data/calendar .json' , // 加载 WP JSON 数据
2020 eventContent : function ( arg ) {
2121 // 自定义事件显示样式
2222 let color = '#fff' ; // 默认白色
@@ -29,44 +29,50 @@ document.addEventListener('DOMContentLoaded', function() {
2929 return { html : `<div style="color:${ color } ; font-weight:bold">${ arg . event . title + " " + type } </div>` } ;
3030 } ,
3131 eventDidMount : function ( info ) {
32- // 根据状态修改整个事件块样式
33- let status = info . event . extendedProps . status ;
34- let color , textColor ;
35- if ( ! info . event . extendedProps . desc ) {
36- if ( status === 'done' ) {
37- // color = '#4CAF50';
38- color = '#4ecd7cff' ; // 亮绿色
39- textColor = '#fff' ;
40- } else if ( status === 'pending' ) {
41- const tomorrow = new Date ( ) ;
42- tomorrow . setHours ( 0 , 0 , 0 , 0 ) ;
43- tomorrow . setDate ( tomorrow . getDate ( ) + 1 ) ;
44- if ( info . event . start < tomorrow ) {
45- color = '#dc2626' ; // 暗红
46- textColor = '#fff' ;
47- } else {
48- color = '#9ca3af' ; // 灰色
49- textColor = '#fff' ;
50- }
51- } else {
52- color = '#9ca3af' ; // 灰色
53- textColor = '#fff' ;
54- }
55- } else {
56- // 如果有 type 字段,表示是节假日或特殊事件
57- color = '#fbbf24' ; // 黄色
58- textColor = '#000' ;
59- }
60- let title = info . event . extendedProps . desc ? info . event . extendedProps . desc : ( info . event . url ? info . event . url : "wp" ) ;
61- // 鼠标悬浮显示完整标题
62- info . el . title = title ;
63- info . el . style . backgroundColor = color ;
64- info . el . style . borderColor = color ;
65- info . el . style . color = textColor ;
66- info . el . style . borderRadius = '4px' ;
67- info . el . style . fontWeight = 'bold' ;
68- info . el . style . padding = '2px 4px' ;
69- info . el . style . cursor = 'pointer' ; // 提示可点击
32+ let status = info . event . extendedProps . status ;
33+ let color , textColor ;
34+
35+ // 从 url 中提取方向
36+ let url = info . event . url || "" ;
37+ let direction = url . split ( "/" ) [ 0 ] . toLowerCase ( ) ; // web/misc/pwn/...
38+
39+ // 定义方向对应的颜色
40+ const directionColors = {
41+ web : '#3498db' , // 蓝
42+ misc : '#9b59b6' , // 紫
43+ pwn : '#e74c3c' , // 红
44+ reverse :'#27ae60' , // 绿
45+ crypto : '#34495e' , // 深灰蓝
46+ ai : '#e67e22' // 橙
47+ } ;
48+
49+ if ( ! info . event . extendedProps . desc ) {
50+ if ( directionColors [ direction ] ) {
51+ // 如果有方向,就按方向颜色
52+ color = directionColors [ direction ] ;
53+ // 让文字颜色自动根据背景深浅决定
54+ textColor = ( direction === 'crypto' ) ? '#000' : '#fff' ;
55+ } else {
56+ // 默认灰
57+ color = '#9ca3af' ;
58+ textColor = '#fff' ;
59+ }
60+ } else {
61+ // 有 desc = 特殊事件
62+ color = '#f1c40f' ; // 亮黄色(特殊事件)
63+ textColor = '#fff' ;
64+ }
65+
66+ let title = info . event . extendedProps . desc ? info . event . extendedProps . desc : ( info . event . url ? info . event . url : "wp" ) ;
67+ // 鼠标悬浮显示完整标题
68+ info . el . title = title ;
69+ info . el . style . backgroundColor = color ;
70+ info . el . style . borderColor = color ;
71+ info . el . style . color = textColor ;
72+ info . el . style . borderRadius = '4px' ;
73+ info . el . style . fontWeight = 'bold' ;
74+ info . el . style . padding = '2px 4px' ;
75+ info . el . style . cursor = 'pointer' ;
7076 } ,
7177 // 点击事件跳转
7278 eventClick : function ( info ) {
0 commit comments