From e4e7beebc730906333985dc8ddbb8d77886fc3e9 Mon Sep 17 00:00:00 2001 From: reng Date: Fri, 26 Sep 2025 11:34:14 +0800 Subject: [PATCH] update --- vite/public/cuelist_0923.json | 14 ++++++---- vite/src/pages/flow_free.jsx | 19 +++++++++++--- vite/src/util/useUser.jsx | 49 ++++++++++++++++++++++------------- 3 files changed, 55 insertions(+), 27 deletions(-) diff --git a/vite/public/cuelist_0923.json b/vite/public/cuelist_0923.json index 184a902..be4b2f5 100644 --- a/vite/public/cuelist_0923.json +++ b/vite/public/cuelist_0923.json @@ -48,7 +48,8 @@ "audioFile": "assets/combine/Q4-0-1.mp3", "nextcue": 4.1, "callback":"numpad", - "numpad_type":"userid" + "numpad_type":"userid", + "input_time": 20000 }, { "id": 4.1, @@ -126,8 +127,9 @@ "description": "discard" } }, - "hint":"保留,請按1\n刪除,請按9\n確定,請按#", - "hint_time": 21800, + "hint":"保留,請按1\n刪除,請按9\n確定輸入後,請按#", + "hint_time":13000, + "input_time":18000, "nextcue":5.4 }, { @@ -141,7 +143,8 @@ "callback":"numpad", "numpad_type":"password", "hint":"請輸入四位數密碼\n確定輸入後,請按#", - "hint_time": 7800, + "hint_time": 3000, + "input_time":11000, "default_password":"0000" }, { @@ -155,7 +158,8 @@ "callback":"numpad", "numpad_type":"password", "hint":"請輸入四位數密碼\n確定輸入後,請按#", - "hint_time": 7900, + "hint_time": 3000, + "input_time":11000, "default_password":"0000" }, { diff --git a/vite/src/pages/flow_free.jsx b/vite/src/pages/flow_free.jsx index e58a68c..cd19697 100644 --- a/vite/src/pages/flow_free.jsx +++ b/vite/src/pages/flow_free.jsx @@ -60,7 +60,7 @@ export function FreeFlow(){ const [padInput, setPadInput] = useState(null); - const [showMessage, setShowMessage] = useState(false); + const [inputReady, setInputReady] = useState(false); const { userId, setUserId, getFileId, setPassword, reset:resetUser, uploadHistory, setSummary, summary,setChoice,choice, getUploadFolder,getDataId, writeSheet } = useUser(); @@ -83,6 +83,7 @@ export function FreeFlow(){ const refData=useRef(data); const refHintTimeout=useRef(); + const refInputTimeout=useRef(); const refFadeOutInterval=useRef(); const refVolDownInterval=useRef(); @@ -425,9 +426,19 @@ export function FreeFlow(){ if(cue.hint!=null && cue.hint_time!=null){ refHintTimeout.current=setTimeout(()=>{ sendOsc(OSC_ADDRESS.HINT, cue.hint); // Send OSC hint message + }, cue.hint_time); } + setInputReady(false); + + if(cue.input_time!=null){ + if(refInputTimeout.current) clearTimeout(refInputTimeout.current); + refInputTimeout.current=setTimeout(()=>{ + setInputReady(()=>true); + }, cue.input_time); + } + if(cue.audioFile){ playAudio(cue.audioFile); } @@ -851,7 +862,7 @@ export function FreeFlow(){ {localIP || '...'} -
+
{refCurrentCue.current?.name}
@@ -860,12 +871,12 @@ export function FreeFlow(){ {/* */} {/* */} - + {/* */} {/*
diff --git a/vite/src/util/useUser.jsx b/vite/src/util/useUser.jsx index 0c6d48d..bf5fac5 100644 --- a/vite/src/util/useUser.jsx +++ b/vite/src/util/useUser.jsx @@ -6,12 +6,12 @@ import { useData } from "./useData"; const userContext=createContext(); const SessionTime={ - A:["12:00", "13:30"], - B:["13:30", "15:00"], - C:["15:00", "17:30"], - D:["17:30", "19:00"], - E:["19:00", "20:30"], - F:["20:30", "22:00"] + "1200":["13:00", "14:00"], + "1330":["14:20", "15:30"], + "1500":["16:00", "17:00"], + "1730":["18:30", "19:30"], + "1900":["20:00", "21:00"], + "2030":["21:30", "23:00"] } @@ -28,9 +28,7 @@ export function UserProvider({children}) { const {data}=useData(); - function getSessionId(){ - return `${SessionTime[sessionId]!=null? SessionTime[sessionId][0].replace(':',''):'no-session'}`; - } + function getFileId(){ if(!userId){ if(data?.id){ @@ -115,20 +113,31 @@ export function UserProvider({children}) { }); },[choice, summary, refPassword.current]); - - useEffect(() => { - - let symbol=''; - - for(const [key, value] of Object.entries(SessionTime)){ + + function getSessionId(time){ + let symbol='no-session'; + for(const [key, value] of Object.entries(SessionTime)){ const start=moment(value[0], "HH:mm"); const end=moment(value[1], "HH:mm"); - if(moment().isBetween(start, end)){ - symbol=key; - break; + if(time){ + const checkTime=moment(time, "HH:mm"); + if(checkTime.isBetween(start, end)){ + return key; + } + }else{ + if(moment().isBetween(start, end)){ + symbol=key; + break; + } } } + return symbol; + } + useEffect(() => { + + + const symbol=getSessionId(); setSessionId(symbol); @@ -137,6 +146,10 @@ export function UserProvider({children}) { console.log("Session ID changed:", sessionId); }, [sessionId]); + + // console.log(getSessionId(), getSessionId("13:12"), getSessionId("14:55"), getSessionId("2213")); + + // useEffect(()=>{ // refChoice.current=choice; // console.log("Choice changed:", choice);