feat: 初始化项目,基于 ai-chat-app v3.14.4
This commit is contained in:
12
.gitignore
vendored
Normal file
12
.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
.Python
|
||||
*.so
|
||||
*.egg-info/
|
||||
dist/
|
||||
build/
|
||||
*.db
|
||||
data.db
|
||||
node_modules/
|
||||
56
README.md
Normal file
56
README.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# AI对话助手移动端应用
|
||||
|
||||
基于 Capacitor 的 AI 对话助手,可打包为 Android/iOS 应用。
|
||||
|
||||
## 功能
|
||||
|
||||
- 💬 AI 对话(智谱 GLM-4.5-Air)
|
||||
- 📱 移动端优化界面
|
||||
- 💾 本地对话历史
|
||||
- 🚀 一键打包 APK/IPA
|
||||
|
||||
## 开发
|
||||
|
||||
```bash
|
||||
# 安装依赖
|
||||
npm install
|
||||
|
||||
# 启动本地服务器
|
||||
npm run dev
|
||||
|
||||
# 访问 http://localhost:19019
|
||||
```
|
||||
|
||||
## 打包移动端
|
||||
|
||||
```bash
|
||||
# 添加平台
|
||||
npx cap add android
|
||||
npx cap add ios
|
||||
|
||||
# 同步代码
|
||||
npm run build:android
|
||||
npm run build:ios
|
||||
|
||||
# 打开原生项目
|
||||
npm run open:android # 需要 Android Studio
|
||||
npm run open:ios # 需要 Xcode (macOS)
|
||||
```
|
||||
|
||||
## 配置
|
||||
|
||||
- 端口: 19019
|
||||
- 模型: GLM-4.5-Air
|
||||
- API: 智谱开放平台
|
||||
|
||||
## 目录结构
|
||||
|
||||
```
|
||||
www/ # 前端代码
|
||||
├── index.html # 主页面
|
||||
├── app.js # 应用逻辑
|
||||
├── style.css # 样式
|
||||
└── manifest.json # PWA 配置
|
||||
android/ # Android 项目(自动生成)
|
||||
ios/ # iOS 项目(自动生成)
|
||||
```
|
||||
1468
backend/app.py
Normal file
1468
backend/app.py
Normal file
File diff suppressed because it is too large
Load Diff
2
backend/requirements.txt
Normal file
2
backend/requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
flask>=2.0.0
|
||||
flask-cors>=3.0.0
|
||||
4
backend/start.sh
Executable file
4
backend/start.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
cd "$(dirname "$0")"
|
||||
pip install -r requirements.txt -q
|
||||
python app.py
|
||||
15
capacitor.config.json
Normal file
15
capacitor.config.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"appId": "com.tphai.aichat",
|
||||
"appName": "AI助手",
|
||||
"webDir": "www",
|
||||
"server": {
|
||||
"androidScheme": "https"
|
||||
},
|
||||
"plugins": {
|
||||
"SplashScreen": {
|
||||
"launchShowDuration": 2000,
|
||||
"backgroundColor": "#667eea",
|
||||
"showSpinner": false
|
||||
}
|
||||
}
|
||||
}
|
||||
20
package.json
Normal file
20
package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "ai-chat-app",
|
||||
"version": "1.0.0",
|
||||
"description": "AI对话助手移动端应用",
|
||||
"scripts": {
|
||||
"dev": "npx http-server -p 19021 -c-1",
|
||||
"build:android": "npx cap sync android",
|
||||
"build:ios": "npx cap sync ios",
|
||||
"open:android": "npx cap open android",
|
||||
"open:ios": "npx cap open ios"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@capacitor/cli": "^6.0.0",
|
||||
"@capacitor/core": "^6.0.0",
|
||||
"@capacitor/android": "^6.0.0",
|
||||
"@capacitor/ios": "^6.0.0",
|
||||
"http-server": "^14.1.1"
|
||||
}
|
||||
}
|
||||
482
www/admin.html
Normal file
482
www/admin.html
Normal file
@@ -0,0 +1,482 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AI助手 - 后台管理</title>
|
||||
<link rel="stylesheet" href="admin.css?v=3.6.6">
|
||||
<style>
|
||||
:root {
|
||||
--primary: #667eea;
|
||||
--primary-dark: #5a67d8;
|
||||
--bg-color: #f5f7fa;
|
||||
--card-bg: #ffffff;
|
||||
--text-color: #2d3748;
|
||||
--text-light: #718096;
|
||||
--border-color: #e2e8f0;
|
||||
--danger: #e53e3e;
|
||||
--success: #22c55e;
|
||||
--warning: #f59e0b;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
background: var(--bg-color);
|
||||
color: var(--text-color);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* 登录页面 */
|
||||
.login-page {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
|
||||
}
|
||||
|
||||
.login-card {
|
||||
background: white;
|
||||
padding: 40px;
|
||||
border-radius: 16px;
|
||||
width: 350px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.login-logo {
|
||||
font-size: 48px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.login-input {
|
||||
width: 100%;
|
||||
padding: 12px 16px;
|
||||
border: 2px solid var(--border-color);
|
||||
border-radius: 10px;
|
||||
font-size: 16px;
|
||||
margin-bottom: 16px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.login-input:focus {
|
||||
border-color: var(--primary);
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
width: 100%;
|
||||
padding: 14px;
|
||||
background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.login-btn:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
/* 主页面 */
|
||||
.admin-page {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.admin-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16px 24px;
|
||||
background: white;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.admin-logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.admin-logo span {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.admin-header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.admin-logout {
|
||||
padding: 8px 16px;
|
||||
background: var(--danger);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* 侧边栏 */
|
||||
.admin-container {
|
||||
display: flex;
|
||||
height: calc(100vh - 60px);
|
||||
}
|
||||
|
||||
.admin-sidebar {
|
||||
width: 220px;
|
||||
background: white;
|
||||
border-right: 1px solid var(--border-color);
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.sidebar-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px 16px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.sidebar-item:hover {
|
||||
background: rgba(102, 126, 234, 0.1);
|
||||
}
|
||||
|
||||
.sidebar-item.active {
|
||||
background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.sidebar-icon {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
/* 内容区 */
|
||||
.admin-content {
|
||||
flex: 1;
|
||||
padding: 24px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.content-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.content-title {
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
padding: 10px 20px;
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* 数据卡片 */
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 16px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-icon {
|
||||
font-size: 32px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 14px;
|
||||
color: var(--text-light);
|
||||
}
|
||||
|
||||
/* 数据表格 */
|
||||
.data-table {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.data-table table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.data-table th, .data-table td {
|
||||
padding: 14px 16px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.data-table th {
|
||||
background: var(--bg-color);
|
||||
font-weight: 600;
|
||||
color: var(--text-light);
|
||||
}
|
||||
|
||||
.data-table tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.data-table tr:hover td {
|
||||
background: rgba(102, 126, 234, 0.05);
|
||||
}
|
||||
|
||||
/* 操作按钮 */
|
||||
.action-btns {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
padding: 6px 12px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.action-btn.edit {
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.action-btn.delete {
|
||||
background: var(--danger);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.action-btn.default {
|
||||
background: var(--success);
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* 默认标记 */
|
||||
.default-badge {
|
||||
padding: 4px 8px;
|
||||
background: var(--success);
|
||||
color: white;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* 模态框 */
|
||||
.modal {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0,0,0,0.5);
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.modal.show {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background: white;
|
||||
padding: 24px;
|
||||
border-radius: 16px;
|
||||
max-width: 500px;
|
||||
width: 90%;
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
font-size: 24px;
|
||||
cursor: pointer;
|
||||
color: var(--text-light);
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.form-input, .form-select, .form-textarea {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.form-input:focus, .form-select:focus, .form-textarea:focus {
|
||||
border-color: var(--primary);
|
||||
}
|
||||
|
||||
.form-textarea {
|
||||
resize: vertical;
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
.form-submit {
|
||||
width: 100%;
|
||||
padding: 14px;
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
/* Toast */
|
||||
.toast {
|
||||
position: fixed;
|
||||
top: 80px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: var(--text-color);
|
||||
color: white;
|
||||
padding: 12px 24px;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s;
|
||||
z-index: 2000;
|
||||
}
|
||||
|
||||
.toast.show {
|
||||
opacity: 1;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- 登录页面 -->
|
||||
<div class="login-page" id="loginPage">
|
||||
<div class="login-card">
|
||||
<div class="login-logo">🤖</div>
|
||||
<h1 class="login-title">后台管理系统</h1>
|
||||
<input type="text" class="login-input" id="loginUsername" placeholder="用户名">
|
||||
<input type="password" class="login-input" id="loginPassword" placeholder="密码">
|
||||
<button class="login-btn" id="loginBtn">登录</button>
|
||||
<p style="margin-top: 16px; color: #999; font-size: 12px;">默认: admin / admin123</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 管理页面 -->
|
||||
<div class="admin-page" id="adminPage">
|
||||
<header class="admin-header">
|
||||
<div class="admin-logo">
|
||||
<span>🤖</span>
|
||||
AI助手 - 后台管理
|
||||
</div>
|
||||
<div class="admin-header-right">
|
||||
<span id="adminName">管理员</span>
|
||||
<button class="admin-logout" id="logoutBtn">退出</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="admin-container">
|
||||
<aside class="admin-sidebar">
|
||||
<div class="sidebar-item active" data-page="stats">
|
||||
<span class="sidebar-icon">📊</span>
|
||||
<span>统计信息</span>
|
||||
</div>
|
||||
<div class="sidebar-item" data-page="users">
|
||||
<span class="sidebar-icon">👥</span>
|
||||
<span>用户管理</span>
|
||||
</div>
|
||||
<div class="sidebar-item" data-page="llm">
|
||||
<span class="sidebar-icon">🧠</span>
|
||||
<span>大模型配置</span>
|
||||
</div>
|
||||
<div class="sidebar-item" data-page="agents">
|
||||
<span class="sidebar-icon">🤖</span>
|
||||
<span>智能体管理</span>
|
||||
</div>
|
||||
<div class="sidebar-item" data-page="chat">
|
||||
<span class="sidebar-icon">💬</span>
|
||||
<span>对话配置</span>
|
||||
</div>
|
||||
<div class="sidebar-item" data-page="tools">
|
||||
<span class="sidebar-icon">🔧</span>
|
||||
<span>工具配置</span>
|
||||
</div>
|
||||
<div class="sidebar-item" data-page="system">
|
||||
<span class="sidebar-icon">⚙️</span>
|
||||
<span>系统设置</span>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<main class="admin-content" id="mainContent">
|
||||
<!-- 内容区动态加载 -->
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Toast -->
|
||||
<div class="toast" id="toast"></div>
|
||||
|
||||
<!-- 模态框 -->
|
||||
<div class="modal" id="modal">
|
||||
<div class="modal-content" id="modalContent">
|
||||
<!-- 动态内容 -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="admin.js?v=3.6.6"></script>
|
||||
</body>
|
||||
</html>
|
||||
1530
www/admin.js
Normal file
1530
www/admin.js
Normal file
File diff suppressed because it is too large
Load Diff
5420
www/app.js
Normal file
5420
www/app.js
Normal file
File diff suppressed because it is too large
Load Diff
19
www/index.html
Normal file
19
www/index.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<meta name="theme-color" content="#667eea">
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Expires" content="0">
|
||||
<title>AI助手</title>
|
||||
<link rel="stylesheet" href="style.css?v=3.5.1">
|
||||
<link rel="manifest" href="manifest.json">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="marked.min.js?v=3.5.1"></script>
|
||||
<script src="app.js?v=3.5.1"></script>
|
||||
</body>
|
||||
</html>
|
||||
22
www/manifest.json
Normal file
22
www/manifest.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "AI助手",
|
||||
"short_name": "AI助手",
|
||||
"description": "AI对话助手移动端应用",
|
||||
"start_url": "/",
|
||||
"display": "standalone",
|
||||
"background_color": "#f7fafc",
|
||||
"theme_color": "#667eea",
|
||||
"orientation": "portrait",
|
||||
"icons": [
|
||||
{
|
||||
"src": "icon-192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "icon-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}
|
||||
]
|
||||
}
|
||||
69
www/marked.min.js
vendored
Normal file
69
www/marked.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3301
www/style.css
Normal file
3301
www/style.css
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user