Spaces:
Sleeping
Sleeping
update user/admin, update data import options
Browse files- public/test_data.json +112 -0
- src/App.css +55 -0
- src/App.jsx +189 -104
- src/components/Customise.jsx +5 -2
public/test_data.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"id": 29,
|
| 4 |
+
"start_time": "2026-03-10T19:27:26.313545",
|
| 5 |
+
"end_time": "2026-03-10T19:27:59.454192",
|
| 6 |
+
"duration_seconds": 33,
|
| 7 |
+
"focus_score": 0.8848484848484849,
|
| 8 |
+
"total_frames": 165,
|
| 9 |
+
"focused_frames": 146,
|
| 10 |
+
"created_at": "2026-03-10 19:27:26"
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"id": 27,
|
| 14 |
+
"start_time": "2026-03-10T15:09:42.264889",
|
| 15 |
+
"end_time": "2026-03-10T15:09:52.066905",
|
| 16 |
+
"duration_seconds": 9,
|
| 17 |
+
"focus_score": 0.575,
|
| 18 |
+
"total_frames": 120,
|
| 19 |
+
"focused_frames": 69,
|
| 20 |
+
"created_at": "2026-03-10 15:09:42"
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"id": 20,
|
| 24 |
+
"start_time": "2026-03-10T12:10:08.838619",
|
| 25 |
+
"end_time": "2026-03-10T12:10:22.613099",
|
| 26 |
+
"duration_seconds": 13,
|
| 27 |
+
"focus_score": 0.3076923076923077,
|
| 28 |
+
"total_frames": 65,
|
| 29 |
+
"focused_frames": 20,
|
| 30 |
+
"created_at": "2026-03-10 12:10:08"
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"id": 19,
|
| 34 |
+
"start_time": "2026-03-10T12:10:04.664410",
|
| 35 |
+
"end_time": "2026-03-10T12:21:08.528749",
|
| 36 |
+
"duration_seconds": 663,
|
| 37 |
+
"focus_score": 1,
|
| 38 |
+
"total_frames": 19,
|
| 39 |
+
"focused_frames": 19,
|
| 40 |
+
"created_at": "2026-03-10 12:10:04"
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"id": 15,
|
| 44 |
+
"start_time": "2026-03-10T12:03:07.498863",
|
| 45 |
+
"end_time": "2026-03-10T12:03:19.454642",
|
| 46 |
+
"duration_seconds": 11,
|
| 47 |
+
"focus_score": 0.896551724137931,
|
| 48 |
+
"total_frames": 58,
|
| 49 |
+
"focused_frames": 52,
|
| 50 |
+
"created_at": "2026-03-10 12:03:07"
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"id": 13,
|
| 54 |
+
"start_time": "2026-03-10T12:02:40.121044",
|
| 55 |
+
"end_time": "2026-03-10T12:03:03.700510",
|
| 56 |
+
"duration_seconds": 23,
|
| 57 |
+
"focus_score": 0.6923076923076923,
|
| 58 |
+
"total_frames": 117,
|
| 59 |
+
"focused_frames": 81,
|
| 60 |
+
"created_at": "2026-03-10 12:02:40"
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"id": 12,
|
| 64 |
+
"start_time": "2026-03-10T12:02:36.741156",
|
| 65 |
+
"end_time": "2026-03-10T12:05:59.301680",
|
| 66 |
+
"duration_seconds": 202,
|
| 67 |
+
"focus_score": 0.13333333333333333,
|
| 68 |
+
"total_frames": 15,
|
| 69 |
+
"focused_frames": 2,
|
| 70 |
+
"created_at": "2026-03-10 12:02:36"
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"id": 8,
|
| 74 |
+
"start_time": "2026-03-10T11:35:26.680264",
|
| 75 |
+
"end_time": "2026-03-10T11:36:07.574547",
|
| 76 |
+
"duration_seconds": 40,
|
| 77 |
+
"focus_score": 0.6225490196078431,
|
| 78 |
+
"total_frames": 204,
|
| 79 |
+
"focused_frames": 127,
|
| 80 |
+
"created_at": "2026-03-10 11:35:26"
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"id": 7,
|
| 84 |
+
"start_time": "2026-03-10T11:35:16.587504",
|
| 85 |
+
"end_time": "2026-03-10T12:17:35.889266",
|
| 86 |
+
"duration_seconds": 2539,
|
| 87 |
+
"focus_score": 0.9387755102040817,
|
| 88 |
+
"total_frames": 49,
|
| 89 |
+
"focused_frames": 46,
|
| 90 |
+
"created_at": "2026-03-10 11:35:16"
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"id": 4,
|
| 94 |
+
"start_time": "2026-03-10T11:16:31.204287",
|
| 95 |
+
"end_time": "2026-03-10T11:16:52.632759",
|
| 96 |
+
"duration_seconds": 21,
|
| 97 |
+
"focus_score": 0.75,
|
| 98 |
+
"total_frames": 104,
|
| 99 |
+
"focused_frames": 78,
|
| 100 |
+
"created_at": "2026-03-10 11:16:31"
|
| 101 |
+
},
|
| 102 |
+
{
|
| 103 |
+
"id": 2,
|
| 104 |
+
"start_time": "2026-03-10T11:15:37.543154",
|
| 105 |
+
"end_time": "2026-03-10T11:17:41.674593",
|
| 106 |
+
"duration_seconds": 124,
|
| 107 |
+
"focus_score": 0.9557522123893806,
|
| 108 |
+
"total_frames": 113,
|
| 109 |
+
"focused_frames": 108,
|
| 110 |
+
"created_at": "2026-03-10 11:15:37"
|
| 111 |
+
}
|
| 112 |
+
]
|
src/App.css
CHANGED
|
@@ -797,3 +797,58 @@ details p {
|
|
| 797 |
from { opacity: 0; transform: scale(0.95); }
|
| 798 |
to { opacity: 1; transform: scale(1); }
|
| 799 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 797 |
from { opacity: 0; transform: scale(0.95); }
|
| 798 |
to { opacity: 1; transform: scale(1); }
|
| 799 |
}
|
| 800 |
+
|
| 801 |
+
/* ================= 迎宾弹窗样式 ================= */
|
| 802 |
+
.welcome-modal-overlay {
|
| 803 |
+
position: fixed;
|
| 804 |
+
top: 0; left: 0; right: 0; bottom: 0;
|
| 805 |
+
background-color: rgba(0, 0, 0, 0.7);
|
| 806 |
+
display: flex;
|
| 807 |
+
justify-content: center;
|
| 808 |
+
align-items: center;
|
| 809 |
+
z-index: 9999;
|
| 810 |
+
}
|
| 811 |
+
|
| 812 |
+
.welcome-modal {
|
| 813 |
+
background-color: #1e1e24;
|
| 814 |
+
padding: 40px;
|
| 815 |
+
border-radius: 15px;
|
| 816 |
+
text-align: center;
|
| 817 |
+
box-shadow: 0 10px 30px rgba(0,0,0,0.5);
|
| 818 |
+
border: 1px solid #333;
|
| 819 |
+
}
|
| 820 |
+
|
| 821 |
+
.welcome-modal h2 { margin-top: 0; color: #fff; }
|
| 822 |
+
.welcome-modal p { margin-bottom: 30px; color: #ccc; }
|
| 823 |
+
.welcome-buttons { display: flex; gap: 20px; justify-content: center; }
|
| 824 |
+
|
| 825 |
+
/* ================= 左上角头像样式 (修改版) ================= */
|
| 826 |
+
#top-menu {
|
| 827 |
+
position: relative;
|
| 828 |
+
display: flex;
|
| 829 |
+
justify-content: center;
|
| 830 |
+
align-items: center;
|
| 831 |
+
}
|
| 832 |
+
|
| 833 |
+
.avatar-container {
|
| 834 |
+
position: absolute;
|
| 835 |
+
left: 20px;
|
| 836 |
+
cursor: pointer;
|
| 837 |
+
}
|
| 838 |
+
|
| 839 |
+
.avatar-circle {
|
| 840 |
+
width: 40px;
|
| 841 |
+
height: 40px;
|
| 842 |
+
border-radius: 50%;
|
| 843 |
+
display: flex;
|
| 844 |
+
justify-content: center;
|
| 845 |
+
align-items: center;
|
| 846 |
+
font-weight: bold;
|
| 847 |
+
font-size: 1.2rem;
|
| 848 |
+
color: white;
|
| 849 |
+
transition: all 0.3s ease;
|
| 850 |
+
border: 2px solid transparent;
|
| 851 |
+
}
|
| 852 |
+
|
| 853 |
+
.avatar-circle.user { background-color: #555; }
|
| 854 |
+
.avatar-circle.admin { background-color: #ffaa00; border-color: #fff; box-shadow: 0 0 10px rgba(255, 170, 0, 0.5); }
|
src/App.jsx
CHANGED
|
@@ -2,8 +2,6 @@ import React, { useState, useRef, useEffect } from 'react';
|
|
| 2 |
import './App.css';
|
| 3 |
import { VideoManagerLocal } from './utils/VideoManagerLocal';
|
| 4 |
|
| 5 |
-
// 引入我们刚刚拆分好的组件
|
| 6 |
-
// 注意:确保你的文件名和这里 import 的名字完全一致
|
| 7 |
import Home from './components/Home';
|
| 8 |
import FocusPageLocal from './components/FocusPageLocal';
|
| 9 |
import Achievement from './components/Achievement';
|
|
@@ -12,108 +10,195 @@ import Customise from './components/Customise';
|
|
| 12 |
import Help from './components/Help';
|
| 13 |
|
| 14 |
function App() {
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
</div>
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
}
|
| 118 |
|
| 119 |
-
export default App;
|
|
|
|
| 2 |
import './App.css';
|
| 3 |
import { VideoManagerLocal } from './utils/VideoManagerLocal';
|
| 4 |
|
|
|
|
|
|
|
| 5 |
import Home from './components/Home';
|
| 6 |
import FocusPageLocal from './components/FocusPageLocal';
|
| 7 |
import Achievement from './components/Achievement';
|
|
|
|
| 10 |
import Help from './components/Help';
|
| 11 |
|
| 12 |
function App() {
|
| 13 |
+
const [activeTab, setActiveTab] = useState('home');
|
| 14 |
+
const videoManagerRef = useRef(null);
|
| 15 |
+
const [isSessionActive, setIsSessionActive] = useState(false);
|
| 16 |
+
const [sessionResult, setSessionResult] = useState(null);
|
| 17 |
+
|
| 18 |
+
// 新增状态:控制身份和弹窗
|
| 19 |
+
const [role, setRole] = useState('user');
|
| 20 |
+
const [showWelcomePopup, setShowWelcomePopup] = useState(false);
|
| 21 |
+
const handleAutoImport = async () => {
|
| 22 |
+
const backup = localStorage.getItem('focus_magic_backup');
|
| 23 |
+
if (backup) {
|
| 24 |
+
try {
|
| 25 |
+
const sessions = JSON.parse(backup);
|
| 26 |
+
const response = await fetch('/api/import', {
|
| 27 |
+
method: 'POST',
|
| 28 |
+
headers: { 'Content-Type': 'application/json' },
|
| 29 |
+
body: JSON.stringify(sessions)
|
| 30 |
+
});
|
| 31 |
+
if (response.ok) {
|
| 32 |
+
alert("Auto-recovery successful! Data restored from local cache.");
|
| 33 |
+
setShowWelcomePopup(false);
|
| 34 |
+
} else {
|
| 35 |
+
alert("Auto-recovery failed on server.");
|
| 36 |
+
}
|
| 37 |
+
} catch (err) {
|
| 38 |
+
alert("Error reading cache: " + err.message);
|
| 39 |
+
}
|
| 40 |
+
} else {
|
| 41 |
+
alert("No previous automatic backup found. Please use 'Manual Import' to select your downloaded JSON file.");
|
| 42 |
+
}
|
| 43 |
+
};
|
| 44 |
+
const fileInputRef = useRef(null);
|
| 45 |
+
|
| 46 |
+
// 刚进网页时的初始化逻辑:先清空,后弹窗
|
| 47 |
+
useEffect(() => {
|
| 48 |
+
fetch('/api/history', { method: 'DELETE' })
|
| 49 |
+
.then(() => {
|
| 50 |
+
console.log("History cleared for new user.");
|
| 51 |
+
setShowWelcomePopup(true);
|
| 52 |
+
})
|
| 53 |
+
.catch(err => console.error("Failed to clear history on load", err));
|
| 54 |
+
|
| 55 |
+
const callbacks = {
|
| 56 |
+
onSessionStart: () => {
|
| 57 |
+
setIsSessionActive(true);
|
| 58 |
+
setSessionResult(null);
|
| 59 |
+
},
|
| 60 |
+
onSessionEnd: (summary) => {
|
| 61 |
+
setIsSessionActive(false);
|
| 62 |
+
if (summary) setSessionResult(summary);
|
| 63 |
+
}
|
| 64 |
+
};
|
| 65 |
+
videoManagerRef.current = new VideoManagerLocal(callbacks);
|
| 66 |
+
|
| 67 |
+
return () => {
|
| 68 |
+
if (videoManagerRef.current) videoManagerRef.current.stopStreaming();
|
| 69 |
+
};
|
| 70 |
+
}, []);
|
| 71 |
+
|
| 72 |
+
// 手动导入文件的处理逻辑 (借用 Customise 的逻辑)
|
| 73 |
+
const handleFileChange = async (event) => {
|
| 74 |
+
const file = event.target.files[0];
|
| 75 |
+
if (!file) return;
|
| 76 |
+
const reader = new FileReader();
|
| 77 |
+
reader.onload = async (e) => {
|
| 78 |
+
try {
|
| 79 |
+
const sessions = JSON.parse(e.target.result);
|
| 80 |
+
const response = await fetch('/api/import', {
|
| 81 |
+
method: 'POST',
|
| 82 |
+
headers: { 'Content-Type': 'application/json' },
|
| 83 |
+
body: JSON.stringify(sessions)
|
| 84 |
+
});
|
| 85 |
+
if (response.ok) {
|
| 86 |
+
alert("Import successful! You can check your records now.");
|
| 87 |
+
setShowWelcomePopup(false);
|
| 88 |
+
} else {
|
| 89 |
+
alert("Import failed on server side.");
|
| 90 |
+
}
|
| 91 |
+
} catch (err) {
|
| 92 |
+
alert("Error parsing file: " + err.message);
|
| 93 |
+
}
|
| 94 |
+
event.target.value = '';
|
| 95 |
+
};
|
| 96 |
+
reader.readAsText(file);
|
| 97 |
+
};
|
| 98 |
+
|
| 99 |
+
// 点击左上角头像切换 Admin/User
|
| 100 |
+
const handleAvatarClick = async () => {
|
| 101 |
+
if (role === 'admin') {
|
| 102 |
+
if (window.confirm("Switch back to User mode? This will clear current test data.")) {
|
| 103 |
+
await fetch('/api/history', { method: 'DELETE' });
|
| 104 |
+
setRole('user');
|
| 105 |
+
setShowWelcomePopup(true);
|
| 106 |
+
}
|
| 107 |
+
} else {
|
| 108 |
+
const pwd = window.prompt("Enter Admin Password:");
|
| 109 |
+
if (pwd === "123") { // 这里是你设定的测试密码
|
| 110 |
+
try {
|
| 111 |
+
// 1. 先清空当前数据
|
| 112 |
+
await fetch('/api/history', { method: 'DELETE' });
|
| 113 |
+
// 2. 读取 public 目录下的测试文件
|
| 114 |
+
const res = await fetch('/test_data.json');
|
| 115 |
+
if (!res.ok) throw new Error("test_data.json not found in public folder");
|
| 116 |
+
const testData = await res.json();
|
| 117 |
+
// 3. 导入测试数据
|
| 118 |
+
const importRes = await fetch('/api/import', {
|
| 119 |
+
method: 'POST',
|
| 120 |
+
headers: { 'Content-Type': 'application/json' },
|
| 121 |
+
body: JSON.stringify(testData)
|
| 122 |
+
});
|
| 123 |
+
if (importRes.ok) {
|
| 124 |
+
setRole('admin');
|
| 125 |
+
alert("Admin mode activated! Test data loaded successfully.");
|
| 126 |
+
}
|
| 127 |
+
} catch (error) {
|
| 128 |
+
alert("Admin login failed: " + error.message);
|
| 129 |
+
}
|
| 130 |
+
} else if (pwd !== null) {
|
| 131 |
+
alert("Incorrect password!");
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
};
|
| 135 |
+
|
| 136 |
+
return (
|
| 137 |
+
<div className="app-container">
|
| 138 |
+
|
| 139 |
+
{/* 迎宾弹窗 */}
|
| 140 |
+
{showWelcomePopup && (
|
| 141 |
+
<div className="welcome-modal-overlay">
|
| 142 |
+
<div className="welcome-modal">
|
| 143 |
+
<h2>Welcome to FocusGuard!</h2>
|
| 144 |
+
<p>Would you like to start fresh or import your previous local records?</p>
|
| 145 |
+
<div className="welcome-buttons">
|
| 146 |
+
<button className="btn-main" onClick={() => setShowWelcomePopup(false)}>New Start</button>
|
| 147 |
+
<button className="btn-main" style={{backgroundColor: '#4CAF50'}} onClick={handleAutoImport}>Auto Import</button>
|
| 148 |
+
<button className="btn-main yellow" onClick={() => fileInputRef.current.click()}>Manual Import</button>
|
| 149 |
+
</div>
|
| 150 |
+
{/* 隐藏的上传框 */}
|
| 151 |
+
<input type="file" ref={fileInputRef} style={{ display: 'none' }} accept=".json" onChange={handleFileChange} />
|
| 152 |
+
</div>
|
| 153 |
+
</div>
|
| 154 |
+
)}
|
| 155 |
+
|
| 156 |
+
<nav id="top-menu">
|
| 157 |
+
{/* 左上角头像区域 */}
|
| 158 |
+
<div className="avatar-container" onClick={handleAvatarClick} title="Click to switch User/Admin">
|
| 159 |
+
<div className={`avatar-circle ${role}`}>
|
| 160 |
+
{role === 'admin' ? 'A' : 'U'}
|
| 161 |
+
</div>
|
| 162 |
</div>
|
| 163 |
+
|
| 164 |
+
<button className={`menu-btn ${activeTab === 'focus' ? 'active' : ''}`} onClick={() => setActiveTab('focus')}>
|
| 165 |
+
Start Focus {isSessionActive && <span style={{marginLeft: '8px', color: '#00FF00'}}>●</span>}
|
| 166 |
+
</button>
|
| 167 |
+
<div className="separator"></div>
|
| 168 |
+
|
| 169 |
+
<button className={`menu-btn ${activeTab === 'achievement' ? 'active' : ''}`} onClick={() => setActiveTab('achievement')}>
|
| 170 |
+
My Achievement
|
| 171 |
+
</button>
|
| 172 |
+
<div className="separator"></div>
|
| 173 |
+
|
| 174 |
+
<button className={`menu-btn ${activeTab === 'records' ? 'active' : ''}`} onClick={() => setActiveTab('records')}>
|
| 175 |
+
My Records
|
| 176 |
+
</button>
|
| 177 |
+
<div className="separator"></div>
|
| 178 |
+
|
| 179 |
+
<button className={`menu-btn ${activeTab === 'customise' ? 'active' : ''}`} onClick={() => setActiveTab('customise')}>
|
| 180 |
+
Customise
|
| 181 |
+
</button>
|
| 182 |
+
<div className="separator"></div>
|
| 183 |
+
|
| 184 |
+
<button className={`menu-btn ${activeTab === 'help' ? 'active' : ''}`} onClick={() => setActiveTab('help')}>
|
| 185 |
+
Help
|
| 186 |
+
</button>
|
| 187 |
+
</nav>
|
| 188 |
+
|
| 189 |
+
{activeTab === 'home' && <Home setActiveTab={setActiveTab} />}
|
| 190 |
+
<FocusPageLocal
|
| 191 |
+
videoManager={videoManagerRef.current}
|
| 192 |
+
sessionResult={sessionResult}
|
| 193 |
+
setSessionResult={setSessionResult}
|
| 194 |
+
isActive={activeTab === 'focus'}
|
| 195 |
+
/>
|
| 196 |
+
{activeTab === 'achievement' && <Achievement />}
|
| 197 |
+
{activeTab === 'records' && <Records />}
|
| 198 |
+
{activeTab === 'customise' && <Customise />}
|
| 199 |
+
{activeTab === 'help' && <Help />}
|
| 200 |
+
</div>
|
| 201 |
+
);
|
| 202 |
}
|
| 203 |
|
| 204 |
+
export default App;
|
src/components/Customise.jsx
CHANGED
|
@@ -57,6 +57,9 @@ function Customise() {
|
|
| 57 |
|
| 58 |
// 创建 JSON Blob
|
| 59 |
const jsonString = JSON.stringify(data, null, 2);
|
|
|
|
|
|
|
|
|
|
| 60 |
const blob = new Blob([jsonString], { type: 'application/json' });
|
| 61 |
|
| 62 |
// 创建临时下载链接
|
|
@@ -142,7 +145,7 @@ function Customise() {
|
|
| 142 |
|
| 143 |
return (
|
| 144 |
<main id="page-e" className="page">
|
| 145 |
-
<h1 className="page-title">Customise</h1>
|
| 146 |
|
| 147 |
<div className="settings-container">
|
| 148 |
{/* Detection Settings */}
|
|
@@ -217,4 +220,4 @@ function Customise() {
|
|
| 217 |
);
|
| 218 |
}
|
| 219 |
|
| 220 |
-
export default Customise;
|
|
|
|
| 57 |
|
| 58 |
// 创建 JSON Blob
|
| 59 |
const jsonString = JSON.stringify(data, null, 2);
|
| 60 |
+
// 在浏览器缓存里存一份
|
| 61 |
+
localStorage.setItem('focus_magic_backup', jsonString);
|
| 62 |
+
|
| 63 |
const blob = new Blob([jsonString], { type: 'application/json' });
|
| 64 |
|
| 65 |
// 创建临时下载链接
|
|
|
|
| 145 |
|
| 146 |
return (
|
| 147 |
<main id="page-e" className="page">
|
| 148 |
+
<h1 className="page-title">Customise</h1>
|
| 149 |
|
| 150 |
<div className="settings-container">
|
| 151 |
{/* Detection Settings */}
|
|
|
|
| 220 |
);
|
| 221 |
}
|
| 222 |
|
| 223 |
+
export default Customise;
|