123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- /**
- * 首页轮播图数据接口
- * @returns 轮播图数据列表
- *
- * 替换真实接口说明:
- * 1. 替换真实接口时,需要修改以下内容:
- * - 将模拟数据替换为真实接口调用
- * - 添加错误处理
- * - 添加接口参数处理
- * - 添加数据转换逻辑
- *
- * 2. 真实接口示例:
- * const response = await $fetch('https://api.example.com/carousel', {
- * method: 'GET',
- * headers: {
- * 'Authorization': 'Bearer your-token',
- * 'Content-Type': 'application/json'
- * },
- * params: {
- * page: 1,
- * limit: 10
- * }
- * })
- *
- * 3. 错误处理示例:
- * try {
- * const response = await $fetch('...')
- * return {
- * code: 200,
- * data: response.data,
- * message: '获取轮播图数据成功'
- * }
- * } catch (error) {
- * return {
- * code: 500,
- * data: [],
- * message: '获取轮播图数据失败'
- * }
- * }
- *
- * 4. 数据转换示例:
- * const transformedData = response.data.map(item => ({
- * id: item.id,
- * title: item.title,
- * image: item.imageUrl,
- * link: `/products/${item.productId}`
- * }))
- *
- * 5. 接口参数处理示例:
- * const query = getQuery(event)
- * const page = Number(query.page) || 1
- * const limit = Number(query.limit) || 10
- */
- export default defineEventHandler(async () => {
- // 模拟数据
- const carouselList = [
- {
- id: 1,
- image: "",
- description: `
- <div class="rounded border border-white w-11 h-6 leading-none justify-center flex items-center text-white text-sm font-normal">SSD</div>
- <div class="justify-center">
- <span class="text-white text-6xl font-normal leading-[78px]">新技術</span>
- <span class="text-white text-6xl font-normal leading-[78px]">3D NAND TLC</span>
- <br />
- <span class="text-white text-6xl font-normal leading-[78px]">フラッシュ採用、 </span><br />
- <span class="text-cyan-400 text-6xl font-normal leading-[78px]">信頼性が高く耐久性に優<br />れている</span>
- </div>
- <div class="flex flex-col gap-2 mt-4">
- <div class="flex items-center gap-2 text-stone-50 text-xl font-normal">
- <div class="w-2 h-2 bg-white rounded-full"></div>
- ストレスのないゲーム体験をお楽しみください
- </div>
- <div class="flex items-center gap-2 text-stone-50 text-xl font-normal">
- <div class="w-2 h-2 bg-white rounded-full"></div>
- パソコンの起動時間が劇的に速くなった!
- </div>
- </div>
- `,
- link: "/products/1",
- },
- {
- id: 2,
- image: "",
- link: "/products/2",
- },
- {
- id: 3,
- image: "",
- link: "/products/3",
- },
- ];
-
- return {
- code: 200,
- data: carouselList,
- message: "获取轮播图数据成功",
- };
- });
|