u
This commit is contained in:
1 parent
26ff2381b7
commit
00a1cce5ac
22 files changed
+335
-215
No files matched your search
@@ -1,39 +0,0 @@
|
||||
import { useNavigation } from 'expo-router'
|
||||
import React, { useState } from 'react'
|
||||
import { Text, View } from 'react-native'
|
||||
import { AButton, AModal } from '@/components/common/ao'
|
||||
import AnimatedSwitch from '@/components/common/ao/Switch'
|
||||
import { useSpaceStore } from '@/store/space'
|
||||
|
||||
export default function TestScreen() {
|
||||
const [showDissolve, setShowDissolve] = useState(false)
|
||||
const spaceStore = useSpaceStore()
|
||||
const navigation = useNavigation()
|
||||
|
||||
console.log(navigation.getState()?.routeNames)
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
||||
<AButton onPress={() => {
|
||||
setShowDissolve(true)
|
||||
}}
|
||||
>
|
||||
{spaceStore.currentSpace?.space_id}
|
||||
</AButton>
|
||||
<AModal
|
||||
title="提示"
|
||||
body="确认解散该空间么?"
|
||||
isOpen={showDissolve}
|
||||
onClose={() => {
|
||||
setShowDissolve(false)
|
||||
}}
|
||||
onCancel={() => {
|
||||
setShowDissolve(false)
|
||||
}}
|
||||
onConfirm={() => {
|
||||
setShowDissolve(false)
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -28,7 +28,7 @@ export default function Index() {
|
||||
<AButton
|
||||
className="w-full"
|
||||
onPress={() => {
|
||||
navStore.navigateTo('finance/index')
|
||||
navStore.navigateTo('finance')
|
||||
}}
|
||||
>
|
||||
开始使用
|
||||
|
||||
@@ -25,7 +25,7 @@ export default function User() {
|
||||
</View>
|
||||
|
||||
<View className="mt-8 flex flex-col">
|
||||
<ListItem icon="Earth" text="共享空间" href="/system/share" />
|
||||
{/* <ListItem icon="Earth" text="共享空间" href="/system/share" /> */}
|
||||
<ListItem icon="Settings" text="设置"href="/system/settings" />
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEvent } from 'expo'
|
||||
// import ExpoQQ from 'expo-qq'
|
||||
import ExpoQQ from 'expo-qq'
|
||||
import { useNavigation, useRouter } from 'expo-router'
|
||||
// import ExpoWeChat from 'expo-wechat'
|
||||
import ExpoWeChat from 'expo-wechat'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Image, Text, View } from 'react-native'
|
||||
import { toast } from 'sonner-native'
|
||||
@@ -28,153 +28,153 @@ export default function Auth() {
|
||||
const router = useRouter()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// const onLoginFinished = useEvent(ExpoQQ, 'onLoginFinished')
|
||||
// const onGetUserInfo = useEvent(ExpoQQ, 'onGetUserInfo')
|
||||
// const authResult = useEvent(ExpoWeChat, 'onAuthResult')
|
||||
const onLoginFinished = useEvent(ExpoQQ, 'onLoginFinished')
|
||||
const onGetUserInfo = useEvent(ExpoQQ, 'onGetUserInfo')
|
||||
const authResult = useEvent(ExpoWeChat, 'onAuthResult')
|
||||
|
||||
// async function onQQLogin() {
|
||||
// setLoading(true)
|
||||
// setForm(val => ({
|
||||
// ...val,
|
||||
// type: 1,
|
||||
// }))
|
||||
// await ExpoQQ.login(['get_user_info'])
|
||||
// }
|
||||
async function onQQLogin() {
|
||||
setLoading(true)
|
||||
setForm(val => ({
|
||||
...val,
|
||||
type: 1,
|
||||
}))
|
||||
await ExpoQQ.login(['get_user_info'])
|
||||
}
|
||||
|
||||
// async function onWeChatLogin() {
|
||||
// setLoading(true)
|
||||
async function onWeChatLogin() {
|
||||
setLoading(true)
|
||||
|
||||
// // 检查微信是否安装
|
||||
// const isInstalled = await ExpoWeChat.isWXAppInstalled()
|
||||
// if (!isInstalled) {
|
||||
// toast.warning(onLoginFinished?.errorMessage || '请先安装微信')
|
||||
// setLoading(false)
|
||||
// return
|
||||
// }
|
||||
// 检查微信是否安装
|
||||
const isInstalled = await ExpoWeChat.isWXAppInstalled()
|
||||
if (!isInstalled) {
|
||||
toast.warning(onLoginFinished?.errorMessage || '请先安装微信')
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
// setForm(val => ({
|
||||
// ...val,
|
||||
// type: 0,
|
||||
// }))
|
||||
setForm(val => ({
|
||||
...val,
|
||||
type: 0,
|
||||
}))
|
||||
|
||||
// ExpoWeChat.sendAuthRequest('snsapi_userinfo', 'state123')
|
||||
// }
|
||||
ExpoWeChat.sendAuthRequest('snsapi_userinfo', 'state123')
|
||||
}
|
||||
|
||||
// useEffect(() => {
|
||||
// ExpoQQ.init('102826474', '')
|
||||
// ExpoWeChat.registerApp('wxdab3e21a1f7e392f', '')
|
||||
// }, [])
|
||||
useEffect(() => {
|
||||
ExpoQQ.init('102826474', '')
|
||||
ExpoWeChat.registerApp('wxdab3e21a1f7e392f', '')
|
||||
}, [])
|
||||
|
||||
// useEffect(() => {
|
||||
// if (!onLoginFinished) {
|
||||
// return
|
||||
// }
|
||||
useEffect(() => {
|
||||
if (!onLoginFinished) {
|
||||
return
|
||||
}
|
||||
|
||||
// if (!onLoginFinished.success) {
|
||||
// toast.warning(onLoginFinished?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权')
|
||||
// setLoading(false)
|
||||
// return
|
||||
// }
|
||||
if (!onLoginFinished.success) {
|
||||
toast.warning(onLoginFinished?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权')
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
// const fetchUserInfo = async () => {
|
||||
// try {
|
||||
// const tokenInfo = await ExpoQQ.getLoginTokenInfo()
|
||||
// if (!tokenInfo.openId) {
|
||||
// toast.warning(tokenInfo?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权')
|
||||
// setLoading(false)
|
||||
// return
|
||||
// }
|
||||
const fetchUserInfo = async () => {
|
||||
try {
|
||||
const tokenInfo = await ExpoQQ.getLoginTokenInfo()
|
||||
if (!tokenInfo.openId) {
|
||||
toast.warning(tokenInfo?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权')
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
// setForm(val => ({
|
||||
// ...val,
|
||||
// openid: String(tokenInfo.openId),
|
||||
// }))
|
||||
setForm(val => ({
|
||||
...val,
|
||||
openid: String(tokenInfo.openId),
|
||||
}))
|
||||
|
||||
// await ExpoQQ.sendGetUserInfoReq()
|
||||
// }
|
||||
// catch (e) {
|
||||
// console.error('QQ 登录未完成', e)
|
||||
// setLoading(false)
|
||||
// }
|
||||
// }
|
||||
await ExpoQQ.sendGetUserInfoReq()
|
||||
}
|
||||
catch (e) {
|
||||
console.error('QQ 登录未完成', e)
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
// fetchUserInfo()
|
||||
// }, [onLoginFinished])
|
||||
fetchUserInfo()
|
||||
}, [onLoginFinished])
|
||||
|
||||
// // QQ登录
|
||||
// useEffect(() => {
|
||||
// const handleLogin = async () => {
|
||||
// if (!onGetUserInfo)
|
||||
// return
|
||||
// QQ登录
|
||||
useEffect(() => {
|
||||
const handleLogin = async () => {
|
||||
if (!onGetUserInfo)
|
||||
return
|
||||
|
||||
// try {
|
||||
// const loginRes = await loginQqApi({
|
||||
// openid: form.openid,
|
||||
// nickname: onGetUserInfo.nickname || '',
|
||||
// avatar: onGetUserInfo.figureurlQq_2 || onGetUserInfo.figureurl_2,
|
||||
// })
|
||||
try {
|
||||
const loginRes = await loginQqApi({
|
||||
openid: form.openid,
|
||||
nickname: onGetUserInfo.nickname || '',
|
||||
avatar: onGetUserInfo.figureurlQq_2 || onGetUserInfo.figureurl_2,
|
||||
})
|
||||
|
||||
// console.log(loginRes)
|
||||
console.log(loginRes)
|
||||
|
||||
// if (loginRes.isSuccess) {
|
||||
// userStore.setUserInfo({
|
||||
// token: loginRes.data.token,
|
||||
// id: loginRes.data.userId,
|
||||
// nickname: loginRes.data.nickname,
|
||||
// avatar: loginRes.data.avatar,
|
||||
// })
|
||||
// await appStore.init()
|
||||
// }
|
||||
// }
|
||||
// catch (err) {
|
||||
// console.error('登录接口出错', err)
|
||||
// }
|
||||
// finally {
|
||||
// setLoading(false)
|
||||
// }
|
||||
// }
|
||||
if (loginRes.isSuccess) {
|
||||
userStore.setUserInfo({
|
||||
token: loginRes.data.token,
|
||||
id: loginRes.data.userId,
|
||||
nickname: loginRes.data.nickname,
|
||||
avatar: loginRes.data.avatar,
|
||||
})
|
||||
await appStore.init()
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.error('登录接口出错', err)
|
||||
}
|
||||
finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
// handleLogin()
|
||||
// }, [onGetUserInfo])
|
||||
handleLogin()
|
||||
}, [onGetUserInfo])
|
||||
|
||||
// // 微信登录
|
||||
// useEffect(() => {
|
||||
// if (!authResult)
|
||||
// return
|
||||
// 微信登录
|
||||
useEffect(() => {
|
||||
if (!authResult)
|
||||
return
|
||||
|
||||
// const handleLogin = async () => {
|
||||
// if (authResult.errorCode === 0) {
|
||||
// try {
|
||||
// const loginRes = await loginWxApi({
|
||||
// code: authResult.code,
|
||||
// })
|
||||
const handleLogin = async () => {
|
||||
if (authResult.errorCode === 0) {
|
||||
try {
|
||||
const loginRes = await loginWxApi({
|
||||
code: authResult.code,
|
||||
})
|
||||
|
||||
// if (loginRes.isSuccess) {
|
||||
// userStore.setUserInfo({
|
||||
// token: loginRes.data.token,
|
||||
// id: loginRes.data.userId,
|
||||
// nickname: loginRes.data.nickname,
|
||||
// avatar: loginRes.data.avatar,
|
||||
// })
|
||||
if (loginRes.isSuccess) {
|
||||
userStore.setUserInfo({
|
||||
token: loginRes.data.token,
|
||||
id: loginRes.data.userId,
|
||||
nickname: loginRes.data.nickname,
|
||||
avatar: loginRes.data.avatar,
|
||||
})
|
||||
|
||||
// await appStore.init()
|
||||
// }
|
||||
// }
|
||||
// catch (err) {
|
||||
// console.error('登录接口出错', err)
|
||||
// }
|
||||
// finally {
|
||||
// setLoading(false)
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// console.log('授权失败:', authResult.errorMessage)
|
||||
// setLoading(false)
|
||||
// }
|
||||
// }
|
||||
await appStore.init()
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.error('登录接口出错', err)
|
||||
}
|
||||
finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log('授权失败:', authResult.errorMessage)
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
// handleLogin()
|
||||
// }, [authResult])
|
||||
handleLogin()
|
||||
}, [authResult])
|
||||
|
||||
async function testLogin() {
|
||||
// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3NjY3ODU5ODIxNjUwNjEsImlhdCI6MTc2OTM0ODI0Nn0.17ZNaHD3HSLM8dVn_JQK-gvsG9MKj47IRYV9D4xZkzs
|
||||
@@ -216,7 +216,7 @@ export default function Auth() {
|
||||
</View>
|
||||
|
||||
<View className="flex flex-col gap-4">
|
||||
{/* <AButton
|
||||
<AButton
|
||||
leftIcon={
|
||||
<IconWeixin color="#fff" />
|
||||
}
|
||||
@@ -235,20 +235,19 @@ export default function Auth() {
|
||||
onPress={onQQLogin}
|
||||
>
|
||||
QQ
|
||||
</AButton> */}
|
||||
|
||||
<AButton
|
||||
variant="outline"
|
||||
leftIcon={
|
||||
<IconQq />
|
||||
}
|
||||
loading={loading}
|
||||
onPress={testLogin}
|
||||
>
|
||||
模拟登录
|
||||
</AButton>
|
||||
</View>
|
||||
|
||||
{/* <AButton
|
||||
variant="outline"
|
||||
leftIcon={
|
||||
<IconQq />
|
||||
}
|
||||
onPress={testLogin}
|
||||
>
|
||||
QQ
|
||||
</AButton> */}
|
||||
|
||||
<View className="mt-10 items-center flex flex-row justify-center">
|
||||
<ACheckbox
|
||||
checked={isAgree}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import React, { useState } from 'react'
|
||||
import { Pressable, Text, View } from 'react-native'
|
||||
import { KeyboardAvoidingView } from 'react-native-keyboard-controller'
|
||||
import { AInput, LucideIcon } from '@/components/common/ao'
|
||||
import CustomHeader from '@/components/custom/Header'
|
||||
|
||||
export default function TestScreen() {
|
||||
const [value, setValue] = useState('')
|
||||
const [height, setHeight] = useState(40)
|
||||
|
||||
const handleContentSizeChange = (event: any) => {
|
||||
const newHeight = Math.min(100, Math.max(40, event.nativeEvent.contentSize.height))
|
||||
setHeight(newHeight)
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="flex-1 bg-white ">
|
||||
<CustomHeader showHeader={false} />
|
||||
|
||||
<KeyboardAvoidingView
|
||||
behavior="padding"
|
||||
className="flex-1"
|
||||
>
|
||||
<View className="flex-row items-center justify-between h-14 px-3 border-b border-gray-100">
|
||||
{/* 左侧 */}
|
||||
<View className="flex-row items-center gap-2">
|
||||
<Pressable className="w-10 h-10 items-center justify-center rounded-full">
|
||||
<LucideIcon icon="ChevronLeft" size={28} color="#111827" />
|
||||
</Pressable>
|
||||
|
||||
<Text className="text-base font-semibold text-gray-900">
|
||||
聊天室
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
{/* 右侧 */}
|
||||
<View className="flex-row items-center gap-3">
|
||||
|
||||
<Pressable className="w-9 h-9 items-center justify-center rounded-full bg-[#f9f9f9]">
|
||||
<LucideIcon icon="TvMinimalPlay" size={18} color="#374151" />
|
||||
</Pressable>
|
||||
|
||||
<Pressable className="w-9 h-9 items-center justify-center rounded-full bg-[#f9f9f9]">
|
||||
<LucideIcon icon="Phone" size={18} color="#374151" />
|
||||
</Pressable>
|
||||
|
||||
<Pressable className="w-9 h-9 items-center justify-center rounded-full bg-[#f9f9f9]">
|
||||
<LucideIcon icon="Ellipsis" size={18} color="#374151" />
|
||||
</Pressable>
|
||||
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="flex-1">
|
||||
|
||||
</View>
|
||||
|
||||
<View
|
||||
className="m-4 flex-row px-3 items-center bg-[#f6f6f7] rounded-full"
|
||||
>
|
||||
<LucideIcon icon="Mic" size={24} />
|
||||
|
||||
<AInput
|
||||
placeholder="请输入消息"
|
||||
className="flex-1 py-2"
|
||||
style={{
|
||||
borderWidth: 0,
|
||||
height,
|
||||
}}
|
||||
multiline={true}
|
||||
onContentSizeChange={handleContentSizeChange}
|
||||
/>
|
||||
|
||||
<LucideIcon icon="Smile" size={24} />
|
||||
<LucideIcon icon="CirclePlus" size={24} className="ml-3" />
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -17,6 +17,8 @@ export interface AInputProps extends Omit<TextInputProps, 'onChange'> {
|
||||
leftIcon?: ComponentType
|
||||
className?: string
|
||||
style?: StyleProp<ViewStyle>
|
||||
inputClassName?: string
|
||||
inputStyle?: StyleProp<ViewStyle>
|
||||
}
|
||||
|
||||
const AInput = forwardRef<React.ComponentRef<typeof InputField>, AInputProps>(
|
||||
@@ -32,6 +34,8 @@ const AInput = forwardRef<React.ComponentRef<typeof InputField>, AInputProps>(
|
||||
leftIcon,
|
||||
className,
|
||||
style,
|
||||
inputClassName,
|
||||
inputStyle,
|
||||
...rest
|
||||
}, ref) => {
|
||||
const [showPassword, setShowPassword] = useState(false)
|
||||
@@ -56,6 +60,8 @@ const AInput = forwardRef<React.ComponentRef<typeof InputField>, AInputProps>(
|
||||
|
||||
<InputField
|
||||
ref={ref}
|
||||
className={inputClassName}
|
||||
style={inputStyle}
|
||||
type={isPassword ? (showPassword ? 'text' : 'password') : 'text'}
|
||||
{...rest}
|
||||
/>
|
||||
|
||||
@@ -31,7 +31,7 @@ function isWhiteListed(url: string) {
|
||||
}
|
||||
|
||||
const alovaInstance = createAlova({
|
||||
baseURL: 'http://192.168.5.6:8086/app',
|
||||
baseURL: 'https://www.oneao.cn/app',
|
||||
// baseURL: 'http://192.168.1.137:8086/app',
|
||||
requestAdapter: axiosRequestAdapter(),
|
||||
timeout: 5000,
|
||||
|
||||
@@ -20,8 +20,8 @@ interface NavState {
|
||||
|
||||
const DEFAULT_NAV_MENUS: NavItem[] = [
|
||||
{ label: '记账', path: '/finance', icon: 'CircleDollarSign' },
|
||||
{ label: '恋爱记', path: '/love', icon: 'Heart' },
|
||||
{ label: '聊天', path: '/chat', icon: 'MessageCircle' },
|
||||
// { label: '恋爱记', path: '/love', icon: 'Heart' },
|
||||
// { label: '聊天', path: '/chat', icon: 'MessageCircle' },
|
||||
{ label: '个人中心', path: '/user', icon: 'CircleUserRound' },
|
||||
{ label: '空间管理', path: '/space', icon: 'Earth' },
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user