aerwen_u_site/lang/fetch.js
2024-05-02 21:38:51 +08:00

8 lines
372 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export default defineI18nLocale(async locale => {
const res = await $fetch('/api/i18n/getLangListByLocale', { params: { code: locale } })
const { code, msg, data } = JSON.parse(res)
// 接口返回问题,如果没有数据返回的是 Array有数据返回的是 Object
// 判断是否有数据
if (Array.isArray(data)) return {}
return data
})