[20250723] 서버/국가 template선택코드 추가-> App.js/applyTemplate
This commit is contained in:
@@ -18,6 +18,7 @@ import { ThemeDecorator } from "@enact/sandstone/ThemeDecorator";
|
||||
|
||||
import {
|
||||
changeAppStatus,
|
||||
changeLocalSettings,
|
||||
// cancelFocusElement,
|
||||
// focusElement,
|
||||
// setExitApp,
|
||||
@@ -70,6 +71,71 @@ import { sendLogTotalRecommend } from "../actions/logActions";
|
||||
// } from "../utils/focus-monitor";
|
||||
// import { PanelHoc } from "../components/TPanel/TPanel";
|
||||
|
||||
// ===== 템플릿 설정 함수들 =====
|
||||
const applyTemplateSettings = (templateName) => {
|
||||
const templates = {
|
||||
// eic 서버 + GB 국가
|
||||
"eic-gb": {
|
||||
serverType: "qt2",
|
||||
ricCodeSetting: "eic",
|
||||
languageSetting: "GB"
|
||||
},
|
||||
// aic 서버 + US 국가
|
||||
"aic-us": {
|
||||
serverType: "qt2",
|
||||
ricCodeSetting: "aic",
|
||||
languageSetting: "US"
|
||||
},
|
||||
// ruc 서버 + RU 국가
|
||||
"ruc-ru": {
|
||||
serverType: "qt2",
|
||||
ricCodeSetting: "ruc",
|
||||
languageSetting: "RU"
|
||||
},
|
||||
// 기본 설정 (system)
|
||||
"default": {
|
||||
serverType: "system",
|
||||
ricCodeSetting: "system",
|
||||
languageSetting: "system"
|
||||
}
|
||||
};
|
||||
|
||||
return templates[templateName] || templates["default"];
|
||||
};
|
||||
|
||||
// 템플릿 설정 적용 훅
|
||||
const useTemplateSettings = () => {
|
||||
const dispatch = useDispatch();
|
||||
const currentLocalSettings = useSelector((state) => state.localSettings);
|
||||
|
||||
const applyTemplate = useCallback((templateName) => {
|
||||
const settings = applyTemplateSettings(templateName);
|
||||
console.log(`[Template] Applying template: ${templateName}`, settings);
|
||||
|
||||
// 현재 설정과 비교하여 변경사항이 있을 때만 적용
|
||||
const hasChanges = Object.keys(settings).some(key =>
|
||||
currentLocalSettings[key] !== settings[key]
|
||||
);
|
||||
|
||||
if (hasChanges) {
|
||||
console.log("[Template] Settings changed, applying new template");
|
||||
dispatch(changeLocalSettings(settings));
|
||||
|
||||
// 설정 변경 후 페이지 새로고침
|
||||
setTimeout(() => {
|
||||
if (typeof window === "object") {
|
||||
window.location.reload();
|
||||
}
|
||||
}, 500);
|
||||
} else {
|
||||
console.log("[Template] No changes detected, skipping template application");
|
||||
}
|
||||
}, [dispatch, currentLocalSettings]);
|
||||
|
||||
return { applyTemplate };
|
||||
};
|
||||
// ===== 템플릿 설정 함수들 끝 =====
|
||||
|
||||
let foreGroundChangeTimer = null;
|
||||
|
||||
// 기존 콘솔 메서드를 백업
|
||||
@@ -153,6 +219,9 @@ function AppBase(props) {
|
||||
// const termsFlag = useSelector((state) => state.common.termsFlag);
|
||||
const termsData = useSelector((state) => state.home.termsData);
|
||||
|
||||
// 템플릿 설정 훅 사용
|
||||
const { applyTemplate } = useTemplateSettings();
|
||||
|
||||
useEffect(() => {
|
||||
// Chromium68 호환성을 위해 Optional Chaining 제거
|
||||
if (termsData && termsData.data && termsData.data.terms) {
|
||||
@@ -190,6 +259,24 @@ function AppBase(props) {
|
||||
}
|
||||
}, [oldDb8Deleted, dispatch]);
|
||||
|
||||
// ===== 템플릿 설정 적용 =====
|
||||
// 테스트 시에만 아래 주석을 해제하고 원하는 템플릿을 선택하세요
|
||||
// 사용법: 원하는 템플릿의 주석을 해제하면 앱 시작 시 해당 설정이 적용됩니다
|
||||
useEffect(() => {
|
||||
// 앱 초기화가 완료된 후 템플릿 설정 적용
|
||||
if (httpHeaderRef.current) {
|
||||
const timer = setTimeout(() => {
|
||||
applyTemplate("eic-gb"); // eic 서버 + GB 국가
|
||||
// applyTemplate("aic-us"); // aic 서버 + US 국가
|
||||
// applyTemplate("ruc-ru"); // ruc 서버 + RU 국가
|
||||
// applyTemplate("default"); // 기본 설정 (system)
|
||||
}, 2000); // 2초 후 적용
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
}, [applyTemplate, httpHeaderRef.current]);
|
||||
// ===== 템플릿 설정 끝 =====
|
||||
|
||||
const hideCursor = useRef(
|
||||
new Job((func) => {
|
||||
func();
|
||||
|
||||
@@ -45,7 +45,7 @@ export default function TermsOfService({ title, cbScrollTo }) {
|
||||
const [closePopUp, setClosePopUp] = useState(false);
|
||||
const [resetScroll, setResetScroll] = useState(false);
|
||||
const [agreePopup, setAgreePopup] = useState(false);
|
||||
const [isOptionalChecked, setIsOptionalChecked] = useState(false);
|
||||
const [isOptionalChecked, setIsOptionalChecked] = useState(optionalTermsAgree);
|
||||
const [optionalDisagreePopupOpen, setOptionalDisagreePopupOpen] =
|
||||
useState(false);
|
||||
const [showCheckboxAlert, setShowCheckboxAlert] = useState(false);
|
||||
@@ -79,6 +79,7 @@ export default function TermsOfService({ title, cbScrollTo }) {
|
||||
|
||||
useEffect(() => {
|
||||
setLocalOptionalTermsAgree(optionalTermsAgree);
|
||||
setIsOptionalChecked(optionalTermsAgree);
|
||||
}, [optionalTermsAgree]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -139,11 +140,12 @@ export default function TermsOfService({ title, cbScrollTo }) {
|
||||
termsListRef.current = termsList;
|
||||
}, [termsList]);
|
||||
|
||||
useEffect(() => {
|
||||
if (termsData && termsData.data && termsData.data.terms) {
|
||||
dispatch(getTermsAgreeYn());
|
||||
}
|
||||
}, [termsData, dispatch]);
|
||||
// ✅ getTermsAgreeYn 호출 제거 - TV 환경에서 서버 동기화 지연 방지
|
||||
// useEffect(() => {
|
||||
// if (termsData && termsData.data && termsData.data.terms) {
|
||||
// dispatch(getTermsAgreeYn());
|
||||
// }
|
||||
// }, [termsData, dispatch]);
|
||||
|
||||
const handleItemClick = useCallback(
|
||||
({ index }) => {
|
||||
@@ -300,6 +302,7 @@ export default function TermsOfService({ title, cbScrollTo }) {
|
||||
// console.log("setMyPageTermsAgree callback response:", response);
|
||||
if (response.retCode === "000" || response.retCode === 0) {
|
||||
setLocalOptionalTermsAgree(true);
|
||||
setIsOptionalChecked(true);
|
||||
console.log("Optional terms agreement successful.");
|
||||
|
||||
// ✅ IntroPanel과 동일한 방식으로 Redux 상태 직접 업데이트 (API 호출 없이)
|
||||
|
||||
Reference in New Issue
Block a user