fix: 优化代码格式和导入,修复小问题

This commit is contained in:
康猛 2026-01-27 13:57:21 +08:00
parent 4fb909a8be
commit b494c3d730
5 changed files with 39 additions and 86 deletions

View File

@ -8,7 +8,7 @@ import { KeyboardAwareScrollView } from 'react-native-keyboard-controller'
import { APP_VERSION } from '@/app.config'
import BannerSection from '@/components/BannerSection'
import { getSession, phoneNumber, setAuthToken, signIn } from '@/lib/auth'
import { isValidEmail, isValidPhone } from '@/utils'
import { isValidPhone } from '@/utils'
import { openUrl } from '@/utils/webview-helper'
const APP_NAME = '多米'
@ -150,7 +150,6 @@ export default function Auth() {
},
)
})
} catch (error: any) {
console.error('登录/注册失败:', error)
Toast.show({ title: error.message || '操作失败,请稍后重试' })
@ -238,7 +237,7 @@ export default function Auth() {
<Block className="flex-row items-center gap-[8px]">
<Block
onClick={() => setAgreed(!agreed)}
className={`size-[20px] items-center justify-center border-[2px] border-black ${agreed ? 'bg-black' : 'bg-white'}`}
className={`size-[20px] items-center justify-center border-2 border-black ${agreed ? 'bg-black' : 'bg-white'}`}
>
{agreed && <Ionicons color="#FFE500" name="checkmark" size={14} />}
</Block>
@ -282,11 +281,7 @@ export default function Auth() {
{(['phone', 'email'] as const).map((type) => {
const isActive = type === loginType
return (
<Block
key={type}
style={{ transform: [{ skewX: '-6deg' }] }}
onClick={() => setLoginType(type)}
>
<Block key={type} style={{ transform: [{ skewX: '-6deg' }] }} onClick={() => setLoginType(type)}>
<Ionicons
color={isActive ? 'black' : '#9CA3AF'}
name={type === 'phone' ? 'phone-portrait' : 'mail'}
@ -300,7 +295,7 @@ export default function Auth() {
)
return (
<Block className="relative flex-1 bg-black h-[100dvh]">
<Block className="relative h-dvh flex-1 bg-black">
<BannerSection />
<KeyboardAwareScrollView bottomOffset={100}>
<Block className="flex-1 items-center justify-center px-[24px] py-[40px]">
@ -347,7 +342,9 @@ export default function Auth() {
onClick={countdown > 0 ? undefined : handleSendCode}
className={`border-2 border-black px-[6px] py-[4px] ${canSendCode && countdown === 0 ? 'bg-black' : 'bg-gray-200'}`}
>
<Text className={`text-[10px] font-[900] ${canSendCode && countdown === 0 ? 'text-accent' : 'text-gray-500'}`}>
<Text
className={`text-[10px] font-[900] ${canSendCode && countdown === 0 ? 'text-accent' : 'text-gray-500'}`}
>
{countdown > 0 ? `${countdown}` : '获取验证码'}
</Text>
</Block>
@ -433,10 +430,11 @@ export default function Auth() {
</Block>
</Block>
<Block className="flex-row items-center justify-between">
<Block className="flex-1">
{renderAgreementCheckbox()}
</Block>
<Text className="font-700 text-[12px] text-gray-500" onClick={() => router.push('/forgotPassword')}>
<Block className="flex-1">{renderAgreementCheckbox()}</Block>
<Text
className="font-700 text-[12px] text-gray-500"
onClick={() => router.push('/forgotPassword')}
>
</Text>
</Block>
@ -452,7 +450,7 @@ export default function Auth() {
<Block className="mt-[24px] items-center">
<Text className="font-700 text-[12px] text-gray-400">© 2025 LOOMART. All rights reserved.</Text>
<Text className="font-700 text-[12px] text-gray-400">: {APP_VERSION}</Text>
<Text className="font-700 text-[12px] text-gray-400">: {APP_VERSION}</Text>
</Block>
</Block>
</Block>

View File

@ -1,6 +1,6 @@
import * as ImagePicker from 'expo-image-picker'
import { Ionicons } from '@expo/vector-icons'
import { Block, ConfirmModal, Img, Input, Text, Toast } from '@share/components'
import * as ImagePicker from 'expo-image-picker'
import { router, Stack } from 'expo-router'
import { observer } from 'mobx-react-lite'
import React, { useEffect, useState } from 'react'
@ -199,11 +199,7 @@ export default observer(function ProfilePage() {
const renderHeader = () => (
<Block className="flex-row items-center justify-between px-[16px] py-[10px]">
<Block
className="ml-[-8px] size-[40px] items-center justify-center"
opacity={0.7}
onClick={() => router.back()}
>
<Block className="ml-[-8px] size-[40px] items-center justify-center" opacity={0.7} onClick={() => router.back()}>
<Ionicons color="black" name="chevron-back" size={24} />
</Block>
<Text className="text-[16px] font-[700] text-black"></Text>
@ -216,17 +212,13 @@ export default observer(function ProfilePage() {
<Block className="relative size-[100px] overflow-hidden rounded-full">
<Block className="size-[100px] items-center justify-center overflow-hidden rounded-full bg-gray-200">
{user?.image ? (
<Img
src={user.image}
style={{ width: 100, height: 100, borderRadius: 50 }}
width={100}
/>
<Img src={user.image} style={{ width: 100, height: 100, borderRadius: 50 }} width={100} />
) : (
<Ionicons color="#9CA3AF" name="person" size={48} />
)}
</Block>
<Block
className="absolute bottom-0 left-0 right-0 items-center justify-center bg-[#00000080] py-[2px]"
className="absolute inset-x-0 bottom-0 items-center justify-center bg-[#00000080] py-[2px]"
style={{ borderBottomLeftRadius: 50, borderBottomRightRadius: 50 }}
onClick={handleEditAvatar}
>
@ -237,25 +229,19 @@ export default observer(function ProfilePage() {
)
const renderInfoList = () => (
<Block className="mt-[32px] mx-[16px] bg-white rounded-xl px-[16px]">
<Block className="mx-[16px] mt-[32px] rounded-xl bg-white px-[16px]">
{infoItems.map((item) => (
<Block
key={item.id}
className="flex-row items-center gap-[12px] py-[16px]"
onClick={item.onPress}
>
<Block key={item.id} className="flex-row items-center gap-[12px] py-[16px]" onClick={item.onPress}>
<Text className="w-[56px] text-[14px] text-black">{item.label}</Text>
<Text
className="flex-1 text-[14px] text-right text-[#9D9D9D]"
className="flex-1 text-right text-[14px] text-[#9D9D9D]"
style={{ color: item.valueGray ? '#9CA3AF' : '#000' }}
numberOfLines={1}
ellipsizeMode="tail"
>
{item.value}
</Text>
{item.id !== 'phone' && item.id !== 'email' && (
<Ionicons color="#9D9D9D" name="chevron-forward" size={18} />
)}
{item.id !== 'phone' && item.id !== 'email' && <Ionicons color="#9D9D9D" name="chevron-forward" size={18} />}
</Block>
))}
</Block>

View File

@ -1,11 +1,10 @@
import { Ionicons } from '@expo/vector-icons'
import { Block, Img, Text } from '@share/components'
import { Block, ConfirmModal, Img, Text, Toast } from '@share/components'
import { router, Stack } from 'expo-router'
import { observer } from 'mobx-react-lite'
import React from 'react'
import { ScrollView } from 'react-native'
import { ConfirmModal, Toast } from '@share/components'
import { userStore } from '@/stores'
type MenuItem = {
@ -24,7 +23,6 @@ export default observer(function SettingsPage() {
title="退出登录"
content="确定要退出登录吗?"
onCancel={Toast.hideModal}
onConfirm={async () => {
await signOut()
Toast.show({ title: '已退出登录' })
@ -45,6 +43,7 @@ export default observer(function SettingsPage() {
router.push({
pathname: '/webview',
params: { url: 'https://mixvideo.bowong.cc/terms', title: '服务条款' },
// params: { url: 'https://google.com', title: '服务条款' },
})
},
},
@ -78,9 +77,7 @@ export default observer(function SettingsPage() {
}
const renderHeader = () => (
<Block
className="flex-row items-center justify-between px-[16px] py-[10px]"
>
<Block className="flex-row items-center justify-between px-[16px] py-[10px]">
<Block className="ml-[-8px] size-[40px] items-center justify-center" opacity={0.7} onClick={() => router.back()}>
<Ionicons color="black" name="chevron-back" size={24} />
</Block>
@ -90,17 +87,10 @@ export default observer(function SettingsPage() {
)
const renderUserSection = () => (
<Block
className="flex-row items-center gap-[12px] px-[16px] py-[10px]"
onClick={handleUserProfileClick}
>
<Block className="flex-row items-center gap-[12px] px-[16px] py-[10px]" onClick={handleUserProfileClick}>
<Block className="size-[60px] items-center justify-center overflow-hidden rounded-full bg-gray-200">
{user?.image ? (
<Img
src={user.image}
style={{ width: 60, height: 60, borderRadius: 30 }}
width={60}
/>
<Img src={user.image} style={{ width: 60, height: 60, borderRadius: 30 }} width={60} />
) : (
<Ionicons color="#9CA3AF" name="person" size={32} />
)}
@ -118,13 +108,10 @@ export default observer(function SettingsPage() {
const renderMenuSection = () => (
<Block className="mt-[8px]">
<Text className="px-[20px] py-[8px] text-[12px] text-[#9D9D9D]">使</Text>
<Block className="bg-white mx-[16px] rounded-xl">
<Block className="mx-[16px] rounded-xl bg-white">
{menuItems.map((item) => (
<Block key={item.id}>
<Block
className="flex-row items-center gap-[12px] px-[16px] py-[16px]"
onClick={item.onPress}
>
<Block className="flex-row items-center gap-[12px] p-[16px]" onClick={item.onPress}>
<Ionicons color="#666" name={item.icon} size={22} />
<Text className="flex-1 text-[14px] text-black">{item.label}</Text>
<Ionicons color="#9CA3AF" name="chevron-forward" size={20} />
@ -137,17 +124,14 @@ export default observer(function SettingsPage() {
const renderLogoutButton = () => (
<Block className="mt-[40px] items-center px-[16px]">
<Block
className="w-full items-center justify-center rounded-xl bg-white py-[14px]"
onClick={handleLogout}
>
<Text className="text-[14px] font-[600] text-black">退</Text>
</Block>
<Block className="w-full items-center justify-center rounded-xl bg-white py-[14px]" onClick={handleLogout}>
<Text className="text-[14px] font-[600] text-black">退</Text>
</Block>
</Block>
)
return (
<Block className="flex-1 bg-[#fafafa] h-full">
<Block className="h-full flex-1 bg-[#fafafa]">
<Stack.Screen options={{ headerShown: false }} />
{renderHeader()}
<ScrollView contentContainerStyle={{ flexGrow: 1 }} showsVerticalScrollIndicator={false}>

View File

@ -196,11 +196,7 @@ export default function ChangePasswordModal({ onConfirm, onCancel }: ChangePassw
className="absolute right-[12px] top-1/2 -translate-y-1/2"
onClick={() => setShowCurrentPassword(!showCurrentPassword)}
>
<Ionicons
color="#9CA3AF"
name={showCurrentPassword ? 'eye-off-outline' : 'eye-outline'}
size={20}
/>
<Ionicons color="#9CA3AF" name={showCurrentPassword ? 'eye-off-outline' : 'eye-outline'} size={20} />
</Block>
</Block>
{errors.currentPassword && (
@ -230,16 +226,10 @@ export default function ChangePasswordModal({ onConfirm, onCancel }: ChangePassw
className="absolute right-[12px] top-1/2 -translate-y-1/2"
onClick={() => setShowNewPassword(!showNewPassword)}
>
<Ionicons
color="#9CA3AF"
name={showNewPassword ? 'eye-off-outline' : 'eye-outline'}
size={20}
/>
<Ionicons color="#9CA3AF" name={showNewPassword ? 'eye-off-outline' : 'eye-outline'} size={20} />
</Block>
</Block>
{errors.newPassword && (
<Text className="mt-[4px] text-[12px] text-red-500">{errors.newPassword}</Text>
)}
{errors.newPassword && <Text className="mt-[4px] text-[12px] text-red-500">{errors.newPassword}</Text>}
</Block>
<Block className="w-full">
<Text className="mb-[8px] text-[14px] text-black"></Text>
@ -264,11 +254,7 @@ export default function ChangePasswordModal({ onConfirm, onCancel }: ChangePassw
className="absolute right-[12px] top-1/2 -translate-y-1/2"
onClick={() => setShowConfirmPassword(!showConfirmPassword)}
>
<Ionicons
color="#9CA3AF"
name={showConfirmPassword ? 'eye-off-outline' : 'eye-outline'}
size={20}
/>
<Ionicons color="#9CA3AF" name={showConfirmPassword ? 'eye-off-outline' : 'eye-outline'} size={20} />
</Block>
</Block>
{errors.confirmPassword && (

View File

@ -128,5 +128,4 @@ export const {
phoneNumber,
} = authClient
export const subscription: ISubscription = Reflect.get(authClient, 'subscription')