|
|
1 ヶ月 前 | |
|---|---|---|
| .. | ||
| README.md | 1 ヶ月 前 | |
| package.json | 1 ヶ月 前 | |
cd mobile
# 安装依赖(使用pnpm)
pnpm install
# iOS(需要Mac)
cd ios
pod install
cd ..
pnpm ios
# Android
pnpm android
src/
├── screens/ # 页面
│ ├── Auth/
│ │ ├── Login.tsx
│ │ └── Register.tsx
│ ├── CharacterList.tsx
│ ├── ChatScreen.tsx
│ └── Profile.tsx
├── components/ # 组件
│ ├── MessageBubble.tsx
│ ├── CharacterCard.tsx
│ └── AffectionBar.tsx
├── services/ # API服务
│ ├── api.ts
│ └── auth.ts
├── stores/ # Zustand状态
│ ├── authStore.ts
│ └── chatStore.ts
├── types/ # TypeScript类型
└── locales/ # 国际化
├── en.json
└── zh.json
// services/api.ts
import axios from 'axios';
const api = axios.create({
baseURL: 'http://localhost:8000/api',
});
export const login = async (username: string, password: string) => {
const response = await api.post('/auth/login', { username, password });
return response.data;
};
export const sendMessage = async (conversationId: number, content: string, token: string) => {
const response = await api.post(
`/conversations/${conversationId}/messages`,
{ content },
{ headers: { Authorization: `Bearer ${token}` } }
);
return response.data;
};
运行以下命令初始化React Native项目:
npx react-native init AIChatApp --template react-native-template-typescript
然后将配置文件复制到新创建的项目中。