官网开发 0804

This commit is contained in:
eafonyang
2026-08-04 19:18:35 +08:00
parent f37b6451ef
commit 816281bf2d
31 changed files with 1177 additions and 543 deletions
+4 -1
View File
@@ -7,6 +7,8 @@
* - code = 2:无数据
*/
import { resolveAssetUrls } from '~/utils/resolveAssetUrl';
export interface ApiResponse<T = unknown> {
code: number;
msg: string;
@@ -36,7 +38,8 @@ export function useRequest() {
}
// code = 2(无数据)时 data 为 null,正常返回
return res.data;
// 统一解析 *_url / *_path 字段中的相对路径(如 /uploads/...)为完整资源地址
return resolveAssetUrls(res.data);
}
function get<T = unknown>(url: string, params?: Record<string, unknown>) {
+5 -1
View File
@@ -1,4 +1,5 @@
import type { SectionBlock, SectionConfig } from '~/types/site';
import { resolveAssetUrl } from '~/utils/resolveAssetUrl';
/**
* 区块内容多语言解析
@@ -16,7 +17,10 @@ export function useSectionContent(section: SectionBlock) {
const content = computed(() => (isEn.value ? section.content_en : section.content_zh) || '');
const ctaPrimaryText = computed(() => (isEn.value ? section.cta_primary_en : section.cta_primary_zh) || '');
const ctaSecondaryText = computed(() => (isEn.value ? section.cta_secondary_en : section.cta_secondary_zh) || '');
const mediaUrl = computed(() => (isEn.value ? section.media_url_en : section.media_url_zh) || section.media_url_zh || '');
// media_url_zh/_en 以语言后缀结尾,不命中数据层 resolveAssetUrls 的 *_url 匹配,需在此单独解析相对路径
const mediaUrl = computed(() =>
resolveAssetUrl((isEn.value ? section.media_url_en : section.media_url_zh) || section.media_url_zh || '')
);
const config = computed<SectionConfig>(() => section.config ?? {});