<template>
	<image :src="themeSrc" :mode="mode" />
</template>

<script setup>
import { computed } from 'vue'
import GlobalConfig from '@/config/global.config.js'

const props = defineProps({
	src: {
		type: String,
		default: ''
	},
	mode: {
		type: String,
		default: 'aspectFill'
	}
})

const themeSrc = computed(() => {
	return combineImgSrc()
})

const combineImgSrc = () => {
	if (!props.src) { return '' }
	if (props.src.startsWith('http')) {
		return props.src
	} else {
		let flagSrc = props.src.replace('@/static', '')
		const imgSrc = `${GlobalConfig.appImagePrefix()}${flagSrc}`
		return imgSrc
	}
}

</script>

<style lang="scss" scoped></style>
