55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
import type {
|
|
GameDataResponse,
|
|
GameDataRequest,
|
|
} from '#layers/types/api/gameData'
|
|
|
|
export const useGetGameDataExternal = () => {
|
|
const { setGameData } = useGameDataStore()
|
|
const logPrefix = {
|
|
exception: '[Exception] /composables/useGetGameDataExternal',
|
|
failure: '[Failure] /composables/useGetGameDataExternal',
|
|
}
|
|
const webGameData = ref<GameDataResponse | null>(null)
|
|
|
|
const getGameDataExternal = async (req: GameDataRequest) => {
|
|
console.log('🚀 ~ getGameDataExternal ~ req:', req)
|
|
// const config = useRuntimeConfig()
|
|
const config = useRuntimeConfig()
|
|
const stoveApiUrl = `${config.public.stoveApiUrl}`
|
|
const apiUrl = `${stoveApiUrl}/pub-comm/v1.0/template/game?game_domain=${req.gameDomain}&lang_code=${req.langCode}`
|
|
|
|
try {
|
|
const response = (await commonFetch('GET', apiUrl)) as GameDataResponse
|
|
console.log('🚀 ~ getGameDataExternal ~ response:', response)
|
|
|
|
// FIXME: 테스트용 데이터 ---------------------------------------------------
|
|
/* if (['local', 'local-gate8', 'dev'].includes(`${config.public.runType}`)) {
|
|
response.value = {
|
|
inspection_status: 1,
|
|
inspection: {
|
|
inspection_status: 1,
|
|
start_date: '2025-09-19 10:00:00',
|
|
end_date: '2025-09-19 12:00:00',
|
|
ts_start_date: new Date().getTime(),
|
|
ts_end_date: new Date().getTime(),
|
|
back_ground_image_type: 'image',
|
|
back_ground_image_url: 'https://www.onstove.com',
|
|
inspection_title1: '',
|
|
inspection_title2: ''
|
|
}
|
|
}
|
|
} */
|
|
// ------------------------------------------------------------------------
|
|
|
|
if (response?.value) {
|
|
webGameData.value = response
|
|
setGameData(response.value)
|
|
}
|
|
} catch (e) {
|
|
console.error(`${logPrefix.exception}.getGameDataExternal: `, e)
|
|
}
|
|
}
|
|
|
|
return { webGameData, getGameDataExternal }
|
|
}
|