fix. 언어 조회 기본 언어 gameDataStore에서 사용하도록 수정
This commit is contained in:
@@ -23,7 +23,7 @@ export default defineNuxtRouteMiddleware(to => {
|
||||
|
||||
// 최종 로케일 결정
|
||||
const finalLocale =
|
||||
csrGetFinalLocale(fullPath, langCodes.value) ||
|
||||
csrGetFinalLocale(fullPath, langCodes.value, defaultLangCode.value) ||
|
||||
defaultLangCode.value ||
|
||||
DEFAULT_LOCALE_CODE
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ export default defineNuxtRouteMiddleware(async to => {
|
||||
|
||||
try {
|
||||
const gameDataStore = useGameDataStore()
|
||||
const { gameId, langCodes } = storeToRefs(gameDataStore)
|
||||
const { gameId, langCodes, defaultLangCode } = storeToRefs(gameDataStore)
|
||||
|
||||
// app.vue에서 설정한 스토어 값이 없으면 대기
|
||||
if (!gameId.value || !langCodes.value) return
|
||||
@@ -19,7 +19,11 @@ export default defineNuxtRouteMiddleware(async to => {
|
||||
// const stoveMaintenanceApiUrl = `${runtimeConfig.public.stoveMaintenanceApiUrl}`
|
||||
const stoveGameId = gameId.value
|
||||
|
||||
const finalLocale = csrGetFinalLocale(to.path, langCodes.value)
|
||||
const finalLocale = csrGetFinalLocale(
|
||||
to.path,
|
||||
langCodes.value,
|
||||
defaultLangCode.value
|
||||
)
|
||||
|
||||
// 웹 점검 -----
|
||||
const { isWebInspection, getInspectionDataExternal } =
|
||||
|
||||
@@ -26,7 +26,8 @@ export default defineNuxtRouteMiddleware(async (to, _from) => {
|
||||
const accessToken = csrGetAccessToken()
|
||||
const gameDomain = getGameDomain()
|
||||
const pathWithoutLocale = getPathAfterLanguage(to.path)
|
||||
const langCode = csrGetFinalLocale(to.path, langCodes.value) || 'ko'
|
||||
const langCode =
|
||||
csrGetFinalLocale(to.path, langCodes.value, defaultLangCode.value) || 'ko'
|
||||
|
||||
let pageDataResponse: PageDataResponse | null = null
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ const cache = new LRUCache<string, WebInspectionData>({
|
||||
/**
|
||||
* Locale Middleware 역할 함수
|
||||
* URL의 언어 코드를 최종 언어로 변경하거나 추가
|
||||
* template에서는 i18n 버전 때문에 사용 필요. (동일 코드 init.route.global -> csr에서만 실행.)
|
||||
*/
|
||||
function fnLocaleMiddleware(
|
||||
event: H3Event,
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { DEFAULT_LOCALE_CODE } from '@/i18n.config'
|
||||
|
||||
// 사용자 선호 언어 조회
|
||||
export const getPreferredLanguage = (acceptLanguageHeader = '') => {
|
||||
const languages = acceptLanguageHeader
|
||||
@@ -32,11 +30,15 @@ const parseCookies = (cookieHeader: string) => {
|
||||
*
|
||||
* @param {string} path - 현재 URL 경로
|
||||
*/
|
||||
export const csrGetFinalLocale = (path = '', coveragesLocales: string[]) => {
|
||||
export const csrGetFinalLocale = (
|
||||
path = '',
|
||||
coveragesLocales: string[],
|
||||
defaultLocale: string
|
||||
) => {
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const baseDomain = `${runtimeConfig.public.baseDomain}`
|
||||
|
||||
let finalLocale = DEFAULT_LOCALE_CODE // 기본값 설정
|
||||
let finalLocale = defaultLocale // 기본값 설정
|
||||
|
||||
// 1. URL 패스에 포함된 언어
|
||||
if (path && path !== '' && path.split('/').length > 1) {
|
||||
@@ -83,8 +85,6 @@ export const csrGetFinalLocale = (path = '', coveragesLocales: string[]) => {
|
||||
}
|
||||
|
||||
// 3. 서비스 기본 언어
|
||||
finalLocale = DEFAULT_LOCALE_CODE
|
||||
|
||||
return finalLocale
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user