refactor: 将数据获取从app端移至server端
- 调整数据获取位置以提升安全性 - 对于后端状态为Archived的数据,通过server控制不进行获取
This commit is contained in:
@ -1,16 +1,17 @@
|
||||
import GetCompanyProfile from '@/graphql/companyProfile.graphql?raw';
|
||||
|
||||
export const useCompanyProfile = () => {
|
||||
const { $directus } = useNuxtApp();
|
||||
const { getDirectusLocale } = useLocalizations();
|
||||
const locale = getDirectusLocale();
|
||||
|
||||
return useAsyncData(`company-profile-${locale}`, async () => {
|
||||
return await $directus.query<{ company_profile: CompanyProfile }>(
|
||||
GetCompanyProfile,
|
||||
{
|
||||
locale: locale,
|
||||
}
|
||||
);
|
||||
try {
|
||||
const data = await $fetch(`/api/cms/companyProfile`, {
|
||||
headers: { 'x-locale': locale },
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
logger.error('Error fetching company profile: ', error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user