mirror of
https://github.com/sky-systems/sky_phone.git
synced 2026-09-04 09:13:24 +00:00
ENH - add authentic App Store previews
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import type { BuiltinPhoneAppId } from '@/types/apps'
|
||||
|
||||
type PreviewableBuiltinAppId = Exclude<BuiltinPhoneAppId, 'app-store'>
|
||||
|
||||
const previewModules = import.meta.glob<string>(
|
||||
'../assets/img/app-previews/*.jpg',
|
||||
{
|
||||
eager: true,
|
||||
import: 'default',
|
||||
query: '?url',
|
||||
},
|
||||
)
|
||||
|
||||
const APP_STORE_PREVIEW_IMAGES = Object.fromEntries(
|
||||
Object.entries(previewModules).map(([path, imageUrl]) => {
|
||||
const appId = path.split('/').at(-1)?.replace(/\.jpg$/, '')
|
||||
if (!appId) throw new Error(`Invalid App Store preview path: ${path}`)
|
||||
return [appId, imageUrl]
|
||||
}),
|
||||
) as Partial<Record<PreviewableBuiltinAppId, string>>
|
||||
|
||||
export function getAppStorePreviewImage(appId: string): string | null {
|
||||
return APP_STORE_PREVIEW_IMAGES[appId as PreviewableBuiltinAppId] ?? null
|
||||
}
|
||||
|
||||
export const APP_STORE_PREVIEW_IMAGE_IDS = Object.freeze(
|
||||
Object.keys(APP_STORE_PREVIEW_IMAGES) as PreviewableBuiltinAppId[],
|
||||
)
|
||||
Reference in New Issue
Block a user