🎉 限时特惠活动公告、获取优惠码、最高立减3200元
跨平台移动端应用开发文档
版本:v4.7.0
server/public/mobile/,直接部署即可server/public/weapp/ 目录manifest.json 中配置代理,或使用后端配置CORS| 技术 | 版本 | 说明 |
|---|---|---|
| uni-app | 3.0.0 | 跨平台框架 |
| Vue | 3.2.45 | 前端框架 |
| TypeScript | 4.x | 类型系统 |
| Vite | 3.x | 构建工具 |
| Pinia | 2.0.20 | 状态管理 |
| uView UI | 2.x | UI组件库 |
uniapp/
├── scripts/ # 构建脚本
│ ├── develop.js # 开发环境脚本
│ ├── publish.js # 发布脚本
│ └── release.mjs # 发布处理
├── src/
│ ├── api/ # API接口
│ │ ├── chat.ts # 对话相关
│ │ ├── draw.ts # 绘画相关
│ │ ├── user.ts # 用户相关
│ │ ├── robot.ts # 机器人相关
│ │ ├── kb.ts # 知识库相关
│ │ ├── video.ts # 视频相关
│ │ ├── music.ts # 音乐相关
│ │ ├── ai_ppt.ts # PPT相关
│ │ └── ...
│ ├── assets/ # 静态资源
│ │ └── svg-icons/ # SVG图标
│ ├── components/ # 公共组件
│ │ ├── chat-input/ # 聊天输入框
│ │ ├── ua-markdown/ # Markdown渲染
│ │ ├── tabbar/ # 底部导航
│ │ ├── audio-play/ # 音频播放
│ │ └── ...
│ ├── config/ # 配置文件
│ │ └── index.ts # 全局配置
│ ├── enums/ # 枚举定义
│ │ ├── appEnums.ts # 应用枚举
│ │ ├── chatEnums.ts # 对话枚举
│ │ └── requestEnums.ts # 请求枚举
│ ├── hooks/ # 组合式函数
│ │ ├── useAudio.ts # 音频处理
│ │ ├── useRecorder.ts # 录音功能
│ │ ├── useCopy.ts # 复制功能
│ │ └── ...
│ ├── lib/ # 第三方库
│ ├── mixins/ # 混入
│ ├── packages/ # 分包
│ │ ├── components/ # 分包组件
│ │ ├── pages/ # 分包页面
│ │ └── static/ # 分包静态资源
│ ├── pages/ # 主包页面
│ │ ├── index/ # 首页
│ │ ├── kb/ # 知识库
│ │ ├── user/ # 个人中心
│ │ ├── login/ # 登录
│ │ └── ...
│ ├── plugins/ # 插件
│ │ ├── modules/ # 插件模块
│ │ └── index.ts # 插件入口
│ ├── router/ # 路由配置
│ │ └── index.ts # 路由实例
│ ├── static/ # 静态资源
│ ├── stores/ # Pinia状态管理
│ │ ├── app.ts # 应用状态
│ │ ├── user.ts # 用户状态
│ │ ├── chat.ts # 对话状态
│ │ └── ...
│ ├── utils/ # 工具函数
│ │ ├── request/ # 请求封装
│ │ ├── pay/ # 支付相关
│ │ └── ...
│ ├── App.vue # 应用入口
│ ├── main.ts # 主入口
│ ├── manifest.json # 应用配置
│ ├── pages.json # 页面配置
│ └── package.json # 分包配置
├── .env.development # 开发环境变量
├── .env.production # 生产环境变量
├── index.html # H5入口
└── package.json # 项目配置| 模块 | 文件 | 功能 |
|---|---|---|
| 对话 | api/chat.ts | 聊天、历史记录、清空会话 |
| 绘画 | api/draw.ts | 文生图、图生图、任务查询 |
| 用户 | api/user.ts | 登录、注册、用户信息 |
| 机器人 | api/robot.ts | 智能体列表、详情、对话 |
| 知识库 | api/kb.ts | 知识库管理、文档上传 |
| 视频 | api/video.ts | 视频生成、任务查询 |
| 音乐 | api/music.ts | 音乐生成、播放 |
| PPT | api/ai_ppt.ts | PPT生成、历史记录 |
| 支付 | api/pay.ts | 微信支付、支付宝 |
| 充值 | api/recharge.ts | 充值套餐、记录 |
<template>
<chat-input
v-model="message"
:loading="loading"
:show-voice="true"
:show-file="true"
@send="handleSend"
@voice="handleVoice"
@file="handleFile"
/>
</template>
<script setup lang="ts">
import ChatInput from '@/components/chat-input/chat-input.vue'
const message = ref('')
const loading = ref(false)
function handleSend(text: string) {
// 发送消息
}
function handleVoice(file: string) {
// 语音输入
}
function handleFile(files: File[]) {
// 文件上传
}
</script><template>
<ua-markdown
:content="content"
:theme="theme"
@link-click="handleLinkClick"
/>
</template>
<script setup lang="ts">
import UaMarkdown from '@/components/ua-markdown/ua-markdown.vue'
const content = ref('# Hello\n\n这是Markdown内容')
const theme = ref('light')
function handleLinkClick(url: string) {
uni.navigateTo({ url: `/pages/webview/webview?url=${encodeURIComponent(url)}` })
}
</script><template>
<audio-play
:src="audioUrl"
:autoplay="false"
@play="onPlay"
@pause="onPause"
@ended="onEnded"
/>
</template>
<script setup lang="ts">
import AudioPlay from '@/components/audio-play/audio-play.vue'
const audioUrl = ref('https://example.com/audio.mp3')
</script><script setup lang="ts">
import { useUserStore } from '@/stores/user'
import { storeToRefs } from 'pinia'
const userStore = useUserStore()
// 使用storeToRefs保持响应式
const { userInfo, isLogin } = storeToRefs(userStore)
// 直接调用action
async function handleLogin() {
await userStore.login({
account: 'user',
password: '123456'
})
}
</script>