fix: update @repo/sdk to version 1.0.14 and adjust build scripts for production
feat: modify TemplateCard and TemplateGrid to handle optional id and filter templates refactor: clean up use-template-filter to use CategoryTemplate type
This commit is contained in:
parent
01865d94c2
commit
a529dc03e1
4
bun.lock
4
bun.lock
|
|
@ -14,7 +14,7 @@
|
||||||
"@react-navigation/elements": "^2.6.3",
|
"@react-navigation/elements": "^2.6.3",
|
||||||
"@react-navigation/native": "^7.1.8",
|
"@react-navigation/native": "^7.1.8",
|
||||||
"@repo/core": "1.0.3",
|
"@repo/core": "1.0.3",
|
||||||
"@repo/sdk": "1.0.13",
|
"@repo/sdk": "1.0.14",
|
||||||
"@shopify/flash-list": "^2.0.0",
|
"@shopify/flash-list": "^2.0.0",
|
||||||
"@stripe/react-stripe-js": "^5.4.1",
|
"@stripe/react-stripe-js": "^5.4.1",
|
||||||
"@stripe/stripe-js": "^8.5.3",
|
"@stripe/stripe-js": "^8.5.3",
|
||||||
|
|
@ -657,7 +657,7 @@
|
||||||
|
|
||||||
"@repo/core": ["@repo/core@1.0.3", "https://gitea.bowongai.com/api/packages/bowong/npm/%40repo%2Fcore/-/1.0.3/core-1.0.3.tgz", {}, "sha512-lO7rk3hsrtoyewZu7cgwlFqjjhGBx+lw4wxkehfvTsbTWm/tKChq1t6SC+XXNJj/YVwnLp6AH8BOsvR4r1nxyg=="],
|
"@repo/core": ["@repo/core@1.0.3", "https://gitea.bowongai.com/api/packages/bowong/npm/%40repo%2Fcore/-/1.0.3/core-1.0.3.tgz", {}, "sha512-lO7rk3hsrtoyewZu7cgwlFqjjhGBx+lw4wxkehfvTsbTWm/tKChq1t6SC+XXNJj/YVwnLp6AH8BOsvR4r1nxyg=="],
|
||||||
|
|
||||||
"@repo/sdk": ["@repo/sdk@1.0.13", "https://gitea.bowongai.com/api/packages/bowong/npm/%40repo%2Fsdk/-/1.0.13/sdk-1.0.13.tgz", { "dependencies": { "@repo/core": "1.0.3", "reflect-metadata": "^0.2.1", "zod": "^4.2.1" } }, "sha512-2Iq2UZFMv6M4uWhJtkbDptYs69w3MJTDFSVlo0G85fxDAtF4YPmjNoxe7Mm6pi6FCf7qXpyHFOSgpeJRxL7GtQ=="],
|
"@repo/sdk": ["@repo/sdk@1.0.14", "https://gitea.bowongai.com/api/packages/bowong/npm/%40repo%2Fsdk/-/1.0.14/sdk-1.0.14.tgz", { "dependencies": { "@repo/core": "1.0.3", "reflect-metadata": "^0.2.1", "zod": "^4.2.1" } }, "sha512-J/j3kRL83X4TtGadjLUGX9ueiROStZ0hM+zCPkKtgk5bMUR8K98HefbWzt1PV8jKBp9n+heckyHWHcL3nKDPwA=="],
|
||||||
|
|
||||||
"@rtsao/scc": ["@rtsao/scc@1.1.0", "", {}, "sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g=="],
|
"@rtsao/scc": ["@rtsao/scc@1.1.0", "", {}, "sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g=="],
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { Image } from 'expo-image'
|
||||||
import { LinearGradient } from 'expo-linear-gradient'
|
import { LinearGradient } from 'expo-linear-gradient'
|
||||||
|
|
||||||
export interface TemplateCardProps {
|
export interface TemplateCardProps {
|
||||||
id: string
|
id?: string
|
||||||
title: string
|
title: string
|
||||||
previewUrl?: string
|
previewUrl?: string
|
||||||
webpPreviewUrl?: string
|
webpPreviewUrl?: string
|
||||||
|
|
@ -55,6 +55,11 @@ const TemplateCardComponent: React.FC<TemplateCardProps> = ({
|
||||||
const aspectRatio = parseAspectRatio(aspectRatioString)
|
const aspectRatio = parseAspectRatio(aspectRatioString)
|
||||||
const imageUri = getImageUri(webpPreviewUrl, previewUrl, coverImageUrl)
|
const imageUri = getImageUri(webpPreviewUrl, previewUrl, coverImageUrl)
|
||||||
|
|
||||||
|
// 如果没有 id,则不渲染卡片
|
||||||
|
if (!id) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Pressable
|
<Pressable
|
||||||
style={[styles.card, { width: cardWidth }]}
|
style={[styles.card, { width: cardWidth }]}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,12 @@
|
||||||
import React, { useState, memo } from 'react'
|
import React, { useState, memo } from 'react'
|
||||||
import { View, StyleSheet, LayoutChangeEvent } from 'react-native'
|
import { View, StyleSheet, LayoutChangeEvent } from 'react-native'
|
||||||
|
import type { CategoryTemplate } from '@repo/sdk'
|
||||||
import { TemplateCard } from './TemplateCard'
|
import { TemplateCard } from './TemplateCard'
|
||||||
|
|
||||||
export interface Template {
|
export type Template = CategoryTemplate
|
||||||
id: string
|
|
||||||
title: string
|
|
||||||
previewUrl?: string
|
|
||||||
webpPreviewUrl?: string
|
|
||||||
coverImageUrl?: string
|
|
||||||
aspectRatio?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TemplateGridProps {
|
export interface TemplateGridProps {
|
||||||
templates: Template[]
|
templates: CategoryTemplate[]
|
||||||
onTemplatePress: (id: string) => void
|
onTemplatePress: (id: string) => void
|
||||||
numColumns?: number
|
numColumns?: number
|
||||||
horizontalPadding?: number
|
horizontalPadding?: number
|
||||||
|
|
@ -45,8 +39,13 @@ const TemplateGridComponent: React.FC<TemplateGridProps> = ({
|
||||||
}) => {
|
}) => {
|
||||||
const [gridWidth, setGridWidth] = useState(0)
|
const [gridWidth, setGridWidth] = useState(0)
|
||||||
|
|
||||||
|
// 过滤掉没有 id 的模板
|
||||||
|
const validTemplates = templates.filter((template): template is CategoryTemplate & { id: string } =>
|
||||||
|
!!template.id
|
||||||
|
)
|
||||||
|
|
||||||
// 空数据时返回 null
|
// 空数据时返回 null
|
||||||
if (!templates || templates.length === 0) {
|
if (!validTemplates || validTemplates.length === 0) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,7 +61,7 @@ const TemplateGridComponent: React.FC<TemplateGridProps> = ({
|
||||||
onLayout={handleLayout}
|
onLayout={handleLayout}
|
||||||
>
|
>
|
||||||
<View style={[styles.grid, { gap: cardGap }]}>
|
<View style={[styles.grid, { gap: cardGap }]}>
|
||||||
{templates.map((template) => (
|
{validTemplates.map((template) => (
|
||||||
<TemplateCard
|
<TemplateCard
|
||||||
key={template.id}
|
key={template.id}
|
||||||
id={template.id}
|
id={template.id}
|
||||||
|
|
|
||||||
1
eas.json
1
eas.json
|
|
@ -20,6 +20,7 @@
|
||||||
"corepack": true
|
"corepack": true
|
||||||
},
|
},
|
||||||
"production": {
|
"production": {
|
||||||
|
"distribution": "internal",
|
||||||
"autoIncrement": true,
|
"autoIncrement": true,
|
||||||
"android": {
|
"android": {
|
||||||
"buildType": "apk"
|
"buildType": "apk"
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,6 @@ export { useDebounce } from './use-debounce'
|
||||||
export { useWorksSearch } from './use-works-search'
|
export { useWorksSearch } from './use-works-search'
|
||||||
export { useChangePassword } from './use-change-password'
|
export { useChangePassword } from './use-change-password'
|
||||||
export { useUpdateProfile } from './use-update-profile'
|
export { useUpdateProfile } from './use-update-profile'
|
||||||
export { useTemplateFilter, type Template, type UseTemplateFilterOptions, type UseTemplateFilterReturn } from './use-template-filter'
|
export { useTemplateFilter, type UseTemplateFilterOptions, type UseTemplateFilterReturn } from './use-template-filter'
|
||||||
export { useStickyTabs, type UseStickyTabsReturn } from './use-sticky-tabs'
|
export { useStickyTabs, type UseStickyTabsReturn } from './use-sticky-tabs'
|
||||||
export { useTabNavigation, type Category, type UseTabNavigationOptions, type UseTabNavigationReturn } from './use-tab-navigation'
|
export { useTabNavigation, type Category, type UseTabNavigationOptions, type UseTabNavigationReturn } from './use-tab-navigation'
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,11 @@
|
||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
|
import type { CategoryTemplate } from '@repo/sdk'
|
||||||
/**
|
|
||||||
* Template interface for filtering
|
|
||||||
*/
|
|
||||||
export interface Template {
|
|
||||||
id: string
|
|
||||||
previewUrl?: string
|
|
||||||
webpPreviewUrl?: string
|
|
||||||
coverImageUrl?: string
|
|
||||||
[key: string]: any
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options for useTemplateFilter hook
|
* Options for useTemplateFilter hook
|
||||||
*/
|
*/
|
||||||
export interface UseTemplateFilterOptions {
|
export interface UseTemplateFilterOptions {
|
||||||
templates: Template[]
|
templates: CategoryTemplate[]
|
||||||
excludeVideo?: boolean
|
excludeVideo?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -23,7 +13,7 @@ export interface UseTemplateFilterOptions {
|
||||||
* Return type for useTemplateFilter hook
|
* Return type for useTemplateFilter hook
|
||||||
*/
|
*/
|
||||||
export interface UseTemplateFilterReturn {
|
export interface UseTemplateFilterReturn {
|
||||||
filteredTemplates: Template[]
|
filteredTemplates: CategoryTemplate[]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "expo start",
|
"start": "expo start",
|
||||||
"build:android:dev": "eas build --platform android --profile development",
|
"build:android:dev": "eas build --platform android --profile development",
|
||||||
"build:android:preview": "eas build --platform android --profile preview",
|
"build:android:production": "eas build --platform android --profile production",
|
||||||
"prebuild:android": "expo prebuild --platform android",
|
"prebuild:android": "expo prebuild --platform android",
|
||||||
"reset-project": "node ./scripts/reset-project.js",
|
"reset-project": "node ./scripts/reset-project.js",
|
||||||
"claude": "claude --dangerously-skip-permissions",
|
"claude": "claude --dangerously-skip-permissions",
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
"@react-navigation/elements": "^2.6.3",
|
"@react-navigation/elements": "^2.6.3",
|
||||||
"@react-navigation/native": "^7.1.8",
|
"@react-navigation/native": "^7.1.8",
|
||||||
"@repo/core": "1.0.3",
|
"@repo/core": "1.0.3",
|
||||||
"@repo/sdk": "1.0.13",
|
"@repo/sdk": "1.0.14",
|
||||||
"@shopify/flash-list": "^2.0.0",
|
"@shopify/flash-list": "^2.0.0",
|
||||||
"@stripe/react-stripe-js": "^5.4.1",
|
"@stripe/react-stripe-js": "^5.4.1",
|
||||||
"@stripe/stripe-js": "^8.5.3",
|
"@stripe/stripe-js": "^8.5.3",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue