update:添加前端代码

This commit is contained in:
hrz 2025-03-03 17:26:05 +08:00
parent adaa0fff17
commit a05bc90ce8
55 changed files with 10664 additions and 1834 deletions

1
.gitignore vendored
View file

@ -143,3 +143,4 @@ tmp
.DS_Store .DS_Store
/data /data
/web/node_modules /web/node_modules
web/vue/node_modules

View file

@ -106,14 +106,14 @@ LLM:
# 可在这里找到你的 api_key https://bailian.console.aliyun.com/?apiKey=1#/api-key # 可在这里找到你的 api_key https://bailian.console.aliyun.com/?apiKey=1#/api-key
base_url: https://dashscope.aliyuncs.com/compatible-mode/v1 base_url: https://dashscope.aliyuncs.com/compatible-mode/v1
model_name: qwen-turbo model_name: qwen-turbo
api_key: 你的deepseek api key api_key: 你的deepseek web key
DeepSeekLLM: DeepSeekLLM:
# 定义LLM API类型 # 定义LLM API类型
type: openai type: openai
# 可在这里找到你的api key https://platform.deepseek.com/ # 可在这里找到你的api key https://platform.deepseek.com/
model_name: deepseek-chat model_name: deepseek-chat
url: https://api.deepseek.com url: https://api.deepseek.com
api_key: 你的deepseek api key api_key: 你的deepseek web key
ChatGLMLLM: ChatGLMLLM:
# 定义LLM API类型 # 定义LLM API类型
type: openai type: openai
@ -121,7 +121,7 @@ LLM:
# 可在这里找到你的api key https://bigmodel.cn/usercenter/proj-mgmt/apikeys # 可在这里找到你的api key https://bigmodel.cn/usercenter/proj-mgmt/apikeys
model_name: glm-4-flash model_name: glm-4-flash
url: https://open.bigmodel.cn/api/paas/v4/ url: https://open.bigmodel.cn/api/paas/v4/
api_key: 你的chat-glm api key api_key: 你的chat-glm web key
OllamaLLM: OllamaLLM:
# 定义LLM API类型 # 定义LLM API类型
type: ollama type: ollama
@ -133,14 +133,14 @@ LLM:
# 建议使用本地部署的dify接口,国内部分区域访问dify公有云接口可能会受限 # 建议使用本地部署的dify接口,国内部分区域访问dify公有云接口可能会受限
# 如果使用DifyLLM,配置文件里prompt(提示词)是无效的,需要在dify控制台设置提示词 # 如果使用DifyLLM,配置文件里prompt(提示词)是无效的,需要在dify控制台设置提示词
base_url: https://api.dify.cn/v1 base_url: https://api.dify.cn/v1
api_key: 你的DifyLLM api key api_key: 你的DifyLLM web key
GeminiLLM: GeminiLLM:
type: gemini type: gemini
# 谷歌Gemini API,需要先在Google Cloud控制台创建API密钥并获取api_key # 谷歌Gemini API,需要先在Google Cloud控制台创建API密钥并获取api_key
# 若在中国境内使用,请遵守《生成式人工智能服务管理暂行办法》 # 若在中国境内使用,请遵守《生成式人工智能服务管理暂行办法》
# token申请地址: https://aistudio.google.com/apikey # token申请地址: https://aistudio.google.com/apikey
# 若部署地无法访问接口,需要开启科学上网 # 若部署地无法访问接口,需要开启科学上网
api_key: 你的gemini api key api_key: 你的gemini web key
model_name: "gemini-1.5-pro" # gemini-1.5-pro 是免费的 model_name: "gemini-1.5-pro" # gemini-1.5-pro 是免费的
CozeLLM: CozeLLM:
# 定义LLM API类型 # 定义LLM API类型
@ -197,7 +197,7 @@ TTS:
# token申请地址 https://www.coze.cn/open/oauth/pats # token申请地址 https://www.coze.cn/open/oauth/pats
voice: 7426720361733046281 voice: 7426720361733046281
output_file: tmp/ output_file: tmp/
access_token: 你的coze api key access_token: 你的coze web key
response_format: wav response_format: wav
FishSpeech: FishSpeech:
# 定义TTS API类型 # 定义TTS API类型

1119
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,7 @@ authors = ["kalicyh <34980061+kaliCYH@users.noreply.github.com>"]
readme = "README.md" readme = "README.md"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.10.16" python = "^3.10"
pyyml = "0.0.2" pyyml = "0.0.2"
torch = "2.2.2" torch = "2.2.2"
silero-vad = "5.1.2" silero-vad = "5.1.2"
@ -26,6 +26,14 @@ ruamel-yaml = "0.18.10"
setuptools = "^75.8.0" setuptools = "^75.8.0"
loguru = "^0.7.3" loguru = "^0.7.3"
opuslib-next = "^1.1.2" opuslib-next = "^1.1.2"
fastapi = {extras = ["all"], version = "^0.115.8"}
uvicorn = "^0.34.0"
pyjwt = "^2.10.1"
python-jose = {extras = ["cryptography"], version = "^3.3.0"}
bcrypt = "^4.2.1"
sqlalchemy = "^2.0.38"
pymysql = "^1.1.1"
asyncpg = "^0.30.0"
[build-system] [build-system]

View file

@ -1,25 +0,0 @@
## admin
常用命令
见 `package.json`
`yarn lib`安装依赖
`yarn dev`运行fastapi+react
### 接口文档
```
Swagger UI:服务于 /docs
ReDoc:服务于 /redoc
OpenAPI 模式服务于 /openapi.json
```
![license](https://img.shields.io/badge/license-MIT-blue.svg)
## 技术栈
Minimal UI ([Free version](https://free.minimals.cc/))
[Material Icons](https://mui.com/material-ui/material-icons/)
[sonner](https://sonner.emilkowal.ski/)

0
web/__init__.py Normal file
View file

View file

View file

@ -1,11 +1,11 @@
# api/admin/admin.py # web/admin/admin.py
from fastapi import APIRouter, Depends, HTTPException, status from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from typing import List from typing import List
from api.auth import models, security from web.api.auth import models, security
from api.db.database import get_db from web.api.db.database import get_db
from api.db import models as db_models from web.api.db import models as db_models
router = APIRouter() router = APIRouter()

View file

@ -1,12 +1,12 @@
# api/auth/auth.py # web/auth/auth.py
from fastapi import APIRouter, Depends, HTTPException, status from fastapi import APIRouter, Depends, HTTPException, status
from fastapi.security import OAuth2PasswordRequestForm from fastapi.security import OAuth2PasswordRequestForm
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from datetime import timedelta from datetime import timedelta
from api.auth import models, security from web.api.auth import models, security
from api.db.database import get_db from web.api.db.database import get_db
from api.db import models as db_models from web.api.db import models as db_models
router = APIRouter() router = APIRouter()

View file

@ -1,12 +1,12 @@
# api/auth/dependencies.py # web/auth/dependencies.py
from fastapi import Depends, HTTPException, status from fastapi import Depends, HTTPException, status
from fastapi.security import OAuth2PasswordBearer from fastapi.security import OAuth2PasswordBearer
from jose import JWTError, jwt from jose import JWTError, jwt
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from api.auth import models, security from web.api.auth import security
from api.db.database import get_db from web.api.db.database import get_db
from api.db import models as db_models from web.api.db import models as db_models
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/auth/login") oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/auth/login")

View file

@ -1,4 +1,4 @@
# api/auth/models.py # web/auth/models.py
from pydantic import BaseModel from pydantic import BaseModel
from typing import Optional from typing import Optional

View file

@ -1,4 +1,4 @@
# api/auth/security.py # web/auth/security.py
import bcrypt import bcrypt
from datetime import datetime, timedelta from datetime import datetime, timedelta
from jose import JWTError, jwt from jose import JWTError, jwt

View file

@ -1,14 +1,14 @@
# api/db/database.py # web/db/database.py
import os import os
from sqlalchemy import create_engine from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker
# 获取数据库连接 URL,可通过环境变量设置,例如: # 获取数据库连接 URL,可通过环境变量设置,例如:
# SQLite: sqlite:///./sql_app.db # SQLite: sqlite:///./data/sql_app.db
# PostgreSQL: postgresql+asyncpg://user:password@localhost/dbname # PostgreSQL: postgresql+asyncpg://user:password@localhost/dbname
# MySQL: mysql+pymysql://user:password@localhost/dbname # MySQL: mysql+pymysql://user:password@localhost/dbname
DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///./sql_app.db") DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///./data/sql_app.db")
if DATABASE_URL.startswith("sqlite"): if DATABASE_URL.startswith("sqlite"):
engine = create_engine( engine = create_engine(

View file

@ -1,6 +1,6 @@
# api/db/models.py # web/db/models.py
from sqlalchemy import Column, Integer, String, Boolean from sqlalchemy import Column, Integer, String, Boolean
from api.db.database import Base from web.api.db.database import Base
class User(Base): class User(Base):
__tablename__ = "users" __tablename__ = "users"

View file

@ -1,30 +1,23 @@
# api/main.py # web/main.py
from fastapi import FastAPI, Depends from fastapi import FastAPI, Depends
from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from api.admin import admin from web.api.admin import admin
from api.auth import auth as auth_router from web.api.auth import auth as auth_router
from api.auth.dependencies import get_current_active_user from web.api.auth.dependencies import get_current_active_user
description = """
`VScode`启动! 🚀
"""
app = FastAPI( app = FastAPI(
title="App", title="App",
description=description, description="",
summary="我们生来,就是为了,在宇宙中,留下印记。", summary="你好小智",
version="0.0.1", version="0.0.1",
terms_of_service="https://blog.kalicyh.love/",
contact={ contact={
"name": "kalicyh", "name": "xiaozhi-esp32-server",
"url": "https://blog.kalicyh.love/", "url": "https://github.com/xinnan-tech/xiaozhi-esp32-server",
"email": "kalicyh@qq.com",
}, },
license_info={ license_info={
"name": "MIT", "name": "MIT",
"url": "https://mit-license.org/", "url": "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/LICENSE",
}, },
) )
@ -38,8 +31,8 @@ app.add_middleware(
) )
# 注册认证路由 # 注册认证路由
app.include_router(auth_router.router, prefix="/api/v1/user", tags=["user"]) app.include_router(auth_router.router, prefix="/web/v1/user", tags=["user"])
app.include_router(admin.router, prefix="/api/v1/admin", tags=["admin"]) app.include_router(admin.router, prefix="/web/v1/admin", tags=["admin"])
# 示例:受保护接口,需要 Bearer Token 验证 # 示例:受保护接口,需要 Bearer Token 验证
@app.get("/users/me") @app.get("/users/me")
@ -47,11 +40,12 @@ async def read_users_me(current_user = Depends(get_current_active_user)):
return current_user return current_user
# 挂载 React 静态文件 # 挂载 React 静态文件
app.mount("/", StaticFiles(directory="dist", html=True), name="dist") # app.mount("/", StaticFiles(directory="dist", html=True), name="dist")
# 应用启动时检查并创建数据库表 # 应用启动时检查并创建数据库表
@app.on_event("startup") @app.on_event("startup")
def on_startup(): def on_startup():
from api.db import database, models from web.api.db import models
from web.api.db import database
models.Base.metadata.create_all(bind=database.engine) models.Base.metadata.create_all(bind=database.engine)
print("数据库表检查完成,如果不存在则已创建!") print("数据库表检查完成,如果不存在则已创建!")

1739
web/poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,22 +0,0 @@
[tool.poetry]
name = "esp32-ai-server"
version = "0.1.0"
description = ""
authors = ["kalicyh <34980061+kaliCYH@users.noreply.github.com>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.13"
fastapi = {extras = ["all"], version = "^0.115.8"}
uvicorn = "^0.34.0"
pyjwt = "^2.10.1"
python-jose = {extras = ["cryptography"], version = "^3.3.0"}
bcrypt = "^4.2.1"
sqlalchemy = "^2.0.38"
pymysql = "^1.1.1"
asyncpg = "^0.30.0"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

19
web/vue/README.md Normal file
View file

@ -0,0 +1,19 @@
# xiaozhi
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

19
web/vue/jsconfig.json Normal file
View file

@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}

8317
web/vue/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

29
web/vue/package.json Normal file
View file

@ -0,0 +1,29 @@
{
"name": "xiaozhi",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"element-ui": "^2.15.14",
"normalize.css": "^8.0.1",
"vue": "^2.6.14",
"vue-router": "^3.5.1",
"vuex": "^3.6.2"
},
"devDependencies": {
"@vue/cli-plugin-router": "~5.0.0",
"@vue/cli-plugin-vuex": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"sass": "^1.32.7",
"sass-loader": "^12.0.0",
"vue-template-compiler": "^2.6.14"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}

BIN
web/vue/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

17
web/vue/public/index.html Normal file
View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

29
web/vue/src/App.vue Normal file
View file

@ -0,0 +1,29 @@
<template>
<div id="app">
<router-view/>
</div>
</template>
<style lang="scss">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
nav {
padding: 30px;
a {
font-weight: bold;
color: #2c3e50;
&.router-link-exact-active {
color: #42b983;
}
}
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 956 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
web/vue/src/assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 876 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View file

@ -0,0 +1,58 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router" target="_blank" rel="noopener">router</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-vuex" target="_blank" rel="noopener">vuex</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>

16
web/vue/src/main.js Normal file
View file

@ -0,0 +1,16 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
Vue.config.productionTip = false
new Vue({
router,
store,
render: function (h) { return h(App) }
}).$mount('#app')

View file

@ -0,0 +1,37 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import Welcome from '../views/welcome.vue'
import Login from '../views/login.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/',
name: 'welcome',
component: Welcome
},
{
path: '/login',
name: 'login',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: function () {
return import(/* webpackChunkName: "about" */ '../views/login.vue')
}
},
{
path: '/home',
name: 'home',
component: function () {
return import(/* webpackChunkName: "about" */ '../views/home.vue')
}
}
]
const router = new VueRouter({
routes
})
export default router

View file

@ -0,0 +1,17 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
},
getters: {
},
mutations: {
},
actions: {
},
modules: {
}
})

600
web/vue/src/views/home.vue Normal file
View file

@ -0,0 +1,600 @@
<template>
<div class="welcome">
<el-container style="height: 100%;">
<el-header class="header">
<div style="display: flex;justify-content: space-between;">
<div style="display: flex;align-items: center;gap: 10px;">
<img src="@/assets/xiaozhi-logo.png" alt="" style="width: 56px;height: 56px;" />
<img src="@/assets/xiaozhi-ai.png" alt="" style="width: 78px;height: 16px;" />
<div class="equipment-management" @click="settingDevice=false">
<img src="@/assets/home/equipment.png" alt="" style="width: 16px;height: 14px;" />
设备管理
</div>
<div class="console">
<i class="el-icon-s-grid" style="font-size: 14px;color: #979db1;" />
控制台
</div>
<div class="equipment-management2">
设备管理
<img src="@/assets/home/close.png" alt="" style="width: 8px;height: 8px;" />
</div>
</div>
<div style="display: flex;align-items: center;gap: 10px;">
<div class="serach-box">
<el-input placeholder="输入名称搜索.." v-model="serach" />
<img src="@/assets/home/search.png" alt=""
style="width: 16px;height: 16px;margin-right: 15px;cursor: pointer;" />
</div>
<img src="@/assets/home/avatar.png" alt="" style="width: 28px;height: 28px;" />
<div class="user-info">
158 3632 4642</div>
</div>
</div>
</el-header>
<el-main style="padding: 20px;display: flex;flex-direction: column;">
<div v-show="!settingDevice">
<div class="add-device">
<div class="add-device-bg">
<div class="hellow-text" style="margin-top: 30px;">
您好,小智</div>
<div class="hellow-text">让我们度过<div style="display: inline-block;color: #5778FF;">
美好的一天!
</div>
</div>
<div class="hi-hint">
Hello, Let's have a wonderful day!</div>
<div class="add-device-btn" @click="showAddDialog">
<div class="left-add">
添加设备
</div>
<div style="width: 23px;height: 13px;background: #5778ff;margin-left: -10px;" />
<div class="right-add">
<i class="el-icon-right" style="font-size: 30px;color: #fff;" />
</div>
</div>
</div>
</div>
<div
style="display: flex;flex-wrap: wrap;margin-top: 20px;gap: 20px;justify-content: space-between;box-sizing: border-box;">
<div class="device-item" v-for="(item,index) in 10" :key="index">
<div style="display: flex;justify-content: space-between;">
<div style="font-weight: 700;font-size: 24px;text-align: left;color: #3d4566;">
CC:ba:97:11:a6:ac
</div>
<div>
<img src="@/assets/home/delete.png" alt=""
style="width: 24px;height: 24px;margin-right: 10px;" />
<img src="@/assets/home/info.png" alt="" style="width: 24px;height: 24px;" />
</div>
</div>
<div class="device-name">
设备型号:esp32-s3-touch-amoled-1.8
</div>
<div style="display: flex;gap: 10px;align-items: center;">
<div class="settings-btn" @click="clickSettingDevice">
配置角色</div>
<div class="settings-btn">
声纹识别</div>
<div class="settings-btn">
历史对话</div>
<el-switch v-model="switchValue" inactive-text="OTA升级:" :width="42"
style="margin-left: auto;" />
</div>
<div class="version-info">
<div>最近对话:6天前</div>
<div>APP版本:1.1.0</div>
</div>
</div>
</div>
</div>
<div v-show="settingDevice" style="border-radius: 20px;background: #fafcfe;">
<div
style="padding: 19px 30px;font-weight: 700;font-size: 24px;text-align: left;color: #3d4566;display: flex;gap: 16px;align-items: center;">
<div
style="width: 46px;height: 46px;background: #5778ff;border-radius: 50%;display: flex;align-items: center;justify-content: center;">
<img src="@/assets/home/setting-user.png" alt="" style="width: 24px;height: 24px;" />
</div>
CC:ba:97:11:a6:ac
</div>
<div style="height: 1px;background: #e8f0ff;" />
<el-form ref="form" :model="form" label-width="90px">
<div style="padding: 20px 30px;max-width: 990px;">
<el-form-item label="助手昵称:">
<div class="input-46">
<el-input v-model="form.name" />
</div>
</el-form-item>
<el-form-item label="角色模版:">
<div style="display: flex;gap: 10px;">
<div class="template-item">
台湾女友</div>
<div class="template-item">
土豆子</div>
<div class="template-item">
英语老师</div>
<div class="template-item">
好奇小男孩</div>
<div class="template-item">
汪汪队队长</div>
</div>
</el-form-item>
<el-form-item label="角色音色:">
<div style="display: flex;gap: 10px;align-items: center;">
<div class="input-46" style="flex:1.4;">
<el-select v-model="form.timbre" placeholder="请选择" style="width: 100%;">
<el-option v-for="item in options" :key="item.value" :label="item.label"
:value="item.value">
</el-option>
</el-select>
</div>
<div class="audio-box">
<audio src="http://music.163.com/song/media/outer/url?id=447925558.mp3" controls
style="height: 100%;width: 100%;" />
</div>
</div>
</el-form-item>
<el-form-item label="角色介绍:">
<div class="textarea-box">
<el-input type="textarea" rows="6" resize="none" placeholder="请输入内容"
v-model="form.introduction" maxlength="2000" show-word-limit />
</div>
</el-form-item>
<el-form-item label="记忆体:">
<div class="textarea-box">
<el-input type="textarea" rows="6" resize="none" placeholder="请输入内容"
v-model="form.prompt" maxlength="1000" />
<div class="prompt-bottom">
<div style="display: flex;gap: 10px;align-items: center;">
<div style="color: #979db1;font-size: 14px;">当前记忆(每次对话后重新生成)</div>
<div class="clear-btn">
<i class="el-icon-delete-solid" style="font-size: 14px;" />
清除
</div>
</div>
<div style="color: #979db1;font-size:14px;">{{form.prompt.length}}/1000</div>
</div>
</div>
</el-form-item>
<el-form-item label="语言模型(内测):" class="lh-form-item">
<div style="display: flex;gap: 10px;">
<div class="input-46" style="width: 100%;">
<el-select v-model="form.model" placeholder="请选择" style="width: 100%;">
<el-option v-for="item in options" :key="item.value" :label="item.label"
:value="item.value">
</el-option>
</el-select>
</div>
</div>
</el-form-item>
<el-form-item label="" class="lh-form-item">
<div style="color: #979db1;text-align: left;">除了“Qwen
实时”,其他模型通常会增加约1秒的延迟。改变模型后,建议清空记忆体,以免影响体验。</div>
</el-form-item>
</div>
</el-form>
<div style="display: flex;padding: 20px;gap: 10px;align-items: center;">
<div class="save-btn">
保存配置</div>
<div class="reset-btn">
重制</div>
<div class="clear-text">
<img src="@/assets/home/red-info.png" alt="" style="width: 24px;height: 24px;" />
保存配置后,需要重启设备,新的配置才会生效。
</div>
</div>
</div>
<div
style="font-size: 12px;font-weight: 400;margin-top: auto;padding-top: 30px;color: #979db1;">
©2025 xiaozhi-esp32-server</div>
</el-main>
</el-container>
<el-dialog :visible.sync="addDeviceDialogVisible" width="480px" center>
<div
style="margin: 0 20px 20px;display: flex;align-items: center;gap: 10px;font-weight: 700;font-size: 20px;text-align: left;color: #3d4566;;">
<div
style="width: 36px;height: 36px;border-radius: 50%;background: #5778ff;display: flex;align-items: center;justify-content: center;">
<img src="@/assets/home/equipment.png" alt="" style="width: 16px;height: 14px;" />
</div>
添加设备
</div>
<div style="height: 1px;background: #e8f0ff;" />
<div style="margin: 30px 20px;">
<div style="font-weight: 400;font-size: 14px;text-align: left;color: #3d4566;">
<div style="color: red;display: inline-block;">*</div>验证码:
</div>
<div class="input-46" style="margin-top: 10px;">
<el-input placeholder="请输入设备播报的6位数验证码.." v-model="deviceCode" />
</div>
</div>
<div style="display: flex;margin: 0 20px;gap: 10px;">
<div class="dialog-btn" @click="addDeviceDialogVisible=false">确定</div>
<div class="dialog-btn"
style="background: #e6ebff;border: 1px solid #adbdff;color: #5778ff;"
@click="addDeviceDialogVisible=false">
取消</div>
</div>
</el-dialog>
</div>
</template>
<script>
// @ is an alias to /src
export default {
name: 'home',
data() {
return {
serach: '',
switchValue: false,
addDeviceDialogVisible: false,
deviceCode: "",
settingDevice: false,
form: {
name: "",
timbre: "",
introduction: "",
prompt: "",
model: ""
},
options: [{
value: '选项1',
label: '黄金糕'
}, {
value: '选项2',
label: '双皮奶'
}]
}
},
methods: {
showAddDialog() {
this.addDeviceDialogVisible = true;
},
clickSettingDevice() {
this.settingDevice = true
}
}
}
</script>
<style scoped lang="scss">
.welcome {
min-width: 1200px;
min-height: 675px;
height: 100vh;
background-image: url("@/assets/home/background.png");
background-size: cover;
/* 确保背景图像覆盖整个元素 */
background-position: center;
/* 从顶部中心对齐 */
-webkit-background-size: cover;
/* 兼容老版本WebKit浏览器 */
-o-background-size: cover;
/* 兼容老版本Opera浏览器 */
}
.equipment-management,
.equipment-management2 {
cursor: pointer;
}
.equipment-management {
width: 110px;
height: 32px;
border-radius: 16px;
background: #5778ff;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
font-weight: 500;
color: #fff;
font-size: 14px;
}
.equipment-management2 {
width: 116px;
height: 30px;
border-radius: 15px;
background: #fff;
display: flex;
justify-content: center;
font-size: 12px;
color: #979db1;
font-weight: 400;
gap: 10px;
color: #3d4566;
margin-left: 20px;
align-items: center;
}
.header {
background: #f6fcfe66;
border: 1px solid #fff;
}
.add-device {
height: 260px;
border-radius: 20px;
position: relative;
overflow: hidden;
background: linear-gradient(
269.62deg,
#e0e6fd 0%,
#cce7ff 49.69%,
#d3d3fe 100%
);
}
.audio-box {
flex: 1;
height: 46px;
border-radius: 10px;
border: 1px solid #e4e6ef;
}
.add-device-bg {
width: 100%;
height: 100%;
text-align: left;
background-image: url("@/assets/home/main-top-bg.png");
overflow: hidden;
background-size: cover;
/* 确保背景图像覆盖整个元素 */
background-position: center;
/* 从顶部中心对齐 */
-webkit-background-size: cover;
/* 兼容老版本WebKit浏览器 */
-o-background-size: cover;
box-sizing: border-box;
/* 兼容老版本Opera浏览器 */
.hellow-text {
margin-left: 100px;
color: #3d4566;
font-size: 44px;
font-weight: 700;
letter-spacing: 0;
}
.hi-hint {
font-weight: 400;
font-size: 12px;
text-align: left;
color: #818cae;
margin-left: 100px;
margin-top: 7px;
}
}
.serach-box {
display: flex;
width: 306px;
height: 40px;
border-radius: 20px;
background-color: #e2f5f7;
align-items: center;
}
.user-info {
font-weight: 600;
font-size: 16px;
letter-spacing: -0.02px;
text-align: left;
color: #3d4566;
}
.clear-btn {
width: 60px;
height: 24px;
background: #fd8383;
border-radius: 12px;
line-height: 24px;
font-size: 14px;
color: #fff;
cursor: pointer;
}
.clear-text {
color: #979db1;
font-size: 14px;
display: flex;
align-items: center;
gap: 10px;
margin-left: 20px;
}
.template-item {
height: 46px;
width: 100px;
border-radius: 10px;
background: #e6ebff;
line-height: 46px;
font-weight: 400;
font-size: 14px;
text-align: center;
color: #5778ff;
}
.prompt-bottom {
margin-bottom: 5px;display: flex;justify-content: space-between;padding: 0 20px;align-items: center;
}
.input-46 {
border: 1px solid #e4e6ef;
background: #f6f8fb;
border-radius: 10px;
}
.console {
width: 120px;
height: 30px;
border-radius: 15px;
background: radial-gradient(50% 50% at 50% 50%, #fff 0%, #e8f0ff 100%);
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
color: #979db1;
font-weight: 400;
gap: 10px;
color: #979db1;
margin-left: 20px;
}
.dialog-btn {
cursor: pointer;
flex: 1;
border-radius: 23px;
background: #5778ff;
height: 46px;
font-weight: 500;
font-size: 14px;
color: #fff;
line-height: 46px;
text-align: center;
}
.add-device-btn {
display: flex;
align-items: center;
margin-left: 100px;
margin-top: 20px;
cursor: pointer;
.left-add {
width: 140px;
height: 46px;
border-radius: 23px;
background: #5778ff;
color: #fff;
font-size: 14px;
font-weight: 500;
text-align: center;
line-height: 46px;
}
.right-add {
width: 46px;
height: 46px;
border-radius: 50%;
background: #5778ff;
margin-left: -8px;
display: flex;
justify-content: center;
align-items: center;
}
}
.device-item {
width: 455px;
border-radius: 20px;
background: #fafcfe;
padding: 30px;
box-sizing: border-box;
}
.device-name {
margin: 10px 0 14px;
font-weight: 400;
font-size: 14px;
color: #3d4566;
text-align: left;
}
audio::-webkit-media-controls-panel {
background-color: #fafcfe; /* 设置音频面板的控制按钮背景颜色为透明 */
}
.settings-btn {
font-weight: 500;
font-size: 14px;
color: #5778ff;
background: #e6ebff;
width: 76px;
height: 28px;
line-height: 28px;
cursor: pointer;
border-radius: 14px;
}
.version-info {
display: flex;
justify-content: space-between;
margin-top: 20px;
font-size: 14px;
color: #979db1;
font-weight: 400;
}
.save-btn,
.reset-btn {
width: 140px;
height: 46px;
border-radius: 23px;
line-height: 46px;
box-sizing: border-box;
cursor: pointer;
}
.save-btn {
border-radius: 23px;
background: #5778ff;
color: #fff;
}
.reset-btn {
border: 1px solid #adbdff;
background: #e6ebff;
color: #5778ff;
}
.textarea-box {
border: 1px solid #e4e6ef;
border-radius: 10px;
background: #f6f8fb;
}
::v-deep {
.textarea-box .el-textarea__inner {
background-color: transparent !important;
border: none !important;
padding: 20px;
}
.el-textarea .el-input__count {
color: #979db1;
font-size: 14px;
right: 20px;
background-color: transparent;
}
.el-input__inner {
border: none;
background-color: transparent;
padding: 0 5px 0 15px;
}
.input-46 .el-input__inner {
padding: 0 15px;
height: 46px;
}
.lh-form-item {
.el-form-item__label {
line-height: 23px;
}
}
.el-form-item__label {
line-height: 46px;
font-weight: 400;
font-size: 14px;
text-align: left;
color: #3d4566;
}
.el-switch__core {
height: 28px;
border-radius: 14px;
}
.el-switch {
line-height: 28x;
}
.el-switch.is-checked .el-switch__core::after {
left: calc(100% - 6px);
}
.el-switch__label {
color: #3d4566;
}
.el-switch__core:after {
left: 4px;
width: 20px;
height: 20px;
top: 3px;
}
.el-dialog__headerbtn .el-dialog__close {
display: none;
}
.el-dialog__header,
.el-dialog__footer {
padding: 0;
}
.el-dialog--center .el-dialog__body {
padding: 24px 0;
}
.el-dialog {
display: flex !important;
flex-direction: column !important;
margin: 0 !important;
position: absolute !important;
top: 50% !important;
left: 50% !important;
transform: translate(-50%, -50%) !important;
overflow-y: scroll !important;
max-height: 100vh !important;
border-radius: 20px;
}
}
</style>

219
web/vue/src/views/login.vue Normal file
View file

@ -0,0 +1,219 @@
<template>
<div class="welcome">
<el-container style="height: 100%;">
<el-header>
<div
style="display: flex;align-items: center;margin-top: 25px;margin-left: 30px;gap: 10px;">
<img src="@/assets/xiaozhi-logo.png" alt="" style="width: 56px;height: 56px;" />
<img src="@/assets/xiaozhi-ai.png" alt="" style="width: 78px;height: 16px;" />
</div>
</el-header>
<el-main style="position: relative;">
<div class="login-box">
<div
style="display: flex;align-items: center;gap: 20px;margin-bottom: 39px;padding: 0 30px;">
<img src="@/assets/login/hi.png" alt="" style="width: 34px;height: 34px;" />
<div class="login-text">登录</div>
<div class="login-welcome">
Welcome to log in</div>
</div>
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="用户名" name="username">
<div style="padding: 0 30px;">
<div class="input-box">
<img src="@/assets/login/username.png" alt="" class="input-icon" />
<el-input v-model="form.username" placeholder="请输入用户名" />
</div>
<div class="input-box">
<img src="@/assets/login/password.png" alt="" class="input-icon" />
<el-input v-model="form.password" placeholder="请输入密码" />
</div>
<div style="font-weight: 400;font-size: 16px;text-align: left;color: #5778ff;display: flex;justify-content: space-between;margin-top: 20px;">
<div style="cursor: pointer;">新用户注册</div>
<div style="cursor: pointer;">忘记密码?</div>
</div>
</div>
</el-tab-pane>
<el-tab-pane label="手机号" name="phone">
<div style="padding: 0 30px;">
<div class="input-box">
<img src="@/assets/login/phone.png" alt="" class="input-icon" />
<el-input v-model="form.phoneNumber" placeholder="请输入手机号" />
<div style="width: 120px;flex-shrink: 0;">
<el-dropdown>
<span class="el-dropdown-link">
+86 中国大陆<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>黄金糕</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
<div style="padding: 0 12px 0 30px;margin-top: 20px;" class="input-box">
<img src="@/assets/login/shield.png" alt="" class="input-icon" />
<el-input v-model="form.phoneCode" placeholder="请输入验证码" />
<div class="code-send">
发送
</div>
</div>
</div>
</el-tab-pane>
</el-tabs>
<div class="login-btn">登陆</div>
<div style="font-size: 16px;color: #979db1;">
登录即同意<div style="display: inline-block;color: #5778FF;cursor: pointer;">《用户协议》</div>和
<div style="display: inline-block;color: #5778FF;cursor: pointer;">《隐私政策》</div>
</div>
</div>
</el-main>
<el-footer>
<div style="font-size: 12px;font-weight: 400;color: #979db1;">
©2025 xiaozhi-esp32-server</div>
</el-footer>
</el-container>
</div>
</template>
<script>
// @ is an alias to /src
export default {
name: 'login',
data() {
return {
activeName: "username",
form:{
phoneNumber:'',
phoneCode:'',
username:'',
password:''
}
}
},
methods:{
handleClick(){
}
}
}
</script>
<style scoped lang="scss">
.welcome {
min-width: 1200px;
min-height: 675px;
height: 100vh;
background-image: url("@/assets/login/background.png");
background-size: cover;
/* 确保背景图像覆盖整个元素 */
background-position: center;
/* 从顶部中心对齐 */
-webkit-background-size: cover;
/* 兼容老版本WebKit浏览器 */
-o-background-size: cover;
/* 兼容老版本Opera浏览器 */
}
.login-text {
font-weight: 700;
font-size: 48px;
text-align: left;
color: #3d4566;
}
.login-welcome {
font-weight: 400;
font-size: 12px;
text-align: left;
color: #818cae;
align-self: flex-end;
margin-bottom: 7px;
}
.login-box {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 18%;
background-color: #fff;
border-radius: 20px;
padding: 36px 0;
width: 550px;
box-sizing: border-box;
}
.el-dropdown-link {
font-weight: 400;
font-size: 16px;
text-align: left;
color: #979db1;
}
.input-icon {
width: 19px;
height: 22px;
flex-shrink: 0;
}
.login-btn {
height: 50px;
background: #5778ff;
border-radius: 10px;
font-weight: 400;
font-size: 18px;
cursor: pointer;
color: #fff;
line-height: 50px;
margin: 82px 30px 20px;
}
.code-send {
width: 80px;
height: 38px;
border-radius: 10px;
background: #e6ebff;
line-height: 38px;
font-weight: 400;
font-size: 16px;
color: #5778ff;
flex-shrink: 0;
cursor: pointer;
}
.input-box {
display: flex;
margin-top: 20px;
align-items: center;
border-radius: 10px;
background: #f6f8fb;
border: 1px solid #e4e6ef;
height: 56px;
padding: 0 30px;
gap: 20px;
}
::v-deep {
.el-tabs__nav-wrap::after {
height: 1px;
}
.el-tabs__nav-wrap::before {
content: "";
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 1px;
background-color: #e4e7ed;
z-index: 1;
}
.el-tabs__item {
height: 65px;
line-height: 65px;
font-weight: 700;
color: #3d4566;
}
.el-tabs__item.is-active {
color: #5778ff;
}
.el-tabs__nav-scroll {
padding: 0 30px;
}
.el-input__inner {
border: none;
background-color: transparent;
height: 56px;
padding: 0;
}
}
</style>

View file

@ -0,0 +1,121 @@
<template>
<div class="welcome">
<el-container style="height: 100%;">
<el-header>
<div
style="display: flex;align-items: center;margin-top: 25px;margin-left: 30px;gap: 10px;">
<img src="@/assets/xiaozhi-logo.png" alt="" style="width: 56px;height: 56px;" />
<img src="@/assets/xiaozhi-ai.png" alt="" style="width: 78px;height: 16px;" />
</div>
</el-header>
<el-main style="position: relative;">
<div style="margin-left: 18%;position: absolute;top: 50%;transform: translateY(-50%);">
<div style="display: flex;align-items: center;margin-bottom: 27px;">
<div class="left-pillar" />
<div class="hi-text-bg" />
<div class="hi-text">Hi,小智</div>
</div>
<div class="introduction">让我们一起探索</div>
<div class="introduction">人工智能与机器人技术</div>
<div class="introduction">的迷人世界!</div>
<div class="hint"
style="text-align: left;font-weight: 400;font-size: 12px;text-align: left;color: #818cae;">
Let's explore the fascinating world
</div>
<div style="margin-top: 107px;display: flex;gap: 20px;">
<div class="btn">
<img src="@/assets/welcome/questions.png" alt="" class="btn-icon" />
DIY教程
</div>
<div class="btn">
<img src="@/assets/welcome/github.png" alt="" class="btn-icon" />
GitHub
</div>
<div class="btn" style="background: #5778ff;color: #fff;" @click="jumpHome">
<img src="@/assets/welcome/more.png" alt="" class="btn-icon" />
控制台
</div>
</div>
</div>
</el-main>
<el-footer>
<div style="font-size: 12px;font-weight: 400;color: #3D4566">
©2025 xiaozhi-esp32-server</div>
</el-footer>
</el-container>
</div>
</template>
<script>
// @ is an alias to /src
export default {
name: 'home',
methods:{
jumpHome(){
this.$router.push('/home')
}
}
}
</script>
<style scoped lang="scss">
.welcome {
min-width: 1200px;
min-height: 675px;
height: 100vh;
background-image: url("@/assets/welcome/background.png");
background-size: cover;
/* 确保背景图像覆盖整个元素 */
background-position: center;
/* 从顶部中心对齐 */
-webkit-background-size: cover;
/* 兼容老版本WebKit浏览器 */
-o-background-size: cover;
/* 兼容老版本Opera浏览器 */
}
.left-pillar {
width: 4px;
height: 36px;
background: #5778ff;
}
.hi-text-bg {
width: 129px;
height: 36px;
background: linear-gradient(90.66deg, #5778ff 0%, #f5f6fa00 100%);
opacity: 0.5;
}
.hi-text {
line-height: 36px;
font-weight: 700;
font-size: 18px;
text-align: left;
color: #3d4566;
padding-left: 14px;
position: absolute;
}
.introduction {
font-weight: 700;
font-size: 54px;
text-align: left;
color: #3d4566;
}
.btn {
width: 140px;
height: 56px;
align-items: center;
justify-content: center;
border-radius: 28px;
display: flex;
gap: 10px;
font-weight: 400;
font-size: 16px;
text-align: left;
color: #3d4566;
cursor: pointer;
background-color: #fff;
}
.btn-icon {
width: 16px;
height: 16px;
}
</style>