From ce729704f8497fc03f9cfd181b69328e18b222cc Mon Sep 17 00:00:00 2001 From: jacobxu666 Date: Fri, 26 Jun 2026 09:58:09 +0800 Subject: [PATCH] feat(mock): create mock infrastructure with USE_MOCK switch --- .env.dev | 1 + .env.local | 1 + .env.uat | 1 + src/mock/images.ts | 112 ++++++++++++++++++++++++++++++++++++++++++++ src/mock/index.ts | 2 + src/mock/order.ts | 4 ++ src/mock/reserve.ts | 4 ++ src/mock/store.ts | 17 +++++++ 8 files changed, 142 insertions(+) create mode 100644 src/mock/images.ts create mode 100644 src/mock/index.ts create mode 100644 src/mock/order.ts create mode 100644 src/mock/reserve.ts create mode 100644 src/mock/store.ts diff --git a/.env.dev b/.env.dev index 2b47ca6..9905706 100644 --- a/.env.dev +++ b/.env.dev @@ -1,2 +1,3 @@ VITE_API_BASE_URL=https://dscp-dev.hn12301.net VITE_APP_TITLE=湖南12301文旅专区 +VITE_USE_MOCK=true diff --git a/.env.local b/.env.local index e2bf5be..203b664 100644 --- a/.env.local +++ b/.env.local @@ -1,2 +1,3 @@ VITE_API_BASE_URL=http://localhost:48080 VITE_APP_TITLE=湖南12301文旅专区 +VITE_USE_MOCK=true diff --git a/.env.uat b/.env.uat index b2e0cfd..e3a81e1 100644 --- a/.env.uat +++ b/.env.uat @@ -1,2 +1,3 @@ VITE_API_BASE_URL=https://dscp-uat.hn12301.net VITE_APP_TITLE=湖南12301文旅专区 +VITE_USE_MOCK=true diff --git a/src/mock/images.ts b/src/mock/images.ts new file mode 100644 index 0000000..e79a77b --- /dev/null +++ b/src/mock/images.ts @@ -0,0 +1,112 @@ +/** + * 集中管理所有外部图片 URL + * 从各页面提取,便于后续替换为真实数据 + */ + +// 首页 Banner +export const IMG_HOME_BANNER = 'https://aliyunoss.hntgov.net/image/2026/04/14/d2bf03167e484ba59f7c2d62879ad07f.jpg' + +// 年卡购买页图片 +export const IMG_CARD_BUY_1 = 'https://aliyunoss.hntgov.net/image/2026/06/23/70e9f4b3b5fd49adb1ff06edcb8fa032.jpg' +export const IMG_CARD_BUY_2 = 'https://aliyunoss.hntgov.net/image/2026/06/25/f3e45bcb3b4f4a2997f107cc6335a1bc.jpg' + +// 入园码页面 +export const IMG_QRCODE_LOGO = 'https://hn12301.oss-cn-shenzhen.aliyuncs.com/hn12301/%E5%88%9D%E5%BF%83%E6%BA%90%20%E6%B9%98%E9%84%82%E8%B5%A3%E6%96%87%E6%97%85%E4%B8%80%E5%8D%A1%E9%80%9A_1777447994254.png' +export const IMG_QRCODE_BG = 'https://hn12301.oss-cn-shenzhen.aliyuncs.com/hn12301/1782285689132_1782285690033.png' + +// 使用说明页 +export const IMG_USAGE_GUIDE = 'https://hn12301.oss-cn-shenzhen.aliyuncs.com/hn12301/%E5%9B%BE%E7%89%87%E6%96%87%E5%AD%97%E6%9B%BF%E6%8D%A2.png' + +// 工会购买页 +export const IMG_UNION_BUY = 'https://hn12301.oss-cn-shenzhen.aliyuncs.com/hn12301/px-062501.png' + +// 用户头像 +export const IMG_AVATAR_DEFAULT = 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?fm=jpg&q=80&w=200&h=200&fit=crop' +export const IMG_AVATAR_FEMALE = 'https://images.unsplash.com/photo-1494790108377-be9c29b29330?fm=jpg&q=80&w=200&h=200&fit=crop' +export const IMG_AVATAR_MALE = 'https://images.unsplash.com/photo-1527980965255-d3b416303d12?fm=jpg&q=80&w=200&h=200&fit=crop' + +// 武功山金顶 +export const IMG_WUGONG_MOUNTAIN = 'https://images.unsplash.com/photo-1513415564515-763d91423bdd?fm=jpg&q=80&w=800&h=400&fit=crop' +export const IMG_WUGONG_MOUNTAIN_500 = 'https://images.unsplash.com/photo-1513415564515-763d91423bdd?fm=jpg&q=80&w=750&h=500&fit=crop' +export const IMG_WUGONG_MOUNTAIN_250 = 'https://images.unsplash.com/photo-1513415564515-763d91423bdd?fm=jpg&q=80&w=400&h=250&fit=crop' + +// 高山云海(杨岐山孽龙洞 / 太阳广场等多处复用) +export const IMG_MOUNTAIN_CLOUD = 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?fm=jpg&q=80&w=800&h=400&fit=crop' +export const IMG_MOUNTAIN_CLOUD_500 = 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?fm=jpg&q=80&w=750&h=500&fit=crop' +export const IMG_MOUNTAIN_CLOUD_400 = 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?fm=jpg&q=80&w=750&h=400&fit=crop' +export const IMG_MOUNTAIN_CLOUD_250 = 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?fm=jpg&q=80&w=400&h=250&fit=crop' + +// 田园风光(仙凤三宝 / 源南田园等多处复用) +export const IMG_PASTORAL = 'https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05?fm=jpg&q=80&w=800&h=400&fit=crop' +export const IMG_PASTORAL_500 = 'https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05?fm=jpg&q=80&w=750&h=500&fit=crop' +export const IMG_PASTORAL_300 = 'https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05?fm=jpg&q=80&w=750&h=300&fit=crop' +export const IMG_PASTORAL_250 = 'https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05?fm=jpg&q=80&w=400&h=250&fit=crop' + +// 瀑布温泉(武功山君澜温泉 / 万龙山温泉 / 东源温泉) +export const IMG_WATERFALL = 'https://images.unsplash.com/photo-1433086966358-54859d0ed716?fm=jpg&q=80&w=800&h=400&fit=crop' +export const IMG_WATERFALL_500 = 'https://images.unsplash.com/photo-1433086966358-54859d0ed716?fm=jpg&q=80&w=750&h=500&fit=crop' +export const IMG_WATERFALL_250 = 'https://images.unsplash.com/photo-1433086966358-54859d0ed716?fm=jpg&q=80&w=400&h=250&fit=crop' + +// 森林(凯光新天地) +export const IMG_FOREST = 'https://images.unsplash.com/photo-1441974231531-c6227db76b6e?fm=jpg&q=80&w=800&h=400&fit=crop' +export const IMG_FOREST_500 = 'https://images.unsplash.com/photo-1441974231531-c6227db76b6e?fm=jpg&q=80&w=750&h=500&fit=crop' +export const IMG_FOREST_250 = 'https://images.unsplash.com/photo-1441974231531-c6227db76b6e?fm=jpg&q=80&w=400&h=250&fit=crop' + +// 草原(和平农场) +export const IMG_GRASSLAND = 'https://images.unsplash.com/photo-1501854140801-50d01698950b?fm=jpg&q=80&w=800&h=400&fit=crop' +export const IMG_GRASSLAND_250 = 'https://images.unsplash.com/photo-1501854140801-50d01698950b?fm=jpg&q=80&w=400&h=250&fit=crop' + +// 山脉(武功山滑草场 / 鸡冠山森林步道 / 张佳坊山地乐园) +export const IMG_MOUNTAIN_RANGE = 'https://images.unsplash.com/photo-1551632811-561732d1e306?fm=jpg&q=80&w=800&h=400&fit=crop' + +// 农田(芦溪仙凤三宝农业观光园 / 高坑生态采摘园) +export const IMG_FARMLAND = 'https://images.unsplash.com/photo-1500382017468-9049fed747ef?fm=jpg&q=80&w=800&h=400&fit=crop' + +// 森林小径(麻山幸福村) +export const IMG_FOREST_PATH = 'https://images.unsplash.com/photo-1523712999610-f77fbcfc3843?fm=jpg&q=80&w=800&h=400&fit=crop' + +// 海滩(东桥双月湾 / 白竺青草湖) +export const IMG_BEACH = 'https://images.unsplash.com/photo-1507525428034-b723cf961d3e?fm=jpg&q=80&w=800&h=400&fit=crop' + +// 节日烟花(上栗花炮文化博览园 / 湘东傩文化园) +export const IMG_FIREWORKS = 'https://images.unsplash.com/photo-1533174072545-7a4b6ad7a6c3?fm=jpg&q=80&w=800&h=400&fit=crop' + +// 佛教寺庙(杨岐普通寺 / 杨岐山野生动物科普园 / 长平养生谷) +export const IMG_TEMPLE = 'https://images.unsplash.com/photo-1518241353330-0f7941c2d9b5?fm=jpg&q=80&w=800&h=400&fit=crop' + +// 露营帐篷(孽龙洞漂流 / 荷尧古渡口) +export const IMG_CAMPING = 'https://images.unsplash.com/photo-1504280390367-361c6d9f38f4?fm=jpg&q=80&w=800&h=400&fit=crop' +export const IMG_CAMPING_500 = 'https://images.unsplash.com/photo-1504280390367-361c6d9f38f4?fm=jpg&q=80&w=750&h=500&fit=crop' + +// 红色教育(安源路矿工人运动纪念馆 / 坊楼红色文化园 / 新泉红色研学基地) +export const IMG_RED_EDUCATION = 'https://images.unsplash.com/photo-1565008576549-57569a49371d?fm=jpg&q=80&w=800&h=400&fit=crop' +export const IMG_RED_EDUCATION_500 = 'https://images.unsplash.com/photo-1565008576549-57569a49371d?fm=jpg&q=80&w=750&h=500&fit=crop' + +// 荷花(莲花荷博园 / 广寒寨四季花海) +export const IMG_FLOWERS = 'https://images.unsplash.com/photo-1490750967868-88aa4486c946?fm=jpg&q=80&w=800&h=400&fit=crop' + +// 湖泊(山口岩水利风景区 / 长丰山水景区) +export const IMG_LAKE = 'https://images.unsplash.com/photo-1439066615861-d1af74d74000?fm=jpg&q=80&w=800&h=400&fit=crop' + +// 雪山(宣风三宝水上乐园 / 安源欢乐谷 / 桐木水上乐园) +export const IMG_SNOW_MOUNTAIN = 'https://images.unsplash.com/photo-1464822759023-fed622ff2c3b?fm=jpg&q=80&w=800&h=400&fit=crop' +export const IMG_SNOW_MOUNTAIN_500 = 'https://images.unsplash.com/photo-1464822759023-fed622ff2c3b?fm=jpg&q=80&w=750&h=500&fit=crop' + +// 星空银河(武功山星空) +export const IMG_STARRY_SKY = 'https://images.unsplash.com/photo-1519681393784-d120267933ba?fm=jpg&q=80&w=750&h=500&fit=crop' + +// 日式建筑(武功山君澜温泉内景) +export const IMG_JAPANESE = 'https://images.unsplash.com/photo-1545569341-9eb8b30979d9?fm=jpg&q=80&w=800&h=400&fit=crop' +export const IMG_JAPANESE_500 = 'https://images.unsplash.com/photo-1545569341-9eb8b30979d9?fm=jpg&q=80&w=750&h=500&fit=crop' + +// 民宿(赤山杨岐山民宿集群) +export const IMG_RESORT = 'https://images.unsplash.com/photo-1510798831971-661eb04b3739?fm=jpg&q=80&w=800&h=400&fit=crop' + +// 度假村酒店(上栗泉水湾度假村) +export const IMG_HOTEL = 'https://images.unsplash.com/photo-1571896349842-33c89424de2d?fm=jpg&q=80&w=800&h=400&fit=crop' + +// 棋盘山(莲花棋盘山) +export const IMG_HILLTOP = 'https://images.unsplash.com/photo-1444464666168-49d633b86797?fm=jpg&q=80&w=800&h=400&fit=crop' + +// 古建筑(芦溪东阳古村 / 下埠陶瓷文化小镇) +export const IMG_ANCIENT_VILLAGE = 'https://images.unsplash.com/photo-1528181304800-259b08848526?fm=jpg&q=80&w=800&h=400&fit=crop' diff --git a/src/mock/index.ts b/src/mock/index.ts new file mode 100644 index 0000000..97b40ce --- /dev/null +++ b/src/mock/index.ts @@ -0,0 +1,2 @@ +/** Mock 数据开关 — 由 .env 文件的 VITE_USE_MOCK 控制 */ +export const USE_MOCK = import.meta.env.VITE_USE_MOCK === 'true' diff --git a/src/mock/order.ts b/src/mock/order.ts new file mode 100644 index 0000000..adc65df --- /dev/null +++ b/src/mock/order.ts @@ -0,0 +1,4 @@ +import type { OrderInfo } from '@/api/types' + +// 占位 — Task 5 将填充实际模拟数据 +export const mockOrders: OrderInfo[] = [] diff --git a/src/mock/reserve.ts b/src/mock/reserve.ts new file mode 100644 index 0000000..099bb25 --- /dev/null +++ b/src/mock/reserve.ts @@ -0,0 +1,4 @@ +import type { ReserveRecord } from '@/api/types' + +// 占位 — Task 5 将填充实际模拟数据 +export const mockReserves: ReserveRecord[] = [] diff --git a/src/mock/store.ts b/src/mock/store.ts new file mode 100644 index 0000000..8f0830f --- /dev/null +++ b/src/mock/store.ts @@ -0,0 +1,17 @@ +import { ref } from 'vue' +import type { OrderInfo, ReserveRecord } from '@/api/types' +import { mockOrders } from './order' +import { mockReserves } from './reserve' + +export const orderStore = ref([...mockOrders]) +export const reserveStore = ref([...mockReserves]) + +export function updateOrderStatus(orderId: string, status: OrderInfo['status']) { + const order = orderStore.value.find(o => o.id === orderId) + if (order) order.status = status +} + +export function addReserve(record: Omit) { + const id = Math.max(...reserveStore.value.map(r => r.id), 0) + 1 + reserveStore.value.push({ ...record, id }) +}