gallery.ts
3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import { localGalleryByIndex } from "@/utils/localGalleryImages";
import { staticAsset } from "@/utils/staticAsset";
export interface GalleryPhoto {
id: number;
imageUrl: string;
title: string;
/** 接口会返回,离线演示可为空 */
description?: string;
likes: number;
author: string;
/** 列表日期(Y-m-d),用于时间范围筛选 */
date?: string;
/** 接口列表:当前登录/游客 token 对应用户是否已点赞 */
liked?: boolean;
/** 接口列表/榜单附带,与 work_category 一致 */
categories?: string[];
}
export const bannerImages = [
{
id: 1,
url: staticAsset("home-top-banner.png"),
title: "云雾山海",
subtitle: "四川·稻城亚丁",
},
{
id: 2,
url: staticAsset("home-top-banner-2.png"),
title: "溪谷漫步",
subtitle: "草甸流水,雪山为幕",
},
{
id: 3,
url: staticAsset("home-top-banner-3.png"),
title: "碧蓝海子",
subtitle: "雪峰倒映,静坐湖岸",
},
];
export const mockPhotos: GalleryPhoto[] = [
{
id: 1,
imageUrl: staticAsset("photo-xiannairi-xuefeng.png"),
title: "仙乃日雪峰",
likes: 156,
author: "山行者",
},
{
id: 2,
imageUrl: staticAsset("photo-niunaihai.png"),
title: "牛奶海",
likes: 528,
author: "云游四方",
},
{
id: 3,
imageUrl: staticAsset("photo-sangdui-caoyuan.png"),
title: "桑堆草原",
likes: 189,
author: "摄影师小李",
},
{
id: 4,
imageUrl: localGalleryByIndex(4),
title: "经幡祈福",
likes: 203,
author: "藏地风情",
},
{
id: 5,
imageUrl: localGalleryByIndex(5),
title: "秋色森林",
likes: 178,
author: "四季光影",
},
{
id: 6,
imageUrl: localGalleryByIndex(6),
title: "央迈勇神山",
likes: 267,
author: "雪域探险",
},
{
id: 7,
imageUrl: staticAsset("photo-xueyu-simiao.png"),
title: "雪域寺庙",
likes: 298,
author: "信仰之光",
},
{
id: 8,
imageUrl: localGalleryByIndex(8),
title: "冰川雪顶",
likes: 312,
author: "冰雪世界",
},
{
id: 9,
imageUrl: localGalleryByIndex(9),
title: "高山草甸",
likes: 145,
author: "草原之歌",
},
{
id: 10,
imageUrl: localGalleryByIndex(10),
title: "山谷溪流",
likes: 221,
author: "流水潺潺",
},
{
id: 11,
imageUrl: localGalleryByIndex(11),
title: "金秋森林",
likes: 256,
author: "秋天童话",
},
{
id: 12,
imageUrl: localGalleryByIndex(12),
title: "冰川奇观",
likes: 289,
author: "极地探索",
},
{
id: 13,
imageUrl: localGalleryByIndex(13),
title: "高原之境",
likes: 167,
author: "高原追梦",
},
{
id: 14,
imageUrl: localGalleryByIndex(14),
title: "日照金山",
likes: 423,
author: "晨曦守望",
},
{
id: 15,
imageUrl: localGalleryByIndex(15),
title: "野花盛开",
likes: 192,
author: "花海寻梦",
},
{
id: 16,
imageUrl: localGalleryByIndex(16),
title: "飞瀑流泉",
likes: 208,
author: "水之灵",
},
];
/** 未排序副本,供按筛选条件排序 */
export function photosUnsorted(): GalleryPhoto[] {
return [...mockPhotos];
}
export function photosSortedByLikes(): GalleryPhoto[] {
return [...mockPhotos].sort((a, b) => b.likes - a.likes || a.id - b.id);
}
export function getPhotoById(id: number): GalleryPhoto | undefined {
return mockPhotos.find((p) => p.id === id);
}