@@ -538,6 +538,7 @@ window.addEventListener("load", ()=>{
538538 setupBackToTop ( ) ;
539539 setupFadeInAnimations ( ) ;
540540 setupActiveNav ( ) ;
541+ setupVisitorCounter ( ) ;
541542} ) ;
542543
543544/* ===== Hero video interactions ===== */
@@ -1080,4 +1081,94 @@ function setupFadeInAnimations(){
10801081 } ) ;
10811082
10821083 elements . forEach ( el => observer . observe ( el ) ) ;
1084+ }
1085+
1086+ /* ===== Busuanzi Visitor Counter (Owner Only) ===== */
1087+ function setupVisitorCounter ( ) {
1088+ const OWNER_PASSWORD = "rise123" ; // 修改为你自己的密码
1089+
1090+ // 创建统计面板
1091+ function createStatsPanel ( ) {
1092+ const panel = document . createElement ( 'div' ) ;
1093+ panel . id = 'visitorStatsPanel' ;
1094+ panel . style . cssText = `
1095+ position: fixed;
1096+ bottom: 20px;
1097+ right: 20px;
1098+ background: white;
1099+ border: 2px solid #5b7cfa;
1100+ border-radius: 12px;
1101+ padding: 20px;
1102+ max-width: 350px;
1103+ box-shadow: 0 4px 20px rgba(0,0,0,0.2);
1104+ z-index: 9999;
1105+ font-family: system-ui, -apple-system, Segoe UI;
1106+ font-size: 14px;
1107+ display: none;
1108+ ` ;
1109+ panel . innerHTML = `
1110+ <div style="margin-bottom: 16px; font-weight: 700; font-size: 16px; color: #5b7cfa; border-bottom: 2px solid #e6e6e6; padding-bottom: 10px;">📊 访客统计(不蒜子)</div>
1111+ <div style="margin-bottom: 8px; color: #333; line-height: 1.8;">
1112+ <div style="margin-bottom: 8px; display: flex; justify-content: space-between;">
1113+ <span>🌐 本站总访问量:</span>
1114+ <strong style="color: #5b7cfa;"><span id="busuanzi_value_site_pv">--</span> 次</strong>
1115+ </div>
1116+ <div style="margin-bottom: 8px; display: flex; justify-content: space-between;">
1117+ <span>👥 本站访客数:</span>
1118+ <strong style="color: #5b7cfa;"><span id="busuanzi_value_site_uv">--</span> 人</strong>
1119+ </div>
1120+ <div style="margin-bottom: 8px; display: flex; justify-content: space-between;">
1121+ <span>📄 本页访问量:</span>
1122+ <strong style="color: #5b7cfa;"><span id="busuanzi_value_page_pv">--</span> 次</strong>
1123+ </div>
1124+ </div>
1125+ <div style="margin-top: 12px; padding-top: 12px; border-top: 1px solid #e6e6e6; font-size: 12px; color: #999;">
1126+ 统计数据由 <a href="http://busuanzi.ibruce.info/" target="_blank" style="color: #5b7cfa;">不蒜子</a> 提供
1127+ </div>
1128+ <button id="closeStats" style="width: 100%; padding: 10px; margin-top: 12px; background: #5b7cfa; color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600;">关闭</button>
1129+ ` ;
1130+ document . body . appendChild ( panel ) ;
1131+
1132+ // 关闭按钮
1133+ document . getElementById ( 'closeStats' ) . addEventListener ( 'click' , ( ) => {
1134+ panel . style . display = 'none' ;
1135+ } ) ;
1136+
1137+ return panel ;
1138+ }
1139+
1140+ // 打开统计面板(需要密码)
1141+ function showStatsPanel ( ) {
1142+ const pwd = prompt ( '请输入访客统计密码:' ) ;
1143+ if ( pwd === OWNER_PASSWORD ) {
1144+ const panel = document . getElementById ( 'visitorStatsPanel' ) || createStatsPanel ( ) ;
1145+ panel . style . display = 'block' ;
1146+
1147+ // 等待不蒜子数据加载
1148+ setTimeout ( ( ) => {
1149+ const pv = document . getElementById ( 'busuanzi_value_site_pv' ) ;
1150+ if ( pv && pv . textContent === '--' ) {
1151+ pv . textContent = '加载中...' ;
1152+ }
1153+ } , 500 ) ;
1154+ } else if ( pwd !== null ) {
1155+ alert ( '密码错误!' ) ;
1156+ }
1157+ }
1158+
1159+ window . showStatsPanel = showStatsPanel ;
1160+
1161+ // 绑定按钮
1162+ const statsBtn = document . getElementById ( 'statsBtn' ) ;
1163+ if ( statsBtn ) {
1164+ statsBtn . addEventListener ( 'click' , showStatsPanel ) ;
1165+ }
1166+
1167+ // 添加快捷键:Ctrl+Shift+S 打开统计
1168+ document . addEventListener ( 'keydown' , ( e ) => {
1169+ if ( e . ctrlKey && e . shiftKey && e . code === 'KeyS' ) {
1170+ e . preventDefault ( ) ;
1171+ showStatsPanel ( ) ;
1172+ }
1173+ } ) ;
10831174}
0 commit comments