fix. [PWT-107] [front] Footer > 언어 선택 박스 노출 순서 지정
This commit is contained in:
@@ -125,6 +125,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
interface LanguageOrder {
|
||||
languageOrder?: any[]
|
||||
}
|
||||
|
||||
const props = defineProps<LanguageOrder>()
|
||||
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const baseDomain = `${runtimeConfig.public.baseDomain}`
|
||||
|
||||
@@ -144,9 +151,37 @@ const availableLanguages = computed(() => {
|
||||
langCodes.includes(lang.code)
|
||||
)
|
||||
|
||||
return filteredLanguages.length > 0
|
||||
? filteredLanguages
|
||||
: [{ code: 'ko', name: '한국어' }]
|
||||
if (filteredLanguages.length === 0) {
|
||||
return [{ code: 'ko', name: '한국어' }]
|
||||
}
|
||||
//languageOrder 값이 있는 경우 정렬, 없는 경우 기본 순서 유지
|
||||
const defaultLanguageOrder = [ 'ko', 'en', 'ja', 'zh-cn', 'zh-tw', 'th' ]
|
||||
const languageOrder = props.languageOrder || defaultLanguageOrder
|
||||
// 정렬: 우선순위 언어 먼저, 그 다음 나머지
|
||||
const sortedLanguages = filteredLanguages.sort((a, b) => {
|
||||
const indexA = languageOrder.indexOf(a.code)
|
||||
const indexB = languageOrder.indexOf(b.code)
|
||||
|
||||
// 둘 다 우선순위 목록에 있는 경우
|
||||
if (indexA !== -1 && indexB !== -1) {
|
||||
return indexA - indexB
|
||||
}
|
||||
|
||||
// a만 우선순위 목록에 있는 경우
|
||||
if (indexA !== -1) {
|
||||
return -1
|
||||
}
|
||||
|
||||
// b만 우선순위 목록에 있는 경우
|
||||
if (indexB !== -1) {
|
||||
return 1
|
||||
}
|
||||
|
||||
// 둘 다 우선순위 목록에 없는 경우 원래 순서 유지
|
||||
return 0
|
||||
})
|
||||
|
||||
return sortedLanguages
|
||||
})
|
||||
|
||||
// 언어 코드를 이름으로 변환하는 함수
|
||||
|
||||
@@ -159,10 +159,13 @@
|
||||
<div
|
||||
class="language-area static md:absolute bottom-7 right-10 text-white mt-5 md:mt-0 md:bottom-5.5 md:right-4"
|
||||
>
|
||||
<BlocksLanguageSwitcher />
|
||||
<BlocksLanguageSwitcher :language-order="tm('Footer_Language_Order')" />
|
||||
</div>
|
||||
|
||||
<div class="mt-6 md:mt-6 hidden sm:block">
|
||||
<div
|
||||
v-if="hasCautionText"
|
||||
class="mt-6 md:mt-6 hidden sm:block"
|
||||
>
|
||||
<div
|
||||
v-dompurify-html="tm('Footer_caution')"
|
||||
class="text-xs text-white/30"
|
||||
@@ -231,6 +234,29 @@ import type {
|
||||
|
||||
const { tm, locale }: any = useI18n()
|
||||
|
||||
// Footer_caution 값이 있고 빈 객체가 아닌지 체크
|
||||
const hasCautionText = computed(() => {
|
||||
const value = tm('Footer_caution')
|
||||
|
||||
// null, undefined 체크
|
||||
if (value === null || value === undefined) {
|
||||
return false
|
||||
}
|
||||
|
||||
// 빈 객체 체크
|
||||
if (typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length === 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
// 문자열로 변환하여 빈 문자열 또는 '{}' 문자열 체크
|
||||
const stringValue = String(value).trim()
|
||||
if (stringValue === '' || stringValue === '{}') {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
const gameDataStore = useGameDataStore()
|
||||
const { gameData } = storeToRefs(gameDataStore)
|
||||
// const path = ref<string>(`${staticUrl}/local/template/${gameData.value.s3_folder_name}`)
|
||||
@@ -317,6 +343,7 @@ const footerAgeRatingInfo = computed((): string[] => {
|
||||
const info = (tm as any)('Footer_AgeRating_Info')
|
||||
return Array.isArray(info) ? info : []
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user