>(() => ({
const tmWithGameName = (key: string): string => {
const text = tm(key)
if (typeof text === 'string' && text.includes('%게임명%')) {
- const gameName = gameData.value?.game_name ?? ''
- return text.replace(/%게임명%/g, gameName)
+ return text.replace(/%게임명%/g, gameName.value)
}
return text
}
@@ -375,7 +374,7 @@ defineExpose({
- {{ gameData?.game_name }}
+ {{ gameName }}
{
const { handleTokenValidation } = useTokenValidation()
const { tm, locale } = useI18n()
- const { gameData } = storeToRefs(gameDataStore)
+ const { gameId } = storeToRefs(gameDataStore)
const stoveCs = runtimeConfig.public.stoveCs
const isProcessing = ref(false) // 연속 클릭 방지
const isShowCheckLauncher = ref(false) // 런처 실행 로딩 표시
const isShowDownloadLauncher = ref(false) // 런처 다운로드 표시
- const customerServiceUrl = `${stoveCs}/${gameData.value?.game_id}`
+ const customerServiceUrl = `${stoveCs}/${gameId.value}`
let launcherTimeoutId: ReturnType | null = null
// 에러 처리
@@ -116,11 +116,8 @@ export const useCheckGameStart = () => {
const runLauncher = async () => {
if (!import.meta.client) return
- const gameDataStore = useGameDataStore()
- const { gameData } = storeToRefs(gameDataStore)
-
const accessTokenSub = csrGetAccessToken()
- const stoveGameId = gameData.value?.game_id || ''
+ const stoveGameId = gameId.value || ''
const nationCookie = useCookie('NNTO').value
const localeCode = locale.value.toUpperCase() || 'KO'
diff --git a/layers/composables/useTokenValidation.ts b/layers/composables/useTokenValidation.ts
index a8cfeb6..15711a9 100644
--- a/layers/composables/useTokenValidation.ts
+++ b/layers/composables/useTokenValidation.ts
@@ -19,11 +19,11 @@ export const useTokenValidation = () => {
const gameDataStore = useGameDataStore()
const { tm } = useI18n()
- const { gameData } = storeToRefs(gameDataStore)
+ const { gameId } = storeToRefs(gameDataStore)
const apiBaseUrl = runtimeConfig.public.stoveApiUrl
const stoveCs = runtimeConfig.public.stoveCs
- const customerServiceUrl = `${stoveCs}/${gameData.value?.game_id}`
+ const customerServiceUrl = `${stoveCs}/${gameId.value}`
const isTokenValid = ref(false)
// 로그인 모달 표시
diff --git a/layers/middleware/init.route.global.ts b/layers/middleware/init.route.global.ts
index 07a3f95..31887c2 100644
--- a/layers/middleware/init.route.global.ts
+++ b/layers/middleware/init.route.global.ts
@@ -9,22 +9,22 @@ export default defineNuxtRouteMiddleware(to => {
if (to.path.includes('inspection')) return
const gameDataStore = useGameDataStore()
- const { gameData } = storeToRefs(gameDataStore)
+ const { langCodes, intro } = storeToRefs(gameDataStore)
// app.vue에서 설정한 스토어 값이 없으면 대기
- if (!gameData.value) return
+ if (!langCodes.value || !intro.value) return
// -------------------------------------------------------------------------------
// [Home Redirect]
// -------------------------------------------------------------------------------
const gamePath = getPathAfterLanguage(to.path)
- const langCode = csrGetFinalLocale(to.path, gameData.value.lang_codes)
+ const langCode = csrGetFinalLocale(to.path, langCodes.value)
const isRootPath = gamePath === '' || gamePath === '/'
if (isRootPath) {
- // gameData.intro.page_url이 있으면 해당 URL로 리다이렉트, 없으면 /home으로
- const introPageUrl = gameData.value?.intro?.page_url
+ // intro.page_url이 있으면 해당 URL로 리다이렉트, 없으면 /home으로
+ const introPageUrl = intro.value?.page_url
const redirectPath = getIntroRedirectPath(
introPageUrl,
langCode,
diff --git a/layers/middleware/inspection.ts b/layers/middleware/inspection.ts
index 5f2bb38..51f30de 100644
--- a/layers/middleware/inspection.ts
+++ b/layers/middleware/inspection.ts
@@ -9,17 +9,17 @@ export default defineNuxtRouteMiddleware(async to => {
try {
const gameDataStore = useGameDataStore()
- const { gameData } = storeToRefs(gameDataStore)
+ const { gameId, langCodes } = storeToRefs(gameDataStore)
// app.vue에서 설정한 스토어 값이 없으면 대기
- if (!gameData.value) return
+ if (!gameId.value || !langCodes.value) return
const stoveApiBaseUrl = `${runtimeConfig.public.stoveApiUrl}`
// const baseDomain = `${runtimeConfig.public.baseDomain}`
// const stoveMaintenanceApiUrl = `${runtimeConfig.public.stoveMaintenanceApiUrl}`
- const stoveGameId = gameData.value.game_id
+ const stoveGameId = gameId.value
- const finalLocale = csrGetFinalLocale(to.path, gameData.value.lang_codes)
+ const finalLocale = csrGetFinalLocale(to.path, langCodes.value)
// 웹 점검 -----
const { isWebInspection, getInspectionDataExternal } =
diff --git a/layers/middleware/pageData.global.ts b/layers/middleware/pageData.global.ts
index 045b8c5..9fd5fc0 100644
--- a/layers/middleware/pageData.global.ts
+++ b/layers/middleware/pageData.global.ts
@@ -20,14 +20,13 @@ export default defineNuxtRouteMiddleware(async (to, _from) => {
const pageDataStore = usePageDataStore()
const loadingStore = useLoadingStore()
- const { gameData } = storeToRefs(gameDataStore)
+ const { langCodes } = storeToRefs(gameDataStore)
const stoveApiBaseUrl = runtimeConfig.public.stoveApiUrl
const accessToken = csrGetAccessToken()
const gameDomain = getGameDomain()
const gamePath = getPathAfterLanguage(to.path)
- const langCode =
- csrGetFinalLocale(to.path, gameData.value?.lang_codes) || 'ko'
+ const langCode = csrGetFinalLocale(to.path, langCodes.value) || 'ko'
let pageDataResponse: PageDataResponse | null = null
diff --git a/layers/plugins/i18n-loader.client.ts b/layers/plugins/i18n-loader.client.ts
index a957923..96f76b4 100644
--- a/layers/plugins/i18n-loader.client.ts
+++ b/layers/plugins/i18n-loader.client.ts
@@ -10,10 +10,9 @@ export default defineNuxtPlugin(async nuxtApp => {
const commonTranslations = 'STOVE_PUBTEMPLATE_common_translations.json'
const gameDataStore = useGameDataStore()
- const { gameData } = storeToRefs(gameDataStore)
- const langCodes = gameData.value?.lang_codes
+ const { langCodes } = storeToRefs(gameDataStore)
- if (!langCodes || langCodes.length === 0) {
+ if (!langCodes || langCodes.value.length === 0) {
return
}
@@ -31,7 +30,7 @@ export default defineNuxtPlugin(async nuxtApp => {
'zh-cn': 'zh-CN',
}
- langCodes.forEach(langCode => {
+ langCodes.value.forEach(langCode => {
// 로케일 코드 변환 (필요한 경우)
const normalizedLangCode = localeMap[langCode] || langCode
diff --git a/layers/server/middleware/gameData.ts b/layers/server/middleware/gameData.ts
index 5559f45..978901b 100644
--- a/layers/server/middleware/gameData.ts
+++ b/layers/server/middleware/gameData.ts
@@ -310,7 +310,7 @@ export default defineEventHandler(async event => {
const isRootPath = gamePath === '' || gamePath === '/'
if (isRootPath) {
- // gameData.intro.page_url이 있으면 해당 URL로 리다이렉트, 없으면 /home으로
+ // intro.page_url이 있으면 해당 URL로 리다이렉트, 없으면 /home으로
const introPageUrl = gameDataValue?.intro?.page_url
const currentFullUrl = event.node.req.url || fullPath
const redirectPath = getIntroRedirectPath(
diff --git a/layers/stores/useGameDataStore.ts b/layers/stores/useGameDataStore.ts
index 697d15e..d63c5fa 100644
--- a/layers/stores/useGameDataStore.ts
+++ b/layers/stores/useGameDataStore.ts
@@ -1,26 +1,50 @@
import type { GameDataValue } from '#layers/types/api/gameData'
export const useGameDataStore = defineStore('gameData', () => {
- const gameData = ref(null)
- const langCodes = ref(null)
- const defaultLangCode = ref(null)
+ const getInitialState = () => ({
+ gameData: null as GameDataValue | null,
+ gameId: null as GameDataValue['game_id'] | null,
+ gameCode: null as GameDataValue['game_code'] | null,
+ gameName: null as GameDataValue['game_name'] | null,
+ langCodes: null as GameDataValue['lang_codes'] | null,
+ defaultLangCode: null as GameDataValue['default_lang_code'] | null,
+ gaCode: null as GameDataValue['ga_code'] | null,
+ platformType: null as GameDataValue['platform_type'] | null,
+ osType: null as GameDataValue['os_type'] | null,
+ intro: null as GameDataValue['intro'] | null,
+ imgJson: null as GameDataValue['img_json'] | null,
+ snsJson: null as GameDataValue['sns_json'] | null,
+ urlJson: null as GameDataValue['url_json'] | null,
+ gnb: null as GameDataValue['gnb'] | null,
+ eventBanner: null as GameDataValue['event_banner'] | null,
+ })
+
+ const state = reactive(getInitialState())
const setGameData = (data: GameDataValue) => {
- gameData.value = data
- langCodes.value = data.lang_codes
- defaultLangCode.value = data.default_lang_code
+ state.gameData = data
+ state.gameId = data?.game_id
+ state.gameCode = data?.game_code
+ state.gameName = data?.game_name
+ state.langCodes = data?.lang_codes
+ state.defaultLangCode = data?.default_lang_code
+ state.gaCode = data?.ga_code
+ state.platformType = data?.platform_type
+ state.osType = data?.os_type
+ state.intro = data?.intro
+ state.imgJson = data?.img_json
+ state.snsJson = data?.sns_json
+ state.urlJson = data?.url_json
+ state.gnb = data?.gnb
+ state.eventBanner = data?.event_banner
}
const clearGameData = () => {
- gameData.value = null
- langCodes.value = null
- defaultLangCode.value = null
+ Object.assign(state, getInitialState())
}
return {
- gameData,
- langCodes,
- defaultLangCode,
+ ...toRefs(state),
setGameData,
clearGameData,
}
diff --git a/layers/stores/usePageDataStore.ts b/layers/stores/usePageDataStore.ts
index 1ddb08d..3dd94cf 100644
--- a/layers/stores/usePageDataStore.ts
+++ b/layers/stores/usePageDataStore.ts
@@ -1,32 +1,29 @@
import type { PageDataValue } from '#layers/types/api/pageData'
export const usePageDataStore = defineStore('pageData', () => {
- const pageData = ref(null)
- const pageLayoutType = ref<'default' | 'promotion' | null>(null)
- const pageName = ref(null)
- const pageNameEn = ref(null)
+ // 초기 상태를 함수로 정의
+ const getInitialState = () => ({
+ pageData: null as PageDataValue | null,
+ pageLayoutType: null as 'default' | 'promotion' | null,
+ pageName: null as PageDataValue['page_name'] | null,
+ pageNameEn: null as PageDataValue['page_name_en'] | null,
+ })
+
+ const state = reactive(getInitialState())
const setPageData = (response: PageDataValue) => {
- clearPageData()
-
- pageData.value = response
- pageLayoutType.value = getLayoutType(pageData.value)
- pageName.value = pageData.value?.page_name
- pageNameEn.value = pageData.value?.page_name_en
+ state.pageData = response
+ state.pageLayoutType = getLayoutType(state.pageData)
+ state.pageName = state.pageData?.page_name
+ state.pageNameEn = state.pageData?.page_name_en
}
const clearPageData = () => {
- pageData.value = null
- pageLayoutType.value = null
- pageName.value = null
- pageNameEn.value = null
+ Object.assign(state, getInitialState())
}
return {
- pageData,
- pageLayoutType,
- pageName,
- pageNameEn,
+ ...toRefs(state),
setPageData,
clearPageData,
}
diff --git a/layers/templates/FxCoupon01/index.vue b/layers/templates/FxCoupon01/index.vue
index 3c257f9..7acd69e 100644
--- a/layers/templates/FxCoupon01/index.vue
+++ b/layers/templates/FxCoupon01/index.vue
@@ -68,7 +68,7 @@ const { pageNo, pageSize, updatePagination, getPageBlock } = useCouponPaging()
const gameDataStore = useGameDataStore()
const modalStore = useModalStore()
const couponStore = useCouponStore()
-const { gameData } = storeToRefs(gameDataStore)
+const { gameId, gameCode } = storeToRefs(gameDataStore)
const { handleOpenAlert, handleOpenConfirm } = modalStore
const { couponNo, isSelectCharacter, selectCharacter } =
storeToRefs(couponStore)
@@ -148,8 +148,8 @@ const validationCheckBefore = async () => {
* await checkGameMaintenance({
* baseApiUrl: stoveMaintenanceApiUrl,
* category: 'GAME',
- * service_id1: gameData.value.game_id,
- * gameId: gameData.value.game_id,
+ * service_id1: gameId.value,
+ * gameId: gameId.value,
* lang: locale.value,
* })
* if (isGameMaintenance.value) {
@@ -176,8 +176,8 @@ const validationCheckBefore = async () => {
* await getCharacterList({
* baseApiUrl: stoveApiUrl,
* accessToken: csrGetAccessToken(),
- * game_id: gameData.value.game_id,
- * gameId: gameData.value.game_id,
+ * game_id: gameId.value,
+ * gameId: gameId.value,
* })
* if (
* !characterList.value.some(
@@ -195,7 +195,7 @@ const validationCheckBefore = async () => {
*/
await getInspectionDataExternal({
baseApiUrl: stoveApiUrl,
- gameId: gameData.value.game_id,
+ gameId: gameId.value,
})
if (isWebInspection.value) {
return COUPON_RESULT.WEB_INSPECTION
@@ -216,8 +216,8 @@ const validationCheckBefore = async () => {
await getGuid({
baseApiUrl: stoveApiUrl,
accessToken: csrGetAccessToken(),
- game_id: gameData.value.game_id,
- gameId: gameData.value.game_id,
+ game_id: gameId.value,
+ gameId: gameId.value,
})
if (!hasGuid.value) {
return COUPON_RESULT.EMPTY_GUID
@@ -311,7 +311,7 @@ const handleCouponRegister = async () => {
const res = await postCouponUse({
accessToken: csrGetAccessToken(),
user_token_type: 'web',
- game_code: gameData.value.game_code.toString(),
+ game_code: gameCode.value.toString(),
coupon_no: couponNo.value,
client_ipaddr: clientIp.value,
world_no: selectCharacter.value.world_id,
@@ -368,7 +368,7 @@ const handlePeriodSearch = async () => {
const req: ReqCouponList = {
accessToken: accessToken,
user_token_type: 'web',
- game_code: gameData.value.game_code.toString(),
+ game_code: gameCode.value.toString(),
start_date: getTime(startDate.value),
end_date: getTime(endDate.value),
use_state_code: searchStatus.value,
@@ -402,7 +402,7 @@ const getCouponBoxUrl = () => {
url = getStoveCouponUrl('desktop')
}
- return `${url}?game_id=${gameData.value.game_id}`
+ return `${url}?game_id=${gameId.value}`
}
/**
@@ -439,7 +439,7 @@ const goToCouponBox = () => {
url = getStoveCouponUrl('desktop')
}
- csrGoExternalLink(`${url}?game_id=${gameData.value.game_id}`)
+ csrGoExternalLink(`${url}?game_id=${gameId.value}`)
}
/**
diff --git a/layers/templates/GrBoard01/index.vue b/layers/templates/GrBoard01/index.vue
index a35bd4c..625bd91 100644
--- a/layers/templates/GrBoard01/index.vue
+++ b/layers/templates/GrBoard01/index.vue
@@ -18,7 +18,7 @@ const pageDataStore = usePageDataStore()
const { getCwmsArticle } = useCwmsArticle()
const { locale } = useI18n()
-const { gameData } = storeToRefs(gameDataStore)
+const { urlJson } = storeToRefs(gameDataStore)
const { pageData } = storeToRefs(pageDataStore)
const boardId = computed(
@@ -101,7 +101,7 @@ const splideOptions = computed(() => {
})
const getArticleUrl = (articleId: string) => {
- const communityUrl = gameData.value?.url_json?.community
+ const communityUrl = urlJson.value?.community
if (!communityUrl || !articleId || !boardId.value) {
return ''
}
diff --git a/layers/types/api/gameData.ts b/layers/types/api/gameData.ts
index 4e5e2d1..5f9d1f5 100644
--- a/layers/types/api/gameData.ts
+++ b/layers/types/api/gameData.ts
@@ -43,12 +43,12 @@ export interface GameDataValue {
intro: GameDataIntro
inspection: Record
stove_gnb_json: GameDataStoveGnb
- favicon_json: GameDataFavicon
+ favicon_json: GameDataImg
meta_tag_json: GameDataMetaTag
sns_json: GameDataSns
url_json: Record
footer_json: string // JSON 문자열로 변경
- comm_img_json: GameDataCommImg
+ img_json: GameDataImg
market_json: Record
event_banner: GameDataEventBanner
os_type: OsType
@@ -78,8 +78,8 @@ export interface GameDataGameFont {
}
// 파비콘 경로 타입
-export interface GameDataFavicon {
- [index: number]: string
+export interface GameDataImg {
+ [key: string]: string
}
// 메타 태그 타입
@@ -111,20 +111,6 @@ export interface GameDataSns {
tiktok?: GameDataSnsItem
}
-// 공통 이미지 그룹 타입
-export interface GameDataCommImgGroup {
- img_name: string
- img_path: {
- comm: string
- }
- group_label: string
-}
-
-// 공통 이미지 타입
-export interface GameDataCommImg {
- groups: GameDataCommImgGroup[]
-}
-
// Global 설정 타입
export interface GameDataGlobal {
system_font: string // JSON 문자열로 변경
@@ -175,7 +161,6 @@ export interface GameDataMenu {
// GNB 설정 타입
export interface GameDataGnb {
game_gnb_ver: string
- bi_path: string
lang_codes: string // JSON 문자열로 변경
buttons: GameDataButton[]
menus: GameDataMenuChildren